]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Merge branch 'drm-patches' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied...
authorLinus Torvalds <torvalds@woody.osdl.org>
Sat, 9 Dec 2006 20:26:37 +0000 (12:26 -0800)
committerLinus Torvalds <torvalds@woody.osdl.org>
Sat, 9 Dec 2006 20:26:37 +0000 (12:26 -0800)
* 'drm-patches' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6: (21 commits)
  Fix http://bugzilla.kernel.org/show_bug.cgi?id=7606
  drm: add flag for mapping PCI DMA buffers read-only.
  drm: fix up irqflags in drm_lock.c
  drm: i915 updates
  drm: i915: fix up irqflags arg
  drm: i915: Only return EBUSY after we've established we need to schedule a new swap.
  drm: i915: Fix 'sequence has passed' condition in i915_vblank_swap().
  drm: i915: Add SAREA fileds for determining which pipe to sync window buffer swaps to.
  drm: Make handling of dev_priv->vblank_pipe more robust.
  drm: DRM_I915_VBLANK_SWAP ioctl: Take drm_vblank_seq_type_t instead
  drm: i915: Add ioctl for scheduling buffer swaps at vertical blanks.
  drm: Core vsync: Don't clobber target sequence number when scheduling signal.
  drm: Core vsync: Add flag DRM_VBLANK_NEXTONMISS.
  drm: Make locked tasklet handling more robust.
  drm: drm_rmdraw: Declare id and idx as signed so testing for < 0 works as intended.
  drm: Change first valid DRM drawable ID to be 1 instead of 0.
  drm: drawable locking + memory management fixes + copyright
  drm: Add support for interrupt triggered driver callback with lock held to DRM core.
  drm: Add support for tracking drawable information to core
  drm: add support for secondary vertical blank interrupt to i915
  ...

2395 files changed:
CREDITS
Documentation/ABI/testing/debugfs-pktcdvd [new file with mode: 0644]
Documentation/ABI/testing/sysfs-class-pktcdvd [new file with mode: 0644]
Documentation/DMA-API.txt
Documentation/DocBook/kernel-api.tmpl
Documentation/IPMI.txt
Documentation/block/as-iosched.txt
Documentation/cdrom/packet-writing.txt
Documentation/devices.txt
Documentation/fault-injection/failcmd.sh [new file with mode: 0644]
Documentation/fault-injection/failmodule.sh [new file with mode: 0644]
Documentation/fault-injection/fault-injection.txt [new file with mode: 0644]
Documentation/feature-removal-schedule.txt
Documentation/filesystems/Locking
Documentation/filesystems/fuse.txt
Documentation/filesystems/sysv-fs.txt
Documentation/i386/boot.txt
Documentation/ioctl-number.txt
Documentation/kernel-parameters.txt
Documentation/networking/00-INDEX
Documentation/networking/generic_netlink.txt [new file with mode: 0644]
Documentation/power/s2ram.txt [new file with mode: 0644]
Documentation/power/swsusp-and-swap-files.txt [new file with mode: 0644]
Documentation/power/swsusp.txt
Documentation/power/userland-swsusp.txt
Documentation/s390/driver-model.txt
Documentation/stable_api_nonsense.txt
Documentation/sysctl/kernel.txt
Documentation/x86_64/boot-options.txt
MAINTAINERS
REPORTING-BUGS
arch/alpha/Kconfig
arch/alpha/kernel/osf_sys.c
arch/alpha/kernel/pci.c
arch/alpha/kernel/sys_miata.c
arch/alpha/kernel/sys_nautilus.c
arch/alpha/mm/fault.c
arch/arm/Kconfig
arch/arm/Kconfig.debug
arch/arm/Makefile
arch/arm/common/gic.c
arch/arm/common/locomo.c
arch/arm/common/sa1111.c
arch/arm/common/vic.c
arch/arm/configs/at91rm9200dk_defconfig
arch/arm/configs/at91rm9200ek_defconfig
arch/arm/configs/at91sam9260ek_defconfig [new file with mode: 0644]
arch/arm/configs/at91sam9261ek_defconfig [new file with mode: 0644]
arch/arm/configs/badge4_defconfig
arch/arm/configs/carmeva_defconfig
arch/arm/configs/cerfcube_defconfig
arch/arm/configs/collie_defconfig
arch/arm/configs/corgi_defconfig
arch/arm/configs/csb337_defconfig
arch/arm/configs/csb637_defconfig
arch/arm/configs/ep93xx_defconfig
arch/arm/configs/h7202_defconfig
arch/arm/configs/hackkit_defconfig
arch/arm/configs/integrator_defconfig
arch/arm/configs/iop13xx_defconfig [new file with mode: 0644]
arch/arm/configs/iop32x_defconfig
arch/arm/configs/iop33x_defconfig
arch/arm/configs/ixp2000_defconfig
arch/arm/configs/ixp23xx_defconfig
arch/arm/configs/ixp4xx_defconfig
arch/arm/configs/jornada720_defconfig
arch/arm/configs/kb9202_defconfig
arch/arm/configs/lpd270_defconfig
arch/arm/configs/lpd7a400_defconfig
arch/arm/configs/lpd7a404_defconfig
arch/arm/configs/lubbock_defconfig
arch/arm/configs/mainstone_defconfig
arch/arm/configs/mx1ads_defconfig
arch/arm/configs/neponset_defconfig
arch/arm/configs/netwinder_defconfig
arch/arm/configs/netx_defconfig
arch/arm/configs/onearm_defconfig
arch/arm/configs/pleb_defconfig
arch/arm/configs/pnx4008_defconfig
arch/arm/configs/pxa255-idp_defconfig
arch/arm/configs/realview-smp_defconfig
arch/arm/configs/realview_defconfig
arch/arm/configs/rpc_defconfig
arch/arm/configs/s3c2410_defconfig
arch/arm/configs/shark_defconfig
arch/arm/configs/simpad_defconfig
arch/arm/configs/spitz_defconfig
arch/arm/configs/versatile_defconfig
arch/arm/kernel/Makefile
arch/arm/kernel/apm.c
arch/arm/kernel/asm-offsets.c
arch/arm/kernel/ecard.c
arch/arm/kernel/entry-armv.S
arch/arm/kernel/head-nommu.S
arch/arm/kernel/head.S
arch/arm/kernel/irq.c
arch/arm/kernel/iwmmxt-notifier.c [deleted file]
arch/arm/kernel/process.c
arch/arm/kernel/setup.c
arch/arm/kernel/signal.c
arch/arm/kernel/traps.c
arch/arm/kernel/xscale-cp0.c [new file with mode: 0644]
arch/arm/mach-aaec2000/core.c
arch/arm/mach-at91rm9200/Kconfig
arch/arm/mach-at91rm9200/Makefile
arch/arm/mach-at91rm9200/at91rm9200.c
arch/arm/mach-at91rm9200/at91rm9200_devices.c [moved from arch/arm/mach-at91rm9200/devices.c with 83% similarity]
arch/arm/mach-at91rm9200/at91rm9200_time.c
arch/arm/mach-at91rm9200/at91sam9260.c [new file with mode: 0644]
arch/arm/mach-at91rm9200/at91sam9260_devices.c [new file with mode: 0644]
arch/arm/mach-at91rm9200/at91sam9261.c [new file with mode: 0644]
arch/arm/mach-at91rm9200/at91sam9261_devices.c [new file with mode: 0644]
arch/arm/mach-at91rm9200/at91sam926x_time.c [new file with mode: 0644]
arch/arm/mach-at91rm9200/board-carmeva.c
arch/arm/mach-at91rm9200/board-csb337.c
arch/arm/mach-at91rm9200/board-dk.c
arch/arm/mach-at91rm9200/board-eb9200.c
arch/arm/mach-at91rm9200/board-ek.c
arch/arm/mach-at91rm9200/board-kb9202.c
arch/arm/mach-at91rm9200/board-sam9260ek.c [new file with mode: 0644]
arch/arm/mach-at91rm9200/board-sam9261ek.c [new file with mode: 0644]
arch/arm/mach-at91rm9200/clock.c
arch/arm/mach-at91rm9200/clock.h
arch/arm/mach-at91rm9200/generic.h
arch/arm/mach-at91rm9200/gpio.c
arch/arm/mach-at91rm9200/irq.c
arch/arm/mach-at91rm9200/pm.c
arch/arm/mach-clps711x/irq.c
arch/arm/mach-clps7500/core.c
arch/arm/mach-ebsa110/core.c
arch/arm/mach-ep93xx/Kconfig
arch/arm/mach-ep93xx/Makefile
arch/arm/mach-ep93xx/adssphere.c [new file with mode: 0644]
arch/arm/mach-ep93xx/core.c
arch/arm/mach-ep93xx/edb9302a.c [new file with mode: 0644]
arch/arm/mach-footbridge/common.c
arch/arm/mach-footbridge/isa-irq.c
arch/arm/mach-h720x/common.c
arch/arm/mach-h720x/cpu-h7202.c
arch/arm/mach-imx/generic.c
arch/arm/mach-imx/irq.c
arch/arm/mach-imx/time.c
arch/arm/mach-integrator/integrator_ap.c
arch/arm/mach-integrator/integrator_cp.c
arch/arm/mach-integrator/platsmp.c
arch/arm/mach-iop13xx/Kconfig [new file with mode: 0644]
arch/arm/mach-iop13xx/Makefile [new file with mode: 0644]
arch/arm/mach-iop13xx/Makefile.boot [new file with mode: 0644]
arch/arm/mach-iop13xx/io.c [new file with mode: 0644]
arch/arm/mach-iop13xx/iq81340mc.c [new file with mode: 0644]
arch/arm/mach-iop13xx/iq81340sc.c [new file with mode: 0644]
arch/arm/mach-iop13xx/irq.c [new file with mode: 0644]
arch/arm/mach-iop13xx/pci.c [new file with mode: 0644]
arch/arm/mach-iop13xx/setup.c [new file with mode: 0644]
arch/arm/mach-iop13xx/time.c [new file with mode: 0644]
arch/arm/mach-iop32x/irq.c
arch/arm/mach-iop33x/irq.c
arch/arm/mach-ixp2000/core.c
arch/arm/mach-ixp2000/ixdp2x00.c
arch/arm/mach-ixp2000/ixdp2x01.c
arch/arm/mach-ixp2000/pci.c
arch/arm/mach-ixp23xx/core.c
arch/arm/mach-ixp23xx/ixdp2351.c
arch/arm/mach-ixp23xx/pci.c
arch/arm/mach-ixp4xx/common.c
arch/arm/mach-l7200/core.c
arch/arm/mach-lh7a40x/arch-kev7a400.c
arch/arm/mach-lh7a40x/arch-lpd7a40x.c
arch/arm/mach-lh7a40x/irq-kev7a400.c
arch/arm/mach-lh7a40x/irq-lh7a400.c
arch/arm/mach-lh7a40x/irq-lh7a404.c
arch/arm/mach-lh7a40x/irq-lpd7a40x.c
arch/arm/mach-netx/generic.c
arch/arm/mach-omap1/devices.c
arch/arm/mach-omap1/fpga.c
arch/arm/mach-omap1/irq.c
arch/arm/mach-omap2/irq.c
arch/arm/mach-pnx4008/irq.c
arch/arm/mach-pxa/Kconfig
arch/arm/mach-pxa/generic.c
arch/arm/mach-pxa/irq.c
arch/arm/mach-pxa/lpd270.c
arch/arm/mach-pxa/lubbock.c
arch/arm/mach-pxa/mainstone.c
arch/arm/mach-pxa/pm.c
arch/arm/mach-pxa/time.c
arch/arm/mach-rpc/irq.c
arch/arm/mach-s3c2410/Kconfig
arch/arm/mach-s3c2410/Makefile
arch/arm/mach-s3c2410/bast-irq.c
arch/arm/mach-s3c2410/dma.c
arch/arm/mach-s3c2410/irq.c
arch/arm/mach-s3c2410/irq.h
arch/arm/mach-s3c2410/mach-h1940.c
arch/arm/mach-s3c2410/mach-osiris.c
arch/arm/mach-s3c2410/mach-rx3715.c
arch/arm/mach-s3c2410/mach-vr1000.c
arch/arm/mach-s3c2410/pm-h1940.S [new file with mode: 0644]
arch/arm/mach-s3c2410/s3c2410-pm.c
arch/arm/mach-s3c2410/s3c2412-irq.c
arch/arm/mach-s3c2410/s3c2440-irq.c
arch/arm/mach-s3c2410/s3c244x-irq.c
arch/arm/mach-sa1100/generic.c
arch/arm/mach-sa1100/h3600.c
arch/arm/mach-sa1100/irq.c
arch/arm/mach-sa1100/neponset.c
arch/arm/mach-sa1100/time.c
arch/arm/mach-shark/irq.c
arch/arm/mach-versatile/core.c
arch/arm/mach-versatile/versatile_pb.c
arch/arm/mm/Kconfig
arch/arm/mm/fault.c
arch/arm/mm/mm.h
arch/arm/mm/mmu.c
arch/arm/mm/nommu.c
arch/arm/mm/proc-arm1020.S
arch/arm/mm/proc-arm1020e.S
arch/arm/mm/proc-arm1022.S
arch/arm/mm/proc-arm1026.S
arch/arm/mm/proc-arm6_7.S
arch/arm/mm/proc-arm720.S
arch/arm/mm/proc-arm740.S
arch/arm/mm/proc-arm7tdmi.S
arch/arm/mm/proc-arm920.S
arch/arm/mm/proc-arm922.S
arch/arm/mm/proc-arm925.S
arch/arm/mm/proc-arm926.S
arch/arm/mm/proc-arm940.S
arch/arm/mm/proc-arm946.S
arch/arm/mm/proc-arm9tdmi.S
arch/arm/mm/proc-sa110.S
arch/arm/mm/proc-sa1100.S
arch/arm/mm/proc-v6.S
arch/arm/mm/proc-xsc3.S
arch/arm/mm/proc-xscale.S
arch/arm/plat-omap/gpio.c
arch/arm/tools/mach-types
arch/arm26/Kconfig
arch/arm26/kernel/ecard.c
arch/arm26/mm/fault.c
arch/arm26/mm/memc.c
arch/avr32/Kconfig
arch/avr32/kernel/kprobes.c
arch/avr32/kernel/signal.c
arch/avr32/mm/dma-coherent.c
arch/cris/Kconfig
arch/cris/arch-v32/drivers/sync_serial.c
arch/cris/mm/fault.c
arch/frv/Kconfig
arch/frv/kernel/futex.c
arch/frv/kernel/setup.c
arch/frv/kernel/signal.c
arch/frv/mm/elf-fdpic.c
arch/frv/mm/fault.c
arch/frv/mm/pgalloc.c
arch/h8300/Kconfig
arch/h8300/kernel/setup.c
arch/h8300/kernel/signal.c
arch/h8300/kernel/vmlinux.lds.S
arch/i386/Kconfig
arch/i386/Kconfig.cpu
arch/i386/Kconfig.debug
arch/i386/Makefile
arch/i386/Makefile.cpu
arch/i386/boot/compressed/Makefile
arch/i386/boot/compressed/head.S
arch/i386/boot/compressed/misc.c
arch/i386/boot/compressed/relocs.c [new file with mode: 0644]
arch/i386/boot/compressed/vmlinux.lds [new file with mode: 0644]
arch/i386/boot/compressed/vmlinux.scr
arch/i386/boot/setup.S
arch/i386/defconfig
arch/i386/kernel/Makefile
arch/i386/kernel/acpi/cstate.c
arch/i386/kernel/acpi/earlyquirk.c
arch/i386/kernel/alternative.c
arch/i386/kernel/apic.c
arch/i386/kernel/apm.c
arch/i386/kernel/asm-offsets.c
arch/i386/kernel/cpu/amd.c
arch/i386/kernel/cpu/common.c
arch/i386/kernel/cpu/intel.c
arch/i386/kernel/cpu/intel_cacheinfo.c
arch/i386/kernel/cpu/mcheck/therm_throt.c
arch/i386/kernel/cpu/mtrr/Makefile
arch/i386/kernel/cpu/mtrr/amd.c
arch/i386/kernel/cpu/mtrr/centaur.c
arch/i386/kernel/cpu/mtrr/cyrix.c
arch/i386/kernel/cpu/mtrr/generic.c
arch/i386/kernel/cpu/mtrr/if.c
arch/i386/kernel/cpu/mtrr/main.c
arch/i386/kernel/cpu/mtrr/mtrr.h
arch/i386/kernel/cpu/proc.c
arch/i386/kernel/cpuid.c
arch/i386/kernel/crash.c
arch/i386/kernel/e820.c [new file with mode: 0644]
arch/i386/kernel/efi.c
arch/i386/kernel/entry.S
arch/i386/kernel/head.S
arch/i386/kernel/hpet.c
arch/i386/kernel/i8259.c
arch/i386/kernel/io_apic.c
arch/i386/kernel/kprobes.c
arch/i386/kernel/ldt.c
arch/i386/kernel/mca.c
arch/i386/kernel/microcode.c
arch/i386/kernel/module.c
arch/i386/kernel/mpparse.c
arch/i386/kernel/msr.c
arch/i386/kernel/nmi.c
arch/i386/kernel/paravirt.c [new file with mode: 0644]
arch/i386/kernel/pci-dma.c
arch/i386/kernel/process.c
arch/i386/kernel/ptrace.c
arch/i386/kernel/quirks.c
arch/i386/kernel/reboot.c
arch/i386/kernel/setup.c
arch/i386/kernel/signal.c
arch/i386/kernel/smp.c
arch/i386/kernel/smpboot.c
arch/i386/kernel/sysenter.c
arch/i386/kernel/time.c
arch/i386/kernel/time_hpet.c
arch/i386/kernel/topology.c
arch/i386/kernel/traps.c
arch/i386/kernel/tsc.c
arch/i386/kernel/vm86.c
arch/i386/kernel/vmlinux.lds.S
arch/i386/mach-generic/probe.c
arch/i386/mach-visws/setup.c
arch/i386/mach-voyager/voyager_cat.c
arch/i386/mach-voyager/voyager_smp.c
arch/i386/math-emu/fpu_emu.h
arch/i386/math-emu/fpu_entry.c
arch/i386/math-emu/fpu_system.h
arch/i386/math-emu/load_store.c
arch/i386/math-emu/reg_ld_str.c
arch/i386/mm/boot_ioremap.c
arch/i386/mm/discontig.c
arch/i386/mm/fault.c
arch/i386/mm/highmem.c
arch/i386/mm/hugetlbpage.c
arch/i386/mm/init.c
arch/i386/mm/pageattr.c
arch/i386/mm/pgtable.c
arch/i386/pci/early.c
arch/i386/pci/irq.c
arch/i386/pci/pcbios.c
arch/i386/power/Makefile
arch/i386/power/cpu.c
arch/i386/power/suspend.c [new file with mode: 0644]
arch/i386/power/swsusp.S
arch/ia64/Kconfig
arch/ia64/hp/common/sba_iommu.c
arch/ia64/hp/sim/simserial.c
arch/ia64/ia32/binfmt_elf32.c
arch/ia64/ia32/ia32_support.c
arch/ia64/ia32/ia32priv.h
arch/ia64/ia32/sys_ia32.c
arch/ia64/kernel/Makefile
arch/ia64/kernel/cpufreq/acpi-cpufreq.c
arch/ia64/kernel/crash.c [new file with mode: 0644]
arch/ia64/kernel/efi.c
arch/ia64/kernel/entry.S
arch/ia64/kernel/ia64_ksyms.c
arch/ia64/kernel/iosapic.c
arch/ia64/kernel/kprobes.c
arch/ia64/kernel/machine_kexec.c [new file with mode: 0644]
arch/ia64/kernel/mca.c
arch/ia64/kernel/palinfo.c
arch/ia64/kernel/perfmon.c
arch/ia64/kernel/perfmon_montecito.h
arch/ia64/kernel/relocate_kernel.S [new file with mode: 0644]
arch/ia64/kernel/salinfo.c
arch/ia64/kernel/setup.c
arch/ia64/kernel/smp.c
arch/ia64/kernel/topology.c
arch/ia64/lib/ip_fast_csum.S
arch/ia64/mm/hugetlbpage.c
arch/ia64/mm/init.c
arch/ia64/pci/pci.c
arch/ia64/sn/kernel/irq.c
arch/ia64/sn/kernel/msi_sn.c
arch/ia64/sn/kernel/setup.c
arch/m32r/Kconfig
arch/m32r/boot/compressed/m32r_sio.c
arch/m32r/kernel/entry.S
arch/m32r/kernel/io_opsput.c
arch/m32r/kernel/setup.c
arch/m32r/kernel/setup_opsput.c
arch/m32r/kernel/signal.c
arch/m32r/mm/discontig.c
arch/m32r/mm/fault.c
arch/m68k/Kconfig
arch/m68k/amiga/chipram.c
arch/m68k/atari/hades-pci.c
arch/m68k/atari/stdma.c
arch/m68k/kernel/sun3-head.S
arch/m68k/kernel/vmlinux-sun3.lds
arch/m68k/mm/fault.c
arch/m68k/mm/memory.c
arch/m68k/mm/sun3mmu.c
arch/m68knommu/Kconfig
arch/m68knommu/kernel/vmlinux.lds.S
arch/mips/Kconfig
arch/mips/Makefile
arch/mips/configs/atlas_defconfig
arch/mips/configs/bigsur_defconfig
arch/mips/configs/capcella_defconfig
arch/mips/configs/cobalt_defconfig
arch/mips/configs/db1000_defconfig
arch/mips/configs/db1100_defconfig
arch/mips/configs/db1200_defconfig
arch/mips/configs/db1500_defconfig
arch/mips/configs/db1550_defconfig
arch/mips/configs/ddb5477_defconfig
arch/mips/configs/decstation_defconfig
arch/mips/configs/e55_defconfig
arch/mips/configs/emma2rh_defconfig
arch/mips/configs/ev64120_defconfig
arch/mips/configs/excite_defconfig
arch/mips/configs/ip22_defconfig
arch/mips/configs/ip27_defconfig
arch/mips/configs/ip32_defconfig
arch/mips/configs/jaguar-atx_defconfig
arch/mips/configs/jazz_defconfig
arch/mips/configs/jmr3927_defconfig
arch/mips/configs/lasat200_defconfig
arch/mips/configs/malta_defconfig
arch/mips/configs/mipssim_defconfig
arch/mips/configs/mpc30x_defconfig
arch/mips/configs/ocelot_3_defconfig
arch/mips/configs/ocelot_c_defconfig
arch/mips/configs/ocelot_defconfig
arch/mips/configs/ocelot_g_defconfig
arch/mips/configs/pb1100_defconfig
arch/mips/configs/pb1500_defconfig
arch/mips/configs/pb1550_defconfig
arch/mips/configs/pnx8550-jbs_defconfig
arch/mips/configs/pnx8550-stb810_defconfig [new file with mode: 0644]
arch/mips/configs/pnx8550-v2pci_defconfig
arch/mips/configs/qemu_defconfig
arch/mips/configs/rbhma4500_defconfig
arch/mips/configs/rm200_defconfig
arch/mips/configs/sb1250-swarm_defconfig
arch/mips/configs/sead_defconfig
arch/mips/configs/tb0226_defconfig
arch/mips/configs/tb0229_defconfig
arch/mips/configs/tb0287_defconfig
arch/mips/configs/workpad_defconfig
arch/mips/configs/wrppmc_defconfig
arch/mips/configs/yosemite_defconfig
arch/mips/defconfig
arch/mips/kernel/binfmt_elfn32.c
arch/mips/kernel/binfmt_elfo32.c
arch/mips/kernel/head.S
arch/mips/kernel/irixelf.c
arch/mips/kernel/rtlx.c
arch/mips/kernel/sysirix.c
arch/mips/kernel/vpe.c
arch/mips/lasat/sysctl.c
arch/mips/lib/csum_partial.S
arch/mips/mm/dma-coherent.c
arch/mips/mm/dma-ip27.c
arch/mips/mm/dma-ip32.c
arch/mips/mm/dma-noncoherent.c
arch/mips/mm/highmem.c
arch/mips/mm/ioremap.c
arch/mips/pci/Makefile
arch/mips/pci/fixup-pnx8550.c
arch/mips/philips/pnx8550/common/prom.c
arch/mips/philips/pnx8550/jbs/irqmap.c
arch/mips/philips/pnx8550/stb810/Makefile [new file with mode: 0644]
arch/mips/philips/pnx8550/stb810/board_setup.c [new file with mode: 0644]
arch/mips/philips/pnx8550/stb810/irqmap.c [new file with mode: 0644]
arch/mips/philips/pnx8550/stb810/prom_init.c [new file with mode: 0644]
arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
arch/mips/vr41xx/Kconfig
arch/mips/vr41xx/nec-cmbvr4133/irq.c
arch/parisc/Kconfig
arch/parisc/hpux/sys_hpux.c
arch/parisc/kernel/binfmt_elf32.c
arch/parisc/mm/fault.c
arch/parisc/mm/ioremap.c
arch/powerpc/Kconfig
arch/powerpc/kernel/crash.c
arch/powerpc/kernel/kprobes.c
arch/powerpc/kernel/proc_ppc64.c
arch/powerpc/kernel/rtas_flash.c
arch/powerpc/kernel/signal_32.c
arch/powerpc/kernel/sysfs.c
arch/powerpc/kernel/vdso.c
arch/powerpc/kernel/vmlinux.lds.S
arch/powerpc/mm/hugetlbpage.c
arch/powerpc/mm/init_64.c
arch/powerpc/platforms/cell/spufs/inode.c
arch/powerpc/platforms/cell/spufs/syscalls.c
arch/powerpc/platforms/iseries/mf.c
arch/powerpc/platforms/pseries/hvCall_inst.c
arch/powerpc/platforms/pseries/scanlog.c
arch/ppc/8xx_io/cs4218_tdm.c
arch/ppc/Kconfig
arch/ppc/kernel/traps.c
arch/ppc/kernel/vmlinux.lds.S
arch/s390/Kconfig
arch/s390/appldata/appldata_base.c
arch/s390/defconfig
arch/s390/hypfs/inode.c
arch/s390/kernel/binfmt_elf32.c
arch/s390/kernel/debug.c
arch/s390/kernel/kprobes.c
arch/s390/kernel/setup.c
arch/s390/lib/uaccess_pt.c
arch/s390/lib/uaccess_std.c
arch/s390/mm/Makefile
arch/s390/mm/extmem.c
arch/s390/mm/init.c
arch/s390/mm/ioremap.c
arch/s390/mm/vmem.c [new file with mode: 0644]
arch/sh/Kconfig
arch/sh/kernel/cpu/sh4/sq.c
arch/sh/kernel/setup.c
arch/sh/kernel/sh_ksyms.c
arch/sh/kernel/signal.c
arch/sh/kernel/vsyscall/vsyscall.c
arch/sh/mm/hugetlbpage.c
arch/sh/mm/ioremap.c
arch/sh/mm/pmb.c
arch/sh/oprofile/op_model_sh7750.c
arch/sh64/Kconfig
arch/sh64/kernel/setup.c
arch/sh64/kernel/signal.c
arch/sh64/mm/fault.c
arch/sh64/mm/hugetlbpage.c
arch/sh64/mm/ioremap.c
arch/sparc/Kconfig
arch/sparc/kernel/sys_sunos.c
arch/sparc/kernel/vmlinux.lds.S
arch/sparc/mm/highmem.c
arch/sparc64/Kconfig
arch/sparc64/kernel/binfmt_aout32.c
arch/sparc64/kernel/binfmt_elf32.c
arch/sparc64/kernel/sys_sunos32.c
arch/sparc64/kernel/vmlinux.lds.S
arch/sparc64/mm/hugetlbpage.c
arch/sparc64/mm/init.c
arch/sparc64/mm/tsb.c
arch/sparc64/solaris/fs.c
arch/sparc64/solaris/ioctl.c
arch/sparc64/solaris/misc.c
arch/sparc64/solaris/socksys.c
arch/sparc64/solaris/timod.c
arch/um/Kconfig
arch/um/drivers/daemon_kern.c
arch/um/drivers/line.c
arch/um/drivers/mcast_kern.c
arch/um/drivers/pcap_kern.c
arch/um/drivers/slip_kern.c
arch/um/drivers/slirp_kern.c
arch/um/include/chan_kern.h
arch/um/include/line.h
arch/um/include/sysdep-i386/ptrace.h
arch/um/include/sysdep-i386/stub.h
arch/um/include/sysdep-x86_64/ptrace.h
arch/um/kernel/exec.c
arch/um/os-Linux/drivers/ethertap_kern.c
arch/um/os-Linux/drivers/tuntap_kern.c
arch/um/sys-i386/Makefile
arch/um/sys-i386/bug.c [new file with mode: 0644]
arch/um/sys-i386/ldt.c
arch/um/sys-i386/ptrace_user.c
arch/um/sys-i386/user-offsets.c
arch/um/sys-x86_64/Makefile
arch/um/sys-x86_64/bug.c [new file with mode: 0644]
arch/v850/Kconfig
arch/v850/kernel/vmlinux.lds.S
arch/x86_64/Kconfig
arch/x86_64/Makefile
arch/x86_64/defconfig
arch/x86_64/ia32/ia32_aout.c
arch/x86_64/ia32/ia32_binfmt.c
arch/x86_64/ia32/ia32_signal.c
arch/x86_64/ia32/syscall32.c
arch/x86_64/kernel/apic.c
arch/x86_64/kernel/crash.c
arch/x86_64/kernel/early-quirks.c
arch/x86_64/kernel/entry.S
arch/x86_64/kernel/genapic.c
arch/x86_64/kernel/head64.c
arch/x86_64/kernel/i387.c
arch/x86_64/kernel/i8259.c
arch/x86_64/kernel/io_apic.c
arch/x86_64/kernel/irq.c
arch/x86_64/kernel/kprobes.c
arch/x86_64/kernel/mce.c
arch/x86_64/kernel/mce_amd.c
arch/x86_64/kernel/module.c
arch/x86_64/kernel/mpparse.c
arch/x86_64/kernel/nmi.c
arch/x86_64/kernel/pci-calgary.c
arch/x86_64/kernel/pci-dma.c
arch/x86_64/kernel/pci-gart.c
arch/x86_64/kernel/process.c
arch/x86_64/kernel/setup.c
arch/x86_64/kernel/smp.c
arch/x86_64/kernel/smpboot.c
arch/x86_64/kernel/traps.c
arch/x86_64/kernel/vmlinux.lds.S
arch/x86_64/kernel/vsyscall.c
arch/x86_64/lib/csum-partial.c
arch/x86_64/lib/delay.c
arch/x86_64/mm/fault.c
arch/x86_64/mm/init.c
arch/x86_64/mm/pageattr.c
arch/xtensa/Kconfig
block/blktrace.c
block/cfq-iosched.c
block/genhd.c
block/ioctl.c
block/ll_rw_blk.c
crypto/Kconfig
crypto/Makefile
crypto/api.c
crypto/digest.c
crypto/gf128mul.c [new file with mode: 0644]
crypto/lrw.c [new file with mode: 0644]
crypto/tcrypt.c
crypto/tcrypt.h
crypto/xcbc.c [new file with mode: 0644]
drivers/Kconfig
drivers/Makefile
drivers/amba/bus.c
drivers/ata/libata-core.c
drivers/ata/sata_promise.c
drivers/atm/Kconfig
drivers/atm/Makefile
drivers/atm/ambassador.c
drivers/atm/he.c
drivers/base/core.c
drivers/base/cpu.c
drivers/base/dmapool.c
drivers/base/memory.c
drivers/base/topology.c
drivers/block/DAC960.c
drivers/block/Kconfig
drivers/block/acsi_slm.c
drivers/block/aoe/aoeblk.c
drivers/block/cciss.c
drivers/block/cciss.h
drivers/block/cciss_cmd.h
drivers/block/loop.c
drivers/block/nbd.c
drivers/block/paride/aten.c
drivers/block/paride/bpck.c
drivers/block/paride/bpck6.c
drivers/block/paride/comm.c
drivers/block/paride/dstr.c
drivers/block/paride/epat.c
drivers/block/paride/epia.c
drivers/block/paride/fit2.c
drivers/block/paride/fit3.c
drivers/block/paride/friq.c
drivers/block/paride/frpw.c
drivers/block/paride/jumbo [deleted file]
drivers/block/paride/kbic.c
drivers/block/paride/ktti.c
drivers/block/paride/on20.c
drivers/block/paride/on26.c
drivers/block/paride/paride.c
drivers/block/paride/paride.h
drivers/block/paride/pcd.c
drivers/block/paride/pf.c
drivers/block/paride/pg.c
drivers/block/paride/pt.c
drivers/block/pktcdvd.c
drivers/bluetooth/hci_bcsp.c
drivers/cdrom/optcd.c
drivers/cdrom/sbpcd.c
drivers/char/Kconfig
drivers/char/Makefile
drivers/char/agp/amd64-agp.c
drivers/char/amiserial.c
drivers/char/cs5535_gpio.c
drivers/char/cyclades.c
drivers/char/decserial.c
drivers/char/drm/drm_ioc32.c
drivers/char/drm/drm_vm.c
drivers/char/drm/i915_ioc32.c
drivers/char/drm/mga_ioc32.c
drivers/char/drm/r128_ioc32.c
drivers/char/drm/radeon_ioc32.c
drivers/char/dsp56k.c
drivers/char/dtlk.c
drivers/char/epca.c
drivers/char/esp.c
drivers/char/generic_serial.c
drivers/char/hvc_console.c
drivers/char/hvcs.c
drivers/char/hvsi.c
drivers/char/hw_random/Kconfig
drivers/char/hw_random/Makefile
drivers/char/ip2/i2cmd.h
drivers/char/ip2/i2lib.c
drivers/char/ip2/ip2main.c
drivers/char/ipmi/ipmi_bt_sm.c
drivers/char/ipmi/ipmi_devintf.c
drivers/char/ipmi/ipmi_kcs_sm.c
drivers/char/ipmi/ipmi_msghandler.c
drivers/char/ipmi/ipmi_poweroff.c
drivers/char/ipmi/ipmi_si_intf.c
drivers/char/ipmi/ipmi_smic_sm.c
drivers/char/ipmi/ipmi_watchdog.c
drivers/char/isicom.c
drivers/char/istallion.c
drivers/char/keyboard.c
drivers/char/lp.c
drivers/char/mem.c
drivers/char/misc.c
drivers/char/mmtimer.c
drivers/char/moxa.c
drivers/char/mxser.c
drivers/char/mxser_new.c [new file with mode: 0644]
drivers/char/mxser_new.h [new file with mode: 0644]
drivers/char/n_r3964.c
drivers/char/n_tty.c
drivers/char/nsc_gpio.c
drivers/char/pcmcia/synclink_cs.c
drivers/char/ppdev.c
drivers/char/pty.c
drivers/char/random.c
drivers/char/raw.c
drivers/char/rio/rio_linux.c
drivers/char/riscom8.c
drivers/char/rocket.c
drivers/char/ser_a2232.c
drivers/char/serial167.c
drivers/char/sonypi.c
drivers/char/specialix.c
drivers/char/stallion.c
drivers/char/sx.c
drivers/char/sx.h
drivers/char/synclink.c
drivers/char/synclink_gt.c
drivers/char/synclinkmp.c
drivers/char/sysrq.c
drivers/char/tb0219.c
drivers/char/tipar.c
drivers/char/toshiba.c
drivers/char/tpm/tpm.c
drivers/char/tty_io.c
drivers/char/tty_ioctl.c
drivers/char/vc_screen.c
drivers/char/viotape.c
drivers/char/vme_scc.c
drivers/char/vr41xx_giu.c
drivers/char/vt.c
drivers/char/watchdog/at91rm9200_wdt.c
drivers/char/watchdog/pcwd_usb.c
drivers/clocksource/acpi_pm.c
drivers/cpufreq/cpufreq.c
drivers/crypto/Kconfig
drivers/crypto/Makefile
drivers/crypto/geode-aes.c [new file with mode: 0644]
drivers/crypto/geode-aes.h [new file with mode: 0644]
drivers/dma/ioatdma.c
drivers/edac/edac_mc.c
drivers/hid/Kconfig [new file with mode: 0644]
drivers/hid/Makefile [new file with mode: 0644]
drivers/hid/hid-core.c [new file with mode: 0644]
drivers/hid/hid-input.c [moved from drivers/usb/input/hid-input.c with 88% similarity]
drivers/i2c/busses/Kconfig
drivers/i2c/busses/i2c-pxa.c
drivers/i2c/i2c-dev.c
drivers/ide/Kconfig
drivers/ide/ide.c
drivers/ide/pci/alim15x3.c
drivers/ide/pci/pdc202xx_new.c
drivers/ide/pci/sis5513.c
drivers/ide/pci/sl82c105.c
drivers/ide/pci/via82cxxx.c
drivers/ieee1394/Kconfig
drivers/ieee1394/Makefile
drivers/ieee1394/csr.c
drivers/ieee1394/dv1394.c
drivers/ieee1394/eth1394.c
drivers/ieee1394/highlevel.h
drivers/ieee1394/hosts.c
drivers/ieee1394/ieee1394_core.c
drivers/ieee1394/ieee1394_core.h
drivers/ieee1394/nodemgr.c
drivers/ieee1394/nodemgr.h
drivers/ieee1394/ohci1394.c
drivers/ieee1394/pcilynx.c
drivers/ieee1394/raw1394-private.h
drivers/ieee1394/raw1394.c
drivers/ieee1394/sbp2.c
drivers/ieee1394/sbp2.h
drivers/ieee1394/video1394.c
drivers/infiniband/core/uverbs_main.c
drivers/infiniband/hw/amso1100/c2_vq.c
drivers/infiniband/hw/ehca/ehca_av.c
drivers/infiniband/hw/ehca/ehca_cq.c
drivers/infiniband/hw/ehca/ehca_main.c
drivers/infiniband/hw/ehca/ehca_mrmw.c
drivers/infiniband/hw/ehca/ehca_pd.c
drivers/infiniband/hw/ehca/ehca_qp.c
drivers/infiniband/hw/ipath/ipath_file_ops.c
drivers/infiniband/hw/ipath/ipath_fs.c
drivers/infiniband/hw/mthca/mthca_av.c
drivers/infiniband/hw/mthca/mthca_provider.c
drivers/infiniband/hw/mthca/mthca_qp.c
drivers/infiniband/hw/mthca/mthca_srq.c
drivers/infiniband/ulp/iser/iser_memory.c
drivers/input/Makefile
drivers/input/ff-core.c
drivers/input/ff-memless.c
drivers/input/gameport/gameport.c
drivers/input/gameport/lightning.c
drivers/input/input.c
drivers/input/joystick/adi.c
drivers/input/joystick/amijoy.c
drivers/input/joystick/analog.c
drivers/input/joystick/cobra.c
drivers/input/joystick/gf2k.c
drivers/input/joystick/grip_mp.c
drivers/input/joystick/guillemot.c
drivers/input/joystick/iforce/iforce-main.c
drivers/input/joystick/iforce/iforce-serio.c
drivers/input/joystick/interact.c
drivers/input/joystick/magellan.c
drivers/input/joystick/spaceball.c
drivers/input/joystick/spaceorb.c
drivers/input/joystick/stinger.c
drivers/input/joystick/twidjoy.c
drivers/input/joystick/warrior.c
drivers/input/keyboard/Kconfig
drivers/input/keyboard/Makefile
drivers/input/keyboard/aaed2000_kbd.c [new file with mode: 0644]
drivers/input/keyboard/amikbd.c
drivers/input/keyboard/atkbd.c
drivers/input/keyboard/corgikbd.c
drivers/input/keyboard/hil_kbd.c
drivers/input/keyboard/lkkbd.c
drivers/input/keyboard/locomokbd.c
drivers/input/keyboard/maple_keyb.c [deleted file]
drivers/input/keyboard/newtonkbd.c
drivers/input/keyboard/spitzkbd.c
drivers/input/keyboard/stowaway.c
drivers/input/keyboard/sunkbd.c
drivers/input/keyboard/xtkbd.c
drivers/input/misc/hp_sdc_rtc.c
drivers/input/mouse/amimouse.c
drivers/input/mouse/hil_ptr.c
drivers/input/mouse/inport.c
drivers/input/mouse/lifebook.c
drivers/input/mouse/logibm.c
drivers/input/mouse/logips2pp.c
drivers/input/mouse/pc110pad.c
drivers/input/mouse/psmouse-base.c
drivers/input/mouse/rpcmouse.c
drivers/input/mouse/sermouse.c
drivers/input/mouse/trackpoint.c
drivers/input/mouse/vsxxxaa.c
drivers/input/mousedev.c
drivers/input/serio/i8042-x86ia64io.h
drivers/input/serio/i8042.c
drivers/input/serio/serio.c
drivers/input/serio/serio_raw.c
drivers/input/touchscreen/Kconfig
drivers/input/touchscreen/Makefile
drivers/input/touchscreen/ads7846.c
drivers/input/touchscreen/corgi_ts.c
drivers/input/touchscreen/elo.c
drivers/input/touchscreen/gunze.c
drivers/input/touchscreen/h3600_ts_input.c
drivers/input/touchscreen/hp680_ts_input.c
drivers/input/touchscreen/mk712.c
drivers/input/touchscreen/mtouch.c
drivers/input/touchscreen/penmount.c
drivers/input/touchscreen/touchright.c
drivers/input/touchscreen/touchwin.c
drivers/input/touchscreen/ucb1400_ts.c [new file with mode: 0644]
drivers/isdn/act2000/module.c
drivers/isdn/capi/capi.c
drivers/isdn/capi/capidrv.c
drivers/isdn/gigaset/Kconfig
drivers/isdn/gigaset/asyncdata.c
drivers/isdn/gigaset/bas-gigaset.c
drivers/isdn/gigaset/common.c
drivers/isdn/gigaset/gigaset.h
drivers/isdn/gigaset/interface.c
drivers/isdn/gigaset/isocdata.c
drivers/isdn/gigaset/usb-gigaset.c
drivers/isdn/hardware/avm/avm_cs.c
drivers/isdn/hardware/avm/b1.c
drivers/isdn/hardware/avm/t1isa.c
drivers/isdn/hardware/eicon/debug.c
drivers/isdn/hardware/eicon/di.c
drivers/isdn/hardware/eicon/divasmain.c
drivers/isdn/hardware/eicon/io.c
drivers/isdn/hardware/eicon/istream.c
drivers/isdn/hardware/eicon/platform.h
drivers/isdn/hisax/Kconfig
drivers/isdn/hisax/avma1_cs.c
drivers/isdn/hisax/config.c
drivers/isdn/hisax/diva.c
drivers/isdn/hisax/elsa_cs.c
drivers/isdn/hisax/fsm.c
drivers/isdn/hisax/hfc4s8s_l1.c
drivers/isdn/hisax/hfc_pci.c
drivers/isdn/hisax/hfc_usb.c
drivers/isdn/hisax/hisax.h
drivers/isdn/hisax/hisax_fcpcipnp.c
drivers/isdn/hisax/hisax_isac.c
drivers/isdn/hisax/isdnhdlc.c
drivers/isdn/hisax/isdnhdlc.h
drivers/isdn/hisax/sedlbauer.c
drivers/isdn/hisax/sedlbauer_cs.c
drivers/isdn/hisax/st5481_b.c
drivers/isdn/hisax/st5481_d.c
drivers/isdn/hisax/st5481_init.c
drivers/isdn/hisax/teles_cs.c
drivers/isdn/hysdn/hycapi.c
drivers/isdn/hysdn/hysdn_boot.c
drivers/isdn/hysdn/hysdn_init.c
drivers/isdn/hysdn/hysdn_net.c
drivers/isdn/hysdn/hysdn_proclog.c
drivers/isdn/i4l/isdn_bsdcomp.c
drivers/isdn/i4l/isdn_common.c
drivers/isdn/i4l/isdn_net.c
drivers/isdn/i4l/isdn_ppp.c
drivers/isdn/i4l/isdn_tty.c
drivers/isdn/i4l/isdn_v110.c
drivers/isdn/icn/icn.c
drivers/isdn/isdnloop/isdnloop.c
drivers/isdn/pcbit/drv.c
drivers/isdn/pcbit/layer2.c
drivers/isdn/sc/init.c
drivers/leds/Kconfig
drivers/leds/Makefile
drivers/leds/leds-wrap.c [new file with mode: 0644]
drivers/macintosh/Kconfig
drivers/macintosh/adbhid.c
drivers/macintosh/apm_emu.c
drivers/macintosh/mac_hid.c
drivers/macintosh/therm_adt746x.c
drivers/macintosh/via-pmu.c
drivers/macintosh/windfarm_core.c
drivers/md/bitmap.c
drivers/md/dm-bio-list.h
drivers/md/dm-crypt.c
drivers/md/dm-emc.c
drivers/md/dm-hw-handler.h
drivers/md/dm-io.c
drivers/md/dm-ioctl.c
drivers/md/dm-linear.c
drivers/md/dm-log.c
drivers/md/dm-log.h
drivers/md/dm-mpath.c
drivers/md/dm-mpath.h
drivers/md/dm-path-selector.h
drivers/md/dm-raid1.c
drivers/md/dm-round-robin.c
drivers/md/dm-snap.c
drivers/md/dm-stripe.c
drivers/md/dm-zero.c
drivers/md/dm.c
drivers/md/dm.h
drivers/md/kcopyd.c
drivers/md/md.c
drivers/md/raid5.c
drivers/media/dvb/cinergyT2/cinergyT2.c
drivers/media/dvb/dvb-core/dvb_frontend.c
drivers/media/dvb/dvb-usb/usb-urb.c
drivers/media/dvb/frontends/l64781.c
drivers/media/dvb/ttusb-dec/ttusb_dec.c
drivers/media/radio/Kconfig
drivers/media/video/compat_ioctl32.c
drivers/media/video/msp3400-driver.c
drivers/media/video/tvaudio.c
drivers/media/video/video-buf-dvb.c
drivers/media/video/videodev.c
drivers/media/video/vivi.c
drivers/media/video/zoran_procfs.c
drivers/message/fusion/mptbase.c
drivers/message/fusion/mptfc.c
drivers/message/fusion/mptscsih.c
drivers/message/fusion/mptspi.c
drivers/message/i2o/bus-osm.c
drivers/message/i2o/device.c
drivers/message/i2o/driver.c
drivers/message/i2o/exec-osm.c
drivers/message/i2o/i2o_block.c
drivers/message/i2o/i2o_block.h
drivers/message/i2o/i2o_config.c
drivers/message/i2o/i2o_proc.c
drivers/message/i2o/i2o_scsi.c
drivers/message/i2o/pci.c
drivers/mfd/ucb1x00-ts.c
drivers/misc/tifm_core.c
drivers/mmc/Kconfig
drivers/mmc/Makefile
drivers/mmc/at91_mci.c
drivers/mmc/au1xmmc.c
drivers/mmc/pxamci.c
drivers/mmc/tifm_sd.c
drivers/mtd/devices/m25p80.c
drivers/net/3c501.c
drivers/net/3c503.c
drivers/net/3c505.c
drivers/net/3c507.c
drivers/net/3c523.c
drivers/net/3c527.c
drivers/net/7990.c
drivers/net/ac3200.c
drivers/net/apne.c
drivers/net/appletalk/cops.c
drivers/net/arm/at91_ether.c
drivers/net/arm/at91_ether.h
drivers/net/arm/ether1.c
drivers/net/arm/ether3.c
drivers/net/at1700.c
drivers/net/atarilance.c
drivers/net/bnx2.c
drivers/net/bonding/bond_main.c
drivers/net/cs89x0.c
drivers/net/de600.c
drivers/net/declance.c
drivers/net/e2100.c
drivers/net/eepro.c
drivers/net/eexpress.c
drivers/net/es3210.c
drivers/net/eth16i.c
drivers/net/hamradio/6pack.c
drivers/net/hamradio/baycom_epp.c
drivers/net/hamradio/bpqether.c
drivers/net/hamradio/dmascc.c
drivers/net/hamradio/hdlcdrv.c
drivers/net/hamradio/mkiss.c
drivers/net/hamradio/scc.c
drivers/net/hamradio/yam.c
drivers/net/hp-plus.c
drivers/net/hp.c
drivers/net/hplance.c
drivers/net/irda/irtty-sir.c
drivers/net/irda/pxaficp_ir.c
drivers/net/irda/stir4200.c
drivers/net/lance.c
drivers/net/lasi_82596.c
drivers/net/lne390.c
drivers/net/mv643xx_eth.c
drivers/net/mvme147.c
drivers/net/myri10ge/myri10ge.c
drivers/net/myri10ge/myri10ge_mcp.h
drivers/net/myri10ge/myri10ge_mcp_gen_header.h
drivers/net/ne.c
drivers/net/ne2.c
drivers/net/netxen/netxen_nic.h
drivers/net/netxen/netxen_nic_ethtool.c
drivers/net/netxen/netxen_nic_hdr.h
drivers/net/netxen/netxen_nic_hw.c
drivers/net/netxen/netxen_nic_hw.h
drivers/net/netxen/netxen_nic_init.c
drivers/net/netxen/netxen_nic_ioctl.h
drivers/net/netxen/netxen_nic_isr.c
drivers/net/netxen/netxen_nic_main.c
drivers/net/netxen/netxen_nic_niu.c
drivers/net/netxen/netxen_nic_phan_reg.h
drivers/net/ni52.c
drivers/net/ni65.c
drivers/net/ns83820.c
drivers/net/phy/phy.c
drivers/net/r8169.c
drivers/net/seeq8005.c
drivers/net/sk98lin/skgesirq.c
drivers/net/skge.h
drivers/net/sky2.c
drivers/net/sky2.h
drivers/net/smc-ultra.c
drivers/net/smc-ultra32.c
drivers/net/smc9194.c
drivers/net/smc91x.h
drivers/net/sun3lance.c
drivers/net/tg3.c
drivers/net/tg3.h
drivers/net/tokenring/smctr.c
drivers/net/via-velocity.c
drivers/net/wan/cosa.c
drivers/net/wd.c
drivers/net/wireless/airo.c
drivers/net/wireless/hostap/hostap_ap.c
drivers/net/wireless/hostap/hostap_cs.c
drivers/net/wireless/hostap/hostap_download.c
drivers/net/wireless/hostap/hostap_hw.c
drivers/net/wireless/hostap/hostap_info.c
drivers/net/wireless/hostap/hostap_ioctl.c
drivers/net/wireless/hostap/hostap_pci.c
drivers/net/wireless/hostap/hostap_plx.c
drivers/net/wireless/ipw2100.c
drivers/net/wireless/ipw2200.c
drivers/net/wireless/prism54/isl_ioctl.c
drivers/net/wireless/prism54/oid_mgt.c
drivers/net/wireless/strip.c
drivers/net/wireless/zd1211rw/zd_chip.c
drivers/net/wireless/zd1211rw/zd_chip.h
drivers/net/wireless/zd1211rw/zd_mac.c
drivers/net/wireless/zd1211rw/zd_mac.h
drivers/net/wireless/zd1211rw/zd_netdev.c
drivers/oprofile/buffer_sync.c
drivers/parport/parport_pc.c
drivers/pci/msi.c
drivers/pci/probe.c
drivers/pci/proc.c
drivers/pcmcia/at91_cf.c
drivers/pcmcia/cs.c
drivers/pcmcia/pcmcia_ioctl.c
drivers/pnp/card.c
drivers/pnp/interface.c
drivers/pnp/isapnp/proc.c
drivers/pnp/pnpbios/core.c
drivers/rtc/Kconfig
drivers/rtc/Makefile
drivers/rtc/rtc-ds1672.c
drivers/rtc/rtc-ds1742.c
drivers/rtc/rtc-omap.c [new file with mode: 0644]
drivers/rtc/rtc-rs5c372.c
drivers/rtc/rtc-test.c
drivers/rtc/rtc-x1205.c
drivers/s390/block/dasd.c
drivers/s390/block/dasd_3990_erp.c
drivers/s390/block/dasd_devmap.c
drivers/s390/block/dasd_eckd.c
drivers/s390/block/dasd_fba.c
drivers/s390/block/dasd_int.h
drivers/s390/block/dasd_ioctl.c
drivers/s390/char/ctrlchar.c
drivers/s390/char/fs3270.c
drivers/s390/char/sclp_tty.c
drivers/s390/char/tape.h
drivers/s390/char/tape_34xx.c
drivers/s390/char/tape_3590.c
drivers/s390/char/tape_block.c
drivers/s390/char/tape_char.c
drivers/s390/char/tape_core.c
drivers/s390/char/tty3270.c
drivers/s390/cio/chsc.c
drivers/s390/cio/cio.c
drivers/s390/cio/cio.h
drivers/s390/cio/css.c
drivers/s390/cio/css.h
drivers/s390/cio/device.c
drivers/s390/cio/device.h
drivers/s390/cio/device_fsm.c
drivers/s390/cio/device_ops.c
drivers/s390/cio/qdio.c
drivers/s390/cio/qdio.h
drivers/s390/crypto/ap_bus.c
drivers/s390/scsi/zfcp_def.h
drivers/s390/scsi/zfcp_fsf.c
drivers/sbus/char/bpp.c
drivers/sbus/char/cpwatchdog.c
drivers/sbus/char/display7seg.c
drivers/sbus/char/openprom.c
drivers/sbus/char/vfc_dev.c
drivers/scsi/53c700.c
drivers/scsi/53c700.h
drivers/scsi/Kconfig
drivers/scsi/aic94xx/aic94xx.h
drivers/scsi/aic94xx/aic94xx_hwi.c
drivers/scsi/aic94xx/aic94xx_init.c
drivers/scsi/ide-scsi.c
drivers/scsi/ipr.c
drivers/scsi/libsas/sas_init.c
drivers/scsi/qla2xxx/qla_os.c
drivers/scsi/qla4xxx/ql4_os.c
drivers/scsi/scsi.c
drivers/scsi/scsi_lib.c
drivers/scsi/scsi_tgt_lib.c
drivers/scsi/sd.c
drivers/scsi/st.c
drivers/scsi/sun3_NCR5380.c
drivers/scsi/sun3_scsi.c
drivers/scsi/sun3_scsi.h
drivers/scsi/sun3_scsi_vme.c
drivers/serial/21285.c
drivers/serial/68328serial.c
drivers/serial/68360serial.c
drivers/serial/8250.c
drivers/serial/8250_exar_st16c554.c [new file with mode: 0644]
drivers/serial/8250_pnp.c
drivers/serial/Kconfig
drivers/serial/Makefile
drivers/serial/amba-pl010.c
drivers/serial/amba-pl011.c
drivers/serial/atmel_serial.c
drivers/serial/atmel_serial.h
drivers/serial/clps711x.c
drivers/serial/crisv10.c
drivers/serial/crisv10.h
drivers/serial/dz.c
drivers/serial/dz.h
drivers/serial/icom.c
drivers/serial/imx.c
drivers/serial/ioc3_serial.c
drivers/serial/ioc4_serial.c
drivers/serial/ip22zilog.c
drivers/serial/jsm/jsm_tty.c
drivers/serial/m32r_sio.c
drivers/serial/mcfserial.c
drivers/serial/mpc52xx_uart.c
drivers/serial/mpsc.c
drivers/serial/mux.c
drivers/serial/netx-serial.c
drivers/serial/pmac_zilog.c
drivers/serial/pmac_zilog.h
drivers/serial/pxa.c
drivers/serial/s3c2410.c
drivers/serial/sa1100.c
drivers/serial/serial_core.c
drivers/serial/serial_lh7a40x.c
drivers/serial/serial_txx9.c
drivers/serial/sh-sci.c
drivers/serial/sn_console.c
drivers/serial/sunhv.c
drivers/serial/sunsab.c
drivers/serial/sunsu.c
drivers/serial/sunzilog.c
drivers/serial/uartlite.c [new file with mode: 0644]
drivers/serial/v850e_uart.c
drivers/serial/vr41xx_siu.c
drivers/spi/spi.c
drivers/spi/spi_bitbang.c
drivers/spi/spi_butterfly.c
drivers/tc/zs.c
drivers/telephony/ixj.c
drivers/usb/Kconfig
drivers/usb/atm/ueagle-atm.c
drivers/usb/class/cdc-acm.c
drivers/usb/core/buffer.c
drivers/usb/core/hub.c
drivers/usb/core/inode.c
drivers/usb/core/message.c
drivers/usb/gadget/Kconfig
drivers/usb/gadget/file_storage.c
drivers/usb/gadget/gmidi.c
drivers/usb/gadget/goku_udc.c
drivers/usb/gadget/inode.c
drivers/usb/gadget/net2280.c
drivers/usb/gadget/omap_udc.c
drivers/usb/gadget/serial.c
drivers/usb/gadget/zero.c
drivers/usb/host/ehci-dbg.c
drivers/usb/host/hc_crisv10.c
drivers/usb/host/ohci-dbg.c
drivers/usb/host/ohci-hcd.c
drivers/usb/host/ohci-pnx4008.c
drivers/usb/host/uhci-hcd.c
drivers/usb/host/uhci-q.c
drivers/usb/input/Kconfig
drivers/usb/input/Makefile
drivers/usb/input/acecad.c
drivers/usb/input/aiptek.c
drivers/usb/input/appletouch.c
drivers/usb/input/ati_remote.c
drivers/usb/input/hid-core.c
drivers/usb/input/hid-ff.c
drivers/usb/input/hid-lgff.c
drivers/usb/input/hid-pidff.c
drivers/usb/input/hid-tmff.c
drivers/usb/input/hid-zpff.c
drivers/usb/input/hiddev.c
drivers/usb/input/keyspan_remote.c
drivers/usb/input/mtouchusb.c
drivers/usb/input/powermate.c
drivers/usb/input/touchkitusb.c
drivers/usb/input/usbhid.h [new file with mode: 0644]
drivers/usb/input/usbkbd.c
drivers/usb/input/usbmouse.c
drivers/usb/input/usbtouchscreen.c
drivers/usb/input/xpad.c
drivers/usb/input/yealink.c
drivers/usb/misc/phidgetkit.c
drivers/usb/misc/phidgetmotorcontrol.c
drivers/usb/misc/sisusbvga/sisusb.c
drivers/usb/misc/usbtest.c
drivers/usb/mon/mon_text.c
drivers/usb/net/catc.c
drivers/usb/net/net1080.c
drivers/usb/net/pegasus.c
drivers/usb/net/rndis_host.c
drivers/usb/net/rtl8150.c
drivers/usb/net/usbnet.c
drivers/usb/serial/ark3116.c
drivers/usb/serial/belkin_sa.c
drivers/usb/serial/console.c
drivers/usb/serial/cp2101.c
drivers/usb/serial/cypress_m8.c
drivers/usb/serial/digi_acceleport.c
drivers/usb/serial/empeg.c
drivers/usb/serial/ftdi_sio.c
drivers/usb/serial/io_edgeport.c
drivers/usb/serial/io_ti.c
drivers/usb/serial/ir-usb.c
drivers/usb/serial/keyspan.c
drivers/usb/serial/keyspan.h
drivers/usb/serial/keyspan_pda.c
drivers/usb/serial/kl5kusb105.c
drivers/usb/serial/kobil_sct.c
drivers/usb/serial/mct_u232.c
drivers/usb/serial/mos7720.c
drivers/usb/serial/mos7840.c
drivers/usb/serial/option.c
drivers/usb/serial/pl2303.c
drivers/usb/serial/sierra.c
drivers/usb/serial/ti_usb_3410_5052.c
drivers/usb/serial/usb-serial.c
drivers/usb/serial/visor.c
drivers/usb/serial/whiteheat.c
drivers/usb/storage/onetouch.c
drivers/usb/storage/transport.c
drivers/usb/storage/usb.c
drivers/video/Kconfig
drivers/video/S3triofb.c
drivers/video/amifb.c
drivers/video/arcfb.c
drivers/video/atafb.c
drivers/video/aty/aty128fb.c
drivers/video/aty/atyfb.h
drivers/video/aty/atyfb_base.c
drivers/video/aty/mach64_ct.c
drivers/video/aty/radeon_monitor.c
drivers/video/au1100fb.h
drivers/video/backlight/backlight.c
drivers/video/backlight/corgi_bl.c
drivers/video/backlight/hp680_bl.c
drivers/video/backlight/lcd.c
drivers/video/backlight/locomolcd.c
drivers/video/cfbimgblt.c
drivers/video/cirrusfb.c
drivers/video/console/softcursor.c
drivers/video/console/sticon.c
drivers/video/console/vgacon.c
drivers/video/cyberfb.c
drivers/video/epson1355fb.c
drivers/video/fbcmap.c
drivers/video/fbcvt.c
drivers/video/fbmem.c
drivers/video/fbmon.c
drivers/video/ffb.c
drivers/video/fm2fb.c
drivers/video/geode/Kconfig
drivers/video/geode/display_gx.c
drivers/video/geode/display_gx.h
drivers/video/geode/gxfb_core.c
drivers/video/geode/video_gx.c
drivers/video/geode/video_gx.h
drivers/video/hpfb.c
drivers/video/i810/i810-i2c.c
drivers/video/igafb.c
drivers/video/intelfb/intelfbdrv.c
drivers/video/macfb.c
drivers/video/mbx/mbxdebugfs.c
drivers/video/mbx/mbxfb.c
drivers/video/mbx/reg_bits.h
drivers/video/mbx/regs.h
drivers/video/modedb.c
drivers/video/neofb.c
drivers/video/nvidia/nv_accel.c
drivers/video/nvidia/nv_i2c.c
drivers/video/nvidia/nv_local.h
drivers/video/nvidia/nv_of.c
drivers/video/nvidia/nv_proto.h
drivers/video/offb.c
drivers/video/platinumfb.c
drivers/video/pmagb-b-fb.c
drivers/video/pvr2fb.c
drivers/video/retz3fb.c
drivers/video/riva/fbdev.c
drivers/video/riva/riva_hw.c
drivers/video/riva/riva_hw.h
drivers/video/s3c2410fb.c
drivers/video/savage/savagefb-i2c.c
drivers/video/sis/init301.c
drivers/video/stifb.c
drivers/video/tgafb.c
drivers/video/tridentfb.c
drivers/video/vesafb.c
drivers/video/vga16fb.c
drivers/video/virgefb.c
drivers/w1/Makefile
drivers/w1/slaves/Makefile
drivers/w1/slaves/w1_ds2433.c
drivers/w1/w1.c
drivers/zorro/proc.c
fs/9p/vfs_addr.c
fs/9p/vfs_dir.c
fs/9p/vfs_file.c
fs/9p/vfs_inode.c
fs/Makefile
fs/adfs/dir.c
fs/adfs/super.c
fs/affs/amigaffs.c
fs/affs/bitmap.c
fs/affs/dir.c
fs/affs/super.c
fs/afs/dir.c
fs/afs/kafsasyncd.c
fs/afs/kafstimod.c
fs/afs/mntpt.c
fs/afs/server.c
fs/afs/super.c
fs/aio.c
fs/autofs/inode.c
fs/autofs/root.c
fs/autofs4/autofs_i.h
fs/autofs4/inode.c
fs/autofs4/root.c
fs/befs/linuxvfs.c
fs/bfs/dir.c
fs/bfs/inode.c
fs/binfmt_aout.c
fs/binfmt_elf.c
fs/binfmt_elf_fdpic.c
fs/binfmt_flat.c
fs/binfmt_misc.c
fs/bio.c
fs/block_dev.c
fs/buffer.c
fs/cifs/CHANGES
fs/cifs/cifsencrypt.c
fs/cifs/cifsfs.c
fs/cifs/cifspdu.h
fs/cifs/connect.c
fs/cifs/fcntl.c
fs/cifs/file.c
fs/cifs/misc.c
fs/cifs/readdir.c
fs/cifs/transport.c
fs/coda/dir.c
fs/coda/file.c
fs/coda/inode.c
fs/compat.c
fs/compat_ioctl.c
fs/configfs/configfs_internal.h
fs/configfs/dir.c
fs/configfs/file.c
fs/configfs/mount.c
fs/cramfs/inode.c
fs/dcache.c
fs/dcookies.c
fs/dlm/Kconfig
fs/dlm/Makefile
fs/dlm/dlm_internal.h
fs/dlm/lock.c
fs/dlm/lockspace.c
fs/dlm/lowcomms-sctp.c [moved from fs/dlm/lowcomms.c with 87% similarity]
fs/dlm/lowcomms-tcp.c [new file with mode: 0644]
fs/dlm/lowcomms.h
fs/dlm/main.c
fs/dlm/member.c
fs/dlm/memory.c
fs/dlm/rcom.c
fs/dlm/recover.c
fs/dlm/recoverd.c
fs/dlm/requestqueue.c
fs/dlm/requestqueue.h
fs/dnotify.c
fs/dquot.c
fs/ecryptfs/crypto.c
fs/ecryptfs/dentry.c
fs/ecryptfs/ecryptfs_kernel.h
fs/ecryptfs/file.c
fs/ecryptfs/inode.c
fs/ecryptfs/keystore.c
fs/ecryptfs/main.c
fs/ecryptfs/mmap.c
fs/ecryptfs/super.c
fs/efs/dir.c
fs/efs/super.c
fs/eventpoll.c
fs/exec.c
fs/ext2/dir.c
fs/ext2/ioctl.c
fs/ext2/super.c
fs/ext2/xattr.c
fs/ext3/Makefile
fs/ext3/balloc.c
fs/ext3/dir.c
fs/ext3/ext3_jbd.c [new file with mode: 0644]
fs/ext3/file.c
fs/ext3/inode.c
fs/ext3/ioctl.c
fs/ext3/namei.c
fs/ext3/super.c
fs/ext3/xattr.c
fs/ext4/Makefile
fs/ext4/balloc.c
fs/ext4/dir.c
fs/ext4/ext4_jbd2.c [new file with mode: 0644]
fs/ext4/extents.c
fs/ext4/file.c
fs/ext4/inode.c
fs/ext4/ioctl.c
fs/ext4/namei.c
fs/ext4/super.c
fs/ext4/xattr.c
fs/fat/cache.c
fs/fat/dir.c
fs/fat/file.c
fs/fat/inode.c
fs/fcntl.c
fs/file.c
fs/file_table.c
fs/freevxfs/vxfs_inode.c
fs/freevxfs/vxfs_lookup.c
fs/fuse/control.c
fs/fuse/dev.c
fs/fuse/dir.c
fs/fuse/file.c
fs/fuse/fuse_i.h
fs/fuse/inode.c
fs/gfs2/Kconfig
fs/gfs2/acl.c
fs/gfs2/acl.h
fs/gfs2/bmap.c
fs/gfs2/daemon.c
fs/gfs2/dir.c
fs/gfs2/dir.h
fs/gfs2/eaops.c
fs/gfs2/eattr.c
fs/gfs2/eattr.h
fs/gfs2/glock.c
fs/gfs2/glock.h
fs/gfs2/glops.c
fs/gfs2/incore.h
fs/gfs2/inode.c
fs/gfs2/inode.h
fs/gfs2/log.c
fs/gfs2/log.h
fs/gfs2/lops.c
fs/gfs2/lops.h
fs/gfs2/main.c
fs/gfs2/meta_io.c
fs/gfs2/meta_io.h
fs/gfs2/ondisk.c
fs/gfs2/ops_address.c
fs/gfs2/ops_dentry.c
fs/gfs2/ops_export.c
fs/gfs2/ops_export.h
fs/gfs2/ops_file.c
fs/gfs2/ops_file.h
fs/gfs2/ops_fstype.c
fs/gfs2/ops_inode.c
fs/gfs2/ops_super.c
fs/gfs2/ops_vm.c
fs/gfs2/quota.c
fs/gfs2/recovery.c
fs/gfs2/recovery.h
fs/gfs2/rgrp.c
fs/gfs2/super.c
fs/gfs2/super.h
fs/gfs2/sys.c
fs/gfs2/util.c
fs/gfs2/util.h
fs/hfs/dir.c
fs/hfs/inode.c
fs/hfs/super.c
fs/hfsplus/dir.c
fs/hfsplus/inode.c
fs/hfsplus/super.c
fs/hostfs/hostfs_kern.c
fs/hpfs/dir.c
fs/hpfs/dnode.c
fs/hpfs/ea.c
fs/hpfs/file.c
fs/hpfs/hpfs_fn.h
fs/hpfs/inode.c
fs/hpfs/map.c
fs/hpfs/super.c
fs/hppfs/hppfs_kern.c
fs/hugetlbfs/inode.c
fs/inode.c
fs/inotify_user.c
fs/ioctl.c
fs/isofs/compress.c
fs/isofs/dir.c
fs/isofs/inode.c
fs/jbd/journal.c
fs/jbd/revoke.c
fs/jbd/transaction.c
fs/jbd2/commit.c
fs/jbd2/journal.c
fs/jbd2/revoke.c
fs/jbd2/transaction.c
fs/jffs/inode-v23.c
fs/jffs/intrep.c
fs/jffs/jffs_fm.c
fs/jffs2/background.c
fs/jffs2/dir.c
fs/jffs2/malloc.c
fs/jffs2/super.c
fs/jfs/jfs_dtree.c
fs/jfs/jfs_logmgr.c
fs/jfs/jfs_metapage.c
fs/jfs/jfs_txnmgr.c
fs/jfs/super.c
fs/libfs.c
fs/lockd/clntlock.c
fs/lockd/clntproc.c
fs/lockd/host.c
fs/lockd/svc4proc.c
fs/lockd/svclock.c
fs/lockd/svcproc.c
fs/lockd/svcsubs.c
fs/locks.c
fs/mbcache.c
fs/minix/dir.c
fs/minix/inode.c
fs/namei.c
fs/namespace.c
fs/ncpfs/dir.c
fs/ncpfs/file.c
fs/ncpfs/inode.c
fs/ncpfs/ioctl.c
fs/ncpfs/mmap.c
fs/nfs/dir.c
fs/nfs/direct.c
fs/nfs/file.c
fs/nfs/getroot.c
fs/nfs/idmap.c
fs/nfs/inode.c
fs/nfs/internal.h
fs/nfs/nfs3proc.c
fs/nfs/nfs4proc.c
fs/nfs/pagelist.c
fs/nfs/proc.c
fs/nfs/read.c
fs/nfs/symlink.c
fs/nfs/write.c
fs/nfsd/nfs2acl.c
fs/nfsd/nfs3acl.c
fs/nfsd/nfs3xdr.c
fs/nfsd/nfs4recover.c
fs/nfsd/nfs4state.c
fs/nfsd/nfscache.c
fs/nfsd/nfsctl.c
fs/nfsd/nfsxdr.c
fs/nfsd/vfs.c
fs/nls/nls_cp936.c
fs/ntfs/attrib.c
fs/ntfs/dir.c
fs/ntfs/file.c
fs/ntfs/index.c
fs/ntfs/inode.c
fs/ntfs/unistr.c
fs/ocfs2/aops.c
fs/ocfs2/dir.c
fs/ocfs2/dlm/dlmfs.c
fs/ocfs2/dlm/dlmmaster.c
fs/ocfs2/extent_map.c
fs/ocfs2/file.c
fs/ocfs2/inode.h
fs/ocfs2/super.c
fs/ocfs2/uptodate.c
fs/open.c
fs/openpromfs/inode.c
fs/partitions/Kconfig
fs/partitions/amiga.c
fs/partitions/atari.c
fs/partitions/check.c
fs/partitions/ibm.c
fs/pipe.c
fs/pnode.c
fs/pnode.h
fs/proc/Makefile
fs/proc/array.c
fs/proc/base.c
fs/proc/generic.c
fs/proc/inode.c
fs/proc/kcore.c
fs/proc/nommu.c
fs/proc/proc_misc.c
fs/proc/task_mmu.c
fs/proc/task_nommu.c
fs/qnx4/dir.c
fs/qnx4/inode.c
fs/ramfs/file-nommu.c
fs/read_write.c
fs/readdir.c
fs/reiserfs/bitmap.c
fs/reiserfs/dir.c
fs/reiserfs/file.c
fs/reiserfs/fix_node.c
fs/reiserfs/inode.c
fs/reiserfs/ioctl.c
fs/reiserfs/namei.c
fs/reiserfs/procfs.c
fs/reiserfs/stree.c
fs/reiserfs/super.c
fs/reiserfs/tail_conversion.c
fs/reiserfs/xattr.c
fs/romfs/inode.c
fs/seq_file.c
fs/smbfs/cache.c
fs/smbfs/dir.c
fs/smbfs/file.c
fs/smbfs/inode.c
fs/smbfs/proc.c
fs/smbfs/request.c
fs/smbfs/sock.c
fs/splice.c
fs/stack.c [new file with mode: 0644]
fs/stat.c
fs/super.c
fs/sync.c
fs/sysfs/bin.c
fs/sysfs/dir.c
fs/sysfs/file.c
fs/sysfs/mount.c
fs/sysfs/sysfs.h
fs/sysv/CHANGES [deleted file]
fs/sysv/ChangeLog [deleted file]
fs/sysv/INTRO [deleted file]
fs/sysv/dir.c
fs/sysv/inode.c
fs/udf/dir.c
fs/udf/file.c
fs/udf/super.c
fs/ufs/dir.c
fs/ufs/super.c
fs/ufs/util.h
fs/xattr.c
fs/xfs/linux-2.6/xfs_buf.c
fs/xfs/linux-2.6/xfs_file.c
fs/xfs/linux-2.6/xfs_ioctl.c
fs/xfs/linux-2.6/xfs_ioctl32.c
fs/xfs/linux-2.6/xfs_lrw.c
fs/xfs/linux-2.6/xfs_super.c
fs/xfs/xfs_dfrag.c
include/acpi/platform/aclinux.h
include/asm-alpha/dma-mapping.h
include/asm-alpha/termbits.h
include/asm-alpha/unistd.h
include/asm-arm/arch-aaec2000/memory.h
include/asm-arm/arch-at91rm9200/at91_aic.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/at91_dbgu.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/at91_ecc.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/at91_lcdc.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/at91_mci.h [moved from include/asm-arm/arch-at91rm9200/at91rm9200_mci.h with 85% similarity]
include/asm-arm/arch-at91rm9200/at91_pdc.h [moved from include/asm-avr32/arch-at32ap/at91rm9200_pdc.h with 92% similarity]
include/asm-arm/arch-at91rm9200/at91_pio.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/at91_pit.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/at91_pmc.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/at91_rstc.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/at91_rtc.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/at91_rtt.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/at91_shdwc.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/at91_spi.h [moved from include/asm-arm/arch-at91rm9200/at91rm9200_spi.h with 95% similarity]
include/asm-arm/arch-at91rm9200/at91_ssc.h [moved from include/asm-arm/arch-at91rm9200/at91rm9200_ssc.h with 86% similarity]
include/asm-arm/arch-at91rm9200/at91_st.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/at91_tc.h [moved from include/asm-arm/arch-at91rm9200/at91rm9200_tc.h with 98% similarity]
include/asm-arm/arch-at91rm9200/at91_twi.h [moved from include/asm-arm/arch-at91rm9200/at91rm9200_twi.h with 90% similarity]
include/asm-arm/arch-at91rm9200/at91_wdt.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/at91rm9200.h
include/asm-arm/arch-at91rm9200/at91rm9200_mc.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/at91rm9200_sys.h [deleted file]
include/asm-arm/arch-at91rm9200/at91rm9200_udp.h [deleted file]
include/asm-arm/arch-at91rm9200/at91sam9260.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/at91sam9260_matrix.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/at91sam9261.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/at91sam9261_matrix.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/at91sam926x_mc.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/board.h
include/asm-arm/arch-at91rm9200/cpu.h [new file with mode: 0644]
include/asm-arm/arch-at91rm9200/debug-macro.S
include/asm-arm/arch-at91rm9200/entry-macro.S
include/asm-arm/arch-at91rm9200/hardware.h
include/asm-arm/arch-at91rm9200/irqs.h
include/asm-arm/arch-at91rm9200/system.h
include/asm-arm/arch-at91rm9200/timex.h
include/asm-arm/arch-at91rm9200/uncompress.h
include/asm-arm/arch-at91rm9200/vmalloc.h
include/asm-arm/arch-clps711x/memory.h
include/asm-arm/arch-imx/timex.h
include/asm-arm/arch-iop13xx/debug-macro.S [new file with mode: 0644]
include/asm-arm/arch-iop13xx/dma.h [new file with mode: 0644]
include/asm-arm/arch-iop13xx/entry-macro.S [new file with mode: 0644]
include/asm-arm/arch-iop13xx/hardware.h [new file with mode: 0644]
include/asm-arm/arch-iop13xx/io.h [new file with mode: 0644]
include/asm-arm/arch-iop13xx/iop13xx.h [new file with mode: 0644]
include/asm-arm/arch-iop13xx/iq81340.h [new file with mode: 0644]
include/asm-arm/arch-iop13xx/irqs.h [new file with mode: 0644]
include/asm-arm/arch-iop13xx/memory.h [new file with mode: 0644]
include/asm-arm/arch-iop13xx/pci.h [new file with mode: 0644]
include/asm-arm/arch-iop13xx/system.h [new file with mode: 0644]
include/asm-arm/arch-iop13xx/timex.h [new file with mode: 0644]
include/asm-arm/arch-iop13xx/uncompress.h [new file with mode: 0644]
include/asm-arm/arch-iop13xx/vmalloc.h [new file with mode: 0644]
include/asm-arm/arch-ixp4xx/nslu2.h
include/asm-arm/arch-ixp4xx/udc.h [new file with mode: 0644]
include/asm-arm/arch-l7200/io.h
include/asm-arm/arch-lh7a40x/memory.h
include/asm-arm/arch-pxa/memory.h
include/asm-arm/arch-pxa/pxa-regs.h
include/asm-arm/arch-s3c2410/fb.h
include/asm-arm/arch-s3c2410/h1940.h [new file with mode: 0644]
include/asm-arm/arch-s3c2410/system.h
include/asm-arm/arch-sa1100/jornada720.h [deleted file]
include/asm-arm/arch-sa1100/memory.h
include/asm-arm/bug.h
include/asm-arm/cnt32_to_63.h [new file with mode: 0644]
include/asm-arm/div64.h
include/asm-arm/dma-mapping.h
include/asm-arm/elf.h
include/asm-arm/io.h
include/asm-arm/mach/irq.h
include/asm-arm/memory.h
include/asm-arm/pgtable-nommu.h
include/asm-arm/pgtable.h
include/asm-arm/processor.h
include/asm-arm/procinfo.h
include/asm-arm/setup.h
include/asm-arm/termbits.h
include/asm-arm/thread_info.h
include/asm-arm/unistd.h
include/asm-arm26/pgalloc.h
include/asm-arm26/setup.h
include/asm-arm26/termbits.h
include/asm-arm26/unistd.h
include/asm-avr32/arch-at32ap/at91_pdc.h [moved from include/asm-arm/arch-at91rm9200/at91rm9200_pdc.h with 92% similarity]
include/asm-avr32/dma-mapping.h
include/asm-avr32/setup.h
include/asm-avr32/termbits.h
include/asm-cris/arch-v10/bitops.h
include/asm-cris/dma-mapping.h
include/asm-cris/semaphore-helper.h
include/asm-cris/termbits.h
include/asm-frv/bitops.h
include/asm-frv/dma-mapping.h
include/asm-frv/highmem.h
include/asm-frv/param.h
include/asm-frv/setup.h
include/asm-frv/termbits.h
include/asm-frv/unistd.h
include/asm-generic/Kbuild
include/asm-generic/Kbuild.asm
include/asm-generic/atomic.h
include/asm-generic/bug.h
include/asm-generic/dma-mapping.h
include/asm-generic/futex.h
include/asm-generic/page.h
include/asm-generic/termios.h
include/asm-generic/vmlinux.lds.h
include/asm-h8300/delay.h
include/asm-h8300/mmu_context.h
include/asm-h8300/pci.h
include/asm-h8300/termbits.h
include/asm-h8300/tlbflush.h
include/asm-h8300/unistd.h
include/asm-i386/Kbuild
include/asm-i386/alternative.h
include/asm-i386/apic.h
include/asm-i386/atomic.h
include/asm-i386/boot.h
include/asm-i386/bug.h
include/asm-i386/bugs.h
include/asm-i386/cpu.h
include/asm-i386/cpufeature.h
include/asm-i386/current.h
include/asm-i386/delay.h
include/asm-i386/desc.h
include/asm-i386/dma-mapping.h
include/asm-i386/e820.h
include/asm-i386/elf.h
include/asm-i386/futex.h
include/asm-i386/genapic.h
include/asm-i386/i387.h
include/asm-i386/ide.h
include/asm-i386/io.h
include/asm-i386/irq.h
include/asm-i386/irq_regs.h
include/asm-i386/irqflags.h
include/asm-i386/mach-default/setup_arch.h
include/asm-i386/math_emu.h
include/asm-i386/mmu_context.h
include/asm-i386/mmzone.h
include/asm-i386/module.h
include/asm-i386/mpspec_def.h
include/asm-i386/msr.h
include/asm-i386/nmi.h
include/asm-i386/page.h
include/asm-i386/param.h
include/asm-i386/paravirt.h [new file with mode: 0644]
include/asm-i386/pda.h [new file with mode: 0644]
include/asm-i386/percpu.h
include/asm-i386/pgtable-2level.h
include/asm-i386/pgtable-3level.h
include/asm-i386/pgtable.h
include/asm-i386/processor.h
include/asm-i386/ptrace.h
include/asm-i386/rwsem.h
include/asm-i386/segment.h
include/asm-i386/setup.h
include/asm-i386/smp.h
include/asm-i386/spinlock.h
include/asm-i386/suspend.h
include/asm-i386/system.h
include/asm-i386/termbits.h
include/asm-i386/thread_info.h
include/asm-i386/time.h [new file with mode: 0644]
include/asm-i386/tlbflush.h
include/asm-i386/unistd.h
include/asm-i386/unwind.h
include/asm-i386/vm86.h
include/asm-ia64/Kbuild
include/asm-ia64/checksum.h
include/asm-ia64/dma-mapping.h
include/asm-ia64/futex.h
include/asm-ia64/kexec.h [new file with mode: 0644]
include/asm-ia64/machvec.h
include/asm-ia64/machvec_sn2.h
include/asm-ia64/meminit.h
include/asm-ia64/page.h
include/asm-ia64/pal.h
include/asm-ia64/pgalloc.h
include/asm-ia64/sn/sn_sal.h
include/asm-ia64/termbits.h
include/asm-m32r/ide.h
include/asm-m32r/m32102.h
include/asm-m32r/ptrace.h
include/asm-m32r/setup.h
include/asm-m32r/sigcontext.h
include/asm-m32r/termbits.h
include/asm-m32r/unistd.h
include/asm-m68k/dma-mapping.h
include/asm-m68k/setup.h
include/asm-m68k/sun3-head.h
include/asm-m68k/sun3ints.h
include/asm-m68k/termbits.h
include/asm-m68k/unistd.h
include/asm-m68knommu/setup.h
include/asm-m68knommu/unistd.h
include/asm-mips/bootinfo.h
include/asm-mips/dma-mapping.h
include/asm-mips/futex.h
include/asm-mips/highmem.h
include/asm-mips/mach-rm/cpu-feature-overrides.h [moved from include/asm-mips/mach-rm200/cpu-feature-overrides.h with 100% similarity]
include/asm-mips/mach-rm/mc146818rtc.h [moved from include/asm-mips/mach-rm200/mc146818rtc.h with 100% similarity]
include/asm-mips/mach-rm/timex.h [moved from include/asm-mips/mach-rm200/timex.h with 100% similarity]
include/asm-mips/setup.h
include/asm-mips/termbits.h
include/asm-mips/unistd.h
include/asm-mips/war.h
include/asm-parisc/dma-mapping.h
include/asm-parisc/futex.h
include/asm-parisc/termbits.h
include/asm-powerpc/bitops.h
include/asm-powerpc/dma-mapping.h
include/asm-powerpc/elf.h
include/asm-powerpc/futex.h
include/asm-powerpc/page_32.h
include/asm-powerpc/pgalloc.h
include/asm-powerpc/setup.h
include/asm-powerpc/termbits.h
include/asm-powerpc/unistd.h
include/asm-ppc/highmem.h
include/asm-s390/dasd.h
include/asm-s390/page.h
include/asm-s390/pgalloc.h
include/asm-s390/pgtable.h
include/asm-s390/setup.h
include/asm-s390/termbits.h
include/asm-s390/unistd.h
include/asm-sh/dma-mapping.h
include/asm-sh/setup.h
include/asm-sh/termbits.h
include/asm-sh/unistd.h
include/asm-sh64/dma-mapping.h
include/asm-sh64/setup.h
include/asm-sh64/unistd.h
include/asm-sparc/termbits.h
include/asm-sparc/unistd.h
include/asm-sparc64/dma-mapping.h
include/asm-sparc64/futex.h
include/asm-sparc64/pgalloc.h
include/asm-sparc64/termbits.h
include/asm-sparc64/unistd.h
include/asm-um/bug.h
include/asm-um/dma-mapping.h
include/asm-v850/irq.h
include/asm-v850/termbits.h
include/asm-v850/unistd.h
include/asm-x86_64/Kbuild
include/asm-x86_64/alternative.h
include/asm-x86_64/atomic.h
include/asm-x86_64/bug.h
include/asm-x86_64/calgary.h
include/asm-x86_64/cpufeature.h
include/asm-x86_64/delay.h
include/asm-x86_64/desc.h
include/asm-x86_64/desc_defs.h [new file with mode: 0644]
include/asm-x86_64/dma-mapping.h
include/asm-x86_64/futex.h
include/asm-x86_64/genapic.h
include/asm-x86_64/ioctls.h
include/asm-x86_64/msr.h
include/asm-x86_64/nmi.h
include/asm-x86_64/pci-direct.h
include/asm-x86_64/pgtable.h
include/asm-x86_64/processor.h
include/asm-x86_64/proto.h
include/asm-x86_64/rio.h [new file with mode: 0644]
include/asm-x86_64/smp.h
include/asm-x86_64/spinlock.h
include/asm-x86_64/stacktrace.h
include/asm-x86_64/termbits.h
include/asm-x86_64/termios.h
include/asm-x86_64/unistd.h
include/asm-x86_64/unwind.h
include/asm-x86_64/vsyscall.h
include/asm-xtensa/dma-mapping.h
include/asm-xtensa/unistd.h
include/crypto/b128ops.h [new file with mode: 0644]
include/crypto/gf128mul.h [new file with mode: 0644]
include/linux/Kbuild
include/linux/aio.h
include/linux/audit.h
include/linux/bitrev.h [new file with mode: 0644]
include/linux/bootmem.h
include/linux/bottom_half.h [new file with mode: 0644]
include/linux/bug.h [new file with mode: 0644]
include/linux/carta_random32.h [deleted file]
include/linux/cciss_ioctl.h
include/linux/cdev.h
include/linux/cpu.h
include/linux/cpuset.h
include/linux/crc32.h
include/linux/crypto.h
include/linux/debug_locks.h
include/linux/delayacct.h
include/linux/device-mapper.h
include/linux/device.h
include/linux/dm-ioctl.h
include/linux/efi.h
include/linux/elf.h
include/linux/ext3_jbd.h
include/linux/ext4_jbd2.h
include/linux/fault-inject.h [new file with mode: 0644]
include/linux/fb.h
include/linux/file.h
include/linux/freezer.h [new file with mode: 0644]
include/linux/fs.h
include/linux/fs_stack.h [new file with mode: 0644]
include/linux/fs_struct.h
include/linux/fsnotify.h
include/linux/fuse.h
include/linux/generic_serial.h
include/linux/genetlink.h
include/linux/genhd.h
include/linux/gfp.h
include/linux/gfs2_ondisk.h
include/linux/hid-debug.h [moved from drivers/usb/input/hid-debug.h with 100% similarity]
include/linux/hid.h [moved from drivers/usb/input/hid.h with 86% similarity]
include/linux/highmem.h
include/linux/hugetlb.h
include/linux/i2c-pxa.h
include/linux/i2o.h
include/linux/if_addr.h
include/linux/if_link.h
include/linux/init_task.h
include/linux/input.h
include/linux/interrupt.h
include/linux/ipmi.h
include/linux/ipmi_msgdefs.h
include/linux/ipmi_smi.h
include/linux/isdn.h
include/linux/istallion.h
include/linux/jbd.h
include/linux/jbd2.h
include/linux/kernel.h
include/linux/kexec.h
include/linux/kprobes.h
include/linux/ktime.h
include/linux/lockd/lockd.h
include/linux/lockdep.h
include/linux/log2.h [new file with mode: 0644]
include/linux/mm.h
include/linux/mmzone.h
include/linux/mnt_namespace.h [new file with mode: 0644]
include/linux/module.h
include/linux/moduleparam.h
include/linux/mount.h
include/linux/msg.h
include/linux/mutex.h
include/linux/namei.h
include/linux/namespace.h [deleted file]
include/linux/nbd.h
include/linux/netdevice.h
include/linux/netfilter/nf_conntrack_pptp.h
include/linux/nfs_fs.h
include/linux/nfs_page.h
include/linux/nfs_xdr.h
include/linux/nmi.h
include/linux/nsproxy.h
include/linux/pci_ids.h
include/linux/pfkeyv2.h
include/linux/pid.h
include/linux/pid_namespace.h [new file with mode: 0644]
include/linux/pktcdvd.h
include/linux/profile.h
include/linux/pspace.h [deleted file]
include/linux/quotaops.h
include/linux/radix-tree.h
include/linux/raid/raid5.h
include/linux/reiserfs_fs.h
include/linux/relay.h
include/linux/rmap.h
include/linux/rtmutex.h
include/linux/rtnetlink.h
include/linux/rwsem-spinlock.h
include/linux/sched.h
include/linux/screen_info.h
include/linux/seq_file.h
include/linux/serial_8250.h
include/linux/serial_core.h
include/linux/serio.h
include/linux/signal.h
include/linux/skbuff.h
include/linux/slab.h
include/linux/smp.h
include/linux/spinlock.h
include/linux/stallion.h
include/linux/start_kernel.h [new file with mode: 0644]
include/linux/sunrpc/auth_gss.h
include/linux/sunrpc/clnt.h
include/linux/sunrpc/debug.h
include/linux/sunrpc/gss_krb5.h
include/linux/sunrpc/gss_spkm3.h
include/linux/sunrpc/sched.h
include/linux/sunrpc/xdr.h
include/linux/sunrpc/xprt.h
include/linux/suspend.h
include/linux/swap.h
include/linux/taskstats_kern.h
include/linux/tty.h
include/linux/tty_driver.h
include/linux/tty_ldisc.h
include/linux/uaccess.h
include/linux/usb/serial.h
include/linux/workqueue.h
include/linux/xfrm.h
include/net/ax25.h
include/net/dst.h
include/net/inet_hashtables.h
include/net/irda/ircomm_tty.h
include/net/irda/irlan_filter.h
include/net/neighbour.h
include/net/netfilter/nf_conntrack_expect.h
include/net/request_sock.h
include/net/sock.h
include/net/timewait_sock.h
include/net/xfrm.h
include/scsi/libsas.h
include/video/mbxfb.h
include/video/pm3fb.h
init/Makefile
init/do_mounts_initrd.c
init/initramfs.c
init/main.c
init/version.c
ipc/compat.c
ipc/mqueue.c
ipc/msg.c
ipc/sem.c
ipc/shm.c
kernel/Kconfig.hz
kernel/acct.c
kernel/audit.c
kernel/auditfilter.c
kernel/auditsc.c
kernel/configs.c
kernel/cpu.c
kernel/cpuset.c
kernel/delayacct.c
kernel/dma.c
kernel/exit.c
kernel/fork.c
kernel/futex.c
kernel/irq/handle.c
kernel/irq/proc.c
kernel/kallsyms.c
kernel/kexec.c
kernel/kmod.c
kernel/kprobes.c
kernel/lockdep.c
kernel/lockdep_internals.h
kernel/lockdep_proc.c
kernel/module.c
kernel/mutex-debug.c
kernel/mutex.c
kernel/nsproxy.c
kernel/pid.c
kernel/posix-timers.c
kernel/power/Kconfig
kernel/power/disk.c
kernel/power/main.c
kernel/power/power.h
kernel/power/process.c
kernel/power/snapshot.c
kernel/power/swap.c
kernel/power/swsusp.c
kernel/power/user.c
kernel/printk.c
kernel/profile.c
kernel/rcupdate.c
kernel/rcutorture.c
kernel/relay.c
kernel/resource.c
kernel/rtmutex-tester.c
kernel/sched.c
kernel/signal.c
kernel/softirq.c
kernel/sys.c
kernel/sysctl.c
kernel/taskstats.c
kernel/unwind.c
kernel/user.c
kernel/workqueue.c
lib/Kconfig
lib/Kconfig.debug
lib/Makefile
lib/bitrev.c [new file with mode: 0644]
lib/bug.c [new file with mode: 0644]
lib/cmdline.c
lib/crc32.c
lib/fault-inject.c [new file with mode: 0644]
lib/idr.c
lib/kobject.c
lib/list_debug.c
lib/locking-selftest.c
lib/radix-tree.c
lib/spinlock_debug.c
mm/allocpercpu.c
mm/bootmem.c
mm/fadvise.c
mm/filemap.c
mm/filemap_xip.c
mm/fremap.c
mm/hugetlb.c
mm/memory.c
mm/memory_hotplug.c
mm/mempolicy.c
mm/migrate.c
mm/mlock.c
mm/mmap.c
mm/mmzone.c
mm/nommu.c
mm/oom_kill.c
mm/page_alloc.c
mm/page_io.c
mm/pdflush.c
mm/readahead.c
mm/shmem.c
mm/slab.c
mm/sparse.c
mm/swap.c
mm/swapfile.c
mm/thrash.c
mm/tiny-shmem.c
mm/vmscan.c
mm/vmstat.c
net/atm/proc.c
net/ax25/ax25_addr.c
net/bluetooth/rfcomm/tty.c
net/bridge/br_fdb.c
net/bridge/br_netfilter.c
net/core/dev.c
net/core/dst.c
net/core/flow.c
net/core/neighbour.c
net/core/netpoll.c
net/core/skbuff.c
net/core/sock.c
net/core/wireless.c
net/dccp/ackvec.c
net/dccp/ccid.c
net/dccp/ccid.h
net/dccp/ccids/ccid3.c
net/dccp/ccids/lib/loss_interval.c
net/dccp/ccids/lib/loss_interval.h
net/dccp/ccids/lib/packet_history.h
net/decnet/dn_table.c
net/ieee80211/softmac/ieee80211softmac_assoc.c
net/ieee80211/softmac/ieee80211softmac_auth.c
net/ieee80211/softmac/ieee80211softmac_priv.h
net/ieee80211/softmac/ieee80211softmac_wx.c
net/ipv4/fib_hash.c
net/ipv4/fib_trie.c
net/ipv4/inet_hashtables.c
net/ipv4/inet_timewait_sock.c
net/ipv4/inetpeer.c
net/ipv4/ip_output.c
net/ipv4/ipmr.c
net/ipv4/ipvs/ip_vs_conn.c
net/ipv4/netfilter/arp_tables.c
net/ipv4/netfilter/ip_conntrack_core.c
net/ipv4/netfilter/ip_tables.c
net/ipv4/netfilter/ipt_CLUSTERIP.c
net/ipv4/netfilter/ipt_recent.c
net/ipv4/route.c
net/ipv4/tcp_input.c
net/ipv4/xfrm4_policy.c
net/ipv6/af_inet6.c
net/ipv6/ip6_fib.c
net/ipv6/ip6_output.c
net/ipv6/netfilter/ip6_tables.c
net/ipv6/raw.c
net/ipv6/xfrm6_tunnel.c
net/irda/ircomm/ircomm_tty_ioctl.c
net/irda/irttp.c
net/key/af_key.c
net/netfilter/nf_conntrack_core.c
net/netfilter/nf_conntrack_expect.c
net/netfilter/xt_hashlimit.c
net/netlink/af_netlink.c
net/netlink/genetlink.c
net/packet/af_packet.c
net/rxrpc/krxiod.c
net/rxrpc/krxsecd.c
net/rxrpc/krxtimod.c
net/sched/cls_fw.c
net/sched/sch_cbq.c
net/sched/sch_htb.c
net/sctp/protocol.c
net/sctp/sm_make_chunk.c
net/sctp/socket.c
net/socket.c
net/sunrpc/auth_gss/auth_gss.c
net/sunrpc/auth_gss/gss_krb5_crypto.c
net/sunrpc/auth_gss/gss_krb5_mech.c
net/sunrpc/auth_gss/gss_krb5_seal.c
net/sunrpc/auth_gss/gss_krb5_unseal.c
net/sunrpc/auth_gss/gss_krb5_wrap.c
net/sunrpc/auth_gss/gss_spkm3_mech.c
net/sunrpc/auth_gss/gss_spkm3_seal.c
net/sunrpc/auth_gss/gss_spkm3_token.c
net/sunrpc/auth_gss/gss_spkm3_unseal.c
net/sunrpc/cache.c
net/sunrpc/clnt.c
net/sunrpc/pmap_clnt.c
net/sunrpc/rpc_pipe.c
net/sunrpc/sched.c
net/sunrpc/socklib.c
net/sunrpc/sunrpc_syms.c
net/sunrpc/svcauth.c
net/sunrpc/svcsock.c
net/sunrpc/sysctl.c
net/sunrpc/xdr.c
net/sunrpc/xprt.c
net/sunrpc/xprtsock.c
net/tipc/handler.c
net/unix/garbage.c
net/wanrouter/wanmain.c
net/xfrm/xfrm_algo.c
net/xfrm/xfrm_input.c
net/xfrm/xfrm_policy.c
net/xfrm/xfrm_state.c
net/xfrm/xfrm_user.c
scripts/kallsyms.c
scripts/kconfig/qconf.cc
scripts/kernel-doc
scripts/mod/modpost.c
scripts/ver_linux
security/keys/key.c
security/keys/keyring.c
security/keys/process_keys.c
security/selinux/avc.c
security/selinux/hooks.c
security/selinux/selinuxfs.c
security/selinux/ss/avtab.c
sound/arm/sa11xx-uda1341.c
sound/core/info.c
sound/core/pcm_native.c
sound/oss/Kconfig
sound/oss/btaudio.c
sound/oss/dmasound/dmasound_core.c
sound/oss/emu10k1/audio.c
sound/oss/emu10k1/cardwi.c
sound/oss/emu10k1/cardwi.h
sound/oss/emu10k1/passthrough.c
sound/oss/msnd_pinnacle.c
sound/oss/soundcard.c
sound/oss/via82cxxx_audio.c
sound/sound_firmware.c
sound/usb/usx2y/usX2Yhwdep.c

diff --git a/CREDITS b/CREDITS
index d0880082c19bda5b25a8a51df7849af2ec55aac5..8218e790f43d33d2c754df8f149b56ef7c19b816 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -1808,6 +1808,14 @@ S: Kruislaan 419
 S: 1098 VA Amsterdam 
 S: The Netherlands
 
+N: Jiri Kosina
+E: jikos@jikos.cz
+E: jkosina@suse.cz
+D: Generic HID layer - original code split, fixes
+D: Various ACPI fixes, keeping correct battery state through suspend
+D: various lockdep annotations, autofs and other random bugfixes
+S: Prague, Czech Republic
+
 N: Gene Kozin
 E: 74604.152@compuserve.com
 W: http://www.sangoma.com
diff --git a/Documentation/ABI/testing/debugfs-pktcdvd b/Documentation/ABI/testing/debugfs-pktcdvd
new file mode 100644 (file)
index 0000000..03dbd88
--- /dev/null
@@ -0,0 +1,20 @@
+What:           /debug/pktcdvd/pktcdvd[0-7]
+Date:           Oct. 2006
+KernelVersion:  2.6.19
+Contact:        Thomas Maier <balagi@justmail.de>
+Description:
+
+debugfs interface
+-----------------
+
+The pktcdvd module (packet writing driver) creates
+these files in debugfs:
+
+/debug/pktcdvd/pktcdvd[0-7]/
+    info            (0444) Lots of human readable driver
+                           statistics and infos. Multiple lines!
+
+Example:
+-------
+
+cat /debug/pktcdvd/pktcdvd0/info
diff --git a/Documentation/ABI/testing/sysfs-class-pktcdvd b/Documentation/ABI/testing/sysfs-class-pktcdvd
new file mode 100644 (file)
index 0000000..c4c55ed
--- /dev/null
@@ -0,0 +1,72 @@
+What:           /sys/class/pktcdvd/
+Date:           Oct. 2006
+KernelVersion:  2.6.19
+Contact:        Thomas Maier <balagi@justmail.de>
+Description:
+
+sysfs interface
+---------------
+
+The pktcdvd module (packet writing driver) creates
+these files in the sysfs:
+(<devid> is in format  major:minor )
+
+/sys/class/pktcdvd/
+    add            (0200)  Write a block device id (major:minor)
+                           to create a new pktcdvd device and map
+                           it to the block device.
+
+    remove         (0200)  Write the pktcdvd device id (major:minor)
+                           to it to remove the pktcdvd device.
+
+    device_map     (0444)  Shows the device mapping in format:
+                             pktcdvd[0-7] <pktdevid> <blkdevid>
+
+/sys/class/pktcdvd/pktcdvd[0-7]/
+    dev                   (0444) Device id
+    uevent                (0200) To send an uevent.
+
+/sys/class/pktcdvd/pktcdvd[0-7]/stat/
+    packets_started       (0444) Number of started packets.
+    packets_finished      (0444) Number of finished packets.
+
+    kb_written            (0444) kBytes written.
+    kb_read               (0444) kBytes read.
+    kb_read_gather        (0444) kBytes read to fill write packets.
+
+    reset                 (0200) Write any value to it to reset
+                                 pktcdvd device statistic values, like
+                                 bytes read/written.
+
+/sys/class/pktcdvd/pktcdvd[0-7]/write_queue/
+    size                  (0444) Contains the size of the bio write
+                                 queue.
+
+    congestion_off        (0644) If bio write queue size is below
+                                 this mark, accept new bio requests
+                                 from the block layer.
+
+    congestion_on         (0644) If bio write queue size is higher
+                                 as this mark, do no longer accept
+                                 bio write requests from the block
+                                 layer and wait till the pktcdvd
+                                 device has processed enough bio's
+                                 so that bio write queue size is
+                                 below congestion off mark.
+                                 A value of <= 0 disables congestion
+                                 control.
+
+
+Example:
+--------
+To use the pktcdvd sysfs interface directly, you can do:
+
+# create a new pktcdvd device mapped to /dev/hdc
+echo "22:0" >/sys/class/pktcdvd/add
+cat /sys/class/pktcdvd/device_map
+# assuming device pktcdvd0 was created, look at stat's
+cat /sys/class/pktcdvd/pktcdvd0/stat/kb_written
+# print the device id of the mapped block device
+fgrep pktcdvd0 /sys/class/pktcdvd/device_map
+# remove device, using pktcdvd0 device id   253:0
+echo "253:0" >/sys/class/pktcdvd/remove
index 05431621c861d7b9f0228a228414beb3fb3ee52e..805db4b2cba65b65bd966f054c71ca13427f9287 100644 (file)
@@ -77,7 +77,7 @@ To get this part of the dma_ API, you must #include <linux/dmapool.h>
 Many drivers need lots of small dma-coherent memory regions for DMA
 descriptors or I/O buffers.  Rather than allocating in units of a page
 or more using dma_alloc_coherent(), you can use DMA pools.  These work
-much like a kmem_cache_t, except that they use the dma-coherent allocator
+much like a struct kmem_cache, except that they use the dma-coherent allocator
 not __get_free_pages().  Also, they understand common hardware constraints
 for alignment, like queue heads needing to be aligned on N byte boundaries.
 
@@ -94,7 +94,7 @@ The pool create() routines initialize a pool of dma-coherent buffers
 for use with a given device.  It must be called in a context which
 can sleep.
 
-The "name" is for diagnostics (like a kmem_cache_t name); dev and size
+The "name" is for diagnostics (like a struct kmem_cache name); dev and size
 are like what you'd pass to dma_alloc_coherent().  The device's hardware
 alignment requirement for this type of data is "align" (which is expressed
 in bytes, and must be a power of two).  If your device has no boundary
@@ -431,10 +431,10 @@ be identical to those passed in (and returned by
 dma_alloc_noncoherent()).
 
 int
-dma_is_consistent(dma_addr_t dma_handle)
+dma_is_consistent(struct device *dev, dma_addr_t dma_handle)
 
-returns true if the memory pointed to by the dma_handle is actually
-consistent.
+returns true if the device dev is performing consistent DMA on the memory
+area pointed to by the dma_handle.
 
 int
 dma_get_cache_alignment(void)
@@ -459,7 +459,7 @@ anything like this.  You must also be extra careful about accessing
 memory you intend to sync partially.
 
 void
-dma_cache_sync(void *vaddr, size_t size,
+dma_cache_sync(struct device *dev, void *vaddr, size_t size,
               enum dma_data_direction direction)
 
 Do a partial sync of memory that was allocated by
index a166675c4303150c7be6111f917b0f2bcd422998..3fa0c4b4541e065760a3c119e88d314ba3b6ee91 100644 (file)
@@ -418,9 +418,35 @@ X!Edrivers/pnp/system.c
 !Idrivers/parport/daisy.c
   </chapter>
 
-  <chapter id="viddev">
-     <title>Video4Linux</title>
-!Edrivers/media/video/videodev.c
+  <chapter id="message_devices">
+       <title>Message-based devices</title>
+     <sect1><title>Fusion message devices</title>
+!Edrivers/message/fusion/mptbase.c
+!Idrivers/message/fusion/mptbase.c
+!Edrivers/message/fusion/mptscsih.c
+!Idrivers/message/fusion/mptscsih.c
+!Idrivers/message/fusion/mptctl.c
+!Idrivers/message/fusion/mptspi.c
+!Idrivers/message/fusion/mptfc.c
+!Idrivers/message/fusion/mptlan.c
+     </sect1>
+     <sect1><title>I2O message devices</title>
+!Iinclude/linux/i2o.h
+!Idrivers/message/i2o/core.h
+!Edrivers/message/i2o/iop.c
+!Idrivers/message/i2o/iop.c
+!Idrivers/message/i2o/config-osm.c
+!Edrivers/message/i2o/exec-osm.c
+!Idrivers/message/i2o/exec-osm.c
+!Idrivers/message/i2o/bus-osm.c
+!Edrivers/message/i2o/device.c
+!Idrivers/message/i2o/device.c
+!Idrivers/message/i2o/driver.c
+!Idrivers/message/i2o/pci.c
+!Idrivers/message/i2o/i2o_block.c
+!Idrivers/message/i2o/i2o_scsi.c
+!Idrivers/message/i2o/i2o_proc.c
+     </sect1>
   </chapter>
 
   <chapter id="snddev">
@@ -533,4 +559,12 @@ X!Idrivers/video/console/fonts.c
 -->
      </sect1>
   </chapter>
+
+  <chapter id="input_subsystem">
+     <title>Input Subsystem</title>
+!Iinclude/linux/input.h
+!Edrivers/input/input.c
+!Edrivers/input/ff-core.c
+!Edrivers/input/ff-memless.c
+  </chapter>
 </book>
index 0e3924ecd76b4e9b197348d656712fee80a2691d..24dc3fcf15948e8a9ed93043cf46c0e81f929c36 100644 (file)
@@ -365,6 +365,7 @@ You can change this at module load time (for a module) with:
        regshifts=<shift1>,<shift2>,...
        slave_addrs=<addr1>,<addr2>,...
        force_kipmid=<enable1>,<enable2>,...
+       unload_when_empty=[0|1]
 
 Each of these except si_trydefaults is a list, the first item for the
 first interface, second item for the second interface, etc.
@@ -416,6 +417,11 @@ by the driver, but systems with broken interrupts might need an enable,
 or users that don't want the daemon (don't need the performance, don't
 want the CPU hit) can disable it.
 
+If unload_when_empty is set to 1, the driver will be unloaded if it
+doesn't find any interfaces or all the interfaces fail to work.  The
+default is one.  Setting to 0 is useful with the hotmod, but is
+obviously only useful for modules.
+
 When compiled into the kernel, the parameters can be specified on the
 kernel command line as:
 
@@ -441,6 +447,25 @@ have high-res timers enabled in the kernel and you don't have
 interrupts enabled, the driver will run VERY slowly.  Don't blame me,
 these interfaces suck.
 
+The driver supports a hot add and remove of interfaces.  This way,
+interfaces can be added or removed after the kernel is up and running.
+This is done using /sys/modules/ipmi_si/hotmod, which is a write-only
+parameter.  You write a string to this interface.  The string has the
+format:
+   <op1>[:op2[:op3...]]
+The "op"s are:
+   add|remove,kcs|bt|smic,mem|i/o,<address>[,<opt1>[,<opt2>[,...]]]
+You can specify more than one interface on the line.  The "opt"s are:
+   rsp=<regspacing>
+   rsi=<regsize>
+   rsh=<regshift>
+   irq=<irq>
+   ipmb=<ipmb slave addr>
+and these have the same meanings as discussed above.  Note that you
+can also use this on the kernel command line for a more compact format
+for specifying an interface.  Note that when removing an interface,
+only the first three parameters (si type, address type, and address)
+are used for the comparison.  Any options are ignored for removing.
 
 The SMBus Driver
 ----------------
@@ -502,7 +527,10 @@ used to control it:
 
   modprobe ipmi_watchdog timeout=<t> pretimeout=<t> action=<action type>
       preaction=<preaction type> preop=<preop type> start_now=x
-      nowayout=x
+      nowayout=x ifnum_to_use=n
+
+ifnum_to_use specifies which interface the watchdog timer should use.
+The default is -1, which means to pick the first one registered.
 
 The timeout is the number of seconds to the action, and the pretimeout
 is the amount of seconds before the reset that the pre-timeout panic will
@@ -624,5 +652,9 @@ command line.  The parameter is also available via the proc filesystem
 in /proc/sys/dev/ipmi/poweroff_powercycle.  Note that if the system
 does not support power cycling, it will always do the power off.
 
+The "ifnum_to_use" parameter specifies which interface the poweroff
+code should use.  The default is -1, which means to pick the first one
+registered.
+
 Note that if you have ACPI enabled, the system will prefer using ACPI to
 power off.
index e2a66f8143c5c63b0b780ee13fc1069b87c82011..a598fe10a2974f5757761df5ab8f7f98c5c5f84a 100644 (file)
@@ -24,8 +24,10 @@ very similar behavior to the deadline IO scheduler.
 Selecting IO schedulers
 -----------------------
 To choose IO schedulers at boot time, use the argument 'elevator=deadline'.
-'noop' and 'as' (the default) are also available. IO schedulers are assigned
-globally at boot time only presently.
+'noop', 'as' and 'cfq' (the default) are also available. IO schedulers are
+assigned globally at boot time only presently. It's also possible to change
+the IO scheduler for a determined device on the fly, as described in
+Documentation/block/switching-sched.txt.
 
 
 Anticipatory IO scheduler Policies
index 3d44c561fe6d935c868bc2d6a4755452cb56c1a1..7715d2247c4de4cf01045a7f46ce9ce5bf36a7a4 100644 (file)
@@ -90,6 +90,41 @@ Notes
   to create an ext2 filesystem on the disc.
 
 
+Using the pktcdvd sysfs interface
+---------------------------------
+
+Since Linux 2.6.19, the pktcdvd module has a sysfs interface
+and can be controlled by it. For example the "pktcdvd" tool uses
+this interface. (see http://people.freenet.de/BalaGi#pktcdvd )
+
+"pktcdvd" works similar to "pktsetup", e.g.:
+
+       # pktcdvd -a dev_name /dev/hdc
+       # mkudffs /dev/pktcdvd/dev_name
+       # mount -t udf -o rw,noatime /dev/pktcdvd/dev_name /dvdram
+       # cp files /dvdram
+       # umount /dvdram
+       # pktcdvd -r dev_name
+
+
+For a description of the sysfs interface look into the file:
+
+  Documentation/ABI/testing/sysfs-block-pktcdvd
+
+
+Using the pktcdvd debugfs interface
+-----------------------------------
+
+To read pktcdvd device infos in human readable form, do:
+
+       # cat /debug/pktcdvd/pktcdvd[0-7]/info
+
+For a description of the debugfs interface look into the file:
+
+  Documentation/ABI/testing/debugfs-pktcdvd
+
+
+
 Links
 -----
 
index 70690f1a14af53cd128ab0a553421044e28cd319..8de132a02ba952867020a846229b0818ee73d214 100644 (file)
@@ -3,7 +3,7 @@
 
             Maintained by Torben Mathiasen <device@lanana.org>
 
-                     Last revised: 15 May 2006
+                     Last revised: 29 November 2006
 
 This list is the Linux Device List, the official registry of allocated
 device numbers and /dev directory nodes for the Linux operating
@@ -94,6 +94,7 @@ Your cooperation is appreciated.
                  9 = /dev/urandom      Faster, less secure random number gen.
                 10 = /dev/aio          Asynchronous I/O notification interface
                 11 = /dev/kmsg         Writes to this come out as printk's
+
   1 block      RAM disk
                  0 = /dev/ram0         First RAM disk
                  1 = /dev/ram1         Second RAM disk
@@ -122,7 +123,7 @@ Your cooperation is appreciated.
                devices are on major 128 and above and use the PTY
                master multiplex (/dev/ptmx) to acquire a PTY on
                demand.
-  
+
   2 block      Floppy disks
                  0 = /dev/fd0          Controller 0, drive 0, autodetect
                  1 = /dev/fd1          Controller 0, drive 1, autodetect
@@ -257,7 +258,7 @@ Your cooperation is appreciated.
                129 = /dev/vcsa1        tty1 text/attribute contents
                    ...
                191 = /dev/vcsa63       tty63 text/attribute contents
-       
+
                NOTE: These devices permit both read and write access.
 
   7 block      Loopback devices
@@ -411,7 +412,7 @@ Your cooperation is appreciated.
                207 = /dev/video/em8300_sp      EM8300 DVD decoder subpicture
                208 = /dev/compaq/cpqphpc       Compaq PCI Hot Plug Controller
                209 = /dev/compaq/cpqrid        Compaq Remote Insight Driver
-               210 = /dev/impi/bt      IMPI coprocessor block transfer 
+               210 = /dev/impi/bt      IMPI coprocessor block transfer
                211 = /dev/impi/smic    IMPI coprocessor stream interface
                212 = /dev/watchdogs/0  First watchdog device
                213 = /dev/watchdogs/1  Second watchdog device
@@ -506,6 +507,7 @@ Your cooperation is appreciated.
                 33 = /dev/patmgr1      Sequencer patch manager
                 34 = /dev/midi02       Third MIDI port
                 50 = /dev/midi03       Fourth MIDI port
+
  14 block      BIOS harddrive callback support {2.6}
                  0 = /dev/dos_hda      First BIOS harddrive whole disk
                 64 = /dev/dos_hdb      Second BIOS harddrive whole disk
@@ -527,6 +529,7 @@ Your cooperation is appreciated.
 
  16 char       Non-SCSI scanners
                  0 = /dev/gs4500       Genius 4500 handheld scanner
+
  16 block      GoldStar CD-ROM
                  0 = /dev/gscd         GoldStar CD-ROM
 
@@ -548,6 +551,7 @@ Your cooperation is appreciated.
                  0 = /dev/ttyC0        First Cyclades port
                    ...
                 31 = /dev/ttyC31       32nd Cyclades port
+
  19 block      "Double" compressed disk
                  0 = /dev/double0      First compressed disk
                    ...
@@ -563,6 +567,7 @@ Your cooperation is appreciated.
                  0 = /dev/cub0         Callout device for ttyC0
                    ...
                 31 = /dev/cub31        Callout device for ttyC31
+
  20 block      Hitachi CD-ROM (under development)
                  0 = /dev/hitcd        Hitachi CD-ROM
 
@@ -582,7 +587,7 @@ Your cooperation is appreciated.
 
                This device is used on the ARM-based Acorn RiscPC.
                Partitions are handled the same way as for IDE disks
-               (see major number 3). 
+               (see major number 3).
 
  22 char       Digiboard serial card
                  0 = /dev/ttyD0        First Digiboard port
@@ -591,7 +596,7 @@ Your cooperation is appreciated.
  22 block      Second IDE hard disk/CD-ROM interface
                  0 = /dev/hdc          Master: whole disk (or CD-ROM)
                 64 = /dev/hdd          Slave: whole disk (or CD-ROM)
-               
+
                Partitions are handled the same way as for the first
                interface (see major number 3).
 
@@ -639,6 +644,7 @@ Your cooperation is appreciated.
 
  26 char       Quanta WinVision frame grabber {2.6}
                  0 = /dev/wvisfgrab    Quanta WinVision frame grabber
+
  26 block      Second Matsushita (Panasonic/SoundBlaster) CD-ROM
                  0 = /dev/sbpcd4       Panasonic CD-ROM controller 1 unit 0
                  1 = /dev/sbpcd5       Panasonic CD-ROM controller 1 unit 1
@@ -670,6 +676,7 @@ Your cooperation is appreciated.
                 37 = /dev/nrawqft1     Unit 1, no rewind-on-close, no file marks
                 38 = /dev/nrawqft2     Unit 2, no rewind-on-close, no file marks
                 39 = /dev/nrawqft3     Unit 3, no rewind-on-close, no file marks
+
  27 block      Third Matsushita (Panasonic/SoundBlaster) CD-ROM
                  0 = /dev/sbpcd8       Panasonic CD-ROM controller 2 unit 0
                  1 = /dev/sbpcd9       Panasonic CD-ROM controller 2 unit 1
@@ -681,6 +688,7 @@ Your cooperation is appreciated.
                  1 = /dev/staliomem1   Second Stallion card I/O memory
                  2 = /dev/staliomem2   Third Stallion card I/O memory
                  3 = /dev/staliomem3   Fourth Stallion card I/O memory
+
  28 char       Atari SLM ACSI laser printer (68k/Atari)
                  0 = /dev/slm0         First SLM laser printer
                  1 = /dev/slm1         Second SLM laser printer
@@ -690,6 +698,7 @@ Your cooperation is appreciated.
                  1 = /dev/sbpcd13      Panasonic CD-ROM controller 3 unit 1
                  2 = /dev/sbpcd14      Panasonic CD-ROM controller 3 unit 2
                  3 = /dev/sbpcd15      Panasonic CD-ROM controller 3 unit 3
+
  28 block      ACSI disk (68k/Atari)
                  0 = /dev/ada          First ACSI disk whole disk
                 16 = /dev/adb          Second ACSI disk whole disk
@@ -750,6 +759,7 @@ Your cooperation is appreciated.
  31 char       MPU-401 MIDI
                  0 = /dev/mpu401data   MPU-401 data port
                  1 = /dev/mpu401stat   MPU-401 status port
+
  31 block      ROM/flash memory card
                  0 = /dev/rom0         First ROM card (rw)
                      ...
@@ -801,7 +811,7 @@ Your cooperation is appreciated.
  34 block      Fourth IDE hard disk/CD-ROM interface
                  0 = /dev/hdg          Master: whole disk (or CD-ROM)
                 64 = /dev/hdh          Slave: whole disk (or CD-ROM)
-               
+
                Partitions are handled the same way as for the first
                interface (see major number 3).
 
@@ -818,6 +828,7 @@ Your cooperation is appreciated.
                129 = /dev/smpte1       Second MIDI port, SMPTE timed
                130 = /dev/smpte2       Third MIDI port, SMPTE timed
                131 = /dev/smpte3       Fourth MIDI port, SMPTE timed
+
  35 block      Slow memory ramdisk
                  0 = /dev/slram        Slow memory ramdisk
 
@@ -828,6 +839,7 @@ Your cooperation is appreciated.
                 16 = /dev/tap0         First Ethertap device
                    ...
                 31 = /dev/tap15        16th Ethertap device
+
  36 block      MCA ESDI hard disk
                  0 = /dev/eda          First ESDI disk whole disk
                 64 = /dev/edb          Second ESDI disk whole disk
@@ -882,6 +894,7 @@ Your cooperation is appreciated.
 
  40 char       Matrox Meteor frame grabber {2.6}
                  0 = /dev/mmetfgrab    Matrox Meteor frame grabber
+
  40 block      Syquest EZ135 parallel port removable drive
                  0 = /dev/eza          Parallel EZ135 drive, whole disk
 
@@ -893,6 +906,7 @@ Your cooperation is appreciated.
 
  41 char       Yet Another Micro Monitor
                  0 = /dev/yamm         Yet Another Micro Monitor
+
  41 block      MicroSolutions BackPack parallel port CD-ROM
                  0 = /dev/bpcd         BackPack CD-ROM
 
@@ -901,6 +915,7 @@ Your cooperation is appreciated.
                the parallel port ATAPI CD-ROM driver at major number 46.
 
  42 char       Demo/sample use
+
  42 block      Demo/sample use
 
                This number is intended for use in sample code, as
@@ -918,6 +933,7 @@ Your cooperation is appreciated.
                  0 = /dev/ttyI0        First virtual modem
                    ...
                 63 = /dev/ttyI63       64th virtual modem
+
  43 block      Network block devices
                  0 = /dev/nb0          First network block device
                  1 = /dev/nb1          Second network block device
@@ -934,12 +950,13 @@ Your cooperation is appreciated.
                  0 = /dev/cui0         Callout device for ttyI0
                    ...
                 63 = /dev/cui63        Callout device for ttyI63
+
  44 block      Flash Translation Layer (FTL) filesystems
                  0 = /dev/ftla         FTL on first Memory Technology Device
                 16 = /dev/ftlb         FTL on second Memory Technology Device
                 32 = /dev/ftlc         FTL on third Memory Technology Device
                    ...
-               240 = /dev/ftlp         FTL on 16th Memory Technology Device 
+               240 = /dev/ftlp         FTL on 16th Memory Technology Device
 
                Partitions are handled in the same way as for IDE
                disks (see major number 3) except that the partition
@@ -958,6 +975,7 @@ Your cooperation is appreciated.
                191 = /dev/ippp63       64th SyncPPP device
 
                255 = /dev/isdninfo     ISDN monitor interface
+
  45 block      Parallel port IDE disk devices
                  0 = /dev/pda          First parallel port IDE disk
                 16 = /dev/pdb          Second parallel port IDE disk
@@ -1044,6 +1062,7 @@ Your cooperation is appreciated.
                  1 = /dev/dcbri1       Second DataComm card
                  2 = /dev/dcbri2       Third DataComm card
                  3 = /dev/dcbri3       Fourth DataComm card
+
  52 block      Mylex DAC960 PCI RAID controller; fifth controller
                  0 = /dev/rd/c4d0      First disk, whole disk
                  8 = /dev/rd/c4d1      Second disk, whole disk
@@ -1093,6 +1112,7 @@ Your cooperation is appreciated.
 
  55 char       DSP56001 digital signal processor
                  0 = /dev/dsp56k       First DSP56001
+
  55 block      Mylex DAC960 PCI RAID controller; eighth controller
                  0 = /dev/rd/c7d0      First disk, whole disk
                  8 = /dev/rd/c7d1      Second disk, whole disk
@@ -1130,6 +1150,7 @@ Your cooperation is appreciated.
                  0 = /dev/cup0         Callout device for ttyP0
                  1 = /dev/cup1         Callout device for ttyP1
                    ...
+
  58 block      Reserved for logical volume manager
 
  59 char       sf firewall package
@@ -1149,6 +1170,7 @@ Your cooperation is appreciated.
                NAMING CONFLICT -- PROPOSED REVISED NAME /dev/rpda0 etc
 
  60-63 char    LOCAL/EXPERIMENTAL USE
+
  60-63 block   LOCAL/EXPERIMENTAL USE
                Allocated for local/experimental use.  For devices not
                assigned official numbers, these ranges should be
@@ -1434,7 +1456,6 @@ Your cooperation is appreciated.
                DAC960 (see major number 48) except that the limit on
                partitions is 15.
 
-
  78 char       PAM Software's multimodem boards
                  0 = /dev/ttyM0        First PAM modem
                  1 = /dev/ttyM1        Second PAM modem
@@ -1450,7 +1471,6 @@ Your cooperation is appreciated.
                DAC960 (see major number 48) except that the limit on
                partitions is 15.
 
-
  79 char       PAM Software's multimodem boards - alternate devices
                  0 = /dev/cum0         Callout device for ttyM0
                  1 = /dev/cum1         Callout device for ttyM1
@@ -1466,7 +1486,6 @@ Your cooperation is appreciated.
                DAC960 (see major number 48) except that the limit on
                partitions is 15.
 
-
  80 char       Photometrics AT200 CCD camera
                  0 = /dev/at200        Photometrics AT200 CCD camera
 
@@ -1679,7 +1698,7 @@ Your cooperation is appreciated.
                  1 = /dev/dcxx1        Second capture card
                    ...
 
- 94 block IBM S/390 DASD block storage
+ 94 block      IBM S/390 DASD block storage
                  0 = /dev/dasda First DASD device, major
                  1 = /dev/dasda1 First DASD device, block 1
                  2 = /dev/dasda2 First DASD device, block 2
@@ -1695,7 +1714,7 @@ Your cooperation is appreciated.
                  1 = /dev/ipnat        NAT control device/log file
                  2 = /dev/ipstate      State information log file
                  3 = /dev/ipauth       Authentication control device/log file
-                   ...         
+                   ...
 
  96 char       Parallel port ATAPI tape devices
                  0 = /dev/pt0          First parallel port ATAPI tape
@@ -1705,7 +1724,7 @@ Your cooperation is appreciated.
                129 = /dev/npt1         Second p.p. ATAPI tape, no rewind
                    ...
 
- 96 block Inverse NAND Flash Translation Layer
+ 96 block      Inverse NAND Flash Translation Layer
                  0 = /dev/inftla First INFTL layer
                 16 = /dev/inftlb Second INFTL layer
                    ...
@@ -1937,7 +1956,6 @@ Your cooperation is appreciated.
                    ...
 
 113 block      IBM iSeries virtual CD-ROM
-
                  0 = /dev/iseries/vcda First virtual CD-ROM
                  1 = /dev/iseries/vcdb Second virtual CD-ROM
                    ...
@@ -2059,11 +2077,12 @@ Your cooperation is appreciated.
                    ...
 
 119 char       VMware virtual network control
-                 0 = /dev/vnet0        1st virtual network
-                 1 = /dev/vnet1        2nd virtual network
+                 0 = /dev/vmnet0       1st virtual network
+                 1 = /dev/vmnet1       2nd virtual network
                    ...
 
 120-127 char   LOCAL/EXPERIMENTAL USE
+
 120-127 block  LOCAL/EXPERIMENTAL USE
                Allocated for local/experimental use.  For devices not
                assigned official numbers, these ranges should be
@@ -2075,7 +2094,6 @@ Your cooperation is appreciated.
                nodes; instead they should be accessed through the
                /dev/ptmx cloning interface.
 
-
 128 block       SCSI disk devices (128-143)
                   0 = /dev/sddy         129th SCSI disk whole disk
                  16 = /dev/sddz         130th SCSI disk whole disk
@@ -2087,7 +2105,6 @@ Your cooperation is appreciated.
                disks (see major number 3) except that the limit on
                partitions is 15.
 
-
 129 block       SCSI disk devices (144-159)
                   0 = /dev/sdeo         145th SCSI disk whole disk
                  16 = /dev/sdep         146th SCSI disk whole disk
@@ -2123,7 +2140,6 @@ Your cooperation is appreciated.
                disks (see major number 3) except that the limit on
                partitions is 15.
 
-
 132 block       SCSI disk devices (192-207)
                   0 = /dev/sdgk         193rd SCSI disk whole disk
                  16 = /dev/sdgl         194th SCSI disk whole disk
@@ -2135,7 +2151,6 @@ Your cooperation is appreciated.
                disks (see major number 3) except that the limit on
                partitions is 15.
 
-
 133 block       SCSI disk devices (208-223)
                   0 = /dev/sdha         209th SCSI disk whole disk
                  16 = /dev/sdhb         210th SCSI disk whole disk
@@ -2147,7 +2162,6 @@ Your cooperation is appreciated.
                disks (see major number 3) except that the limit on
                partitions is 15.
 
-
 134 block       SCSI disk devices (224-239)
                   0 = /dev/sdhq         225th SCSI disk whole disk
                  16 = /dev/sdhr         226th SCSI disk whole disk
@@ -2159,7 +2173,6 @@ Your cooperation is appreciated.
                disks (see major number 3) except that the limit on
                partitions is 15.
 
-
 135 block       SCSI disk devices (240-255)
                   0 = /dev/sdig         241st SCSI disk whole disk
                  16 = /dev/sdih         242nd SCSI disk whole disk
@@ -2171,7 +2184,6 @@ Your cooperation is appreciated.
                disks (see major number 3) except that the limit on
                partitions is 15.
 
-
 136-143 char   Unix98 PTY slaves
                  0 = /dev/pts/0        First Unix98 pseudo-TTY
                  1 = /dev/pts/1        Second Unix98 pesudo-TTY
@@ -2384,6 +2396,7 @@ Your cooperation is appreciated.
                    ...
 
 159 char       RESERVED
+
 159 block      RESERVED
 
 160 char       General Purpose Instrument Bus (GPIB)
@@ -2427,7 +2440,7 @@ Your cooperation is appreciated.
 
                Partitions are handled in the same way as for IDE
                disks (see major number 3) except that the limit on
-               partitions is 31. 
+               partitions is 31.
 
 162 char       Raw block device interface
                  0 = /dev/rawctl       Raw I/O control device
@@ -2483,7 +2496,6 @@ Your cooperation is appreciated.
 
 171 char       Reserved for IEEE 1394 (Firewire)
 
-
 172 char       Moxa Intellio serial card
                  0 = /dev/ttyMX0       First Moxa port
                  1 = /dev/ttyMX1       Second Moxa port
@@ -2543,9 +2555,6 @@ Your cooperation is appreciated.
                 64 = /dev/usb/rio500   Diamond Rio 500
                 65 = /dev/usb/usblcd   USBLCD Interface (info@usblcd.de)
                 66 = /dev/usb/cpad0    Synaptics cPad (mouse/LCD)
-                67 = /dev/usb/adutux0  1st Ontrak ADU device
-                   ...
-                76 = /dev/usb/adutux10 10th Ontrak ADU device
                 96 = /dev/usb/hiddev0  1st USB HID device
                    ...
                111 = /dev/usb/hiddev15 16th USB HID device
@@ -2558,7 +2567,7 @@ Your cooperation is appreciated.
                132 = /dev/usb/idmouse  ID Mouse (fingerprint scanner) device
                133 = /dev/usb/sisusbvga1       First SiSUSB VGA device
                    ...
-               140 = /dev/usb/sisusbvga8       Eigth SISUSB VGA device
+               140 = /dev/usb/sisusbvga8       Eighth SISUSB VGA device
                144 = /dev/usb/lcd      USB LCD device
                160 = /dev/usb/legousbtower0    1st USB Legotower device
                    ...
@@ -2571,7 +2580,7 @@ Your cooperation is appreciated.
                  0 = /dev/uba          First USB block device
                  8 = /dev/ubb          Second USB block device
                 16 = /dev/ubc          Third USB block device
-                   ...
+                   ...
 
 181 char       Conrad Electronic parallel port radio clocks
                  0 = /dev/pcfclock0    First Conrad radio clock
@@ -2657,7 +2666,7 @@ Your cooperation is appreciated.
                 32 = /dev/mvideo/status2       Third device
                    ...
                    ...
-               240 = /dev/mvideo/status15      16th device 
+               240 = /dev/mvideo/status15      16th device
                    ...
 
 195 char       Nvidia graphics devices
@@ -2795,6 +2804,10 @@ Your cooperation is appreciated.
                    ...
                 185 = /dev/ttyNX15             Hilscher netX serial port 15
                 186 = /dev/ttyJ0               JTAG1 DCC protocol based serial port emulation
+                187 = /dev/ttyUL0              Xilinx uartlite - port 0
+                   ...
+                190 = /dev/ttyUL3              Xilinx uartlite - port 3
+                191 = /dev/xvc0                Xen virtual console - port 0
 
 205 char       Low-density serial ports (alternate device)
                  0 = /dev/culu0                Callout device for ttyLU0
@@ -2832,7 +2845,6 @@ Your cooperation is appreciated.
                 82 = /dev/cuvr0                Callout device for ttyVR0
                 83 = /dev/cuvr1                Callout device for ttyVR1
 
-
 206 char       OnStream SC-x0 tape devices
                  0 = /dev/osst0                First OnStream SCSI tape, mode 0
                  1 = /dev/osst1                Second OnStream SCSI tape, mode 0
@@ -2922,7 +2934,6 @@ Your cooperation is appreciated.
                    ...
 
 212 char       LinuxTV.org DVB driver subsystem
-
                  0 = /dev/dvb/adapter0/video0    first video decoder of first card
                  1 = /dev/dvb/adapter0/audio0    first audio decoder of first card
                  2 = /dev/dvb/adapter0/sec0      (obsolete/unused)
@@ -3008,9 +3019,9 @@ Your cooperation is appreciated.
                  2 = /dev/3270/tub2            Second 3270 terminal
                    ...
 
-229 char       IBM iSeries virtual console
-                 0 = /dev/iseries/vtty0        First console port
-                 1 = /dev/iseries/vtty1        Second console port
+229 char       IBM iSeries/pSeries virtual console
+                 0 = /dev/hvc0                 First console port
+                 1 = /dev/hvc1                 Second console port
                    ...
 
 230 char       IBM iSeries virtual tape
@@ -3083,12 +3094,14 @@ Your cooperation is appreciated.
 234-239                UNASSIGNED
 
 240-254 char   LOCAL/EXPERIMENTAL USE
+
 240-254 block  LOCAL/EXPERIMENTAL USE
                Allocated for local/experimental use.  For devices not
                assigned official numbers, these ranges should be
                used in order to avoid conflicting with future assignments.
 
 255 char       RESERVED
+
 255 block      RESERVED
 
                This major is reserved to assist the expansion to a
@@ -3115,7 +3128,20 @@ Your cooperation is appreciated.
 257 char       Phoenix Technologies Cryptographic Services Driver
                  0 = /dev/ptlsec       Crypto Services Driver
 
-
+257 block      SSFDC Flash Translation Layer filesystem
+                 0 = /dev/ssfdca       First SSFDC layer
+                 8 = /dev/ssfdcb       Second SSFDC layer
+                16 = /dev/ssfdcc       Third SSFDC layer
+                24 = /dev/ssfdcd       4th SSFDC layer
+                32 = /dev/ssfdce       5th SSFDC layer
+                40 = /dev/ssfdcf       6th SSFDC layer
+                48 = /dev/ssfdcg       7th SSFDC layer
+                56 = /dev/ssfdch       8th SSFDC layer
+
+258 block      ROM/Flash read-only translation layer
+                 0 = /dev/blockrom0    First ROM card's translation layer interface
+                 1 = /dev/blockrom1    Second ROM card's translation layer interface
+                 ...
 
  ****  ADDITIONAL /dev DIRECTORY ENTRIES
 
diff --git a/Documentation/fault-injection/failcmd.sh b/Documentation/fault-injection/failcmd.sh
new file mode 100644 (file)
index 0000000..63177ab
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+echo 1 > /proc/self/make-it-fail
+exec $*
diff --git a/Documentation/fault-injection/failmodule.sh b/Documentation/fault-injection/failmodule.sh
new file mode 100644 (file)
index 0000000..474a8b9
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# Usage: failmodule <failname> <modulename> [stacktrace-depth]
+#
+#      <failname>: "failslab", "fail_alloc_page", or "fail_make_request"
+#
+#      <modulename>: module name that you want to inject faults.
+#
+#      [stacktrace-depth]: the maximum number of stacktrace walking allowed
+#
+
+STACKTRACE_DEPTH=5
+if [ $# -gt 2 ]; then
+       STACKTRACE_DEPTH=$3
+fi
+
+if [ ! -d /debug/$1 ]; then
+       echo "Fault-injection $1 does not exist" >&2
+       exit 1
+fi
+if [ ! -d /sys/module/$2 ]; then
+       echo "Module $2 does not exist" >&2
+       exit 1
+fi
+
+# Disable any fault injection
+echo 0 > /debug/$1/stacktrace-depth
+
+echo `cat /sys/module/$2/sections/.text` > /debug/$1/require-start
+echo `cat /sys/module/$2/sections/.exit.text` > /debug/$1/require-end
+echo $STACKTRACE_DEPTH > /debug/$1/stacktrace-depth
diff --git a/Documentation/fault-injection/fault-injection.txt b/Documentation/fault-injection/fault-injection.txt
new file mode 100644 (file)
index 0000000..b7ca560
--- /dev/null
@@ -0,0 +1,225 @@
+Fault injection capabilities infrastructure
+===========================================
+
+See also drivers/md/faulty.c and "every_nth" module option for scsi_debug.
+
+
+Available fault injection capabilities
+--------------------------------------
+
+o failslab
+
+  injects slab allocation failures. (kmalloc(), kmem_cache_alloc(), ...)
+
+o fail_page_alloc
+
+  injects page allocation failures. (alloc_pages(), get_free_pages(), ...)
+
+o fail_make_request
+
+  injects disk IO errors on devices permitted by setting
+  /sys/block/<device>/make-it-fail or
+  /sys/block/<device>/<partition>/make-it-fail. (generic_make_request())
+
+Configure fault-injection capabilities behavior
+-----------------------------------------------
+
+o debugfs entries
+
+fault-inject-debugfs kernel module provides some debugfs entries for runtime
+configuration of fault-injection capabilities.
+
+- /debug/fail*/probability:
+
+       likelihood of failure injection, in percent.
+       Format: <percent>
+
+       Note that one-failure-per-hundred is a very high error rate
+       for some testcases.  Consider setting probability=100 and configure
+       /debug/fail*/interval for such testcases.
+
+- /debug/fail*/interval:
+
+       specifies the interval between failures, for calls to
+       should_fail() that pass all the other tests.
+
+       Note that if you enable this, by setting interval>1, you will
+       probably want to set probability=100.
+
+- /debug/fail*/times:
+
+       specifies how many times failures may happen at most.
+       A value of -1 means "no limit".
+
+- /debug/fail*/space:
+
+       specifies an initial resource "budget", decremented by "size"
+       on each call to should_fail(,size).  Failure injection is
+       suppressed until "space" reaches zero.
+
+- /debug/fail*/verbose
+
+       Format: { 0 | 1 | 2 }
+       specifies the verbosity of the messages when failure is
+       injected.  '0' means no messages; '1' will print only a single
+       log line per failure; '2' will print a call trace too -- useful
+       to debug the problems revealed by fault injection.
+
+- /debug/fail*/task-filter:
+
+       Format: { 'Y' | 'N' }
+       A value of 'N' disables filtering by process (default).
+       Any positive value limits failures to only processes indicated by
+       /proc/<pid>/make-it-fail==1.
+
+- /debug/fail*/require-start:
+- /debug/fail*/require-end:
+- /debug/fail*/reject-start:
+- /debug/fail*/reject-end:
+
+       specifies the range of virtual addresses tested during
+       stacktrace walking.  Failure is injected only if some caller
+       in the walked stacktrace lies within the required range, and
+       none lies within the rejected range.
+       Default required range is [0,ULONG_MAX) (whole of virtual address space).
+       Default rejected range is [0,0).
+
+- /debug/fail*/stacktrace-depth:
+
+       specifies the maximum stacktrace depth walked during search
+       for a caller within [require-start,require-end) OR
+       [reject-start,reject-end).
+
+- /debug/fail_page_alloc/ignore-gfp-highmem:
+
+       Format: { 'Y' | 'N' }
+       default is 'N', setting it to 'Y' won't inject failures into
+       highmem/user allocations.
+
+- /debug/failslab/ignore-gfp-wait:
+- /debug/fail_page_alloc/ignore-gfp-wait:
+
+       Format: { 'Y' | 'N' }
+       default is 'N', setting it to 'Y' will inject failures
+       only into non-sleep allocations (GFP_ATOMIC allocations).
+
+o Boot option
+
+In order to inject faults while debugfs is not available (early boot time),
+use the boot option:
+
+       failslab=
+       fail_page_alloc=
+       fail_make_request=<interval>,<probability>,<space>,<times>
+
+How to add new fault injection capability
+-----------------------------------------
+
+o #include <linux/fault-inject.h>
+
+o define the fault attributes
+
+  DECLARE_FAULT_INJECTION(name);
+
+  Please see the definition of struct fault_attr in fault-inject.h
+  for details.
+
+o provide a way to configure fault attributes
+
+- boot option
+
+  If you need to enable the fault injection capability from boot time, you can
+  provide boot option to configure it. There is a helper function for it:
+
+       setup_fault_attr(attr, str);
+
+- debugfs entries
+
+  failslab, fail_page_alloc, and fail_make_request use this way.
+  Helper functions:
+
+       init_fault_attr_entries(entries, attr, name);
+       void cleanup_fault_attr_entries(entries);
+
+- module parameters
+
+  If the scope of the fault injection capability is limited to a
+  single kernel module, it is better to provide module parameters to
+  configure the fault attributes.
+
+o add a hook to insert failures
+
+  Upon should_fail() returning true, client code should inject a failure.
+
+       should_fail(attr, size);
+
+Application Examples
+--------------------
+
+o inject slab allocation failures into module init/cleanup code
+
+------------------------------------------------------------------------------
+#!/bin/bash
+
+FAILCMD=Documentation/fault-injection/failcmd.sh
+BLACKLIST="root_plug evbug"
+
+FAILNAME=failslab
+echo Y > /debug/$FAILNAME/task-filter
+echo 10 > /debug/$FAILNAME/probability
+echo 100 > /debug/$FAILNAME/interval
+echo -1 > /debug/$FAILNAME/times
+echo 2 > /debug/$FAILNAME/verbose
+echo 1 > /debug/$FAILNAME/ignore-gfp-wait
+
+blacklist()
+{
+       echo $BLACKLIST | grep $1 > /dev/null 2>&1
+}
+
+oops()
+{
+       dmesg | grep BUG > /dev/null 2>&1
+}
+
+find /lib/modules/`uname -r` -name '*.ko' -exec basename {} .ko \; |
+       while read i
+       do
+               oops && exit 1
+
+               if ! blacklist $i
+               then
+                       echo inserting $i...
+                       bash $FAILCMD modprobe $i
+               fi
+       done
+
+lsmod | awk '{ if ($3 == 0) { print $1 } }' |
+       while read i
+       do
+               oops && exit 1
+
+               if ! blacklist $i
+               then
+                       echo removing $i...
+                       bash $FAILCMD modprobe -r $i
+               fi
+       done
+
+------------------------------------------------------------------------------
+
+o inject slab allocation failures only for a specific module
+
+------------------------------------------------------------------------------
+#!/bin/bash
+
+FAILMOD=Documentation/fault-injection/failmodule.sh
+
+echo injecting errors into the module $1...
+
+modprobe $1
+bash $FAILMOD failslab $1 10
+echo 25 > /debug/failslab/probability
+
+------------------------------------------------------------------------------
+
index 226ecf2ffd568158a2927b24e27e21bde00b6d30..46f2a559b27c8fd55a593eb996360b528a7b4a39 100644 (file)
@@ -30,11 +30,39 @@ Who:        Adrian Bunk <bunk@stusta.de>
 ---------------------------
 
 What:  raw1394: requests of type RAW1394_REQ_ISO_SEND, RAW1394_REQ_ISO_LISTEN
-When:  November 2006
-Why:   Deprecated in favour of the new ioctl-based rawiso interface, which is
-       more efficient.  You should really be using libraw1394 for raw1394
-       access anyway.
-Who:   Jody McIntyre <scjody@modernduck.com>
+When:  June 2007
+Why:   Deprecated in favour of the more efficient and robust rawiso interface.
+       Affected are applications which use the deprecated part of libraw1394
+       (raw1394_iso_write, raw1394_start_iso_write, raw1394_start_iso_rcv,
+       raw1394_stop_iso_rcv) or bypass libraw1394.
+Who:   Dan Dennedy <dan@dennedy.org>, Stefan Richter <stefanr@s5r6.in-berlin.de>
+
+---------------------------
+
+What:  dv1394 driver (CONFIG_IEEE1394_DV1394)
+When:  June 2007
+Why:   Replaced by raw1394 + userspace libraries, notably libiec61883.  This
+       shift of application support has been indicated on www.linux1394.org
+       and developers' mailinglists for quite some time.  Major applications
+       have been converted, with the exception of ffmpeg and hence xine.
+       Piped output of dvgrab2 is a partial equivalent to dv1394.
+Who:   Dan Dennedy <dan@dennedy.org>, Stefan Richter <stefanr@s5r6.in-berlin.de>
+
+---------------------------
+
+What:  ieee1394 core's unused exports (CONFIG_IEEE1394_EXPORT_FULL_API)
+When:  January 2007
+Why:   There are no projects known to use these exported symbols, except
+       dfg1394 (uses one symbol whose functionality is core-internal now).
+Who:   Stefan Richter <stefanr@s5r6.in-berlin.de>
+
+---------------------------
+
+What:  ieee1394's *_oui sysfs attributes (CONFIG_IEEE1394_OUI_DB)
+When:  January 2007
+Files: drivers/ieee1394/: oui.db, oui2c.sh
+Why:   big size, little value
+Who:   Stefan Richter <stefanr@s5r6.in-berlin.de>
 
 ---------------------------
 
index eb1a6cad21e6a8cadc993111b1f4c7099d794ad2..790ef6fbe495914f94ea351e92834d9fb206f80c 100644 (file)
@@ -124,7 +124,7 @@ sync_fs:            no      no      read
 write_super_lockfs:    ?
 unlockfs:              ?
 statfs:                        no      no      no
-remount_fs:            no      yes     maybe           (see below)
+remount_fs:            yes     yes     maybe           (see below)
 clear_inode:           no
 umount_begin:          yes     no      no
 show_options:          no                              (vfsmount->sem)
index 3d74477389587b4be4d03950845c17a1e396a707..345392c4caebdb1d7bc806d4f6f6b9fa911fc8e6 100644 (file)
@@ -51,6 +51,22 @@ homepage:
 
   http://fuse.sourceforge.net/
 
+Filesystem type
+~~~~~~~~~~~~~~~
+
+The filesystem type given to mount(2) can be one of the following:
+
+'fuse'
+
+  This is the usual way to mount a FUSE filesystem.  The first
+  argument of the mount system call may contain an arbitrary string,
+  which is not interpreted by the kernel.
+
+'fuseblk'
+
+  The filesystem is block device based.  The first argument of the
+  mount system call is interpreted as the name of the device.
+
 Mount options
 ~~~~~~~~~~~~~
 
@@ -94,6 +110,11 @@ Mount options
   The default is infinite.  Note that the size of read requests is
   limited anyway to 32 pages (which is 128kbyte on i386).
 
+'blksize=N'
+
+  Set the block size for the filesystem.  The default is 512.  This
+  option is only valid for 'fuseblk' type mounts.
+
 Control filesystem
 ~~~~~~~~~~~~~~~~~~
 
index d81722418010f551f066d264c8276c861e82ef40..253b50d1328ed8d62e873f9e6ca750972bc603ce 100644 (file)
@@ -1,11 +1,8 @@
-This is the implementation of the SystemV/Coherent filesystem for Linux.
 It implements all of
   - Xenix FS,
   - SystemV/386 FS,
   - Coherent FS.
 
-This is version beta 4.
-
 To install:
 * Answer the 'System V and Coherent filesystem support' question with 'y'
   when configuring the kernel.
@@ -28,11 +25,173 @@ Bugs in the present implementation:
   for this FS on hard disk yet.
 
 
-Please report any bugs and suggestions to
-  Bruno Haible <haible@ma2s2.mathematik.uni-karlsruhe.de>
-  Pascal Haible <haible@izfm.uni-stuttgart.de>
-  Krzysztof G. Baranowski <kgb@manjak.knm.org.pl>
+These filesystems are rather similar. Here is a comparison with Minix FS:
+
+* Linux fdisk reports on partitions
+  - Minix FS     0x81 Linux/Minix
+  - Xenix FS     ??
+  - SystemV FS   ??
+  - Coherent FS  0x08 AIX bootable
+
+* Size of a block or zone (data allocation unit on disk)
+  - Minix FS     1024
+  - Xenix FS     1024 (also 512 ??)
+  - SystemV FS   1024 (also 512 and 2048)
+  - Coherent FS   512
+
+* General layout: all have one boot block, one super block and
+  separate areas for inodes and for directories/data.
+  On SystemV Release 2 FS (e.g. Microport) the first track is reserved and
+  all the block numbers (including the super block) are offset by one track.
+
+* Byte ordering of "short" (16 bit entities) on disk:
+  - Minix FS     little endian  0 1
+  - Xenix FS     little endian  0 1
+  - SystemV FS   little endian  0 1
+  - Coherent FS  little endian  0 1
+  Of course, this affects only the file system, not the data of files on it!
+
+* Byte ordering of "long" (32 bit entities) on disk:
+  - Minix FS     little endian  0 1 2 3
+  - Xenix FS     little endian  0 1 2 3
+  - SystemV FS   little endian  0 1 2 3
+  - Coherent FS  PDP-11         2 3 0 1
+  Of course, this affects only the file system, not the data of files on it!
+
+* Inode on disk: "short", 0 means non-existent, the root dir ino is:
+  - Minix FS                            1
+  - Xenix FS, SystemV FS, Coherent FS   2
+
+* Maximum number of hard links to a file:
+  - Minix FS     250
+  - Xenix FS     ??
+  - SystemV FS   ??
+  - Coherent FS  >=10000
+
+* Free inode management:
+  - Minix FS                             a bitmap
+  - Xenix FS, SystemV FS, Coherent FS
+      There is a cache of a certain number of free inodes in the super-block.
+      When it is exhausted, new free inodes are found using a linear search.
+
+* Free block management:
+  - Minix FS                             a bitmap
+  - Xenix FS, SystemV FS, Coherent FS
+      Free blocks are organized in a "free list". Maybe a misleading term,
+      since it is not true that every free block contains a pointer to
+      the next free block. Rather, the free blocks are organized in chunks
+      of limited size, and every now and then a free block contains pointers
+      to the free blocks pertaining to the next chunk; the first of these
+      contains pointers and so on. The list terminates with a "block number"
+      0 on Xenix FS and SystemV FS, with a block zeroed out on Coherent FS.
+
+* Super-block location:
+  - Minix FS     block 1 = bytes 1024..2047
+  - Xenix FS     block 1 = bytes 1024..2047
+  - SystemV FS   bytes 512..1023
+  - Coherent FS  block 1 = bytes 512..1023
+
+* Super-block layout:
+  - Minix FS
+                    unsigned short s_ninodes;
+                    unsigned short s_nzones;
+                    unsigned short s_imap_blocks;
+                    unsigned short s_zmap_blocks;
+                    unsigned short s_firstdatazone;
+                    unsigned short s_log_zone_size;
+                    unsigned long s_max_size;
+                    unsigned short s_magic;
+  - Xenix FS, SystemV FS, Coherent FS
+                    unsigned short s_firstdatazone;
+                    unsigned long  s_nzones;
+                    unsigned short s_fzone_count;
+                    unsigned long  s_fzones[NICFREE];
+                    unsigned short s_finode_count;
+                    unsigned short s_finodes[NICINOD];
+                    char           s_flock;
+                    char           s_ilock;
+                    char           s_modified;
+                    char           s_rdonly;
+                    unsigned long  s_time;
+                    short          s_dinfo[4]; -- SystemV FS only
+                    unsigned long  s_free_zones;
+                    unsigned short s_free_inodes;
+                    short          s_dinfo[4]; -- Xenix FS only
+                    unsigned short s_interleave_m,s_interleave_n; -- Coherent FS only
+                    char           s_fname[6];
+                    char           s_fpack[6];
+    then they differ considerably:
+        Xenix FS
+                    char           s_clean;
+                    char           s_fill[371];
+                    long           s_magic;
+                    long           s_type;
+        SystemV FS
+                    long           s_fill[12 or 14];
+                    long           s_state;
+                    long           s_magic;
+                    long           s_type;
+        Coherent FS
+                    unsigned long  s_unique;
+    Note that Coherent FS has no magic.
+
+* Inode layout:
+  - Minix FS
+                    unsigned short i_mode;
+                    unsigned short i_uid;
+                    unsigned long  i_size;
+                    unsigned long  i_time;
+                    unsigned char  i_gid;
+                    unsigned char  i_nlinks;
+                    unsigned short i_zone[7+1+1];
+  - Xenix FS, SystemV FS, Coherent FS
+                    unsigned short i_mode;
+                    unsigned short i_nlink;
+                    unsigned short i_uid;
+                    unsigned short i_gid;
+                    unsigned long  i_size;
+                    unsigned char  i_zone[3*(10+1+1+1)];
+                    unsigned long  i_atime;
+                    unsigned long  i_mtime;
+                    unsigned long  i_ctime;
+
+* Regular file data blocks are organized as
+  - Minix FS
+               7 direct blocks
+               1 indirect block (pointers to blocks)
+               1 double-indirect block (pointer to pointers to blocks)
+  - Xenix FS, SystemV FS, Coherent FS
+              10 direct blocks
+               1 indirect block (pointers to blocks)
+               1 double-indirect block (pointer to pointers to blocks)
+               1 triple-indirect block (pointer to pointers to pointers to blocks)
+
+* Inode size, inodes per block
+  - Minix FS        32   32
+  - Xenix FS        64   16
+  - SystemV FS      64   16
+  - Coherent FS     64    8
+
+* Directory entry on disk
+  - Minix FS
+                    unsigned short inode;
+                    char name[14/30];
+  - Xenix FS, SystemV FS, Coherent FS
+                    unsigned short inode;
+                    char name[14];
+
+* Dir entry size, dir entries per block
+  - Minix FS     16/32    64/32
+  - Xenix FS     16       64
+  - SystemV FS   16       64
+  - Coherent FS  16       32
+
+* How to implement symbolic links such that the host fsck doesn't scream:
+  - Minix FS     normal
+  - Xenix FS     kludge: as regular files with  chmod 1000
+  - SystemV FS   ??
+  - Coherent FS  kludge: as regular files with  chmod 1000
 
-Bruno Haible
-<haible@ma2s2.mathematik.uni-karlsruhe.de>
 
+Notation: We often speak of a "block" but mean a zone (the allocation unit)
+and not the disk driver's notion of "block".
index c51314b1a463a35eb222d550409d0a29137149e2..9575de300a6173ea92dec18b198f48395721ed0e 100644 (file)
@@ -2,7 +2,7 @@
                     ----------------------------
 
                    H. Peter Anvin <hpa@zytor.com>
-                       Last update 2005-09-02
+                       Last update 2006-11-17
 
 On the i386 platform, the Linux kernel uses a rather complicated boot
 convention.  This has evolved partially due to historical aspects, as
@@ -35,6 +35,8 @@ Protocol 2.03:        (Kernel 2.4.18-pre1) Explicitly makes the highest possible
                initrd address available to the bootloader.
 
 Protocol 2.04: (Kernel 2.6.14) Extend the syssize field to four bytes.
+Protocol 2.05: (Kernel 2.6.20) Make protected mode kernel relocatable.
+               Introduce relocatable_kernel and kernel_alignment fields.
 
 
 **** MEMORY LAYOUT
@@ -129,6 +131,8 @@ Offset      Proto   Name            Meaning
 0226/2 N/A     pad1            Unused
 0228/4 2.02+   cmd_line_ptr    32-bit pointer to the kernel command line
 022C/4 2.03+   initrd_addr_max Highest legal initrd address
+0230/4 2.05+   kernel_alignment Physical addr alignment required for kernel
+0234/1 2.05+   relocatable_kernel Whether kernel is relocatable or not
 
 (1) For backwards compatibility, if the setup_sects field contains 0, the
     real value is 4.
index edc04d74ae239e35308081415ea19cd7de9304bf..5a8bd5bd88eff17f02421165fff6811674e0a53f 100644 (file)
@@ -191,3 +191,5 @@ Code        Seq#    Include File            Comments
                                        <mailto:aherrman@de.ibm.com>
 0xF3   00-3F   video/sisfb.h           sisfb (in development)
                                        <mailto:thomas@winischhofer.net>
+0xF4   00-1F   video/mbxfb.h           mbxfb
+                                       <mailto:raph@8d.com>
index 2e1898e4e8fd38e67ac9913480178454b094355e..d8323b8893c3709170d3e79c09a975f6bac42864 100644 (file)
@@ -548,6 +548,13 @@ and is between 256 and 4096 characters. It is defined in the file
        eurwdt=         [HW,WDT] Eurotech CPU-1220/1410 onboard watchdog.
                        Format: <io>[,<irq>]
 
+       failslab=
+       fail_page_alloc=
+       fail_make_request=[KNL]
+                       General fault injection mechanism.
+                       Format: <interval>,<probability>,<space>,<times>
+                       See also /Documentation/fault-injection/.
+
        fd_mcs=         [HW,SCSI]
                        See header of drivers/scsi/fd_mcs.c.
 
@@ -599,8 +606,6 @@ and is between 256 and 4096 characters. It is defined in the file
 
        hugepages=      [HW,IA-32,IA-64] Maximal number of HugeTLB pages.
 
-       noirqbalance    [IA-32,SMP,KNL] Disable kernel irq balancing
-
        i8042.direct    [HW] Put keyboard port into non-translated mode
        i8042.dumbkbd   [HW] Pretend that controller can only read data from
                             keyboard and cannot control its state
@@ -650,6 +655,10 @@ and is between 256 and 4096 characters. It is defined in the file
        idle=           [HW]
                        Format: idle=poll or idle=halt
 
+       ignore_loglevel [KNL]
+                       Ignore loglevel setting - this will print /all/
+                       kernel messages to the console. Useful for debugging.
+
        ihash_entries=  [KNL]
                        Set number of hash buckets for inode cache.
 
@@ -714,7 +723,12 @@ and is between 256 and 4096 characters. It is defined in the file
                        Format: <RDP>,<reset>,<pci_scan>,<verbosity>
 
        isolcpus=       [KNL,SMP] Isolate CPUs from the general scheduler.
-                       Format: <cpu number>,...,<cpu number>
+                       Format:
+                       <cpu number>,...,<cpu number>
+                       or
+                       <cpu number>-<cpu number>  (must be a positive range in ascending order)
+                       or a mixture
+                       <cpu number>,...,<cpu number>-<cpu number>
                        This option can be used to specify one or more CPUs
                        to isolate from the general SMP balancing and scheduling
                        algorithms. The only way to move a process onto or off
@@ -1012,6 +1026,10 @@ and is between 256 and 4096 characters. It is defined in the file
                        emulation library even if a 387 maths coprocessor
                        is present.
 
+       noaliencache    [MM, NUMA] Disables the allcoation of alien caches in
+                       the slab allocator.  Saves per-node memory, but will
+                       impact performance on real NUMA hardware.
+
        noalign         [KNL,ARM]
 
        noapic          [SMP,APIC] Tells the kernel to not make use of any
@@ -1052,9 +1070,14 @@ and is between 256 and 4096 characters. It is defined in the file
                        in certain environments such as networked servers or
                        real-time systems.
 
+       noirqbalance    [IA-32,SMP,KNL] Disable kernel irq balancing
+
        noirqdebug      [IA-32] Disables the code which attempts to detect and
                        disable unhandled interrupt sources.
 
+       no_timer_check  [IA-32,X86_64,APIC] Disables the code which tests for
+                       broken timer IRQ sources.
+
        noisapnp        [ISAPNP] Disables ISA PnP code.
 
        noinitrd        [RAM] Tells the kernel not to load any configured
@@ -1285,6 +1308,7 @@ and is between 256 and 4096 characters. It is defined in the file
                        Param: "schedule" - profile schedule points.
                        Param: <number> - step/bucket size as a power of 2 for
                                statistical time based profiling.
+                       Param: "sleep" - profile D-state sleeping (millisecs)
 
        processor.max_cstate=   [HW,ACPI]
                        Limit processor to maximum C-state
@@ -1366,6 +1390,12 @@ and is between 256 and 4096 characters. It is defined in the file
        resume=         [SWSUSP]
                        Specify the partition device for software suspend
 
+       resume_offset=  [SWSUSP]
+                       Specify the offset from the beginning of the partition
+                       given by "resume=" at which the swap header is located,
+                       in <PAGE_SIZE> units (needed only for swap files).
+                       See  Documentation/power/swsusp-and-swap-files.txt
+
        rhash_entries=  [KNL,NET]
                        Set number of hash buckets for route cache
 
@@ -1732,6 +1762,9 @@ and is between 256 and 4096 characters. It is defined in the file
        norandmaps      Don't use address space randomization
                        Equivalent to echo 0 > /proc/sys/kernel/randomize_va_space
 
+       unwind_debug=N  N > 0 will enable dwarf2 unwinder debugging
+                       This is useful to get more information why
+                       you got a "dwarf2 unwinder stuck"
 
 ______________________________________________________________________
 
index b1181ce232d987453f13917904a3f1ba180125f2..e06b6e3c1db577d5fe513cc2ea045e3d57507564 100644 (file)
@@ -58,6 +58,8 @@ fore200e.txt
        - FORE Systems PCA-200E/SBA-200E ATM NIC driver info.
 framerelay.txt
        - info on using Frame Relay/Data Link Connection Identifier (DLCI).
+generic_netlink.txt
+       - info on Generic Netlink
 ip-sysctl.txt
        - /proc/sys/net/ipv4/* variables
 ip_dynaddr.txt
diff --git a/Documentation/networking/generic_netlink.txt b/Documentation/networking/generic_netlink.txt
new file mode 100644 (file)
index 0000000..d4f8b8b
--- /dev/null
@@ -0,0 +1,3 @@
+A wiki document on how to use Generic Netlink can be found here:
+
+ * http://linux-net.osdl.org/index.php/Generic_Netlink_HOWTO
diff --git a/Documentation/power/s2ram.txt b/Documentation/power/s2ram.txt
new file mode 100644 (file)
index 0000000..b05f512
--- /dev/null
@@ -0,0 +1,56 @@
+                       How to get s2ram working
+                       ~~~~~~~~~~~~~~~~~~~~~~~~
+                       2006 Linus Torvalds
+                       2006 Pavel Machek
+
+1) Check suspend.sf.net, program s2ram there has long whitelist of
+   "known ok" machines, along with tricks to use on each one.
+
+2) If that does not help, try reading tricks.txt and
+   video.txt. Perhaps problem is as simple as broken module, and
+   simple module unload can fix it.
+
+3) You can use Linus' TRACE_RESUME infrastructure, described below.
+
+                     Using TRACE_RESUME
+                     ~~~~~~~~~~~~~~~~~~
+
+I've been working at making the machines I have able to STR, and almost
+always it's a driver that is buggy. Thank God for the suspend/resume
+debugging - the thing that Chuck tried to disable. That's often the _only_
+way to debug these things, and it's actually pretty powerful (but
+time-consuming - having to insert TRACE_RESUME() markers into the device
+driver that doesn't resume and recompile and reboot).
+
+Anyway, the way to debug this for people who are interested (have a
+machine that doesn't boot) is:
+
+ - enable PM_DEBUG, and PM_TRACE
+
+ - use a script like this:
+
+       #!/bin/sh
+       sync
+       echo 1 > /sys/power/pm_trace
+       echo mem > /sys/power/state
+
+   to suspend
+
+ - if it doesn't come back up (which is usually the problem), reboot by
+   holding the power button down, and look at the dmesg output for things
+   like
+
+       Magic number: 4:156:725
+       hash matches drivers/base/power/resume.c:28
+       hash matches device 0000:01:00.0
+
+   which means that the last trace event was just before trying to resume
+   device 0000:01:00.0. Then figure out what driver is controlling that
+   device (lspci and /sys/devices/pci* is your friend), and see if you can
+   fix it, disable it, or trace into its resume function.
+
+For example, the above happens to be the VGA device on my EVO, which I
+used to run with "radeonfb" (it's an ATI Radeon mobility). It turns out
+that "radeonfb" simply cannot resume that device - it tries to set the
+PLL's, and it just _hangs_. Using the regular VGA console and letting X
+resume it instead works fine.
diff --git a/Documentation/power/swsusp-and-swap-files.txt b/Documentation/power/swsusp-and-swap-files.txt
new file mode 100644 (file)
index 0000000..06f911a
--- /dev/null
@@ -0,0 +1,60 @@
+Using swap files with software suspend (swsusp)
+       (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
+
+The Linux kernel handles swap files almost in the same way as it handles swap
+partitions and there are only two differences between these two types of swap
+areas:
+(1) swap files need not be contiguous,
+(2) the header of a swap file is not in the first block of the partition that
+holds it.  From the swsusp's point of view (1) is not a problem, because it is
+already taken care of by the swap-handling code, but (2) has to be taken into
+consideration.
+
+In principle the location of a swap file's header may be determined with the
+help of appropriate filesystem driver.  Unfortunately, however, it requires the
+filesystem holding the swap file to be mounted, and if this filesystem is
+journaled, it cannot be mounted during resume from disk.  For this reason to
+identify a swap file swsusp uses the name of the partition that holds the file
+and the offset from the beginning of the partition at which the swap file's
+header is located.  For convenience, this offset is expressed in <PAGE_SIZE>
+units.
+
+In order to use a swap file with swsusp, you need to:
+
+1) Create the swap file and make it active, eg.
+
+# dd if=/dev/zero of=<swap_file_path> bs=1024 count=<swap_file_size_in_k>
+# mkswap <swap_file_path>
+# swapon <swap_file_path>
+
+2) Use an application that will bmap the swap file with the help of the
+FIBMAP ioctl and determine the location of the file's swap header, as the
+offset, in <PAGE_SIZE> units, from the beginning of the partition which
+holds the swap file.
+
+3) Add the following parameters to the kernel command line:
+
+resume=<swap_file_partition> resume_offset=<swap_file_offset>
+
+where <swap_file_partition> is the partition on which the swap file is located
+and <swap_file_offset> is the offset of the swap header determined by the
+application in 2) (of course, this step may be carried out automatically
+by the same application that determies the swap file's header offset using the
+FIBMAP ioctl)
+
+OR
+
+Use a userland suspend application that will set the partition and offset
+with the help of the SNAPSHOT_SET_SWAP_AREA ioctl described in
+Documentation/power/userland-swsusp.txt (this is the only method to suspend
+to a swap file allowing the resume to be initiated from an initrd or initramfs
+image).
+
+Now, swsusp will use the swap file in the same way in which it would use a swap
+partition.  In particular, the swap file has to be active (ie. be present in
+/proc/swaps) so that it can be used for suspending.
+
+Note that if the swap file used for suspending is deleted and recreated,
+the location of its header need not be the same as before.  Thus every time
+this happens the value of the "resume_offset=" kernel command line parameter
+has to be updated.
index e635e6f1e316ca549834716c95fccc3c61b35748..0761ff6c57eddf65779e11d4991e751c250fe340 100644 (file)
@@ -297,20 +297,12 @@ system is shut down or suspended. Additionally use the encrypted
 suspend image to prevent sensitive data from being stolen after
 resume.
 
-Q: Why can't we suspend to a swap file?
+Q: Can I suspend to a swap file?
 
-A: Because accessing swap file needs the filesystem mounted, and
-filesystem might do something wrong (like replaying the journal)
-during mount.
-
-There are few ways to get that fixed:
-
-1) Probably could be solved by modifying every filesystem to support
-some kind of "really read-only!" option. Patches welcome.
-
-2) suspend2 gets around that by storing absolute positions in on-disk
-image (and blocksize), with resume parameter pointing directly to
-suspend header.
+A: Generally, yes, you can.  However, it requires you to use the "resume=" and
+"resume_offset=" kernel command line parameters, so the resume from a swap file
+cannot be initiated from an initrd or initramfs image.  See
+swsusp-and-swap-files.txt for details.
 
 Q: Is there a maximum system RAM size that is supported by swsusp?
 
index 64755e9285dbfe9236916bc7aca819b9d41f908e..000556c932e9fc4a4ede893f997d66833c4902c9 100644 (file)
@@ -9,9 +9,8 @@ done it already.
 Now, to use the userland interface for software suspend you need special
 utilities that will read/write the system memory snapshot from/to the
 kernel.  Such utilities are available, for example, from
-<http://www.sisk.pl/kernel/utilities/suspend>.  You may want to have
-a look at them if you are going to develop your own suspend/resume
-utilities.
+<http://suspend.sourceforge.net>.  You may want to have a look at them if you
+are going to develop your own suspend/resume utilities.
 
 The interface consists of a character device providing the open(),
 release(), read(), and write() operations as well as several ioctl()
@@ -21,9 +20,9 @@ be read from /sys/class/misc/snapshot/dev.
 
 The device can be open either for reading or for writing.  If open for
 reading, it is considered to be in the suspend mode.  Otherwise it is
-assumed to be in the resume mode.  The device cannot be open for reading
-and writing.  It is also impossible to have the device open more than once
-at a time.
+assumed to be in the resume mode.  The device cannot be open for simultaneous
+reading and writing.  It is also impossible to have the device open more than
+once at a time.
 
 The ioctl() commands recognized by the device are:
 
@@ -69,9 +68,46 @@ SNAPSHOT_FREE_SWAP_PAGES - free all swap pages allocated with
 SNAPSHOT_SET_SWAP_FILE - set the resume partition (the last ioctl() argument
        should specify the device's major and minor numbers in the old
        two-byte format, as returned by the stat() function in the .st_rdev
-       member of the stat structure); it is recommended to always use this
-       call, because the code to set the resume partition could be removed from
-       future kernels
+       member of the stat structure)
+
+SNAPSHOT_SET_SWAP_AREA - set the resume partition and the offset (in <PAGE_SIZE>
+       units) from the beginning of the partition at which the swap header is
+       located (the last ioctl() argument should point to a struct
+       resume_swap_area, as defined in kernel/power/power.h, containing the
+       resume device specification, as for the SNAPSHOT_SET_SWAP_FILE ioctl(),
+       and the offset); for swap partitions the offset is always 0, but it is
+       different to zero for swap files (please see
+       Documentation/swsusp-and-swap-files.txt for details).
+       The SNAPSHOT_SET_SWAP_AREA ioctl() is considered as a replacement for
+       SNAPSHOT_SET_SWAP_FILE which is regarded as obsolete.   It is
+       recommended to always use this call, because the code to set the resume
+       partition may be removed from future kernels
+
+SNAPSHOT_S2RAM - suspend to RAM; using this call causes the kernel to
+       immediately enter the suspend-to-RAM state, so this call must always
+       be preceded by the SNAPSHOT_FREEZE call and it is also necessary
+       to use the SNAPSHOT_UNFREEZE call after the system wakes up.  This call
+       is needed to implement the suspend-to-both mechanism in which the
+       suspend image is first created, as though the system had been suspended
+       to disk, and then the system is suspended to RAM (this makes it possible
+       to resume the system from RAM if there's enough battery power or restore
+       its state on the basis of the saved suspend image otherwise)
+
+SNAPSHOT_PMOPS - enable the usage of the pmops->prepare, pmops->enter and
+       pmops->finish methods (the in-kernel swsusp knows these as the "platform
+       method") which are needed on many machines to (among others) speed up
+       the resume by letting the BIOS skip some steps or to let the system
+       recognise the correct state of the hardware after the resume (in
+       particular on many machines this ensures that unplugged AC
+       adapters get correctly detected and that kacpid does not run wild after
+       the resume).  The last ioctl() argument can take one of the three
+       values, defined in kernel/power/power.h:
+       PMOPS_PREPARE - make the kernel carry out the
+               pm_ops->prepare(PM_SUSPEND_DISK) operation
+       PMOPS_ENTER - make the kernel power off the system by calling
+               pm_ops->enter(PM_SUSPEND_DISK)
+       PMOPS_FINISH - make the kernel carry out the
+               pm_ops->finish(PM_SUSPEND_DISK) operation
 
 The device's read() operation can be used to transfer the snapshot image from
 the kernel.  It has the following limitations:
@@ -91,10 +127,12 @@ unfreeze user space processes frozen by SNAPSHOT_UNFREEZE if they are
 still frozen when the device is being closed).
 
 Currently it is assumed that the userland utilities reading/writing the
-snapshot image from/to the kernel will use a swap partition, called the resume
-partition, as storage space.  However, this is not really required, as they
-can use, for example, a special (blank) suspend partition or a file on a partition
-that is unmounted before SNAPSHOT_ATOMIC_SNAPSHOT and mounted afterwards.
+snapshot image from/to the kernel will use a swap parition, called the resume
+partition, or a swap file as storage space (if a swap file is used, the resume
+partition is the partition that holds this file).  However, this is not really
+required, as they can use, for example, a special (blank) suspend partition or
+a file on a partition that is unmounted before SNAPSHOT_ATOMIC_SNAPSHOT and
+mounted afterwards.
 
 These utilities SHOULD NOT make any assumptions regarding the ordering of
 data within the snapshot image, except for the image header that MAY be
index 77bf450ec39be579ae422916c569e2f31bf344a9..e938c442277dc0ecd1b05002ba9167abbedd914c 100644 (file)
@@ -18,11 +18,18 @@ devices/
           - 0.0.0002/
           - 0.1.0000/0.1.1234/
           ...
+          - defunct/
 
 In this example, device 0815 is accessed via subchannel 0 in subchannel set 0,
 device 4711 via subchannel 1 in subchannel set 0, and subchannel 2 is a non-I/O
 subchannel. Device 1234 is accessed via subchannel 0 in subchannel set 1.
 
+The subchannel named 'defunct' does not represent any real subchannel on the
+system; it is a pseudo subchannel where disconnnected ccw devices are moved to
+if they are displaced by another ccw device becoming operational on their
+former subchannel. The ccw devices will be moved again to a proper subchannel
+if they become operational again on that subchannel.
+
 You should address a ccw device via its bus id (e.g. 0.0.4711); the device can
 be found under bus/ccw/devices/.
 
index f39c9d714db3d6bf2f6440d2f6cf9353057eeae5..a2afca3b2bab6fb923fb9eda102073606d15c278 100644 (file)
@@ -62,9 +62,6 @@ consider the following facts about the Linux kernel:
       - different structures can contain different fields
       - Some functions may not be implemented at all, (i.e. some locks
        compile away to nothing for non-SMP builds.)
-      - Parameter passing of variables from function to function can be
-       done in different ways (the CONFIG_REGPARM option controls
-       this.)
       - Memory within the kernel can be aligned in different ways,
        depending on the build options.
   - Linux runs on a wide range of different processor architectures.
index 0bc7f1e3c9e6aa2e340bec8f512684351630fc9f..5922e84d913340b98891a8e583663ab55ad3c5a6 100644 (file)
@@ -27,6 +27,7 @@ show up in /proc/sys/kernel:
 - hotplug
 - java-appletviewer           [ binfmt_java, obsolete ]
 - java-interpreter            [ binfmt_java, obsolete ]
+- kstack_depth_to_print       [ X86 only ]
 - l2cr                        [ PPC only ]
 - modprobe                    ==> Documentation/kmod.txt
 - msgmax
@@ -170,6 +171,13 @@ This flag controls the L2 cache of G3 processor boards. If
 
 ==============================================================
 
+kstack_depth_to_print: (X86 only)
+
+Controls the number of words to print when dumping the raw
+kernel stack.
+
+==============================================================
+
 osrelease, ostype & version:
 
 # cat osrelease
index f3c57f43ba6460e5b5927eaee2c86e2cfcaf5fa3..dbdcaf68e3ea382304784bf66fce502216f1d1f1 100644 (file)
@@ -52,10 +52,6 @@ APICs
                 apicmaintimer. Useful when your PIT timer is totally
                 broken.
 
-   disable_8254_timer / enable_8254_timer
-                Enable interrupt 0 timer routing over the 8254 in addition to over
-                the IO-APIC. The kernel tries to set a sensible default.
-
 Early Console
 
    syntax: earlyprintk=vga
@@ -183,7 +179,7 @@ PCI
 IOMMU
 
  iommu=[size][,noagp][,off][,force][,noforce][,leak][,memaper[=order]][,merge]
-         [,forcesac][,fullflush][,nomerge][,noaperture]
+         [,forcesac][,fullflush][,nomerge][,noaperture][,calgary]
    size  set size of iommu (in bytes)
    noagp don't initialize the AGP driver and use full aperture.
    off   don't use the IOMMU
@@ -204,6 +200,7 @@ IOMMU
            buffering.
    nodac    Forbid DMA >4GB
    panic    Always panic when IOMMU overflows
+   calgary  Use the Calgary IOMMU if it is available
 
   swiotlb=pages[,force]
 
index 5dff26814a06067c6122816fced3ce675638747d..dbf449ba240c9f5b6cac91cfb6cfda27713599f2 100644 (file)
@@ -348,6 +348,13 @@ P: Ian Molton
 M:     spyro@f2s.com
 S:     Maintained
 
+ARM/ATMEL AT91RM9200 ARM ARCHITECTURE
+P:      Andrew Victor
+M:      andrew@sanpeople.com
+L:      linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only)
+W:      http://maxim.org.za/at91_26.html
+S:      Maintained
+
 ARM/CORGI MACHINE SUPPORT
 P:     Richard Purdie
 M:     rpurdie@rpsys.net
@@ -677,7 +684,7 @@ S:  Supported
 CIRRUS LOGIC GENERIC FBDEV DRIVER
 P:     Jeff Garzik
 M:     jgarzik@pobox.com
-L:     linux-fbdev-devel@lists.sourceforge.net
+L:     linux-fbdev-devel@lists.sourceforge.net (subscribers-only)
 S:     Odd Fixes
 
 CIRRUS LOGIC CS4280/CS461x SOUNDDRIVER
@@ -784,7 +791,7 @@ S:  Maintained
 CYBLAFB FRAMEBUFFER DRIVER
 P:     Knut Petersen
 M:     Knut_Petersen@t-online.de
-L:     linux-fbdev-devel@lists.sourceforge.net
+L:     linux-fbdev-devel@lists.sourceforge.net (subscribers-only)
 S:     Maintained
 
 CYCLADES 2X SYNC CARD DRIVER
@@ -1091,13 +1098,19 @@ M:      miku@iki.fi
 S:     Maintained
 
 EXT2 FILE SYSTEM
-L:     ext2-devel@lists.sourceforge.net
+L:     linux-ext4@vger.kernel.org
 S:     Maintained
 
 EXT3 FILE SYSTEM
 P:     Stephen Tweedie, Andrew Morton
 M:     sct@redhat.com, akpm@osdl.org, adilger@clusterfs.com
-L:     ext2-devel@lists.sourceforge.net
+L:     linux-ext4@vger.kernel.org
+S:     Maintained
+
+EXT4 FILE SYSTEM
+P:     Stephen Tweedie, Andrew Morton
+M:     sct@redhat.com, akpm@osdl.org, adilger@clusterfs.com
+L:     linux-ext4@vger.kernel.org
 S:     Maintained
 
 F71805F HARDWARE MONITORING DRIVER
@@ -1115,7 +1128,7 @@ S:        Supported
 FRAMEBUFFER LAYER
 P:     Antonino Daplas
 M:     adaplas@pol.net
-L:     linux-fbdev-devel@lists.sourceforge.net 
+L:     linux-fbdev-devel@lists.sourceforge.net (subscribers-only)
 W:     http://linux-fbdev.sourceforge.net/
 S:     Maintained
 
@@ -1214,7 +1227,8 @@ HARDWARE MONITORING
 P:     Jean Delvare
 M:     khali@linux-fr.org
 L:     lm-sensors@lm-sensors.org
-W:     http://www.lm-sensors.nu/
+W:     http://www.lm-sensors.org/
+T:     quilt http://khali.linux-fr.org/devel/linux-2.6/jdelvare-hwmon/
 S:     Maintained
 
 HARDWARE RANDOM NUMBER GENERATOR CORE
@@ -1340,8 +1354,7 @@ I2C SUBSYSTEM
 P:     Jean Delvare
 M:     khali@linux-fr.org
 L:     i2c@lm-sensors.org
-W:     http://www.lm-sensors.nu/
-T:     quilt kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/
+T:     quilt http://khali.linux-fr.org/devel/linux-2.6/jdelvare-i2c/
 S:     Maintained
 
 I2O
@@ -1466,7 +1479,7 @@ S:        Maintained
 IMS TWINTURBO FRAMEBUFFER DRIVER
 P:     Paul Mundt
 M:     lethal@chaoticdreams.org
-L:     linux-fbdev-devel@lists.sourceforge.net
+L:     linux-fbdev-devel@lists.sourceforge.net (subscribers-only)
 S:     Maintained
 
 INFINIBAND SUBSYSTEM
@@ -1499,13 +1512,13 @@ S:      Maintained
 INTEL FRAMEBUFFER DRIVER (excluding 810 and 815)
 P:     Sylvain Meyer
 M:     sylvain.meyer@worldonline.fr
-L:     linux-fbdev-devel@lists.sourceforge.net
+L:     linux-fbdev-devel@lists.sourceforge.net (subscribers-only)
 S:     Maintained
 
 INTEL 810/815 FRAMEBUFFER DRIVER
 P:     Antonino Daplas
 M:     adaplas@pol.net
-L:     linux-fbdev-devel@lists.sourceforge.net
+L:     linux-fbdev-devel@lists.sourceforge.net (subscribers-only)
 S:     Maintained
 
 INTEL APIC/IOAPIC, LOWLEVEL X86 SMP SUPPORT
@@ -1673,7 +1686,7 @@ S:        Supported
 JOURNALLING LAYER FOR BLOCK DEVICES (JBD)
 P:     Stephen Tweedie, Andrew Morton
 M:     sct@redhat.com, akpm@osdl.org
-L:     ext2-devel@lists.sourceforge.net
+L:     linux-ext4@vger.kernel.org
 S:     Maintained
 
 K8TEMP HARDWARE MONITORING DRIVER
@@ -1951,7 +1964,7 @@ S:        Odd Fixes for 2.4; Maintained for 2.6.
 MATROX FRAMEBUFFER DRIVER
 P:     Petr Vandrovec
 M:     vandrove@vc.cvut.cz
-L:     linux-fbdev-devel@lists.sourceforge.net
+L:     linux-fbdev-devel@lists.sourceforge.net (subscribers-only)
 S:     Maintained
 
 MEGARAID SCSI DRIVERS
@@ -2012,6 +2025,12 @@ M:       rubini@ipvvis.unipv.it
 L:     linux-kernel@vger.kernel.org
 S:     Maintained
 
+MOXA SMARTIO/INDUSTIO SERIAL CARD (MXSER 2.0)
+P:     Jiri Slaby
+M:     jirislaby@gmail.com
+L:     linux-kernel@vger.kernel.org
+S:     Maintained
+
 MSI LAPTOP SUPPORT
 P:     Lennart Poettering
 M:     mzxreary@0pointer.de
@@ -2037,6 +2056,12 @@ P:       Andrew Veliath
 M:     andrewtv@usa.net
 S:     Maintained
 
+MULTITECH MULTIPORT CARD (ISICOM)
+P:     Jiri Slaby
+M:     jirislaby@gmail.com
+L:     linux-kernel@vger.kernel.org
+S:     Maintained
+
 NATSEMI ETHERNET DRIVER (DP8381x)
 P:     Tim Hockin
 M:     thockin@hockin.org
@@ -2197,7 +2222,7 @@ S:        Maintained
 NVIDIA (rivafb and nvidiafb) FRAMEBUFFER DRIVER
 P:     Antonino Daplas
 M:     adaplas@pol.net
-L:     linux-fbdev-devel@lists.sourceforge.net
+L:     linux-fbdev-devel@lists.sourceforge.net (subscribers-only)
 S:     Maintained
 
 OPENCORES I2C BUS DRIVER
@@ -2481,13 +2506,13 @@ S:      Maintained
 RADEON FRAMEBUFFER DISPLAY DRIVER
 P:     Benjamin Herrenschmidt
 M:     benh@kernel.crashing.org
-L:     linux-fbdev-devel@lists.sourceforge.net
+L:     linux-fbdev-devel@lists.sourceforge.net (subscribers-only)
 S:     Maintained
 
 RAGE128 FRAMEBUFFER DISPLAY DRIVER
 P:     Paul Mackerras
 M:     paulus@samba.org
-L:     linux-fbdev-devel@lists.sourceforge.net
+L:     linux-fbdev-devel@lists.sourceforge.net (subscribers-only)
 S:     Maintained
 
 RAYLINK/WEBGEAR 802.11 WIRELESS LAN DRIVER
@@ -2557,7 +2582,7 @@ S:        Orphan
 S3 SAVAGE FRAMEBUFFER DRIVER
 P:     Antonino Daplas
 M:     adaplas@pol.net
-L:     linux-fbdev-devel@lists.sourceforge.net
+L:     linux-fbdev-devel@lists.sourceforge.net (subscribers-only)
 S:     Maintained
 
 S390
@@ -2913,7 +2938,6 @@ S:        Maintained
 SUN3/3X
 P:     Sam Creasey
 M:     sammy@sammy.net
-L:     sun3-list@redhat.com
 W:     http://sammy.net/sun3/
 S:     Maintained
 
@@ -3454,6 +3478,12 @@ W:       http://oss.sgi.com/projects/xfs
 T:     git git://oss.sgi.com:8090/xfs/xfs-2.6
 S:     Supported
 
+XILINX UARTLITE SERIAL DRIVER
+P:     Peter Korsgaard
+M:     jacmet@sunsite.dk
+L:     linux-serial@vger.kernel.org
+S:     Maintained
+
 X86 3-LEVEL PAGING (PAE) SUPPORT
 P:     Ingo Molnar
 M:     mingo@redhat.com
index f9da827a0c1880154757981e1430f01f071181f2..ac02e42a2627f359575ae0e689afca911a75e0ff 100644 (file)
@@ -40,7 +40,9 @@ summary from [1.]>" for easy identification by the developers.
 [1.] One line summary of the problem:
 [2.] Full description of the problem/report:
 [3.] Keywords (i.e., modules, networking, kernel):
-[4.] Kernel version (from /proc/version):
+[4.] Kernel information
+[4.1.] Kernel version (from /proc/version):
+[4.2.] Kernel .config file:
 [5.] Most recent kernel version which did not have the bug:
 [6.] Output of Oops.. message (if applicable) with symbolic information
      resolved (see Documentation/oops-tracing.txt)
index 7e55ea66c6d4ad1e41fdaa02ae09c3aabf1991b1..84caf50725b53e829df2a39baa059084d63663e4 100644 (file)
@@ -25,6 +25,14 @@ config RWSEM_XCHGADD_ALGORITHM
        bool
        default y
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 config GENERIC_FIND_NEXT_BIT
        bool
        default y
index ad61736519950e72debd8fa691a9c59181a361a8..fb804043b32080b856dd3e176c9747258b747d62 100644 (file)
@@ -277,7 +277,7 @@ osf_fstatfs(unsigned long fd, struct osf_statfs __user *buffer, unsigned long bu
        retval = -EBADF;
        file = fget(fd);
        if (file) {
-               retval = do_osf_statfs(file->f_dentry, buffer, bufsiz);
+               retval = do_osf_statfs(file->f_path.dentry, buffer, bufsiz);
                fput(file);
        }
        return retval;
index ffb7d5423cc00210fc99e1bf5d6b98cd8d68f1fb..3c10b9a1ddf51fa138bb7e7de192d4d70e4d4544 100644 (file)
@@ -516,10 +516,11 @@ sys_pciconfig_iobase(long which, unsigned long bus, unsigned long dfn)
                if (bus == 0 && dfn == 0) {
                        hose = pci_isa_hose;
                } else {
-                       dev = pci_find_slot(bus, dfn);
+                       dev = pci_get_bus_and_slot(bus, dfn);
                        if (!dev)
                                return -ENODEV;
                        hose = dev->sysdata;
+                       pci_dev_put(dev);
                }
        }
 
index b8b817feb1eedb8db7be5baa8df5639cb02a4b0f..910b43cd63e830b7f1a8664b3a4833b1a81e2e8e 100644 (file)
@@ -183,11 +183,15 @@ miata_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 
        if((slot == 7) && (PCI_FUNC(dev->devfn) == 3)) {
                u8 irq=0;
-
-               if(pci_read_config_byte(pci_find_slot(dev->bus->number, dev->devfn & ~(7)), 0x40,&irq)!=PCIBIOS_SUCCESSFUL)
+               struct pci_dev *pdev = pci_get_slot(dev->bus, dev->devfn & ~7);
+               if(pdev == NULL || pci_read_config_byte(pdev, 0x40,&irq) != PCIBIOS_SUCCESSFUL) {
+                       pci_dev_put(pdev);
                        return -1;
-               else    
+               }
+               else    {
+                       pci_dev_put(pdev);
                        return irq;
+               }
        }
 
        return COMMON_TABLE_LOOKUP;
index 93744bab73fb24ac63d6ba9406a4a3c4d0a294fb..e7594a7cf5850830c0d5b75ccece2e0914a842bd 100644 (file)
@@ -200,7 +200,7 @@ nautilus_init_pci(void)
        bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
        hose->bus = bus;
 
-       irongate = pci_find_slot(0, 0);
+       irongate = pci_get_bus_and_slot(0, 0);
        bus->self = irongate;
        bus->resource[1] = &irongate_mem;
 
index 8871529a34e2026e4f2bd4eda531df7ec59808a4..8aa9db834c11551afc1462bf970d2dbc0ab8a157 100644 (file)
@@ -108,7 +108,7 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
 
        /* If we're in an interrupt context, or have no user context,
           we must not take the fault.  */
-       if (!mm || in_interrupt())
+       if (!mm || in_atomic())
                goto no_context;
 
 #ifdef CONFIG_ALPHA_LARGE_VMALLOC
index ce00c570459de45a19b0ae97c56aca85a84d36f2..aa1d400d721a662f3dbae57a3cb9eea8bc6b6522 100644 (file)
@@ -74,6 +74,14 @@ config RWSEM_GENERIC_SPINLOCK
 config RWSEM_XCHGADD_ALGORITHM
        bool
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 config GENERIC_HWEIGHT
        bool
        default y
@@ -223,6 +231,12 @@ config ARCH_IOP33X
        help
          Support for Intel's IOP33X (XScale) family of processors.
 
+config ARCH_IOP13XX
+       bool "IOP13xx-based"
+       select PCI
+       help
+         Support for Intel's IOP13XX (XScale) family of processors.
+
 config ARCH_IXP4XX
        bool "IXP4xx-based"
        depends on MMU
@@ -331,6 +345,8 @@ source "arch/arm/mach-iop32x/Kconfig"
 
 source "arch/arm/mach-iop33x/Kconfig"
 
+source "arch/arm/mach-iop13xx/Kconfig"
+
 source "arch/arm/mach-ixp4xx/Kconfig"
 
 source "arch/arm/mach-ixp2000/Kconfig"
@@ -374,6 +390,14 @@ config PLAT_IOP
 
 source arch/arm/mm/Kconfig
 
+config IWMMXT
+       bool "Enable iWMMXt support"
+       depends CPU_XSCALE || CPU_XSC3
+       default y if PXA27x
+       help
+         Enable support for iWMMXt context switching at run time if
+         running on a CPU that supports it.
+
 #  bool 'Use XScale PMU as timer source' CONFIG_XSCALE_PMU_TIMER
 config XSCALE_PMU
        bool
@@ -583,7 +607,7 @@ config LEDS
                   ARCH_LUBBOCK || MACH_MAINSTONE || ARCH_NETWINDER || \
                   ARCH_OMAP || ARCH_P720T || ARCH_PXA_IDP || \
                   ARCH_SA1100 || ARCH_SHARK || ARCH_VERSATILE || \
-                  ARCH_AT91RM9200 || MACH_TRIZEPS4
+                  ARCH_AT91 || MACH_TRIZEPS4
        help
          If you say Y here, the LEDs on your machine will be used
          to provide useful information about your current system status.
index d22f38b957db9c825e5cae7bec8bee90357efa06..40c5eb1f55c7e3572f02ebdc39e12d9020bc1936 100644 (file)
@@ -32,10 +32,6 @@ config DEBUG_USER
              8 - SIGSEGV faults
             16 - SIGBUS faults
 
-config DEBUG_WAITQ
-       bool "Wait queue debugging"
-       depends on DEBUG_KERNEL
-
 config DEBUG_ERRORS
        bool "Verbose kernel error messages"
        depends on DEBUG_KERNEL
index 6f4f8bf3607168e4b7df0c213a676ac7d68e8521..000f1100b5538f9f69da886fc0054d2d16746864 100644 (file)
@@ -15,6 +15,8 @@ CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET)
 OBJCOPYFLAGS   :=-O binary -R .note -R .comment -S
 GZFLAGS                :=-9
 #CFLAGS                +=-pipe
+# Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
+CFLAGS         +=$(call cc-option,-marm,)
 
 # Do not use arch/arm/defconfig - it's always outdated.
 # Select a platform tht is kept up-to-date
@@ -108,6 +110,7 @@ endif
  machine-$(CONFIG_ARCH_CLPS711X)   := clps711x
  machine-$(CONFIG_ARCH_IOP32X)    := iop32x
  machine-$(CONFIG_ARCH_IOP33X)    := iop33x
+ machine-$(CONFIG_ARCH_IOP13XX)           := iop13xx
  machine-$(CONFIG_ARCH_IXP4XX)    := ixp4xx
  machine-$(CONFIG_ARCH_IXP2000)    := ixp2000
  machine-$(CONFIG_ARCH_IXP23XX)    := ixp23xx
index f3e020f2227f316a754d0584a5ad0f386146d8df..09b9d1b6844c05315dc50af6e0ea0ffacdfad725 100644 (file)
@@ -160,7 +160,7 @@ void __init gic_dist_init(void __iomem *base)
         */
        for (i = 29; i < max_irq; i++) {
                set_irq_chip(i, &gic_chip);
-               set_irq_handler(i, do_level_IRQ);
+               set_irq_handler(i, handle_level_irq);
                set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
        }
 
index 80a72c75214f65956e5ce1872d190fcb3a4cceae..cfe6f4650bc9fffc836136ecc9ee61d7b5ca0a9c 100644 (file)
@@ -163,11 +163,11 @@ static struct locomo_dev_info locomo_devices[] = {
 #define        LOCOMO_IRQ_LT_START     (IRQ_LOCOMO_LT)
 #define        LOCOMO_IRQ_SPI_START    (IRQ_LOCOMO_SPI_RFR)
 
-static void locomo_handler(unsigned int irq, struct irqdesc *desc)
+static void locomo_handler(unsigned int irq, struct irq_desc *desc)
 {
        int req, i;
-       struct irqdesc *d;
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       struct irq_desc *d;
+       void __iomem *mapbase = get_irq_chip_data(irq);
 
        /* Acknowledge the parent IRQ */
        desc->chip->ack(irq);
@@ -194,7 +194,7 @@ static void locomo_ack_irq(unsigned int irq)
 
 static void locomo_mask_irq(unsigned int irq)
 {
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned int r;
        r = locomo_readl(mapbase + LOCOMO_ICR);
        r &= ~(0x0010 << (irq - LOCOMO_IRQ_START));
@@ -203,7 +203,7 @@ static void locomo_mask_irq(unsigned int irq)
 
 static void locomo_unmask_irq(unsigned int irq)
 {
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned int r;
        r = locomo_readl(mapbase + LOCOMO_ICR);
        r |= (0x0010 << (irq - LOCOMO_IRQ_START));
@@ -217,10 +217,10 @@ static struct irq_chip locomo_chip = {
        .unmask = locomo_unmask_irq,
 };
 
-static void locomo_key_handler(unsigned int irq, struct irqdesc *desc)
+static void locomo_key_handler(unsigned int irq, struct irq_desc *desc)
 {
-       struct irqdesc *d;
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       struct irq_desc *d;
+       void __iomem *mapbase = get_irq_chip_data(irq);
 
        if (locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC) & 0x0001) {
                d = irq_desc + LOCOMO_IRQ_KEY_START;
@@ -230,7 +230,7 @@ static void locomo_key_handler(unsigned int irq, struct irqdesc *desc)
 
 static void locomo_key_ack_irq(unsigned int irq)
 {
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned int r;
        r = locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC);
        r &= ~(0x0100 << (irq - LOCOMO_IRQ_KEY_START));
@@ -239,7 +239,7 @@ static void locomo_key_ack_irq(unsigned int irq)
 
 static void locomo_key_mask_irq(unsigned int irq)
 {
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned int r;
        r = locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC);
        r &= ~(0x0010 << (irq - LOCOMO_IRQ_KEY_START));
@@ -248,7 +248,7 @@ static void locomo_key_mask_irq(unsigned int irq)
 
 static void locomo_key_unmask_irq(unsigned int irq)
 {
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned int r;
        r = locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC);
        r |= (0x0010 << (irq - LOCOMO_IRQ_KEY_START));
@@ -262,11 +262,11 @@ static struct irq_chip locomo_key_chip = {
        .unmask = locomo_key_unmask_irq,
 };
 
-static void locomo_gpio_handler(unsigned int irq, struct irqdesc *desc)
+static void locomo_gpio_handler(unsigned int irq, struct irq_desc *desc)
 {
        int req, i;
-       struct irqdesc *d;
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       struct irq_desc *d;
+       void __iomem *mapbase = get_irq_chip_data(irq);
 
        req =   locomo_readl(mapbase + LOCOMO_GIR) &
                locomo_readl(mapbase + LOCOMO_GPD) &
@@ -285,7 +285,7 @@ static void locomo_gpio_handler(unsigned int irq, struct irqdesc *desc)
 
 static void locomo_gpio_ack_irq(unsigned int irq)
 {
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned int r;
        r = locomo_readl(mapbase + LOCOMO_GWE);
        r |= (0x0001 << (irq - LOCOMO_IRQ_GPIO_START));
@@ -302,7 +302,7 @@ static void locomo_gpio_ack_irq(unsigned int irq)
 
 static void locomo_gpio_mask_irq(unsigned int irq)
 {
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned int r;
        r = locomo_readl(mapbase + LOCOMO_GIE);
        r &= ~(0x0001 << (irq - LOCOMO_IRQ_GPIO_START));
@@ -311,7 +311,7 @@ static void locomo_gpio_mask_irq(unsigned int irq)
 
 static void locomo_gpio_unmask_irq(unsigned int irq)
 {
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned int r;
        r = locomo_readl(mapbase + LOCOMO_GIE);
        r |= (0x0001 << (irq - LOCOMO_IRQ_GPIO_START));
@@ -325,10 +325,10 @@ static struct irq_chip locomo_gpio_chip = {
        .unmask = locomo_gpio_unmask_irq,
 };
 
-static void locomo_lt_handler(unsigned int irq, struct irqdesc *desc)
+static void locomo_lt_handler(unsigned int irq, struct irq_desc *desc)
 {
-       struct irqdesc *d;
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       struct irq_desc *d;
+       void __iomem *mapbase = get_irq_chip_data(irq);
 
        if (locomo_readl(mapbase + LOCOMO_LTINT) & 0x0001) {
                d = irq_desc + LOCOMO_IRQ_LT_START;
@@ -338,7 +338,7 @@ static void locomo_lt_handler(unsigned int irq, struct irqdesc *desc)
 
 static void locomo_lt_ack_irq(unsigned int irq)
 {
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned int r;
        r = locomo_readl(mapbase + LOCOMO_LTINT);
        r &= ~(0x0100 << (irq - LOCOMO_IRQ_LT_START));
@@ -347,7 +347,7 @@ static void locomo_lt_ack_irq(unsigned int irq)
 
 static void locomo_lt_mask_irq(unsigned int irq)
 {
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned int r;
        r = locomo_readl(mapbase + LOCOMO_LTINT);
        r &= ~(0x0010 << (irq - LOCOMO_IRQ_LT_START));
@@ -356,7 +356,7 @@ static void locomo_lt_mask_irq(unsigned int irq)
 
 static void locomo_lt_unmask_irq(unsigned int irq)
 {
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned int r;
        r = locomo_readl(mapbase + LOCOMO_LTINT);
        r |= (0x0010 << (irq - LOCOMO_IRQ_LT_START));
@@ -370,11 +370,11 @@ static struct irq_chip locomo_lt_chip = {
        .unmask = locomo_lt_unmask_irq,
 };
 
-static void locomo_spi_handler(unsigned int irq, struct irqdesc *desc)
+static void locomo_spi_handler(unsigned int irq, struct irq_desc *desc)
 {
        int req, i;
-       struct irqdesc *d;
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       struct irq_desc *d;
+       void __iomem *mapbase = get_irq_chip_data(irq);
 
        req = locomo_readl(mapbase + LOCOMO_SPI + LOCOMO_SPIIR) & 0x000F;
        if (req) {
@@ -391,7 +391,7 @@ static void locomo_spi_handler(unsigned int irq, struct irqdesc *desc)
 
 static void locomo_spi_ack_irq(unsigned int irq)
 {
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned int r;
        r = locomo_readl(mapbase + LOCOMO_SPI + LOCOMO_SPIWE);
        r |= (0x0001 << (irq - LOCOMO_IRQ_SPI_START));
@@ -408,7 +408,7 @@ static void locomo_spi_ack_irq(unsigned int irq)
 
 static void locomo_spi_mask_irq(unsigned int irq)
 {
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned int r;
        r = locomo_readl(mapbase + LOCOMO_SPI + LOCOMO_SPIIE);
        r &= ~(0x0001 << (irq - LOCOMO_IRQ_SPI_START));
@@ -417,7 +417,7 @@ static void locomo_spi_mask_irq(unsigned int irq)
 
 static void locomo_spi_unmask_irq(unsigned int irq)
 {
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned int r;
        r = locomo_readl(mapbase + LOCOMO_SPI + LOCOMO_SPIIE);
        r |= (0x0001 << (irq - LOCOMO_IRQ_SPI_START));
@@ -440,55 +440,55 @@ static void locomo_setup_irq(struct locomo *lchip)
         * Install handler for IRQ_LOCOMO_HW.
         */
        set_irq_type(lchip->irq, IRQT_FALLING);
-       set_irq_chipdata(lchip->irq, irqbase);
+       set_irq_chip_data(lchip->irq, irqbase);
        set_irq_chained_handler(lchip->irq, locomo_handler);
 
        /* Install handlers for IRQ_LOCOMO_*_BASE */
        set_irq_chip(IRQ_LOCOMO_KEY_BASE, &locomo_chip);
-       set_irq_chipdata(IRQ_LOCOMO_KEY_BASE, irqbase);
+       set_irq_chip_data(IRQ_LOCOMO_KEY_BASE, irqbase);
        set_irq_chained_handler(IRQ_LOCOMO_KEY_BASE, locomo_key_handler);
        set_irq_flags(IRQ_LOCOMO_KEY_BASE, IRQF_VALID | IRQF_PROBE);
 
        set_irq_chip(IRQ_LOCOMO_GPIO_BASE, &locomo_chip);
-       set_irq_chipdata(IRQ_LOCOMO_GPIO_BASE, irqbase);
+       set_irq_chip_data(IRQ_LOCOMO_GPIO_BASE, irqbase);
        set_irq_chained_handler(IRQ_LOCOMO_GPIO_BASE, locomo_gpio_handler);
        set_irq_flags(IRQ_LOCOMO_GPIO_BASE, IRQF_VALID | IRQF_PROBE);
 
        set_irq_chip(IRQ_LOCOMO_LT_BASE, &locomo_chip);
-       set_irq_chipdata(IRQ_LOCOMO_LT_BASE, irqbase);
+       set_irq_chip_data(IRQ_LOCOMO_LT_BASE, irqbase);
        set_irq_chained_handler(IRQ_LOCOMO_LT_BASE, locomo_lt_handler);
        set_irq_flags(IRQ_LOCOMO_LT_BASE, IRQF_VALID | IRQF_PROBE);
 
        set_irq_chip(IRQ_LOCOMO_SPI_BASE, &locomo_chip);
-       set_irq_chipdata(IRQ_LOCOMO_SPI_BASE, irqbase);
+       set_irq_chip_data(IRQ_LOCOMO_SPI_BASE, irqbase);
        set_irq_chained_handler(IRQ_LOCOMO_SPI_BASE, locomo_spi_handler);
        set_irq_flags(IRQ_LOCOMO_SPI_BASE, IRQF_VALID | IRQF_PROBE);
 
        /* install handlers for IRQ_LOCOMO_KEY_BASE generated interrupts */
        set_irq_chip(LOCOMO_IRQ_KEY_START, &locomo_key_chip);
-       set_irq_chipdata(LOCOMO_IRQ_KEY_START, irqbase);
-       set_irq_handler(LOCOMO_IRQ_KEY_START, do_edge_IRQ);
+       set_irq_chip_data(LOCOMO_IRQ_KEY_START, irqbase);
+       set_irq_handler(LOCOMO_IRQ_KEY_START, handle_edge_irq);
        set_irq_flags(LOCOMO_IRQ_KEY_START, IRQF_VALID | IRQF_PROBE);
 
        /* install handlers for IRQ_LOCOMO_GPIO_BASE generated interrupts */
        for (irq = LOCOMO_IRQ_GPIO_START; irq < LOCOMO_IRQ_GPIO_START + 16; irq++) {
                set_irq_chip(irq, &locomo_gpio_chip);
-               set_irq_chipdata(irq, irqbase);
-               set_irq_handler(irq, do_edge_IRQ);
+               set_irq_chip_data(irq, irqbase);
+               set_irq_handler(irq, handle_edge_irq);
                set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
        }
 
        /* install handlers for IRQ_LOCOMO_LT_BASE generated interrupts */
        set_irq_chip(LOCOMO_IRQ_LT_START, &locomo_lt_chip);
-       set_irq_chipdata(LOCOMO_IRQ_LT_START, irqbase);
-       set_irq_handler(LOCOMO_IRQ_LT_START, do_edge_IRQ);
+       set_irq_chip_data(LOCOMO_IRQ_LT_START, irqbase);
+       set_irq_handler(LOCOMO_IRQ_LT_START, handle_edge_irq);
        set_irq_flags(LOCOMO_IRQ_LT_START, IRQF_VALID | IRQF_PROBE);
 
        /* install handlers for IRQ_LOCOMO_SPI_BASE generated interrupts */
        for (irq = LOCOMO_IRQ_SPI_START; irq < LOCOMO_IRQ_SPI_START + 3; irq++) {
                set_irq_chip(irq, &locomo_spi_chip);
-               set_irq_chipdata(irq, irqbase);
-               set_irq_handler(irq, do_edge_IRQ);
+               set_irq_chip_data(irq, irqbase);
+               set_irq_handler(irq, handle_edge_irq);
                set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
        }
 }
index d5f72010a6f315c122fb50f211690eec45ed39b6..fe3f05901a234cffc6a3b0cf8031ae5832280663 100644 (file)
@@ -147,7 +147,7 @@ void __init sa1111_adjust_zones(int node, unsigned long *size, unsigned long *ho
  * will call us again if there are more interrupts to process.
  */
 static void
-sa1111_irq_handler(unsigned int irq, struct irqdesc *desc)
+sa1111_irq_handler(unsigned int irq, struct irq_desc *desc)
 {
        unsigned int stat0, stat1, i;
        void __iomem *base = get_irq_data(irq);
@@ -187,7 +187,7 @@ static void sa1111_ack_irq(unsigned int irq)
 
 static void sa1111_mask_lowirq(unsigned int irq)
 {
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned long ie0;
 
        ie0 = sa1111_readl(mapbase + SA1111_INTEN0);
@@ -197,7 +197,7 @@ static void sa1111_mask_lowirq(unsigned int irq)
 
 static void sa1111_unmask_lowirq(unsigned int irq)
 {
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned long ie0;
 
        ie0 = sa1111_readl(mapbase + SA1111_INTEN0);
@@ -215,7 +215,7 @@ static void sa1111_unmask_lowirq(unsigned int irq)
 static int sa1111_retrigger_lowirq(unsigned int irq)
 {
        unsigned int mask = SA1111_IRQMASK_LO(irq);
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned long ip0;
        int i;
 
@@ -236,7 +236,7 @@ static int sa1111_retrigger_lowirq(unsigned int irq)
 static int sa1111_type_lowirq(unsigned int irq, unsigned int flags)
 {
        unsigned int mask = SA1111_IRQMASK_LO(irq);
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned long ip0;
 
        if (flags == IRQT_PROBE)
@@ -259,7 +259,7 @@ static int sa1111_type_lowirq(unsigned int irq, unsigned int flags)
 static int sa1111_wake_lowirq(unsigned int irq, unsigned int on)
 {
        unsigned int mask = SA1111_IRQMASK_LO(irq);
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned long we0;
 
        we0 = sa1111_readl(mapbase + SA1111_WAKEEN0);
@@ -284,7 +284,7 @@ static struct irq_chip sa1111_low_chip = {
 
 static void sa1111_mask_highirq(unsigned int irq)
 {
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned long ie1;
 
        ie1 = sa1111_readl(mapbase + SA1111_INTEN1);
@@ -294,7 +294,7 @@ static void sa1111_mask_highirq(unsigned int irq)
 
 static void sa1111_unmask_highirq(unsigned int irq)
 {
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned long ie1;
 
        ie1 = sa1111_readl(mapbase + SA1111_INTEN1);
@@ -312,7 +312,7 @@ static void sa1111_unmask_highirq(unsigned int irq)
 static int sa1111_retrigger_highirq(unsigned int irq)
 {
        unsigned int mask = SA1111_IRQMASK_HI(irq);
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned long ip1;
        int i;
 
@@ -333,7 +333,7 @@ static int sa1111_retrigger_highirq(unsigned int irq)
 static int sa1111_type_highirq(unsigned int irq, unsigned int flags)
 {
        unsigned int mask = SA1111_IRQMASK_HI(irq);
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned long ip1;
 
        if (flags == IRQT_PROBE)
@@ -356,7 +356,7 @@ static int sa1111_type_highirq(unsigned int irq, unsigned int flags)
 static int sa1111_wake_highirq(unsigned int irq, unsigned int on)
 {
        unsigned int mask = SA1111_IRQMASK_HI(irq);
-       void __iomem *mapbase = get_irq_chipdata(irq);
+       void __iomem *mapbase = get_irq_chip_data(irq);
        unsigned long we1;
 
        we1 = sa1111_readl(mapbase + SA1111_WAKEEN1);
@@ -410,15 +410,15 @@ static void sa1111_setup_irq(struct sa1111 *sachip)
 
        for (irq = IRQ_GPAIN0; irq <= SSPROR; irq++) {
                set_irq_chip(irq, &sa1111_low_chip);
-               set_irq_chipdata(irq, irqbase);
-               set_irq_handler(irq, do_edge_IRQ);
+               set_irq_chip_data(irq, irqbase);
+               set_irq_handler(irq, handle_edge_irq);
                set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
        }
 
        for (irq = AUDXMTDMADONEA; irq <= IRQ_S1_BVD1_STSCHG; irq++) {
                set_irq_chip(irq, &sa1111_high_chip);
-               set_irq_chipdata(irq, irqbase);
-               set_irq_handler(irq, do_edge_IRQ);
+               set_irq_chip_data(irq, irqbase);
+               set_irq_handler(irq, handle_edge_irq);
                set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
        }
 
index 43d278134521a23f7d5ab9e9075d3de0e9ab6efb..c026fa2214a3f5000b28eaf206e2275d001f5c5f 100644 (file)
 
 static void vic_mask_irq(unsigned int irq)
 {
-       void __iomem *base = get_irq_chipdata(irq);
+       void __iomem *base = get_irq_chip_data(irq);
        irq &= 31;
        writel(1 << irq, base + VIC_INT_ENABLE_CLEAR);
 }
 
 static void vic_unmask_irq(unsigned int irq)
 {
-       void __iomem *base = get_irq_chipdata(irq);
+       void __iomem *base = get_irq_chip_data(irq);
        irq &= 31;
        writel(1 << irq, base + VIC_INT_ENABLE);
 }
@@ -88,10 +88,10 @@ void __init vic_init(void __iomem *base, unsigned int irq_start,
                unsigned int irq = irq_start + i;
 
                set_irq_chip(irq, &vic_chip);
-               set_irq_chipdata(irq, base);
+               set_irq_chip_data(irq, base);
 
                if (vic_sources & (1 << i)) {
-                       set_irq_handler(irq, do_level_IRQ);
+                       set_irq_handler(irq, handle_level_irq);
                        set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
                }
        }
index b43041476e02b9c550f48d82fabf536ea06aa052..e10d003566d6360d937d1f008055a553fb57fe80 100644 (file)
@@ -357,9 +357,9 @@ CONFIG_MTD_CFI_UTIL=y
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
 CONFIG_MTD_PHYSMAP=y
-CONFIG_MTD_PHYSMAP_START=0x10000000
-CONFIG_MTD_PHYSMAP_LEN=0x200000
-CONFIG_MTD_PHYSMAP_BANKWIDTH=2
+CONFIG_MTD_PHYSMAP_START=0
+CONFIG_MTD_PHYSMAP_LEN=0
+CONFIG_MTD_PHYSMAP_BANKWIDTH=0
 # CONFIG_MTD_ARM_INTEGRATOR is not set
 # CONFIG_MTD_IMPA7 is not set
 # CONFIG_MTD_PLATRAM is not set
@@ -585,7 +585,9 @@ CONFIG_AT91RM9200_WATCHDOG=y
 # CONFIG_USBPCWATCHDOG is not set
 # CONFIG_NVRAM is not set
 # CONFIG_RTC is not set
-CONFIG_AT91_RTC=y
+CONFIG_RTC_LIB=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_AT91RM9200=y
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 
@@ -979,7 +981,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 CONFIG_FRAME_POINTER=y
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 # CONFIG_DEBUG_ERRORS is not set
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index d96fc8386e2f024ea7905e54a3b287a7f5244294..834dddb513144ce90da4be457d9136bff3086c6f 100644 (file)
@@ -348,9 +348,9 @@ CONFIG_MTD_CFI_UTIL=y
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
 CONFIG_MTD_PHYSMAP=y
-CONFIG_MTD_PHYSMAP_START=0x10000000
-CONFIG_MTD_PHYSMAP_LEN=0x800000
-CONFIG_MTD_PHYSMAP_BANKWIDTH=2
+CONFIG_MTD_PHYSMAP_START=0
+CONFIG_MTD_PHYSMAP_LEN=0
+CONFIG_MTD_PHYSMAP_BANKWIDTH=0
 # CONFIG_MTD_ARM_INTEGRATOR is not set
 # CONFIG_MTD_IMPA7 is not set
 # CONFIG_MTD_PLATRAM is not set
@@ -566,7 +566,9 @@ CONFIG_AT91RM9200_WATCHDOG=y
 # CONFIG_USBPCWATCHDOG is not set
 # CONFIG_NVRAM is not set
 # CONFIG_RTC is not set
-CONFIG_AT91_RTC=y
+CONFIG_RTC_LIB=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_AT91RM9200=y
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 
@@ -968,7 +970,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 CONFIG_FRAME_POINTER=y
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 # CONFIG_DEBUG_ERRORS is not set
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
diff --git a/arch/arm/configs/at91sam9260ek_defconfig b/arch/arm/configs/at91sam9260ek_defconfig
new file mode 100644 (file)
index 0000000..7904920
--- /dev/null
@@ -0,0 +1,950 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.19-rc6
+# Fri Nov 17 18:42:21 2006
+#
+CONFIG_ARM=y
+# CONFIG_GENERIC_TIME is not set
+CONFIG_MMU=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_HARDIRQS_SW_RESEND=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_VECTORS_BASE=0xffff0000
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+# CONFIG_SWAP is not set
+CONFIG_SYSVIPC=y
+# CONFIG_IPC_NS is not set
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_TASKSTATS is not set
+# CONFIG_UTS_NS is not set
+# CONFIG_AUDIT is not set
+# CONFIG_IKCONFIG is not set
+# CONFIG_RELAY is not set
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+# CONFIG_EMBEDDED is not set
+CONFIG_UID16=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SHMEM=y
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_RT_MUTEXES=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Block layer
+#
+CONFIG_BLOCK=y
+# CONFIG_BLK_DEV_IO_TRACE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+# CONFIG_IOSCHED_DEADLINE is not set
+# CONFIG_IOSCHED_CFQ is not set
+CONFIG_DEFAULT_AS=y
+# CONFIG_DEFAULT_DEADLINE is not set
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="anticipatory"
+
+#
+# System Type
+#
+# CONFIG_ARCH_AAEC2000 is not set
+# CONFIG_ARCH_INTEGRATOR is not set
+# CONFIG_ARCH_REALVIEW is not set
+# CONFIG_ARCH_VERSATILE is not set
+CONFIG_ARCH_AT91=y
+# CONFIG_ARCH_CLPS7500 is not set
+# CONFIG_ARCH_CLPS711X is not set
+# CONFIG_ARCH_CO285 is not set
+# CONFIG_ARCH_EBSA110 is not set
+# CONFIG_ARCH_EP93XX is not set
+# CONFIG_ARCH_FOOTBRIDGE is not set
+# CONFIG_ARCH_NETX is not set
+# CONFIG_ARCH_H720X is not set
+# CONFIG_ARCH_IMX is not set
+# CONFIG_ARCH_IOP32X is not set
+# CONFIG_ARCH_IOP33X is not set
+# CONFIG_ARCH_IXP4XX is not set
+# CONFIG_ARCH_IXP2000 is not set
+# CONFIG_ARCH_IXP23XX is not set
+# CONFIG_ARCH_L7200 is not set
+# CONFIG_ARCH_PNX4008 is not set
+# CONFIG_ARCH_PXA is not set
+# CONFIG_ARCH_RPC is not set
+# CONFIG_ARCH_SA1100 is not set
+# CONFIG_ARCH_S3C2410 is not set
+# CONFIG_ARCH_SHARK is not set
+# CONFIG_ARCH_LH7A40X is not set
+# CONFIG_ARCH_OMAP is not set
+
+#
+# Atmel AT91 System-on-Chip
+#
+# CONFIG_ARCH_AT91RM9200 is not set
+CONFIG_ARCH_AT91SAM9260=y
+# CONFIG_ARCH_AT91SAM9261 is not set
+
+#
+# AT91SAM9260 Board Type
+#
+CONFIG_MACH_AT91SAM9260EK=y
+
+#
+# AT91 Board Options
+#
+# CONFIG_MTD_NAND_AT91_BUSWIDTH_16 is not set
+
+#
+# AT91 Feature Selections
+#
+# CONFIG_AT91_PROGRAMMABLE_CLOCKS is not set
+
+#
+# Processor Type
+#
+CONFIG_CPU_32=y
+CONFIG_CPU_ARM926T=y
+CONFIG_CPU_32v5=y
+CONFIG_CPU_ABRT_EV5TJ=y
+CONFIG_CPU_CACHE_VIVT=y
+CONFIG_CPU_COPY_V4WB=y
+CONFIG_CPU_TLB_V4WBI=y
+CONFIG_CPU_CP15=y
+CONFIG_CPU_CP15_MMU=y
+
+#
+# Processor Features
+#
+# CONFIG_ARM_THUMB is not set
+# CONFIG_CPU_ICACHE_DISABLE is not set
+# CONFIG_CPU_DCACHE_DISABLE is not set
+# CONFIG_CPU_DCACHE_WRITETHROUGH is not set
+# CONFIG_CPU_CACHE_ROUND_ROBIN is not set
+
+#
+# Bus support
+#
+
+#
+# PCCARD (PCMCIA/CardBus) support
+#
+# CONFIG_PCCARD is not set
+
+#
+# Kernel Features
+#
+# CONFIG_PREEMPT is not set
+# CONFIG_NO_IDLE_HZ is not set
+CONFIG_HZ=100
+# CONFIG_AEABI is not set
+# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4096
+# CONFIG_RESOURCES_64BIT is not set
+# CONFIG_LEDS is not set
+CONFIG_ALIGNMENT_TRAP=y
+
+#
+# Boot options
+#
+CONFIG_ZBOOT_ROM_TEXT=0x0
+CONFIG_ZBOOT_ROM_BSS=0x0
+CONFIG_CMDLINE="mem=64M console=ttyS0,115200 initrd=0x21100000,3145728 root=/dev/ram0 rw"
+# CONFIG_XIP_KERNEL is not set
+
+#
+# Floating point emulation
+#
+
+#
+# At least one emulation must be selected
+#
+CONFIG_FPE_NWFPE=y
+# CONFIG_FPE_NWFPE_XP is not set
+# CONFIG_FPE_FASTFPE is not set
+# CONFIG_VFP is not set
+
+#
+# Userspace binary formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_AOUT is not set
+# CONFIG_BINFMT_MISC is not set
+# CONFIG_ARTHUR is not set
+
+#
+# Power management options
+#
+# CONFIG_PM is not set
+# CONFIG_APM is not set
+
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+# CONFIG_IP_PNP_DHCP is not set
+CONFIG_IP_PNP_BOOTP=y
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_IPV6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_FW_LOADER is not set
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_COW_COMMON is not set
+# CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=8192
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+CONFIG_SCSI=y
+# CONFIG_SCSI_NETLINK is not set
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+# CONFIG_BLK_DEV_SR is not set
+# CONFIG_CHR_DEV_SG is not set
+# CONFIG_CHR_DEV_SCH is not set
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+CONFIG_SCSI_MULTI_LUN=y
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transports
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+# CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_ISCSI_TCP is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Fusion MPT device support
+#
+# CONFIG_FUSION is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Network device support
+#
+# CONFIG_NETDEVICES is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+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_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_ATMEL=y
+CONFIG_SERIAL_ATMEL_CONSOLE=y
+# CONFIG_SERIAL_ATMEL_TTYAT is not set
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+CONFIG_WATCHDOG=y
+CONFIG_WATCHDOG_NOWAYOUT=y
+
+#
+# Watchdog Device Drivers
+#
+# CONFIG_SOFT_WATCHDOG is not set
+
+#
+# USB-based Watchdog Cards
+#
+# CONFIG_USBPCWATCHDOG is not set
+CONFIG_HW_RANDOM=y
+# CONFIG_NVRAM is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_RAW_DRIVER is not set
+
+#
+# TPM devices
+#
+# CONFIG_TCG_TPM is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Hardware Monitoring support
+#
+# CONFIG_HWMON is not set
+# CONFIG_HWMON_VID is not set
+
+#
+# Misc devices
+#
+# CONFIG_TIFM_CORE is not set
+
+#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+# CONFIG_USB_DABUSB is not set
+
+#
+# Graphics support
+#
+# CONFIG_FIRMWARE_EDID is not set
+# CONFIG_FB is not set
+
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+CONFIG_USB=y
+# CONFIG_USB_DEBUG is not set
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_BANDWIDTH is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_OTG is not set
+
+#
+# USB Host Controller Drivers
+#
+# CONFIG_USB_ISP116X_HCD is not set
+CONFIG_USB_OHCI_HCD=y
+# CONFIG_USB_OHCI_BIG_ENDIAN is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+# CONFIG_USB_SL811_HCD is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# may also be needed; see USB_STORAGE Help for more information
+#
+CONFIG_USB_STORAGE=y
+CONFIG_USB_STORAGE_DEBUG=y
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_USBAT is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_STORAGE_SDDR55 is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_ALAUDA is not set
+# CONFIG_USB_STORAGE_KARMA is not set
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Input Devices
+#
+# CONFIG_USB_HID is not set
+
+#
+# USB HID Boot Protocol drivers
+#
+# CONFIG_USB_KBD is not set
+# CONFIG_USB_MOUSE is not set
+# CONFIG_USB_AIPTEK is not set
+# CONFIG_USB_WACOM is not set
+# CONFIG_USB_ACECAD is not set
+# CONFIG_USB_KBTAB is not set
+# CONFIG_USB_POWERMATE is not set
+# CONFIG_USB_TOUCHSCREEN is not set
+# CONFIG_USB_YEALINK is not set
+# CONFIG_USB_XPAD is not set
+# CONFIG_USB_ATI_REMOTE is not set
+# CONFIG_USB_ATI_REMOTE2 is not set
+# CONFIG_USB_KEYSPAN_REMOTE is not set
+# CONFIG_USB_APPLETOUCH is not set
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_MICROTEK is not set
+
+#
+# USB Network Adapters
+#
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_RTL8150 is not set
+# CONFIG_USB_USBNET_MII is not set
+# CONFIG_USB_USBNET is not set
+CONFIG_USB_MON=y
+
+#
+# USB port drivers
+#
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+
+#
+# USB Miscellaneous drivers
+#
+# CONFIG_USB_EMI62 is not set
+# CONFIG_USB_EMI26 is not set
+# CONFIG_USB_ADUTUX is not set
+# CONFIG_USB_AUERSWALD is not set
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_LEGOTOWER is not set
+# CONFIG_USB_LCD is not set
+# CONFIG_USB_LED is not set
+# CONFIG_USB_CYPRESS_CY7C63 is not set
+# CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_PHIDGET is not set
+# CONFIG_USB_IDMOUSE is not set
+# CONFIG_USB_FTDI_ELAN is not set
+# CONFIG_USB_APPLEDISPLAY is not set
+# CONFIG_USB_LD is not set
+# CONFIG_USB_TRANCEVIBRATOR is not set
+# CONFIG_USB_TEST is not set
+
+#
+# USB DSL modem support
+#
+
+#
+# USB Gadget Support
+#
+CONFIG_USB_GADGET=y
+# CONFIG_USB_GADGET_DEBUG_FILES is not set
+CONFIG_USB_GADGET_SELECTED=y
+# CONFIG_USB_GADGET_NET2280 is not set
+# CONFIG_USB_GADGET_PXA2XX is not set
+# CONFIG_USB_GADGET_GOKU is not set
+# CONFIG_USB_GADGET_LH7A40X is not set
+# CONFIG_USB_GADGET_OMAP is not set
+CONFIG_USB_GADGET_AT91=y
+CONFIG_USB_AT91=y
+# CONFIG_USB_GADGET_DUMMY_HCD is not set
+# CONFIG_USB_GADGET_DUALSPEED is not set
+CONFIG_USB_ZERO=m
+# CONFIG_USB_ETH is not set
+CONFIG_USB_GADGETFS=m
+CONFIG_USB_FILE_STORAGE=m
+# CONFIG_USB_FILE_STORAGE_TEST is not set
+CONFIG_USB_G_SERIAL=m
+# CONFIG_USB_MIDI_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
+# Real Time Clock
+#
+CONFIG_RTC_LIB=y
+# CONFIG_RTC_CLASS is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_EXT4DEV_FS is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+# CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+# CONFIG_MSDOS_FS is not set
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_POSIX_ACL is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+# CONFIG_CONFIGFS_FS is not set
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_CRAMFS=y
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+# CONFIG_NFS_FS is not set
+# CONFIG_NFSD is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+CONFIG_NLS_CODEPAGE_850=y
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ISO8859_1=y
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_MUST_CHECK=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+CONFIG_DEBUG_KERNEL=y
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_DETECT_SOFTLOCKUP=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_RWSEMS is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_DEBUG_FS is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_LIST is not set
+CONFIG_FRAME_POINTER=y
+CONFIG_FORCED_INLINING=y
+# CONFIG_HEADERS_CHECK is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+CONFIG_DEBUG_USER=y
+# CONFIG_DEBUG_WAITQ is not set
+# CONFIG_DEBUG_ERRORS is not set
+CONFIG_DEBUG_LL=y
+# CONFIG_DEBUG_ICEDCC is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+# CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_PLIST=y
diff --git a/arch/arm/configs/at91sam9261ek_defconfig b/arch/arm/configs/at91sam9261ek_defconfig
new file mode 100644 (file)
index 0000000..784ad7c
--- /dev/null
@@ -0,0 +1,1106 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.19-rc6
+# Fri Nov 17 18:00:38 2006
+#
+CONFIG_ARM=y
+# CONFIG_GENERIC_TIME is not set
+CONFIG_MMU=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_HARDIRQS_SW_RESEND=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_VECTORS_BASE=0xffff0000
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+# CONFIG_SWAP is not set
+CONFIG_SYSVIPC=y
+# CONFIG_IPC_NS is not set
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_TASKSTATS is not set
+# CONFIG_UTS_NS is not set
+# CONFIG_AUDIT is not set
+# CONFIG_IKCONFIG is not set
+# CONFIG_RELAY is not set
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+# CONFIG_EMBEDDED is not set
+CONFIG_UID16=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SHMEM=y
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_RT_MUTEXES=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Block layer
+#
+CONFIG_BLOCK=y
+# CONFIG_BLK_DEV_IO_TRACE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+# CONFIG_IOSCHED_DEADLINE is not set
+# CONFIG_IOSCHED_CFQ is not set
+CONFIG_DEFAULT_AS=y
+# CONFIG_DEFAULT_DEADLINE is not set
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="anticipatory"
+
+#
+# System Type
+#
+# CONFIG_ARCH_AAEC2000 is not set
+# CONFIG_ARCH_INTEGRATOR is not set
+# CONFIG_ARCH_REALVIEW is not set
+# CONFIG_ARCH_VERSATILE is not set
+CONFIG_ARCH_AT91=y
+# CONFIG_ARCH_CLPS7500 is not set
+# CONFIG_ARCH_CLPS711X is not set
+# CONFIG_ARCH_CO285 is not set
+# CONFIG_ARCH_EBSA110 is not set
+# CONFIG_ARCH_EP93XX is not set
+# CONFIG_ARCH_FOOTBRIDGE is not set
+# CONFIG_ARCH_NETX is not set
+# CONFIG_ARCH_H720X is not set
+# CONFIG_ARCH_IMX is not set
+# CONFIG_ARCH_IOP32X is not set
+# CONFIG_ARCH_IOP33X is not set
+# CONFIG_ARCH_IXP4XX is not set
+# CONFIG_ARCH_IXP2000 is not set
+# CONFIG_ARCH_IXP23XX is not set
+# CONFIG_ARCH_L7200 is not set
+# CONFIG_ARCH_PNX4008 is not set
+# CONFIG_ARCH_PXA is not set
+# CONFIG_ARCH_RPC is not set
+# CONFIG_ARCH_SA1100 is not set
+# CONFIG_ARCH_S3C2410 is not set
+# CONFIG_ARCH_SHARK is not set
+# CONFIG_ARCH_LH7A40X is not set
+# CONFIG_ARCH_OMAP is not set
+
+#
+# Atmel AT91 System-on-Chip
+#
+# CONFIG_ARCH_AT91RM9200 is not set
+# CONFIG_ARCH_AT91SAM9260 is not set
+CONFIG_ARCH_AT91SAM9261=y
+
+#
+# AT91SAM9261 Board Type
+#
+CONFIG_MACH_AT91SAM9261EK=y
+
+#
+# AT91 Board Options
+#
+# CONFIG_MTD_NAND_AT91_BUSWIDTH_16 is not set
+
+#
+# AT91 Feature Selections
+#
+# CONFIG_AT91_PROGRAMMABLE_CLOCKS is not set
+
+#
+# Processor Type
+#
+CONFIG_CPU_32=y
+CONFIG_CPU_ARM926T=y
+CONFIG_CPU_32v5=y
+CONFIG_CPU_ABRT_EV5TJ=y
+CONFIG_CPU_CACHE_VIVT=y
+CONFIG_CPU_COPY_V4WB=y
+CONFIG_CPU_TLB_V4WBI=y
+CONFIG_CPU_CP15=y
+CONFIG_CPU_CP15_MMU=y
+
+#
+# Processor Features
+#
+# CONFIG_ARM_THUMB is not set
+# CONFIG_CPU_ICACHE_DISABLE is not set
+# CONFIG_CPU_DCACHE_DISABLE is not set
+# CONFIG_CPU_DCACHE_WRITETHROUGH is not set
+# CONFIG_CPU_CACHE_ROUND_ROBIN is not set
+
+#
+# Bus support
+#
+
+#
+# PCCARD (PCMCIA/CardBus) support
+#
+# CONFIG_PCCARD is not set
+
+#
+# Kernel Features
+#
+# CONFIG_PREEMPT is not set
+# CONFIG_NO_IDLE_HZ is not set
+CONFIG_HZ=100
+# CONFIG_AEABI is not set
+# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4096
+# CONFIG_RESOURCES_64BIT is not set
+# CONFIG_LEDS is not set
+CONFIG_ALIGNMENT_TRAP=y
+
+#
+# Boot options
+#
+CONFIG_ZBOOT_ROM_TEXT=0x0
+CONFIG_ZBOOT_ROM_BSS=0x0
+CONFIG_CMDLINE="mem=64M console=ttyS0,115200 initrd=0x21100000,3145728 root=/dev/ram0 rw"
+# CONFIG_XIP_KERNEL is not set
+
+#
+# Floating point emulation
+#
+
+#
+# At least one emulation must be selected
+#
+CONFIG_FPE_NWFPE=y
+# CONFIG_FPE_NWFPE_XP is not set
+# CONFIG_FPE_FASTFPE is not set
+# CONFIG_VFP is not set
+
+#
+# Userspace binary formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_AOUT is not set
+# CONFIG_BINFMT_MISC is not set
+# CONFIG_ARTHUR is not set
+
+#
+# Power management options
+#
+# CONFIG_PM is not set
+# CONFIG_APM is not set
+
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+# CONFIG_IP_PNP_DHCP is not set
+CONFIG_IP_PNP_BOOTP=y
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_IPV6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_FW_LOADER is not set
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_CONCAT is not set
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_REDBOOT_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AFS_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+# CONFIG_MTD_CHAR is not set
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+# CONFIG_MTD_CFI is not set
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+# CONFIG_MTD_OBSOLETE_CHIPS is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLOCK2MTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+
+#
+# NAND Flash Device Drivers
+#
+CONFIG_MTD_NAND=y
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+# CONFIG_MTD_NAND_ECC_SMC is not set
+CONFIG_MTD_NAND_IDS=y
+# CONFIG_MTD_NAND_DISKONCHIP is not set
+CONFIG_MTD_NAND_AT91=y
+# CONFIG_MTD_NAND_NANDSIM is not set
+
+#
+# OneNAND Flash Device Drivers
+#
+# CONFIG_MTD_ONENAND is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_COW_COMMON is not set
+# CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=8192
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+CONFIG_SCSI=y
+# CONFIG_SCSI_NETLINK is not set
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+# CONFIG_BLK_DEV_SR is not set
+# CONFIG_CHR_DEV_SG is not set
+# CONFIG_CHR_DEV_SCH is not set
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+CONFIG_SCSI_MULTI_LUN=y
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transports
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+# CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_ISCSI_TCP is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Fusion MPT device support
+#
+# CONFIG_FUSION is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# PHY device support
+#
+# CONFIG_PHYLIB is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+# CONFIG_SMC91X is not set
+CONFIG_DM9000=y
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+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_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_ATMEL=y
+CONFIG_SERIAL_ATMEL_CONSOLE=y
+# CONFIG_SERIAL_ATMEL_TTYAT is not set
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+CONFIG_WATCHDOG=y
+CONFIG_WATCHDOG_NOWAYOUT=y
+
+#
+# Watchdog Device Drivers
+#
+# CONFIG_SOFT_WATCHDOG is not set
+
+#
+# USB-based Watchdog Cards
+#
+# CONFIG_USBPCWATCHDOG is not set
+CONFIG_HW_RANDOM=y
+# CONFIG_NVRAM is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_RAW_DRIVER is not set
+
+#
+# TPM devices
+#
+# CONFIG_TCG_TPM is not set
+
+#
+# I2C support
+#
+CONFIG_I2C=y
+CONFIG_I2C_CHARDEV=y
+
+#
+# I2C Algorithms
+#
+# CONFIG_I2C_ALGOBIT is not set
+# CONFIG_I2C_ALGOPCF is not set
+# CONFIG_I2C_ALGOPCA is not set
+
+#
+# I2C Hardware Bus support
+#
+CONFIG_I2C_AT91=y
+# CONFIG_I2C_OCORES is not set
+# CONFIG_I2C_PARPORT_LIGHT is not set
+# CONFIG_I2C_STUB is not set
+# CONFIG_I2C_PCA is not set
+# CONFIG_I2C_PCA_ISA is not set
+
+#
+# Miscellaneous I2C Chip support
+#
+# CONFIG_SENSORS_DS1337 is not set
+# CONFIG_SENSORS_DS1374 is not set
+# CONFIG_SENSORS_EEPROM is not set
+# CONFIG_SENSORS_PCF8574 is not set
+# CONFIG_SENSORS_PCA9539 is not set
+# CONFIG_SENSORS_PCF8591 is not set
+# CONFIG_SENSORS_MAX6875 is not set
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Hardware Monitoring support
+#
+# CONFIG_HWMON is not set
+# CONFIG_HWMON_VID is not set
+
+#
+# Misc devices
+#
+# CONFIG_TIFM_CORE is not set
+
+#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+# CONFIG_USB_DABUSB is not set
+
+#
+# Graphics support
+#
+# CONFIG_FIRMWARE_EDID is not set
+# CONFIG_FB is not set
+
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+CONFIG_USB=y
+# CONFIG_USB_DEBUG is not set
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_BANDWIDTH is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_OTG is not set
+
+#
+# USB Host Controller Drivers
+#
+# CONFIG_USB_ISP116X_HCD is not set
+CONFIG_USB_OHCI_HCD=y
+# CONFIG_USB_OHCI_BIG_ENDIAN is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+# CONFIG_USB_SL811_HCD is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# may also be needed; see USB_STORAGE Help for more information
+#
+CONFIG_USB_STORAGE=y
+CONFIG_USB_STORAGE_DEBUG=y
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_USBAT is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_STORAGE_SDDR55 is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_ALAUDA is not set
+# CONFIG_USB_STORAGE_KARMA is not set
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Input Devices
+#
+# CONFIG_USB_HID is not set
+
+#
+# USB HID Boot Protocol drivers
+#
+# CONFIG_USB_KBD is not set
+# CONFIG_USB_MOUSE is not set
+# CONFIG_USB_AIPTEK is not set
+# CONFIG_USB_WACOM is not set
+# CONFIG_USB_ACECAD is not set
+# CONFIG_USB_KBTAB is not set
+# CONFIG_USB_POWERMATE is not set
+# CONFIG_USB_TOUCHSCREEN is not set
+# CONFIG_USB_YEALINK is not set
+# CONFIG_USB_XPAD is not set
+# CONFIG_USB_ATI_REMOTE is not set
+# CONFIG_USB_ATI_REMOTE2 is not set
+# CONFIG_USB_KEYSPAN_REMOTE is not set
+# CONFIG_USB_APPLETOUCH is not set
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_MICROTEK is not set
+
+#
+# USB Network Adapters
+#
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_RTL8150 is not set
+# CONFIG_USB_USBNET_MII is not set
+# CONFIG_USB_USBNET is not set
+CONFIG_USB_MON=y
+
+#
+# USB port drivers
+#
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+
+#
+# USB Miscellaneous drivers
+#
+# CONFIG_USB_EMI62 is not set
+# CONFIG_USB_EMI26 is not set
+# CONFIG_USB_ADUTUX is not set
+# CONFIG_USB_AUERSWALD is not set
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_LEGOTOWER is not set
+# CONFIG_USB_LCD is not set
+# CONFIG_USB_LED is not set
+# CONFIG_USB_CYPRESS_CY7C63 is not set
+# CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_PHIDGET is not set
+# CONFIG_USB_IDMOUSE is not set
+# CONFIG_USB_FTDI_ELAN is not set
+# CONFIG_USB_APPLEDISPLAY is not set
+# CONFIG_USB_LD is not set
+# CONFIG_USB_TRANCEVIBRATOR is not set
+# CONFIG_USB_TEST is not set
+
+#
+# USB DSL modem support
+#
+
+#
+# USB Gadget Support
+#
+CONFIG_USB_GADGET=y
+# CONFIG_USB_GADGET_DEBUG_FILES is not set
+CONFIG_USB_GADGET_SELECTED=y
+# CONFIG_USB_GADGET_NET2280 is not set
+# CONFIG_USB_GADGET_PXA2XX is not set
+# CONFIG_USB_GADGET_GOKU is not set
+# CONFIG_USB_GADGET_LH7A40X is not set
+# CONFIG_USB_GADGET_OMAP is not set
+CONFIG_USB_GADGET_AT91=y
+CONFIG_USB_AT91=y
+# CONFIG_USB_GADGET_DUMMY_HCD is not set
+# CONFIG_USB_GADGET_DUALSPEED is not set
+CONFIG_USB_ZERO=m
+# CONFIG_USB_ETH is not set
+CONFIG_USB_GADGETFS=m
+CONFIG_USB_FILE_STORAGE=m
+# CONFIG_USB_FILE_STORAGE_TEST is not set
+CONFIG_USB_G_SERIAL=m
+# CONFIG_USB_MIDI_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+CONFIG_MMC=y
+# CONFIG_MMC_DEBUG is not set
+CONFIG_MMC_BLOCK=y
+CONFIG_MMC_AT91=m
+# CONFIG_MMC_TIFM_SD is not set
+
+#
+# Real Time Clock
+#
+CONFIG_RTC_LIB=y
+# CONFIG_RTC_CLASS is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_EXT4DEV_FS is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+# CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+# CONFIG_MSDOS_FS is not set
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_POSIX_ACL is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+# CONFIG_CONFIGFS_FS is not set
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
+CONFIG_CRAMFS=y
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+# CONFIG_NFS_FS is not set
+# CONFIG_NFSD is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+CONFIG_NLS_CODEPAGE_850=y
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ISO8859_1=y
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_MUST_CHECK=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+CONFIG_DEBUG_KERNEL=y
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_DETECT_SOFTLOCKUP=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_RWSEMS is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_DEBUG_FS is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_LIST is not set
+CONFIG_FRAME_POINTER=y
+CONFIG_FORCED_INLINING=y
+# CONFIG_HEADERS_CHECK is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+CONFIG_DEBUG_USER=y
+# CONFIG_DEBUG_WAITQ is not set
+# CONFIG_DEBUG_ERRORS is not set
+CONFIG_DEBUG_LL=y
+# CONFIG_DEBUG_ICEDCC is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+# CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_PLIST=y
index cfe6bd8e81cdbccc14873a221f2ecb81b3aa5cfa..821865f7560515bc2d5b0a91f0410bcb71351234 100644 (file)
@@ -1216,7 +1216,6 @@ CONFIG_DEBUG_INFO=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index d24ae8777c35d2b4d20bc77b1d012a71cc662ca2..d392833b31fbb40bf30f481218854a5244eb77a5 100644 (file)
@@ -474,7 +474,7 @@ CONFIG_LEGACY_PTY_COUNT=256
 # CONFIG_WATCHDOG is not set
 # CONFIG_NVRAM is not set
 # CONFIG_RTC is not set
-# CONFIG_AT91_RTC is not set
+# CONFIG_AT91RM9200_RTC is not set
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 
index 09b7acd7f6479de538724b96e1ed4065d71b3025..ee130b528bd4ef748af6364ba4887b5e7a19d47f 100644 (file)
@@ -851,7 +851,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index a3758913c0bb10e09f275301357be685ae055b49..970c8c772eb71a31d046f3316bd388b3f1cf0336 100644 (file)
@@ -934,7 +934,6 @@ CONFIG_FRAME_POINTER=y
 CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 # CONFIG_DEBUG_USER is not set
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 # CONFIG_DEBUG_LL is not set
 
index c41c04fa502096f6cdb02cf178d753c05cc1ff2e..e8980a9bb893f50e94889e1237e842547a7bc9a5 100644 (file)
@@ -1513,7 +1513,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 CONFIG_FRAME_POINTER=y
 # CONFIG_RCU_TORTURE_TEST is not set
 # CONFIG_DEBUG_USER is not set
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index 20e68250d835196252e65d142e1b9f2e302450b8..2cadd51506bb574c747e9935d8fbb86e67bdaa19 100644 (file)
@@ -1113,7 +1113,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 CONFIG_FRAME_POINTER=y
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 # CONFIG_DEBUG_ERRORS is not set
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index df8595ac031f15cb6a72406e965acd1f80f51eca..94908c1df4cf36c05673376db78048b6ecb1667f 100644 (file)
@@ -623,7 +623,7 @@ CONFIG_AT91RM9200_WATCHDOG=y
 # CONFIG_USBPCWATCHDOG is not set
 # CONFIG_NVRAM is not set
 CONFIG_RTC=y
-# CONFIG_AT91_RTC is not set
+# CONFIG_AT91RM9200_RTC is not set
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 
@@ -1062,7 +1062,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 CONFIG_FRAME_POINTER=y
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 # CONFIG_DEBUG_ERRORS is not set
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index 3b4802a849e444590175933b77fb73d5061cd724..f8a66b72ad5df9ffcbcf2eb994dfb4d6df11fc20 100644 (file)
@@ -125,6 +125,7 @@ CONFIG_CRUNCH=y
 #
 # EP93xx Platforms
 #
+CONFIG_MACH_ADSSPHERE=y
 CONFIG_MACH_EDB9302=y
 CONFIG_MACH_EDB9312=y
 CONFIG_MACH_EDB9315=y
@@ -1134,7 +1135,6 @@ CONFIG_FRAME_POINTER=y
 CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_DEBUG_USER=y
-CONFIG_DEBUG_WAITQ=y
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index 9d62ed16bf57b016da6861bee0aa5d68d243c240..0e739af527135c49e87a13116fa3ae3edb96a684 100644 (file)
@@ -702,7 +702,6 @@ CONFIG_DEBUG_INFO=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 # CONFIG_DEBUG_ERRORS is not set
 # CONFIG_DEBUG_LL is not set
 
index a45b57582b86e1809408ac7d3fa46296246533e9..1c8fb89a6730c55387cdafc169b0afb72e29dc62 100644 (file)
@@ -740,7 +740,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 CONFIG_DEBUG_USER=y
-CONFIG_DEBUG_WAITQ=y
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index 692ab57ba1ca9b484e39d1e8c944d6e90f70c45e..3ce96e60b4094417eb4e807b601d61cd6ad8c9c9 100644 (file)
@@ -835,7 +835,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 # CONFIG_DEBUG_USER is not set
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 # CONFIG_DEBUG_LL is not set
 
diff --git a/arch/arm/configs/iop13xx_defconfig b/arch/arm/configs/iop13xx_defconfig
new file mode 100644 (file)
index 0000000..f6e4619
--- /dev/null
@@ -0,0 +1,1134 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.19
+# Fri Dec  1 10:51:01 2006
+#
+CONFIG_ARM=y
+# CONFIG_GENERIC_TIME is not set
+CONFIG_MMU=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_HARDIRQS_SW_RESEND=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_VECTORS_BASE=0xffff0000
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+# CONFIG_IPC_NS is not set
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+# CONFIG_TASKSTATS is not set
+# CONFIG_UTS_NS is not set
+# CONFIG_AUDIT is not set
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+# CONFIG_RELAY is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
+# CONFIG_EMBEDDED is not set
+CONFIG_UID16=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SHMEM=y
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_RT_MUTEXES=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_MODVERSIONS=y
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Block layer
+#
+CONFIG_BLOCK=y
+# CONFIG_BLK_DEV_IO_TRACE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+# CONFIG_IOSCHED_CFQ is not set
+# CONFIG_DEFAULT_AS is not set
+CONFIG_DEFAULT_DEADLINE=y
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="deadline"
+
+#
+# System Type
+#
+# CONFIG_ARCH_AAEC2000 is not set
+# CONFIG_ARCH_INTEGRATOR is not set
+# CONFIG_ARCH_REALVIEW is not set
+# CONFIG_ARCH_VERSATILE is not set
+# CONFIG_ARCH_AT91 is not set
+# CONFIG_ARCH_CLPS7500 is not set
+# CONFIG_ARCH_CLPS711X is not set
+# CONFIG_ARCH_CO285 is not set
+# CONFIG_ARCH_EBSA110 is not set
+# CONFIG_ARCH_EP93XX is not set
+# CONFIG_ARCH_FOOTBRIDGE is not set
+# CONFIG_ARCH_NETX is not set
+# CONFIG_ARCH_H720X is not set
+# CONFIG_ARCH_IMX is not set
+# CONFIG_ARCH_IOP32X is not set
+# CONFIG_ARCH_IOP33X is not set
+CONFIG_ARCH_IOP13XX=y
+# CONFIG_ARCH_IXP4XX is not set
+# CONFIG_ARCH_IXP2000 is not set
+# CONFIG_ARCH_IXP23XX is not set
+# CONFIG_ARCH_L7200 is not set
+# CONFIG_ARCH_PNX4008 is not set
+# CONFIG_ARCH_PXA is not set
+# CONFIG_ARCH_RPC is not set
+# CONFIG_ARCH_SA1100 is not set
+# CONFIG_ARCH_S3C2410 is not set
+# CONFIG_ARCH_SHARK is not set
+# CONFIG_ARCH_LH7A40X is not set
+# CONFIG_ARCH_OMAP is not set
+
+#
+# IOP13XX Implementation Options
+#
+
+#
+# IOP13XX Platform Support
+#
+CONFIG_MACH_IQ81340SC=y
+CONFIG_MACH_IQ81340MC=y
+
+#
+# Processor Type
+#
+CONFIG_CPU_32=y
+CONFIG_CPU_XSC3=y
+CONFIG_CPU_32v5=y
+CONFIG_CPU_ABRT_EV5T=y
+CONFIG_CPU_CACHE_VIVT=y
+CONFIG_CPU_TLB_V4WBI=y
+CONFIG_CPU_CP15=y
+CONFIG_CPU_CP15_MMU=y
+CONFIG_IO_36=y
+
+#
+# Processor Features
+#
+CONFIG_ARM_THUMB=y
+# CONFIG_CPU_DCACHE_DISABLE is not set
+# CONFIG_CPU_BPREDICT_DISABLE is not set
+
+#
+# Bus support
+#
+CONFIG_PCI=y
+
+#
+# PCCARD (PCMCIA/CardBus) support
+#
+# CONFIG_PCCARD is not set
+
+#
+# Kernel Features
+#
+# CONFIG_PREEMPT is not set
+# CONFIG_NO_IDLE_HZ is not set
+CONFIG_HZ=100
+# CONFIG_AEABI is not set
+# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4096
+# CONFIG_RESOURCES_64BIT is not set
+CONFIG_ALIGNMENT_TRAP=y
+
+#
+# Boot options
+#
+CONFIG_ZBOOT_ROM_TEXT=0x0
+CONFIG_ZBOOT_ROM_BSS=0x0
+CONFIG_CMDLINE="ip=bootp root=nfs console=ttyS0,115200 nfsroot=,tcp,v3,wsize=8192,rsize=8192"
+# CONFIG_XIP_KERNEL is not set
+
+#
+# Floating point emulation
+#
+
+#
+# At least one emulation must be selected
+#
+CONFIG_FPE_NWFPE=y
+# CONFIG_FPE_NWFPE_XP is not set
+# CONFIG_FPE_FASTFPE is not set
+
+#
+# Userspace binary formats
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_AOUT=y
+# CONFIG_BINFMT_MISC is not set
+# CONFIG_ARTHUR is not set
+
+#
+# Power management options
+#
+# CONFIG_PM is not set
+# CONFIG_APM is not set
+
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+CONFIG_NET_KEY=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+# CONFIG_IP_PNP_DHCP is not set
+CONFIG_IP_PNP_BOOTP=y
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_IP_MROUTE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_IPV6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_FW_LOADER is not set
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_CONCAT is not set
+CONFIG_MTD_PARTITIONS=y
+CONFIG_MTD_REDBOOT_PARTS=y
+CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
+CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
+CONFIG_MTD_REDBOOT_PARTS_READONLY=y
+# CONFIG_MTD_CMDLINE_PARTS is not set
+# CONFIG_MTD_AFS_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+# CONFIG_MTD_CHAR is not set
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=y
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_GEN_PROBE=y
+CONFIG_MTD_CFI_ADV_OPTIONS=y
+CONFIG_MTD_CFI_NOSWAP=y
+# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
+# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
+# CONFIG_MTD_CFI_GEOMETRY is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_OTP is not set
+CONFIG_MTD_CFI_INTELEXT=y
+# CONFIG_MTD_CFI_AMDSTD is not set
+# CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=y
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+# CONFIG_MTD_OBSOLETE_CHIPS is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+CONFIG_MTD_PHYSMAP=y
+CONFIG_MTD_PHYSMAP_START=0xfa000000
+CONFIG_MTD_PHYSMAP_LEN=0x0
+CONFIG_MTD_PHYSMAP_BANKWIDTH=2
+# CONFIG_MTD_ARM_INTEGRATOR is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_PMC551 is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLOCK2MTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+
+#
+# NAND Flash Device Drivers
+#
+# CONFIG_MTD_NAND is not set
+
+#
+# OneNAND Flash Device Drivers
+#
+# CONFIG_MTD_ONENAND is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_UMEM is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
+# CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_SX8 is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=2
+CONFIG_BLK_DEV_RAM_SIZE=8192
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+CONFIG_SCSI=y
+# CONFIG_SCSI_NETLINK is not set
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+# CONFIG_BLK_DEV_SR is not set
+CONFIG_CHR_DEV_SG=y
+# CONFIG_CHR_DEV_SCH is not set
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+CONFIG_SCSI_CONSTANTS=y
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transports
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+CONFIG_SCSI_ISCSI_ATTRS=y
+CONFIG_SCSI_SAS_ATTRS=y
+# CONFIG_SCSI_SAS_LIBSAS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_ISCSI_TCP is not set
+# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
+# CONFIG_SCSI_3W_9XXX is not set
+# CONFIG_SCSI_ACARD 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_AIC94XX is not set
+# CONFIG_SCSI_DPT_I2O is not set
+# CONFIG_SCSI_ARCMSR is not set
+# CONFIG_MEGARAID_NEWGEN is not set
+# CONFIG_MEGARAID_LEGACY is not set
+# CONFIG_MEGARAID_SAS is not set
+# CONFIG_SCSI_HPTIOP is not set
+# CONFIG_SCSI_DMX3191D is not set
+# CONFIG_SCSI_FUTURE_DOMAIN is not set
+# CONFIG_SCSI_IPS is not set
+# CONFIG_SCSI_INITIO is not set
+# CONFIG_SCSI_INIA100 is not set
+# CONFIG_SCSI_STEX is not set
+# CONFIG_SCSI_SYM53C8XX_2 is not set
+# CONFIG_SCSI_QLOGIC_1280 is not set
+# CONFIG_SCSI_QLA_FC is not set
+# CONFIG_SCSI_QLA_ISCSI is not set
+# CONFIG_SCSI_LPFC is not set
+# CONFIG_SCSI_DC395x is not set
+# CONFIG_SCSI_DC390T is not set
+# CONFIG_SCSI_NSP32 is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# Serial ATA (prod) and Parallel ATA (experimental) drivers
+#
+# CONFIG_ATA is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=y
+# CONFIG_MD_LINEAR is not set
+CONFIG_MD_RAID0=y
+CONFIG_MD_RAID1=y
+CONFIG_MD_RAID10=y
+CONFIG_MD_RAID456=y
+# CONFIG_MD_RAID5_RESHAPE is not set
+# CONFIG_MD_MULTIPATH is not set
+# CONFIG_MD_FAULTY is not set
+CONFIG_BLK_DEV_DM=y
+# CONFIG_DM_DEBUG is not set
+# CONFIG_DM_CRYPT is not set
+# CONFIG_DM_SNAPSHOT is not set
+# CONFIG_DM_MIRROR is not set
+# CONFIG_DM_ZERO is not set
+# CONFIG_DM_MULTIPATH is not set
+
+#
+# Fusion MPT device support
+#
+# CONFIG_FUSION is not set
+# CONFIG_FUSION_SPI is not set
+# CONFIG_FUSION_FC is not set
+# CONFIG_FUSION_SAS is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+# CONFIG_IEEE1394 is not set
+
+#
+# I2O device support
+#
+# CONFIG_I2O is not set
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+
+#
+# PHY device support
+#
+
+#
+# Ethernet (10 or 100Mbit)
+#
+# CONFIG_NET_ETHERNET is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+CONFIG_E1000=y
+CONFIG_E1000_NAPI=y
+# CONFIG_E1000_DISABLE_PACKET_SPLIT is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_R8169 is not set
+# CONFIG_SIS190 is not set
+# CONFIG_SKGE is not set
+# CONFIG_SKY2 is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_TIGON3 is not set
+# CONFIG_BNX2 is not set
+# CONFIG_QLA3XXX is not set
+
+#
+# Ethernet (10000 Mbit)
+#
+# CONFIG_CHELSIO_T1 is not set
+# CONFIG_IXGB is not set
+# CONFIG_S2IO is not set
+# CONFIG_MYRI10GE is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_NET_FC is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+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_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_PCI=y
+CONFIG_SERIAL_8250_NR_UARTS=2
+CONFIG_SERIAL_8250_RUNTIME_UARTS=2
+# CONFIG_SERIAL_8250_EXTENDED is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_SERIAL_JSM is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+CONFIG_HW_RANDOM=y
+# CONFIG_NVRAM is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# TPM devices
+#
+# CONFIG_TCG_TPM is not set
+
+#
+# I2C support
+#
+CONFIG_I2C=y
+# CONFIG_I2C_CHARDEV is not set
+
+#
+# I2C Algorithms
+#
+CONFIG_I2C_ALGOBIT=m
+CONFIG_I2C_ALGOPCF=m
+CONFIG_I2C_ALGOPCA=m
+
+#
+# I2C Hardware Bus support
+#
+# CONFIG_I2C_ALI1535 is not set
+# CONFIG_I2C_ALI1563 is not set
+# CONFIG_I2C_ALI15X3 is not set
+# CONFIG_I2C_AMD756 is not set
+# CONFIG_I2C_AMD8111 is not set
+# CONFIG_I2C_I801 is not set
+# CONFIG_I2C_I810 is not set
+# CONFIG_I2C_PIIX4 is not set
+CONFIG_I2C_IOP3XX=y
+# CONFIG_I2C_NFORCE2 is not set
+# CONFIG_I2C_OCORES is not set
+# CONFIG_I2C_PARPORT_LIGHT is not set
+# CONFIG_I2C_PROSAVAGE is not set
+# CONFIG_I2C_SAVAGE4 is not set
+# CONFIG_I2C_SIS5595 is not set
+# CONFIG_I2C_SIS630 is not set
+# CONFIG_I2C_SIS96X is not set
+# CONFIG_I2C_STUB is not set
+# CONFIG_I2C_VIA is not set
+# CONFIG_I2C_VIAPRO is not set
+# CONFIG_I2C_VOODOO3 is not set
+# CONFIG_I2C_PCA_ISA is not set
+
+#
+# Miscellaneous I2C Chip support
+#
+# CONFIG_SENSORS_DS1337 is not set
+# CONFIG_SENSORS_DS1374 is not set
+# CONFIG_SENSORS_EEPROM is not set
+# CONFIG_SENSORS_PCF8574 is not set
+# CONFIG_SENSORS_PCA9539 is not set
+# CONFIG_SENSORS_PCF8591 is not set
+# CONFIG_SENSORS_MAX6875 is not set
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Hardware Monitoring support
+#
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
+# CONFIG_SENSORS_ABITUGURU is not set
+# CONFIG_SENSORS_ADM1021 is not set
+# CONFIG_SENSORS_ADM1025 is not set
+# CONFIG_SENSORS_ADM1026 is not set
+# CONFIG_SENSORS_ADM1031 is not set
+# CONFIG_SENSORS_ADM9240 is not set
+# CONFIG_SENSORS_ASB100 is not set
+# CONFIG_SENSORS_ATXP1 is not set
+# CONFIG_SENSORS_DS1621 is not set
+# CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_FSCHER is not set
+# CONFIG_SENSORS_FSCPOS is not set
+# CONFIG_SENSORS_GL518SM is not set
+# CONFIG_SENSORS_GL520SM is not set
+# CONFIG_SENSORS_IT87 is not set
+# CONFIG_SENSORS_LM63 is not set
+# CONFIG_SENSORS_LM75 is not set
+# CONFIG_SENSORS_LM77 is not set
+# CONFIG_SENSORS_LM78 is not set
+# CONFIG_SENSORS_LM80 is not set
+# CONFIG_SENSORS_LM83 is not set
+# CONFIG_SENSORS_LM85 is not set
+# CONFIG_SENSORS_LM87 is not set
+# CONFIG_SENSORS_LM90 is not set
+# CONFIG_SENSORS_LM92 is not set
+# CONFIG_SENSORS_MAX1619 is not set
+# CONFIG_SENSORS_PC87360 is not set
+# CONFIG_SENSORS_SIS5595 is not set
+# CONFIG_SENSORS_SMSC47M1 is not set
+# CONFIG_SENSORS_SMSC47M192 is not set
+# CONFIG_SENSORS_SMSC47B397 is not set
+# CONFIG_SENSORS_VIA686A is not set
+# CONFIG_SENSORS_VT1211 is not set
+# CONFIG_SENSORS_VT8231 is not set
+# CONFIG_SENSORS_W83781D is not set
+# CONFIG_SENSORS_W83791D is not set
+# CONFIG_SENSORS_W83792D is not set
+# CONFIG_SENSORS_W83L785TS is not set
+# CONFIG_SENSORS_W83627HF is not set
+# CONFIG_SENSORS_W83627EHF is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
+
+#
+# Misc devices
+#
+# CONFIG_SGI_IOC4 is not set
+# CONFIG_TIFM_CORE is not set
+
+#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+CONFIG_FIRMWARE_EDID=y
+# CONFIG_FB is not set
+
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+CONFIG_USB_ARCH_HAS_EHCI=y
+# CONFIG_USB is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
+# Real Time Clock
+#
+CONFIG_RTC_LIB=y
+# CONFIG_RTC_CLASS is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_FS_XATTR=y
+# CONFIG_EXT3_FS_POSIX_ACL is not set
+# CONFIG_EXT3_FS_SECURITY is not set
+# CONFIG_EXT4DEV_FS is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_FS_MBCACHE=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+# CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_POSIX_ACL is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+# CONFIG_CONFIGFS_FS is not set
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+CONFIG_JFFS2_FS=y
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_SUMMARY is not set
+# CONFIG_JFFS2_FS_XATTR is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN 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_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
+# CONFIG_NFS_V4 is not set
+# CONFIG_NFS_DIRECTIO is not set
+CONFIG_NFSD=y
+CONFIG_NFSD_V3=y
+# CONFIG_NFSD_V3_ACL is not set
+# CONFIG_NFSD_V4 is not set
+CONFIG_NFSD_TCP=y
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=y
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+# CONFIG_SMB_NLS_DEFAULT is not set
+CONFIG_CIFS=m
+# CONFIG_CIFS_STATS is not set
+# CONFIG_CIFS_WEAK_PW_HASH is not set
+# CONFIG_CIFS_XATTR is not set
+# CONFIG_CIFS_DEBUG2 is not set
+# CONFIG_CIFS_EXPERIMENTAL is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+# CONFIG_OSF_PARTITION is not set
+# CONFIG_AMIGA_PARTITION is not set
+# CONFIG_ATARI_PARTITION is not set
+# CONFIG_MAC_PARTITION is not set
+CONFIG_MSDOS_PARTITION=y
+# CONFIG_BSD_DISKLABEL is not set
+# CONFIG_MINIX_SUBPARTITION is not set
+# CONFIG_SOLARIS_X86_PARTITION is not set
+# CONFIG_UNIXWARE_DISKLABEL is not set
+# CONFIG_LDM_PARTITION is not set
+# CONFIG_SGI_PARTITION is not set
+# CONFIG_ULTRIX_PARTITION is not set
+# CONFIG_SUN_PARTITION is not set
+# CONFIG_KARMA_PARTITION is not set
+# CONFIG_EFI_PARTITION is not set
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+# CONFIG_NLS_CODEPAGE_437 is not set
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+# CONFIG_NLS_ISO8859_1 is not set
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_MUST_CHECK=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+# CONFIG_DEBUG_KERNEL is not set
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_FS is not set
+CONFIG_FRAME_POINTER=y
+# CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_USER=y
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=y
+# CONFIG_CRC16 is not set
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=y
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_PLIST=y
index 0d67f66e78c259f224979191d90b21e256f1a66f..b275c53728ec2fd66dd4579851d7a9d306a140b7 100644 (file)
@@ -1204,7 +1204,6 @@ CONFIG_FRAME_POINTER=y
 # CONFIG_FORCED_INLINING is not set
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 # CONFIG_DEBUG_ERRORS is not set
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index 2a8fc153969d87e745c1ae8a432d34c1ef4d2801..848e3ace906965ed214a11eabcad3e0cde55ed1d 100644 (file)
@@ -1051,7 +1051,6 @@ CONFIG_FRAME_POINTER=y
 # CONFIG_FORCED_INLINING is not set
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 # CONFIG_DEBUG_ERRORS is not set
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index 27b3e31a8ad896a9d26a3649522e3a7ef7c98b98..bbd2dcf91e521d4179f3ed68644177188c5911e1 100644 (file)
@@ -1026,7 +1026,6 @@ CONFIG_FRAME_POINTER=y
 CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index 7b18997083cef1aa517d7065bdcdeed4a23fd2bc..06deefaec1d280c0343b3cb4a720ed12bf719362 100644 (file)
@@ -1305,7 +1305,6 @@ CONFIG_FRAME_POINTER=y
 CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index fac7c3b240c0574b659fc791508dc6d0b866df4c..fabf74c51a88f27bbc44e580a961ba4bab6e2f2a 100644 (file)
@@ -1243,7 +1243,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 CONFIG_FRAME_POINTER=y
 # CONFIG_RCU_TORTURE_TEST is not set
 # CONFIG_DEBUG_USER is not set
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index 80a6fd97eb32a8e352674e5731e741d6f12d1763..0c556289a3f4e6318f262e9f7e16d69f51728b99 100644 (file)
@@ -889,7 +889,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 # CONFIG_DEBUG_USER is not set
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index b4cd4b4148367887579d65b0b072b70365bdfdfa..c16537d9d67a9102818e9ef3fdc4041812520680 100644 (file)
@@ -437,7 +437,7 @@ CONFIG_LEGACY_PTY_COUNT=256
 # CONFIG_WATCHDOG is not set
 # CONFIG_NVRAM is not set
 # CONFIG_RTC is not set
-# CONFIG_AT91_RTC is not set
+# CONFIG_AT91RM9200_RTC is not set
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 
@@ -753,7 +753,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index 4b29e099640d4b05f8cb5bd364d69c25a5166387..e146189ab54f17925ec128c2bac27878c88188bf 100644 (file)
@@ -949,7 +949,6 @@ CONFIG_FRAME_POINTER=y
 CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index bf9cf9c6d2dfb7770e0ac2b35fee5e3a87e1b8f2..f8ac29d5c654221d336233f77fe9c6ec9368a266 100644 (file)
@@ -850,7 +850,6 @@ CONFIG_DEBUG_INFO=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 # CONFIG_DEBUG_LL is not set
 
index 3a57be32e849d1ec89f29131c8e25d5f1c6d78be..46a0f7fe1fa51823eda6d4b25f2bdca451099203 100644 (file)
@@ -1100,7 +1100,6 @@ CONFIG_FRAME_POINTER=y
 CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 # CONFIG_DEBUG_LL is not set
 
index 81daadcbe0ba3f4f202fd8cd8d520302cba71ec6..e544bfbbde5d4d55ae2e04529d876754ca1f9e0e 100644 (file)
@@ -772,7 +772,6 @@ CONFIG_DEBUG_INFO=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index b112bd75bda2f5a302785302c8d0091e3413a32f..cc8c95b992923d4211b19d2cc0158fd57e847965 100644 (file)
@@ -766,7 +766,6 @@ CONFIG_DEBUG_INFO=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index d16f6cd6e0390affdc5b865463fa691d89b3591f..577d7e1b5d42c5955e07d95cf084a91c92e48f8a 100644 (file)
@@ -691,7 +691,6 @@ CONFIG_DEBUG_INFO=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 # CONFIG_DEBUG_LL is not set
 
index df8168e57b7c2d5dfb83aab793014195028a2a34..e86794a10fc060c831e3c50080d3c36781b70b6c 100644 (file)
@@ -1115,7 +1115,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index 2cae1ead9f9bdccc0b8e739583587210a76e0e67..c1a63a35c58d6df59d0499df7d01b8dc739ca297 100644 (file)
@@ -994,7 +994,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 # CONFIG_DEBUG_ERRORS is not set
 # CONFIG_DEBUG_LL is not set
 
index 61115a7733829dfa19bbd267cce323d5639fda9f..57f32f39d0ff6af2de160fd9cdc897f85af516fa 100644 (file)
@@ -872,7 +872,6 @@ CONFIG_FRAME_POINTER=y
 CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 # CONFIG_DEBUG_USER is not set
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 # CONFIG_DEBUG_LL is not set
 
index 9b9f2155af35fedcd8999102a3eab37ca4c59d46..0498ebd7d5de8bb59506c4b7c09c7b7c423342d4 100644 (file)
@@ -1045,7 +1045,6 @@ CONFIG_FRAME_POINTER=y
 CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 # CONFIG_DEBUG_ERRORS is not set
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index 24e8bdd4cb91c1e67d6c88fc030bdb294542e482..a6b47ea8e4655290b0798dd652a8b6439a1f7468 100644 (file)
@@ -721,7 +721,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 # CONFIG_DEBUG_USER is not set
-# CONFIG_DEBUG_WAITQ is not set
 # CONFIG_DEBUG_ERRORS is not set
 # CONFIG_DEBUG_LL is not set
 
index a4989f44baaab70721ae3144416b5a7a09725999..b5e11aa2e290f4f94c33b3e2c5fe0e5cd9ee381f 100644 (file)
@@ -1604,7 +1604,6 @@ CONFIG_FRAME_POINTER=y
 CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 # CONFIG_DEBUG_USER is not set
-# CONFIG_DEBUG_WAITQ is not set
 # CONFIG_DEBUG_ERRORS is not set
 # CONFIG_DEBUG_LL is not set
 
index b71d31a4bb56632eb379e53f1abdc70eeaae5acd..46e5089df0aea9b79e9a792c74adc5e772b1bcf4 100644 (file)
@@ -768,7 +768,6 @@ CONFIG_DEBUG_INFO=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index ffd905ff19f13d360ab0c20c9c242d17fbfc6a63..fc39ba1a89f316cd222b61d36794340a334bc92f 100644 (file)
@@ -967,7 +967,6 @@ CONFIG_FORCED_INLINING=y
 # CONFIG_HEADERS_CHECK is not set
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index 3f1ec4e304f7f532209298db418867a72e81f40d..accbf529ce5bdba509700fe787917f0a8b231b36 100644 (file)
@@ -759,7 +759,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 # CONFIG_DEBUG_LL is not set
 
index b498afdc03b6b19ca98aecc119bbca7ec4c4b76c..bc091264d354e0d80144410a5010e9b9f74f3caa 100644 (file)
@@ -910,7 +910,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index c0152393e494ec7551e5af61a8ba7638b925576a..3b31a33d0080eab75165a7f1166a02ab2da00bd1 100644 (file)
@@ -1319,7 +1319,6 @@ CONFIG_FORCED_INLINING=y
 # CONFIG_HEADERS_CHECK is not set
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 # CONFIG_DEBUG_ERRORS is not set
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index c48d17062262e0c5d4b49cd17e75352cfcb9ec82..9b6561d119afabd00a8074e70c59ebacb52234e6 100644 (file)
@@ -965,7 +965,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 # CONFIG_DEBUG_ERRORS is not set
 # CONFIG_DEBUG_LL is not set
 
index 140056a3507f96fdea4652d898951d558cdd624f..03f783e696b3a028d9b57acc5e3a31c991ffca44 100644 (file)
@@ -934,7 +934,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_FS is not set
 CONFIG_FRAME_POINTER=y
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index bd03238968c15b10ebf00dd596765dc01ffc1a94..aa7a011795006fad2a2d624453d38595f933ec12 100644 (file)
@@ -1406,7 +1406,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
 CONFIG_FRAME_POINTER=y
 # CONFIG_RCU_TORTURE_TEST is not set
 # CONFIG_DEBUG_USER is not set
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index f7bf6ef27d19158ac4444aa19c70c784b7782deb..48dca69addae8608fc2aea9c40d62f441351f2d3 100644 (file)
@@ -972,7 +972,6 @@ CONFIG_FRAME_POINTER=y
 CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
index 1320a0efca738eea92013b0d9461913d758205c7..ab06a86e85d58c71e17fb223e8e8ef4b45e22587 100644 (file)
@@ -24,7 +24,9 @@ obj-$(CONFIG_OABI_COMPAT)     += sys_oabi-compat.o
 obj-$(CONFIG_CRUNCH)           += crunch.o crunch-bits.o
 AFLAGS_crunch-bits.o           := -Wa,-mcpu=ep9312
 
-obj-$(CONFIG_IWMMXT)           += iwmmxt.o iwmmxt-notifier.o
+obj-$(CONFIG_CPU_XSCALE)       += xscale-cp0.o
+obj-$(CONFIG_CPU_XSC3)         += xscale-cp0.o
+obj-$(CONFIG_IWMMXT)           += iwmmxt.o
 AFLAGS_iwmmxt.o                        := -Wa,-mcpu=iwmmxt
 
 ifneq ($(CONFIG_ARCH_EBSA110),y)
index ecf4f9472d94e950781e7bfdea05fd446bd40ade..a11fb9a40c04f0c16e9d46e1e2d17cfbe934b91c 100644 (file)
@@ -12,7 +12,6 @@
  */
 #include <linux/module.h>
 #include <linux/poll.h>
-#include <linux/timer.h>
 #include <linux/slab.h>
 #include <linux/proc_fs.h>
 #include <linux/miscdevice.h>
@@ -26,6 +25,7 @@
 #include <linux/init.h>
 #include <linux/completion.h>
 #include <linux/kthread.h>
+#include <linux/delay.h>
 
 #include <asm/apm.h> /* apm_power_info */
 #include <asm/system.h>
@@ -71,7 +71,8 @@ struct apm_user {
 #define SUSPEND_PENDING        1               /* suspend pending read */
 #define SUSPEND_READ   2               /* suspend read, pending ack */
 #define SUSPEND_ACKED  3               /* suspend acked */
-#define SUSPEND_DONE   4               /* suspend completed */
+#define SUSPEND_WAIT   4               /* waiting for suspend */
+#define SUSPEND_DONE   5               /* suspend completed */
 
        struct apm_queue        queue;
 };
@@ -101,6 +102,7 @@ static DECLARE_WAIT_QUEUE_HEAD(kapmd_wait);
 static DEFINE_SPINLOCK(kapmd_queue_lock);
 static struct apm_queue kapmd_queue;
 
+static DEFINE_MUTEX(state_lock);
 
 static const char driver_version[] = "1.13";   /* no spaces */
 
@@ -148,38 +150,60 @@ static void queue_add_event(struct apm_queue *q, apm_event_t event)
        q->events[q->event_head] = event;
 }
 
-static void queue_event_one_user(struct apm_user *as, apm_event_t event)
+static void queue_event(apm_event_t event)
 {
-       if (as->suser && as->writer) {
-               switch (event) {
-               case APM_SYS_SUSPEND:
-               case APM_USER_SUSPEND:
-                       /*
-                        * If this user already has a suspend pending,
-                        * don't queue another one.
-                        */
-                       if (as->suspend_state != SUSPEND_NONE)
-                               return;
+       struct apm_user *as;
 
-                       as->suspend_state = SUSPEND_PENDING;
-                       suspends_pending++;
-                       break;
-               }
+       down_read(&user_list_lock);
+       list_for_each_entry(as, &apm_user_list, list) {
+               if (as->reader)
+                       queue_add_event(&as->queue, event);
        }
-       queue_add_event(&as->queue, event);
+       up_read(&user_list_lock);
+       wake_up_interruptible(&apm_waitqueue);
 }
 
-static void queue_event(apm_event_t event, struct apm_user *sender)
+/*
+ * queue_suspend_event - queue an APM suspend event.
+ *
+ * Check that we're in a state where we can suspend.  If not,
+ * return -EBUSY.  Otherwise, queue an event to all "writer"
+ * users.  If there are no "writer" users, return '1' to
+ * indicate that we can immediately suspend.
+ */
+static int queue_suspend_event(apm_event_t event, struct apm_user *sender)
 {
        struct apm_user *as;
+       int ret = 1;
 
+       mutex_lock(&state_lock);
        down_read(&user_list_lock);
+
+       /*
+        * If a thread is still processing, we can't suspend, so reject
+        * the request.
+        */
        list_for_each_entry(as, &apm_user_list, list) {
-               if (as != sender && as->reader)
-                       queue_event_one_user(as, event);
+               if (as != sender && as->reader && as->writer && as->suser &&
+                   as->suspend_state != SUSPEND_NONE) {
+                       ret = -EBUSY;
+                       goto out;
+               }
        }
+
+       list_for_each_entry(as, &apm_user_list, list) {
+               if (as != sender && as->reader && as->writer && as->suser) {
+                       as->suspend_state = SUSPEND_PENDING;
+                       suspends_pending++;
+                       queue_add_event(&as->queue, event);
+                       ret = 0;
+               }
+       }
+ out:
        up_read(&user_list_lock);
+       mutex_unlock(&state_lock);
        wake_up_interruptible(&apm_waitqueue);
+       return ret;
 }
 
 static void apm_suspend(void)
@@ -191,17 +215,22 @@ static void apm_suspend(void)
         * Anyone on the APM queues will think we're still suspended.
         * Send a message so everyone knows we're now awake again.
         */
-       queue_event(APM_NORMAL_RESUME, NULL);
+       queue_event(APM_NORMAL_RESUME);
 
        /*
         * Finally, wake up anyone who is sleeping on the suspend.
         */
+       mutex_lock(&state_lock);
        down_read(&user_list_lock);
        list_for_each_entry(as, &apm_user_list, list) {
-               as->suspend_result = err;
-               as->suspend_state = SUSPEND_DONE;
+               if (as->suspend_state == SUSPEND_WAIT ||
+                   as->suspend_state == SUSPEND_ACKED) {
+                       as->suspend_result = err;
+                       as->suspend_state = SUSPEND_DONE;
+               }
        }
        up_read(&user_list_lock);
+       mutex_unlock(&state_lock);
 
        wake_up(&apm_suspend_waitqueue);
 }
@@ -227,8 +256,11 @@ static ssize_t apm_read(struct file *fp, char __user *buf, size_t count, loff_t
                if (copy_to_user(buf, &event, sizeof(event)))
                        break;
 
-               if (event == APM_SYS_SUSPEND || event == APM_USER_SUSPEND)
+               mutex_lock(&state_lock);
+               if (as->suspend_state == SUSPEND_PENDING &&
+                   (event == APM_SYS_SUSPEND || event == APM_USER_SUSPEND))
                        as->suspend_state = SUSPEND_READ;
+               mutex_unlock(&state_lock);
 
                buf += sizeof(event);
                i -= sizeof(event);
@@ -270,9 +302,13 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
 
        switch (cmd) {
        case APM_IOC_SUSPEND:
+               mutex_lock(&state_lock);
+
                as->suspend_result = -EINTR;
 
                if (as->suspend_state == SUSPEND_READ) {
+                       int pending;
+
                        /*
                         * If we read a suspend command from /dev/apm_bios,
                         * then the corresponding APM_IOC_SUSPEND ioctl is
@@ -280,47 +316,73 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
                         */
                        as->suspend_state = SUSPEND_ACKED;
                        suspends_pending--;
+                       pending = suspends_pending == 0;
+                       mutex_unlock(&state_lock);
+
+                       /*
+                        * If there are no further acknowledges required,
+                        * suspend the system.
+                        */
+                       if (pending)
+                               apm_suspend();
+
+                       /*
+                        * Wait for the suspend/resume to complete.  If there
+                        * are pending acknowledges, we wait here for them.
+                        *
+                        * Note: we need to ensure that the PM subsystem does
+                        * not kick us out of the wait when it suspends the
+                        * threads.
+                        */
+                       flags = current->flags;
+                       current->flags |= PF_NOFREEZE;
+
+                       wait_event(apm_suspend_waitqueue,
+                                  as->suspend_state == SUSPEND_DONE);
                } else {
+                       as->suspend_state = SUSPEND_WAIT;
+                       mutex_unlock(&state_lock);
+
                        /*
                         * Otherwise it is a request to suspend the system.
                         * Queue an event for all readers, and expect an
                         * acknowledge from all writers who haven't already
                         * acknowledged.
                         */
-                       queue_event(APM_USER_SUSPEND, as);
-               }
-
-               /*
-                * If there are no further acknowledges required, suspend
-                * the system.
-                */
-               if (suspends_pending == 0)
-                       apm_suspend();
+                       err = queue_suspend_event(APM_USER_SUSPEND, as);
+                       if (err < 0) {
+                               /*
+                                * Avoid taking the lock here - this
+                                * should be fine.
+                                */
+                               as->suspend_state = SUSPEND_NONE;
+                               break;
+                       }
+
+                       if (err > 0)
+                               apm_suspend();
 
-               /*
-                * Wait for the suspend/resume to complete.  If there are
-                * pending acknowledges, we wait here for them.
-                *
-                * Note that we need to ensure that the PM subsystem does
-                * not kick us out of the wait when it suspends the threads.
-                */
-               flags = current->flags;
-               current->flags |= PF_NOFREEZE;
+                       /*
+                        * Wait for the suspend/resume to complete.  If there
+                        * are pending acknowledges, we wait here for them.
+                        *
+                        * Note: we need to ensure that the PM subsystem does
+                        * not kick us out of the wait when it suspends the
+                        * threads.
+                        */
+                       flags = current->flags;
+                       current->flags |= PF_NOFREEZE;
 
-               /*
-                * Note: do not allow a thread which is acking the suspend
-                * to escape until the resume is complete.
-                */
-               if (as->suspend_state == SUSPEND_ACKED)
-                       wait_event(apm_suspend_waitqueue,
-                                        as->suspend_state == SUSPEND_DONE);
-               else
                        wait_event_interruptible(apm_suspend_waitqueue,
                                         as->suspend_state == SUSPEND_DONE);
+               }
 
                current->flags = flags;
+
+               mutex_lock(&state_lock);
                err = as->suspend_result;
                as->suspend_state = SUSPEND_NONE;
+               mutex_unlock(&state_lock);
                break;
        }
 
@@ -330,6 +392,8 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
 static int apm_release(struct inode * inode, struct file * filp)
 {
        struct apm_user *as = filp->private_data;
+       int pending = 0;
+
        filp->private_data = NULL;
 
        down_write(&user_list_lock);
@@ -342,11 +406,14 @@ static int apm_release(struct inode * inode, struct file * filp)
         * need to balance suspends_pending, which means the
         * possibility of sleeping.
         */
+       mutex_lock(&state_lock);
        if (as->suspend_state != SUSPEND_NONE) {
                suspends_pending -= 1;
-               if (suspends_pending == 0)
-                       apm_suspend();
+               pending = suspends_pending == 0;
        }
+       mutex_unlock(&state_lock);
+       if (pending)
+               apm_suspend();
 
        kfree(as);
        return 0;
@@ -470,6 +537,7 @@ static int kapmd(void *arg)
 {
        do {
                apm_event_t event;
+               int ret;
 
                wait_event_interruptible(kapmd_wait,
                                !queue_empty(&kapmd_queue) || kthread_should_stop());
@@ -489,13 +557,20 @@ static int kapmd(void *arg)
 
                case APM_LOW_BATTERY:
                case APM_POWER_STATUS_CHANGE:
-                       queue_event(event, NULL);
+                       queue_event(event);
                        break;
 
                case APM_USER_SUSPEND:
                case APM_SYS_SUSPEND:
-                       queue_event(event, NULL);
-                       if (suspends_pending == 0)
+                       ret = queue_suspend_event(event, NULL);
+                       if (ret < 0) {
+                               /*
+                                * We were busy.  Try again in 50ms.
+                                */
+                               queue_add_event(&kapmd_queue, event);
+                               msleep(50);
+                       }
+                       if (ret > 0)
                                apm_suspend();
                        break;
 
index cc2d58d028e17b10b1decb656315f71f27267cc9..3c078e3467537f8c9045e82674f93ef270836a74 100644 (file)
@@ -15,6 +15,7 @@
 #include <asm/mach/arch.h>
 #include <asm/thread_info.h>
 #include <asm/memory.h>
+#include <asm/procinfo.h>
 
 /*
  * Make sure that the compiler and target are compatible.
index b27513a0f11ee292502ce47152c21e10154e1de4..a786f769035d1a8c46197dae1124b40345dddb32 100644 (file)
@@ -529,7 +529,7 @@ static void ecard_dump_irq_state(void)
        }
 }
 
-static void ecard_check_lockup(struct irqdesc *desc)
+static void ecard_check_lockup(struct irq_desc *desc)
 {
        static unsigned long last;
        static int lockup;
@@ -567,7 +567,7 @@ static void ecard_check_lockup(struct irqdesc *desc)
 }
 
 static void
-ecard_irq_handler(unsigned int irq, struct irqdesc *desc)
+ecard_irq_handler(unsigned int irq, struct irq_desc *desc)
 {
        ecard_t *ec;
        int called = 0;
@@ -585,7 +585,7 @@ ecard_irq_handler(unsigned int irq, struct irqdesc *desc)
                        pending = ecard_default_ops.irqpending(ec);
 
                if (pending) {
-                       struct irqdesc *d = irq_desc + ec->irq;
+                       struct irq_desc *d = irq_desc + ec->irq;
                        desc_handle_irq(ec->irq, d);
                        called ++;
                }
@@ -609,7 +609,7 @@ static unsigned char first_set[] =
 };
 
 static void
-ecard_irqexp_handler(unsigned int irq, struct irqdesc *desc)
+ecard_irqexp_handler(unsigned int irq, struct irq_desc *desc)
 {
        const unsigned int statusmask = 15;
        unsigned int status;
@@ -1022,7 +1022,7 @@ ecard_probe(int slot, card_type_t type)
        if (slot < 8) {
                ec->irq = 32 + slot;
                set_irq_chip(ec->irq, &ecard_chip);
-               set_irq_handler(ec->irq, do_level_IRQ);
+               set_irq_handler(ec->irq, handle_level_irq);
                set_irq_flags(ec->irq, IRQF_VALID);
        }
 
index bd623b73445f79a9b37018e0da7d320d003c2a7c..2db42b18f53f060a1040ba65cf01114793535ad9 100644 (file)
@@ -589,10 +589,6 @@ ENTRY(__switch_to)
        strex   r5, r4, [ip]                    @ Clear exclusive monitor
 #endif
 #endif
-#if defined(CONFIG_CPU_XSCALE) && !defined(CONFIG_IWMMXT)
-       mra     r4, r5, acc0
-       stmia   ip, {r4, r5}
-#endif
 #if defined(CONFIG_HAS_TLS_REG)
        mcr     p15, 0, r3, c13, c0, 3          @ set TLS register
 #elif !defined(CONFIG_TLS_REG_EMUL)
@@ -601,11 +597,6 @@ ENTRY(__switch_to)
 #endif
 #ifdef CONFIG_MMU
        mcr     p15, 0, r6, c3, c0, 0           @ Set domain register
-#endif
-#if defined(CONFIG_CPU_XSCALE) && !defined(CONFIG_IWMMXT)
-       add     r4, r2, #TI_CPU_DOMAIN + 40     @ cpu_context_save->extra
-       ldmib   r4, {r4, r5}
-       mar     acc0, r4, r5
 #endif
        mov     r5, r0
        add     r4, r2, #TI_CPU_SAVE
index f359a189dcf2cda84f112dc0003e616cdd6434d4..0119c0d5f9788009b30cd135b3a8b51dda9c354d 100644 (file)
@@ -16,7 +16,6 @@
 
 #include <asm/assembler.h>
 #include <asm/mach-types.h>
-#include <asm/procinfo.h>
 #include <asm/ptrace.h>
 #include <asm/asm-offsets.h>
 #include <asm/thread_info.h>
index ebc3e74a79476ebde1171351ac33dd5f9a23d319..bda0748ffb004b31bb66e5a234091c6fe01fd9fd 100644 (file)
@@ -16,7 +16,6 @@
 
 #include <asm/assembler.h>
 #include <asm/domain.h>
-#include <asm/procinfo.h>
 #include <asm/ptrace.h>
 #include <asm/asm-offsets.h>
 #include <asm/memory.h>
index 2c4ff1cbe33490df3d4c37e08817eae074ae68ad..ec01f08f5642bef24e4e84ab6339042afabdb60d 100644 (file)
@@ -112,7 +112,7 @@ static struct irq_desc bad_irq_desc = {
 asmlinkage void asm_do_IRQ(unsigned int irq, struct pt_regs *regs)
 {
        struct pt_regs *old_regs = set_irq_regs(regs);
-       struct irqdesc *desc = irq_desc + irq;
+       struct irq_desc *desc = irq_desc + irq;
 
        /*
         * Some hardware gives randomly wrong interrupts.  Rather
@@ -134,7 +134,7 @@ asmlinkage void asm_do_IRQ(unsigned int irq, struct pt_regs *regs)
 
 void set_irq_flags(unsigned int irq, unsigned int iflags)
 {
-       struct irqdesc *desc;
+       struct irq_desc *desc;
        unsigned long flags;
 
        if (irq >= NR_IRQS) {
@@ -171,7 +171,7 @@ void __init init_IRQ(void)
 
 #ifdef CONFIG_HOTPLUG_CPU
 
-static void route_irq(struct irqdesc *desc, unsigned int irq, unsigned int cpu)
+static void route_irq(struct irq_desc *desc, unsigned int irq, unsigned int cpu)
 {
        pr_debug("IRQ%u: moving from cpu%u to cpu%u\n", irq, desc->cpu, cpu);
 
@@ -190,7 +190,7 @@ void migrate_irqs(void)
        unsigned int i, cpu = smp_processor_id();
 
        for (i = 0; i < NR_IRQS; i++) {
-               struct irqdesc *desc = irq_desc + i;
+               struct irq_desc *desc = irq_desc + i;
 
                if (desc->cpu == cpu) {
                        unsigned int newcpu = any_online_cpu(desc->affinity);
diff --git a/arch/arm/kernel/iwmmxt-notifier.c b/arch/arm/kernel/iwmmxt-notifier.c
deleted file mode 100644 (file)
index 0d1a1db..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- *  linux/arch/arm/kernel/iwmmxt-notifier.c
- *
- *  XScale iWMMXt (Concan) context switching and handling
- *
- *  Initial code:
- *  Copyright (c) 2003, Intel Corporation
- *
- *  Full lazy switching support, optimizations and more, by Nicolas Pitre
- *  Copyright (c) 2003-2004, 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.
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/init.h>
-#include <asm/thread_notify.h>
-#include <asm/io.h>
-
-static int iwmmxt_do(struct notifier_block *self, unsigned long cmd, void *t)
-{
-       struct thread_info *thread = t;
-
-       switch (cmd) {
-       case THREAD_NOTIFY_FLUSH:
-               /*
-                * flush_thread() zeroes thread->fpstate, so no need
-                * to do anything here.
-                *
-                * FALLTHROUGH: Ensure we don't try to overwrite our newly
-                * initialised state information on the first fault.
-                */
-
-       case THREAD_NOTIFY_RELEASE:
-               iwmmxt_task_release(thread);
-               break;
-
-       case THREAD_NOTIFY_SWITCH:
-               iwmmxt_task_switch(thread);
-               break;
-       }
-
-       return NOTIFY_DONE;
-}
-
-static struct notifier_block iwmmxt_notifier_block = {
-       .notifier_call  = iwmmxt_do,
-};
-
-static int __init iwmmxt_init(void)
-{
-       thread_register_notifier(&iwmmxt_notifier_block);
-
-       return 0;
-}
-
-late_initcall(iwmmxt_init);
index bf35c178a8772d232fc5e5e1eb0e5ba91449a2fd..a9e8f7e55fd61edc8242f1193c95d49fb5d14d42 100644 (file)
@@ -280,67 +280,6 @@ void show_fpregs(struct user_fp *regs)
                (unsigned long)regs->fpcr);
 }
 
-/*
- * Task structure and kernel stack allocation.
- */
-struct thread_info_list {
-       unsigned long *head;
-       unsigned int nr;
-};
-
-static DEFINE_PER_CPU(struct thread_info_list, thread_info_list) = { NULL, 0 };
-
-#define EXTRA_TASK_STRUCT      4
-
-struct thread_info *alloc_thread_info(struct task_struct *task)
-{
-       struct thread_info *thread = NULL;
-
-       if (EXTRA_TASK_STRUCT) {
-               struct thread_info_list *th = &get_cpu_var(thread_info_list);
-               unsigned long *p = th->head;
-
-               if (p) {
-                       th->head = (unsigned long *)p[0];
-                       th->nr -= 1;
-               }
-               put_cpu_var(thread_info_list);
-
-               thread = (struct thread_info *)p;
-       }
-
-       if (!thread)
-               thread = (struct thread_info *)
-                          __get_free_pages(GFP_KERNEL, THREAD_SIZE_ORDER);
-
-#ifdef CONFIG_DEBUG_STACK_USAGE
-       /*
-        * The stack must be cleared if you want SYSRQ-T to
-        * give sensible stack usage information
-        */
-       if (thread)
-               memzero(thread, THREAD_SIZE);
-#endif
-       return thread;
-}
-
-void free_thread_info(struct thread_info *thread)
-{
-       if (EXTRA_TASK_STRUCT) {
-               struct thread_info_list *th = &get_cpu_var(thread_info_list);
-               if (th->nr < EXTRA_TASK_STRUCT) {
-                       unsigned long *p = (unsigned long *)thread;
-                       p[0] = (unsigned long)th->head;
-                       th->head = p;
-                       th->nr += 1;
-                       put_cpu_var(thread_info_list);
-                       return;
-               }
-               put_cpu_var(thread_info_list);
-       }
-       free_pages((unsigned long)thread, THREAD_SIZE_ORDER);
-}
-
 /*
  * Free current thread data structures etc..
  */
index 29efc9f82057c534d5ece4868e29ff00b0854e9f..238dd9b6db847474d536af3555a5ea9760fba806 100644 (file)
@@ -357,9 +357,6 @@ static void __init setup_processor(void)
 #ifndef CONFIG_VFP
        elf_hwcap &= ~HWCAP_VFP;
 #endif
-#ifndef CONFIG_IWMMXT
-       elf_hwcap &= ~HWCAP_IWMMXT;
-#endif
 
        cpu_proc_init();
 }
@@ -441,16 +438,19 @@ __early_param("initrd=", early_initrd);
 
 static void __init arm_add_memory(unsigned long start, unsigned long size)
 {
+       struct membank *bank;
+
        /*
         * Ensure that start/size are aligned to a page boundary.
         * Size is appropriately rounded down, start is rounded up.
         */
        size -= start & ~PAGE_MASK;
 
-       meminfo.bank[meminfo.nr_banks].start = PAGE_ALIGN(start);
-       meminfo.bank[meminfo.nr_banks].size  = size & PAGE_MASK;
-       meminfo.bank[meminfo.nr_banks].node  = PHYS_TO_NID(start);
-       meminfo.nr_banks += 1;
+       bank = &meminfo.bank[meminfo.nr_banks++];
+
+       bank->start = PAGE_ALIGN(start);
+       bank->size  = size & PAGE_MASK;
+       bank->node  = PHYS_TO_NID(start);
 }
 
 /*
index 48cf7fffddf2add8d663fc4db96b019ed3eaea04..3843d3bab2ddc4d2e7eb536cc8380ee3d420d5f5 100644 (file)
@@ -11,7 +11,9 @@
 #include <linux/signal.h>
 #include <linux/ptrace.h>
 #include <linux/personality.h>
+#include <linux/freezer.h>
 
+#include <asm/elf.h>
 #include <asm/cacheflush.h>
 #include <asm/ucontext.h>
 #include <asm/uaccess.h>
index bede380c07a9ef2e285303756502792c2a7f0c45..042a12982e980c43bb0520e289477df525a50fc2 100644 (file)
@@ -631,12 +631,9 @@ baddataabort(int code, unsigned long instr, struct pt_regs *regs)
        notify_die("unknown data abort code", regs, &info, instr, 0);
 }
 
-void __attribute__((noreturn)) __bug(const char *file, int line, void *data)
+void __attribute__((noreturn)) __bug(const char *file, int line)
 {
-       printk(KERN_CRIT"kernel BUG at %s:%d!", file, line);
-       if (data)
-               printk(" - extra data = %p", data);
-       printk("\n");
+       printk(KERN_CRIT"kernel BUG at %s:%d!\n", file, line);
        *(int *)0 = 0;
 
        /* Avoid "noreturn function does return" */
diff --git a/arch/arm/kernel/xscale-cp0.c b/arch/arm/kernel/xscale-cp0.c
new file mode 100644 (file)
index 0000000..180000b
--- /dev/null
@@ -0,0 +1,179 @@
+/*
+ * linux/arch/arm/kernel/xscale-cp0.c
+ *
+ * XScale DSP and iWMMXt coprocessor context switching and handling
+ *
+ * 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/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/init.h>
+#include <asm/thread_notify.h>
+#include <asm/io.h>
+
+static inline void dsp_save_state(u32 *state)
+{
+       __asm__ __volatile__ (
+               "mrrc   p0, 0, %0, %1, c0\n"
+               : "=r" (state[0]), "=r" (state[1]));
+}
+
+static inline void dsp_load_state(u32 *state)
+{
+       __asm__ __volatile__ (
+               "mcrr   p0, 0, %0, %1, c0\n"
+               : : "r" (state[0]), "r" (state[1]));
+}
+
+static int dsp_do(struct notifier_block *self, unsigned long cmd, void *t)
+{
+       struct thread_info *thread = t;
+
+       switch (cmd) {
+       case THREAD_NOTIFY_FLUSH:
+               thread->cpu_context.extra[0] = 0;
+               thread->cpu_context.extra[1] = 0;
+               break;
+
+       case THREAD_NOTIFY_SWITCH:
+               dsp_save_state(current_thread_info()->cpu_context.extra);
+               dsp_load_state(thread->cpu_context.extra);
+               break;
+       }
+
+       return NOTIFY_DONE;
+}
+
+static struct notifier_block dsp_notifier_block = {
+       .notifier_call  = dsp_do,
+};
+
+
+#ifdef CONFIG_IWMMXT
+static int iwmmxt_do(struct notifier_block *self, unsigned long cmd, void *t)
+{
+       struct thread_info *thread = t;
+
+       switch (cmd) {
+       case THREAD_NOTIFY_FLUSH:
+               /*
+                * flush_thread() zeroes thread->fpstate, so no need
+                * to do anything here.
+                *
+                * FALLTHROUGH: Ensure we don't try to overwrite our newly
+                * initialised state information on the first fault.
+                */
+
+       case THREAD_NOTIFY_RELEASE:
+               iwmmxt_task_release(thread);
+               break;
+
+       case THREAD_NOTIFY_SWITCH:
+               iwmmxt_task_switch(thread);
+               break;
+       }
+
+       return NOTIFY_DONE;
+}
+
+static struct notifier_block iwmmxt_notifier_block = {
+       .notifier_call  = iwmmxt_do,
+};
+#endif
+
+
+static u32 __init xscale_cp_access_read(void)
+{
+       u32 value;
+
+       __asm__ __volatile__ (
+               "mrc    p15, 0, %0, c15, c1, 0\n\t"
+               : "=r" (value));
+
+       return value;
+}
+
+static void __init xscale_cp_access_write(u32 value)
+{
+       u32 temp;
+
+       __asm__ __volatile__ (
+               "mcr    p15, 0, %1, c15, c1, 0\n\t"
+               "mrc    p15, 0, %0, c15, c1, 0\n\t"
+               "mov    %0, %0\n\t"
+               "sub    pc, pc, #4\n\t"
+               : "=r" (temp) : "r" (value));
+}
+
+/*
+ * Detect whether we have a MAC coprocessor (40 bit register) or an
+ * iWMMXt coprocessor (64 bit registers) by loading 00000100:00000000
+ * into a coprocessor register and reading it back, and checking
+ * whether the upper word survived intact.
+ */
+static int __init cpu_has_iwmmxt(void)
+{
+       u32 lo;
+       u32 hi;
+
+       /*
+        * This sequence is interpreted by the DSP coprocessor as:
+        *      mar     acc0, %2, %3
+        *      mra     %0, %1, acc0
+        *
+        * And by the iWMMXt coprocessor as:
+        *      tmcrr   wR0, %2, %3
+        *      tmrrc   %0, %1, wR0
+        */
+       __asm__ __volatile__ (
+               "mcrr   p0, 0, %2, %3, c0\n"
+               "mrrc   p0, 0, %0, %1, c0\n"
+               : "=r" (lo), "=r" (hi)
+               : "r" (0), "r" (0x100));
+
+       return !!hi;
+}
+
+
+/*
+ * If we detect that the CPU has iWMMXt (and CONFIG_IWMMXT=y), we
+ * disable CP0/CP1 on boot, and let call_fpe() and the iWMMXt lazy
+ * switch code handle iWMMXt context switching.  If on the other
+ * hand the CPU has a DSP coprocessor, we keep access to CP0 enabled
+ * all the time, and save/restore acc0 on context switch in non-lazy
+ * fashion.
+ */
+static int __init xscale_cp0_init(void)
+{
+       u32 cp_access;
+
+       cp_access = xscale_cp_access_read() & ~3;
+       xscale_cp_access_write(cp_access | 1);
+
+       if (cpu_has_iwmmxt()) {
+#ifndef CONFIG_IWMMXT
+               printk(KERN_WARNING "CAUTION: XScale iWMMXt coprocessor "
+                       "detected, but kernel support is missing.\n");
+#else
+               printk(KERN_INFO "XScale iWMMXt coprocessor detected.\n");
+               elf_hwcap |= HWCAP_IWMMXT;
+               thread_register_notifier(&iwmmxt_notifier_block);
+#endif
+       } else {
+               printk(KERN_INFO "XScale DSP coprocessor detected.\n");
+               thread_register_notifier(&dsp_notifier_block);
+               cp_access |= 1;
+       }
+
+       xscale_cp_access_write(cp_access);
+
+       return 0;
+}
+
+late_initcall(xscale_cp0_init);
index fe3d297d682d2ba19fd224f9c7cf9ce3ad63eeef..a950160fcfb69c171944f8ea0ef50c6e0c479e07 100644 (file)
@@ -82,7 +82,7 @@ static void aaec2000_int_unmask(unsigned int irq)
        IRQ_INTENS |= (1 << irq);
 }
 
-static struct irqchip aaec2000_irq_chip = {
+static struct irq_chip aaec2000_irq_chip = {
        .ack    = aaec2000_int_ack,
        .mask   = aaec2000_int_mask,
        .unmask = aaec2000_int_unmask,
@@ -93,7 +93,7 @@ void __init aaec2000_init_irq(void)
        unsigned int i;
 
        for (i = 0; i < NR_IRQS; i++) {
-               set_irq_handler(i, do_level_IRQ);
+               set_irq_handler(i, handle_level_irq);
                set_irq_chip(i, &aaec2000_irq_chip);
                set_irq_flags(i, IRQF_VALID);
        }
index 2f85e8693b1ba1e3984f93fa4e83b53fdb38a468..9f11db8af2339b5f2bb2170e7bff03e147707e50 100644 (file)
@@ -2,7 +2,8 @@ if ARCH_AT91
 
 menu "Atmel AT91 System-on-Chip"
 
-comment "Atmel AT91 Processors"
+choice
+       prompt "Atmel AT91 Processor"
 
 config ARCH_AT91RM9200
        bool "AT91RM9200"
@@ -13,6 +14,8 @@ config ARCH_AT91SAM9260
 config ARCH_AT91SAM9261
        bool "AT91SAM9261"
 
+endchoice
+
 # ----------------------------------------------------------
 
 if ARCH_AT91RM9200
@@ -33,7 +36,6 @@ config ARCH_AT91RM9200DK
          Select this if you are using Atmel's AT91RM9200-DK Development board.
          (Discontinued)
 
-
 config MACH_AT91RM9200EK
        bool "Atmel AT91RM9200-EK Evaluation Kit"
        depends on ARCH_AT91RM9200
@@ -90,6 +92,13 @@ if ARCH_AT91SAM9260
 
 comment "AT91SAM9260 Board Type"
 
+config MACH_AT91SAM9260EK
+       bool "Atmel AT91SAM9260-EK Evaluation Kit"
+       depends on ARCH_AT91SAM9260
+       help
+         Select this if you are using Atmel's AT91SAM9260-EK Evaluation Kit.
+         <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3933>
+
 endif
 
 # ----------------------------------------------------------
@@ -98,8 +107,31 @@ if ARCH_AT91SAM9261
 
 comment "AT91SAM9261 Board Type"
 
+config MACH_AT91SAM9261EK
+       bool "Atmel AT91SAM9261-EK Evaluation Kit"
+       depends on ARCH_AT91SAM9261
+       help
+         Select this if you are using Atmel's AT91SAM9261-EK Evaluation Kit.
+         <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3820>
+
 endif
 
+# ----------------------------------------------------------
+
+comment "AT91 Board Options"
+
+config MTD_AT91_DATAFLASH_CARD
+       bool "Enable DataFlash Card support"
+       depends on (ARCH_AT91RM9200DK || MACH_AT91RM9200EK || MACH_AT91SAM9260EK || MACH_AT91SAM9261EK)
+       help
+         Enable support for the DataFlash card.
+
+config MTD_NAND_AT91_BUSWIDTH_16
+       bool "Enable 16-bit data bus interface to NAND flash"
+       depends on (MACH_AT91SAM9261EK || MACH_AT91SAM9260EK)
+       help
+         On AT91SAM926x boards both types of NAND flash can be present
+         (8 and 16 bit data bus width).
 
 # ----------------------------------------------------------
 
index c174805c24e538305fd433051dcbae0b346a5ef0..cf777007847af4f2d88f63125102282b5ea97cdb 100644 (file)
@@ -2,7 +2,7 @@
 # Makefile for the linux kernel.
 #
 
-obj-y          := clock.o irq.o gpio.o devices.o
+obj-y          := clock.o irq.o gpio.o
 obj-m          :=
 obj-n          :=
 obj-           :=
@@ -10,11 +10,11 @@ obj-                :=
 obj-$(CONFIG_PM)               += pm.o
 
 # CPU-specific support
-obj-$(CONFIG_ARCH_AT91RM9200)  += at91rm9200.o at91rm9200_time.o
-obj-$(CONFIG_ARCH_AT91SAM9260) +=
-obj-$(CONFIG_ARCH_AT91SAM9261) +=
+obj-$(CONFIG_ARCH_AT91RM9200)  += at91rm9200.o at91rm9200_time.o at91rm9200_devices.o
+obj-$(CONFIG_ARCH_AT91SAM9260) += at91sam9260.o at91sam926x_time.o at91sam9260_devices.o
+obj-$(CONFIG_ARCH_AT91SAM9261) += at91sam9261.o at91sam926x_time.o at91sam9261_devices.o
 
-# AT91RM9200 Board-specific support
+# AT91RM9200 board-specific support
 obj-$(CONFIG_MACH_ONEARM)      += board-1arm.o
 obj-$(CONFIG_ARCH_AT91RM9200DK)        += board-dk.o
 obj-$(CONFIG_MACH_AT91RM9200EK)        += board-ek.o
@@ -26,8 +26,10 @@ obj-$(CONFIG_MACH_ATEB9200)  += board-eb9200.o
 obj-$(CONFIG_MACH_KAFA)                += board-kafa.o
 
 # AT91SAM9260 board-specific support
+obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o
 
 # AT91SAM9261 board-specific support
+obj-$(CONFIG_MACH_AT91SAM9261EK) += board-sam9261ek.o
 
 # LEDs support
 led-$(CONFIG_ARCH_AT91RM9200DK)        += leds.o
index dcf6136fedf9deb51f916a190634e0c333d416c1..a92e9a495b07a1bdc64e3093a1711abbaf3f0656 100644 (file)
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
+#include <asm/arch/at91rm9200.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/at91_st.h>
 
-#include <asm/hardware.h>
 #include "generic.h"
 #include "clock.h"
 
@@ -25,33 +27,13 @@ static struct map_desc at91rm9200_io_desc[] __initdata = {
                .pfn            = __phys_to_pfn(AT91_BASE_SYS),
                .length         = SZ_4K,
                .type           = MT_DEVICE,
-       }, {
-               .virtual        = AT91_VA_BASE_SPI,
-               .pfn            = __phys_to_pfn(AT91RM9200_BASE_SPI),
-               .length         = SZ_16K,
-               .type           = MT_DEVICE,
        }, {
                .virtual        = AT91_VA_BASE_EMAC,
                .pfn            = __phys_to_pfn(AT91RM9200_BASE_EMAC),
                .length         = SZ_16K,
                .type           = MT_DEVICE,
        }, {
-               .virtual        = AT91_VA_BASE_TWI,
-               .pfn            = __phys_to_pfn(AT91RM9200_BASE_TWI),
-               .length         = SZ_16K,
-               .type           = MT_DEVICE,
-       }, {
-               .virtual        = AT91_VA_BASE_MCI,
-               .pfn            = __phys_to_pfn(AT91RM9200_BASE_MCI),
-               .length         = SZ_16K,
-               .type           = MT_DEVICE,
-       }, {
-               .virtual        = AT91_VA_BASE_UDP,
-               .pfn            = __phys_to_pfn(AT91RM9200_BASE_UDP),
-               .length         = SZ_16K,
-               .type           = MT_DEVICE,
-       }, {
-               .virtual        = AT91_SRAM_VIRT_BASE,
+               .virtual        = AT91_IO_VIRT_BASE - AT91RM9200_SRAM_SIZE,
                .pfn            = __phys_to_pfn(AT91RM9200_SRAM_BASE),
                .length         = AT91RM9200_SRAM_SIZE,
                .type           = MT_DEVICE,
@@ -222,6 +204,16 @@ static struct at91_gpio_bank at91rm9200_gpio[] = {
        }
 };
 
+static void at91rm9200_reset(void)
+{
+       /*
+        * Perform a hardware reset with the use of the Watchdog timer.
+        */
+       at91_sys_write(AT91_ST_WDMR, AT91_ST_RSTEN | AT91_ST_EXTEN | 1);
+       at91_sys_write(AT91_ST_CR, AT91_ST_WDRST);
+}
+
+
 /* --------------------------------------------------------------------
  *  AT91RM9200 processor initialization
  * -------------------------------------------------------------------- */
@@ -230,6 +222,12 @@ void __init at91rm9200_initialize(unsigned long main_clock, unsigned short banks
        /* Map peripherals */
        iotable_init(at91rm9200_io_desc, ARRAY_SIZE(at91rm9200_io_desc));
 
+       at91_arch_reset = at91rm9200_reset;
+       at91_extern_irq = (1 << AT91RM9200_ID_IRQ0) | (1 << AT91RM9200_ID_IRQ1)
+                       | (1 << AT91RM9200_ID_IRQ2) | (1 << AT91RM9200_ID_IRQ3)
+                       | (1 << AT91RM9200_ID_IRQ4) | (1 << AT91RM9200_ID_IRQ5)
+                       | (1 << AT91RM9200_ID_IRQ6);
+
        /* Init clock subsystem */
        at91_clock_init(main_clock);
 
similarity index 83%
rename from arch/arm/mach-at91rm9200/devices.c
rename to arch/arm/mach-at91rm9200/at91rm9200_devices.c
index 059824376629db538a6306e56bee80b9dbaeeb69..4641b99db0ee1ca56b93be286952ddc763108256 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * arch/arm/mach-at91rm9200/devices.c
+ * arch/arm/mach-at91rm9200/at91rm9200_devices.c
  *
  *  Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org>
  *  Copyright (C) 2005 David Brownell
 
 #include <linux/platform_device.h>
 
-#include <asm/hardware.h>
 #include <asm/arch/board.h>
 #include <asm/arch/gpio.h>
+#include <asm/arch/at91rm9200.h>
+#include <asm/arch/at91rm9200_mc.h>
 
 #include "generic.h"
 
@@ -33,7 +34,7 @@
 static u64 ohci_dmamask = 0xffffffffUL;
 static struct at91_usbh_data usbh_data;
 
-static struct resource at91_usbh_resources[] = {
+static struct resource usbh_resources[] = {
        [0] = {
                .start  = AT91RM9200_UHP_BASE,
                .end    = AT91RM9200_UHP_BASE + SZ_1M - 1,
@@ -54,8 +55,8 @@ static struct platform_device at91rm9200_usbh_device = {
                                .coherent_dma_mask      = 0xffffffff,
                                .platform_data          = &usbh_data,
        },
-       .resource       = at91_usbh_resources,
-       .num_resources  = ARRAY_SIZE(at91_usbh_resources),
+       .resource       = usbh_resources,
+       .num_resources  = ARRAY_SIZE(usbh_resources),
 };
 
 void __init at91_add_device_usbh(struct at91_usbh_data *data)
@@ -78,7 +79,7 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
 #ifdef CONFIG_USB_GADGET_AT91
 static struct at91_udc_data udc_data;
 
-static struct resource at91_udc_resources[] = {
+static struct resource udc_resources[] = {
        [0] = {
                .start  = AT91RM9200_BASE_UDP,
                .end    = AT91RM9200_BASE_UDP + SZ_16K - 1,
@@ -97,8 +98,8 @@ static struct platform_device at91rm9200_udc_device = {
        .dev            = {
                                .platform_data          = &udc_data,
        },
-       .resource       = at91_udc_resources,
-       .num_resources  = ARRAY_SIZE(at91_udc_resources),
+       .resource       = udc_resources,
+       .num_resources  = ARRAY_SIZE(udc_resources),
 };
 
 void __init at91_add_device_udc(struct at91_udc_data *data)
@@ -129,7 +130,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data) {}
 static u64 eth_dmamask = 0xffffffffUL;
 static struct at91_eth_data eth_data;
 
-static struct resource at91_eth_resources[] = {
+static struct resource eth_resources[] = {
        [0] = {
                .start  = AT91_VA_BASE_EMAC,
                .end    = AT91_VA_BASE_EMAC + SZ_16K - 1,
@@ -150,8 +151,8 @@ static struct platform_device at91rm9200_eth_device = {
                                .coherent_dma_mask      = 0xffffffff,
                                .platform_data          = &eth_data,
        },
-       .resource       = at91_eth_resources,
-       .num_resources  = ARRAY_SIZE(at91_eth_resources),
+       .resource       = eth_resources,
+       .num_resources  = ARRAY_SIZE(eth_resources),
 };
 
 void __init at91_add_device_eth(struct at91_eth_data *data)
@@ -202,11 +203,13 @@ void __init at91_add_device_eth(struct at91_eth_data *data) {}
 #if defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE)
 static struct at91_cf_data cf_data;
 
-static struct resource at91_cf_resources[] = {
+#define CF_BASE                AT91_CHIPSELECT_4
+
+static struct resource cf_resources[] = {
        [0] = {
-               .start  = AT91_CF_BASE,
+               .start  = CF_BASE,
                /* ties up CS4, CS5 and CS6 */
-               .end    = AT91_CF_BASE + (0x30000000 - 1),
+               .end    = CF_BASE + (0x30000000 - 1),
                .flags  = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
        },
 };
@@ -217,15 +220,38 @@ static struct platform_device at91rm9200_cf_device = {
        .dev            = {
                                .platform_data          = &cf_data,
        },
-       .resource       = at91_cf_resources,
-       .num_resources  = ARRAY_SIZE(at91_cf_resources),
+       .resource       = cf_resources,
+       .num_resources  = ARRAY_SIZE(cf_resources),
 };
 
 void __init at91_add_device_cf(struct at91_cf_data *data)
 {
+       unsigned int csa;
+
        if (!data)
                return;
 
+       data->chipselect = 4;           /* can only use EBI ChipSelect 4 */
+
+       /* CF takes over CS4, CS5, CS6 */
+       csa = at91_sys_read(AT91_EBI_CSA);
+       at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH);
+
+       /*
+        * Static memory controller timing adjustments.
+        * REVISIT:  these timings are in terms of MCK cycles, so
+        * when MCK changes (cpufreq etc) so must these values...
+        */
+       at91_sys_write(AT91_SMC_CSR(4),
+                                 AT91_SMC_ACSS_STD
+                               | AT91_SMC_DBW_16
+                               | AT91_SMC_BAT
+                               | AT91_SMC_WSEN
+                               | AT91_SMC_NWS_(32)     /* wait states */
+                               | AT91_SMC_RWSETUP_(6)  /* setup time */
+                               | AT91_SMC_RWHOLD_(4)   /* hold time */
+       );
+
        /* input/irq */
        if (data->irq_pin) {
                at91_set_gpio_input(data->irq_pin, 1);
@@ -245,6 +271,9 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
        at91_set_A_periph(AT91_PIN_PC11, 0);    /* NCS5/CFCE1 */
        at91_set_A_periph(AT91_PIN_PC12, 0);    /* NCS6/CFCE2 */
 
+       /* nWAIT is _not_ a default setting */
+       at91_set_A_periph(AT91_PIN_PC6, 1);     /*  nWAIT */
+
        cf_data = *data;
        platform_device_register(&at91rm9200_cf_device);
 }
@@ -257,11 +286,11 @@ void __init at91_add_device_cf(struct at91_cf_data *data) {}
  *  MMC / SD
  * -------------------------------------------------------------------- */
 
-#if defined(CONFIG_MMC_AT91RM9200) || defined(CONFIG_MMC_AT91RM9200_MODULE)
+#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
 static u64 mmc_dmamask = 0xffffffffUL;
 static struct at91_mmc_data mmc_data;
 
-static struct resource at91_mmc_resources[] = {
+static struct resource mmc_resources[] = {
        [0] = {
                .start  = AT91RM9200_BASE_MCI,
                .end    = AT91RM9200_BASE_MCI + SZ_16K - 1,
@@ -282,8 +311,8 @@ static struct platform_device at91rm9200_mmc_device = {
                                .coherent_dma_mask      = 0xffffffff,
                                .platform_data          = &mmc_data,
        },
-       .resource       = at91_mmc_resources,
-       .num_resources  = ARRAY_SIZE(at91_mmc_resources),
+       .resource       = mmc_resources,
+       .num_resources  = ARRAY_SIZE(mmc_resources),
 };
 
 void __init at91_add_device_mmc(struct at91_mmc_data *data)
@@ -298,31 +327,33 @@ void __init at91_add_device_mmc(struct at91_mmc_data *data)
        }
        if (data->wp_pin)
                at91_set_gpio_input(data->wp_pin, 1);
+       if (data->vcc_pin)
+               at91_set_gpio_output(data->vcc_pin, 0);
 
        /* CLK */
        at91_set_A_periph(AT91_PIN_PA27, 0);
 
-       if (data->is_b) {
+       if (data->slot_b) {
                /* CMD */
-               at91_set_B_periph(AT91_PIN_PA8, 0);
+               at91_set_B_periph(AT91_PIN_PA8, 1);
 
                /* DAT0, maybe DAT1..DAT3 */
-               at91_set_B_periph(AT91_PIN_PA9, 0);
+               at91_set_B_periph(AT91_PIN_PA9, 1);
                if (data->wire4) {
-                       at91_set_B_periph(AT91_PIN_PA10, 0);
-                       at91_set_B_periph(AT91_PIN_PA11, 0);
-                       at91_set_B_periph(AT91_PIN_PA12, 0);
+                       at91_set_B_periph(AT91_PIN_PA10, 1);
+                       at91_set_B_periph(AT91_PIN_PA11, 1);
+                       at91_set_B_periph(AT91_PIN_PA12, 1);
                }
        } else {
                /* CMD */
-               at91_set_A_periph(AT91_PIN_PA28, 0);
+               at91_set_A_periph(AT91_PIN_PA28, 1);
 
                /* DAT0, maybe DAT1..DAT3 */
-               at91_set_A_periph(AT91_PIN_PA29, 0);
+               at91_set_A_periph(AT91_PIN_PA29, 1);
                if (data->wire4) {
-                       at91_set_B_periph(AT91_PIN_PB3, 0);
-                       at91_set_B_periph(AT91_PIN_PB4, 0);
-                       at91_set_B_periph(AT91_PIN_PB5, 0);
+                       at91_set_B_periph(AT91_PIN_PB3, 1);
+                       at91_set_B_periph(AT91_PIN_PB4, 1);
+                       at91_set_B_periph(AT91_PIN_PB5, 1);
                }
        }
 
@@ -341,29 +372,45 @@ void __init at91_add_device_mmc(struct at91_mmc_data *data) {}
 #if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
 static struct at91_nand_data nand_data;
 
-static struct resource at91_nand_resources[] = {
+#define NAND_BASE      AT91_CHIPSELECT_3
+
+static struct resource nand_resources[] = {
        {
-               .start  = AT91_SMARTMEDIA_BASE,
-               .end    = AT91_SMARTMEDIA_BASE + SZ_8M - 1,
+               .start  = NAND_BASE,
+               .end    = NAND_BASE + SZ_8M - 1,
                .flags  = IORESOURCE_MEM,
        }
 };
 
-static struct platform_device at91_nand_device = {
+static struct platform_device at91rm9200_nand_device = {
        .name           = "at91_nand",
        .id             = -1,
        .dev            = {
                                .platform_data  = &nand_data,
        },
-       .resource       = at91_nand_resources,
-       .num_resources  = ARRAY_SIZE(at91_nand_resources),
+       .resource       = nand_resources,
+       .num_resources  = ARRAY_SIZE(nand_resources),
 };
 
 void __init at91_add_device_nand(struct at91_nand_data *data)
 {
+       unsigned int csa;
+
        if (!data)
                return;
 
+       /* enable the address range of CS3 */
+       csa = at91_sys_read(AT91_EBI_CSA);
+       at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS3A_SMC_SMARTMEDIA);
+
+       /* set the bus interface characteristics */
+       at91_sys_write(AT91_SMC_CSR(3), AT91_SMC_ACSS_STD | AT91_SMC_DBW_8 | AT91_SMC_WSEN
+               | AT91_SMC_NWS_(5)
+               | AT91_SMC_TDF_(1)
+               | AT91_SMC_RWSETUP_(0)  /* tDS Data Set up Time 30 - ns */
+               | AT91_SMC_RWHOLD_(1)   /* tDH Data Hold Time 20 - ns */
+       );
+
        /* enable pin */
        if (data->enable_pin)
                at91_set_gpio_output(data->enable_pin, 1);
@@ -380,7 +427,7 @@ void __init at91_add_device_nand(struct at91_nand_data *data)
        at91_set_A_periph(AT91_PIN_PC3, 0);             /* SMWE */
 
        nand_data = *data;
-       platform_device_register(&at91_nand_device);
+       platform_device_register(&at91rm9200_nand_device);
 }
 #else
 void __init at91_add_device_nand(struct at91_nand_data *data) {}
@@ -392,10 +439,25 @@ void __init at91_add_device_nand(struct at91_nand_data *data) {}
  * -------------------------------------------------------------------- */
 
 #if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
+
+static struct resource twi_resources[] = {
+       [0] = {
+               .start  = AT91RM9200_BASE_TWI,
+               .end    = AT91RM9200_BASE_TWI + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91RM9200_ID_TWI,
+               .end    = AT91RM9200_ID_TWI,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
 static struct platform_device at91rm9200_twi_device = {
        .name           = "at91_i2c",
        .id             = -1,
-       .num_resources  = 0,
+       .resource       = twi_resources,
+       .num_resources  = ARRAY_SIZE(twi_resources),
 };
 
 void __init at91_add_device_i2c(void)
@@ -421,7 +483,7 @@ void __init at91_add_device_i2c(void) {}
 #if defined(CONFIG_SPI_AT91) || defined(CONFIG_SPI_AT91_MODULE) || defined(CONFIG_AT91_SPI) || defined(CONFIG_AT91_SPI_MODULE)
 static u64 spi_dmamask = 0xffffffffUL;
 
-static struct resource at91_spi_resources[] = {
+static struct resource spi_resources[] = {
        [0] = {
                .start  = AT91RM9200_BASE_SPI,
                .end    = AT91RM9200_BASE_SPI + SZ_16K - 1,
@@ -438,14 +500,14 @@ static struct platform_device at91rm9200_spi_device = {
        .name           = "at91_spi",
        .id             = 0,
        .dev            = {
-               .dma_mask               = &spi_dmamask,
-               .coherent_dma_mask      = 0xffffffff,
+                               .dma_mask               = &spi_dmamask,
+                               .coherent_dma_mask      = 0xffffffff,
        },
-       .resource       = at91_spi_resources,
-       .num_resources  = ARRAY_SIZE(at91_spi_resources),
+       .resource       = spi_resources,
+       .num_resources  = ARRAY_SIZE(spi_resources),
 };
 
-static const unsigned at91_spi_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PA5, AT91_PIN_PA6 };
+static const unsigned spi_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PA5, AT91_PIN_PA6 };
 
 void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
 {
@@ -461,7 +523,7 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
                if (devices[i].controller_data)
                        cs_pin = (unsigned long) devices[i].controller_data;
                else
-                       cs_pin = at91_spi_standard_cs[devices[i].chip_select];
+                       cs_pin = spi_standard_cs[devices[i].chip_select];
 
 #ifdef CONFIG_SPI_AT91_MANUAL_CS
                at91_set_gpio_output(cs_pin, 1);
@@ -474,7 +536,7 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
        }
 
        spi_register_board_info(devices, nr_devices);
-       at91_clock_associate("spi0_clk", &at91rm9200_spi_device.dev, "spi");
+       at91_clock_associate("spi_clk", &at91rm9200_spi_device.dev, "spi");
        platform_device_register(&at91rm9200_spi_device);
 }
 #else
@@ -486,7 +548,7 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
  *  RTC
  * -------------------------------------------------------------------- */
 
-#if defined(CONFIG_RTC_DRV_AT91) || defined(CONFIG_RTC_DRV_AT91_MODULE)
+#if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE)
 static struct platform_device at91rm9200_rtc_device = {
        .name           = "at91_rtc",
        .id             = -1,
@@ -506,7 +568,7 @@ static void __init at91_add_device_rtc(void) {}
  *  Watchdog
  * -------------------------------------------------------------------- */
 
-#if defined(CONFIG_AT91_WATCHDOG) || defined(CONFIG_AT91_WATCHDOG_MODULE)
+#if defined(CONFIG_AT91RM9200_WATCHDOG) || defined(CONFIG_AT91RM9200_WATCHDOG_MODULE)
 static struct platform_device at91rm9200_wdt_device = {
        .name           = "at91_wdt",
        .id             = -1,
index 07c9cea8961d745742d83490802f2a4a05888120..b999e192a7e9c22719cd83c8cdc254584dc299df 100644 (file)
@@ -30,6 +30,8 @@
 #include <asm/io.h>
 #include <asm/mach/time.h>
 
+#include <asm/arch/at91_st.h>
+
 static unsigned long last_crtr;
 
 /*
@@ -99,6 +101,9 @@ void at91rm9200_timer_reset(void)
        /* Set Period Interval timer */
        at91_sys_write(AT91_ST_PIMR, LATCH);
 
+       /* Clear any pending interrupts */
+       (void) at91_sys_read(AT91_ST_SR);
+
        /* Enable Period Interval Timer interrupt */
        at91_sys_write(AT91_ST_IER, AT91_ST_PITS);
 }
diff --git a/arch/arm/mach-at91rm9200/at91sam9260.c b/arch/arm/mach-at91rm9200/at91sam9260.c
new file mode 100644 (file)
index 0000000..203f073
--- /dev/null
@@ -0,0 +1,294 @@
+/*
+ * arch/arm/mach-at91rm9200/at91sam9260.c
+ *
+ *  Copyright (C) 2006 SAN People
+ *
+ * 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/module.h>
+
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+#include <asm/arch/at91sam9260.h>
+#include <asm/arch/at91_pmc.h>
+
+#include "generic.h"
+#include "clock.h"
+
+static struct map_desc at91sam9260_io_desc[] __initdata = {
+       {
+               .virtual        = AT91_VA_BASE_SYS,
+               .pfn            = __phys_to_pfn(AT91_BASE_SYS),
+               .length         = SZ_16K,
+               .type           = MT_DEVICE,
+       }, {
+               .virtual        = AT91_IO_VIRT_BASE - AT91SAM9260_SRAM0_SIZE,
+               .pfn            = __phys_to_pfn(AT91SAM9260_SRAM0_BASE),
+               .length         = AT91SAM9260_SRAM0_SIZE,
+               .type           = MT_DEVICE,
+       }, {
+               .virtual        = AT91_IO_VIRT_BASE - AT91SAM9260_SRAM0_SIZE - AT91SAM9260_SRAM1_SIZE,
+               .pfn            = __phys_to_pfn(AT91SAM9260_SRAM1_BASE),
+               .length         = AT91SAM9260_SRAM1_SIZE,
+               .type           = MT_DEVICE,
+       },
+};
+
+/* --------------------------------------------------------------------
+ *  Clocks
+ * -------------------------------------------------------------------- */
+
+/*
+ * The peripheral clocks.
+ */
+static struct clk pioA_clk = {
+       .name           = "pioA_clk",
+       .pmc_mask       = 1 << AT91SAM9260_ID_PIOA,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk pioB_clk = {
+       .name           = "pioB_clk",
+       .pmc_mask       = 1 << AT91SAM9260_ID_PIOB,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk pioC_clk = {
+       .name           = "pioC_clk",
+       .pmc_mask       = 1 << AT91SAM9260_ID_PIOC,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk adc_clk = {
+       .name           = "adc_clk",
+       .pmc_mask       = 1 << AT91SAM9260_ID_ADC,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk usart0_clk = {
+       .name           = "usart0_clk",
+       .pmc_mask       = 1 << AT91SAM9260_ID_US0,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk usart1_clk = {
+       .name           = "usart1_clk",
+       .pmc_mask       = 1 << AT91SAM9260_ID_US1,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk usart2_clk = {
+       .name           = "usart2_clk",
+       .pmc_mask       = 1 << AT91SAM9260_ID_US2,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk mmc_clk = {
+       .name           = "mci_clk",
+       .pmc_mask       = 1 << AT91SAM9260_ID_MCI,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk udc_clk = {
+       .name           = "udc_clk",
+       .pmc_mask       = 1 << AT91SAM9260_ID_UDP,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk twi_clk = {
+       .name           = "twi_clk",
+       .pmc_mask       = 1 << AT91SAM9260_ID_TWI,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk spi0_clk = {
+       .name           = "spi0_clk",
+       .pmc_mask       = 1 << AT91SAM9260_ID_SPI0,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk spi1_clk = {
+       .name           = "spi1_clk",
+       .pmc_mask       = 1 << AT91SAM9260_ID_SPI1,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk ohci_clk = {
+       .name           = "ohci_clk",
+       .pmc_mask       = 1 << AT91SAM9260_ID_UHP,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk ether_clk = {
+       .name           = "ether_clk",
+       .pmc_mask       = 1 << AT91SAM9260_ID_EMAC,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk isi_clk = {
+       .name           = "isi_clk",
+       .pmc_mask       = 1 << AT91SAM9260_ID_ISI,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk usart3_clk = {
+       .name           = "usart3_clk",
+       .pmc_mask       = 1 << AT91SAM9260_ID_US3,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk usart4_clk = {
+       .name           = "usart4_clk",
+       .pmc_mask       = 1 << AT91SAM9260_ID_US4,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk usart5_clk = {
+       .name           = "usart5_clk",
+       .pmc_mask       = 1 << AT91SAM9260_ID_US5,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+
+static struct clk *periph_clocks[] __initdata = {
+       &pioA_clk,
+       &pioB_clk,
+       &pioC_clk,
+       &adc_clk,
+       &usart0_clk,
+       &usart1_clk,
+       &usart2_clk,
+       &mmc_clk,
+       &udc_clk,
+       &twi_clk,
+       &spi0_clk,
+       &spi1_clk,
+       // ssc
+       // tc0 .. tc2
+       &ohci_clk,
+       &ether_clk,
+       &isi_clk,
+       &usart3_clk,
+       &usart4_clk,
+       &usart5_clk,
+       // tc3 .. tc5
+       // irq0 .. irq2
+};
+
+/*
+ * The two programmable clocks.
+ * You must configure pin multiplexing to bring these signals out.
+ */
+static struct clk pck0 = {
+       .name           = "pck0",
+       .pmc_mask       = AT91_PMC_PCK0,
+       .type           = CLK_TYPE_PROGRAMMABLE,
+       .id             = 0,
+};
+static struct clk pck1 = {
+       .name           = "pck1",
+       .pmc_mask       = AT91_PMC_PCK1,
+       .type           = CLK_TYPE_PROGRAMMABLE,
+       .id             = 1,
+};
+
+static void __init at91sam9260_register_clocks(void)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
+               clk_register(periph_clocks[i]);
+
+       clk_register(&pck0);
+       clk_register(&pck1);
+}
+
+/* --------------------------------------------------------------------
+ *  GPIO
+ * -------------------------------------------------------------------- */
+
+static struct at91_gpio_bank at91sam9260_gpio[] = {
+       {
+               .id             = AT91SAM9260_ID_PIOA,
+               .offset         = AT91_PIOA,
+               .clock          = &pioA_clk,
+       }, {
+               .id             = AT91SAM9260_ID_PIOB,
+               .offset         = AT91_PIOB,
+               .clock          = &pioB_clk,
+       }, {
+               .id             = AT91SAM9260_ID_PIOC,
+               .offset         = AT91_PIOC,
+               .clock          = &pioC_clk,
+       }
+};
+
+static void at91sam9260_reset(void)
+{
+#warning "Implement CPU reset"
+}
+
+
+/* --------------------------------------------------------------------
+ *  AT91SAM9260 processor initialization
+ * -------------------------------------------------------------------- */
+
+void __init at91sam9260_initialize(unsigned long main_clock)
+{
+       /* Map peripherals */
+       iotable_init(at91sam9260_io_desc, ARRAY_SIZE(at91sam9260_io_desc));
+
+       at91_arch_reset = at91sam9260_reset;
+       at91_extern_irq = (1 << AT91SAM9260_ID_IRQ0) | (1 << AT91SAM9260_ID_IRQ1)
+                       | (1 << AT91SAM9260_ID_IRQ2);
+
+       /* Init clock subsystem */
+       at91_clock_init(main_clock);
+
+       /* Register the processor-specific clocks */
+       at91sam9260_register_clocks();
+
+       /* Register GPIO subsystem */
+       at91_gpio_init(at91sam9260_gpio, 3);
+}
+
+/* --------------------------------------------------------------------
+ *  Interrupt initialization
+ * -------------------------------------------------------------------- */
+
+/*
+ * The default interrupt priority levels (0 = lowest, 7 = highest).
+ */
+static unsigned int at91sam9260_default_irq_priority[NR_AIC_IRQS] __initdata = {
+       7,      /* Advanced Interrupt Controller */
+       7,      /* System Peripherals */
+       0,      /* Parallel IO Controller A */
+       0,      /* Parallel IO Controller B */
+       0,      /* Parallel IO Controller C */
+       0,      /* Analog-to-Digital Converter */
+       6,      /* USART 0 */
+       6,      /* USART 1 */
+       6,      /* USART 2 */
+       0,      /* Multimedia Card Interface */
+       4,      /* USB Device Port */
+       0,      /* Two-Wire Interface */
+       6,      /* Serial Peripheral Interface 0 */
+       6,      /* Serial Peripheral Interface 1 */
+       5,      /* Serial Synchronous Controller */
+       0,
+       0,
+       0,      /* Timer Counter 0 */
+       0,      /* Timer Counter 1 */
+       0,      /* Timer Counter 2 */
+       3,      /* USB Host port */
+       3,      /* Ethernet */
+       0,      /* Image Sensor Interface */
+       6,      /* USART 3 */
+       6,      /* USART 4 */
+       6,      /* USART 5 */
+       0,      /* Timer Counter 3 */
+       0,      /* Timer Counter 4 */
+       0,      /* Timer Counter 5 */
+       0,      /* Advanced Interrupt Controller */
+       0,      /* Advanced Interrupt Controller */
+       0,      /* Advanced Interrupt Controller */
+};
+
+void __init at91sam9260_init_interrupts(unsigned int priority[NR_AIC_IRQS])
+{
+       if (!priority)
+               priority = at91sam9260_default_irq_priority;
+
+       /* Initialize the AIC interrupt controller */
+       at91_aic_init(priority);
+
+       /* Enable GPIO interrupts */
+       at91_gpio_irq_setup();
+}
diff --git a/arch/arm/mach-at91rm9200/at91sam9260_devices.c b/arch/arm/mach-at91rm9200/at91sam9260_devices.c
new file mode 100644 (file)
index 0000000..a6c596d
--- /dev/null
@@ -0,0 +1,866 @@
+/*
+ * arch/arm/mach-at91rm9200/at91sam9260_devices.c
+ *
+ *  Copyright (C) 2006 Atmel
+ *
+ * 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 <asm/mach/arch.h>
+#include <asm/mach/map.h>
+
+#include <linux/platform_device.h>
+
+#include <asm/arch/board.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/at91sam9260.h>
+#include <asm/arch/at91sam926x_mc.h>
+
+#include "generic.h"
+
+#define SZ_512 0x00000200
+#define SZ_256 0x00000100
+#define SZ_16  0x00000010
+
+/* --------------------------------------------------------------------
+ *  USB Host
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
+static u64 ohci_dmamask = 0xffffffffUL;
+static struct at91_usbh_data usbh_data;
+
+static struct resource usbh_resources[] = {
+       [0] = {
+               .start  = AT91SAM9260_UHP_BASE,
+               .end    = AT91SAM9260_UHP_BASE + SZ_1M - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9260_ID_UHP,
+               .end    = AT91SAM9260_ID_UHP,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91_usbh_device = {
+       .name           = "at91_ohci",
+       .id             = -1,
+       .dev            = {
+                               .dma_mask               = &ohci_dmamask,
+                               .coherent_dma_mask      = 0xffffffff,
+                               .platform_data          = &usbh_data,
+       },
+       .resource       = usbh_resources,
+       .num_resources  = ARRAY_SIZE(usbh_resources),
+};
+
+void __init at91_add_device_usbh(struct at91_usbh_data *data)
+{
+       if (!data)
+               return;
+
+       usbh_data = *data;
+       platform_device_register(&at91_usbh_device);
+}
+#else
+void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ *  USB Device (Gadget)
+ * -------------------------------------------------------------------- */
+
+#ifdef CONFIG_USB_GADGET_AT91
+static struct at91_udc_data udc_data;
+
+static struct resource udc_resources[] = {
+       [0] = {
+               .start  = AT91SAM9260_BASE_UDP,
+               .end    = AT91SAM9260_BASE_UDP + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9260_ID_UDP,
+               .end    = AT91SAM9260_ID_UDP,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91_udc_device = {
+       .name           = "at91_udc",
+       .id             = -1,
+       .dev            = {
+                               .platform_data          = &udc_data,
+       },
+       .resource       = udc_resources,
+       .num_resources  = ARRAY_SIZE(udc_resources),
+};
+
+void __init at91_add_device_udc(struct at91_udc_data *data)
+{
+       if (!data)
+               return;
+
+       if (data->vbus_pin) {
+               at91_set_gpio_input(data->vbus_pin, 0);
+               at91_set_deglitch(data->vbus_pin, 1);
+       }
+
+       /* Pullup pin is handled internally by USB device peripheral */
+
+       udc_data = *data;
+       platform_device_register(&at91_udc_device);
+}
+#else
+void __init at91_add_device_udc(struct at91_udc_data *data) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ *  Ethernet
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
+static u64 eth_dmamask = 0xffffffffUL;
+static struct eth_platform_data eth_data;
+
+static struct resource eth_resources[] = {
+       [0] = {
+               .start  = AT91SAM9260_BASE_EMAC,
+               .end    = AT91SAM9260_BASE_EMAC + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9260_ID_EMAC,
+               .end    = AT91SAM9260_ID_EMAC,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91sam9260_eth_device = {
+       .name           = "macb",
+       .id             = -1,
+       .dev            = {
+                               .dma_mask               = &eth_dmamask,
+                               .coherent_dma_mask      = 0xffffffff,
+                               .platform_data          = &eth_data,
+       },
+       .resource       = eth_resources,
+       .num_resources  = ARRAY_SIZE(eth_resources),
+};
+
+void __init at91_add_device_eth(struct eth_platform_data *data)
+{
+       if (!data)
+               return;
+
+       if (data->phy_irq_pin) {
+               at91_set_gpio_input(data->phy_irq_pin, 0);
+               at91_set_deglitch(data->phy_irq_pin, 1);
+       }
+
+       /* Pins used for MII and RMII */
+       at91_set_A_periph(AT91_PIN_PA19, 0);    /* ETXCK_EREFCK */
+       at91_set_A_periph(AT91_PIN_PA17, 0);    /* ERXDV */
+       at91_set_A_periph(AT91_PIN_PA14, 0);    /* ERX0 */
+       at91_set_A_periph(AT91_PIN_PA15, 0);    /* ERX1 */
+       at91_set_A_periph(AT91_PIN_PA18, 0);    /* ERXER */
+       at91_set_A_periph(AT91_PIN_PA16, 0);    /* ETXEN */
+       at91_set_A_periph(AT91_PIN_PA12, 0);    /* ETX0 */
+       at91_set_A_periph(AT91_PIN_PA13, 0);    /* ETX1 */
+       at91_set_A_periph(AT91_PIN_PA21, 0);    /* EMDIO */
+       at91_set_A_periph(AT91_PIN_PA20, 0);    /* EMDC */
+
+       if (!data->is_rmii) {
+               at91_set_B_periph(AT91_PIN_PA28, 0);    /* ECRS */
+               at91_set_B_periph(AT91_PIN_PA29, 0);    /* ECOL */
+               at91_set_B_periph(AT91_PIN_PA25, 0);    /* ERX2 */
+               at91_set_B_periph(AT91_PIN_PA26, 0);    /* ERX3 */
+               at91_set_B_periph(AT91_PIN_PA27, 0);    /* ERXCK */
+               at91_set_B_periph(AT91_PIN_PA23, 0);    /* ETX2 */
+               at91_set_B_periph(AT91_PIN_PA24, 0);    /* ETX3 */
+               at91_set_B_periph(AT91_PIN_PA22, 0);    /* ETXER */
+       }
+
+       eth_data = *data;
+       platform_device_register(&at91sam9260_eth_device);
+}
+#else
+void __init at91_add_device_eth(struct eth_platform_data *data) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ *  MMC / SD
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
+static u64 mmc_dmamask = 0xffffffffUL;
+static struct at91_mmc_data mmc_data;
+
+static struct resource mmc_resources[] = {
+       [0] = {
+               .start  = AT91SAM9260_BASE_MCI,
+               .end    = AT91SAM9260_BASE_MCI + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9260_ID_MCI,
+               .end    = AT91SAM9260_ID_MCI,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91sam9260_mmc_device = {
+       .name           = "at91_mci",
+       .id             = -1,
+       .dev            = {
+                               .dma_mask               = &mmc_dmamask,
+                               .coherent_dma_mask      = 0xffffffff,
+                               .platform_data          = &mmc_data,
+       },
+       .resource       = mmc_resources,
+       .num_resources  = ARRAY_SIZE(mmc_resources),
+};
+
+void __init at91_add_device_mmc(struct at91_mmc_data *data)
+{
+       if (!data)
+               return;
+
+       /* input/irq */
+       if (data->det_pin) {
+               at91_set_gpio_input(data->det_pin, 1);
+               at91_set_deglitch(data->det_pin, 1);
+       }
+       if (data->wp_pin)
+               at91_set_gpio_input(data->wp_pin, 1);
+       if (data->vcc_pin)
+               at91_set_gpio_output(data->vcc_pin, 0);
+
+       /* CLK */
+       at91_set_A_periph(AT91_PIN_PA8, 0);
+
+       if (data->slot_b) {
+               /* CMD */
+               at91_set_B_periph(AT91_PIN_PA1, 1);
+
+               /* DAT0, maybe DAT1..DAT3 */
+               at91_set_B_periph(AT91_PIN_PA0, 1);
+               if (data->wire4) {
+                       at91_set_B_periph(AT91_PIN_PA5, 1);
+                       at91_set_B_periph(AT91_PIN_PA4, 1);
+                       at91_set_B_periph(AT91_PIN_PA3, 1);
+               }
+       } else {
+               /* CMD */
+               at91_set_A_periph(AT91_PIN_PA7, 1);
+
+               /* DAT0, maybe DAT1..DAT3 */
+               at91_set_A_periph(AT91_PIN_PA6, 1);
+               if (data->wire4) {
+                       at91_set_A_periph(AT91_PIN_PA9, 1);
+                       at91_set_A_periph(AT91_PIN_PA10, 1);
+                       at91_set_A_periph(AT91_PIN_PA11, 1);
+               }
+       }
+
+       mmc_data = *data;
+       platform_device_register(&at91sam9260_mmc_device);
+}
+#else
+void __init at91_add_device_mmc(struct at91_mmc_data *data) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ *  NAND / SmartMedia
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
+static struct at91_nand_data nand_data;
+
+#define NAND_BASE      AT91_CHIPSELECT_3
+
+static struct resource nand_resources[] = {
+       {
+               .start  = NAND_BASE,
+               .end    = NAND_BASE + SZ_8M - 1,
+               .flags  = IORESOURCE_MEM,
+       }
+};
+
+static struct platform_device at91sam9260_nand_device = {
+       .name           = "at91_nand",
+       .id             = -1,
+       .dev            = {
+                               .platform_data  = &nand_data,
+       },
+       .resource       = nand_resources,
+       .num_resources  = ARRAY_SIZE(nand_resources),
+};
+
+void __init at91_add_device_nand(struct at91_nand_data *data)
+{
+       unsigned long csa, mode;
+
+       if (!data)
+               return;
+
+       csa = at91_sys_read(AT91_MATRIX_EBICSA);
+       at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC);
+
+       /* set the bus interface characteristics */
+       at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0)
+                       | AT91_SMC_NRDSETUP_(0) | AT91_SMC_NCS_RDSETUP_(0));
+
+       at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(2) | AT91_SMC_NCS_WRPULSE_(5)
+                       | AT91_SMC_NRDPULSE_(2) | AT91_SMC_NCS_RDPULSE_(5));
+
+       at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(7) | AT91_SMC_NRDCYCLE_(7));
+
+       if (data->bus_width_16)
+               mode = AT91_SMC_DBW_16;
+       else
+               mode = AT91_SMC_DBW_8;
+       at91_sys_write(AT91_SMC_MODE(3), mode | AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_TDF_(1));
+
+       /* enable pin */
+       if (data->enable_pin)
+               at91_set_gpio_output(data->enable_pin, 1);
+
+       /* ready/busy pin */
+       if (data->rdy_pin)
+               at91_set_gpio_input(data->rdy_pin, 1);
+
+       /* card detect pin */
+       if (data->det_pin)
+               at91_set_gpio_input(data->det_pin, 1);
+
+       nand_data = *data;
+       platform_device_register(&at91sam9260_nand_device);
+}
+#else
+void __init at91_add_device_nand(struct at91_nand_data *data) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ *  TWI (i2c)
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
+
+static struct resource twi_resources[] = {
+       [0] = {
+               .start  = AT91SAM9260_BASE_TWI,
+               .end    = AT91SAM9260_BASE_TWI + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9260_ID_TWI,
+               .end    = AT91SAM9260_ID_TWI,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91sam9260_twi_device = {
+       .name           = "at91_i2c",
+       .id             = -1,
+       .resource       = twi_resources,
+       .num_resources  = ARRAY_SIZE(twi_resources),
+};
+
+void __init at91_add_device_i2c(void)
+{
+       /* pins used for TWI interface */
+       at91_set_A_periph(AT91_PIN_PA23, 0);            /* TWD */
+       at91_set_multi_drive(AT91_PIN_PA23, 1);
+
+       at91_set_A_periph(AT91_PIN_PA24, 0);            /* TWCK */
+       at91_set_multi_drive(AT91_PIN_PA24, 1);
+
+       platform_device_register(&at91sam9260_twi_device);
+}
+#else
+void __init at91_add_device_i2c(void) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ *  SPI
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
+static u64 spi_dmamask = 0xffffffffUL;
+
+static struct resource spi0_resources[] = {
+       [0] = {
+               .start  = AT91SAM9260_BASE_SPI0,
+               .end    = AT91SAM9260_BASE_SPI0 + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9260_ID_SPI0,
+               .end    = AT91SAM9260_ID_SPI0,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91sam9260_spi0_device = {
+       .name           = "atmel_spi",
+       .id             = 0,
+       .dev            = {
+                               .dma_mask               = &spi_dmamask,
+                               .coherent_dma_mask      = 0xffffffff,
+       },
+       .resource       = spi0_resources,
+       .num_resources  = ARRAY_SIZE(spi0_resources),
+};
+
+static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PC11, AT91_PIN_PC16, AT91_PIN_PC17 };
+
+static struct resource spi1_resources[] = {
+       [0] = {
+               .start  = AT91SAM9260_BASE_SPI1,
+               .end    = AT91SAM9260_BASE_SPI1 + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9260_ID_SPI1,
+               .end    = AT91SAM9260_ID_SPI1,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91sam9260_spi1_device = {
+       .name           = "atmel_spi",
+       .id             = 1,
+       .dev            = {
+                               .dma_mask               = &spi_dmamask,
+                               .coherent_dma_mask      = 0xffffffff,
+       },
+       .resource       = spi1_resources,
+       .num_resources  = ARRAY_SIZE(spi1_resources),
+};
+
+static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB3, AT91_PIN_PC5, AT91_PIN_PC4, AT91_PIN_PC3 };
+
+void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
+{
+       int i;
+       unsigned long cs_pin;
+       short enable_spi0 = 0;
+       short enable_spi1 = 0;
+
+       /* Choose SPI chip-selects */
+       for (i = 0; i < nr_devices; i++) {
+               if (devices[i].controller_data)
+                       cs_pin = (unsigned long) devices[i].controller_data;
+               else if (devices[i].bus_num == 0)
+                       cs_pin = spi0_standard_cs[devices[i].chip_select];
+               else
+                       cs_pin = spi1_standard_cs[devices[i].chip_select];
+
+               if (devices[i].bus_num == 0)
+                       enable_spi0 = 1;
+               else
+                       enable_spi1 = 1;
+
+               /* enable chip-select pin */
+               at91_set_gpio_output(cs_pin, 1);
+
+               /* pass chip-select pin to driver */
+               devices[i].controller_data = (void *) cs_pin;
+       }
+
+       spi_register_board_info(devices, nr_devices);
+
+       /* Configure SPI bus(es) */
+       if (enable_spi0) {
+               at91_set_A_periph(AT91_PIN_PA0, 0);     /* SPI0_MISO */
+               at91_set_A_periph(AT91_PIN_PA1, 0);     /* SPI0_MOSI */
+               at91_set_A_periph(AT91_PIN_PA2, 0);     /* SPI1_SPCK */
+
+               at91_clock_associate("spi0_clk", &at91sam9260_spi0_device.dev, "spi_clk");
+               platform_device_register(&at91sam9260_spi0_device);
+       }
+       if (enable_spi1) {
+               at91_set_A_periph(AT91_PIN_PB0, 0);     /* SPI1_MISO */
+               at91_set_A_periph(AT91_PIN_PB1, 0);     /* SPI1_MOSI */
+               at91_set_A_periph(AT91_PIN_PB2, 0);     /* SPI1_SPCK */
+
+               at91_clock_associate("spi1_clk", &at91sam9260_spi1_device.dev, "spi_clk");
+               platform_device_register(&at91sam9260_spi1_device);
+       }
+}
+#else
+void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ *  LEDs
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_LEDS)
+u8 at91_leds_cpu;
+u8 at91_leds_timer;
+
+void __init at91_init_leds(u8 cpu_led, u8 timer_led)
+{
+       at91_leds_cpu   = cpu_led;
+       at91_leds_timer = timer_led;
+}
+#else
+void __init at91_init_leds(u8 cpu_led, u8 timer_led) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ *  UART
+ * -------------------------------------------------------------------- */
+#if defined(CONFIG_SERIAL_ATMEL)
+static struct resource dbgu_resources[] = {
+       [0] = {
+               .start  = AT91_VA_BASE_SYS + AT91_DBGU,
+               .end    = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91_ID_SYS,
+               .end    = AT91_ID_SYS,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct atmel_uart_data dbgu_data = {
+       .use_dma_tx     = 0,
+       .use_dma_rx     = 0,            /* DBGU not capable of receive DMA */
+       .regs           = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
+};
+
+static struct platform_device at91sam9260_dbgu_device = {
+       .name           = "atmel_usart",
+       .id             = 0,
+       .dev            = {
+                               .platform_data  = &dbgu_data,
+                               .coherent_dma_mask = 0xffffffff,
+       },
+       .resource       = dbgu_resources,
+       .num_resources  = ARRAY_SIZE(dbgu_resources),
+};
+
+static inline void configure_dbgu_pins(void)
+{
+       at91_set_A_periph(AT91_PIN_PB14, 0);            /* DRXD */
+       at91_set_A_periph(AT91_PIN_PB15, 1);            /* DTXD */
+}
+
+static struct resource uart0_resources[] = {
+       [0] = {
+               .start  = AT91SAM9260_BASE_US0,
+               .end    = AT91SAM9260_BASE_US0 + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9260_ID_US0,
+               .end    = AT91SAM9260_ID_US0,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct atmel_uart_data uart0_data = {
+       .use_dma_tx     = 1,
+       .use_dma_rx     = 1,
+};
+
+static struct platform_device at91sam9260_uart0_device = {
+       .name           = "atmel_usart",
+       .id             = 1,
+       .dev            = {
+                               .platform_data  = &uart0_data,
+                               .coherent_dma_mask = 0xffffffff,
+       },
+       .resource       = uart0_resources,
+       .num_resources  = ARRAY_SIZE(uart0_resources),
+};
+
+static inline void configure_usart0_pins(void)
+{
+       at91_set_A_periph(AT91_PIN_PB4, 1);             /* TXD0 */
+       at91_set_A_periph(AT91_PIN_PB5, 0);             /* RXD0 */
+       at91_set_A_periph(AT91_PIN_PB26, 0);            /* RTS0 */
+       at91_set_A_periph(AT91_PIN_PB27, 0);            /* CTS0 */
+       at91_set_A_periph(AT91_PIN_PB24, 0);            /* DTR0 */
+       at91_set_A_periph(AT91_PIN_PB22, 0);            /* DSR0 */
+       at91_set_A_periph(AT91_PIN_PB23, 0);            /* DCD0 */
+       at91_set_A_periph(AT91_PIN_PB25, 0);            /* RI0 */
+}
+
+static struct resource uart1_resources[] = {
+       [0] = {
+               .start  = AT91SAM9260_BASE_US1,
+               .end    = AT91SAM9260_BASE_US1 + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9260_ID_US1,
+               .end    = AT91SAM9260_ID_US1,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct atmel_uart_data uart1_data = {
+       .use_dma_tx     = 1,
+       .use_dma_rx     = 1,
+};
+
+static struct platform_device at91sam9260_uart1_device = {
+       .name           = "atmel_usart",
+       .id             = 2,
+       .dev            = {
+                               .platform_data  = &uart1_data,
+                               .coherent_dma_mask = 0xffffffff,
+       },
+       .resource       = uart1_resources,
+       .num_resources  = ARRAY_SIZE(uart1_resources),
+};
+
+static inline void configure_usart1_pins(void)
+{
+       at91_set_A_periph(AT91_PIN_PB6, 1);             /* TXD1 */
+       at91_set_A_periph(AT91_PIN_PB7, 0);             /* RXD1 */
+       at91_set_A_periph(AT91_PIN_PB28, 0);            /* RTS1 */
+       at91_set_A_periph(AT91_PIN_PB29, 0);            /* CTS1 */
+}
+
+static struct resource uart2_resources[] = {
+       [0] = {
+               .start  = AT91SAM9260_BASE_US2,
+               .end    = AT91SAM9260_BASE_US2 + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9260_ID_US2,
+               .end    = AT91SAM9260_ID_US2,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct atmel_uart_data uart2_data = {
+       .use_dma_tx     = 1,
+       .use_dma_rx     = 1,
+};
+
+static struct platform_device at91sam9260_uart2_device = {
+       .name           = "atmel_usart",
+       .id             = 3,
+       .dev            = {
+                               .platform_data  = &uart2_data,
+                               .coherent_dma_mask = 0xffffffff,
+       },
+       .resource       = uart2_resources,
+       .num_resources  = ARRAY_SIZE(uart2_resources),
+};
+
+static inline void configure_usart2_pins(void)
+{
+       at91_set_A_periph(AT91_PIN_PB8, 1);             /* TXD2 */
+       at91_set_A_periph(AT91_PIN_PB9, 0);             /* RXD2 */
+}
+
+static struct resource uart3_resources[] = {
+       [0] = {
+               .start  = AT91SAM9260_BASE_US3,
+               .end    = AT91SAM9260_BASE_US3 + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9260_ID_US3,
+               .end    = AT91SAM9260_ID_US3,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct atmel_uart_data uart3_data = {
+       .use_dma_tx     = 1,
+       .use_dma_rx     = 1,
+};
+
+static struct platform_device at91sam9260_uart3_device = {
+       .name           = "atmel_usart",
+       .id             = 4,
+       .dev            = {
+                               .platform_data  = &uart3_data,
+                               .coherent_dma_mask = 0xffffffff,
+       },
+       .resource       = uart3_resources,
+       .num_resources  = ARRAY_SIZE(uart3_resources),
+};
+
+static inline void configure_usart3_pins(void)
+{
+       at91_set_A_periph(AT91_PIN_PB10, 1);            /* TXD3 */
+       at91_set_A_periph(AT91_PIN_PB11, 0);            /* RXD3 */
+}
+
+static struct resource uart4_resources[] = {
+       [0] = {
+               .start  = AT91SAM9260_BASE_US4,
+               .end    = AT91SAM9260_BASE_US4 + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9260_ID_US4,
+               .end    = AT91SAM9260_ID_US4,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct atmel_uart_data uart4_data = {
+       .use_dma_tx     = 1,
+       .use_dma_rx     = 1,
+};
+
+static struct platform_device at91sam9260_uart4_device = {
+       .name           = "atmel_usart",
+       .id             = 5,
+       .dev            = {
+                               .platform_data  = &uart4_data,
+                               .coherent_dma_mask = 0xffffffff,
+       },
+       .resource       = uart4_resources,
+       .num_resources  = ARRAY_SIZE(uart4_resources),
+};
+
+static inline void configure_usart4_pins(void)
+{
+       at91_set_B_periph(AT91_PIN_PA31, 1);            /* TXD4 */
+       at91_set_B_periph(AT91_PIN_PA30, 0);            /* RXD4 */
+}
+
+static struct resource uart5_resources[] = {
+       [0] = {
+               .start  = AT91SAM9260_BASE_US5,
+               .end    = AT91SAM9260_BASE_US5 + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9260_ID_US5,
+               .end    = AT91SAM9260_ID_US5,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct atmel_uart_data uart5_data = {
+       .use_dma_tx     = 1,
+       .use_dma_rx     = 1,
+};
+
+static struct platform_device at91sam9260_uart5_device = {
+       .name           = "atmel_usart",
+       .id             = 6,
+       .dev            = {
+                               .platform_data  = &uart5_data,
+                               .coherent_dma_mask = 0xffffffff,
+       },
+       .resource       = uart5_resources,
+       .num_resources  = ARRAY_SIZE(uart5_resources),
+};
+
+static inline void configure_usart5_pins(void)
+{
+       at91_set_A_periph(AT91_PIN_PB12, 1);            /* TXD5 */
+       at91_set_A_periph(AT91_PIN_PB13, 0);            /* RXD5 */
+}
+
+struct platform_device *at91_uarts[ATMEL_MAX_UART];    /* the UARTs to use */
+struct platform_device *atmel_default_console_device;  /* the serial console device */
+
+void __init at91_init_serial(struct at91_uart_config *config)
+{
+       int i;
+
+       /* Fill in list of supported UARTs */
+       for (i = 0; i < config->nr_tty; i++) {
+               switch (config->tty_map[i]) {
+                       case 0:
+                               configure_usart0_pins();
+                               at91_uarts[i] = &at91sam9260_uart0_device;
+                               at91_clock_associate("usart0_clk", &at91sam9260_uart0_device.dev, "usart");
+                               break;
+                       case 1:
+                               configure_usart1_pins();
+                               at91_uarts[i] = &at91sam9260_uart1_device;
+                               at91_clock_associate("usart1_clk", &at91sam9260_uart1_device.dev, "usart");
+                               break;
+                       case 2:
+                               configure_usart2_pins();
+                               at91_uarts[i] = &at91sam9260_uart2_device;
+                               at91_clock_associate("usart2_clk", &at91sam9260_uart2_device.dev, "usart");
+                               break;
+                       case 3:
+                               configure_usart3_pins();
+                               at91_uarts[i] = &at91sam9260_uart3_device;
+                               at91_clock_associate("usart3_clk", &at91sam9260_uart3_device.dev, "usart");
+                               break;
+                       case 4:
+                               configure_usart4_pins();
+                               at91_uarts[i] = &at91sam9260_uart4_device;
+                               at91_clock_associate("usart4_clk", &at91sam9260_uart4_device.dev, "usart");
+                               break;
+                       case 5:
+                               configure_usart5_pins();
+                               at91_uarts[i] = &at91sam9260_uart5_device;
+                               at91_clock_associate("usart5_clk", &at91sam9260_uart5_device.dev, "usart");
+                               break;
+                       case 6:
+                               configure_dbgu_pins();
+                               at91_uarts[i] = &at91sam9260_dbgu_device;
+                               at91_clock_associate("mck", &at91sam9260_dbgu_device.dev, "usart");
+                               break;
+                       default:
+                               continue;
+               }
+               at91_uarts[i]->id = i;          /* update ID number to mapped ID */
+       }
+
+       /* Set serial console device */
+       if (config->console_tty < ATMEL_MAX_UART)
+               atmel_default_console_device = at91_uarts[config->console_tty];
+       if (!atmel_default_console_device)
+               printk(KERN_INFO "AT91: No default serial console defined.\n");
+}
+
+void __init at91_add_device_serial(void)
+{
+       int i;
+
+       for (i = 0; i < ATMEL_MAX_UART; i++) {
+               if (at91_uarts[i])
+                       platform_device_register(at91_uarts[i]);
+       }
+}
+#else
+void __init at91_init_serial(struct at91_uart_config *config) {}
+void __init at91_add_device_serial(void) {}
+#endif
+
+
+/* -------------------------------------------------------------------- */
+/*
+ * These devices are always present and don't need any board-specific
+ * setup.
+ */
+static int __init at91_add_standard_devices(void)
+{
+       return 0;
+}
+
+arch_initcall(at91_add_standard_devices);
diff --git a/arch/arm/mach-at91rm9200/at91sam9261.c b/arch/arm/mach-at91rm9200/at91sam9261.c
new file mode 100644 (file)
index 0000000..5a82f35
--- /dev/null
@@ -0,0 +1,289 @@
+/*
+ * arch/arm/mach-at91rm9200/at91sam9261.c
+ *
+ *  Copyright (C) 2005 SAN People
+ *
+ * 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/module.h>
+
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+#include <asm/arch/at91sam9261.h>
+#include <asm/arch/at91_pmc.h>
+
+#include "generic.h"
+#include "clock.h"
+
+static struct map_desc at91sam9261_io_desc[] __initdata = {
+       {
+               .virtual        = AT91_VA_BASE_SYS,
+               .pfn            = __phys_to_pfn(AT91_BASE_SYS),
+               .length         = SZ_16K,
+               .type           = MT_DEVICE,
+       }, {
+               .virtual        = AT91_IO_VIRT_BASE - AT91SAM9261_SRAM_SIZE,
+               .pfn            = __phys_to_pfn(AT91SAM9261_SRAM_BASE),
+               .length         = AT91SAM9261_SRAM_SIZE,
+               .type           = MT_DEVICE,
+       },
+};
+
+/* --------------------------------------------------------------------
+ *  Clocks
+ * -------------------------------------------------------------------- */
+
+/*
+ * The peripheral clocks.
+ */
+static struct clk pioA_clk = {
+       .name           = "pioA_clk",
+       .pmc_mask       = 1 << AT91SAM9261_ID_PIOA,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk pioB_clk = {
+       .name           = "pioB_clk",
+       .pmc_mask       = 1 << AT91SAM9261_ID_PIOB,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk pioC_clk = {
+       .name           = "pioC_clk",
+       .pmc_mask       = 1 << AT91SAM9261_ID_PIOC,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk usart0_clk = {
+       .name           = "usart0_clk",
+       .pmc_mask       = 1 << AT91SAM9261_ID_US0,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk usart1_clk = {
+       .name           = "usart1_clk",
+       .pmc_mask       = 1 << AT91SAM9261_ID_US1,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk usart2_clk = {
+       .name           = "usart2_clk",
+       .pmc_mask       = 1 << AT91SAM9261_ID_US2,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk mmc_clk = {
+       .name           = "mci_clk",
+       .pmc_mask       = 1 << AT91SAM9261_ID_MCI,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk udc_clk = {
+       .name           = "udc_clk",
+       .pmc_mask       = 1 << AT91SAM9261_ID_UDP,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk twi_clk = {
+       .name           = "twi_clk",
+       .pmc_mask       = 1 << AT91SAM9261_ID_TWI,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk spi0_clk = {
+       .name           = "spi0_clk",
+       .pmc_mask       = 1 << AT91SAM9261_ID_SPI0,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk spi1_clk = {
+       .name           = "spi1_clk",
+       .pmc_mask       = 1 << AT91SAM9261_ID_SPI1,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk ohci_clk = {
+       .name           = "ohci_clk",
+       .pmc_mask       = 1 << AT91SAM9261_ID_UHP,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+static struct clk lcdc_clk = {
+       .name           = "lcdc_clk",
+       .pmc_mask       = 1 << AT91SAM9261_ID_LCDC,
+       .type           = CLK_TYPE_PERIPHERAL,
+};
+
+static struct clk *periph_clocks[] __initdata = {
+       &pioA_clk,
+       &pioB_clk,
+       &pioC_clk,
+       &usart0_clk,
+       &usart1_clk,
+       &usart2_clk,
+       &mmc_clk,
+       &udc_clk,
+       &twi_clk,
+       &spi0_clk,
+       &spi1_clk,
+       // ssc 0 .. ssc2
+       // tc0 .. tc2
+       &ohci_clk,
+       &lcdc_clk,
+       // irq0 .. irq2
+};
+
+/*
+ * The four programmable clocks.
+ * You must configure pin multiplexing to bring these signals out.
+ */
+static struct clk pck0 = {
+       .name           = "pck0",
+       .pmc_mask       = AT91_PMC_PCK0,
+       .type           = CLK_TYPE_PROGRAMMABLE,
+       .id             = 0,
+};
+static struct clk pck1 = {
+       .name           = "pck1",
+       .pmc_mask       = AT91_PMC_PCK1,
+       .type           = CLK_TYPE_PROGRAMMABLE,
+       .id             = 1,
+};
+static struct clk pck2 = {
+       .name           = "pck2",
+       .pmc_mask       = AT91_PMC_PCK2,
+       .type           = CLK_TYPE_PROGRAMMABLE,
+       .id             = 2,
+};
+static struct clk pck3 = {
+       .name           = "pck3",
+       .pmc_mask       = AT91_PMC_PCK3,
+       .type           = CLK_TYPE_PROGRAMMABLE,
+       .id             = 3,
+};
+
+/* HClocks */
+static struct clk hck0 = {
+       .name           = "hck0",
+       .pmc_mask       = AT91_PMC_HCK0,
+       .type           = CLK_TYPE_SYSTEM,
+       .id             = 0,
+};
+static struct clk hck1 = {
+       .name           = "hck1",
+       .pmc_mask       = AT91_PMC_HCK1,
+       .type           = CLK_TYPE_SYSTEM,
+       .id             = 1,
+};
+
+static void __init at91sam9261_register_clocks(void)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
+               clk_register(periph_clocks[i]);
+
+       clk_register(&pck0);
+       clk_register(&pck1);
+       clk_register(&pck2);
+       clk_register(&pck3);
+
+       clk_register(&hck0);
+       clk_register(&hck1);
+}
+
+/* --------------------------------------------------------------------
+ *  GPIO
+ * -------------------------------------------------------------------- */
+
+static struct at91_gpio_bank at91sam9261_gpio[] = {
+       {
+               .id             = AT91SAM9261_ID_PIOA,
+               .offset         = AT91_PIOA,
+               .clock          = &pioA_clk,
+       }, {
+               .id             = AT91SAM9261_ID_PIOB,
+               .offset         = AT91_PIOB,
+               .clock          = &pioB_clk,
+       }, {
+               .id             = AT91SAM9261_ID_PIOC,
+               .offset         = AT91_PIOC,
+               .clock          = &pioC_clk,
+       }
+};
+
+static void at91sam9261_reset(void)
+{
+#warning "Implement CPU reset"
+}
+
+
+/* --------------------------------------------------------------------
+ *  AT91SAM9261 processor initialization
+ * -------------------------------------------------------------------- */
+
+void __init at91sam9261_initialize(unsigned long main_clock)
+{
+       /* Map peripherals */
+       iotable_init(at91sam9261_io_desc, ARRAY_SIZE(at91sam9261_io_desc));
+
+       at91_arch_reset = at91sam9261_reset;
+       at91_extern_irq = (1 << AT91SAM9261_ID_IRQ0) | (1 << AT91SAM9261_ID_IRQ1)
+                       | (1 << AT91SAM9261_ID_IRQ2);
+
+       /* Init clock subsystem */
+       at91_clock_init(main_clock);
+
+       /* Register the processor-specific clocks */
+       at91sam9261_register_clocks();
+
+       /* Register GPIO subsystem */
+       at91_gpio_init(at91sam9261_gpio, 3);
+}
+
+/* --------------------------------------------------------------------
+ *  Interrupt initialization
+ * -------------------------------------------------------------------- */
+
+/*
+ * The default interrupt priority levels (0 = lowest, 7 = highest).
+ */
+static unsigned int at91sam9261_default_irq_priority[NR_AIC_IRQS] __initdata = {
+       7,      /* Advanced Interrupt Controller */
+       7,      /* System Peripherals */
+       0,      /* Parallel IO Controller A */
+       0,      /* Parallel IO Controller B */
+       0,      /* Parallel IO Controller C */
+       0,
+       6,      /* USART 0 */
+       6,      /* USART 1 */
+       6,      /* USART 2 */
+       0,      /* Multimedia Card Interface */
+       4,      /* USB Device Port */
+       0,      /* Two-Wire Interface */
+       6,      /* Serial Peripheral Interface 0 */
+       6,      /* Serial Peripheral Interface 1 */
+       5,      /* Serial Synchronous Controller 0 */
+       5,      /* Serial Synchronous Controller 1 */
+       5,      /* Serial Synchronous Controller 2 */
+       0,      /* Timer Counter 0 */
+       0,      /* Timer Counter 1 */
+       0,      /* Timer Counter 2 */
+       3,      /* USB Host port */
+       3,      /* LCD Controller */
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,      /* Advanced Interrupt Controller */
+       0,      /* Advanced Interrupt Controller */
+       0,      /* Advanced Interrupt Controller */
+};
+
+void __init at91sam9261_init_interrupts(unsigned int priority[NR_AIC_IRQS])
+{
+       if (!priority)
+               priority = at91sam9261_default_irq_priority;
+
+       /* Initialize the AIC interrupt controller */
+       at91_aic_init(priority);
+
+       /* Enable GPIO interrupts */
+       at91_gpio_irq_setup();
+}
diff --git a/arch/arm/mach-at91rm9200/at91sam9261_devices.c b/arch/arm/mach-at91rm9200/at91sam9261_devices.c
new file mode 100644 (file)
index 0000000..ed1d790
--- /dev/null
@@ -0,0 +1,741 @@
+/*
+ * arch/arm/mach-at91rm9200/at91sam9261_devices.c
+ *
+ *  Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org>
+ *  Copyright (C) 2005 David Brownell
+ *
+ * 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 <asm/mach/arch.h>
+#include <asm/mach/map.h>
+
+#include <linux/platform_device.h>
+
+#include <asm/arch/board.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/at91sam9261.h>
+#include <asm/arch/at91sam9261_matrix.h>
+#include <asm/arch/at91sam926x_mc.h>
+
+#include "generic.h"
+
+#define SZ_512 0x00000200
+#define SZ_256 0x00000100
+#define SZ_16  0x00000010
+
+/* --------------------------------------------------------------------
+ *  USB Host
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
+static u64 ohci_dmamask = 0xffffffffUL;
+static struct at91_usbh_data usbh_data;
+
+static struct resource usbh_resources[] = {
+       [0] = {
+               .start  = AT91SAM9261_UHP_BASE,
+               .end    = AT91SAM9261_UHP_BASE + SZ_1M - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9261_ID_UHP,
+               .end    = AT91SAM9261_ID_UHP,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91sam9261_usbh_device = {
+       .name           = "at91_ohci",
+       .id             = -1,
+       .dev            = {
+                               .dma_mask               = &ohci_dmamask,
+                               .coherent_dma_mask      = 0xffffffff,
+                               .platform_data          = &usbh_data,
+       },
+       .resource       = usbh_resources,
+       .num_resources  = ARRAY_SIZE(usbh_resources),
+};
+
+void __init at91_add_device_usbh(struct at91_usbh_data *data)
+{
+       if (!data)
+               return;
+
+       usbh_data = *data;
+       platform_device_register(&at91sam9261_usbh_device);
+}
+#else
+void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ *  USB Device (Gadget)
+ * -------------------------------------------------------------------- */
+
+#ifdef CONFIG_USB_GADGET_AT91
+static struct at91_udc_data udc_data;
+
+static struct resource udc_resources[] = {
+       [0] = {
+               .start  = AT91SAM9261_BASE_UDP,
+               .end    = AT91SAM9261_BASE_UDP + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9261_ID_UDP,
+               .end    = AT91SAM9261_ID_UDP,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91sam9261_udc_device = {
+       .name           = "at91_udc",
+       .id             = -1,
+       .dev            = {
+                               .platform_data          = &udc_data,
+       },
+       .resource       = udc_resources,
+       .num_resources  = ARRAY_SIZE(udc_resources),
+};
+
+void __init at91_add_device_udc(struct at91_udc_data *data)
+{
+       unsigned long x;
+
+       if (!data)
+               return;
+
+       if (data->vbus_pin) {
+               at91_set_gpio_input(data->vbus_pin, 0);
+               at91_set_deglitch(data->vbus_pin, 1);
+       }
+
+       /* Pullup pin is handled internally */
+       x = at91_sys_read(AT91_MATRIX_USBPUCR);
+       at91_sys_write(AT91_MATRIX_USBPUCR, x | AT91_MATRIX_USBPUCR_PUON);
+
+       udc_data = *data;
+       platform_device_register(&at91sam9261_udc_device);
+}
+#else
+void __init at91_add_device_udc(struct at91_udc_data *data) {}
+#endif
+
+/* --------------------------------------------------------------------
+ *  MMC / SD
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
+static u64 mmc_dmamask = 0xffffffffUL;
+static struct at91_mmc_data mmc_data;
+
+static struct resource mmc_resources[] = {
+       [0] = {
+               .start  = AT91SAM9261_BASE_MCI,
+               .end    = AT91SAM9261_BASE_MCI + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9261_ID_MCI,
+               .end    = AT91SAM9261_ID_MCI,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91sam9261_mmc_device = {
+       .name           = "at91_mci",
+       .id             = -1,
+       .dev            = {
+                               .dma_mask               = &mmc_dmamask,
+                               .coherent_dma_mask      = 0xffffffff,
+                               .platform_data          = &mmc_data,
+       },
+       .resource       = mmc_resources,
+       .num_resources  = ARRAY_SIZE(mmc_resources),
+};
+
+void __init at91_add_device_mmc(struct at91_mmc_data *data)
+{
+       if (!data)
+               return;
+
+       /* input/irq */
+       if (data->det_pin) {
+               at91_set_gpio_input(data->det_pin, 1);
+               at91_set_deglitch(data->det_pin, 1);
+       }
+       if (data->wp_pin)
+               at91_set_gpio_input(data->wp_pin, 1);
+       if (data->vcc_pin)
+               at91_set_gpio_output(data->vcc_pin, 0);
+
+       /* CLK */
+       at91_set_B_periph(AT91_PIN_PA2, 0);
+
+       /* CMD */
+       at91_set_B_periph(AT91_PIN_PA1, 1);
+
+       /* DAT0, maybe DAT1..DAT3 */
+       at91_set_B_periph(AT91_PIN_PA0, 1);
+       if (data->wire4) {
+               at91_set_B_periph(AT91_PIN_PA4, 1);
+               at91_set_B_periph(AT91_PIN_PA5, 1);
+               at91_set_B_periph(AT91_PIN_PA6, 1);
+       }
+
+       mmc_data = *data;
+       platform_device_register(&at91sam9261_mmc_device);
+}
+#else
+void __init at91_add_device_mmc(struct at91_mmc_data *data) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ *  NAND / SmartMedia
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
+static struct at91_nand_data nand_data;
+
+#define NAND_BASE      AT91_CHIPSELECT_3
+
+static struct resource nand_resources[] = {
+       {
+               .start  = NAND_BASE,
+               .end    = NAND_BASE + SZ_256M - 1,
+               .flags  = IORESOURCE_MEM,
+       }
+};
+
+static struct platform_device at91_nand_device = {
+       .name           = "at91_nand",
+       .id             = -1,
+       .dev            = {
+                               .platform_data  = &nand_data,
+       },
+       .resource       = nand_resources,
+       .num_resources  = ARRAY_SIZE(nand_resources),
+};
+
+void __init at91_add_device_nand(struct at91_nand_data *data)
+{
+       unsigned long csa, mode;
+
+       if (!data)
+               return;
+
+       csa = at91_sys_read(AT91_MATRIX_EBICSA);
+       at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC);
+
+       /* set the bus interface characteristics */
+       at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0)
+                       | AT91_SMC_NRDSETUP_(0) | AT91_SMC_NCS_RDSETUP_(0));
+
+       at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(2) | AT91_SMC_NCS_WRPULSE_(5)
+                       | AT91_SMC_NRDPULSE_(2) | AT91_SMC_NCS_RDPULSE_(5));
+
+       at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(7) | AT91_SMC_NRDCYCLE_(7));
+
+       if (data->bus_width_16)
+               mode = AT91_SMC_DBW_16;
+       else
+               mode = AT91_SMC_DBW_8;
+       at91_sys_write(AT91_SMC_MODE(3), mode | AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_TDF_(1));
+
+       /* enable pin */
+       if (data->enable_pin)
+               at91_set_gpio_output(data->enable_pin, 1);
+
+       /* ready/busy pin */
+       if (data->rdy_pin)
+               at91_set_gpio_input(data->rdy_pin, 1);
+
+       /* card detect pin */
+       if (data->det_pin)
+               at91_set_gpio_input(data->det_pin, 1);
+
+       at91_set_A_periph(AT91_PIN_PC0, 0);             /* NANDOE */
+       at91_set_A_periph(AT91_PIN_PC1, 0);             /* NANDWE */
+
+       nand_data = *data;
+       platform_device_register(&at91_nand_device);
+}
+
+#else
+void __init at91_add_device_nand(struct at91_nand_data *data) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ *  TWI (i2c)
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
+
+static struct resource twi_resources[] = {
+       [0] = {
+               .start  = AT91SAM9261_BASE_TWI,
+               .end    = AT91SAM9261_BASE_TWI + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9261_ID_TWI,
+               .end    = AT91SAM9261_ID_TWI,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91sam9261_twi_device = {
+       .name           = "at91_i2c",
+       .id             = -1,
+       .resource       = twi_resources,
+       .num_resources  = ARRAY_SIZE(twi_resources),
+};
+
+void __init at91_add_device_i2c(void)
+{
+       /* pins used for TWI interface */
+       at91_set_A_periph(AT91_PIN_PA7, 0);             /* TWD */
+       at91_set_multi_drive(AT91_PIN_PA7, 1);
+
+       at91_set_A_periph(AT91_PIN_PA8, 0);             /* TWCK */
+       at91_set_multi_drive(AT91_PIN_PA8, 1);
+
+       platform_device_register(&at91sam9261_twi_device);
+}
+#else
+void __init at91_add_device_i2c(void) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ *  SPI
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
+static u64 spi_dmamask = 0xffffffffUL;
+
+static struct resource spi0_resources[] = {
+       [0] = {
+               .start  = AT91SAM9261_BASE_SPI0,
+               .end    = AT91SAM9261_BASE_SPI0 + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9261_ID_SPI0,
+               .end    = AT91SAM9261_ID_SPI0,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91sam9261_spi0_device = {
+       .name           = "atmel_spi",
+       .id             = 0,
+       .dev            = {
+                               .dma_mask               = &spi_dmamask,
+                               .coherent_dma_mask      = 0xffffffff,
+       },
+       .resource       = spi0_resources,
+       .num_resources  = ARRAY_SIZE(spi0_resources),
+};
+
+static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PA5, AT91_PIN_PA6 };
+
+static struct resource spi1_resources[] = {
+       [0] = {
+               .start  = AT91SAM9261_BASE_SPI1,
+               .end    = AT91SAM9261_BASE_SPI1 + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9261_ID_SPI1,
+               .end    = AT91SAM9261_ID_SPI1,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91sam9261_spi1_device = {
+       .name           = "atmel_spi",
+       .id             = 1,
+       .dev            = {
+                               .dma_mask               = &spi_dmamask,
+                               .coherent_dma_mask      = 0xffffffff,
+       },
+       .resource       = spi1_resources,
+       .num_resources  = ARRAY_SIZE(spi1_resources),
+};
+
+static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB28, AT91_PIN_PA24, AT91_PIN_PA25, AT91_PIN_PA26 };
+
+void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
+{
+       int i;
+       unsigned long cs_pin;
+       short enable_spi0 = 0;
+       short enable_spi1 = 0;
+
+       /* Choose SPI chip-selects */
+       for (i = 0; i < nr_devices; i++) {
+               if (devices[i].controller_data)
+                       cs_pin = (unsigned long) devices[i].controller_data;
+               else if (devices[i].bus_num == 0)
+                       cs_pin = spi0_standard_cs[devices[i].chip_select];
+               else
+                       cs_pin = spi1_standard_cs[devices[i].chip_select];
+
+               if (devices[i].bus_num == 0)
+                       enable_spi0 = 1;
+               else
+                       enable_spi1 = 1;
+
+               /* enable chip-select pin */
+               at91_set_gpio_output(cs_pin, 1);
+
+               /* pass chip-select pin to driver */
+               devices[i].controller_data = (void *) cs_pin;
+       }
+
+       spi_register_board_info(devices, nr_devices);
+
+       /* Configure SPI bus(es) */
+       if (enable_spi0) {
+               at91_set_A_periph(AT91_PIN_PA0, 0);     /* SPI0_MISO */
+               at91_set_A_periph(AT91_PIN_PA1, 0);     /* SPI0_MOSI */
+               at91_set_A_periph(AT91_PIN_PA2, 0);     /* SPI0_SPCK */
+
+               at91_clock_associate("spi0_clk", &at91sam9261_spi0_device.dev, "spi_clk");
+               platform_device_register(&at91sam9261_spi0_device);
+       }
+       if (enable_spi1) {
+               at91_set_A_periph(AT91_PIN_PB30, 0);    /* SPI1_MISO */
+               at91_set_A_periph(AT91_PIN_PB31, 0);    /* SPI1_MOSI */
+               at91_set_A_periph(AT91_PIN_PB29, 0);    /* SPI1_SPCK */
+
+               at91_clock_associate("spi1_clk", &at91sam9261_spi1_device.dev, "spi_clk");
+               platform_device_register(&at91sam9261_spi1_device);
+       }
+}
+#else
+void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ *  LCD Controller
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_FB_AT91) || defined(CONFIG_FB_AT91_MODULE)
+static u64 lcdc_dmamask = 0xffffffffUL;
+static struct at91fb_info lcdc_data;
+
+static struct resource lcdc_resources[] = {
+       [0] = {
+               .start  = AT91SAM9261_LCDC_BASE,
+               .end    = AT91SAM9261_LCDC_BASE + SZ_4K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9261_ID_LCDC,
+               .end    = AT91SAM9261_ID_LCDC,
+               .flags  = IORESOURCE_IRQ,
+       },
+#if defined(CONFIG_FB_INTSRAM)
+       [2] = {
+               .start  = AT91SAM9261_SRAM_BASE,
+               .end    = AT91SAM9261_SRAM_BASE + AT91SAM9261_SRAM_SIZE - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+#endif
+};
+
+static struct platform_device at91_lcdc_device = {
+       .name           = "at91-fb",
+       .id             = 0,
+       .dev            = {
+                               .dma_mask               = &lcdc_dmamask,
+                               .coherent_dma_mask      = 0xffffffff,
+                               .platform_data          = &lcdc_data,
+       },
+       .resource       = lcdc_resources,
+       .num_resources  = ARRAY_SIZE(lcdc_resources),
+};
+
+void __init at91_add_device_lcdc(struct at91fb_info *data)
+{
+       if (!data) {
+               return;
+       }
+
+       at91_set_A_periph(AT91_PIN_PB1, 0);     /* LCDHSYNC */
+       at91_set_A_periph(AT91_PIN_PB2, 0);     /* LCDDOTCK */
+       at91_set_A_periph(AT91_PIN_PB3, 0);     /* LCDDEN */
+       at91_set_A_periph(AT91_PIN_PB4, 0);     /* LCDCC */
+       at91_set_A_periph(AT91_PIN_PB7, 0);     /* LCDD2 */
+       at91_set_A_periph(AT91_PIN_PB8, 0);     /* LCDD3 */
+       at91_set_A_periph(AT91_PIN_PB9, 0);     /* LCDD4 */
+       at91_set_A_periph(AT91_PIN_PB10, 0);    /* LCDD5 */
+       at91_set_A_periph(AT91_PIN_PB11, 0);    /* LCDD6 */
+       at91_set_A_periph(AT91_PIN_PB12, 0);    /* LCDD7 */
+       at91_set_A_periph(AT91_PIN_PB15, 0);    /* LCDD10 */
+       at91_set_A_periph(AT91_PIN_PB16, 0);    /* LCDD11 */
+       at91_set_A_periph(AT91_PIN_PB17, 0);    /* LCDD12 */
+       at91_set_A_periph(AT91_PIN_PB18, 0);    /* LCDD13 */
+       at91_set_A_periph(AT91_PIN_PB19, 0);    /* LCDD14 */
+       at91_set_A_periph(AT91_PIN_PB20, 0);    /* LCDD15 */
+       at91_set_B_periph(AT91_PIN_PB23, 0);    /* LCDD18 */
+       at91_set_B_periph(AT91_PIN_PB24, 0);    /* LCDD19 */
+       at91_set_B_periph(AT91_PIN_PB25, 0);    /* LCDD20 */
+       at91_set_B_periph(AT91_PIN_PB26, 0);    /* LCDD21 */
+       at91_set_B_periph(AT91_PIN_PB27, 0);    /* LCDD22 */
+       at91_set_B_periph(AT91_PIN_PB28, 0);    /* LCDD23 */
+
+       lcdc_data = *data;
+       platform_device_register(&at91_lcdc_device);
+}
+#else
+void __init at91_add_device_lcdc(struct at91fb_info *data) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ *  LEDs
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_LEDS)
+u8 at91_leds_cpu;
+u8 at91_leds_timer;
+
+void __init at91_init_leds(u8 cpu_led, u8 timer_led)
+{
+       at91_leds_cpu   = cpu_led;
+       at91_leds_timer = timer_led;
+}
+#else
+void __init at91_init_leds(u8 cpu_led, u8 timer_led) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ *  UART
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_SERIAL_ATMEL)
+static struct resource dbgu_resources[] = {
+       [0] = {
+               .start  = AT91_VA_BASE_SYS + AT91_DBGU,
+               .end    = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91_ID_SYS,
+               .end    = AT91_ID_SYS,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct atmel_uart_data dbgu_data = {
+       .use_dma_tx     = 0,
+       .use_dma_rx     = 0,            /* DBGU not capable of receive DMA */
+       .regs           = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
+};
+
+static struct platform_device at91sam9261_dbgu_device = {
+       .name           = "atmel_usart",
+       .id             = 0,
+       .dev            = {
+                               .platform_data  = &dbgu_data,
+                               .coherent_dma_mask = 0xffffffff,
+       },
+       .resource       = dbgu_resources,
+       .num_resources  = ARRAY_SIZE(dbgu_resources),
+};
+
+static inline void configure_dbgu_pins(void)
+{
+       at91_set_A_periph(AT91_PIN_PA9, 0);             /* DRXD */
+       at91_set_A_periph(AT91_PIN_PA10, 1);            /* DTXD */
+}
+
+static struct resource uart0_resources[] = {
+       [0] = {
+               .start  = AT91SAM9261_BASE_US0,
+               .end    = AT91SAM9261_BASE_US0 + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9261_ID_US0,
+               .end    = AT91SAM9261_ID_US0,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct atmel_uart_data uart0_data = {
+       .use_dma_tx     = 1,
+       .use_dma_rx     = 1,
+};
+
+static struct platform_device at91sam9261_uart0_device = {
+       .name           = "atmel_usart",
+       .id             = 1,
+       .dev            = {
+                               .platform_data  = &uart0_data,
+                               .coherent_dma_mask = 0xffffffff,
+       },
+       .resource       = uart0_resources,
+       .num_resources  = ARRAY_SIZE(uart0_resources),
+};
+
+static inline void configure_usart0_pins(void)
+{
+       at91_set_A_periph(AT91_PIN_PC8, 1);             /* TXD0 */
+       at91_set_A_periph(AT91_PIN_PC9, 0);             /* RXD0 */
+       at91_set_A_periph(AT91_PIN_PC10, 0);            /* RTS0 */
+       at91_set_A_periph(AT91_PIN_PC11, 0);            /* CTS0 */
+}
+
+static struct resource uart1_resources[] = {
+       [0] = {
+               .start  = AT91SAM9261_BASE_US1,
+               .end    = AT91SAM9261_BASE_US1 + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9261_ID_US1,
+               .end    = AT91SAM9261_ID_US1,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct atmel_uart_data uart1_data = {
+       .use_dma_tx     = 1,
+       .use_dma_rx     = 1,
+};
+
+static struct platform_device at91sam9261_uart1_device = {
+       .name           = "atmel_usart",
+       .id             = 2,
+       .dev            = {
+                               .platform_data  = &uart1_data,
+                               .coherent_dma_mask = 0xffffffff,
+       },
+       .resource       = uart1_resources,
+       .num_resources  = ARRAY_SIZE(uart1_resources),
+};
+
+static inline void configure_usart1_pins(void)
+{
+       at91_set_A_periph(AT91_PIN_PC12, 1);            /* TXD1 */
+       at91_set_A_periph(AT91_PIN_PC13, 0);            /* RXD1 */
+}
+
+static struct resource uart2_resources[] = {
+       [0] = {
+               .start  = AT91SAM9261_BASE_US2,
+               .end    = AT91SAM9261_BASE_US2 + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9261_ID_US2,
+               .end    = AT91SAM9261_ID_US2,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct atmel_uart_data uart2_data = {
+       .use_dma_tx     = 1,
+       .use_dma_rx     = 1,
+};
+
+static struct platform_device at91sam9261_uart2_device = {
+       .name           = "atmel_usart",
+       .id             = 3,
+       .dev            = {
+                               .platform_data  = &uart2_data,
+                               .coherent_dma_mask = 0xffffffff,
+       },
+       .resource       = uart2_resources,
+       .num_resources  = ARRAY_SIZE(uart2_resources),
+};
+
+static inline void configure_usart2_pins(void)
+{
+       at91_set_A_periph(AT91_PIN_PC15, 0);            /* RXD2 */
+       at91_set_A_periph(AT91_PIN_PC14, 1);            /* TXD2 */
+}
+
+struct platform_device *at91_uarts[ATMEL_MAX_UART];    /* the UARTs to use */
+struct platform_device *atmel_default_console_device;  /* the serial console device */
+
+void __init at91_init_serial(struct at91_uart_config *config)
+{
+       int i;
+
+       /* Fill in list of supported UARTs */
+       for (i = 0; i < config->nr_tty; i++) {
+               switch (config->tty_map[i]) {
+                       case 0:
+                               configure_usart0_pins();
+                               at91_uarts[i] = &at91sam9261_uart0_device;
+                               at91_clock_associate("usart0_clk", &at91sam9261_uart0_device.dev, "usart");
+                               break;
+                       case 1:
+                               configure_usart1_pins();
+                               at91_uarts[i] = &at91sam9261_uart1_device;
+                               at91_clock_associate("usart1_clk", &at91sam9261_uart1_device.dev, "usart");
+                               break;
+                       case 2:
+                               configure_usart2_pins();
+                               at91_uarts[i] = &at91sam9261_uart2_device;
+                               at91_clock_associate("usart2_clk", &at91sam9261_uart2_device.dev, "usart");
+                               break;
+                       case 3:
+                               configure_dbgu_pins();
+                               at91_uarts[i] = &at91sam9261_dbgu_device;
+                               at91_clock_associate("mck", &at91sam9261_dbgu_device.dev, "usart");
+                               break;
+                       default:
+                               continue;
+               }
+               at91_uarts[i]->id = i;          /* update ID number to mapped ID */
+       }
+
+       /* Set serial console device */
+       if (config->console_tty < ATMEL_MAX_UART)
+               atmel_default_console_device = at91_uarts[config->console_tty];
+       if (!atmel_default_console_device)
+               printk(KERN_INFO "AT91: No default serial console defined.\n");
+}
+
+void __init at91_add_device_serial(void)
+{
+       int i;
+
+       for (i = 0; i < ATMEL_MAX_UART; i++) {
+               if (at91_uarts[i])
+                       platform_device_register(at91_uarts[i]);
+       }
+}
+#else
+void __init at91_init_serial(struct at91_uart_config *config) {}
+void __init at91_add_device_serial(void) {}
+#endif
+
+
+/* -------------------------------------------------------------------- */
+
+/*
+ * These devices are always present and don't need any board-specific
+ * setup.
+ */
+static int __init at91_add_standard_devices(void)
+{
+       return 0;
+}
+
+arch_initcall(at91_add_standard_devices);
diff --git a/arch/arm/mach-at91rm9200/at91sam926x_time.c b/arch/arm/mach-at91rm9200/at91sam926x_time.c
new file mode 100644 (file)
index 0000000..99df5f6
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * linux/arch/arm/mach-at91rm9200/at91sam926x_time.c
+ *
+ * Copyright (C) 2005-2006 M. Amine SAYA, ATMEL Rousset, France
+ * Revision     2005 M. Nicolas Diremdjian, ATMEL Rousset, France
+ *
+ * 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/init.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/time.h>
+
+#include <asm/hardware.h>
+#include <asm/io.h>
+#include <asm/mach/time.h>
+
+#include <asm/arch/at91_pit.h>
+
+
+#define PIT_CPIV(x)    ((x) & AT91_PIT_CPIV)
+#define PIT_PICNT(x)   (((x) & AT91_PIT_PICNT) >> 20)
+
+/*
+ * Returns number of microseconds since last timer interrupt.  Note that interrupts
+ * will have been disabled by do_gettimeofday()
+ *  'LATCH' is hwclock ticks (see CLOCK_TICK_RATE in timex.h) per jiffy.
+ *  'tick' is usecs per jiffy (linux/timex.h).
+ */
+static unsigned long at91sam926x_gettimeoffset(void)
+{
+       unsigned long elapsed;
+       unsigned long t = at91_sys_read(AT91_PIT_PIIR);
+
+       elapsed = (PIT_PICNT(t) * LATCH) + PIT_CPIV(t);         /* hardware clock cycles */
+
+       return (unsigned long)(elapsed * 1000000) / LATCH;
+}
+
+/*
+ * IRQ handler for the timer.
+ */
+static irqreturn_t at91sam926x_timer_interrupt(int irq, void *dev_id)
+{
+       volatile long nr_ticks;
+
+       if (at91_sys_read(AT91_PIT_SR) & AT91_PIT_PITS) {       /* This is a shared interrupt */
+               write_seqlock(&xtime_lock);
+
+               /* Get number to ticks performed before interrupt and clear PIT interrupt */
+               nr_ticks = PIT_PICNT(at91_sys_read(AT91_PIT_PIVR));
+               do {
+                       timer_tick();
+                       nr_ticks--;
+               } while (nr_ticks);
+
+               write_sequnlock(&xtime_lock);
+               return IRQ_HANDLED;
+       } else
+               return IRQ_NONE;                /* not handled */
+}
+
+static struct irqaction at91sam926x_timer_irq = {
+       .name           = "at91_tick",
+       .flags          = IRQF_SHARED | IRQF_DISABLED | IRQF_TIMER,
+       .handler        = at91sam926x_timer_interrupt
+};
+
+void at91sam926x_timer_reset(void)
+{
+       /* Disable timer */
+       at91_sys_write(AT91_PIT_MR, 0);
+
+       /* Clear any pending interrupts */
+       (void) at91_sys_read(AT91_PIT_PIVR);
+
+       /* Set Period Interval timer and enable its interrupt */
+       at91_sys_write(AT91_PIT_MR, (LATCH & AT91_PIT_PIV) | AT91_PIT_PITIEN | AT91_PIT_PITEN);
+}
+
+/*
+ * Set up timer interrupt.
+ */
+void __init at91sam926x_timer_init(void)
+{
+       /* Initialize and enable the timer */
+       at91sam926x_timer_reset();
+
+       /* Make IRQs happen for the system timer. */
+       setup_irq(AT91_ID_SYS, &at91sam926x_timer_irq);
+}
+
+#ifdef CONFIG_PM
+static void at91sam926x_timer_suspend(void)
+{
+       /* Disable timer */
+       at91_sys_write(AT91_PIT_MR, 0);
+}
+#else
+#define at91sam926x_timer_suspend      NULL
+#endif
+
+struct sys_timer at91sam926x_timer = {
+       .init           = at91sam926x_timer_init,
+       .offset         = at91sam926x_gettimeoffset,
+       .suspend        = at91sam926x_timer_suspend,
+       .resume         = at91sam926x_timer_reset,
+};
+
index 98208740e7c52f1be6aa1f5d9a62c655fa7cd92c..654f0379550aef5d2e26a52d7c989b858dddf1c6 100644 (file)
@@ -65,7 +65,6 @@ static void __init carmeva_init_irq(void)
        at91rm9200_init_interrupts(NULL);
 }
 
-
 static struct at91_eth_data __initdata carmeva_eth_data = {
        .phy_irq_pin    = AT91_PIN_PC4,
        .is_rmii        = 1,
@@ -89,8 +88,33 @@ static struct at91_udc_data __initdata carmeva_udc_data = {
 // };
 
 static struct at91_mmc_data __initdata carmeva_mmc_data = {
-       .is_b           = 0,
+       .slot_b         = 0,
        .wire4          = 1,
+       .det_pin        = AT91_PIN_PB10,
+       .wp_pin         = AT91_PIN_PC14,
+};
+
+static struct spi_board_info carmeva_spi_devices[] = {
+       { /* DataFlash chip */
+               .modalias = "mtd_dataflash",
+               .chip_select  = 0,
+               .max_speed_hz = 10 * 1000 * 1000,
+       },
+       { /* User accessable spi - cs1 (250KHz) */
+               .modalias = "spi-cs1",
+               .chip_select  = 1,
+               .max_speed_hz = 250 *  1000,
+       },
+       { /* User accessable spi - cs2 (1MHz) */
+               .modalias = "spi-cs2",
+               .chip_select  = 2,
+               .max_speed_hz = 1 * 1000 *  1000,
+       },
+       { /* User accessable spi - cs3 (10MHz) */
+               .modalias = "spi-cs3",
+               .chip_select  = 3,
+               .max_speed_hz = 10 * 1000 *  1000,
+       },
 };
 
 static void __init carmeva_board_init(void)
@@ -105,10 +129,10 @@ static void __init carmeva_board_init(void)
        at91_add_device_udc(&carmeva_udc_data);
        /* I2C */
        at91_add_device_i2c();
+       /* SPI */
+       at91_add_device_spi(carmeva_spi_devices, ARRAY_SIZE(carmeva_spi_devices));
        /* Compact Flash */
 //     at91_add_device_cf(&carmeva_cf_data);
-       /* SPI */
-//     at91_add_device_spi(NULL, 0);
        /* MMC */
        at91_add_device_mmc(&carmeva_mmc_data);
 }
index 8eeae491ce712c83d714b99c8ffa72b5c58fee48..b8bb8052607a8f44342c27d56e8fdf818d1372e4 100644 (file)
@@ -99,7 +99,7 @@ static struct at91_cf_data __initdata csb337_cf_data = {
 
 static struct at91_mmc_data __initdata csb337_mmc_data = {
        .det_pin        = AT91_PIN_PD5,
-       .is_b           = 0,
+       .slot_b         = 0,
        .wire4          = 1,
        .wp_pin         = AT91_PIN_PD6,
 };
index c699f3984d4b086b25820257b2c6a11c9172cffd..7522bf91bce86adfcd4ad3828f9f5980aeb04129 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
+#include <linux/mtd/physmap.h>
 
 #include <asm/hardware.h>
 #include <asm/setup.h>
@@ -39,6 +40,7 @@
 
 #include <asm/arch/board.h>
 #include <asm/arch/gpio.h>
+#include <asm/arch/at91rm9200_mc.h>
 
 #include "generic.h"
 
@@ -93,7 +95,7 @@ static struct at91_cf_data __initdata dk_cf_data = {
 };
 
 static struct at91_mmc_data __initdata dk_mmc_data = {
-       .is_b           = 0,
+       .slot_b         = 0,
        .wire4          = 1,
 };
 
@@ -145,6 +147,30 @@ static struct at91_nand_data __initdata dk_nand_data = {
        .partition_info = nand_partitions,
 };
 
+#define DK_FLASH_BASE  AT91_CHIPSELECT_0
+#define DK_FLASH_SIZE  0x200000
+
+static struct physmap_flash_data dk_flash_data = {
+       .width  = 2,
+};
+
+static struct resource dk_flash_resource = {
+       .start          = DK_FLASH_BASE,
+       .end            = DK_FLASH_BASE + DK_FLASH_SIZE - 1,
+       .flags          = IORESOURCE_MEM,
+};
+
+static struct platform_device dk_flash = {
+       .name           = "physmap-flash",
+       .id             = 0,
+       .dev            = {
+                               .platform_data  = &dk_flash_data,
+                       },
+       .resource       = &dk_flash_resource,
+       .num_resources  = 1,
+};
+
+
 static void __init dk_board_init(void)
 {
        /* Serial */
@@ -172,6 +198,8 @@ static void __init dk_board_init(void)
 #endif
        /* NAND */
        at91_add_device_nand(&dk_nand_data);
+       /* NOR Flash */
+       platform_device_register(&dk_flash);
        /* VGA */
 //     dk_add_device_video();
 }
index 65e867ba2df371795177a3256eeb73eff0e576be..80b72cf7264cc104766333dc1fb23379bc9041e7 100644 (file)
@@ -87,7 +87,7 @@ static struct at91_cf_data __initdata eb9200_cf_data = {
 };
 
 static struct at91_mmc_data __initdata eb9200_mmc_data = {
-       .is_b           = 0,
+       .slot_b         = 0,
        .wire4          = 1,
 };
 
index 830eb7932178dee09e72c554cc8fddfa72e70d9f..c4fdb415f20e435e3bf093adc4320b4e2b2ca272 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
+#include <linux/mtd/physmap.h>
 
 #include <asm/hardware.h>
 #include <asm/setup.h>
@@ -39,6 +40,7 @@
 
 #include <asm/arch/board.h>
 #include <asm/arch/gpio.h>
+#include <asm/arch/at91rm9200_mc.h>
 
 #include "generic.h"
 
@@ -87,7 +89,7 @@ static struct at91_udc_data __initdata ek_udc_data = {
 
 static struct at91_mmc_data __initdata ek_mmc_data = {
        .det_pin        = AT91_PIN_PB27,
-       .is_b           = 0,
+       .slot_b         = 0,
        .wire4          = 1,
        .wp_pin         = AT91_PIN_PA17,
 };
@@ -107,6 +109,30 @@ static struct spi_board_info ek_spi_devices[] = {
 #endif
 };
 
+#define EK_FLASH_BASE  AT91_CHIPSELECT_0
+#define EK_FLASH_SIZE  0x200000
+
+static struct physmap_flash_data ek_flash_data = {
+       .width  = 2,
+};
+
+static struct resource ek_flash_resource = {
+       .start          = EK_FLASH_BASE,
+       .end            = EK_FLASH_BASE + EK_FLASH_SIZE - 1,
+       .flags          = IORESOURCE_MEM,
+};
+
+static struct platform_device ek_flash = {
+       .name           = "physmap-flash",
+       .id             = 0,
+       .dev            = {
+                               .platform_data  = &ek_flash_data,
+                       },
+       .resource       = &ek_flash_resource,
+       .num_resources  = 1,
+};
+
+
 static void __init ek_board_init(void)
 {
        /* Serial */
@@ -130,6 +156,8 @@ static void __init ek_board_init(void)
        at91_set_gpio_output(AT91_PIN_PB22, 1); /* this MMC card slot can optionally use SPI signaling (CS3). */
        at91_add_device_mmc(&ek_mmc_data);
 #endif
+       /* NOR Flash */
+       platform_device_register(&ek_flash);
        /* VGA */
 //     ek_add_device_video();
 }
index 35a954a44b1b9d6f7f7749dc217a0af26785f58d..759d8191854f3b6e6976da422572a981bce21c5b 100644 (file)
@@ -84,7 +84,7 @@ static struct at91_udc_data __initdata kb9202_udc_data = {
 
 static struct at91_mmc_data __initdata kb9202_mmc_data = {
        .det_pin        = AT91_PIN_PB2,
-       .is_b           = 0,
+       .slot_b         = 0,
        .wire4          = 1,
 };
 
diff --git a/arch/arm/mach-at91rm9200/board-sam9260ek.c b/arch/arm/mach-at91rm9200/board-sam9260ek.c
new file mode 100644 (file)
index 0000000..ffca9bd
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ * linux/arch/arm/mach-at91rm9200/board-ek.c
+ *
+ *  Copyright (C) 2005 SAN People
+ *  Copyright (C) 2006 Atmel
+ *
+ * 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
+ */
+
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/spi/spi.h>
+
+#include <asm/hardware.h>
+#include <asm/setup.h>
+#include <asm/mach-types.h>
+#include <asm/irq.h>
+
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+#include <asm/mach/irq.h>
+
+#include <asm/arch/board.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/at91sam926x_mc.h>
+
+#include "generic.h"
+
+
+/*
+ * Serial port configuration.
+ *    0 .. 5 = USART0 .. USART5
+ *    6      = DBGU
+ */
+static struct at91_uart_config __initdata ek_uart_config = {
+       .console_tty    = 0,                            /* ttyS0 */
+       .nr_tty         = 3,
+       .tty_map        = { 6, 0, 1, -1, -1, -1, -1 }   /* ttyS0, ..., ttyS6 */
+};
+
+static void __init ek_map_io(void)
+{
+       /* Initialize processor: 18.432 MHz crystal */
+       at91sam9260_initialize(18432000);
+
+       /* Setup the serial ports and console */
+       at91_init_serial(&ek_uart_config);
+}
+
+static void __init ek_init_irq(void)
+{
+       at91sam9260_init_interrupts(NULL);
+}
+
+
+/*
+ * USB Host port
+ */
+static struct at91_usbh_data __initdata ek_usbh_data = {
+       .ports          = 2,
+};
+
+/*
+ * USB Device port
+ */
+static struct at91_udc_data __initdata ek_udc_data = {
+       .vbus_pin       = AT91_PIN_PC5,
+       .pullup_pin     = 0,            /* pull-up driven by UDC */
+};
+
+
+/*
+ * SPI devices.
+ */
+static struct spi_board_info ek_spi_devices[] = {
+#if !defined(CONFIG_MMC_AT91)
+       {       /* DataFlash chip */
+               .modalias       = "mtd_dataflash",
+               .chip_select    = 1,
+               .max_speed_hz   = 15 * 1000 * 1000,
+               .bus_num        = 0,
+       },
+#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
+       {       /* DataFlash card */
+               .modalias       = "mtd_dataflash",
+               .chip_select    = 0,
+               .max_speed_hz   = 15 * 1000 * 1000,
+               .bus_num        = 0,
+       },
+#endif
+#endif
+#if defined(CONFIG_SND_AT73C213)
+       {       /* AT73C213 DAC */
+               .modalias       = "snd_at73c213",
+               .chip_select    = 0,
+               .max_speed_hz   = 10 * 1000 * 1000,
+               .bus_num        = 1,
+       },
+#endif
+};
+
+
+/*
+ * MACB Ethernet device
+ */
+static struct __initdata eth_platform_data ek_macb_data = {
+       .is_rmii        = 1,
+};
+
+
+/*
+ * NAND flash
+ */
+static struct mtd_partition __initdata ek_nand_partition[] = {
+       {
+               .name   = "Partition 1",
+               .offset = 0,
+               .size   = 256 * 1024,
+       },
+       {
+               .name   = "Partition 2",
+               .offset = 256 * 1024,
+               .size   = MTDPART_SIZ_FULL,
+       },
+};
+
+static struct mtd_partition *nand_partitions(int size, int *num_partitions)
+{
+       *num_partitions = ARRAY_SIZE(ek_nand_partition);
+       return ek_nand_partition;
+}
+
+static struct at91_nand_data __initdata ek_nand_data = {
+       .ale            = 21,
+       .cle            = 22,
+//     .det_pin        = ... not connected
+       .rdy_pin        = AT91_PIN_PC13,
+       .enable_pin     = AT91_PIN_PC14,
+       .partition_info = nand_partitions,
+#if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
+       .bus_width_16   = 1,
+#else
+       .bus_width_16   = 0,
+#endif
+};
+
+
+/*
+ * MCI (SD/MMC)
+ */
+static struct at91_mmc_data __initdata ek_mmc_data = {
+       .slot_b         = 1,
+       .wire4          = 1,
+//     .det_pin        = ... not connected
+//     .wp_pin         = ... not connected
+//     .vcc_pin        = ... not connected
+};
+
+static void __init ek_board_init(void)
+{
+       /* Serial */
+       at91_add_device_serial();
+       /* USB Host */
+       at91_add_device_usbh(&ek_usbh_data);
+       /* USB Device */
+       at91_add_device_udc(&ek_udc_data);
+       /* SPI */
+       at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
+       /* NAND */
+       at91_add_device_nand(&ek_nand_data);
+       /* Ethernet */
+       at91_add_device_eth(&ek_macb_data);
+       /* MMC */
+       at91_add_device_mmc(&ek_mmc_data);
+}
+
+MACHINE_START(AT91SAM9260EK, "Atmel AT91SAM9260-EK")
+       /* Maintainer: Atmel */
+       .phys_io        = AT91_BASE_SYS,
+       .io_pg_offst    = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
+       .boot_params    = AT91_SDRAM_BASE + 0x100,
+       .timer          = &at91sam926x_timer,
+       .map_io         = ek_map_io,
+       .init_irq       = ek_init_irq,
+       .init_machine   = ek_board_init,
+MACHINE_END
diff --git a/arch/arm/mach-at91rm9200/board-sam9261ek.c b/arch/arm/mach-at91rm9200/board-sam9261ek.c
new file mode 100644 (file)
index 0000000..30b490d
--- /dev/null
@@ -0,0 +1,259 @@
+/*
+ * linux/arch/arm/mach-at91rm9200/board-ek.c
+ *
+ *  Copyright (C) 2005 SAN People
+ *  Copyright (C) 2006 Atmel
+ *
+ * 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
+ */
+
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/spi/spi.h>
+#include <linux/dm9000.h>
+
+#include <asm/hardware.h>
+#include <asm/setup.h>
+#include <asm/mach-types.h>
+#include <asm/irq.h>
+
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+#include <asm/mach/irq.h>
+
+#include <asm/arch/board.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/at91sam926x_mc.h>
+
+#include "generic.h"
+
+
+/*
+ * Serial port configuration.
+ *    0 .. 2 = USART0 .. USART2
+ *    3      = DBGU
+ */
+static struct at91_uart_config __initdata ek_uart_config = {
+       .console_tty    = 0,                            /* ttyS0 */
+       .nr_tty         = 1,
+       .tty_map        = { 3, -1, -1, -1 }             /* ttyS0, ..., ttyS3 */
+};
+
+static void __init ek_map_io(void)
+{
+       /* Initialize processor: 18.432 MHz crystal */
+       at91sam9261_initialize(18432000);
+
+       /* Setup the serial ports and console */
+       at91_init_serial(&ek_uart_config);
+}
+
+static void __init ek_init_irq(void)
+{
+       at91sam9261_init_interrupts(NULL);
+}
+
+
+/*
+ * DM9000 ethernet device
+ */
+#if defined(CONFIG_DM9000)
+static struct resource at91sam9261_dm9000_resource[] = {
+       [0] = {
+               .start  = AT91_CHIPSELECT_2,
+               .end    = AT91_CHIPSELECT_2 + 3,
+               .flags  = IORESOURCE_MEM
+       },
+       [1] = {
+               .start  = AT91_CHIPSELECT_2 + 0x44,
+               .end    = AT91_CHIPSELECT_2 + 0xFF,
+               .flags  = IORESOURCE_MEM
+       },
+       [2] = {
+               .start  = AT91_PIN_PC11,
+               .end    = AT91_PIN_PC11,
+               .flags  = IORESOURCE_IRQ
+       }
+};
+
+static struct dm9000_plat_data dm9000_platdata = {
+       .flags          = DM9000_PLATF_16BITONLY,
+};
+
+static struct platform_device at91sam9261_dm9000_device = {
+       .name           = "dm9000",
+       .id             = 0,
+       .num_resources  = ARRAY_SIZE(at91sam9261_dm9000_resource),
+       .resource       = at91sam9261_dm9000_resource,
+       .dev            = {
+               .platform_data  = &dm9000_platdata,
+       }
+};
+
+static void __init ek_add_device_dm9000(void)
+{
+       /*
+        * Configure Chip-Select 2 on SMC for the DM9000.
+        * Note: These timings were calculated for MASTER_CLOCK = 100000000
+        *  according to the DM9000 timings.
+        */
+       at91_sys_write(AT91_SMC_SETUP(2), AT91_SMC_NWESETUP_(2) | AT91_SMC_NCS_WRSETUP_(0) | AT91_SMC_NRDSETUP_(2) | AT91_SMC_NCS_RDSETUP_(0));
+       at91_sys_write(AT91_SMC_PULSE(2), AT91_SMC_NWEPULSE_(4) | AT91_SMC_NCS_WRPULSE_(8) | AT91_SMC_NRDPULSE_(4) | AT91_SMC_NCS_RDPULSE_(8));
+       at91_sys_write(AT91_SMC_CYCLE(2), AT91_SMC_NWECYCLE_(16) | AT91_SMC_NRDCYCLE_(16));
+       at91_sys_write(AT91_SMC_MODE(2), AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_16 | AT91_SMC_TDF_(1));
+
+       /* Configure Reset signal as output */
+       at91_set_gpio_output(AT91_PIN_PC10, 0);
+
+       /* Configure Interrupt pin as input, no pull-up */
+       at91_set_gpio_input(AT91_PIN_PC11, 0);
+
+       platform_device_register(&at91sam9261_dm9000_device);
+}
+#else
+static void __init ek_add_device_dm9000(void) {}
+#endif /* CONFIG_DM9000 */
+
+
+/*
+ * USB Host Port
+ */
+static struct at91_usbh_data __initdata ek_usbh_data = {
+       .ports          = 2,
+};
+
+
+/*
+ * USB Device Port
+ */
+static struct at91_udc_data __initdata ek_udc_data = {
+       .vbus_pin       = AT91_PIN_PB29,
+       .pullup_pin     = 0,            /* pull-up driven by UDC */
+};
+
+
+/*
+ * MCI (SD/MMC)
+ */
+static struct at91_mmc_data __initdata ek_mmc_data = {
+       .wire4          = 1,
+//     .det_pin        = ... not connected
+//     .wp_pin         = ... not connected
+//     .vcc_pin        = ... not connected
+};
+
+
+/*
+ * NAND flash
+ */
+static struct mtd_partition __initdata ek_nand_partition[] = {
+       {
+               .name   = "Partition 1",
+               .offset = 0,
+               .size   = 256 * 1024,
+       },
+       {
+               .name   = "Partition 2",
+               .offset = 256 * 1024 ,
+               .size   = MTDPART_SIZ_FULL,
+       },
+};
+
+static struct mtd_partition *nand_partitions(int size, int *num_partitions)
+{
+       *num_partitions = ARRAY_SIZE(ek_nand_partition);
+       return ek_nand_partition;
+}
+
+static struct at91_nand_data __initdata ek_nand_data = {
+       .ale            = 22,
+       .cle            = 21,
+//     .det_pin        = ... not connected
+       .rdy_pin        = AT91_PIN_PC15,
+       .enable_pin     = AT91_PIN_PC14,
+       .partition_info = nand_partitions,
+#if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
+       .bus_width_16   = 1,
+#else
+       .bus_width_16   = 0,
+#endif
+};
+
+/*
+ * SPI devices
+ */
+static struct spi_board_info ek_spi_devices[] = {
+       {       /* DataFlash chip */
+               .modalias       = "mtd_dataflash",
+               .chip_select    = 0,
+               .max_speed_hz   = 15 * 1000 * 1000,
+               .bus_num        = 0,
+       },
+#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
+       {       /* DataFlash card - jumper (J12) configurable to CS3 or CS0 */
+               .modalias       = "mtd_dataflash",
+               .chip_select    = 3,
+               .max_speed_hz   = 15 * 1000 * 1000,
+               .bus_num        = 0,
+       },
+#elif defined(CONFIG_SND_AT73C213)
+       {       /* AT73C213 DAC */
+               .modalias       = "snd_at73c213",
+               .chip_select    = 3,
+               .max_speed_hz   = 10 * 1000 * 1000,
+               .bus_num        = 0,
+       },
+#endif
+};
+
+
+static void __init ek_board_init(void)
+{
+       /* Serial */
+       at91_add_device_serial();
+       /* USB Host */
+       at91_add_device_usbh(&ek_usbh_data);
+       /* USB Device */
+       at91_add_device_udc(&ek_udc_data);
+       /* I2C */
+       at91_add_device_i2c();
+       /* NAND */
+       at91_add_device_nand(&ek_nand_data);
+       /* DM9000 ethernet */
+       ek_add_device_dm9000();
+
+       /* spi0 and mmc/sd share the same PIO pins */
+#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
+       /* SPI */
+       at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
+#else
+       /* MMC */
+       at91_add_device_mmc(&ek_mmc_data);
+#endif
+}
+
+MACHINE_START(AT91SAM9261EK, "Atmel AT91SAM9261-EK")
+       /* Maintainer: Atmel */
+       .phys_io        = AT91_BASE_SYS,
+       .io_pg_offst    = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
+       .boot_params    = AT91_SDRAM_BASE + 0x100,
+       .timer          = &at91sam926x_timer,
+       .map_io         = ek_map_io,
+       .init_irq       = ek_init_irq,
+       .init_machine   = ek_board_init,
+MACHINE_END
index a43b061a7c852789d404f931658217a8a4fdd6e1..4dee21fefe5a61647552f0a7e5b91ea0aadf6631 100644 (file)
@@ -28,6 +28,8 @@
 #include <asm/mach-types.h>
 
 #include <asm/hardware.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/cpu.h>
 
 #include "clock.h"
 
@@ -41,6 +43,7 @@
 #define clk_is_primary(x)      ((x)->type & CLK_TYPE_PRIMARY)
 #define clk_is_programmable(x) ((x)->type & CLK_TYPE_PROGRAMMABLE)
 #define clk_is_peripheral(x)   ((x)->type & CLK_TYPE_PERIPHERAL)
+#define clk_is_sys(x)          ((x)->type & CLK_TYPE_SYSTEM)
 
 
 static LIST_HEAD(clocks);
@@ -114,13 +117,11 @@ static void pmc_sys_mode(struct clk *clk, int is_on)
 static struct clk udpck = {
        .name           = "udpck",
        .parent         = &pllb,
-       .pmc_mask       = AT91_PMC_UDP,
        .mode           = pmc_sys_mode,
 };
 static struct clk uhpck = {
        .name           = "uhpck",
        .parent         = &pllb,
-       .pmc_mask       = AT91_PMC_UHP,
        .mode           = pmc_sys_mode,
 };
 
@@ -434,6 +435,12 @@ int __init clk_register(struct clk *clk)
                clk->mode = pmc_periph_mode;
                list_add_tail(&clk->node, &clocks);
        }
+       else if (clk_is_sys(clk)) {
+               clk->parent = &mck;
+               clk->mode = pmc_sys_mode;
+
+               list_add_tail(&clk->node, &clocks);
+       }
 #ifdef CONFIG_AT91_PROGRAMMABLE_CLOCKS
        else if (clk_is_programmable(clk)) {
                clk->mode = pmc_sys_mode;
@@ -586,9 +593,21 @@ int __init at91_clock_init(unsigned long main_clock)
         */
        at91_pllb_usb_init = at91_pll_calc(main_clock, 48000000 * 2) | AT91_PMC_USB96M;
        pllb.rate_hz = at91_pll_rate(&pllb, main_clock, at91_pllb_usb_init);
-       at91_sys_write(AT91_PMC_SCDR, AT91_PMC_UHP | AT91_PMC_UDP);
+       if (cpu_is_at91rm9200()) {
+               uhpck.pmc_mask = AT91RM9200_PMC_UHP;
+               udpck.pmc_mask = AT91RM9200_PMC_UDP;
+               at91_sys_write(AT91_PMC_SCDR, AT91RM9200_PMC_UHP | AT91RM9200_PMC_UDP);
+               at91_sys_write(AT91_PMC_SCER, AT91RM9200_PMC_MCKUDP);
+       } else if (cpu_is_at91sam9260()) {
+               uhpck.pmc_mask = AT91SAM926x_PMC_UHP;
+               udpck.pmc_mask = AT91SAM926x_PMC_UDP;
+               at91_sys_write(AT91_PMC_SCDR, AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP);
+       } else if (cpu_is_at91sam9261()) {
+               uhpck.pmc_mask = (AT91SAM926x_PMC_UHP | AT91_PMC_HCK0);
+               udpck.pmc_mask = AT91SAM926x_PMC_UDP;
+               at91_sys_write(AT91_PMC_SCDR, AT91SAM926x_PMC_UHP | AT91_PMC_HCK0 | AT91SAM926x_PMC_UDP);
+       }
        at91_sys_write(AT91_CKGR_PLLBR, 0);
-       at91_sys_write(AT91_PMC_SCER, AT91_PMC_MCKUDP);
 
        udpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init);
        uhpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init);
index 0592e662ab371605b0560a59fd594739bec10c55..b5c7a2eb2d1dd7a24f7acaf20da5e4e584ac2c77 100644 (file)
@@ -10,6 +10,7 @@
 #define CLK_TYPE_PLL           0x2
 #define CLK_TYPE_PROGRAMMABLE  0x4
 #define CLK_TYPE_PERIPHERAL    0x8
+#define CLK_TYPE_SYSTEM                0x10
 
 
 struct clk {
index 694e411e285f6933254ccbf077c2aa69c50a2237..8c4d5a77d485e52b9d367a9cf7b0b8233c942011 100644 (file)
 
  /* Processors */
 extern void __init at91rm9200_initialize(unsigned long main_clock, unsigned short banks);
+extern void __init at91sam9260_initialize(unsigned long main_clock);
+extern void __init at91sam9261_initialize(unsigned long main_clock);
 
  /* Interrupts */
 extern void __init at91rm9200_init_interrupts(unsigned int priority[]);
+extern void __init at91sam9260_init_interrupts(unsigned int priority[]);
+extern void __init at91sam9261_init_interrupts(unsigned int priority[]);
 extern void __init at91_aic_init(unsigned int priority[]);
 
  /* Timer */
 struct sys_timer;
 extern struct sys_timer at91rm9200_timer;
+extern struct sys_timer at91sam926x_timer;
 
  /* Clocks */
 extern int __init at91_clock_init(unsigned long main_clock);
@@ -39,3 +44,6 @@ struct at91_gpio_bank {
 };
 extern void __init at91_gpio_init(struct at91_gpio_bank *, int nr_banks);
 extern void __init at91_gpio_irq_setup(void);
+
+extern void (*at91_arch_reset)(void);
+extern int at91_extern_irq;
index 7467d644f0a3406c7ccc939d4f19e0f9ff8ab2aa..3f188508c39194aebab97e79871546a81eb8a0db 100644 (file)
@@ -19,6 +19,8 @@
 
 #include <asm/io.h>
 #include <asm/hardware.h>
+#include <asm/arch/at91_pio.h>
+#include <asm/arch/at91_pmc.h>
 #include <asm/arch/gpio.h>
 
 #include "generic.h"
@@ -332,10 +334,10 @@ static struct irq_chip gpio_irqchip = {
        .set_wake       = gpio_irq_set_wake,
 };
 
-static void gpio_irq_handler(unsigned irq, struct irqdesc *desc)
+static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
 {
        unsigned        pin;
-       struct irqdesc  *gpio;
+       struct irq_desc *gpio;
        void __iomem    *pio;
        u32             isr;
 
@@ -396,7 +398,7 @@ void __init at91_gpio_irq_setup(void)
                __raw_writel(~0, controller + PIO_IDR);
 
                set_irq_data(id, (void *) pin);
-               set_irq_chipdata(id, controller);
+               set_irq_chip_data(id, controller);
 
                for (i = 0; i < 32; i++, pin++) {
                        /*
@@ -404,7 +406,7 @@ void __init at91_gpio_irq_setup(void)
                         * shorter, and the AIC handles interupts sanely.
                         */
                        set_irq_chip(pin, &gpio_irqchip);
-                       set_irq_handler(pin, do_simple_IRQ);
+                       set_irq_handler(pin, handle_simple_irq);
                        set_irq_flags(pin, IRQF_VALID);
                }
 
index 3e488117ca91bb2154d992c9bd815d0d619750f2..2148daafd29c3535e3b03e0ed0a90d9a4fb2d975 100644 (file)
@@ -47,6 +47,10 @@ static void at91_aic_unmask_irq(unsigned int irq)
        at91_sys_write(AT91_AIC_IECR, 1 << irq);
 }
 
+unsigned int at91_extern_irq;
+
+#define is_extern_irq(irq) ((1 << (irq)) & at91_extern_irq)
+
 static int at91_aic_set_type(unsigned irq, unsigned type)
 {
        unsigned int smr, srctype;
@@ -59,14 +63,16 @@ static int at91_aic_set_type(unsigned irq, unsigned type)
                srctype = AT91_AIC_SRCTYPE_RISING;
                break;
        case IRQT_LOW:
-               if ((irq > AT91_ID_FIQ) && (irq < AT91RM9200_ID_IRQ0))  /* only supported on external interrupts */
+               if ((irq == AT91_ID_FIQ) || is_extern_irq(irq))         /* only supported on external interrupts */
+                       srctype = AT91_AIC_SRCTYPE_LOW;
+               else
                        return -EINVAL;
-               srctype = AT91_AIC_SRCTYPE_LOW;
                break;
        case IRQT_FALLING:
-               if ((irq > AT91_ID_FIQ) && (irq < AT91RM9200_ID_IRQ0))  /* only supported on external interrupts */
+               if ((irq == AT91_ID_FIQ) || is_extern_irq(irq))         /* only supported on external interrupts */
+                       srctype = AT91_AIC_SRCTYPE_FALLING;
+               else
                        return -EINVAL;
-               srctype = AT91_AIC_SRCTYPE_FALLING;
                break;
        default:
                return -EINVAL;
@@ -139,7 +145,7 @@ void __init at91_aic_init(unsigned int priority[NR_AIC_IRQS])
                at91_sys_write(AT91_AIC_SMR(i), AT91_AIC_SRCTYPE_LOW | priority[i]);
 
                set_irq_chip(i, &at91_aic_chip);
-               set_irq_handler(i, do_level_IRQ);
+               set_irq_handler(i, handle_level_irq);
                set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
 
                /* Perform 8 End Of Interrupt Command to make sure AIC will not Lock out nIRQ */
index 32c95d8eaacf3dabe0866f9603104534b43839eb..67aa5572a3eaeb9c7e305a041b2254cdfc376b4e 100644 (file)
 #include <asm/mach/irq.h>
 #include <asm/mach-types.h>
 
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/at91rm9200_mc.h>
 #include <asm/arch/gpio.h>
+#include <asm/arch/cpu.h>
 
 #include "generic.h"
 
@@ -68,9 +71,15 @@ static int at91_pm_verify_clocks(void)
        scsr = at91_sys_read(AT91_PMC_SCSR);
 
        /* USB must not be using PLLB */
-       if ((scsr & (AT91_PMC_UHP | AT91_PMC_UDP)) != 0) {
-               pr_debug("AT91: PM - Suspend-to-RAM with USB still active\n");
-               return 0;
+       if (cpu_is_at91rm9200()) {
+               if ((scsr & (AT91RM9200_PMC_UHP | AT91RM9200_PMC_UDP)) != 0) {
+                       pr_debug("AT91: PM - Suspend-to-RAM with USB still active\n");
+                       return 0;
+               }
+       } else if (cpu_is_at91sam9260()) {
+#warning "Check SAM9260 USB clocks"
+       } else if (cpu_is_at91sam9261()) {
+#warning "Check SAM9261 USB clocks"
        }
 
 #ifdef CONFIG_AT91_PROGRAMMABLE_CLOCKS
@@ -112,7 +121,6 @@ EXPORT_SYMBOL(at91_suspend_entering_slow_clock);
 static void (*slow_clock)(void);
 
 
-
 static int at91_pm_enter(suspend_state_t state)
 {
        at91_gpio_suspend();
@@ -123,13 +131,7 @@ static int at91_pm_enter(suspend_state_t state)
                        (at91_sys_read(AT91_PMC_PCSR)
                                        | (1 << AT91_ID_FIQ)
                                        | (1 << AT91_ID_SYS)
-                                       | (1 << AT91RM9200_ID_IRQ0)
-                                       | (1 << AT91RM9200_ID_IRQ1)
-                                       | (1 << AT91RM9200_ID_IRQ2)
-                                       | (1 << AT91RM9200_ID_IRQ3)
-                                       | (1 << AT91RM9200_ID_IRQ4)
-                                       | (1 << AT91RM9200_ID_IRQ5)
-                                       | (1 << AT91RM9200_ID_IRQ6))
+                                       | (at91_extern_irq))
                                & at91_sys_read(AT91_AIC_IMR),
                        state);
 
index 7ee926e5bad2d3429eee65ca6a3b9a81c6e64313..ca102960f5284dac84b11ca48012061dc10e1b3b 100644 (file)
@@ -63,7 +63,7 @@ static void int1_unmask(unsigned int irq)
        clps_writel(intmr1, INTMR1);
 }
 
-static struct irqchip int1_chip = {
+static struct irq_chip int1_chip = {
        .ack    = int1_ack,
        .mask   = int1_mask,
        .unmask = int1_unmask,
@@ -100,7 +100,7 @@ static void int2_unmask(unsigned int irq)
        clps_writel(intmr2, INTMR2);
 }
 
-static struct irqchip int2_chip = {
+static struct irq_chip int2_chip = {
        .ack    = int2_ack,
        .mask   = int2_mask,
        .unmask = int2_unmask,
@@ -112,12 +112,12 @@ void __init clps711x_init_irq(void)
 
        for (i = 0; i < NR_IRQS; i++) {
                if (INT1_IRQS & (1 << i)) {
-                       set_irq_handler(i, do_level_IRQ);
+                       set_irq_handler(i, handle_level_irq);
                        set_irq_chip(i, &int1_chip);
                        set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
                }
                if (INT2_IRQS & (1 << i)) {
-                       set_irq_handler(i, do_level_IRQ);
+                       set_irq_handler(i, handle_level_irq);
                        set_irq_chip(i, &int2_chip);
                        set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
                }                       
index fb10cf252588ac1174304095b3b1cf82d6aec710..231b90004736e131416877747da5d65fbf73e175 100644 (file)
@@ -57,7 +57,7 @@ static void cl7500_unmask_irq_a(unsigned int irq)
        iomd_writeb(val | mask, IOMD_IRQMASKA);
 }
 
-static struct irqchip clps7500_a_chip = {
+static struct irq_chip clps7500_a_chip = {
        .ack    = cl7500_ack_irq_a,
        .mask   = cl7500_mask_irq_a,
        .unmask = cl7500_unmask_irq_a,
@@ -81,7 +81,7 @@ static void cl7500_unmask_irq_b(unsigned int irq)
        iomd_writeb(val | mask, IOMD_IRQMASKB);
 }
 
-static struct irqchip clps7500_b_chip = {
+static struct irq_chip clps7500_b_chip = {
        .ack    = cl7500_mask_irq_b,
        .mask   = cl7500_mask_irq_b,
        .unmask = cl7500_unmask_irq_b,
@@ -105,7 +105,7 @@ static void cl7500_unmask_irq_c(unsigned int irq)
        iomd_writeb(val | mask, IOMD_IRQMASKC);
 }
 
-static struct irqchip clps7500_c_chip = {
+static struct irq_chip clps7500_c_chip = {
        .ack    = cl7500_mask_irq_c,
        .mask   = cl7500_mask_irq_c,
        .unmask = cl7500_unmask_irq_c,
@@ -129,7 +129,7 @@ static void cl7500_unmask_irq_d(unsigned int irq)
        iomd_writeb(val | mask, IOMD_IRQMASKD);
 }
 
-static struct irqchip clps7500_d_chip = {
+static struct irq_chip clps7500_d_chip = {
        .ack    = cl7500_mask_irq_d,
        .mask   = cl7500_mask_irq_d,
        .unmask = cl7500_unmask_irq_d,
@@ -153,7 +153,7 @@ static void cl7500_unmask_irq_dma(unsigned int irq)
        iomd_writeb(val | mask, IOMD_DMAMASK);
 }
 
-static struct irqchip clps7500_dma_chip = {
+static struct irq_chip clps7500_dma_chip = {
        .ack    = cl7500_mask_irq_dma,
        .mask   = cl7500_mask_irq_dma,
        .unmask = cl7500_unmask_irq_dma,
@@ -177,7 +177,7 @@ static void cl7500_unmask_irq_fiq(unsigned int irq)
        iomd_writeb(val | mask, IOMD_FIQMASK);
 }
 
-static struct irqchip clps7500_fiq_chip = {
+static struct irq_chip clps7500_fiq_chip = {
        .ack    = cl7500_mask_irq_fiq,
        .mask   = cl7500_mask_irq_fiq,
        .unmask = cl7500_unmask_irq_fiq,
@@ -187,7 +187,7 @@ static void cl7500_no_action(unsigned int irq)
 {
 }
 
-static struct irqchip clps7500_no_chip = {
+static struct irq_chip clps7500_no_chip = {
        .ack    = cl7500_no_action,
        .mask   = cl7500_no_action,
        .unmask = cl7500_no_action,
@@ -214,43 +214,43 @@ static void __init clps7500_init_irq(void)
                switch (irq) {
                case 0 ... 7:
                        set_irq_chip(irq, &clps7500_a_chip);
-                       set_irq_handler(irq, do_level_IRQ);
+                       set_irq_handler(irq, handle_level_irq);
                        set_irq_flags(irq, flags);
                        break;
 
                case 8 ... 15:
                        set_irq_chip(irq, &clps7500_b_chip);
-                       set_irq_handler(irq, do_level_IRQ);
+                       set_irq_handler(irq, handle_level_irq);
                        set_irq_flags(irq, flags);
                        break;
 
                case 16 ... 22:
                        set_irq_chip(irq, &clps7500_dma_chip);
-                       set_irq_handler(irq, do_level_IRQ);
+                       set_irq_handler(irq, handle_level_irq);
                        set_irq_flags(irq, flags);
                        break;
 
                case 24 ... 31:
                        set_irq_chip(irq, &clps7500_c_chip);
-                       set_irq_handler(irq, do_level_IRQ);
+                       set_irq_handler(irq, handle_level_irq);
                        set_irq_flags(irq, flags);
                        break;
 
                case 40 ... 47:
                        set_irq_chip(irq, &clps7500_d_chip);
-                       set_irq_handler(irq, do_level_IRQ);
+                       set_irq_handler(irq, handle_level_irq);
                        set_irq_flags(irq, flags);
                        break;
 
                case 48 ... 55:
                        set_irq_chip(irq, &clps7500_no_chip);
-                       set_irq_handler(irq, do_level_IRQ);
+                       set_irq_handler(irq, handle_level_irq);
                        set_irq_flags(irq, flags);
                        break;
 
                case 64 ... 72:
                        set_irq_chip(irq, &clps7500_fiq_chip);
-                       set_irq_handler(irq, do_level_IRQ);
+                       set_irq_handler(irq, handle_level_irq);
                        set_irq_flags(irq, flags);
                        break;
                }
index 90103ab373a6ae8fbe830f5e96767ecbe197787c..8459431cfd71f4a9f38858bfbd147fe45eae28fa 100644 (file)
@@ -45,7 +45,7 @@ static void ebsa110_unmask_irq(unsigned int irq)
        __raw_writeb(1 << irq, IRQ_MSET);
 }
 
-static struct irqchip ebsa110_irq_chip = {
+static struct irq_chip ebsa110_irq_chip = {
        .ack    = ebsa110_mask_irq,
        .mask   = ebsa110_mask_irq,
        .unmask = ebsa110_unmask_irq,
@@ -67,7 +67,7 @@ static void __init ebsa110_init_irq(void)
 
        for (irq = 0; irq < NR_IRQS; irq++) {
                set_irq_chip(irq, &ebsa110_irq_chip);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
        }
 }
index e346b03cd92114ed29ef44770de626c404e4df34..af7904b3d0a864149593d38e307f7debbc49267f 100644 (file)
@@ -9,12 +9,24 @@ config CRUNCH
 
 comment "EP93xx Platforms"
 
+config MACH_ADSSPHERE
+       bool "Support ADS Sphere"
+       help
+         Say 'Y' here if you want your kernel to support the ADS
+         Sphere board.
+
 config MACH_EDB9302
        bool "Support Cirrus Logic EDB9302"
        help
          Say 'Y' here if you want your kernel to support the Cirrus
          Logic EDB9302 Evaluation Board.
 
+config MACH_EDB9302A
+       bool "Support Cirrus Logic EDB9302A"
+       help
+         Say 'Y' here if you want your kernel to support the Cirrus
+         Logic EDB9302A Evaluation Board.
+
 config MACH_EDB9312
        bool "Support Cirrus Logic EDB9312"
        help
index c2eb18b530c2d0367be36a4e86fb01105a83e552..b06641dd450d5699c9bda5422d6dc2eabfe08027 100644 (file)
@@ -6,7 +6,9 @@ obj-m                   :=
 obj-n                  :=
 obj-                   :=
 
+obj-$(CONFIG_MACH_ADSSPHERE)   += adssphere.o
 obj-$(CONFIG_MACH_EDB9302)     += edb9302.o
+obj-$(CONFIG_MACH_EDB9302A)    += edb9302a.o
 obj-$(CONFIG_MACH_EDB9312)     += edb9312.o
 obj-$(CONFIG_MACH_EDB9315)     += edb9315.o
 obj-$(CONFIG_MACH_EDB9315A)    += edb9315a.o
diff --git a/arch/arm/mach-ep93xx/adssphere.c b/arch/arm/mach-ep93xx/adssphere.c
new file mode 100644 (file)
index 0000000..ac5d581
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * arch/arm/mach-ep93xx/adssphere.c
+ * ADS Sphere support.
+ *
+ * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.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/kernel.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/ioport.h>
+#include <linux/mtd/physmap.h>
+#include <linux/platform_device.h>
+#include <asm/io.h>
+#include <asm/hardware.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+
+static struct physmap_flash_data adssphere_flash_data = {
+       .width          = 4,
+};
+
+static struct resource adssphere_flash_resource = {
+       .start          = 0x60000000,
+       .end            = 0x61ffffff,
+       .flags          = IORESOURCE_MEM,
+};
+
+static struct platform_device adssphere_flash = {
+       .name           = "physmap-flash",
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &adssphere_flash_data,
+       },
+       .num_resources  = 1,
+       .resource       = &adssphere_flash_resource,
+};
+
+static struct ep93xx_eth_data adssphere_eth_data = {
+       .phy_id         = 1,
+};
+
+static struct resource adssphere_eth_resource[] = {
+       {
+               .start  = EP93XX_ETHERNET_PHYS_BASE,
+               .end    = EP93XX_ETHERNET_PHYS_BASE + 0xffff,
+               .flags  = IORESOURCE_MEM,
+       }, {
+               .start  = IRQ_EP93XX_ETHERNET,
+               .end    = IRQ_EP93XX_ETHERNET,
+               .flags  = IORESOURCE_IRQ,
+       }
+};
+
+static struct platform_device adssphere_eth_device = {
+       .name           = "ep93xx-eth",
+       .id             = -1,
+       .dev            = {
+               .platform_data  = &adssphere_eth_data,
+       },
+       .num_resources  = 2,
+       .resource       = adssphere_eth_resource,
+};
+
+static void __init adssphere_init_machine(void)
+{
+       ep93xx_init_devices();
+       platform_device_register(&adssphere_flash);
+
+       memcpy(adssphere_eth_data.dev_addr,
+               (void *)(EP93XX_ETHERNET_BASE + 0x50), 6);
+       platform_device_register(&adssphere_eth_device);
+}
+
+MACHINE_START(ADSSPHERE, "ADS Sphere board")
+       /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
+       .phys_io        = EP93XX_APB_PHYS_BASE,
+       .io_pg_offst    = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
+       .boot_params    = 0x00000100,
+       .map_io         = ep93xx_map_io,
+       .init_irq       = ep93xx_init_irq,
+       .timer          = &ep93xx_timer,
+       .init_machine   = adssphere_init_machine,
+MACHINE_END
index e3fd1ab6adccfa4ca051a76a5a31a675b75c11a7..d649b39711d49296423963c50e9cd2a9753f5bf0 100644 (file)
@@ -245,7 +245,7 @@ EXPORT_SYMBOL(gpio_line_set);
  * EP93xx IRQ handling
  *************************************************************************/
 static void ep93xx_gpio_ab_irq_handler(unsigned int irq,
-               struct irqdesc *desc)
+               struct irq_desc *desc)
 {
        unsigned char status;
        int i;
@@ -335,7 +335,7 @@ static int ep93xx_gpio_ab_irq_type(unsigned int irq, unsigned int type)
        return 0;
 }
 
-static struct irqchip ep93xx_gpio_ab_irq_chip = {
+static struct irq_chip ep93xx_gpio_ab_irq_chip = {
        .ack            = ep93xx_gpio_ab_irq_mask_ack,
        .mask           = ep93xx_gpio_ab_irq_mask,
        .unmask         = ep93xx_gpio_ab_irq_unmask,
@@ -352,7 +352,7 @@ void __init ep93xx_init_irq(void)
 
        for (irq = IRQ_EP93XX_GPIO(0) ; irq <= IRQ_EP93XX_GPIO(15); irq++) {
                set_irq_chip(irq, &ep93xx_gpio_ab_irq_chip);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                set_irq_flags(irq, IRQF_VALID);
        }
        set_irq_chained_handler(IRQ_EP93XX_GPIO_AB, ep93xx_gpio_ab_irq_handler);
diff --git a/arch/arm/mach-ep93xx/edb9302a.c b/arch/arm/mach-ep93xx/edb9302a.c
new file mode 100644 (file)
index 0000000..62e064b
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * arch/arm/mach-ep93xx/edb9302a.c
+ * Cirrus Logic EDB9302A support.
+ *
+ * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.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/kernel.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/ioport.h>
+#include <linux/mtd/physmap.h>
+#include <linux/platform_device.h>
+#include <asm/io.h>
+#include <asm/hardware.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+
+static struct physmap_flash_data edb9302a_flash_data = {
+       .width          = 2,
+};
+
+static struct resource edb9302a_flash_resource = {
+       .start          = 0x60000000,
+       .end            = 0x60ffffff,
+       .flags          = IORESOURCE_MEM,
+};
+
+static struct platform_device edb9302a_flash = {
+       .name           = "physmap-flash",
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &edb9302a_flash_data,
+       },
+       .num_resources  = 1,
+       .resource       = &edb9302a_flash_resource,
+};
+
+static struct ep93xx_eth_data edb9302a_eth_data = {
+       .phy_id                 = 1,
+};
+
+static struct resource edb9302a_eth_resource[] = {
+       {
+               .start  = EP93XX_ETHERNET_PHYS_BASE,
+               .end    = EP93XX_ETHERNET_PHYS_BASE + 0xffff,
+               .flags  = IORESOURCE_MEM,
+       }, {
+               .start  = IRQ_EP93XX_ETHERNET,
+               .end    = IRQ_EP93XX_ETHERNET,
+               .flags  = IORESOURCE_IRQ,
+       }
+};
+
+static struct platform_device edb9302a_eth_device = {
+       .name           = "ep93xx-eth",
+       .id             = -1,
+       .dev            = {
+               .platform_data  = &edb9302a_eth_data,
+       },
+       .num_resources  = 2,
+       .resource       = edb9302a_eth_resource,
+};
+
+static void __init edb9302a_init_machine(void)
+{
+       ep93xx_init_devices();
+       platform_device_register(&edb9302a_flash);
+
+       memcpy(edb9302a_eth_data.dev_addr,
+               (void *)(EP93XX_ETHERNET_BASE + 0x50), 6);
+       platform_device_register(&edb9302a_eth_device);
+}
+
+MACHINE_START(EDB9302A, "Cirrus Logic EDB9302A Evaluation Board")
+       /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
+       .phys_io        = EP93XX_APB_PHYS_BASE,
+       .io_pg_offst    = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
+       .boot_params    = 0xc0000100,
+       .map_io         = ep93xx_map_io,
+       .init_irq       = ep93xx_init_irq,
+       .timer          = &ep93xx_timer,
+       .init_machine   = edb9302a_init_machine,
+MACHINE_END
index af900f4755a44fabe0afff71d06334d06dc50349..ef29fc34ce6587ff6493a86e01c29b31ce542f2f 100644 (file)
@@ -78,7 +78,7 @@ static void fb_unmask_irq(unsigned int irq)
        *CSR_IRQ_ENABLE = fb_irq_mask[_DC21285_INR(irq)];
 }
 
-static struct irqchip fb_chip = {
+static struct irq_chip fb_chip = {
        .ack    = fb_mask_irq,
        .mask   = fb_mask_irq,
        .unmask = fb_unmask_irq,
@@ -96,7 +96,7 @@ static void __init __fb_init_irq(void)
 
        for (irq = _DC21285_IRQ(0); irq < _DC21285_IRQ(20); irq++) {
                set_irq_chip(irq, &fb_chip);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
        }
 }
index 888dedd501b9b94ce4a7bef35e98b9f9868a28fa..79443ffc8916d9af59a2cfd84aa162c08ab88055 100644 (file)
@@ -49,7 +49,7 @@ static void isa_unmask_pic_lo_irq(unsigned int irq)
        outb(inb(PIC_MASK_LO) & ~mask, PIC_MASK_LO);
 }
 
-static struct irqchip isa_lo_chip = {
+static struct irq_chip isa_lo_chip = {
        .ack    = isa_ack_pic_lo_irq,
        .mask   = isa_mask_pic_lo_irq,
        .unmask = isa_unmask_pic_lo_irq,
@@ -78,14 +78,14 @@ static void isa_unmask_pic_hi_irq(unsigned int irq)
        outb(inb(PIC_MASK_HI) & ~mask, PIC_MASK_HI);
 }
 
-static struct irqchip isa_hi_chip = {
+static struct irq_chip isa_hi_chip = {
        .ack    = isa_ack_pic_hi_irq,
        .mask   = isa_mask_pic_hi_irq,
        .unmask = isa_unmask_pic_hi_irq,
 };
 
 static void
-isa_irq_handler(unsigned int irq, struct irqdesc *desc)
+isa_irq_handler(unsigned int irq, struct irq_desc *desc)
 {
        unsigned int isa_irq = *(unsigned char *)PCIIACK_BASE;
 
@@ -150,13 +150,13 @@ void __init isa_init_irq(unsigned int host_irq)
        if (host_irq != (unsigned int)-1) {
                for (irq = _ISA_IRQ(0); irq < _ISA_IRQ(8); irq++) {
                        set_irq_chip(irq, &isa_lo_chip);
-                       set_irq_handler(irq, do_level_IRQ);
+                       set_irq_handler(irq, handle_level_irq);
                        set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
                }
 
                for (irq = _ISA_IRQ(8); irq < _ISA_IRQ(16); irq++) {
                        set_irq_chip(irq, &isa_hi_chip);
-                       set_irq_handler(irq, do_level_IRQ);
+                       set_irq_handler(irq, handle_level_irq);
                        set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
                }
 
index 4719229a1a78555d1b61dbfe4b746f3e4b41fbc3..7f31816896ad2ae662196c3772bf595781fc1dbd 100644 (file)
@@ -101,7 +101,7 @@ static void inline unmask_gpio_irq(u32 irq)
 
 static void
 h720x_gpio_handler(unsigned int mask, unsigned int irq,
-                 struct irqdesc *desc)
+                 struct irq_desc *desc)
 {
        IRQDBG("%s irq: %d\n",__FUNCTION__,irq);
        desc = irq_desc + irq;
@@ -117,7 +117,7 @@ h720x_gpio_handler(unsigned int mask, unsigned int irq,
 }
 
 static void
-h720x_gpioa_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
+h720x_gpioa_demux_handler(unsigned int irq_unused, struct irq_desc *desc)
 {
        unsigned int mask, irq;
 
@@ -128,7 +128,7 @@ h720x_gpioa_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
 }
 
 static void
-h720x_gpiob_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
+h720x_gpiob_demux_handler(unsigned int irq_unused, struct irq_desc *desc)
 {
        unsigned int mask, irq;
        mask = CPU_REG(GPIO_B_VIRT,GPIO_STAT);
@@ -138,7 +138,7 @@ h720x_gpiob_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
 }
 
 static void
-h720x_gpioc_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
+h720x_gpioc_demux_handler(unsigned int irq_unused, struct irq_desc *desc)
 {
        unsigned int mask, irq;
 
@@ -149,7 +149,7 @@ h720x_gpioc_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
 }
 
 static void
-h720x_gpiod_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
+h720x_gpiod_demux_handler(unsigned int irq_unused, struct irq_desc *desc)
 {
        unsigned int mask, irq;
 
@@ -161,7 +161,7 @@ h720x_gpiod_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
 
 #ifdef CONFIG_CPU_H7202
 static void
-h720x_gpioe_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
+h720x_gpioe_demux_handler(unsigned int irq_unused, struct irq_desc *desc)
 {
        unsigned int mask, irq;
 
@@ -172,13 +172,13 @@ h720x_gpioe_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
 }
 #endif
 
-static struct irqchip h720x_global_chip = {
+static struct irq_chip h720x_global_chip = {
        .ack = mask_global_irq,
        .mask = mask_global_irq,
        .unmask = unmask_global_irq,
 };
 
-static struct irqchip h720x_gpio_chip = {
+static struct irq_chip h720x_gpio_chip = {
        .ack = ack_gpio_irq,
        .mask = mask_gpio_irq,
        .unmask = unmask_gpio_irq,
@@ -203,14 +203,14 @@ void __init h720x_init_irq (void)
        /* Initialize global IRQ's, fast path */
        for (irq = 0; irq < NR_GLBL_IRQS; irq++) {
                set_irq_chip(irq, &h720x_global_chip);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
        }
 
        /* Initialize multiplexed IRQ's, slow path */
        for (irq = IRQ_CHAINED_GPIOA(0) ; irq <= IRQ_CHAINED_GPIOD(31); irq++) {
                set_irq_chip(irq, &h720x_gpio_chip);
-               set_irq_handler(irq, do_edge_IRQ);
+               set_irq_handler(irq, handle_edge_irq);
                set_irq_flags(irq, IRQF_VALID );
        }
        set_irq_chained_handler(IRQ_GPIOA, h720x_gpioa_demux_handler);
@@ -221,7 +221,7 @@ void __init h720x_init_irq (void)
 #ifdef CONFIG_CPU_H7202
        for (irq = IRQ_CHAINED_GPIOE(0) ; irq <= IRQ_CHAINED_GPIOE(31); irq++) {
                set_irq_chip(irq, &h720x_gpio_chip);
-               set_irq_handler(irq, do_edge_IRQ);
+               set_irq_handler(irq, handle_edge_irq);
                set_irq_flags(irq, IRQF_VALID );
        }
        set_irq_chained_handler(IRQ_GPIOE, h720x_gpioe_demux_handler);
index 06fecaefd8dcaf249e1ba48bbc03aa672aed3a27..703870f30adf78cc01adb5515e0f7d06da30dce8 100644 (file)
@@ -106,7 +106,7 @@ static struct platform_device *devices[] __initdata = {
  * we have to handle all timer interrupts in one place.
  */
 static void
-h7202_timerx_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
+h7202_timerx_demux_handler(unsigned int irq_unused, struct irq_desc *desc)
 {
        unsigned int mask, irq;
 
@@ -162,7 +162,7 @@ static void inline unmask_timerx_irq (u32 irq)
        CPU_REG (TIMER_VIRT, TIMER_TOPCTRL) |= bit;
 }
 
-static struct irqchip h7202_timerx_chip = {
+static struct irq_chip h7202_timerx_chip = {
        .ack = mask_timerx_irq,
        .mask = mask_timerx_irq,
        .unmask = unmask_timerx_irq,
@@ -202,7 +202,7 @@ void __init h7202_init_irq (void)
                          irq < IRQ_CHAINED_TIMERX(NR_TIMERX_IRQS); irq++) {
                mask_timerx_irq(irq);
                set_irq_chip(irq, &h7202_timerx_chip);
-               set_irq_handler(irq, do_edge_IRQ);
+               set_irq_handler(irq, handle_edge_irq);
                set_irq_flags(irq, IRQF_VALID );
        }
        set_irq_chained_handler(IRQ_TIMERX, h7202_timerx_demux_handler);
index 12ea58a3b84f2472ac96a3d869f4e26ba01e0d00..b5aa49d00ca388cce26ea6bcb1c8e9b972c18c80 100644 (file)
@@ -104,6 +104,9 @@ EXPORT_SYMBOL(imx_gpio_mode);
  */
 static unsigned int imx_decode_pll(unsigned int pll)
 {
+       unsigned long long ll;
+       unsigned long quot;
+
        u32 mfi = (pll >> 10) & 0xf;
        u32 mfn = pll & 0x3ff;
        u32 mfd = (pll >> 16) & 0x3ff;
@@ -112,7 +115,11 @@ static unsigned int imx_decode_pll(unsigned int pll)
 
        mfi = mfi <= 5 ? 5 : mfi;
 
-       return (2 * (f_ref>>10) * ( (mfi<<10) + (mfn<<10) / (mfd+1) )) / (pd+1);
+       ll = 2 * (unsigned long long)f_ref * ( (mfi<<16) + (mfn<<16) / (mfd+1) );
+       quot = (pd+1) * (1<<16);
+       ll += quot / 2;
+       do_div(ll, quot);
+       return (unsigned int) ll;
 }
 
 unsigned int imx_get_system_clk(void)
index 368b13b058ab1c8e3e852e45be97c59faf9faa51..0791b56caeccf827b8405426f23506b9327fce25 100644 (file)
@@ -146,7 +146,7 @@ imx_gpio_unmask_irq(unsigned int irq)
 
 static void
 imx_gpio_handler(unsigned int mask, unsigned int irq,
-                 struct irqdesc *desc)
+                 struct irq_desc *desc)
 {
        desc = irq_desc + irq;
        while (mask) {
@@ -161,7 +161,7 @@ imx_gpio_handler(unsigned int mask, unsigned int irq,
 }
 
 static void
-imx_gpioa_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
+imx_gpioa_demux_handler(unsigned int irq_unused, struct irq_desc *desc)
 {
        unsigned int mask, irq;
 
@@ -171,7 +171,7 @@ imx_gpioa_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
 }
 
 static void
-imx_gpiob_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
+imx_gpiob_demux_handler(unsigned int irq_unused, struct irq_desc *desc)
 {
        unsigned int mask, irq;
 
@@ -181,7 +181,7 @@ imx_gpiob_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
 }
 
 static void
-imx_gpioc_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
+imx_gpioc_demux_handler(unsigned int irq_unused, struct irq_desc *desc)
 {
        unsigned int mask, irq;
 
@@ -191,7 +191,7 @@ imx_gpioc_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
 }
 
 static void
-imx_gpiod_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
+imx_gpiod_demux_handler(unsigned int irq_unused, struct irq_desc *desc)
 {
        unsigned int mask, irq;
 
@@ -230,13 +230,13 @@ imx_init_irq(void)
 
        for (irq = 0; irq < IMX_IRQS; irq++) {
                set_irq_chip(irq, &imx_internal_chip);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                set_irq_flags(irq, IRQF_VALID);
        }
 
        for (irq = IRQ_GPIOA(0); irq < IRQ_GPIOD(32); irq++) {
                set_irq_chip(irq, &imx_gpio_chip);
-               set_irq_handler(irq, do_edge_IRQ);
+               set_irq_handler(irq, handle_edge_irq);
                set_irq_flags(irq, IRQF_VALID);
        }
 
index 8ae4a2c5066fc2a55e7bec5c46377162aa119cc6..40039b2a90b39079a7af6f5fcdd5856f6452280e 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/time.h>
+#include <linux/clocksource.h>
 
 #include <asm/hardware.h>
 #include <asm/io.h>
 /* Use timer 1 as system timer */
 #define TIMER_BASE IMX_TIM1_BASE
 
-/*
- * Returns number of us since last clock interrupt.  Note that interrupts
- * will have been disabled by do_gettimeoffset()
- */
-static unsigned long imx_gettimeoffset(void)
-{
-       unsigned long ticks;
-
-       /*
-        * Get the current number of ticks.  Note that there is a race
-        * condition between us reading the timer and checking for
-        * an interrupt.  We get around this by ensuring that the
-        * counter has not reloaded between our two reads.
-        */
-       ticks = IMX_TCN(TIMER_BASE);
-
-       /*
-        * Interrupt pending?  If so, we've reloaded once already.
-        */
-       if (IMX_TSTAT(TIMER_BASE) & TSTAT_COMP)
-               ticks += LATCH;
-
-       /*
-        * Convert the ticks to usecs
-        */
-       return (1000000 / CLK32) * ticks;
-}
+static unsigned long evt_diff;
 
 /*
  * IRQ handler for the timer
@@ -58,14 +33,23 @@ static unsigned long imx_gettimeoffset(void)
 static irqreturn_t
 imx_timer_interrupt(int irq, void *dev_id)
 {
-       write_seqlock(&xtime_lock);
+       uint32_t tstat;
 
        /* clear the interrupt */
-       if (IMX_TSTAT(TIMER_BASE))
-               IMX_TSTAT(TIMER_BASE) = 0;
+       tstat = IMX_TSTAT(TIMER_BASE);
+       IMX_TSTAT(TIMER_BASE) = 0;
+
+       if (tstat & TSTAT_COMP) {
+               do {
+
+                       write_seqlock(&xtime_lock);
+                       timer_tick();
+                       write_sequnlock(&xtime_lock);
+                       IMX_TCMP(TIMER_BASE) += evt_diff;
 
-       timer_tick();
-       write_sequnlock(&xtime_lock);
+               } while (unlikely((int32_t)(IMX_TCMP(TIMER_BASE)
+                                       - IMX_TCN(TIMER_BASE)) < 0));
+       }
 
        return IRQ_HANDLED;
 }
@@ -77,9 +61,9 @@ static struct irqaction imx_timer_irq = {
 };
 
 /*
- * Set up timer interrupt, and return the current time in seconds.
+ * Set up timer hardware into expected mode and state.
  */
-static void __init imx_timer_init(void)
+static void __init imx_timer_hardware_init(void)
 {
        /*
         * Initialise to a known state (all timers off, and timing reset)
@@ -87,7 +71,38 @@ static void __init imx_timer_init(void)
        IMX_TCTL(TIMER_BASE) = 0;
        IMX_TPRER(TIMER_BASE) = 0;
        IMX_TCMP(TIMER_BASE) = LATCH - 1;
-       IMX_TCTL(TIMER_BASE) = TCTL_CLK_32 | TCTL_IRQEN | TCTL_TEN;
+
+       IMX_TCTL(TIMER_BASE) = TCTL_FRR | TCTL_CLK_PCLK1 | TCTL_IRQEN | TCTL_TEN;
+       evt_diff = LATCH;
+}
+
+cycle_t imx_get_cycles(void)
+{
+       return IMX_TCN(TIMER_BASE);
+}
+
+static struct clocksource clocksource_imx = {
+       .name           = "imx_timer1",
+       .rating         = 200,
+       .read           = imx_get_cycles,
+       .mask           = 0xFFFFFFFF,
+       .shift          = 20,
+       .is_continuous  = 1,
+};
+
+static int __init imx_clocksource_init(void)
+{
+       clocksource_imx.mult =
+               clocksource_hz2mult(imx_get_perclk1(), clocksource_imx.shift);
+       clocksource_register(&clocksource_imx);
+
+       return 0;
+}
+
+static void __init imx_timer_init(void)
+{
+       imx_timer_hardware_init();
+       imx_clocksource_init();
 
        /*
         * Make irqs happen for the system timer
@@ -97,5 +112,4 @@ static void __init imx_timer_init(void)
 
 struct sys_timer imx_timer = {
        .init           = imx_timer_init,
-       .offset         = imx_gettimeoffset,
 };
index 191c57a3b997a8efc52b3df0934058296b033b81..72280754354d3b98e7785c945abd0ec33930202c 100644 (file)
@@ -183,7 +183,7 @@ static void __init ap_init_irq(void)
        for (i = 0; i < NR_IRQS; i++) {
                if (((1 << i) & INTEGRATOR_SC_VALID_INT) != 0) {
                        set_irq_chip(i, &sc_chip);
-                       set_irq_handler(i, do_level_IRQ);
+                       set_irq_handler(i, handle_level_irq);
                        set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
                }
        }
index 771b65bffe69edd206f0e1de6bc1f34692c56e51..913f64b224051bc968bab4e15464682e3085ba86 100644 (file)
@@ -202,7 +202,7 @@ static struct irq_chip sic_chip = {
 };
 
 static void
-sic_handle_irq(unsigned int irq, struct irqdesc *desc)
+sic_handle_irq(unsigned int irq, struct irq_desc *desc)
 {
        unsigned long status = sic_readl(INTCP_VA_SIC_BASE + IRQ_STATUS);
 
@@ -238,7 +238,7 @@ static void __init intcp_init_irq(void)
                if (i == 29)
                        break;
                set_irq_chip(i, &pic_chip);
-               set_irq_handler(i, do_level_IRQ);
+               set_irq_handler(i, handle_level_irq);
                set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
        }
 
@@ -247,7 +247,7 @@ static void __init intcp_init_irq(void)
 
        for (i = IRQ_CIC_START; i <= IRQ_CIC_END; i++) {
                set_irq_chip(i, &cic_chip);
-               set_irq_handler(i, do_level_IRQ);
+               set_irq_handler(i, handle_level_irq);
                set_irq_flags(i, IRQF_VALID);
        }
 
@@ -256,7 +256,7 @@ static void __init intcp_init_irq(void)
 
        for (i = IRQ_SIC_START; i <= IRQ_SIC_END; i++) {
                set_irq_chip(i, &sic_chip);
-               set_irq_handler(i, do_level_IRQ);
+               set_irq_handler(i, handle_level_irq);
                set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
        }
 
index 1bc8534ef0c696d5fca65a19dbe10b47be3f7d66..613b841a10f3b42285326f0559d33920f3b9c4a0 100644 (file)
@@ -18,7 +18,6 @@
 #include <asm/cacheflush.h>
 #include <asm/delay.h>
 #include <asm/mmu_context.h>
-#include <asm/procinfo.h>
 #include <asm/ptrace.h>
 #include <asm/smp.h>
 
diff --git a/arch/arm/mach-iop13xx/Kconfig b/arch/arm/mach-iop13xx/Kconfig
new file mode 100644 (file)
index 0000000..40c2d68
--- /dev/null
@@ -0,0 +1,20 @@
+if ARCH_IOP13XX
+
+menu "IOP13XX Implementation Options"
+
+comment "IOP13XX Platform Support"
+
+config MACH_IQ81340SC
+       bool "Enable IQ81340SC Hardware Support"
+       help
+         Say Y here if you want to support running on the Intel IQ81340SC
+         evaluation kit.
+
+config MACH_IQ81340MC
+       bool "Enable IQ81340MC Hardware Support"
+       help
+         Say Y here if you want to support running on the Intel IQ81340MC
+         evaluation kit.
+
+endmenu
+endif
diff --git a/arch/arm/mach-iop13xx/Makefile b/arch/arm/mach-iop13xx/Makefile
new file mode 100644 (file)
index 0000000..c3d6c08
--- /dev/null
@@ -0,0 +1,12 @@
+obj-y                  :=
+obj-m                  :=
+obj-n                  :=
+obj-                   :=
+
+obj-$(CONFIG_ARCH_IOP13XX) += setup.o
+obj-$(CONFIG_ARCH_IOP13XX) += irq.o
+obj-$(CONFIG_ARCH_IOP13XX) += time.o
+obj-$(CONFIG_ARCH_IOP13XX) += pci.o
+obj-$(CONFIG_ARCH_IOP13XX) += io.o
+obj-$(CONFIG_MACH_IQ81340SC) += iq81340sc.o
+obj-$(CONFIG_MACH_IQ81340MC) += iq81340mc.o
diff --git a/arch/arm/mach-iop13xx/Makefile.boot b/arch/arm/mach-iop13xx/Makefile.boot
new file mode 100644 (file)
index 0000000..0b0e19f
--- /dev/null
@@ -0,0 +1,3 @@
+   zreladdr-y   := 0x00008000
+params_phys-y  := 0x00000100
+initrd_phys-y  := 0x00800000
diff --git a/arch/arm/mach-iop13xx/io.c b/arch/arm/mach-iop13xx/io.c
new file mode 100644 (file)
index 0000000..fbf9f88
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * iop13xx custom ioremap implementation
+ * Copyright (c) 2005-2006, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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.
+ *
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <asm/hardware.h>
+#include <asm/io.h>
+
+void * __iomem __iop13xx_ioremap(unsigned long cookie, size_t size,
+       unsigned long flags)
+{
+       void __iomem * retval;
+
+       switch (cookie) {
+       case IOP13XX_PCIX_LOWER_MEM_RA ... IOP13XX_PCIX_UPPER_MEM_RA:
+               if (unlikely(!iop13xx_atux_mem_base))
+                       retval = NULL;
+               else
+                       retval = (void *)(iop13xx_atux_mem_base +
+                                (cookie - IOP13XX_PCIX_LOWER_MEM_RA));
+               break;
+       case IOP13XX_PCIE_LOWER_MEM_RA ... IOP13XX_PCIE_UPPER_MEM_RA:
+               if (unlikely(!iop13xx_atue_mem_base))
+                       retval = NULL;
+               else
+                       retval = (void *)(iop13xx_atue_mem_base +
+                                (cookie - IOP13XX_PCIE_LOWER_MEM_RA));
+               break;
+       case IOP13XX_PBI_LOWER_MEM_RA ... IOP13XX_PBI_UPPER_MEM_RA:
+               retval = __ioremap(IOP13XX_PBI_LOWER_MEM_PA +
+                                 (cookie - IOP13XX_PBI_LOWER_MEM_RA),
+                                 size, flags);
+               break;
+       case IOP13XX_PCIE_LOWER_IO_PA ... IOP13XX_PCIE_UPPER_IO_PA:
+               retval = (void *) IOP13XX_PCIE_IO_PHYS_TO_VIRT(cookie);
+               break;
+       case IOP13XX_PCIX_LOWER_IO_PA ... IOP13XX_PCIX_UPPER_IO_PA:
+               retval = (void *) IOP13XX_PCIX_IO_PHYS_TO_VIRT(cookie);
+               break;
+       case IOP13XX_PMMR_PHYS_MEM_BASE ... IOP13XX_PMMR_UPPER_MEM_PA:
+               retval = (void *) IOP13XX_PMMR_PHYS_TO_VIRT(cookie);
+               break;
+       default:
+               retval = __ioremap(cookie, size, flags);
+       }
+
+       return retval;
+}
+EXPORT_SYMBOL(__iop13xx_ioremap);
+
+void __iop13xx_iounmap(void __iomem *addr)
+{
+       extern void __iounmap(volatile void __iomem *addr);
+
+       if (iop13xx_atue_mem_base)
+               if (addr >= (void __iomem *) iop13xx_atue_mem_base &&
+                   addr < (void __iomem *) (iop13xx_atue_mem_base +
+                                            iop13xx_atue_mem_size))
+                   goto skip;
+
+       if (iop13xx_atux_mem_base)
+               if (addr >= (void __iomem *) iop13xx_atux_mem_base &&
+                   addr < (void __iomem *) (iop13xx_atux_mem_base +
+                                            iop13xx_atux_mem_size))
+                   goto skip;
+
+       switch ((u32) addr) {
+       case IOP13XX_PCIE_LOWER_IO_VA ... IOP13XX_PCIE_UPPER_IO_VA:
+       case IOP13XX_PCIX_LOWER_IO_VA ... IOP13XX_PCIX_UPPER_IO_VA:
+       case IOP13XX_PMMR_VIRT_MEM_BASE ... IOP13XX_PMMR_UPPER_MEM_VA:
+               goto skip;
+       }
+       __iounmap(addr);
+
+skip:
+       return;
+}
+EXPORT_SYMBOL(__iop13xx_iounmap);
diff --git a/arch/arm/mach-iop13xx/iq81340mc.c b/arch/arm/mach-iop13xx/iq81340mc.c
new file mode 100644 (file)
index 0000000..ee59578
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * iq81340mc board support
+ * Copyright (c) 2005-2006, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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.
+ *
+ */
+#include <linux/pci.h>
+
+#include <asm/hardware.h>
+#include <asm/irq.h>
+#include <asm/mach/pci.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/arch/pci.h>
+#include <asm/mach/time.h>
+
+extern int init_atu; /* Flag to select which ATU(s) to initialize / disable */
+
+static int __init
+iq81340mc_pcix_map_irq(struct pci_dev *dev, u8 idsel, u8 pin)
+{
+       switch (idsel) {
+       case 1:
+               switch (pin) {
+               case 1: return ATUX_INTB;
+               case 2: return ATUX_INTC;
+               case 3: return ATUX_INTD;
+               case 4: return ATUX_INTA;
+               default: return -1;
+               }
+       case 2:
+               switch (pin) {
+               case 1: return ATUX_INTC;
+               case 2: return ATUX_INTD;
+               case 3: return ATUX_INTC;
+               case 4: return ATUX_INTD;
+               default: return -1;
+               }
+       default: return -1;
+       }
+}
+
+static struct hw_pci iq81340mc_pci __initdata = {
+       .swizzle        = pci_std_swizzle,
+       .nr_controllers = 0,
+       .setup          = iop13xx_pci_setup,
+       .map_irq        = iq81340mc_pcix_map_irq,
+       .scan           = iop13xx_scan_bus,
+       .preinit        = iop13xx_pci_init,
+};
+
+static int __init iq81340mc_pci_init(void)
+{
+       iop13xx_atu_select(&iq81340mc_pci);
+       pci_common_init(&iq81340mc_pci);
+       iop13xx_map_pci_memory();
+
+       return 0;
+}
+
+static void __init iq81340mc_init(void)
+{
+       iop13xx_platform_init();
+       iq81340mc_pci_init();
+}
+
+static void __init iq81340mc_timer_init(void)
+{
+       iop13xx_init_time(400000000);
+}
+
+static struct sys_timer iq81340mc_timer = {
+       .init       = iq81340mc_timer_init,
+       .offset     = iop13xx_gettimeoffset,
+};
+
+MACHINE_START(IQ81340MC, "Intel IQ81340MC")
+       /* Maintainer: Dan Williams <dan.j.williams@intel.com> */
+       .phys_io        = PHYS_IO,
+       .io_pg_offst    = IO_PG_OFFSET,
+       .map_io         = iop13xx_map_io,
+       .init_irq       = iop13xx_init_irq,
+       .timer          = &iq81340mc_timer,
+       .boot_params    = BOOT_PARAM_OFFSET,
+       .init_machine   = iq81340mc_init,
+MACHINE_END
diff --git a/arch/arm/mach-iop13xx/iq81340sc.c b/arch/arm/mach-iop13xx/iq81340sc.c
new file mode 100644 (file)
index 0000000..6677e14
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * iq81340sc board support
+ * Copyright (c) 2005-2006, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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.
+ *
+ */
+#include <linux/pci.h>
+
+#include <asm/hardware.h>
+#include <asm/irq.h>
+#include <asm/mach/pci.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/arch/pci.h>
+#include <asm/mach/time.h>
+
+extern int init_atu;
+
+static int __init
+iq81340sc_atux_map_irq(struct pci_dev *dev, u8 idsel, u8 pin)
+{
+       WARN_ON(idsel < 1 || idsel > 2);
+
+       switch (idsel) {
+       case 1:
+               switch (pin) {
+               case 1: return ATUX_INTB;
+               case 2: return ATUX_INTC;
+               case 3: return ATUX_INTD;
+               case 4: return ATUX_INTA;
+               default: return -1;
+               }
+       case 2:
+               switch (pin) {
+               case 1: return ATUX_INTC;
+               case 2: return ATUX_INTC;
+               case 3: return ATUX_INTC;
+               case 4: return ATUX_INTC;
+               default: return -1;
+               }
+       default: return -1;
+       }
+}
+
+static struct hw_pci iq81340sc_pci __initdata = {
+       .swizzle        = pci_std_swizzle,
+       .nr_controllers = 0,
+       .setup          = iop13xx_pci_setup,
+       .scan           = iop13xx_scan_bus,
+       .map_irq        = iq81340sc_atux_map_irq,
+       .preinit        = iop13xx_pci_init
+};
+
+static int __init iq81340sc_pci_init(void)
+{
+       iop13xx_atu_select(&iq81340sc_pci);
+       pci_common_init(&iq81340sc_pci);
+       iop13xx_map_pci_memory();
+
+       return 0;
+}
+
+static void __init iq81340sc_init(void)
+{
+       iop13xx_platform_init();
+       iq81340sc_pci_init();
+}
+
+static void __init iq81340sc_timer_init(void)
+{
+       iop13xx_init_time(400000000);
+}
+
+static struct sys_timer iq81340sc_timer = {
+       .init       = iq81340sc_timer_init,
+       .offset     = iop13xx_gettimeoffset,
+};
+
+MACHINE_START(IQ81340SC, "Intel IQ81340SC")
+       /* Maintainer: Dan Williams <dan.j.williams@intel.com> */
+       .phys_io        = PHYS_IO,
+       .io_pg_offst    = IO_PG_OFFSET,
+       .map_io         = iop13xx_map_io,
+       .init_irq       = iop13xx_init_irq,
+       .timer          = &iq81340sc_timer,
+       .boot_params    = BOOT_PARAM_OFFSET,
+       .init_machine   = iq81340sc_init,
+MACHINE_END
diff --git a/arch/arm/mach-iop13xx/irq.c b/arch/arm/mach-iop13xx/irq.c
new file mode 100644 (file)
index 0000000..c4d9c8c
--- /dev/null
@@ -0,0 +1,286 @@
+/*
+ * iop13xx IRQ handling / support functions
+ * Copyright (c) 2005-2006, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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.
+ *
+ */
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/list.h>
+#include <linux/sysctl.h>
+#include <asm/uaccess.h>
+#include <asm/mach/irq.h>
+#include <asm/irq.h>
+#include <asm/hardware.h>
+#include <asm/mach-types.h>
+#include <asm/arch/irqs.h>
+
+/* INTCTL0 CP6 R0 Page 4
+ */
+static inline u32 read_intctl_0(void)
+{
+       u32 val;
+       asm volatile("mrc p6, 0, %0, c0, c4, 0":"=r" (val));
+       return val;
+}
+static inline void write_intctl_0(u32 val)
+{
+       asm volatile("mcr p6, 0, %0, c0, c4, 0"::"r" (val));
+}
+
+/* INTCTL1 CP6 R1 Page 4
+ */
+static inline u32 read_intctl_1(void)
+{
+       u32 val;
+       asm volatile("mrc p6, 0, %0, c1, c4, 0":"=r" (val));
+       return val;
+}
+static inline void write_intctl_1(u32 val)
+{
+       asm volatile("mcr p6, 0, %0, c1, c4, 0"::"r" (val));
+}
+
+/* INTCTL2 CP6 R2 Page 4
+ */
+static inline u32 read_intctl_2(void)
+{
+       u32 val;
+       asm volatile("mrc p6, 0, %0, c2, c4, 0":"=r" (val));
+       return val;
+}
+static inline void write_intctl_2(u32 val)
+{
+       asm volatile("mcr p6, 0, %0, c2, c4, 0"::"r" (val));
+}
+
+/* INTCTL3 CP6 R3 Page 4
+ */
+static inline u32 read_intctl_3(void)
+{
+       u32 val;
+       asm volatile("mrc p6, 0, %0, c3, c4, 0":"=r" (val));
+       return val;
+}
+static inline void write_intctl_3(u32 val)
+{
+       asm volatile("mcr p6, 0, %0, c3, c4, 0"::"r" (val));
+}
+
+/* INTSTR0 CP6 R0 Page 5
+ */
+static inline u32 read_intstr_0(void)
+{
+       u32 val;
+       asm volatile("mrc p6, 0, %0, c0, c5, 0":"=r" (val));
+       return val;
+}
+static inline void write_intstr_0(u32 val)
+{
+       asm volatile("mcr p6, 0, %0, c0, c5, 0"::"r" (val));
+}
+
+/* INTSTR1 CP6 R1 Page 5
+ */
+static inline u32 read_intstr_1(void)
+{
+       u32 val;
+       asm volatile("mrc p6, 0, %0, c1, c5, 0":"=r" (val));
+       return val;
+}
+static void write_intstr_1(u32 val)
+{
+       asm volatile("mcr p6, 0, %0, c1, c5, 0"::"r" (val));
+}
+
+/* INTSTR2 CP6 R2 Page 5
+ */
+static inline u32 read_intstr_2(void)
+{
+       u32 val;
+       asm volatile("mrc p6, 0, %0, c2, c5, 0":"=r" (val));
+       return val;
+}
+static void write_intstr_2(u32 val)
+{
+       asm volatile("mcr p6, 0, %0, c2, c5, 0"::"r" (val));
+}
+
+/* INTSTR3 CP6 R3 Page 5
+ */
+static inline u32 read_intstr_3(void)
+{
+       u32 val;
+       asm volatile("mrc p6, 0, %0, c3, c5, 0":"=r" (val));
+       return val;
+}
+static void write_intstr_3(u32 val)
+{
+       asm volatile("mcr p6, 0, %0, c3, c5, 0"::"r" (val));
+}
+
+/* INTBASE CP6 R0 Page 2
+ */
+static inline u32 read_intbase(void)
+{
+       u32 val;
+       asm volatile("mrc p6, 0, %0, c0, c2, 0":"=r" (val));
+       return val;
+}
+static void write_intbase(u32 val)
+{
+       asm volatile("mcr p6, 0, %0, c0, c2, 0"::"r" (val));
+}
+
+/* INTSIZE CP6 R2 Page 2
+ */
+static inline u32 read_intsize(void)
+{
+       u32 val;
+       asm volatile("mrc p6, 0, %0, c2, c2, 0":"=r" (val));
+       return val;
+}
+static void write_intsize(u32 val)
+{
+       asm volatile("mcr p6, 0, %0, c2, c2, 0"::"r" (val));
+}
+
+/* 0 = Interrupt Masked and 1 = Interrupt not masked */
+static void
+iop13xx_irq_mask0 (unsigned int irq)
+{
+       u32 cp_flags = iop13xx_cp6_save();
+       write_intctl_0(read_intctl_0() & ~(1 << (irq - 0)));
+       iop13xx_cp6_restore(cp_flags);
+}
+
+static void
+iop13xx_irq_mask1 (unsigned int irq)
+{
+       u32 cp_flags = iop13xx_cp6_save();
+       write_intctl_1(read_intctl_1() & ~(1 << (irq - 32)));
+       iop13xx_cp6_restore(cp_flags);
+}
+
+static void
+iop13xx_irq_mask2 (unsigned int irq)
+{
+       u32 cp_flags = iop13xx_cp6_save();
+       write_intctl_2(read_intctl_2() & ~(1 << (irq - 64)));
+       iop13xx_cp6_restore(cp_flags);
+}
+
+static void
+iop13xx_irq_mask3 (unsigned int irq)
+{
+       u32 cp_flags = iop13xx_cp6_save();
+       write_intctl_3(read_intctl_3() & ~(1 << (irq - 96)));
+       iop13xx_cp6_restore(cp_flags);
+}
+
+static void
+iop13xx_irq_unmask0(unsigned int irq)
+{
+       u32 cp_flags = iop13xx_cp6_save();
+       write_intctl_0(read_intctl_0() | (1 << (irq - 0)));
+       iop13xx_cp6_restore(cp_flags);
+}
+
+static void
+iop13xx_irq_unmask1(unsigned int irq)
+{
+       u32 cp_flags = iop13xx_cp6_save();
+       write_intctl_1(read_intctl_1() | (1 << (irq - 32)));
+       iop13xx_cp6_restore(cp_flags);
+}
+
+static void
+iop13xx_irq_unmask2(unsigned int irq)
+{
+       u32 cp_flags = iop13xx_cp6_save();
+       write_intctl_2(read_intctl_2() | (1 << (irq - 64)));
+       iop13xx_cp6_restore(cp_flags);
+}
+
+static void
+iop13xx_irq_unmask3(unsigned int irq)
+{
+       u32 cp_flags = iop13xx_cp6_save();
+       write_intctl_3(read_intctl_3() | (1 << (irq - 96)));
+       iop13xx_cp6_restore(cp_flags);
+}
+
+static struct irqchip iop13xx_irqchip0 = {
+       .ack    = iop13xx_irq_mask0,
+       .mask   = iop13xx_irq_mask0,
+       .unmask = iop13xx_irq_unmask0,
+};
+
+static struct irqchip iop13xx_irqchip1 = {
+       .ack    = iop13xx_irq_mask1,
+       .mask   = iop13xx_irq_mask1,
+       .unmask = iop13xx_irq_unmask1,
+};
+
+static struct irqchip iop13xx_irqchip2 = {
+       .ack    = iop13xx_irq_mask2,
+       .mask   = iop13xx_irq_mask2,
+       .unmask = iop13xx_irq_unmask2,
+};
+
+static struct irqchip iop13xx_irqchip3 = {
+       .ack    = iop13xx_irq_mask3,
+       .mask   = iop13xx_irq_mask3,
+       .unmask = iop13xx_irq_unmask3,
+};
+
+void __init iop13xx_init_irq(void)
+{
+       unsigned int i;
+
+       u32 cp_flags = iop13xx_cp6_save();
+
+       /* disable all interrupts */
+       write_intctl_0(0);
+       write_intctl_1(0);
+       write_intctl_2(0);
+       write_intctl_3(0);
+
+       /* treat all as IRQ */
+       write_intstr_0(0);
+       write_intstr_1(0);
+       write_intstr_2(0);
+       write_intstr_3(0);
+
+       /* initialize the interrupt vector generator */
+       write_intbase(INTBASE);
+       write_intsize(INTSIZE_4);
+
+       for(i = 0; i < NR_IOP13XX_IRQS; i++) {
+               if (i < 32)
+                       set_irq_chip(i, &iop13xx_irqchip0);
+               else if (i < 64)
+                       set_irq_chip(i, &iop13xx_irqchip1);
+               else if (i < 96)
+                       set_irq_chip(i, &iop13xx_irqchip2);
+               else
+                       set_irq_chip(i, &iop13xx_irqchip3);
+
+               set_irq_handler(i, do_level_IRQ);
+               set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
+       }
+
+       iop13xx_cp6_restore(cp_flags);
+}
diff --git a/arch/arm/mach-iop13xx/pci.c b/arch/arm/mach-iop13xx/pci.c
new file mode 100644 (file)
index 0000000..89ec70e
--- /dev/null
@@ -0,0 +1,1113 @@
+/*
+ * iop13xx PCI support
+ * Copyright (c) 2005-2006, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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.
+ *
+ */
+
+#include <linux/pci.h>
+#include <linux/delay.h>
+
+#include <asm/irq.h>
+#include <asm/hardware.h>
+#include <asm/sizes.h>
+#include <asm/mach/pci.h>
+#include <asm/arch/pci.h>
+
+#define IOP13XX_PCI_DEBUG 0
+#define PRINTK(x...) ((void)(IOP13XX_PCI_DEBUG && printk(x)))
+
+u32 iop13xx_atux_pmmr_offset; /* This offset can change based on strapping */
+u32 iop13xx_atue_pmmr_offset; /* This offset can change based on strapping */
+static struct pci_bus *pci_bus_atux = 0;
+static struct pci_bus *pci_bus_atue = 0;
+u32 iop13xx_atue_mem_base;
+u32 iop13xx_atux_mem_base;
+size_t iop13xx_atue_mem_size;
+size_t iop13xx_atux_mem_size;
+unsigned long iop13xx_pcibios_min_io = 0;
+unsigned long iop13xx_pcibios_min_mem = 0;
+
+EXPORT_SYMBOL(iop13xx_atue_mem_base);
+EXPORT_SYMBOL(iop13xx_atux_mem_base);
+EXPORT_SYMBOL(iop13xx_atue_mem_size);
+EXPORT_SYMBOL(iop13xx_atux_mem_size);
+
+int init_atu = 0; /* Flag to select which ATU(s) to initialize / disable */
+static unsigned long atux_trhfa_timeout = 0; /* Trhfa = RST# high to first
+                                                access */
+
+/* Scan the initialized busses and ioremap the requested memory range
+ */
+void iop13xx_map_pci_memory(void)
+{
+       int atu;
+       struct pci_bus *bus;
+       struct pci_dev *dev;
+       resource_size_t end = 0;
+
+       for (atu = 0; atu < 2; atu++) {
+               bus = atu ? pci_bus_atue : pci_bus_atux;
+               if (bus) {
+                       list_for_each_entry(dev, &bus->devices, bus_list) {
+                               int i;
+                               int max = 7;
+
+                               if (dev->subordinate)
+                                       max = DEVICE_COUNT_RESOURCE;
+
+                               for (i = 0; i < max; i++) {
+                                       struct resource *res = &dev->resource[i];
+                                       if (res->flags & IORESOURCE_MEM)
+                                               end = max(res->end, end);
+                               }
+                       }
+
+                       switch(atu) {
+                       case 0:
+                               iop13xx_atux_mem_size =
+                                       (end - IOP13XX_PCIX_LOWER_MEM_RA) + 1;
+
+                               /* 16MB align the request */
+                               if (iop13xx_atux_mem_size & (SZ_16M - 1)) {
+                                       iop13xx_atux_mem_size &= ~(SZ_16M - 1);
+                                       iop13xx_atux_mem_size += SZ_16M;
+                               }
+
+                               if (end) {
+                                       iop13xx_atux_mem_base =
+                                       (u32) __ioremap_pfn(
+                                       __phys_to_pfn(IOP13XX_PCIX_LOWER_MEM_PA)
+                                       , 0, iop13xx_atux_mem_size, 0);
+                                       if (!iop13xx_atux_mem_base) {
+                                               printk("%s: atux allocation "
+                                                      "failed\n", __FUNCTION__);
+                                               BUG();
+                                       }
+                               } else
+                                       iop13xx_atux_mem_size = 0;
+                               PRINTK("%s: atu: %d bus_size: %d mem_base: %x\n",
+                               __FUNCTION__, atu, iop13xx_atux_mem_size,
+                               iop13xx_atux_mem_base);
+                               break;
+                       case 1:
+                               iop13xx_atue_mem_size =
+                                       (end - IOP13XX_PCIE_LOWER_MEM_RA) + 1;
+
+                               /* 16MB align the request */
+                               if (iop13xx_atue_mem_size & (SZ_16M - 1)) {
+                                       iop13xx_atue_mem_size &= ~(SZ_16M - 1);
+                                       iop13xx_atue_mem_size += SZ_16M;
+                               }
+
+                               if (end) {
+                                       iop13xx_atue_mem_base =
+                                       (u32) __ioremap_pfn(
+                                       __phys_to_pfn(IOP13XX_PCIE_LOWER_MEM_PA)
+                                       , 0, iop13xx_atue_mem_size, 0);
+                                       if (!iop13xx_atue_mem_base) {
+                                               printk("%s: atue allocation "
+                                                      "failed\n", __FUNCTION__);
+                                               BUG();
+                                       }
+                               } else
+                                       iop13xx_atue_mem_size = 0;
+                               PRINTK("%s: atu: %d bus_size: %d mem_base: %x\n",
+                               __FUNCTION__, atu, iop13xx_atue_mem_size,
+                               iop13xx_atue_mem_base);
+                               break;
+                       }
+
+                       printk("%s: Initialized (%uM @ resource/virtual: %08lx/%08x)\n",
+                       atu ? "ATUE" : "ATUX",
+                       (atu ? iop13xx_atue_mem_size : iop13xx_atux_mem_size) /
+                       SZ_1M,
+                       atu ? IOP13XX_PCIE_LOWER_MEM_RA :
+                       IOP13XX_PCIX_LOWER_MEM_RA,
+                       atu ? iop13xx_atue_mem_base :
+                       iop13xx_atux_mem_base);
+                       end = 0;
+               }
+
+       }
+}
+
+static inline int iop13xx_atu_function(int atu)
+{
+       int func = 0;
+       /* the function number depends on the value of the
+        * IOP13XX_INTERFACE_SEL_PCIX reset strap
+        * see C-Spec section 3.17
+        */
+       switch(atu) {
+       case IOP13XX_INIT_ATU_ATUX:
+               if (__raw_readl(IOP13XX_ESSR0) & IOP13XX_INTERFACE_SEL_PCIX)
+                       func = 5;
+               else
+                       func = 0;
+               break;
+       case IOP13XX_INIT_ATU_ATUE:
+               if (__raw_readl(IOP13XX_ESSR0) & IOP13XX_INTERFACE_SEL_PCIX)
+                       func = 0;
+               else
+                       func = 5;
+               break;
+       default:
+               BUG();
+       }
+
+       return func;
+}
+
+/* iop13xx_atux_cfg_address - format a configuration address for atux
+ * @bus: Target bus to access
+ * @devfn: Combined device number and function number
+ * @where: Desired register's address offset
+ *
+ * Convert the parameters to a configuration address formatted
+ * according the PCI-X 2.0 specification
+ */
+static u32 iop13xx_atux_cfg_address(struct pci_bus *bus, int devfn, int where)
+{
+       struct pci_sys_data *sys = bus->sysdata;
+       u32 addr;
+
+       if (sys->busnr == bus->number)
+               addr = 1 << (PCI_SLOT(devfn) + 16) | (PCI_SLOT(devfn) << 11);
+       else
+               addr = bus->number << 16 | PCI_SLOT(devfn) << 11 | 1;
+
+       addr |= PCI_FUNC(devfn) << 8 | ((where & 0xff) & ~3);
+       addr |= ((where & 0xf00) >> 8) << 24; /* upper register number */
+
+       return addr;
+}
+
+/* iop13xx_atue_cfg_address - format a configuration address for atue
+ * @bus: Target bus to access
+ * @devfn: Combined device number and function number
+ * @where: Desired register's address offset
+ *
+ * Convert the parameters to an address usable by the ATUE_OCCAR
+ */
+static u32 iop13xx_atue_cfg_address(struct pci_bus *bus, int devfn, int where)
+{
+       struct pci_sys_data *sys = bus->sysdata;
+       u32 addr;
+
+       PRINTK("iop13xx_atue_cfg_address: bus: %d dev: %d func: %d",
+               bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn));
+       addr = ((u32) bus->number)     << IOP13XX_ATUE_OCCAR_BUS_NUM |
+                  ((u32) PCI_SLOT(devfn)) << IOP13XX_ATUE_OCCAR_DEV_NUM |
+                  ((u32) PCI_FUNC(devfn)) << IOP13XX_ATUE_OCCAR_FUNC_NUM |
+                  (where & ~0x3);
+
+       if (sys->busnr != bus->number)
+               addr |= 1; /* type 1 access */
+
+       return addr;
+}
+
+/* This routine checks the status of the last configuration cycle.  If an error
+ * was detected it returns >0, else it returns a 0.  The errors being checked
+ * are parity, master abort, target abort (master and target).  These types of
+ * errors occure during a config cycle where there is no device, like during
+ * the discovery stage.
+ */
+static int iop13xx_atux_pci_status(int clear)
+{
+       unsigned int status;
+       int err = 0;
+
+       /*
+        * Check the status registers.
+        */
+       status = __raw_readw(IOP13XX_ATUX_ATUSR);
+       if (status & IOP_PCI_STATUS_ERROR)
+       {
+               PRINTK("\t\t\tPCI error: ATUSR %#08x", status);
+               if(clear)
+                       __raw_writew(status & IOP_PCI_STATUS_ERROR,
+                               IOP13XX_ATUX_ATUSR);
+               err = 1;
+       }
+       status = __raw_readl(IOP13XX_ATUX_ATUISR);
+       if (status & IOP13XX_ATUX_ATUISR_ERROR)
+       {
+               PRINTK("\t\t\tPCI error interrupt:  ATUISR %#08x", status);
+               if(clear)
+                       __raw_writel(status & IOP13XX_ATUX_ATUISR_ERROR,
+                               IOP13XX_ATUX_ATUISR);
+               err = 1;
+       }
+       return err;
+}
+
+/* Simply write the address register and read the configuration
+ * data.  Note that the data dependency on %0 encourages an abort
+ * to be detected before we return.
+ */
+static inline u32 iop13xx_atux_read(unsigned long addr)
+{
+       u32 val;
+
+       __asm__ __volatile__(
+               "str    %1, [%2]\n\t"
+               "ldr    %0, [%3]\n\t"
+               "mov    %0, %0\n\t"
+               : "=r" (val)
+               : "r" (addr), "r" (IOP13XX_ATUX_OCCAR), "r" (IOP13XX_ATUX_OCCDR));
+
+       return val;
+}
+
+/* The read routines must check the error status of the last configuration
+ * cycle.  If there was an error, the routine returns all hex f's.
+ */
+static int
+iop13xx_atux_read_config(struct pci_bus *bus, unsigned int devfn, int where,
+               int size, u32 *value)
+{
+       unsigned long addr = iop13xx_atux_cfg_address(bus, devfn, where);
+       u32 val = iop13xx_atux_read(addr) >> ((where & 3) * 8);
+
+       if (iop13xx_atux_pci_status(1) || is_atux_occdr_error()) {
+               __raw_writel(__raw_readl(IOP13XX_XBG_BECSR) & 3,
+                       IOP13XX_XBG_BECSR);
+               val = 0xffffffff;
+       }
+
+       *value = val;
+
+       return PCIBIOS_SUCCESSFUL;
+}
+
+static int
+iop13xx_atux_write_config(struct pci_bus *bus, unsigned int devfn, int where,
+               int size, u32 value)
+{
+       unsigned long addr = iop13xx_atux_cfg_address(bus, devfn, where);
+       u32 val;
+
+       if (size != 4) {
+               val = iop13xx_atux_read(addr);
+               if (!iop13xx_atux_pci_status(1) == 0)
+                       return PCIBIOS_SUCCESSFUL;
+
+               where = (where & 3) * 8;
+
+               if (size == 1)
+                       val &= ~(0xff << where);
+               else
+                       val &= ~(0xffff << where);
+
+               __raw_writel(val | value << where, IOP13XX_ATUX_OCCDR);
+       } else {
+               __raw_writel(addr, IOP13XX_ATUX_OCCAR);
+               __raw_writel(value, IOP13XX_ATUX_OCCDR);
+       }
+
+       return PCIBIOS_SUCCESSFUL;
+}
+
+static struct pci_ops iop13xx_atux_ops = {
+       .read   = iop13xx_atux_read_config,
+       .write  = iop13xx_atux_write_config,
+};
+
+/* This routine checks the status of the last configuration cycle.  If an error
+ * was detected it returns >0, else it returns a 0.  The errors being checked
+ * are parity, master abort, target abort (master and target).  These types of
+ * errors occure during a config cycle where there is no device, like during
+ * the discovery stage.
+ */
+static int iop13xx_atue_pci_status(int clear)
+{
+       unsigned int status;
+       int err = 0;
+
+       /*
+        * Check the status registers.
+        */
+
+       /* standard pci status register */
+       status = __raw_readw(IOP13XX_ATUE_ATUSR);
+       if (status & IOP_PCI_STATUS_ERROR) {
+               PRINTK("\t\t\tPCI error: ATUSR %#08x", status);
+               if(clear)
+                       __raw_writew(status & IOP_PCI_STATUS_ERROR,
+                               IOP13XX_ATUE_ATUSR);
+               err++;
+       }
+
+       /* check the normal status bits in the ATUISR */
+       status = __raw_readl(IOP13XX_ATUE_ATUISR);
+       if (status & IOP13XX_ATUE_ATUISR_ERROR) {
+               PRINTK("\t\t\tPCI error: ATUISR %#08x", status);
+               if (clear)
+                       __raw_writew(status & IOP13XX_ATUE_ATUISR_ERROR,
+                               IOP13XX_ATUE_ATUISR);
+               err++;
+
+               /* check the PCI-E status if the ATUISR reports an interface error */
+               if (status & IOP13XX_ATUE_STAT_PCI_IFACE_ERR) {
+                       /* get the unmasked errors */
+                       status = __raw_readl(IOP13XX_ATUE_PIE_STS) &
+                                       ~(__raw_readl(IOP13XX_ATUE_PIE_MSK));
+
+                       if (status) {
+                               PRINTK("\t\t\tPCI-E error: ATUE_PIE_STS %#08x",
+                                       __raw_readl(IOP13XX_ATUE_PIE_STS));
+                               err++;
+                       } else {
+                               PRINTK("\t\t\tPCI-E error: ATUE_PIE_STS %#08x",
+                                       __raw_readl(IOP13XX_ATUE_PIE_STS));
+                               PRINTK("\t\t\tPCI-E error: ATUE_PIE_MSK %#08x",
+                                       __raw_readl(IOP13XX_ATUE_PIE_MSK));
+                               BUG();
+                       }
+
+                       if(clear)
+                               __raw_writel(status, IOP13XX_ATUE_PIE_STS);
+               }
+       }
+
+       return err;
+}
+
+static inline int __init
+iop13xx_pcie_map_irq(struct pci_dev *dev, u8 idsel, u8 pin)
+{
+       WARN_ON(idsel != 0);
+
+       switch (pin) {
+       case 1: return ATUE_INTA;
+       case 2: return ATUE_INTB;
+       case 3: return ATUE_INTC;
+       case 4: return ATUE_INTD;
+       default: return -1;
+       }
+}
+
+static inline u32 iop13xx_atue_read(unsigned long addr)
+{
+       u32 val;
+
+       __raw_writel(addr, IOP13XX_ATUE_OCCAR);
+       val = __raw_readl(IOP13XX_ATUE_OCCDR);
+
+       rmb();
+
+       return val;
+}
+
+/* The read routines must check the error status of the last configuration
+ * cycle.  If there was an error, the routine returns all hex f's.
+ */
+static int
+iop13xx_atue_read_config(struct pci_bus *bus, unsigned int devfn, int where,
+               int size, u32 *value)
+{
+       u32 val;
+       unsigned long addr = iop13xx_atue_cfg_address(bus, devfn, where);
+
+       /* Hide device numbers > 0 on the local PCI-E bus (Type 0 access) */
+       if (!PCI_SLOT(devfn) || (addr & 1)) {
+               val = iop13xx_atue_read(addr) >> ((where & 3) * 8);
+               if( iop13xx_atue_pci_status(1) || is_atue_occdr_error() ) {
+                       __raw_writel(__raw_readl(IOP13XX_XBG_BECSR) & 3,
+                               IOP13XX_XBG_BECSR);
+                       val = 0xffffffff;
+               }
+
+               PRINTK("addr=%#0lx, val=%#010x", addr, val);
+       } else
+               val = 0xffffffff;
+
+       *value = val;
+
+       return PCIBIOS_SUCCESSFUL;
+}
+
+static int
+iop13xx_atue_write_config(struct pci_bus *bus, unsigned int devfn, int where,
+               int size, u32 value)
+{
+       unsigned long addr = iop13xx_atue_cfg_address(bus, devfn, where);
+       u32 val;
+
+       if (size != 4) {
+               val = iop13xx_atue_read(addr);
+               if (!iop13xx_atue_pci_status(1) == 0)
+                       return PCIBIOS_SUCCESSFUL;
+
+               where = (where & 3) * 8;
+
+               if (size == 1)
+                       val &= ~(0xff << where);
+               else
+                       val &= ~(0xffff << where);
+
+               __raw_writel(val | value << where, IOP13XX_ATUE_OCCDR);
+       } else {
+               __raw_writel(addr, IOP13XX_ATUE_OCCAR);
+               __raw_writel(value, IOP13XX_ATUE_OCCDR);
+       }
+
+       return PCIBIOS_SUCCESSFUL;
+}
+
+static struct pci_ops iop13xx_atue_ops = {
+       .read   = iop13xx_atue_read_config,
+       .write  = iop13xx_atue_write_config,
+};
+
+/* When a PCI device does not exist during config cycles, the XScale gets a
+ * bus error instead of returning 0xffffffff.  We can't rely on the ATU status
+ * bits to tell us that it was indeed a configuration cycle that caused this
+ * error especially in the case when the ATUE link is down.  Instead we rely
+ * on data from the south XSI bridge to validate the abort
+ */
+int
+iop13xx_pci_abort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
+{
+       PRINTK("Data abort: address = 0x%08lx "
+                   "fsr = 0x%03x PC = 0x%08lx LR = 0x%08lx",
+               addr, fsr, regs->ARM_pc, regs->ARM_lr);
+
+       PRINTK("IOP13XX_XBG_BECSR: %#10x", __raw_readl(IOP13XX_XBG_BECSR));
+       PRINTK("IOP13XX_XBG_BERAR: %#10x", __raw_readl(IOP13XX_XBG_BERAR));
+       PRINTK("IOP13XX_XBG_BERUAR: %#10x", __raw_readl(IOP13XX_XBG_BERUAR));
+
+       /*  If it was an imprecise abort, then we need to correct the
+        *  return address to be _after_ the instruction.
+        */
+       if (fsr & (1 << 10))
+               regs->ARM_pc += 4;
+
+       if (is_atue_occdr_error() || is_atux_occdr_error())
+               return 0;
+       else
+               return 1;
+}
+
+/* Scan an IOP13XX PCI bus.  nr selects which ATU we use.
+ */
+struct pci_bus *iop13xx_scan_bus(int nr, struct pci_sys_data *sys)
+{
+       int which_atu;
+       struct pci_bus *bus = NULL;
+
+       switch (init_atu) {
+       case IOP13XX_INIT_ATU_ATUX:
+               which_atu = nr ? 0 : IOP13XX_INIT_ATU_ATUX;
+               break;
+       case IOP13XX_INIT_ATU_ATUE:
+               which_atu = nr ? 0 : IOP13XX_INIT_ATU_ATUE;
+               break;
+       case (IOP13XX_INIT_ATU_ATUX | IOP13XX_INIT_ATU_ATUE):
+               which_atu = nr ? IOP13XX_INIT_ATU_ATUE : IOP13XX_INIT_ATU_ATUX;
+               break;
+       default:
+               which_atu = 0;
+       }
+
+       if (!which_atu) {
+               BUG();
+               return NULL;
+       }
+
+       switch (which_atu) {
+       case IOP13XX_INIT_ATU_ATUX:
+               if (time_after_eq(jiffies + msecs_to_jiffies(1000),
+                                 atux_trhfa_timeout))  /* ensure not wrap */
+                       while(time_before(jiffies, atux_trhfa_timeout))
+                               udelay(100);
+
+               bus = pci_bus_atux = pci_scan_bus(sys->busnr,
+                                                 &iop13xx_atux_ops,
+                                                 sys);
+               break;
+       case IOP13XX_INIT_ATU_ATUE:
+               bus = pci_bus_atue = pci_scan_bus(sys->busnr,
+                                                 &iop13xx_atue_ops,
+                                                 sys);
+               break;
+       }
+
+       return bus;
+}
+
+/* This function is called from iop13xx_pci_init() after assigning valid
+ * values to iop13xx_atue_pmmr_offset.  This is the location for common
+ * setup of ATUE for all IOP13XX implementations.
+ */
+void __init iop13xx_atue_setup(void)
+{
+       int func = iop13xx_atu_function(IOP13XX_INIT_ATU_ATUE);
+       u32 reg_val;
+
+       /* BAR 1 (1:1 mapping with Physical RAM) */
+       /* Set limit and enable */
+       __raw_writel(~(IOP13XX_MAX_RAM_SIZE - PHYS_OFFSET - 1) & ~0x1,
+                       IOP13XX_ATUE_IALR1);
+       __raw_writel(0x0, IOP13XX_ATUE_IAUBAR1);
+
+       /* Set base at the top of the reserved address space */
+       __raw_writel(PHYS_OFFSET | PCI_BASE_ADDRESS_MEM_TYPE_64 |
+                       PCI_BASE_ADDRESS_MEM_PREFETCH, IOP13XX_ATUE_IABAR1);
+
+       /* 1:1 mapping with physical ram
+        * (leave big endian byte swap disabled)
+        */
+        __raw_writel(0x0, IOP13XX_ATUE_IAUTVR1);
+        __raw_writel(PHYS_OFFSET, IOP13XX_ATUE_IATVR1);
+
+       /* Outbound window 1 (PCIX/PCIE memory window) */
+       /* 32 bit Address Space */
+       __raw_writel(0x0, IOP13XX_ATUE_OUMWTVR1);
+       /* PA[35:32] */
+       __raw_writel(IOP13XX_ATUE_OUMBAR_ENABLE |
+                       (IOP13XX_PCIE_MEM_PHYS_OFFSET >> 32),
+                       IOP13XX_ATUE_OUMBAR1);
+
+       /* Setup the I/O Bar
+        * A[35-16] in 31-12
+        */
+       __raw_writel(((IOP13XX_PCIE_LOWER_IO_PA >> 0x4) & 0xfffff000),
+               IOP13XX_ATUE_OIOBAR);
+       __raw_writel(IOP13XX_PCIE_LOWER_IO_BA, IOP13XX_ATUE_OIOWTVR);
+
+       /* clear startup errors */
+       iop13xx_atue_pci_status(1);
+
+       /* OIOBAR function number
+        */
+       reg_val = __raw_readl(IOP13XX_ATUE_OIOBAR);
+       reg_val &= ~0x7;
+       reg_val |= func;
+       __raw_writel(reg_val, IOP13XX_ATUE_OIOBAR);
+
+       /* OUMBAR function numbers
+        */
+       reg_val = __raw_readl(IOP13XX_ATUE_OUMBAR0);
+       reg_val &= ~(IOP13XX_ATU_OUMBAR_FUNC_NUM_MASK <<
+                       IOP13XX_ATU_OUMBAR_FUNC_NUM);
+       reg_val |= func << IOP13XX_ATU_OUMBAR_FUNC_NUM;
+       __raw_writel(reg_val, IOP13XX_ATUE_OUMBAR0);
+
+       reg_val = __raw_readl(IOP13XX_ATUE_OUMBAR1);
+       reg_val &= ~(IOP13XX_ATU_OUMBAR_FUNC_NUM_MASK <<
+                       IOP13XX_ATU_OUMBAR_FUNC_NUM);
+       reg_val |= func << IOP13XX_ATU_OUMBAR_FUNC_NUM;
+       __raw_writel(reg_val, IOP13XX_ATUE_OUMBAR1);
+
+       reg_val = __raw_readl(IOP13XX_ATUE_OUMBAR2);
+       reg_val &= ~(IOP13XX_ATU_OUMBAR_FUNC_NUM_MASK <<
+                       IOP13XX_ATU_OUMBAR_FUNC_NUM);
+       reg_val |= func << IOP13XX_ATU_OUMBAR_FUNC_NUM;
+       __raw_writel(reg_val, IOP13XX_ATUE_OUMBAR2);
+
+       reg_val = __raw_readl(IOP13XX_ATUE_OUMBAR3);
+       reg_val &= ~(IOP13XX_ATU_OUMBAR_FUNC_NUM_MASK <<
+                       IOP13XX_ATU_OUMBAR_FUNC_NUM);
+       reg_val |= func << IOP13XX_ATU_OUMBAR_FUNC_NUM;
+       __raw_writel(reg_val, IOP13XX_ATUE_OUMBAR3);
+
+       /* Enable inbound and outbound cycles
+        */
+       reg_val = __raw_readw(IOP13XX_ATUE_ATUCMD);
+       reg_val |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
+                       PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
+       __raw_writew(reg_val, IOP13XX_ATUE_ATUCMD);
+
+       reg_val = __raw_readl(IOP13XX_ATUE_ATUCR);
+       reg_val |= IOP13XX_ATUE_ATUCR_OUT_EN |
+                       IOP13XX_ATUE_ATUCR_IVM;
+       __raw_writel(reg_val, IOP13XX_ATUE_ATUCR);
+}
+
+void __init iop13xx_atue_disable(void)
+{
+       u32 reg_val;
+
+       __raw_writew(0x0, IOP13XX_ATUE_ATUCMD);
+       __raw_writel(IOP13XX_ATUE_ATUCR_IVM, IOP13XX_ATUE_ATUCR);
+
+       /* wait for cycles to quiesce */
+       while (__raw_readl(IOP13XX_ATUE_PCSR) & (IOP13XX_ATUE_PCSR_OUT_Q_BUSY |
+                                            IOP13XX_ATUE_PCSR_IN_Q_BUSY |
+                                            IOP13XX_ATUE_PCSR_LLRB_BUSY))
+               cpu_relax();
+
+       /* BAR 0 ( Disabled ) */
+       __raw_writel(0x0, IOP13XX_ATUE_IAUBAR0);
+       __raw_writel(0x0, IOP13XX_ATUE_IABAR0);
+       __raw_writel(0x0, IOP13XX_ATUE_IAUTVR0);
+       __raw_writel(0x0, IOP13XX_ATUE_IATVR0);
+       __raw_writel(0x0, IOP13XX_ATUE_IALR0);
+       reg_val = __raw_readl(IOP13XX_ATUE_OUMBAR0);
+       reg_val &= ~IOP13XX_ATUE_OUMBAR_ENABLE;
+       __raw_writel(reg_val, IOP13XX_ATUE_OUMBAR0);
+
+       /* BAR 1 ( Disabled ) */
+       __raw_writel(0x0, IOP13XX_ATUE_IAUBAR1);
+       __raw_writel(0x0, IOP13XX_ATUE_IABAR1);
+       __raw_writel(0x0, IOP13XX_ATUE_IAUTVR1);
+       __raw_writel(0x0, IOP13XX_ATUE_IATVR1);
+       __raw_writel(0x0, IOP13XX_ATUE_IALR1);
+       reg_val = __raw_readl(IOP13XX_ATUE_OUMBAR1);
+       reg_val &= ~IOP13XX_ATUE_OUMBAR_ENABLE;
+       __raw_writel(reg_val, IOP13XX_ATUE_OUMBAR1);
+
+       /* BAR 2 ( Disabled ) */
+       __raw_writel(0x0, IOP13XX_ATUE_IAUBAR2);
+       __raw_writel(0x0, IOP13XX_ATUE_IABAR2);
+       __raw_writel(0x0, IOP13XX_ATUE_IAUTVR2);
+       __raw_writel(0x0, IOP13XX_ATUE_IATVR2);
+       __raw_writel(0x0, IOP13XX_ATUE_IALR2);
+       reg_val = __raw_readl(IOP13XX_ATUE_OUMBAR2);
+       reg_val &= ~IOP13XX_ATUE_OUMBAR_ENABLE;
+       __raw_writel(reg_val, IOP13XX_ATUE_OUMBAR2);
+
+       /* BAR 3 ( Disabled ) */
+       reg_val = __raw_readl(IOP13XX_ATUE_OUMBAR3);
+       reg_val &= ~IOP13XX_ATUE_OUMBAR_ENABLE;
+       __raw_writel(reg_val, IOP13XX_ATUE_OUMBAR3);
+
+       /* Setup the I/O Bar
+        * A[35-16] in 31-12
+        */
+       __raw_writel((IOP13XX_PCIE_LOWER_IO_PA >> 0x4) & 0xfffff000,
+                       IOP13XX_ATUE_OIOBAR);
+       __raw_writel(IOP13XX_PCIE_LOWER_IO_BA, IOP13XX_ATUE_OIOWTVR);
+}
+
+/* This function is called from iop13xx_pci_init() after assigning valid
+ * values to iop13xx_atux_pmmr_offset.  This is the location for common
+ * setup of ATUX for all IOP13XX implementations.
+ */
+void __init iop13xx_atux_setup(void)
+{
+       u32 reg_val;
+       int func = iop13xx_atu_function(IOP13XX_INIT_ATU_ATUX);
+
+       /* Take PCI-X bus out of reset if bootloader hasn't already.
+        * According to spec, we should wait for 2^25 PCI clocks to meet
+        * the PCI timing parameter Trhfa (RST# high to first access).
+        * This is rarely necessary and often ignored.
+        */
+       reg_val = __raw_readl(IOP13XX_ATUX_PCSR);
+       if (reg_val & IOP13XX_ATUX_PCSR_P_RSTOUT) {
+               int msec = (reg_val >> IOP13XX_ATUX_PCSR_FREQ_OFFSET) & 0x7;
+               msec = 1000 / (8-msec); /* bits 100=133MHz, 111=>33MHz */
+               __raw_writel(reg_val & ~IOP13XX_ATUX_PCSR_P_RSTOUT,
+                               IOP13XX_ATUX_PCSR);
+               atux_trhfa_timeout = jiffies + msecs_to_jiffies(msec);
+       }
+       else
+               atux_trhfa_timeout = jiffies;
+
+       /* BAR 1 (1:1 mapping with Physical RAM) */
+       /* Set limit and enable */
+       __raw_writel(~(IOP13XX_MAX_RAM_SIZE - PHYS_OFFSET - 1) & ~0x1,
+                       IOP13XX_ATUX_IALR1);
+       __raw_writel(0x0, IOP13XX_ATUX_IAUBAR1);
+
+       /* Set base at the top of the reserved address space */
+       __raw_writel(PHYS_OFFSET | PCI_BASE_ADDRESS_MEM_TYPE_64 |
+                       PCI_BASE_ADDRESS_MEM_PREFETCH, IOP13XX_ATUX_IABAR1);
+
+       /* 1:1 mapping with physical ram
+        * (leave big endian byte swap disabled)
+        */
+       __raw_writel(0x0, IOP13XX_ATUX_IAUTVR1);
+       __raw_writel(PHYS_OFFSET, IOP13XX_ATUX_IATVR1);
+
+       /* Outbound window 1 (PCIX/PCIE memory window) */
+       /* 32 bit Address Space */
+       __raw_writel(0x0, IOP13XX_ATUX_OUMWTVR1);
+       /* PA[35:32] */
+       __raw_writel(IOP13XX_ATUX_OUMBAR_ENABLE |
+                       IOP13XX_PCIX_MEM_PHYS_OFFSET >> 32,
+                       IOP13XX_ATUX_OUMBAR1);
+
+       /* Setup the I/O Bar
+        * A[35-16] in 31-12
+        */
+       __raw_writel((IOP13XX_PCIX_LOWER_IO_PA >> 0x4) & 0xfffff000,
+               IOP13XX_ATUX_OIOBAR);
+       __raw_writel(IOP13XX_PCIX_LOWER_IO_BA, IOP13XX_ATUX_OIOWTVR);
+
+       /* clear startup errors */
+       iop13xx_atux_pci_status(1);
+
+       /* OIOBAR function number
+        */
+       reg_val = __raw_readl(IOP13XX_ATUX_OIOBAR);
+       reg_val &= ~0x7;
+       reg_val |= func;
+       __raw_writel(reg_val, IOP13XX_ATUX_OIOBAR);
+
+       /* OUMBAR function numbers
+        */
+       reg_val = __raw_readl(IOP13XX_ATUX_OUMBAR0);
+       reg_val &= ~(IOP13XX_ATU_OUMBAR_FUNC_NUM_MASK <<
+                       IOP13XX_ATU_OUMBAR_FUNC_NUM);
+       reg_val |= func << IOP13XX_ATU_OUMBAR_FUNC_NUM;
+       __raw_writel(reg_val, IOP13XX_ATUX_OUMBAR0);
+
+       reg_val = __raw_readl(IOP13XX_ATUX_OUMBAR1);
+       reg_val &= ~(IOP13XX_ATU_OUMBAR_FUNC_NUM_MASK <<
+                       IOP13XX_ATU_OUMBAR_FUNC_NUM);
+       reg_val |= func << IOP13XX_ATU_OUMBAR_FUNC_NUM;
+       __raw_writel(reg_val, IOP13XX_ATUX_OUMBAR1);
+
+       reg_val = __raw_readl(IOP13XX_ATUX_OUMBAR2);
+       reg_val &= ~(IOP13XX_ATU_OUMBAR_FUNC_NUM_MASK <<
+                       IOP13XX_ATU_OUMBAR_FUNC_NUM);
+       reg_val |= func << IOP13XX_ATU_OUMBAR_FUNC_NUM;
+       __raw_writel(reg_val, IOP13XX_ATUX_OUMBAR2);
+
+       reg_val = __raw_readl(IOP13XX_ATUX_OUMBAR3);
+       reg_val &= ~(IOP13XX_ATU_OUMBAR_FUNC_NUM_MASK <<
+                       IOP13XX_ATU_OUMBAR_FUNC_NUM);
+       reg_val |= func << IOP13XX_ATU_OUMBAR_FUNC_NUM;
+       __raw_writel(reg_val, IOP13XX_ATUX_OUMBAR3);
+
+       /* Enable inbound and outbound cycles
+        */
+       reg_val = __raw_readw(IOP13XX_ATUX_ATUCMD);
+       reg_val |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
+                       PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
+       __raw_writew(reg_val, IOP13XX_ATUX_ATUCMD);
+
+       reg_val = __raw_readl(IOP13XX_ATUX_ATUCR);
+       reg_val |= IOP13XX_ATUX_ATUCR_OUT_EN;
+       __raw_writel(reg_val, IOP13XX_ATUX_ATUCR);
+}
+
+void __init iop13xx_atux_disable(void)
+{
+       u32 reg_val;
+
+       __raw_writew(0x0, IOP13XX_ATUX_ATUCMD);
+       __raw_writel(0x0, IOP13XX_ATUX_ATUCR);
+
+       /* wait for cycles to quiesce */
+       while (__raw_readl(IOP13XX_ATUX_PCSR) & (IOP13XX_ATUX_PCSR_OUT_Q_BUSY |
+                                    IOP13XX_ATUX_PCSR_IN_Q_BUSY))
+               cpu_relax();
+
+       /* BAR 0 ( Disabled ) */
+       __raw_writel(0x0, IOP13XX_ATUX_IAUBAR0);
+       __raw_writel(0x0, IOP13XX_ATUX_IABAR0);
+       __raw_writel(0x0, IOP13XX_ATUX_IAUTVR0);
+       __raw_writel(0x0, IOP13XX_ATUX_IATVR0);
+       __raw_writel(0x0, IOP13XX_ATUX_IALR0);
+       reg_val = __raw_readl(IOP13XX_ATUX_OUMBAR0);
+       reg_val &= ~IOP13XX_ATUX_OUMBAR_ENABLE;
+       __raw_writel(reg_val, IOP13XX_ATUX_OUMBAR0);
+
+       /* BAR 1 ( Disabled ) */
+       __raw_writel(0x0, IOP13XX_ATUX_IAUBAR1);
+       __raw_writel(0x0, IOP13XX_ATUX_IABAR1);
+       __raw_writel(0x0, IOP13XX_ATUX_IAUTVR1);
+       __raw_writel(0x0, IOP13XX_ATUX_IATVR1);
+       __raw_writel(0x0, IOP13XX_ATUX_IALR1);
+       reg_val = __raw_readl(IOP13XX_ATUX_OUMBAR1);
+       reg_val &= ~IOP13XX_ATUX_OUMBAR_ENABLE;
+       __raw_writel(reg_val, IOP13XX_ATUX_OUMBAR1);
+
+       /* BAR 2 ( Disabled ) */
+       __raw_writel(0x0, IOP13XX_ATUX_IAUBAR2);
+       __raw_writel(0x0, IOP13XX_ATUX_IABAR2);
+       __raw_writel(0x0, IOP13XX_ATUX_IAUTVR2);
+       __raw_writel(0x0, IOP13XX_ATUX_IATVR2);
+       __raw_writel(0x0, IOP13XX_ATUX_IALR2);
+       reg_val = __raw_readl(IOP13XX_ATUX_OUMBAR2);
+       reg_val &= ~IOP13XX_ATUX_OUMBAR_ENABLE;
+       __raw_writel(reg_val, IOP13XX_ATUX_OUMBAR2);
+
+       /* BAR 3 ( Disabled ) */
+       __raw_writel(0x0, IOP13XX_ATUX_IAUBAR3);
+       __raw_writel(0x0, IOP13XX_ATUX_IABAR3);
+       __raw_writel(0x0, IOP13XX_ATUX_IAUTVR3);
+       __raw_writel(0x0, IOP13XX_ATUX_IATVR3);
+       __raw_writel(0x0, IOP13XX_ATUX_IALR3);
+       reg_val = __raw_readl(IOP13XX_ATUX_OUMBAR3);
+       reg_val &= ~IOP13XX_ATUX_OUMBAR_ENABLE;
+       __raw_writel(reg_val, IOP13XX_ATUX_OUMBAR3);
+
+       /* Setup the I/O Bar
+       * A[35-16] in 31-12
+       */
+       __raw_writel((IOP13XX_PCIX_LOWER_IO_PA >> 0x4) & 0xfffff000,
+                       IOP13XX_ATUX_OIOBAR);
+       __raw_writel(IOP13XX_PCIX_LOWER_IO_BA, IOP13XX_ATUX_OIOWTVR);
+}
+
+void __init iop13xx_set_atu_mmr_bases(void)
+{
+       /* Based on ESSR0, determine the ATU X/E offsets */
+       switch(__raw_readl(IOP13XX_ESSR0) &
+               (IOP13XX_CONTROLLER_ONLY | IOP13XX_INTERFACE_SEL_PCIX)) {
+       /* both asserted */
+       case 0:
+               iop13xx_atux_pmmr_offset = IOP13XX_ATU1_PMMR_OFFSET;
+               iop13xx_atue_pmmr_offset = IOP13XX_ATU2_PMMR_OFFSET;
+               break;
+       /* IOP13XX_CONTROLLER_ONLY = deasserted
+        * IOP13XX_INTERFACE_SEL_PCIX = asserted
+        */
+       case IOP13XX_CONTROLLER_ONLY:
+               iop13xx_atux_pmmr_offset = IOP13XX_ATU0_PMMR_OFFSET;
+               iop13xx_atue_pmmr_offset = IOP13XX_ATU2_PMMR_OFFSET;
+               break;
+       /* IOP13XX_CONTROLLER_ONLY = asserted
+        * IOP13XX_INTERFACE_SEL_PCIX = deasserted
+        */
+       case IOP13XX_INTERFACE_SEL_PCIX:
+               iop13xx_atux_pmmr_offset = IOP13XX_ATU1_PMMR_OFFSET;
+               iop13xx_atue_pmmr_offset = IOP13XX_ATU2_PMMR_OFFSET;
+               break;
+       /* both deasserted */
+       case IOP13XX_CONTROLLER_ONLY | IOP13XX_INTERFACE_SEL_PCIX:
+               iop13xx_atux_pmmr_offset = IOP13XX_ATU2_PMMR_OFFSET;
+               iop13xx_atue_pmmr_offset = IOP13XX_ATU0_PMMR_OFFSET;
+               break;
+       default:
+               BUG();
+       }
+}
+
+void __init iop13xx_atu_select(struct hw_pci *plat_pci)
+{
+       int i;
+
+       /* set system defaults
+        * note: if "iop13xx_init_atu=" is specified this autodetect
+        * sequence will be bypassed
+        */
+       if (init_atu == IOP13XX_INIT_ATU_DEFAULT) {
+               /* check for single/dual interface */
+               if (__raw_readl(IOP13XX_ESSR0) & IOP13XX_INTERFACE_SEL_PCIX) {
+                       /* ATUE must be present check the device id
+                        * to see if ATUX is present.
+                        */
+                       init_atu |= IOP13XX_INIT_ATU_ATUE;
+                       switch (__raw_readw(IOP13XX_ATUE_DID) & 0xf0) {
+                       case 0x70:
+                       case 0x80:
+                       case 0xc0:
+                               init_atu |= IOP13XX_INIT_ATU_ATUX;
+                               break;
+                       }
+               } else {
+                       /* ATUX must be present check the device id
+                        * to see if ATUE is present.
+                        */
+                       init_atu |= IOP13XX_INIT_ATU_ATUX;
+                       switch (__raw_readw(IOP13XX_ATUX_DID) & 0xf0) {
+                       case 0x70:
+                       case 0x80:
+                       case 0xc0:
+                               init_atu |= IOP13XX_INIT_ATU_ATUE;
+                               break;
+                       }
+               }
+
+               /* check central resource and root complex capability */
+               if (init_atu & IOP13XX_INIT_ATU_ATUX)
+                       if (!(__raw_readl(IOP13XX_ATUX_PCSR) &
+                               IOP13XX_ATUX_PCSR_CENTRAL_RES))
+                               init_atu &= ~IOP13XX_INIT_ATU_ATUX;
+
+               if (init_atu & IOP13XX_INIT_ATU_ATUE)
+                       if (__raw_readl(IOP13XX_ATUE_PCSR) &
+                               IOP13XX_ATUE_PCSR_END_POINT)
+                               init_atu &= ~IOP13XX_INIT_ATU_ATUE;
+       }
+
+       for (i = 0; i < 2; i++) {
+               if((init_atu & (1 << i)) == (1 << i))
+                       plat_pci->nr_controllers++;
+       }
+}
+
+void __init iop13xx_pci_init(void)
+{
+       /* clear pre-existing south bridge errors */
+       __raw_writel(__raw_readl(IOP13XX_XBG_BECSR) & 3, IOP13XX_XBG_BECSR);
+
+       /* Setup the Min Address for PCI memory... */
+       iop13xx_pcibios_min_mem = IOP13XX_PCIX_LOWER_MEM_BA;
+
+       /* if Linux is given control of an ATU
+        * clear out its prior configuration,
+        * otherwise do not touch the registers
+        */
+       if (init_atu & IOP13XX_INIT_ATU_ATUE) {
+               iop13xx_atue_disable();
+               iop13xx_atue_setup();
+       }
+
+       if (init_atu & IOP13XX_INIT_ATU_ATUX) {
+               iop13xx_atux_disable();
+               iop13xx_atux_setup();
+       }
+
+       hook_fault_code(16+6, iop13xx_pci_abort, SIGBUS,
+                       "imprecise external abort");
+}
+
+/* intialize the pci memory space.  handle any combination of
+ * atue and atux enabled/disabled
+ */
+int iop13xx_pci_setup(int nr, struct pci_sys_data *sys)
+{
+       struct resource *res;
+       int which_atu;
+       u32 pcixsr, pcsr;
+
+       if (nr > 1)
+               return 0;
+
+       res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL);
+       if (!res)
+               panic("PCI: unable to alloc resources");
+
+       memset(res, 0, sizeof(struct resource) * 2);
+
+       /* 'nr' assumptions:
+        * ATUX is always 0
+        * ATUE is 1 when ATUX is also enabled
+        * ATUE is 0 when ATUX is disabled
+        */
+       switch(init_atu) {
+       case IOP13XX_INIT_ATU_ATUX:
+               which_atu = nr ? 0 : IOP13XX_INIT_ATU_ATUX;
+               break;
+       case IOP13XX_INIT_ATU_ATUE:
+               which_atu = nr ? 0 : IOP13XX_INIT_ATU_ATUE;
+               break;
+       case (IOP13XX_INIT_ATU_ATUX | IOP13XX_INIT_ATU_ATUE):
+               which_atu = nr ? IOP13XX_INIT_ATU_ATUE : IOP13XX_INIT_ATU_ATUX;
+               break;
+       default:
+               which_atu = 0;
+       }
+
+       if (!which_atu)
+               return 0;
+
+       switch(which_atu) {
+       case IOP13XX_INIT_ATU_ATUX:
+               pcixsr = __raw_readl(IOP13XX_ATUX_PCIXSR);
+               pcixsr &= ~0xffff;
+               pcixsr |= sys->busnr << IOP13XX_ATUX_PCIXSR_BUS_NUM |
+                         0 << IOP13XX_ATUX_PCIXSR_DEV_NUM |
+                         iop13xx_atu_function(IOP13XX_INIT_ATU_ATUX)
+                                 << IOP13XX_ATUX_PCIXSR_FUNC_NUM;
+               __raw_writel(pcixsr, IOP13XX_ATUX_PCIXSR);
+
+               res[0].start = IOP13XX_PCIX_LOWER_IO_PA;
+               res[0].end   = IOP13XX_PCIX_UPPER_IO_PA;
+               res[0].name  = "IQ81340 ATUX PCI I/O Space";
+               res[0].flags = IORESOURCE_IO;
+
+               res[1].start = IOP13XX_PCIX_LOWER_MEM_RA;
+               res[1].end   = IOP13XX_PCIX_UPPER_MEM_RA;
+               res[1].name  = "IQ81340 ATUX PCI Memory Space";
+               res[1].flags = IORESOURCE_MEM;
+               sys->mem_offset = IOP13XX_PCIX_MEM_OFFSET;
+               sys->io_offset = IOP13XX_PCIX_IO_OFFSET;
+               break;
+       case IOP13XX_INIT_ATU_ATUE:
+               /* Note: the function number field in the PCSR is ro */
+               pcsr = __raw_readl(IOP13XX_ATUE_PCSR);
+               pcsr &= ~(0xfff8 << 16);
+               pcsr |= sys->busnr << IOP13XX_ATUE_PCSR_BUS_NUM |
+                               0 << IOP13XX_ATUE_PCSR_DEV_NUM;
+
+               __raw_writel(pcsr, IOP13XX_ATUE_PCSR);
+
+               res[0].start = IOP13XX_PCIE_LOWER_IO_PA;
+               res[0].end   = IOP13XX_PCIE_UPPER_IO_PA;
+               res[0].name  = "IQ81340 ATUE PCI I/O Space";
+               res[0].flags = IORESOURCE_IO;
+
+               res[1].start = IOP13XX_PCIE_LOWER_MEM_RA;
+               res[1].end   = IOP13XX_PCIE_UPPER_MEM_RA;
+               res[1].name  = "IQ81340 ATUE PCI Memory Space";
+               res[1].flags = IORESOURCE_MEM;
+               sys->mem_offset = IOP13XX_PCIE_MEM_OFFSET;
+               sys->io_offset = IOP13XX_PCIE_IO_OFFSET;
+               sys->map_irq = iop13xx_pcie_map_irq;
+               break;
+       default:
+               return 0;
+       }
+
+       request_resource(&ioport_resource, &res[0]);
+       request_resource(&iomem_resource, &res[1]);
+
+       sys->resource[0] = &res[0];
+       sys->resource[1] = &res[1];
+       sys->resource[2] = NULL;
+
+       return 1;
+}
+
+u16 iop13xx_dev_id(void)
+{
+       if (__raw_readl(IOP13XX_ESSR0) & IOP13XX_INTERFACE_SEL_PCIX)
+               return __raw_readw(IOP13XX_ATUE_DID);
+       else
+               return __raw_readw(IOP13XX_ATUX_DID);
+}
+
+static int __init iop13xx_init_atu_setup(char *str)
+{
+        init_atu = IOP13XX_INIT_ATU_NONE;
+        if (str) {
+                while (*str != '\0') {
+                        switch (*str) {
+                        case 'x':
+                        case 'X':
+                                init_atu |= IOP13XX_INIT_ATU_ATUX;
+                                init_atu &= ~IOP13XX_INIT_ATU_NONE;
+                                break;
+                        case 'e':
+                        case 'E':
+                                init_atu |= IOP13XX_INIT_ATU_ATUE;
+                                init_atu &= ~IOP13XX_INIT_ATU_NONE;
+                                break;
+                        case ',':
+                        case '=':
+                                break;
+                        default:
+                                PRINTK("\"iop13xx_init_atu\" malformed at "
+                                            "character: \'%c\'", *str);
+                                *(str + 1) = '\0';
+                                init_atu = IOP13XX_INIT_ATU_DEFAULT;
+                        }
+                        str++;
+                }
+        }
+        return 1;
+}
+
+__setup("iop13xx_init_atu", iop13xx_init_atu_setup);
diff --git a/arch/arm/mach-iop13xx/setup.c b/arch/arm/mach-iop13xx/setup.c
new file mode 100644 (file)
index 0000000..3756d2c
--- /dev/null
@@ -0,0 +1,406 @@
+/*
+ * iop13xx platform Initialization
+ * Copyright (c) 2005-2006, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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.
+ *
+ */
+
+#include <linux/serial_8250.h>
+#ifdef CONFIG_MTD_PHYSMAP
+#include <linux/mtd/physmap.h>
+#endif
+#include <asm/mach/map.h>
+#include <asm/hardware.h>
+#include <asm/irq.h>
+
+#define IOP13XX_UART_XTAL 33334000
+#define IOP13XX_SETUP_DEBUG 0
+#define PRINTK(x...) ((void)(IOP13XX_SETUP_DEBUG && printk(x)))
+
+/* Standard IO mapping for all IOP13XX based systems
+ */
+static struct map_desc iop13xx_std_desc[] __initdata = {
+       {    /* mem mapped registers */
+               .virtual = IOP13XX_PMMR_VIRT_MEM_BASE,
+               .pfn     = __phys_to_pfn(IOP13XX_PMMR_PHYS_MEM_BASE),
+               .length  = IOP13XX_PMMR_SIZE,
+               .type    = MT_DEVICE,
+       }, { /* PCIE IO space */
+               .virtual = IOP13XX_PCIE_LOWER_IO_VA,
+               .pfn     = __phys_to_pfn(IOP13XX_PCIE_LOWER_IO_PA),
+               .length  = IOP13XX_PCIX_IO_WINDOW_SIZE,
+               .type    = MT_DEVICE,
+       }, { /* PCIX IO space */
+               .virtual = IOP13XX_PCIX_LOWER_IO_VA,
+               .pfn     = __phys_to_pfn(IOP13XX_PCIX_LOWER_IO_PA),
+               .length  = IOP13XX_PCIX_IO_WINDOW_SIZE,
+               .type    = MT_DEVICE,
+       },
+};
+
+static struct resource iop13xx_uart0_resources[] = {
+       [0] = {
+               .start = IOP13XX_UART0_PHYS,
+               .end = IOP13XX_UART0_PHYS + 0x3f,
+               .flags = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start = IRQ_IOP13XX_UART0,
+               .end = IRQ_IOP13XX_UART0,
+               .flags = IORESOURCE_IRQ
+       }
+};
+
+static struct resource iop13xx_uart1_resources[] = {
+       [0] = {
+               .start = IOP13XX_UART1_PHYS,
+               .end = IOP13XX_UART1_PHYS + 0x3f,
+               .flags = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start = IRQ_IOP13XX_UART1,
+               .end = IRQ_IOP13XX_UART1,
+               .flags = IORESOURCE_IRQ
+       }
+};
+
+static struct plat_serial8250_port iop13xx_uart0_data[] = {
+       {
+       .membase     = (char*)(IOP13XX_UART0_VIRT),
+       .mapbase     = (IOP13XX_UART0_PHYS),
+       .irq         = IRQ_IOP13XX_UART0,
+       .uartclk     = IOP13XX_UART_XTAL,
+       .regshift    = 2,
+       .iotype      = UPIO_MEM,
+       .flags       = UPF_SKIP_TEST,
+       },
+       {  },
+};
+
+static struct plat_serial8250_port iop13xx_uart1_data[] = {
+       {
+       .membase     = (char*)(IOP13XX_UART1_VIRT),
+       .mapbase     = (IOP13XX_UART1_PHYS),
+       .irq         = IRQ_IOP13XX_UART1,
+       .uartclk     = IOP13XX_UART_XTAL,
+       .regshift    = 2,
+       .iotype      = UPIO_MEM,
+       .flags       = UPF_SKIP_TEST,
+       },
+       {  },
+};
+
+/* The ids are fixed up later in iop13xx_platform_init */
+static struct platform_device iop13xx_uart0 = {
+       .name = "serial8250",
+       .id = 0,
+       .dev.platform_data = iop13xx_uart0_data,
+       .num_resources = 2,
+       .resource = iop13xx_uart0_resources,
+};
+
+static struct platform_device iop13xx_uart1 = {
+       .name = "serial8250",
+       .id = 0,
+       .dev.platform_data = iop13xx_uart1_data,
+       .num_resources = 2,
+       .resource = iop13xx_uart1_resources
+};
+
+static struct resource iop13xx_i2c_0_resources[] = {
+       [0] = {
+               .start = IOP13XX_I2C0_PHYS,
+               .end = IOP13XX_I2C0_PHYS + 0x18,
+               .flags = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start = IRQ_IOP13XX_I2C_0,
+               .end = IRQ_IOP13XX_I2C_0,
+               .flags = IORESOURCE_IRQ
+       }
+};
+
+static struct resource iop13xx_i2c_1_resources[] = {
+       [0] = {
+               .start = IOP13XX_I2C1_PHYS,
+               .end = IOP13XX_I2C1_PHYS + 0x18,
+               .flags = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start = IRQ_IOP13XX_I2C_1,
+               .end = IRQ_IOP13XX_I2C_1,
+               .flags = IORESOURCE_IRQ
+       }
+};
+
+static struct resource iop13xx_i2c_2_resources[] = {
+       [0] = {
+               .start = IOP13XX_I2C2_PHYS,
+               .end = IOP13XX_I2C2_PHYS + 0x18,
+               .flags = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start = IRQ_IOP13XX_I2C_2,
+               .end = IRQ_IOP13XX_I2C_2,
+               .flags = IORESOURCE_IRQ
+       }
+};
+
+/* I2C controllers. The IOP13XX uses the same block as the IOP3xx, so
+ * we just use the same device name.
+ */
+
+/* The ids are fixed up later in iop13xx_platform_init */
+static struct platform_device iop13xx_i2c_0_controller = {
+       .name = "IOP3xx-I2C",
+       .id = 0,
+       .num_resources = 2,
+       .resource = iop13xx_i2c_0_resources
+};
+
+static struct platform_device iop13xx_i2c_1_controller = {
+       .name = "IOP3xx-I2C",
+       .id = 0,
+       .num_resources = 2,
+       .resource = iop13xx_i2c_1_resources
+};
+
+static struct platform_device iop13xx_i2c_2_controller = {
+       .name = "IOP3xx-I2C",
+       .id = 0,
+       .num_resources = 2,
+       .resource = iop13xx_i2c_2_resources
+};
+
+#ifdef CONFIG_MTD_PHYSMAP
+/* PBI Flash Device
+ */
+static struct physmap_flash_data iq8134x_flash_data = {
+       .width = 2,
+};
+
+static struct resource iq8134x_flash_resource = {
+       .start = IQ81340_FLASHBASE,
+       .end   = 0,
+       .flags = IORESOURCE_MEM,
+};
+
+static struct platform_device iq8134x_flash = {
+       .name           = "physmap-flash",
+       .id             = 0,
+       .dev            = { .platform_data  = &iq8134x_flash_data, },
+       .num_resources  = 1,
+       .resource       = &iq8134x_flash_resource,
+};
+
+static unsigned long iq8134x_probe_flash_size(void)
+{
+       uint8_t __iomem *flash_addr = ioremap(IQ81340_FLASHBASE, PAGE_SIZE);
+       int i;
+       char query[3];
+       unsigned long size = 0;
+       int width = iq8134x_flash_data.width;
+
+       if (flash_addr) {
+               /* send CFI 'query' command */
+               writew(0x98, flash_addr);
+
+               /* check for CFI compliance */
+               for (i = 0; i < 3 * width; i += width)
+                       query[i / width] = readb(flash_addr + (0x10 * width) + i);
+
+               /* read the size */
+               if (memcmp(query, "QRY", 3) == 0)
+                       size = 1 << readb(flash_addr + (0x27 * width));
+
+               /* send CFI 'read array' command */
+               writew(0xff, flash_addr);
+
+               iounmap(flash_addr);
+       }
+
+       return size;
+}
+#endif
+
+void __init iop13xx_map_io(void)
+{
+       /* Initialize the Static Page Table maps */
+       iotable_init(iop13xx_std_desc, ARRAY_SIZE(iop13xx_std_desc));
+}
+
+static int init_uart = 0;
+static int init_i2c = 0;
+
+void __init iop13xx_platform_init(void)
+{
+       int i;
+       u32 uart_idx, i2c_idx, plat_idx;
+       struct platform_device *iop13xx_devices[IQ81340_MAX_PLAT_DEVICES];
+
+       /* set the bases so we can read the device id */
+       iop13xx_set_atu_mmr_bases();
+
+       memset(iop13xx_devices, 0, sizeof(iop13xx_devices));
+
+       if (init_uart == IOP13XX_INIT_UART_DEFAULT) {
+               switch (iop13xx_dev_id()) {
+               /* enable both uarts on iop341 and iop342 */
+               case 0x3380:
+               case 0x3384:
+               case 0x3388:
+               case 0x338c:
+               case 0x3382:
+               case 0x3386:
+               case 0x338a:
+               case 0x338e:
+                       init_uart |= IOP13XX_INIT_UART_0;
+                       init_uart |= IOP13XX_INIT_UART_1;
+                       break;
+               /* only enable uart 1 */
+               default:
+                       init_uart |= IOP13XX_INIT_UART_1;
+               }
+       }
+
+       if (init_i2c == IOP13XX_INIT_I2C_DEFAULT) {
+               switch (iop13xx_dev_id()) {
+               /* enable all i2c units on iop341 and iop342 */
+               case 0x3380:
+               case 0x3384:
+               case 0x3388:
+               case 0x338c:
+               case 0x3382:
+               case 0x3386:
+               case 0x338a:
+               case 0x338e:
+                       init_i2c |= IOP13XX_INIT_I2C_0;
+                       init_i2c |= IOP13XX_INIT_I2C_1;
+                       init_i2c |= IOP13XX_INIT_I2C_2;
+                       break;
+               /* only enable i2c 1 and 2 */
+               default:
+                       init_i2c |= IOP13XX_INIT_I2C_1;
+                       init_i2c |= IOP13XX_INIT_I2C_2;
+               }
+       }
+
+       plat_idx = 0;
+       uart_idx = 0;
+       i2c_idx = 0;
+
+       /* uart 1 (if enabled) is ttyS0 */
+       if (init_uart & IOP13XX_INIT_UART_1) {
+               PRINTK("Adding uart1 to platform device list\n");
+               iop13xx_uart1.id = uart_idx++;
+               iop13xx_devices[plat_idx++] = &iop13xx_uart1;
+       }
+       if (init_uart & IOP13XX_INIT_UART_0) {
+               PRINTK("Adding uart0 to platform device list\n");
+               iop13xx_uart0.id = uart_idx++;
+               iop13xx_devices[plat_idx++] = &iop13xx_uart0;
+       }
+
+       for(i = 0; i < IQ81340_NUM_I2C; i++) {
+               if ((init_i2c & (1 << i)) && IOP13XX_SETUP_DEBUG)
+                       printk("Adding i2c%d to platform device list\n", i);
+               switch(init_i2c & (1 << i)) {
+               case IOP13XX_INIT_I2C_0:
+                       iop13xx_i2c_0_controller.id = i2c_idx++;
+                       iop13xx_devices[plat_idx++] =
+                               &iop13xx_i2c_0_controller;
+                       break;
+               case IOP13XX_INIT_I2C_1:
+                       iop13xx_i2c_1_controller.id = i2c_idx++;
+                       iop13xx_devices[plat_idx++] =
+                               &iop13xx_i2c_1_controller;
+                       break;
+               case IOP13XX_INIT_I2C_2:
+                       iop13xx_i2c_2_controller.id = i2c_idx++;
+                       iop13xx_devices[plat_idx++] =
+                               &iop13xx_i2c_2_controller;
+                       break;
+               }
+       }
+
+#ifdef CONFIG_MTD_PHYSMAP
+       iq8134x_flash_resource.end = iq8134x_flash_resource.start +
+                               iq8134x_probe_flash_size();
+       if (iq8134x_flash_resource.end > iq8134x_flash_resource.start)
+               iop13xx_devices[plat_idx++] = &iq8134x_flash;
+       else
+               printk(KERN_ERR "%s: Failed to probe flash size\n", __FUNCTION__);
+#endif
+
+       platform_add_devices(iop13xx_devices, plat_idx);
+}
+
+static int __init iop13xx_init_uart_setup(char *str)
+{
+       if (str) {
+               while (*str != '\0') {
+                       switch(*str) {
+                       case '0':
+                               init_uart |= IOP13XX_INIT_UART_0;
+                               break;
+                       case '1':
+                               init_uart |= IOP13XX_INIT_UART_1;
+                               break;
+                       case ',':
+                       case '=':
+                               break;
+                       default:
+                               PRINTK("\"iop13xx_init_uart\" malformed"
+                                           " at character: \'%c\'", *str);
+                               *(str + 1) = '\0';
+                               init_uart = IOP13XX_INIT_UART_DEFAULT;
+                       }
+                       str++;
+               }
+       }
+       return 1;
+}
+
+static int __init iop13xx_init_i2c_setup(char *str)
+{
+       if (str) {
+               while (*str != '\0') {
+                       switch(*str) {
+                       case '0':
+                               init_i2c |= IOP13XX_INIT_I2C_0;
+                               break;
+                       case '1':
+                               init_i2c |= IOP13XX_INIT_I2C_1;
+                               break;
+                       case '2':
+                               init_i2c |= IOP13XX_INIT_I2C_2;
+                               break;
+                       case ',':
+                       case '=':
+                               break;
+                       default:
+                               PRINTK("\"iop13xx_init_i2c\" malformed"
+                                           " at character: \'%c\'", *str);
+                               *(str + 1) = '\0';
+                               init_i2c = IOP13XX_INIT_I2C_DEFAULT;
+                       }
+                       str++;
+               }
+       }
+       return 1;
+}
+
+__setup("iop13xx_init_uart", iop13xx_init_uart_setup);
+__setup("iop13xx_init_i2c", iop13xx_init_i2c_setup);
diff --git a/arch/arm/mach-iop13xx/time.c b/arch/arm/mach-iop13xx/time.c
new file mode 100644 (file)
index 0000000..8b21365
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * arch/arm/mach-iop13xx/time.c
+ *
+ * Timer code for IOP13xx (copied from IOP32x/IOP33x implementation)
+ *
+ * Author: Deepak Saxena <dsaxena@mvista.com>
+ *
+ * Copyright 2002-2003 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 as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/kernel.h>
+#include <linux/interrupt.h>
+#include <linux/time.h>
+#include <linux/init.h>
+#include <linux/timex.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/uaccess.h>
+#include <asm/mach/irq.h>
+#include <asm/mach/time.h>
+
+static unsigned long ticks_per_jiffy;
+static unsigned long ticks_per_usec;
+static unsigned long next_jiffy_time;
+
+static inline u32 read_tcr1(void)
+{
+       u32 val;
+       asm volatile("mrc p6, 0, %0, c3, c9, 0" : "=r" (val));
+       return val;
+}
+
+unsigned long iop13xx_gettimeoffset(void)
+{
+       unsigned long offset;
+       u32 cp_flags;
+
+       cp_flags = iop13xx_cp6_save();
+       offset = next_jiffy_time - read_tcr1();
+       iop13xx_cp6_restore(cp_flags);
+
+       return offset / ticks_per_usec;
+}
+
+static irqreturn_t
+iop13xx_timer_interrupt(int irq, void *dev_id)
+{
+       u32 cp_flags = iop13xx_cp6_save();
+
+       write_seqlock(&xtime_lock);
+
+       asm volatile("mcr p6, 0, %0, c6, c9, 0" : : "r" (1));
+
+       while ((signed long)(next_jiffy_time - read_tcr1())
+                                                       >= ticks_per_jiffy) {
+               timer_tick();
+               next_jiffy_time -= ticks_per_jiffy;
+       }
+
+       write_sequnlock(&xtime_lock);
+
+       iop13xx_cp6_restore(cp_flags);
+
+       return IRQ_HANDLED;
+}
+
+static struct irqaction iop13xx_timer_irq = {
+       .name           = "IOP13XX Timer Tick",
+       .handler        = iop13xx_timer_interrupt,
+       .flags          = IRQF_DISABLED | IRQF_TIMER,
+};
+
+void __init iop13xx_init_time(unsigned long tick_rate)
+{
+       u32 timer_ctl;
+       u32 cp_flags;
+
+       ticks_per_jiffy = (tick_rate + HZ/2) / HZ;
+       ticks_per_usec = tick_rate / 1000000;
+       next_jiffy_time = 0xffffffff;
+
+       timer_ctl = IOP13XX_TMR_EN | IOP13XX_TMR_PRIVILEGED |
+                       IOP13XX_TMR_RELOAD | IOP13XX_TMR_RATIO_1_1;
+
+       /*
+        * We use timer 0 for our timer interrupt, and timer 1 as
+        * monotonic counter for tracking missed jiffies.
+        */
+       cp_flags = iop13xx_cp6_save();
+       asm volatile("mcr p6, 0, %0, c4, c9, 0" : : "r" (ticks_per_jiffy - 1));
+       asm volatile("mcr p6, 0, %0, c0, c9, 0" : : "r" (timer_ctl));
+       asm volatile("mcr p6, 0, %0, c5, c9, 0" : : "r" (0xffffffff));
+       asm volatile("mcr p6, 0, %0, c1, c9, 0" : : "r" (timer_ctl));
+       iop13xx_cp6_restore(cp_flags);
+
+       setup_irq(IRQ_IOP13XX_TIMER0, &iop13xx_timer_irq);
+}
index 69d6302f40cfd5e29462c41854510f60b1491f29..3ec1cd5c4f99733e4b1e76a9116f27b6040709b9 100644 (file)
@@ -70,7 +70,7 @@ void __init iop32x_init_irq(void)
 
        for (i = 0; i < NR_IRQS; i++) {
                set_irq_chip(i, &ext_chip);
-               set_irq_handler(i, do_level_IRQ);
+               set_irq_handler(i, handle_level_irq);
                set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
        }
 }
index 63304b3d0d7634232bc95f89b1502162fcedce85..00b37f32d72e0c9a9314d93412850babd7c8c926 100644 (file)
@@ -121,7 +121,7 @@ void __init iop33x_init_irq(void)
 
        for (i = 0; i < NR_IRQS; i++) {
                set_irq_chip(i, (i < 32) ? &iop33x_irqchip1 : &iop33x_irqchip2);
-               set_irq_handler(i, do_level_IRQ);
+               set_irq_handler(i, handle_level_irq);
                set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
        }
 }
index 22c98e9dad280aff426b4070a24a0a9ec5971ffd..27b7480f4afe94cc873fb62e9547c67b8cf86caa 100644 (file)
@@ -308,7 +308,7 @@ EXPORT_SYMBOL(gpio_line_config);
 /*************************************************************************
  * IRQ handling IXP2000
  *************************************************************************/
-static void ixp2000_GPIO_irq_handler(unsigned int irq, struct irqdesc *desc)
+static void ixp2000_GPIO_irq_handler(unsigned int irq, struct irq_desc *desc)
 {                               
        int i;
        unsigned long status = *IXP2000_GPIO_INST;
@@ -373,7 +373,7 @@ static void ixp2000_GPIO_irq_unmask(unsigned int irq)
        ixp2000_reg_write(IXP2000_GPIO_INSR, (1 << (irq - IRQ_IXP2000_GPIO0)));
 }
 
-static struct irqchip ixp2000_GPIO_irq_chip = {
+static struct irq_chip ixp2000_GPIO_irq_chip = {
        .ack            = ixp2000_GPIO_irq_mask_ack,
        .mask           = ixp2000_GPIO_irq_mask,
        .unmask         = ixp2000_GPIO_irq_unmask,
@@ -401,7 +401,7 @@ static void ixp2000_pci_irq_unmask(unsigned int irq)
 /*
  * Error interrupts. These are used extensively by the microengine drivers
  */
-static void ixp2000_err_irq_handler(unsigned int irq, struct irqdesc *desc)
+static void ixp2000_err_irq_handler(unsigned int irq, struct irq_desc *desc)
 {
        int i;
        unsigned long status = *IXP2000_IRQ_ERR_STATUS;
@@ -426,13 +426,13 @@ static void ixp2000_err_irq_unmask(unsigned int irq)
                        (1 << (irq - IRQ_IXP2000_DRAM0_MIN_ERR)));
 }
 
-static struct irqchip ixp2000_err_irq_chip = {
+static struct irq_chip ixp2000_err_irq_chip = {
        .ack    = ixp2000_err_irq_mask,
        .mask   = ixp2000_err_irq_mask,
        .unmask = ixp2000_err_irq_unmask
 };
 
-static struct irqchip ixp2000_pci_irq_chip = {
+static struct irq_chip ixp2000_pci_irq_chip = {
        .ack    = ixp2000_pci_irq_mask,
        .mask   = ixp2000_pci_irq_mask,
        .unmask = ixp2000_pci_irq_unmask
@@ -448,7 +448,7 @@ static void ixp2000_irq_unmask(unsigned int irq)
        ixp2000_reg_write(IXP2000_IRQ_ENABLE_SET, (1 << irq));
 }
 
-static struct irqchip ixp2000_irq_chip = {
+static struct irq_chip ixp2000_irq_chip = {
        .ack    = ixp2000_irq_mask,
        .mask   = ixp2000_irq_mask,
        .unmask = ixp2000_irq_unmask
@@ -484,7 +484,7 @@ void __init ixp2000_init_irq(void)
        for (irq = IRQ_IXP2000_SOFT_INT; irq <= IRQ_IXP2000_THDB3; irq++) {
                if ((1 << irq) & IXP2000_VALID_IRQ_MASK) {
                        set_irq_chip(irq, &ixp2000_irq_chip);
-                       set_irq_handler(irq, do_level_IRQ);
+                       set_irq_handler(irq, handle_level_irq);
                        set_irq_flags(irq, IRQF_VALID);
                } else set_irq_flags(irq, 0);
        }
@@ -493,7 +493,7 @@ void __init ixp2000_init_irq(void)
                if((1 << (irq - IRQ_IXP2000_DRAM0_MIN_ERR)) &
                                IXP2000_VALID_ERR_IRQ_MASK) {
                        set_irq_chip(irq, &ixp2000_err_irq_chip);
-                       set_irq_handler(irq, do_level_IRQ);
+                       set_irq_handler(irq, handle_level_irq);
                        set_irq_flags(irq, IRQF_VALID);
                }
                else
@@ -503,7 +503,7 @@ void __init ixp2000_init_irq(void)
 
        for (irq = IRQ_IXP2000_GPIO0; irq <= IRQ_IXP2000_GPIO7; irq++) {
                set_irq_chip(irq, &ixp2000_GPIO_irq_chip);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                set_irq_flags(irq, IRQF_VALID);
        }
        set_irq_chained_handler(IRQ_IXP2000_GPIO, ixp2000_GPIO_irq_handler);
@@ -516,7 +516,7 @@ void __init ixp2000_init_irq(void)
        ixp2000_reg_write(IXP2000_IRQ_ENABLE_SET, (1 << IRQ_IXP2000_PCI));
        for (irq = IRQ_IXP2000_PCIA; irq <= IRQ_IXP2000_PCIB; irq++) {
                set_irq_chip(irq, &ixp2000_pci_irq_chip);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                set_irq_flags(irq, IRQF_VALID);
        }
 }
index aa2655092d2dc728805609969a7bbf43331e4ef8..52b368b34346a4fb48a66b0d9500ffdbe47236d3 100644 (file)
@@ -106,7 +106,7 @@ static void ixdp2x00_irq_unmask(unsigned int irq)
                ixp2000_release_slowport(&old_cfg);
 }
 
-static void ixdp2x00_irq_handler(unsigned int irq, struct irqdesc *desc)
+static void ixdp2x00_irq_handler(unsigned int irq, struct irq_desc *desc)
 {
         volatile u32 ex_interrupt = 0;
        static struct slowport_cfg old_cfg;
@@ -129,7 +129,7 @@ static void ixdp2x00_irq_handler(unsigned int irq, struct irqdesc *desc)
 
        for(i = 0; i < board_irq_count; i++) {
                if(ex_interrupt & (1 << i))  {
-                       struct irqdesc *cpld_desc;
+                       struct irq_desc *cpld_desc;
                        int cpld_irq = IXP2000_BOARD_IRQ(0) + i;
                        cpld_desc = irq_desc + cpld_irq;
                        desc_handle_irq(cpld_irq, cpld_desc);
@@ -139,7 +139,7 @@ static void ixdp2x00_irq_handler(unsigned int irq, struct irqdesc *desc)
        desc->chip->unmask(irq);
 }
 
-static struct irqchip ixdp2x00_cpld_irq_chip = {
+static struct irq_chip ixdp2x00_cpld_irq_chip = {
        .ack    = ixdp2x00_irq_mask,
        .mask   = ixdp2x00_irq_mask,
        .unmask = ixdp2x00_irq_unmask
@@ -162,7 +162,7 @@ void ixdp2x00_init_irq(volatile unsigned long *stat_reg, volatile unsigned long
 
        for(irq = IXP2000_BOARD_IRQ(0); irq < IXP2000_BOARD_IRQ(board_irq_count); irq++) {
                set_irq_chip(irq, &ixdp2x00_cpld_irq_chip);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                set_irq_flags(irq, IRQF_VALID);
        }
 
index 9ccae9e63f70deacdffc5fde976abd4d86677799..3084a5fa751cc89313e3af378ab856d4a9a54878 100644 (file)
@@ -63,7 +63,7 @@ static void ixdp2x01_irq_unmask(unsigned int irq)
 
 static u32 valid_irq_mask;
 
-static void ixdp2x01_irq_handler(unsigned int irq, struct irqdesc *desc)
+static void ixdp2x01_irq_handler(unsigned int irq, struct irq_desc *desc)
 {
        u32 ex_interrupt;
        int i;
@@ -79,7 +79,7 @@ static void ixdp2x01_irq_handler(unsigned int irq, struct irqdesc *desc)
 
        for (i = 0; i < IXP2000_BOARD_IRQS; i++) {
                if (ex_interrupt & (1 << i)) {
-                       struct irqdesc *cpld_desc;
+                       struct irq_desc *cpld_desc;
                        int cpld_irq = IXP2000_BOARD_IRQ(0) + i;
                        cpld_desc = irq_desc + cpld_irq;
                        desc_handle_irq(cpld_irq, cpld_desc);
@@ -89,7 +89,7 @@ static void ixdp2x01_irq_handler(unsigned int irq, struct irqdesc *desc)
        desc->chip->unmask(irq);
 }
 
-static struct irqchip ixdp2x01_irq_chip = {
+static struct irq_chip ixdp2x01_irq_chip = {
        .mask   = ixdp2x01_irq_mask,
        .ack    = ixdp2x01_irq_mask,
        .unmask = ixdp2x01_irq_unmask
@@ -119,7 +119,7 @@ void __init ixdp2x01_init_irq(void)
        for (irq = NR_IXP2000_IRQS; irq < NR_IXDP2X01_IRQS; irq++) {
                if (irq & valid_irq_mask) {
                        set_irq_chip(irq, &ixdp2x01_irq_chip);
-                       set_irq_handler(irq, do_level_IRQ);
+                       set_irq_handler(irq, handle_level_irq);
                        set_irq_flags(irq, IRQF_VALID);
                } else {
                        set_irq_flags(irq, 0);
index d4bf1e1c0031c5e79a1051790a02c817c6b3218d..5a09a90c08fb7f3e36df1a2f2967e01616a6ea5e 100644 (file)
@@ -32,7 +32,7 @@
 
 #include <asm/mach/pci.h>
 
-static int pci_master_aborts = 0;
+static volatile int pci_master_aborts = 0;
 
 static int clear_master_aborts(void);
 
index a704a1820048404e8f6ef7e8fc8be68f7a18c5a3..ce6ad635a00c2e6991dd35eca189bce268fb16a5 100644 (file)
@@ -224,14 +224,14 @@ static void ixp23xx_irq_edge_unmask(unsigned int irq)
        *intr_reg |= (1 << (irq % 32));
 }
 
-static struct irqchip ixp23xx_irq_level_chip = {
+static struct irq_chip ixp23xx_irq_level_chip = {
        .ack            = ixp23xx_irq_mask,
        .mask           = ixp23xx_irq_mask,
        .unmask         = ixp23xx_irq_level_unmask,
        .set_type       = ixp23xx_irq_set_type
 };
 
-static struct irqchip ixp23xx_irq_edge_chip = {
+static struct irq_chip ixp23xx_irq_edge_chip = {
        .ack            = ixp23xx_irq_ack,
        .mask           = ixp23xx_irq_mask,
        .unmask         = ixp23xx_irq_edge_unmask,
@@ -251,11 +251,11 @@ static void ixp23xx_pci_irq_unmask(unsigned int irq)
 /*
  * TODO: Should this just be done at ASM level?
  */
-static void pci_handler(unsigned int irq, struct irqdesc *desc)
+static void pci_handler(unsigned int irq, struct irq_desc *desc)
 {
        u32 pci_interrupt;
        unsigned int irqno;
-       struct irqdesc *int_desc;
+       struct irq_desc *int_desc;
 
        pci_interrupt = *IXP23XX_PCI_XSCALE_INT_STATUS;
 
@@ -276,7 +276,7 @@ static void pci_handler(unsigned int irq, struct irqdesc *desc)
        desc->chip->unmask(irq);
 }
 
-static struct irqchip ixp23xx_pci_irq_chip = {
+static struct irq_chip ixp23xx_pci_irq_chip = {
        .ack    = ixp23xx_pci_irq_mask,
        .mask   = ixp23xx_pci_irq_mask,
        .unmask = ixp23xx_pci_irq_unmask
@@ -287,11 +287,11 @@ static void ixp23xx_config_irq(unsigned int irq, enum ixp23xx_irq_type type)
        switch (type) {
        case IXP23XX_IRQ_LEVEL:
                set_irq_chip(irq, &ixp23xx_irq_level_chip);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                break;
        case IXP23XX_IRQ_EDGE:
                set_irq_chip(irq, &ixp23xx_irq_edge_chip);
-               set_irq_handler(irq, do_edge_IRQ);
+               set_irq_handler(irq, handle_edge_irq);
                break;
        }
        set_irq_flags(irq, IRQF_VALID);
@@ -322,7 +322,7 @@ void __init ixp23xx_init_irq(void)
 
        for (irq = IRQ_IXP23XX_INTA; irq <= IRQ_IXP23XX_INTB; irq++) {
                set_irq_chip(irq, &ixp23xx_pci_irq_chip);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                set_irq_flags(irq, IRQF_VALID);
        }
 
index b6ab0e8bb5e826c2ae861bb4781cde3d052579ee..7a86a2516eaa57e30fc74c7330116fbff53bb02d 100644 (file)
@@ -60,7 +60,7 @@ static void ixdp2351_inta_unmask(unsigned int irq)
        *IXDP2351_CPLD_INTA_MASK_CLR_REG = IXDP2351_INTA_IRQ_MASK(irq);
 }
 
-static void ixdp2351_inta_handler(unsigned int irq, struct irqdesc *desc)
+static void ixdp2351_inta_handler(unsigned int irq, struct irq_desc *desc)
 {
        u16 ex_interrupt =
                *IXDP2351_CPLD_INTA_STAT_REG & IXDP2351_INTA_IRQ_VALID;
@@ -70,7 +70,7 @@ static void ixdp2351_inta_handler(unsigned int irq, struct irqdesc *desc)
 
        for (i = 0; i < IXDP2351_INTA_IRQ_NUM; i++) {
                if (ex_interrupt & (1 << i)) {
-                       struct irqdesc *cpld_desc;
+                       struct irq_desc *cpld_desc;
                        int cpld_irq =
                                IXP23XX_MACH_IRQ(IXDP2351_INTA_IRQ_BASE + i);
                        cpld_desc = irq_desc + cpld_irq;
@@ -81,7 +81,7 @@ static void ixdp2351_inta_handler(unsigned int irq, struct irqdesc *desc)
        desc->chip->unmask(irq);
 }
 
-static struct irqchip ixdp2351_inta_chip = {
+static struct irq_chip ixdp2351_inta_chip = {
        .ack    = ixdp2351_inta_mask,
        .mask   = ixdp2351_inta_mask,
        .unmask = ixdp2351_inta_unmask
@@ -97,7 +97,7 @@ static void ixdp2351_intb_unmask(unsigned int irq)
        *IXDP2351_CPLD_INTB_MASK_CLR_REG = IXDP2351_INTB_IRQ_MASK(irq);
 }
 
-static void ixdp2351_intb_handler(unsigned int irq, struct irqdesc *desc)
+static void ixdp2351_intb_handler(unsigned int irq, struct irq_desc *desc)
 {
        u16 ex_interrupt =
                *IXDP2351_CPLD_INTB_STAT_REG & IXDP2351_INTB_IRQ_VALID;
@@ -107,7 +107,7 @@ static void ixdp2351_intb_handler(unsigned int irq, struct irqdesc *desc)
 
        for (i = 0; i < IXDP2351_INTB_IRQ_NUM; i++) {
                if (ex_interrupt & (1 << i)) {
-                       struct irqdesc *cpld_desc;
+                       struct irq_desc *cpld_desc;
                        int cpld_irq =
                                IXP23XX_MACH_IRQ(IXDP2351_INTB_IRQ_BASE + i);
                        cpld_desc = irq_desc + cpld_irq;
@@ -118,7 +118,7 @@ static void ixdp2351_intb_handler(unsigned int irq, struct irqdesc *desc)
        desc->chip->unmask(irq);
 }
 
-static struct irqchip ixdp2351_intb_chip = {
+static struct irq_chip ixdp2351_intb_chip = {
        .ack    = ixdp2351_intb_mask,
        .mask   = ixdp2351_intb_mask,
        .unmask = ixdp2351_intb_unmask
@@ -142,7 +142,7 @@ void ixdp2351_init_irq(void)
             irq++) {
                if (IXDP2351_INTA_IRQ_MASK(irq) & IXDP2351_INTA_IRQ_VALID) {
                        set_irq_flags(irq, IRQF_VALID);
-                       set_irq_handler(irq, do_level_IRQ);
+                       set_irq_handler(irq, handle_level_irq);
                        set_irq_chip(irq, &ixdp2351_inta_chip);
                }
        }
@@ -153,7 +153,7 @@ void ixdp2351_init_irq(void)
             irq++) {
                if (IXDP2351_INTB_IRQ_MASK(irq) & IXDP2351_INTB_IRQ_VALID) {
                        set_irq_flags(irq, IRQF_VALID);
-                       set_irq_handler(irq, do_level_IRQ);
+                       set_irq_handler(irq, handle_level_irq);
                        set_irq_chip(irq, &ixdp2351_intb_chip);
                }
        }
index 3b34fa35e36bbcde0f1dacc892aac432c0617398..ac7d43d23c28f1f35d6dd5abc62adee1dee95e0b 100644 (file)
@@ -36,7 +36,7 @@
 
 extern int (*external_fault) (unsigned long, struct pt_regs *);
 
-static int pci_master_aborts = 0;
+static volatile int pci_master_aborts = 0;
 
 #ifdef DEBUG
 #define DBG(x...)      printk(x)
index fbe288a8da656a5ad6b17250d9fc1f99dbe73931..2ec9a9e9a04dd0e702c58faa8015dd0df5498fac 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/timex.h>
 #include <linux/clocksource.h>
 
+#include <asm/arch/udc.h>
 #include <asm/hardware.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -39,6 +40,8 @@
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
 
+static int __init ixp4xx_clocksource_init(void);
+
 /*************************************************************************
  * IXP4xx chipset I/O mapping
  *************************************************************************/
@@ -195,7 +198,7 @@ static void ixp4xx_irq_unmask(unsigned int irq)
                *IXP4XX_ICMR |= (1 << irq);
 }
 
-static struct irqchip ixp4xx_irq_chip = {
+static struct irq_chip ixp4xx_irq_chip = {
        .name           = "IXP4xx",
        .ack            = ixp4xx_irq_ack,
        .mask           = ixp4xx_irq_mask,
@@ -224,7 +227,7 @@ void __init ixp4xx_init_irq(void)
         /* Default to all level triggered */
        for(i = 0; i < NR_IRQS; i++) {
                set_irq_chip(i, &ixp4xx_irq_chip);
-               set_irq_handler(i, do_level_IRQ);
+               set_irq_handler(i, handle_level_irq);
                set_irq_flags(i, IRQF_VALID);
        }
 }
@@ -280,12 +283,52 @@ static void __init ixp4xx_timer_init(void)
 
        /* Connect the interrupt handler and enable the interrupt */
        setup_irq(IRQ_IXP4XX_TIMER1, &ixp4xx_timer_irq);
+
+       ixp4xx_clocksource_init();
 }
 
 struct sys_timer ixp4xx_timer = {
        .init           = ixp4xx_timer_init,
 };
 
+static struct pxa2xx_udc_mach_info ixp4xx_udc_info;
+
+void __init ixp4xx_set_udc_info(struct pxa2xx_udc_mach_info *info)
+{
+       memcpy(&ixp4xx_udc_info, info, sizeof *info);
+}
+
+static struct resource ixp4xx_udc_resources[] = {
+       [0] = {
+               .start  = 0xc800b000,
+               .end    = 0xc800bfff,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = IRQ_IXP4XX_USB,
+               .end    = IRQ_IXP4XX_USB,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+/*
+ * USB device controller. The IXP4xx uses the same controller as PXA2XX,
+ * so we just use the same device.
+ */
+static struct platform_device ixp4xx_udc_device = {
+       .name           = "pxa2xx-udc",
+       .id             = -1,
+       .num_resources  = 2,
+       .resource       = ixp4xx_udc_resources,
+       .dev            = {
+               .platform_data = &ixp4xx_udc_info,
+       },
+};
+
+static struct platform_device *ixp4xx_devices[] __initdata = {
+       &ixp4xx_udc_device,
+};
+
 static struct resource ixp46x_i2c_resources[] = {
        [0] = {
                .start  = 0xc8011000,
@@ -321,6 +364,8 @@ void __init ixp4xx_sys_init(void)
 {
        ixp4xx_exp_bus_size = SZ_16M;
 
+       platform_add_devices(ixp4xx_devices, ARRAY_SIZE(ixp4xx_devices));
+
        if (cpu_is_ixp46x()) {
                int region;
 
@@ -363,5 +408,3 @@ static int __init ixp4xx_clocksource_init(void)
 
        return 0;
 }
-
-device_initcall(ixp4xx_clocksource_init);
index b7af5640ea7bde758e804c119ad2be41bdf02102..561a0fe7095db1d6f6285d8ebc2d85a5848246a4 100644 (file)
@@ -55,7 +55,7 @@ static void l7200_unmask_irq(unsigned int irq)
        IRQ_ENABLE = 1 << irq;
 }
 
-static struct irqchip l7200_irq_chip = {
+static struct irq_chip l7200_irq_chip = {
        .ack            = l7200_mask_irq,
        .mask           = l7200_mask_irq,
        .unmask         = l7200_unmask_irq
@@ -71,7 +71,7 @@ static void __init l7200_init_irq(void)
        for (irq = 0; irq < NR_IRQS; irq++) {
                set_irq_chip(irq, &l7200_irq_chip);
                set_irq_flags(irq, IRQF_VALID);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
        }
 
        init_FIQ();
index 15fbcc911fe76da4fa97a3bb1f68fbd2fc189b06..6d26661d99f634b0f631dc866804f8211f5cb5aa 100644 (file)
@@ -71,7 +71,7 @@ static struct irq_chip kev7a400_cpld_chip = {
 };
 
 
-static void kev7a400_cpld_handler (unsigned int irq, struct irqdesc *desc)
+static void kev7a400_cpld_handler (unsigned int irq, struct irq_desc *desc)
 {
        u32 mask = CPLD_LATCHED_INTS;
        irq = IRQ_KEV7A400_CPLD;
@@ -88,7 +88,7 @@ void __init lh7a40x_init_board_irq (void)
        for (irq = IRQ_KEV7A400_CPLD;
             irq < IRQ_KEV7A400_CPLD + NR_IRQ_BOARD; ++irq) {
                set_irq_chip (irq, &kev7a400_cpld_chip);
-               set_irq_handler (irq, do_edge_IRQ);
+               set_irq_handler (irq, handle_edge_irq);
                set_irq_flags (irq, IRQF_VALID);
        }
        set_irq_chained_handler (IRQ_CPLD, kev7a400_cpld_handler);
index 8441e0a156cb2f28555c4eab291d6bd0af2c74c6..fe64946f9e18ea824efa6839745143c3e326cf92 100644 (file)
@@ -207,7 +207,7 @@ static struct irq_chip lpd7a40x_cpld_chip = {
        .unmask = lh7a40x_unmask_cpld_irq,
 };
 
-static void lpd7a40x_cpld_handler (unsigned int irq, struct irqdesc *desc)
+static void lpd7a40x_cpld_handler (unsigned int irq, struct irq_desc *desc)
 {
        unsigned int mask = CPLD_INTERRUPTS;
 
@@ -279,7 +279,7 @@ void __init lh7a40x_init_board_irq (void)
        for (irq = IRQ_BOARD_START;
             irq < IRQ_BOARD_START + NR_IRQ_BOARD; ++irq) {
                set_irq_chip (irq, &lpd7a40x_cpld_chip);
-               set_irq_handler (irq, do_level_IRQ);
+               set_irq_handler (irq, handle_level_irq);
                set_irq_flags (irq, IRQF_VALID);
        }
 
index 646071334b8f107a2ee0b72620cefd33e02ff06c..c7433b3c5812e3f83c74061469efaca64c1c1eda 100644 (file)
@@ -51,7 +51,7 @@ irq_chip lh7a400_cpld_chip = {
 };
 
 static void
-lh7a400_cpld_handler (unsigned int irq, struct irqdesc *desc)
+lh7a400_cpld_handler (unsigned int irq, struct irq_desc *desc)
 {
        u32 mask = CPLD_LATCHED_INTS;
        irq = IRQ_KEV_7A400_CPLD;
@@ -71,7 +71,7 @@ lh7a400_init_board_irq (void)
        for (irq = IRQ_KEV7A400_CPLD;
             irq < IRQ_KEV7A400_CPLD + NR_IRQ_KEV7A400_CPLD; ++irq) {
                set_irq_chip (irq, &lh7a400_cpld_chip);
-               set_irq_handler (irq, do_edge_IRQ);
+               set_irq_handler (irq, handle_edge_irq);
                set_irq_flags (irq, IRQF_VALID);
        }
        set_irq_chained_handler (IRQ_CPLD, kev7a400_cpld_handler);
index 091b2dc58d25176e673809bfdadad8e6bf6a86a2..0b938e8b4d98ef4694469a7d019eabe8889c18d8 100644 (file)
@@ -74,11 +74,11 @@ void __init lh7a400_init_irq (void)
                case IRQ_GPIO6INTR:
                case IRQ_GPIO7INTR:
                        set_irq_chip (irq, &lh7a400_gpio_chip);
-                       set_irq_handler (irq, do_level_IRQ); /* OK default */
+                       set_irq_handler (irq, handle_level_irq); /* OK default */
                        break;
                default:
                        set_irq_chip (irq, &lh7a400_internal_chip);
-                       set_irq_handler (irq, do_level_IRQ);
+                       set_irq_handler (irq, handle_level_irq);
                }
                set_irq_flags (irq, IRQF_VALID);
        }
index 7059b983724f384dbdc2b80936ca5d6aaaa0e8da..5760f8c53e89207914b04b75b55f5b61eb5ea93b 100644 (file)
@@ -161,13 +161,13 @@ void __init lh7a404_init_irq (void)
                        set_irq_chip (irq, irq < 32
                                      ? &lh7a404_gpio_vic1_chip
                                      : &lh7a404_gpio_vic2_chip);
-                       set_irq_handler (irq, do_level_IRQ); /* OK default */
+                       set_irq_handler (irq, handle_level_irq); /* OK default */
                        break;
                default:
                        set_irq_chip (irq, irq < 32
                                      ? &lh7a404_vic1_chip
                                      : &lh7a404_vic2_chip);
-                       set_irq_handler (irq, do_level_IRQ);
+                       set_irq_handler (irq, handle_level_irq);
                }
                set_irq_flags (irq, IRQF_VALID);
        }
index b20376804bbb19849bafdb7348143f6f3a4a60f1..15b9577023c928cca403e209cddb8b1c383f4153 100644 (file)
@@ -57,7 +57,7 @@ static struct irq_chip lh7a40x_cpld_chip = {
        .unmask = lh7a40x_unmask_cpld_irq,
 };
 
-static void lh7a40x_cpld_handler (unsigned int irq, struct irqdesc *desc)
+static void lh7a40x_cpld_handler (unsigned int irq, struct irq_desc *desc)
 {
        unsigned int mask = CPLD_INTERRUPTS;
 
@@ -118,7 +118,7 @@ void __init lh7a40x_init_board_irq (void)
        for (irq = IRQ_BOARD_START;
             irq < IRQ_BOARD_START + NR_IRQ_BOARD; ++irq) {
                set_irq_chip (irq, &lh7a40x_cpld_chip);
-               set_irq_handler (irq, do_edge_IRQ);
+               set_irq_handler (irq, handle_edge_irq);
                set_irq_flags (irq, IRQF_VALID);
        }
 
index edbbbdc3b06be2b50e0c40a46f92cc7b10bfdb64..b9ca8f98265da182787fff8efa2b94d72129b33f 100644 (file)
@@ -69,7 +69,7 @@ static struct platform_device *devices[] __initdata = {
 #endif
 
 static void
-netx_hif_demux_handler(unsigned int irq_unused, struct irqdesc *desc)
+netx_hif_demux_handler(unsigned int irq_unused, struct irq_desc *desc)
 {
        unsigned int irq = NETX_IRQ_HIF_CHAINED(0);
        unsigned int stat;
@@ -160,7 +160,7 @@ netx_hif_unmask_irq(unsigned int _irq)
        DEBUG_IRQ("%s: irq %d\n", __FUNCTION__, _irq);
 }
 
-static struct irqchip netx_hif_chip = {
+static struct irq_chip netx_hif_chip = {
        .ack = netx_hif_ack_irq,
        .mask = netx_hif_mask_irq,
        .unmask = netx_hif_unmask_irq,
@@ -175,7 +175,7 @@ void __init netx_init_irq(void)
 
        for (irq = NETX_IRQ_HIF_CHAINED(0); irq <= NETX_IRQ_HIF_LAST; irq++) {
                set_irq_chip(irq, &netx_hif_chip);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                set_irq_flags(irq, IRQF_VALID);
        }
 
index a611c3b6395491e250cd50be7005b67c5171e307..6dcd10ab4496f765a7681731e85c1a8ee7c36f30 100644 (file)
@@ -55,7 +55,7 @@ static inline void omap_init_irda(void) {}
 
 /*-------------------------------------------------------------------------*/
 
-#if    defined(CONFIG_OMAP_RTC) || defined(CONFIG_OMAP_RTC)
+#if defined(CONFIG_RTC_DRV_OMAP) || defined(CONFIG_RTC_DRV_OMAP_MODULE)
 
 #define        OMAP_RTC_BASE           0xfffb4800
 
index 8e40208b10bbf6f0c61f0c451ac92a3d51a800ab..30e188109046a297fc70a14bcc41ffee59205110 100644 (file)
@@ -84,9 +84,9 @@ static void fpga_mask_ack_irq(unsigned int irq)
        fpga_ack_irq(irq);
 }
 
-void innovator_fpga_IRQ_demux(unsigned int irq, struct irqdesc *desc)
+void innovator_fpga_IRQ_demux(unsigned int irq, struct irq_desc *desc)
 {
-       struct irqdesc *d;
+       struct irq_desc *d;
        u32 stat;
        int fpga_irq;
 
@@ -168,7 +168,7 @@ void omap1510_fpga_init_irq(void)
                        set_irq_chip(i, &omap_fpga_irq);
                }
 
-               set_irq_handler(i, do_edge_IRQ);
+               set_irq_handler(i, handle_edge_irq);
                set_irq_flags(i, IRQF_VALID);
        }
 
index 3ea140bb9ebaae5ba454ed0007ced1e9d4d6a306..6383a12ad970ffe275049d87237109ea80d13a5b 100644 (file)
@@ -229,7 +229,7 @@ void __init omap_init_irq(void)
                        omap_irq_set_cfg(j, 0, 0, irq_trigger);
 
                        set_irq_chip(j, &omap_irq_chip);
-                       set_irq_handler(j, do_level_IRQ);
+                       set_irq_handler(j, handle_level_irq);
                        set_irq_flags(j, IRQF_VALID);
                }
        }
index 11870093d7a1159f41022f747a328c1fa938eda4..a39d306803002448d86357fa3bd7535be73e0e7f 100644 (file)
@@ -130,7 +130,7 @@ void __init omap_init_irq(void)
 
        for (i = 0; i < nr_irqs; i++) {
                set_irq_chip(i, &omap_irq_chip);
-               set_irq_handler(i, do_level_IRQ);
+               set_irq_handler(i, handle_level_irq);
                set_irq_flags(i, IRQF_VALID);
        }
 }
index 3a4bcf3d91fa578d5ed374f4e96d29d23c4c8b2e..968d0b027597399fa88d3d627756dddb1abc7316 100644 (file)
@@ -59,22 +59,22 @@ static int pnx4008_set_irq_type(unsigned int irq, unsigned int type)
        case IRQT_RISING:
                __raw_writel(__raw_readl(INTC_ATR(irq)) | INTC_BIT(irq), INTC_ATR(irq));        /*edge sensitive */
                __raw_writel(__raw_readl(INTC_APR(irq)) | INTC_BIT(irq), INTC_APR(irq));        /*rising edge */
-               set_irq_handler(irq, do_edge_IRQ);
+               set_irq_handler(irq, handle_edge_irq);
                break;
        case IRQT_FALLING:
                __raw_writel(__raw_readl(INTC_ATR(irq)) | INTC_BIT(irq), INTC_ATR(irq));        /*edge sensitive */
                __raw_writel(__raw_readl(INTC_APR(irq)) & ~INTC_BIT(irq), INTC_APR(irq));       /*falling edge */
-               set_irq_handler(irq, do_edge_IRQ);
+               set_irq_handler(irq, handle_edge_irq);
                break;
        case IRQT_LOW:
                __raw_writel(__raw_readl(INTC_ATR(irq)) & ~INTC_BIT(irq), INTC_ATR(irq));       /*level sensitive */
                __raw_writel(__raw_readl(INTC_APR(irq)) & ~INTC_BIT(irq), INTC_APR(irq));       /*low level */
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                break;
        case IRQT_HIGH:
                __raw_writel(__raw_readl(INTC_ATR(irq)) & ~INTC_BIT(irq), INTC_ATR(irq));       /*level sensitive */
                __raw_writel(__raw_readl(INTC_APR(irq)) | INTC_BIT(irq), INTC_APR(irq));        /* high level */
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                break;
 
        /* IRQT_BOTHEDGE is not supported */
@@ -85,7 +85,7 @@ static int pnx4008_set_irq_type(unsigned int irq, unsigned int type)
        return 0;
 }
 
-static struct irqchip pnx4008_irq_chip = {
+static struct irq_chip pnx4008_irq_chip = {
        .ack = pnx4008_mask_ack_irq,
        .mask = pnx4008_mask_irq,
        .unmask = pnx4008_unmask_irq,
index 03d07cae26c827285f9407e47c9b46504d6a08b1..9e3d0bdcba071acd5e8e185aa933417367ed8d08 100644 (file)
@@ -13,12 +13,10 @@ config ARCH_LUBBOCK
 config MACH_LOGICPD_PXA270
        bool "LogicPD PXA270 Card Engine Development Platform"
        select PXA27x
-       select IWMMXT
 
 config MACH_MAINSTONE
        bool "Intel HCDDBBVA0 Development Platform"
        select PXA27x
-       select IWMMXT
 
 config ARCH_PXA_IDP
        bool "Accelent Xscale IDP"
@@ -53,7 +51,6 @@ config PXA_SHARPSL_25x
 config PXA_SHARPSL_27x
        bool "Sharp PXA270 models (SL-Cxx00)"
        select PXA27x
-       select IWMMXT
 
 endchoice
 
@@ -129,11 +126,6 @@ config PXA27x
        help
          Select code specific to PXA27x variants
 
-config IWMMXT
-       bool
-       help
-         Enable support for iWMMXt
-
 config PXA_SHARP_C7xx
        bool
        select PXA_SSP
index 45fb2c3bcf828f3812adf0b95675d77256487c05..6ae605857ca9bfb6764bfbe68761ff960ba35ddb 100644 (file)
 #include <linux/pm.h>
 #include <linux/string.h>
 
+#include <linux/sched.h>
+#include <asm/cnt32_to_63.h>
+#include <asm/div64.h>
+
 #include <asm/hardware.h>
 #include <asm/irq.h>
 #include <asm/system.h>
 
 #include "generic.h"
 
+/*
+ * This is the PXA2xx sched_clock implementation. This has a resolution
+ * of at least 308ns and a maximum value that depends on the value of
+ * CLOCK_TICK_RATE.
+ *
+ * The return value is guaranteed to be monotonic in that range as
+ * long as there is always less than 582 seconds between successive
+ * calls to this function.
+ */
+unsigned long long sched_clock(void)
+{
+       unsigned long long v = cnt32_to_63(OSCR);
+       /* Note: top bit ov v needs cleared unless multiplier is even. */
+
+#if    CLOCK_TICK_RATE == 3686400
+       /* 1E9 / 3686400 => 78125 / 288, max value = 32025597s (370 days). */
+       /* The <<1 is used to get rid of tick.hi top bit */
+       v *= 78125<<1;
+       do_div(v, 288<<1);
+#elif  CLOCK_TICK_RATE == 3250000
+       /* 1E9 / 3250000 => 4000 / 13, max value = 709490156s (8211 days) */
+       v *= 4000;
+       do_div(v, 13);
+#elif  CLOCK_TICK_RATE == 3249600
+       /* 1E9 / 3249600 => 625000 / 2031, max value = 4541295s (52 days) */
+       v *= 625000;
+       do_div(v, 2031);
+#else
+#warning "consider fixing sched_clock for your value of CLOCK_TICK_RATE"
+       /*
+        * 96-bit math to perform tick * NSEC_PER_SEC / CLOCK_TICK_RATE for
+        * any value of CLOCK_TICK_RATE. Max value is in the 80 thousand
+        * years range which is nice, but with higher computation cost.
+        */
+       {
+               union {
+                       unsigned long long val;
+                       struct { unsigned long lo, hi; };
+               } x;
+               unsigned long long y;
+
+               x.val = v;
+               x.hi &= 0x7fffffff;
+               y = (unsigned long long)x.lo * NSEC_PER_SEC;
+               x.lo = y;
+               y = (y >> 32) + (unsigned long long)x.hi * NSEC_PER_SEC;
+               x.hi = do_div(y, CLOCK_TICK_RATE);
+               do_div(x.val, CLOCK_TICK_RATE);
+               x.hi += y;
+               v = x.val;
+       }
+#endif
+
+       return v;
+}
+
 /*
  * Handy function to set GPIO alternate functions
  */
index ab1a16025d51ccb1ec98db0d0eba019d20d5d894..f815678a9d6348be0269f4cb1cc1acf1ea079d84 100644 (file)
@@ -143,7 +143,7 @@ static struct irq_chip pxa_low_gpio_chip = {
  * Demux handler for GPIO>=2 edge detect interrupts
  */
 
-static void pxa_gpio_demux_handler(unsigned int irq, struct irqdesc *desc)
+static void pxa_gpio_demux_handler(unsigned int irq, struct irq_desc *desc)
 {
        unsigned int mask;
        int loop;
@@ -286,27 +286,27 @@ void __init pxa_init_irq(void)
 
        for (irq = PXA_IRQ(PXA_IRQ_SKIP); irq <= PXA_IRQ(31); irq++) {
                set_irq_chip(irq, &pxa_internal_chip_low);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                set_irq_flags(irq, IRQF_VALID);
        }
 
 #if PXA_INTERNAL_IRQS > 32
        for (irq = PXA_IRQ(32); irq < PXA_IRQ(PXA_INTERNAL_IRQS); irq++) {
                set_irq_chip(irq, &pxa_internal_chip_high);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                set_irq_flags(irq, IRQF_VALID);
        }
 #endif
 
        for (irq = IRQ_GPIO0; irq <= IRQ_GPIO1; irq++) {
                set_irq_chip(irq, &pxa_low_gpio_chip);
-               set_irq_handler(irq, do_edge_IRQ);
+               set_irq_handler(irq, handle_edge_irq);
                set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
        }
 
        for (irq = IRQ_GPIO(2); irq <= IRQ_GPIO(PXA_LAST_GPIO); irq++) {
                set_irq_chip(irq, &pxa_muxed_gpio_chip);
-               set_irq_handler(irq, do_edge_IRQ);
+               set_irq_handler(irq, handle_edge_irq);
                set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
        }
 
index 5749f6b72e12646d733a447a9c4bb90e8198adae..8e27a64fa9f40141797e980c102f8f78c687b354 100644 (file)
@@ -75,7 +75,7 @@ static struct irq_chip lpd270_irq_chip = {
        .unmask         = lpd270_unmask_irq,
 };
 
-static void lpd270_irq_handler(unsigned int irq, struct irqdesc *desc)
+static void lpd270_irq_handler(unsigned int irq, struct irq_desc *desc)
 {
        unsigned long pending;
 
@@ -105,7 +105,7 @@ static void __init lpd270_init_irq(void)
        /* setup extra LogicPD PXA270 irqs */
        for (irq = LPD270_IRQ(2); irq <= LPD270_IRQ(4); irq++) {
                set_irq_chip(irq, &lpd270_irq_chip);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
        }
        set_irq_chained_handler(IRQ_GPIO(0), lpd270_irq_handler);
index 142c33c3dff57ab4233ef0b4db002c12906c33a3..055de7f4f00ad113c730f13e2ccba025ec6b3e8d 100644 (file)
@@ -85,7 +85,7 @@ static struct irq_chip lubbock_irq_chip = {
        .unmask         = lubbock_unmask_irq,
 };
 
-static void lubbock_irq_handler(unsigned int irq, struct irqdesc *desc)
+static void lubbock_irq_handler(unsigned int irq, struct irq_desc *desc)
 {
        unsigned long pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
        do {
@@ -108,7 +108,7 @@ static void __init lubbock_init_irq(void)
        /* setup extra lubbock irqs */
        for (irq = LUBBOCK_IRQ(0); irq <= LUBBOCK_LAST_IRQ; irq++) {
                set_irq_chip(irq, &lubbock_irq_chip);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
        }
 
index 49c34d94a9fee6d489b11f19346586e5d5091525..56d94d88d5cad3753b0d0129abe0b3f9cc71bde7 100644 (file)
@@ -71,7 +71,7 @@ static struct irq_chip mainstone_irq_chip = {
        .unmask         = mainstone_unmask_irq,
 };
 
-static void mainstone_irq_handler(unsigned int irq, struct irqdesc *desc)
+static void mainstone_irq_handler(unsigned int irq, struct irq_desc *desc)
 {
        unsigned long pending = MST_INTSETCLR & mainstone_irq_enabled;
        do {
@@ -94,7 +94,7 @@ static void __init mainstone_init_irq(void)
        /* setup extra Mainstone irqs */
        for(irq = MAINSTONE_IRQ(0); irq <= MAINSTONE_IRQ(15); irq++) {
                set_irq_chip(irq, &mainstone_irq_chip);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                if (irq == MAINSTONE_IRQ(10) || irq == MAINSTONE_IRQ(14))
                        set_irq_flags(irq, IRQF_VALID | IRQF_PROBE | IRQF_NOAUTOEN);
                else
index 2112c414f0e212588742c1be02c2a312772856a8..b4d8276d6050b1e34d16c06153228f03c0b113a3 100644 (file)
@@ -83,7 +83,8 @@ int pxa_pm_enter(suspend_state_t state)
 
 #ifdef CONFIG_IWMMXT
        /* force any iWMMXt context to ram **/
-       iwmmxt_task_disable(NULL);
+       if (elf_hwcap & HWCAP_IWMMXT)
+               iwmmxt_task_disable(NULL);
 #endif
 
        /* preserve current time */
index 3ac268fa419b68ce81c04af8e5b369d7f1aae1ca..b914668610298507badd3441484d627bbd8f888a 100644 (file)
@@ -124,6 +124,7 @@ static struct irqaction pxa_timer_irq = {
 static void __init pxa_timer_init(void)
 {
        struct timespec tv;
+       unsigned long flags;
 
        set_rtc = pxa_set_rtc;
 
@@ -132,12 +133,12 @@ static void __init pxa_timer_init(void)
        do_settimeofday(&tv);
 
        OIER = 0;               /* disable any timer interrupts */
-       OSCR = LATCH*2;         /* push OSCR out of the way */
-       OSMR0 = LATCH;          /* set initial match */
        OSSR = 0xf;             /* clear status on all timers */
        setup_irq(IRQ_OST0, &pxa_timer_irq);
+       local_irq_save(flags);
        OIER = OIER_E0;         /* enable match on timer 0 to cause interrupts */
-       OSCR = 0;               /* initialize free-running timer */
+       OSMR0 = OSCR + LATCH;   /* set initial match */
+       local_irq_restore(flags);
 }
 
 #ifdef CONFIG_NO_IDLE_HZ
index 56b2716f8cf5ba49e4cf747d75c034b23d9166ed..7a029621db433a8199a9ccb33513057aa4566505 100644 (file)
@@ -34,7 +34,7 @@ static void iomd_unmask_irq_a(unsigned int irq)
        iomd_writeb(val | mask, IOMD_IRQMASKA);
 }
 
-static struct irqchip iomd_a_chip = {
+static struct irq_chip iomd_a_chip = {
        .ack    = iomd_ack_irq_a,
        .mask   = iomd_mask_irq_a,
        .unmask = iomd_unmask_irq_a,
@@ -58,7 +58,7 @@ static void iomd_unmask_irq_b(unsigned int irq)
        iomd_writeb(val | mask, IOMD_IRQMASKB);
 }
 
-static struct irqchip iomd_b_chip = {
+static struct irq_chip iomd_b_chip = {
        .ack    = iomd_mask_irq_b,
        .mask   = iomd_mask_irq_b,
        .unmask = iomd_unmask_irq_b,
@@ -82,7 +82,7 @@ static void iomd_unmask_irq_dma(unsigned int irq)
        iomd_writeb(val | mask, IOMD_DMAMASK);
 }
 
-static struct irqchip iomd_dma_chip = {
+static struct irq_chip iomd_dma_chip = {
        .ack    = iomd_mask_irq_dma,
        .mask   = iomd_mask_irq_dma,
        .unmask = iomd_unmask_irq_dma,
@@ -106,7 +106,7 @@ static void iomd_unmask_irq_fiq(unsigned int irq)
        iomd_writeb(val | mask, IOMD_FIQMASK);
 }
 
-static struct irqchip iomd_fiq_chip = {
+static struct irq_chip iomd_fiq_chip = {
        .ack    = iomd_mask_irq_fiq,
        .mask   = iomd_mask_irq_fiq,
        .unmask = iomd_unmask_irq_fiq,
@@ -134,19 +134,19 @@ void __init rpc_init_irq(void)
                switch (irq) {
                case 0 ... 7:
                        set_irq_chip(irq, &iomd_a_chip);
-                       set_irq_handler(irq, do_level_IRQ);
+                       set_irq_handler(irq, handle_level_irq);
                        set_irq_flags(irq, flags);
                        break;
 
                case 8 ... 15:
                        set_irq_chip(irq, &iomd_b_chip);
-                       set_irq_handler(irq, do_level_IRQ);
+                       set_irq_handler(irq, handle_level_irq);
                        set_irq_flags(irq, flags);
                        break;
 
                case 16 ... 21:
                        set_irq_chip(irq, &iomd_dma_chip);
-                       set_irq_handler(irq, do_level_IRQ);
+                       set_irq_handler(irq, handle_level_irq);
                        set_irq_flags(irq, flags);
                        break;
 
index 9aa26b99045dfd58251363ac957d72d73ad5b8b4..9f46bf330bc8f314420e2764092d8c4602aa1792 100644 (file)
@@ -41,9 +41,16 @@ config BAST_PC104_IRQ
          Say Y here to enable the PC104 IRQ routing on the
          Simtec BAST (EB2410ITX)
 
+config PM_H1940
+       bool
+       depends on PM
+       help
+         Internal node for H1940 and related PM
+
 config ARCH_H1940
        bool "IPAQ H1940"
        select CPU_S3C2410
+       select PM_H1940
        help
          Say Y here if you are using the HP IPAQ H1940
 
@@ -115,6 +122,7 @@ config MACH_VR1000
 config MACH_RX3715
        bool "HP iPAQ rx3715"
        select CPU_S3C2440
+       select PM_H1940
        help
          Say Y here if you are using the HP iPAQ rx3715.
 
index d66013365b6bc2e7fa9d2888272a5df8520cd17d..27663e28cc8881bd49aefd1a59fba40b3b337862 100644 (file)
@@ -31,6 +31,7 @@ obj-$(CONFIG_CPU_S3C2410_DMA) += s3c2410-dma.o
 
 obj-$(CONFIG_PM)               += pm.o sleep.o
 obj-$(CONFIG_PM_SIMTEC)                += pm-simtec.o
+obj-$(CONFIG_PM_H1940)         += pm-h1940.o
 
 # S3C2412 support
 obj-$(CONFIG_CPU_S3C2412)      += s3c2412.o
index 23d5beea55680bc04dc45a726945bb85b6f567c8..379efe70778c6841d4b407d16b3a33c5f66070b5 100644 (file)
@@ -88,7 +88,7 @@ bast_pc104_mask(unsigned int irqno)
 static void
 bast_pc104_maskack(unsigned int irqno)
 {
-       struct irqdesc *desc = irq_desc + IRQ_ISA;
+       struct irq_desc *desc = irq_desc + IRQ_ISA;
 
        bast_pc104_mask(irqno);
        desc->chip->ack(IRQ_ISA);
@@ -104,7 +104,7 @@ bast_pc104_unmask(unsigned int irqno)
        __raw_writeb(temp, BAST_VA_PC104_IRQMASK);
 }
 
-static struct irqchip  bast_pc104_chip = {
+static struct irq_chip  bast_pc104_chip = {
        .mask        = bast_pc104_mask,
        .unmask      = bast_pc104_unmask,
        .ack         = bast_pc104_maskack
@@ -112,7 +112,7 @@ static struct irqchip  bast_pc104_chip = {
 
 static void
 bast_irq_pc104_demux(unsigned int irq,
-                    struct irqdesc *desc)
+                    struct irq_desc *desc)
 {
        unsigned int stat;
        unsigned int irqno;
@@ -157,7 +157,7 @@ static __init int bast_irq_init(void)
                        unsigned int irqno = bast_pc104_irqs[i];
 
                        set_irq_chip(irqno, &bast_pc104_chip);
-                       set_irq_handler(irqno, do_level_IRQ);
+                       set_irq_handler(irqno, handle_level_irq);
                        set_irq_flags(irqno, IRQF_VALID);
                }
        }
index 3d211dc2f2f90923136b55a8e814e842463e49d0..01abb0ace234ad823df9ad39b90ab719f1167d4e 100644 (file)
@@ -40,7 +40,7 @@
 
 /* io map for dma */
 static void __iomem *dma_base;
-static kmem_cache_t *dma_kmem;
+static struct kmem_cache *dma_kmem;
 
 struct s3c24xx_dma_selection dma_sel;
 
@@ -1271,7 +1271,7 @@ struct sysdev_class dma_sysclass = {
 
 /* kmem cache implementation */
 
-static void s3c2410_dma_cache_ctor(void *p, kmem_cache_t *c, unsigned long f)
+static void s3c2410_dma_cache_ctor(void *p, struct kmem_cache *c, unsigned long f)
 {
        memset(p, 0, sizeof(struct s3c2410_dma_buf));
 }
index 683b3491ba3c4ae4634aed2e7a217363dc03f45b..3c0ed7871c55dc51c0c4dbf41a7a0d4e92fbb70f 100644 (file)
@@ -180,7 +180,7 @@ s3c_irq_unmask(unsigned int irqno)
        __raw_writel(mask, S3C2410_INTMSK);
 }
 
-struct irqchip s3c_irq_level_chip = {
+struct irq_chip s3c_irq_level_chip = {
        .name           = "s3c-level",
        .ack            = s3c_irq_maskack,
        .mask           = s3c_irq_mask,
@@ -188,7 +188,7 @@ struct irqchip s3c_irq_level_chip = {
        .set_wake       = s3c_irq_wake
 };
 
-static struct irqchip s3c_irq_chip = {
+static struct irq_chip s3c_irq_chip = {
        .name           = "s3c",
        .ack            = s3c_irq_ack,
        .mask           = s3c_irq_mask,
@@ -206,18 +206,6 @@ s3c_irqext_mask(unsigned int irqno)
        mask = __raw_readl(S3C24XX_EINTMASK);
        mask |= ( 1UL << irqno);
        __raw_writel(mask, S3C24XX_EINTMASK);
-
-       if (irqno <= (IRQ_EINT7 - EXTINT_OFF)) {
-               /* check to see if all need masking */
-
-               if ((mask & (0xf << 4)) == (0xf << 4)) {
-                       /* all masked, mask the parent */
-                       s3c_irq_mask(IRQ_EINT4t7);
-               }
-       } else {
-               /* todo: the same check as above for the rest of the irq regs...*/
-
-       }
 }
 
 static void
@@ -229,7 +217,6 @@ s3c_irqext_ack(unsigned int irqno)
 
        bit = 1UL << (irqno - EXTINT_OFF);
 
-
        mask = __raw_readl(S3C24XX_EINTMASK);
 
        __raw_writel(bit, S3C24XX_EINTPEND);
@@ -258,8 +245,6 @@ s3c_irqext_unmask(unsigned int irqno)
        mask = __raw_readl(S3C24XX_EINTMASK);
        mask &= ~( 1UL << irqno);
        __raw_writel(mask, S3C24XX_EINTMASK);
-
-       s3c_irq_unmask((irqno <= (IRQ_EINT7 - EXTINT_OFF)) ? IRQ_EINT4t7 : IRQ_EINT8t23);
 }
 
 int
@@ -344,7 +329,7 @@ s3c_irqext_type(unsigned int irq, unsigned int type)
        return 0;
 }
 
-static struct irqchip s3c_irqext_chip = {
+static struct irq_chip s3c_irqext_chip = {
        .name           = "s3c-ext",
        .mask           = s3c_irqext_mask,
        .unmask         = s3c_irqext_unmask,
@@ -353,7 +338,7 @@ static struct irqchip s3c_irqext_chip = {
        .set_wake       = s3c_irqext_wake
 };
 
-static struct irqchip s3c_irq_eint0t4 = {
+static struct irq_chip s3c_irq_eint0t4 = {
        .name           = "s3c-ext0",
        .ack            = s3c_irq_ack,
        .mask           = s3c_irq_mask,
@@ -390,7 +375,7 @@ s3c_irq_uart0_ack(unsigned int irqno)
        s3c_irqsub_maskack(irqno, INTMSK_UART0, 7);
 }
 
-static struct irqchip s3c_irq_uart0 = {
+static struct irq_chip s3c_irq_uart0 = {
        .name           = "s3c-uart0",
        .mask           = s3c_irq_uart0_mask,
        .unmask         = s3c_irq_uart0_unmask,
@@ -417,7 +402,7 @@ s3c_irq_uart1_ack(unsigned int irqno)
        s3c_irqsub_maskack(irqno, INTMSK_UART1, 7 << 3);
 }
 
-static struct irqchip s3c_irq_uart1 = {
+static struct irq_chip s3c_irq_uart1 = {
        .name           = "s3c-uart1",
        .mask           = s3c_irq_uart1_mask,
        .unmask         = s3c_irq_uart1_unmask,
@@ -444,7 +429,7 @@ s3c_irq_uart2_ack(unsigned int irqno)
        s3c_irqsub_maskack(irqno, INTMSK_UART2, 7 << 6);
 }
 
-static struct irqchip s3c_irq_uart2 = {
+static struct irq_chip s3c_irq_uart2 = {
        .name           = "s3c-uart2",
        .mask           = s3c_irq_uart2_mask,
        .unmask         = s3c_irq_uart2_unmask,
@@ -471,7 +456,7 @@ s3c_irq_adc_ack(unsigned int irqno)
        s3c_irqsub_ack(irqno, INTMSK_ADCPARENT, 3 << 9);
 }
 
-static struct irqchip s3c_irq_adc = {
+static struct irq_chip s3c_irq_adc = {
        .name           = "s3c-adc",
        .mask           = s3c_irq_adc_mask,
        .unmask         = s3c_irq_adc_unmask,
@@ -480,11 +465,11 @@ static struct irqchip s3c_irq_adc = {
 
 /* irq demux for adc */
 static void s3c_irq_demux_adc(unsigned int irq,
-                             struct irqdesc *desc)
+                             struct irq_desc *desc)
 {
        unsigned int subsrc, submsk;
        unsigned int offset = 9;
-       struct irqdesc *mydesc;
+       struct irq_desc *mydesc;
 
        /* read the current pending interrupts, and the mask
         * for what it is available */
@@ -512,7 +497,7 @@ static void s3c_irq_demux_uart(unsigned int start)
 {
        unsigned int subsrc, submsk;
        unsigned int offset = start - IRQ_S3CUART_RX0;
-       struct irqdesc *desc;
+       struct irq_desc *desc;
 
        /* read the current pending interrupts, and the mask
         * for what it is available */
@@ -549,7 +534,7 @@ static void s3c_irq_demux_uart(unsigned int start)
 
 static void
 s3c_irq_demux_uart0(unsigned int irq,
-                   struct irqdesc *desc)
+                   struct irq_desc *desc)
 {
        irq = irq;
        s3c_irq_demux_uart(IRQ_S3CUART_RX0);
@@ -557,7 +542,7 @@ s3c_irq_demux_uart0(unsigned int irq,
 
 static void
 s3c_irq_demux_uart1(unsigned int irq,
-                   struct irqdesc *desc)
+                   struct irq_desc *desc)
 {
        irq = irq;
        s3c_irq_demux_uart(IRQ_S3CUART_RX1);
@@ -565,7 +550,7 @@ s3c_irq_demux_uart1(unsigned int irq,
 
 static void
 s3c_irq_demux_uart2(unsigned int irq,
-                   struct irqdesc *desc)
+                   struct irq_desc *desc)
 {
        irq = irq;
        s3c_irq_demux_uart(IRQ_S3CUART_RX2);
@@ -573,7 +558,7 @@ s3c_irq_demux_uart2(unsigned int irq,
 
 static void
 s3c_irq_demux_extint8(unsigned int irq,
-                     struct irqdesc *desc)
+                     struct irq_desc *desc)
 {
        unsigned long eintpnd = __raw_readl(S3C24XX_EINTPEND);
        unsigned long eintmsk = __raw_readl(S3C24XX_EINTMASK);
@@ -595,7 +580,7 @@ s3c_irq_demux_extint8(unsigned int irq,
 
 static void
 s3c_irq_demux_extint4t7(unsigned int irq,
-                       struct irqdesc *desc)
+                       struct irq_desc *desc)
 {
        unsigned long eintpnd = __raw_readl(S3C24XX_EINTPEND);
        unsigned long eintmsk = __raw_readl(S3C24XX_EINTMASK);
@@ -738,7 +723,7 @@ void __init s3c24xx_init_irq(void)
                case IRQ_UART2:
                case IRQ_ADCPARENT:
                        set_irq_chip(irqno, &s3c_irq_level_chip);
-                       set_irq_handler(irqno, do_level_IRQ);
+                       set_irq_handler(irqno, handle_level_irq);
                        break;
 
                case IRQ_RESERVED6:
@@ -749,7 +734,7 @@ void __init s3c24xx_init_irq(void)
                default:
                        //irqdbf("registering irq %d (s3c irq)\n", irqno);
                        set_irq_chip(irqno, &s3c_irq_chip);
-                       set_irq_handler(irqno, do_edge_IRQ);
+                       set_irq_handler(irqno, handle_edge_irq);
                        set_irq_flags(irqno, IRQF_VALID);
                }
        }
@@ -769,14 +754,14 @@ void __init s3c24xx_init_irq(void)
        for (irqno = IRQ_EINT0; irqno <= IRQ_EINT3; irqno++) {
                irqdbf("registering irq %d (ext int)\n", irqno);
                set_irq_chip(irqno, &s3c_irq_eint0t4);
-               set_irq_handler(irqno, do_edge_IRQ);
+               set_irq_handler(irqno, handle_edge_irq);
                set_irq_flags(irqno, IRQF_VALID);
        }
 
        for (irqno = IRQ_EINT4; irqno <= IRQ_EINT23; irqno++) {
                irqdbf("registering irq %d (extended s3c irq)\n", irqno);
                set_irq_chip(irqno, &s3c_irqext_chip);
-               set_irq_handler(irqno, do_edge_IRQ);
+               set_irq_handler(irqno, handle_edge_irq);
                set_irq_flags(irqno, IRQF_VALID);
        }
 
@@ -787,28 +772,28 @@ void __init s3c24xx_init_irq(void)
        for (irqno = IRQ_S3CUART_RX0; irqno <= IRQ_S3CUART_ERR0; irqno++) {
                irqdbf("registering irq %d (s3c uart0 irq)\n", irqno);
                set_irq_chip(irqno, &s3c_irq_uart0);
-               set_irq_handler(irqno, do_level_IRQ);
+               set_irq_handler(irqno, handle_level_irq);
                set_irq_flags(irqno, IRQF_VALID);
        }
 
        for (irqno = IRQ_S3CUART_RX1; irqno <= IRQ_S3CUART_ERR1; irqno++) {
                irqdbf("registering irq %d (s3c uart1 irq)\n", irqno);
                set_irq_chip(irqno, &s3c_irq_uart1);
-               set_irq_handler(irqno, do_level_IRQ);
+               set_irq_handler(irqno, handle_level_irq);
                set_irq_flags(irqno, IRQF_VALID);
        }
 
        for (irqno = IRQ_S3CUART_RX2; irqno <= IRQ_S3CUART_ERR2; irqno++) {
                irqdbf("registering irq %d (s3c uart2 irq)\n", irqno);
                set_irq_chip(irqno, &s3c_irq_uart2);
-               set_irq_handler(irqno, do_level_IRQ);
+               set_irq_handler(irqno, handle_level_irq);
                set_irq_flags(irqno, IRQF_VALID);
        }
 
        for (irqno = IRQ_TC; irqno <= IRQ_ADC; irqno++) {
                irqdbf("registering irq %d (s3c adc irq)\n", irqno);
                set_irq_chip(irqno, &s3c_irq_adc);
-               set_irq_handler(irqno, do_edge_IRQ);
+               set_irq_handler(irqno, handle_edge_irq);
                set_irq_flags(irqno, IRQF_VALID);
        }
 
index 842a9f42c97b9d4b60a08fbfee3dc818667fd801..3686a00822459b20bced746696e2681f81a46f48 100644 (file)
@@ -17,7 +17,7 @@
 
 #define EXTINT_OFF (IRQ_EINT4 - 4)
 
-extern struct irqchip s3c_irq_level_chip;
+extern struct irq_chip s3c_irq_level_chip;
 
 static inline void
 s3c_irqsub_mask(unsigned int irqno, unsigned int parentbit,
index 8c895c077d22d48701251f889abbc04c6b3c2466..f5b98099a5d9cb1c925d060eb0b472be65078e6e 100644 (file)
@@ -33,6 +33,7 @@
 #include <asm/arch/regs-serial.h>
 #include <asm/arch/regs-lcd.h>
 
+#include <asm/arch/h1940.h>
 #include <asm/arch/h1940-latch.h>
 #include <asm/arch/fb.h>
 
@@ -41,6 +42,7 @@
 #include "clock.h"
 #include "devs.h"
 #include "cpu.h"
+#include "pm.h"
 
 static struct map_desc h1940_iodesc[] __initdata = {
        [0] = {
@@ -164,12 +166,16 @@ static void __init h1940_map_io(void)
        s3c24xx_init_clocks(0);
        s3c24xx_init_uarts(h1940_uartcfgs, ARRAY_SIZE(h1940_uartcfgs));
        s3c24xx_set_board(&h1940_board);
+
+       /* setup PM */
+
+       memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 1024);
+       s3c2410_pm_init();
 }
 
 static void __init h1940_init_irq(void)
 {
        s3c24xx_init_irq();
-
 }
 
 static void __init h1940_init(void)
index e193ba69e652e2e39c0dffed700363cbecb42c54..a4ab144e7292622d4c4968fb43c8da5544a557de 100644 (file)
@@ -114,6 +114,15 @@ static struct s3c2410_uartcfg osiris_uartcfgs[] __initdata = {
                .clocks      = osiris_serial_clocks,
                .clocks_size = ARRAY_SIZE(osiris_serial_clocks),
        },
+       [2] = {
+               .hwport      = 2,
+               .flags       = 0,
+               .ucon        = UCON,
+               .ulcon       = ULCON,
+               .ufcon       = UFCON,
+               .clocks      = osiris_serial_clocks,
+               .clocks_size = ARRAY_SIZE(osiris_serial_clocks),
+       }
 };
 
 /* NAND Flash on Osiris board */
index 23d7c052013ce08aeefd58f45fbc0ee858ae78d1..ecbcdf79d739b9abf1f4f5e248aca5292a412e39 100644 (file)
@@ -42,6 +42,7 @@
 #include <asm/arch/regs-gpio.h>
 #include <asm/arch/regs-lcd.h>
 
+#include <asm/arch/h1940.h>
 #include <asm/arch/nand.h>
 #include <asm/arch/fb.h>
 
@@ -224,7 +225,9 @@ static void __init rx3715_init_irq(void)
 
 static void __init rx3715_init_machine(void)
 {
+       memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 1024);
        s3c2410_pm_init();
+
        s3c24xx_fb_set_platdata(&rx3715_lcdcfg);
 }
 
index a0d7692cdb2b918f6304280cf63bfc613fb73122..e2eda3937ab08915ca1c98b4c3abbfb50567be9e 100644 (file)
@@ -41,6 +41,7 @@
 
 #include <asm/arch/regs-serial.h>
 #include <asm/arch/regs-gpio.h>
+#include <asm/arch/leds-gpio.h>
 
 #include "clock.h"
 #include "devs.h"
@@ -313,6 +314,50 @@ static struct platform_device vr1000_dm9k1 = {
        }
 };
 
+/* LEDS */
+
+static struct s3c24xx_led_platdata vr1000_led1_pdata = {
+       .name           = "led1",
+       .gpio           = S3C2410_GPB0,
+       .def_trigger    = "",
+};
+
+static struct s3c24xx_led_platdata vr1000_led2_pdata = {
+       .name           = "led2",
+       .gpio           = S3C2410_GPB1,
+       .def_trigger    = "",
+};
+
+static struct s3c24xx_led_platdata vr1000_led3_pdata = {
+       .name           = "led3",
+       .gpio           = S3C2410_GPB2,
+       .def_trigger    = "",
+};
+
+static struct platform_device vr1000_led1 = {
+       .name           = "s3c24xx_led",
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &vr1000_led1_pdata,
+       },
+};
+
+static struct platform_device vr1000_led2 = {
+       .name           = "s3c24xx_led",
+       .id             = 2,
+       .dev            = {
+               .platform_data  = &vr1000_led2_pdata,
+       },
+};
+
+static struct platform_device vr1000_led3 = {
+       .name           = "s3c24xx_led",
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &vr1000_led3_pdata,
+       },
+};
+
 /* devices for this board */
 
 static struct platform_device *vr1000_devices[] __initdata = {
@@ -325,7 +370,10 @@ static struct platform_device *vr1000_devices[] __initdata = {
        &serial_device,
        &vr1000_nor,
        &vr1000_dm9k0,
-       &vr1000_dm9k1
+       &vr1000_dm9k1,
+       &vr1000_led1,
+       &vr1000_led2,
+       &vr1000_led3,
 };
 
 static struct clk *vr1000_clocks[] = {
diff --git a/arch/arm/mach-s3c2410/pm-h1940.S b/arch/arm/mach-s3c2410/pm-h1940.S
new file mode 100644 (file)
index 0000000..7d66de7
--- /dev/null
@@ -0,0 +1,33 @@
+/* linux/arch/arm/mach-s3c2410/pm-h1940.S
+ *
+ * Copyright (c) 2006 Ben Dooks <ben-linux@fluff.org>
+ *
+ * H1940 Suspend to RAM
+ *
+ * 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
+ *
+ * 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
+*/
+
+#include <linux/linkage.h>
+#include <asm/assembler.h>
+#include <asm/hardware.h>
+#include <asm/arch/map.h>
+
+#include <asm/arch/regs-gpio.h>
+
+       .text
+       .global h1940_pm_return
+
+h1940_pm_return:
+       mov     r0, #S3C2410_PA_GPIO
+       ldr     pc, [ r0, #S3C2410_GSTATUS3 - S3C24XX_VA_GPIO ]
index e51d76669512ced432e3df2bf5f5147cfbdaa702..77c6814c0f0507599c650e72d35bfd3d071b6c58 100644 (file)
@@ -32,6 +32,7 @@
 #include <asm/mach-types.h>
 
 #include <asm/arch/regs-gpio.h>
+#include <asm/arch/h1940.h>
 
 #include "cpu.h"
 #include "pm.h"
@@ -52,6 +53,35 @@ static void s3c2410_pm_prepare(void)
        DBG("GSTATUS3 0x%08x\n", __raw_readl(S3C2410_GSTATUS3));
        DBG("GSTATUS4 0x%08x\n", __raw_readl(S3C2410_GSTATUS4));
 
+       if (machine_is_h1940()) {
+               void *base = phys_to_virt(H1940_SUSPEND_CHECK);
+               unsigned long ptr;
+               unsigned long calc = 0;
+
+               /* generate check for the bootloader to check on resume */
+
+               for (ptr = 0; ptr < 0x40000; ptr += 0x400)
+                       calc += __raw_readl(base+ptr);
+
+               __raw_writel(calc, phys_to_virt(H1940_SUSPEND_CHECKSUM));
+       }
+
+       /* the RX3715 uses similar code and the same H1940 and the
+        * same offsets for resume and checksum pointers */
+
+       if (machine_is_rx3715()) {
+               void *base = phys_to_virt(H1940_SUSPEND_CHECK);
+               unsigned long ptr;
+               unsigned long calc = 0;
+
+               /* generate check for the bootloader to check on resume */
+
+               for (ptr = 0; ptr < 0x40000; ptr += 0x4)
+                       calc += __raw_readl(base+ptr);
+
+               __raw_writel(calc, phys_to_virt(H1940_SUSPEND_CHECKSUM));
+       }
+
        if ( machine_is_aml_m5900() )
                s3c2410_gpio_setpin(S3C2410_GPF2, 1);
 
index 7f741547658fbd34173815982ecc92d9411b6b2d..ffcc30b23a8052d1a0abf920b4cdeed0ad203f9e 100644 (file)
@@ -98,7 +98,7 @@ s3c2412_irq_unmask(unsigned int irqno)
        __raw_writel(mask & ~bitval, S3C2410_INTMSK);
 }
 
-static struct irqchip s3c2412_irq_eint0t4 = {
+static struct irq_chip s3c2412_irq_eint0t4 = {
        .ack       = s3c2412_irq_ack,
        .mask      = s3c2412_irq_mask,
        .unmask    = s3c2412_irq_unmask,
@@ -112,7 +112,7 @@ static int s3c2412_irq_add(struct sys_device *sysdev)
 
        for (irqno = IRQ_EINT0; irqno <= IRQ_EINT3; irqno++) {
                set_irq_chip(irqno, &s3c2412_irq_eint0t4);
-               set_irq_handler(irqno, do_edge_IRQ);
+               set_irq_handler(irqno, handle_edge_irq);
                set_irq_flags(irqno, IRQF_VALID);
        }
 
index 39db0752d53b1b67573dcb4f227a06411b312b80..1ba19b27ab0560c18bde1709aad224de3d47fc0a 100644 (file)
 /* WDT/AC97 */
 
 static void s3c_irq_demux_wdtac97(unsigned int irq,
-                                 struct irqdesc *desc)
+                                 struct irq_desc *desc)
 {
        unsigned int subsrc, submsk;
-       struct irqdesc *mydesc;
+       struct irq_desc *mydesc;
 
        /* read the current pending interrupts, and the mask
         * for what it is available */
@@ -90,7 +90,7 @@ s3c_irq_wdtac97_ack(unsigned int irqno)
        s3c_irqsub_maskack(irqno, INTMSK_WDT, 3<<13);
 }
 
-static struct irqchip s3c_irq_wdtac97 = {
+static struct irq_chip s3c_irq_wdtac97 = {
        .mask       = s3c_irq_wdtac97_mask,
        .unmask     = s3c_irq_wdtac97_unmask,
        .ack        = s3c_irq_wdtac97_ack,
@@ -105,12 +105,12 @@ static int s3c2440_irq_add(struct sys_device *sysdev)
        /* add new chained handler for wdt, ac7 */
 
        set_irq_chip(IRQ_WDT, &s3c_irq_level_chip);
-       set_irq_handler(IRQ_WDT, do_level_IRQ);
+       set_irq_handler(IRQ_WDT, handle_level_irq);
        set_irq_chained_handler(IRQ_WDT, s3c_irq_demux_wdtac97);
 
        for (irqno = IRQ_S3C2440_WDT; irqno <= IRQ_S3C2440_AC97; irqno++) {
                set_irq_chip(irqno, &s3c_irq_wdtac97);
-               set_irq_handler(irqno, do_level_IRQ);
+               set_irq_handler(irqno, handle_level_irq);
                set_irq_flags(irqno, IRQF_VALID);
        }
 
index 146f2109dd905bcff124151fea8573428a8a68a3..ede94636a72a94bc0be668fd102472b5975d8ca2 100644 (file)
 /* camera irq */
 
 static void s3c_irq_demux_cam(unsigned int irq,
-                             struct irqdesc *desc)
+                             struct irq_desc *desc)
 {
        unsigned int subsrc, submsk;
-       struct irqdesc *mydesc;
+       struct irq_desc *mydesc;
 
        /* read the current pending interrupts, and the mask
         * for what it is available */
@@ -89,7 +89,7 @@ s3c_irq_cam_ack(unsigned int irqno)
        s3c_irqsub_maskack(irqno, INTMSK_CAM, 3<<11);
 }
 
-static struct irqchip s3c_irq_cam = {
+static struct irq_chip s3c_irq_cam = {
        .mask       = s3c_irq_cam_mask,
        .unmask     = s3c_irq_cam_unmask,
        .ack        = s3c_irq_cam_ack,
@@ -100,18 +100,18 @@ static int s3c244x_irq_add(struct sys_device *sysdev)
        unsigned int irqno;
 
        set_irq_chip(IRQ_NFCON, &s3c_irq_level_chip);
-       set_irq_handler(IRQ_NFCON, do_level_IRQ);
+       set_irq_handler(IRQ_NFCON, handle_level_irq);
        set_irq_flags(IRQ_NFCON, IRQF_VALID);
 
        /* add chained handler for camera */
 
        set_irq_chip(IRQ_CAM, &s3c_irq_level_chip);
-       set_irq_handler(IRQ_CAM, do_level_IRQ);
+       set_irq_handler(IRQ_CAM, handle_level_irq);
        set_irq_chained_handler(IRQ_CAM, s3c_irq_demux_cam);
 
        for (irqno = IRQ_S3C2440_CAM_C; irqno <= IRQ_S3C2440_CAM_P; irqno++) {
                set_irq_chip(irqno, &s3c_irq_cam);
-               set_irq_handler(irqno, do_level_IRQ);
+               set_irq_handler(irqno, handle_level_irq);
                set_irq_flags(irqno, IRQF_VALID);
        }
 
index 4575f316e141a80179d341eee2a19eb27118c22f..e510295c2580d89591eee0b4675f8d401f966540 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/platform_device.h>
 
 #include <asm/div64.h>
+#include <asm/cnt32_to_63.h>
 #include <asm/hardware.h>
 #include <asm/system.h>
 #include <asm/pgtable.h>
@@ -118,15 +119,21 @@ EXPORT_SYMBOL(cpufreq_get);
 
 /*
  * This is the SA11x0 sched_clock implementation.  This has
- * a resolution of 271ns, and a maximum value of 1165s.
+ * a resolution of 271ns, and a maximum value of 32025597s (370 days).
+ *
+ * The return value is guaranteed to be monotonic in that range as
+ * long as there is always less than 582 seconds between successive
+ * calls to this function.
+ *
  *  ( * 1E9 / 3686400 => * 78125 / 288)
  */
 unsigned long long sched_clock(void)
 {
-       unsigned long long v;
+       unsigned long long v = cnt32_to_63(OSCR);
 
-       v = (unsigned long long)OSCR * 78125;
-       do_div(v, 288);
+       /* the <<1 gets rid of the cnt_32_to_63 top bit saving on a bic insn */
+       v *= 78125<<1;
+       do_div(v, 288<<1);
 
        return v;
 }
index fa6dc71bd6ad053bef39fffde07261f190ee5f50..b034ad69a3249e979fb61eb56f002d9113a8c3c7 100644 (file)
@@ -702,7 +702,7 @@ static u32 gpio_irq_mask[] = {
        GPIO2_SD_CON_SLT,
 };
 
-static void h3800_IRQ_demux(unsigned int irq, struct irqdesc *desc)
+static void h3800_IRQ_demux(unsigned int irq, struct irq_desc *desc)
 {
        int i;
 
@@ -719,14 +719,14 @@ static void h3800_IRQ_demux(unsigned int irq, struct irqdesc *desc)
                if (0) printk("%s KPIO 0x%08X\n", __FUNCTION__, irq);
                for (j = 0; j < H3800_KPIO_IRQ_COUNT; j++)
                        if (irq & kpio_irq_mask[j])
-                               do_edge_IRQ(H3800_KPIO_IRQ_COUNT + j, irq_desc + H3800_KPIO_IRQ_COUNT + j);
+                               handle_edge_irq(H3800_KPIO_IRQ_COUNT + j, irq_desc + H3800_KPIO_IRQ_COUNT + j);
 
                /* GPIO2 */
                irq = H3800_ASIC2_GPIINTFLAG;
                if (0) printk("%s GPIO 0x%08X\n", __FUNCTION__, irq);
                for (j = 0; j < H3800_GPIO_IRQ_COUNT; j++)
                        if (irq & gpio_irq_mask[j])
-                               do_edge_IRQ(H3800_GPIO_IRQ_COUNT + j, irq_desc + H3800_GPIO_IRQ_COUNT + j);
+                               handle_edge_irq(H3800_GPIO_IRQ_COUNT + j, irq_desc + H3800_GPIO_IRQ_COUNT + j);
        }
 
        if (i >= MAX_ASIC_ISR_LOOPS)
index f4c6322ca33eec90c58aab15ee990f9712c30eed..5642aeca079e68eeb8654b6d95e2aea2c393d4d0 100644 (file)
@@ -110,7 +110,7 @@ static struct irq_chip sa1100_low_gpio_chip = {
  * and call the handler.
  */
 static void
-sa1100_high_gpio_handler(unsigned int irq, struct irqdesc *desc)
+sa1100_high_gpio_handler(unsigned int irq, struct irq_desc *desc)
 {
        unsigned int mask;
 
@@ -327,19 +327,19 @@ void __init sa1100_init_irq(void)
 
        for (irq = 0; irq <= 10; irq++) {
                set_irq_chip(irq, &sa1100_low_gpio_chip);
-               set_irq_handler(irq, do_edge_IRQ);
+               set_irq_handler(irq, handle_edge_irq);
                set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
        }
 
        for (irq = 12; irq <= 31; irq++) {
                set_irq_chip(irq, &sa1100_normal_chip);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                set_irq_flags(irq, IRQF_VALID);
        }
 
        for (irq = 32; irq <= 48; irq++) {
                set_irq_chip(irq, &sa1100_high_gpio_chip);
-               set_irq_handler(irq, do_edge_IRQ);
+               set_irq_handler(irq, handle_edge_irq);
                set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
        }
 
index 354d5e91da599f72a03750ac9b14c29a873cc573..075d4d1d63beb850d9e4a90cf0e72a213c38e480 100644 (file)
  * is rather unfortunate.
  */
 static void
-neponset_irq_handler(unsigned int irq, struct irqdesc *desc)
+neponset_irq_handler(unsigned int irq, struct irq_desc *desc)
 {
        unsigned int irr;
 
        while (1) {
-               struct irqdesc *d;
+               struct irq_desc *d;
 
                /*
                 * Acknowledge the parent IRQ.
@@ -168,9 +168,9 @@ static int neponset_probe(struct platform_device *dev)
         * Setup other Neponset IRQs.  SA1111 will be done by the
         * generic SA1111 code.
         */
-       set_irq_handler(IRQ_NEPONSET_SMC9196, do_simple_IRQ);
+       set_irq_handler(IRQ_NEPONSET_SMC9196, handle_simple_irq);
        set_irq_flags(IRQ_NEPONSET_SMC9196, IRQF_VALID | IRQF_PROBE);
-       set_irq_handler(IRQ_NEPONSET_USAR, do_simple_IRQ);
+       set_irq_handler(IRQ_NEPONSET_USAR, handle_simple_irq);
        set_irq_flags(IRQ_NEPONSET_USAR, IRQF_VALID | IRQF_PROBE);
 
        /*
index 4284bd6f7a1f583c2af51cc98be24f7e6f638e87..29c89f9eb2ceed1e345fb193d6bf0a2bd0f6f9a9 100644 (file)
@@ -118,6 +118,7 @@ static struct irqaction sa1100_timer_irq = {
 static void __init sa1100_timer_init(void)
 {
        struct timespec tv;
+       unsigned long flags;
 
        set_rtc = sa1100_set_rtc;
 
@@ -126,12 +127,12 @@ static void __init sa1100_timer_init(void)
        do_settimeofday(&tv);
 
        OIER = 0;               /* disable any timer interrupts */
-       OSCR = LATCH*2;         /* push OSCR out of the way */
-       OSMR0 = LATCH;          /* set initial match */
        OSSR = 0xf;             /* clear status on all timers */
        setup_irq(IRQ_OST0, &sa1100_timer_irq);
+       local_irq_save(flags);
        OIER = OIER_E0;         /* enable match on timer 0 to cause interrupts */
-       OSCR = 0;               /* initialize free-running timer */
+       OSMR0 = OSCR + LATCH;   /* set initial match */
+       local_irq_restore(flags);
 }
 
 #ifdef CONFIG_NO_IDLE_HZ
index 297ecf130650bae3916b6cd97e029af9d9c8bb88..00a6c14668673f4158e77c01690f8fa8af0d16c2 100644 (file)
@@ -82,7 +82,7 @@ void __init shark_init_irq(void)
 
        for (irq = 0; irq < NR_IRQS; irq++) {
                set_irq_chip(irq, &fb_chip);
-               set_irq_handler(irq, do_edge_IRQ);
+               set_irq_handler(irq, handle_edge_irq);
                set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
        }
 
index 3b8576111c16db0a8a9e425cacfa89e2fd5ac572..57196947559fb520ead8e371bac5e85cc74b688b 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/amba/bus.h>
 #include <linux/amba/clcd.h>
 
+#include <asm/cnt32_to_63.h>
 #include <asm/system.h>
 #include <asm/hardware.h>
 #include <asm/io.h>
@@ -77,7 +78,7 @@ static struct irq_chip sic_chip = {
 };
 
 static void
-sic_handle_irq(unsigned int irq, struct irqdesc *desc)
+sic_handle_irq(unsigned int irq, struct irq_desc *desc)
 {
        unsigned long status = readl(VA_SIC_BASE + SIC_IRQ_STATUS);
 
@@ -123,7 +124,7 @@ void __init versatile_init_irq(void)
        for (i = IRQ_SIC_START; i <= IRQ_SIC_END; i++) {
                if ((PIC_MASK & (1 << (i - IRQ_SIC_START))) == 0) {
                        set_irq_chip(i, &sic_chip);
-                       set_irq_handler(i, do_level_IRQ);
+                       set_irq_handler(i, handle_level_irq);
                        set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
                }
        }
@@ -228,14 +229,19 @@ void __init versatile_map_io(void)
 
 /*
  * This is the Versatile sched_clock implementation.  This has
- * a resolution of 41.7ns, and a maximum value of about 179s.
+ * a resolution of 41.7ns, and a maximum value of about 35583 days.
+ *
+ * The return value is guaranteed to be monotonic in that range as
+ * long as there is always less than 89 seconds between successive
+ * calls to this function.
  */
 unsigned long long sched_clock(void)
 {
-       unsigned long long v;
+       unsigned long long v = cnt32_to_63(readl(VERSATILE_REFCOUNTER));
 
-       v = (unsigned long long)readl(VERSATILE_REFCOUNTER) * 125;
-       do_div(v, 3);
+       /* the <<1 gets rid of the cnt_32_to_63 top bit saving on a bic insn */
+       v *= 125<<1;
+       do_div(v, 3<<1);
 
        return v;
 }
index 503725b166fc9c473649f737c65a42072f9fc0e7..be439bb9d450ca1695e6275ba1cfceb269996cb7 100644 (file)
@@ -81,22 +81,18 @@ static struct amba_device *amba_devs[] __initdata = {
        &mmc1_device,
 };
 
-static int __init versatile_pb_init(void)
+static void __init versatile_pb_init(void)
 {
        int i;
 
-       if (machine_is_versatile_pb()) {
-               for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
-                       struct amba_device *d = amba_devs[i];
-                       amba_device_register(d, &iomem_resource);
-               }
-       }
+       versatile_init();
 
-       return 0;
+       for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
+               struct amba_device *d = amba_devs[i];
+               amba_device_register(d, &iomem_resource);
+       }
 }
 
-arch_initcall(versatile_pb_init);
-
 MACHINE_START(VERSATILE_PB, "ARM-Versatile PB")
        /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
        .phys_io        = 0x101f1000,
@@ -105,5 +101,5 @@ MACHINE_START(VERSATILE_PB, "ARM-Versatile PB")
        .map_io         = versatile_map_io,
        .init_irq       = versatile_init_irq,
        .timer          = &versatile_timer,
-       .init_machine   = versatile_init,
+       .init_machine   = versatile_pb_init,
 MACHINE_END
index b09a19f87d682d084dcc08995ecfb18c085df4b9..aade2f72c9209f995b4f7e70461742610648bccf 100644 (file)
@@ -333,7 +333,7 @@ config CPU_XSCALE
 # XScale Core Version 3
 config CPU_XSC3
        bool
-       depends on ARCH_IXP23XX
+       depends on ARCH_IXP23XX || ARCH_IOP13XX
        default y
        select CPU_32v5
        select CPU_ABRT_EV5T
@@ -580,7 +580,7 @@ config CPU_CACHE_ROUND_ROBIN
 
 config CPU_BPREDICT_DISABLE
        bool "Disable branch prediction"
-       depends on CPU_ARM1020 || CPU_V6
+       depends on CPU_ARM1020 || CPU_V6 || CPU_XSC3
        help
          Say Y here to disable branch prediction.  If unsure, say N.
 
index 5e658a8744984688ee171e16b67a44aee65c1331..9fd6d2eafb40c0bf06e80c0643f7d5bb020f8173 100644 (file)
@@ -230,7 +230,7 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
         * If we're in an interrupt or have no user
         * context, we must not take the fault..
         */
-       if (in_interrupt() || !mm)
+       if (in_atomic() || !mm)
                goto no_context;
 
        /*
index bb2bc9ab6bd38fd06243542effd2017cc4326b8a..a44e3097063544315b14d43acc29a575385561cf 100644 (file)
@@ -1,4 +1,7 @@
 /* the upper-most page table pointer */
+
+#ifdef CONFIG_MMU
+
 extern pmd_t *top_pmd;
 
 #define TOP_PTE(x)     pte_offset_kernel(top_pmd, x)
@@ -13,6 +16,8 @@ static inline pmd_t *pmd_off_k(unsigned long virt)
        return pmd_off(pgd_offset_k(virt), virt);
 }
 
+#endif
+
 struct map_desc;
 struct meminfo;
 struct pglist_data;
index f866bf6b97d4f3dc810eeeaa140f9ecf2e10d965..b7f194af20b490b03c85805ad9731fda33c6745c 100644 (file)
@@ -265,7 +265,7 @@ static void __init build_mem_type_table(void)
        if (arch_is_coherent()) {
                if (cpu_is_xsc3()) {
                        mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
-                       mem_types[MT_MEMORY].prot_pte |= L_PTE_COHERENT;
+                       mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
                }
        }
 
@@ -619,6 +619,13 @@ void __init reserve_node_zero(pg_data_t *pgdat)
        if (machine_is_p720t())
                res_size = 0x00014000;
 
+       /* H1940 and RX3715 need to reserve this for suspend */
+
+       if (machine_is_h1940() || machine_is_rx3715()) {
+               reserve_bootmem_node(pgdat, 0x30003000, 0x1000);
+               reserve_bootmem_node(pgdat, 0x30081000, 0x1000);
+       }
+
 #ifdef CONFIG_SA1111
        /*
         * Because of the SA1111 DMA bug, we want to preserve our
index d0e66424a59720886d81908643ba1431afdd609e..05818fc0c705453c58a551fdd6485fcdd1abdd1d 100644 (file)
@@ -6,10 +6,12 @@
 #include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/pagemap.h>
+#include <linux/bootmem.h>
 
 #include <asm/cacheflush.h>
 #include <asm/io.h>
 #include <asm/page.h>
+#include <asm/mach/arch.h>
 
 #include "mm.h"
 
@@ -76,7 +78,7 @@ void __iomem *__ioremap(unsigned long phys_addr, size_t size,
 }
 EXPORT_SYMBOL(__ioremap);
 
-void __iounmap(void __iomem *addr)
+void __iounmap(volatile void __iomem *addr)
 {
 }
 EXPORT_SYMBOL(__iounmap);
index 1d8316f3cecfbe124fa6fe1ed6cdc4fa78b3206e..289b8e6f504dc656a75c8e1f2f2a3c82f631e626 100644 (file)
@@ -29,9 +29,9 @@
 #include <linux/init.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
+#include <asm/elf.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
-#include <asm/procinfo.h>
 #include <asm/ptrace.h>
 
 #include "proc-macros.S"
index 89b1d6d3d7c0fc572be129aa38361da0b2736669..bed9db6ba582a7190cdac76576a51aba64bd1469 100644 (file)
@@ -29,9 +29,9 @@
 #include <linux/init.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
+#include <asm/elf.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
-#include <asm/procinfo.h>
 #include <asm/ptrace.h>
 
 #include "proc-macros.S"
index a089528e6bce24e793db1a3b09f35ebdb21b131f..d2a7c1b9cab928255d2d74bb8be005dbd93296fa 100644 (file)
@@ -18,9 +18,9 @@
 #include <linux/init.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
+#include <asm/elf.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
-#include <asm/procinfo.h>
 #include <asm/ptrace.h>
 
 #include "proc-macros.S"
index d6d84d92c7c7208e832b6c6ea0673077603b9bd1..3247ce5c0177c461d09adcdf932a2a3eca4ef240 100644 (file)
@@ -18,9 +18,9 @@
 #include <linux/init.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
+#include <asm/elf.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
-#include <asm/procinfo.h>
 #include <asm/ptrace.h>
 
 #include "proc-macros.S"
index 0432e4806888aa51e1c39a843d63fa4f633a5d8b..ce4f9eef763c8dd2b65e31f758267164277c5d3a 100644 (file)
@@ -15,9 +15,9 @@
 #include <linux/init.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
+#include <asm/elf.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
-#include <asm/procinfo.h>
 #include <asm/ptrace.h>
 
 ENTRY(cpu_arm6_dcache_clean_area)
index c2f0705bfd49ed6f9f7f4eebdb251b1d7a3c34e5..c04c194da78503e11984c942130d50d4a0f0fc6b 100644 (file)
@@ -36,9 +36,9 @@
 #include <linux/init.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
+#include <asm/elf.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
-#include <asm/procinfo.h>
 #include <asm/ptrace.h>
 
 #include "proc-macros.S"
index 40713818a87b2701071ef866e3575c5099c1dd7c..7069f495cf9bfa663120b5ec79e2a011b981638e 100644 (file)
@@ -12,9 +12,9 @@
 #include <linux/init.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
+#include <asm/elf.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
-#include <asm/procinfo.h>
 #include <asm/ptrace.h>
 
        .text
index 22d7e3100ea6f38f797b20e58664b285d13ae499..d091c25718235f47e06ebeac9bda8426029ab777 100644 (file)
@@ -12,9 +12,9 @@
 #include <linux/init.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
+#include <asm/elf.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
-#include <asm/procinfo.h>
 #include <asm/ptrace.h>
 
        .text
index 4adb46b3a4e0d4f68b33c4c1f6979e4e59ae0d51..65cbb2851bffad40e3aaa8771e02c3ece13d96f0 100644 (file)
@@ -28,9 +28,9 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 #include <asm/assembler.h>
+#include <asm/elf.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
-#include <asm/procinfo.h>
 #include <asm/page.h>
 #include <asm/ptrace.h>
 #include "proc-macros.S"
index 571f082f0247e5c14b1201a695fdffe63ba8b7ba..52761b70d7355b1bbc072e426a7995491e65aff9 100644 (file)
@@ -29,9 +29,9 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 #include <asm/assembler.h>
+#include <asm/elf.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
-#include <asm/procinfo.h>
 #include <asm/page.h>
 #include <asm/ptrace.h>
 #include "proc-macros.S"
index 8d9a9f93b011cc914d407b1b5646289d9eb31483..5b74339d1588ee7073381501610aa7026733e336 100644 (file)
@@ -52,9 +52,9 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 #include <asm/assembler.h>
+#include <asm/elf.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
-#include <asm/procinfo.h>
 #include <asm/page.h>
 #include <asm/ptrace.h>
 #include "proc-macros.S"
index 44a7a652d62507232ec73f20cab6a0e23d0e61f0..8628ed29a955d9f168f6b785ab2960acb72a891c 100644 (file)
@@ -28,9 +28,9 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 #include <asm/assembler.h>
+#include <asm/elf.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
-#include <asm/procinfo.h>
 #include <asm/page.h>
 #include <asm/ptrace.h>
 #include "proc-macros.S"
index 2397f4b6e15149f31b9b317904b5f03dc3b41fe6..786c593778f0a0b91e5b5c8bb8f4ae1a1e3cdb95 100644 (file)
@@ -11,9 +11,9 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 #include <asm/assembler.h>
+#include <asm/elf.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
-#include <asm/procinfo.h>
 #include <asm/ptrace.h>
 
 /* ARM940T has a 4KB DCache comprising 256 lines of 4 words */
index e186175644213ab6b505343ea32c2f84ceb062f9..a60c1421d450ed9ebca2230762db9ec3df70d06a 100644 (file)
@@ -13,9 +13,9 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 #include <asm/assembler.h>
+#include <asm/elf.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
-#include <asm/procinfo.h>
 #include <asm/ptrace.h>
 
 /*
index 918ebf65d4f696e32bba0a5516950faa0839c211..4848eeac86b653416a24f6bf6fca478c0cd3f153 100644 (file)
@@ -12,9 +12,9 @@
 #include <linux/init.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
+#include <asm/elf.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
-#include <asm/procinfo.h>
 #include <asm/ptrace.h>
 
        .text
index c878064e9b887b271af7b75749d37f05ed77b646..cd7d865c9d19d29e278392d6d7a05a42855487a0 100644 (file)
@@ -17,7 +17,7 @@
 #include <linux/init.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
-#include <asm/procinfo.h>
+#include <asm/elf.h>
 #include <asm/hardware.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
index b23b66a6155aa314304dc1dcf659e7e9fbe4ac89..b776653cc31ca486033750b4d8a6cfb3eb89d119 100644 (file)
@@ -22,7 +22,7 @@
 #include <linux/init.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
-#include <asm/procinfo.h>
+#include <asm/elf.h>
 #include <asm/hardware.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
index 6f72549f8843b78043d082382a4599cbce597cde..b440c8a1d3458ed00d957b8b45bc9b776ed691bf 100644 (file)
@@ -13,8 +13,8 @@
 #include <linux/linkage.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
+#include <asm/elf.h>
 #include <asm/hardware/arm_scu.h>
-#include <asm/procinfo.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
 
index 4ace2d8090c7dd83bccd8787ef7fcc2cc67a6233..1ef564d0957f58634c4c229f15e8ad1d9645b92f 100644 (file)
@@ -27,7 +27,7 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 #include <asm/assembler.h>
-#include <asm/procinfo.h>
+#include <asm/elf.h>
 #include <asm/hardware.h>
 #include <asm/pgtable.h>
 #include <asm/pgtable-hwdef.h>
  */
 #define L2_CACHE_ENABLE        1
 
-/*
- * Enable the Branch Target Buffer (can cause crashes, see erratum #42.)
- */
-#define BTB_ENABLE     0
-
 /*
  * This macro is used to wait for a CP15 write and is needed
  * when we have to ensure that the last operation to the co-pro
@@ -371,8 +366,10 @@ ENTRY(cpu_xsc3_switch_mm)
 ENTRY(cpu_xsc3_set_pte)
        str     r1, [r0], #-2048                @ linux version
 
-       bic     r2, r1, #0xdf0                  @ Keep C, B, coherency bits
+       bic     r2, r1, #0xff0                  @ Keep C, B bits
        orr     r2, r2, #PTE_TYPE_EXT           @ extended page
+       tst     r1, #L_PTE_SHARED               @ Shared?
+       orrne   r2, r2, #0x200
 
        eor     r3, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
 
@@ -432,9 +429,7 @@ __xsc3_setup:
        mrc     p15, 0, r0, c1, c0, 0           @ get control register
        bic     r0, r0, r5                      @ .... .... .... ..A.
        orr     r0, r0, r6                      @ .... .... .... .C.M
-#if BTB_ENABLE
        orr     r0, r0, #0x00000800             @ ..VI Z..S .... ....
-#endif
 #if L2_CACHE_ENABLE
        orr     r0, r0, #0x04000000             @ L2 enable
 #endif
index 2749c1f88d7da07528232f9875ba97d57751c676..cc1004b3e5117cdcfa9a6d365406de93ebdb1722 100644 (file)
@@ -23,7 +23,7 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 #include <asm/assembler.h>
-#include <asm/procinfo.h>
+#include <asm/elf.h>
 #include <asm/pgtable.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/page.h>
@@ -491,12 +491,7 @@ __xscale_setup:
        mcr     p15, 0, ip, c7, c7, 0           @ invalidate I, D caches & BTB
        mcr     p15, 0, ip, c7, c10, 4          @ Drain Write (& Fill) Buffer
        mcr     p15, 0, ip, c8, c7, 0           @ invalidate I, D TLBs
-#ifdef CONFIG_IWMMXT
-       mov     r0, #0                          @ initially disallow access to CP0/CP1
-#else
-       mov     r0, #1                          @ Allow access to CP0
-#endif
-       orr     r0, r0, #1 << 6                 @ cp6 for IOP3xx and Bulverde
+       mov     r0, #1 << 6                     @ cp6 for IOP3xx and Bulverde
        orr     r0, r0, #1 << 13                @ Its undefined whether this
        mcr     p15, 0, r0, c15, c1, 0          @ affects USR or SVC modes
 
@@ -909,7 +904,7 @@ __pxa270_proc_info:
        b       __xscale_setup
        .long   cpu_arch_name
        .long   cpu_elf_name
-       .long   HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_IWMMXT
+       .long   HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
        .long   cpu_pxa270_name
        .long   xscale_processor_functions
        .long   v4wbi_tlb_fns
index 8162eed8b500e697938fbc78e90bbb99392cfd24..4f2fd55913379a10b080412408f9d8e2a2b132c4 100644 (file)
@@ -410,7 +410,7 @@ static inline void set_24xx_gpio_triggering(void __iomem *base, int gpio, int tr
                trigger & __IRQT_RISEDGE);
        MOD_REG_BIT(OMAP24XX_GPIO_FALLINGDETECT, gpio_bit,
                trigger & __IRQT_FALEDGE);
-       /* FIXME: Possibly do 'set_irq_handler(j, do_level_IRQ)' if only level
+       /* FIXME: Possibly do 'set_irq_handler(j, handle_level_irq)' if only level
         * triggering requested. */
 }
 
@@ -783,7 +783,7 @@ void omap_free_gpio(int gpio)
  * line's interrupt handler has been run, we may miss some nested
  * interrupts.
  */
-static void gpio_irq_handler(unsigned int irq, struct irqdesc *desc)
+static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
 {
        void __iomem *isr_reg = NULL;
        u32 isr;
@@ -853,7 +853,7 @@ static void gpio_irq_handler(unsigned int irq, struct irqdesc *desc)
 
                gpio_irq = bank->virtual_irq_start;
                for (; isr != 0; isr >>= 1, gpio_irq++) {
-                       struct irqdesc *d;
+                       struct irq_desc *d;
                        int irq_mask;
                        if (!(isr & 1))
                                continue;
@@ -1092,7 +1092,7 @@ static int __init _omap_gpio_init(void)
                                set_irq_chip(j, &mpuio_irq_chip);
                        else
                                set_irq_chip(j, &gpio_irq_chip);
-                       set_irq_handler(j, do_simple_IRQ);
+                       set_irq_handler(j, handle_simple_irq);
                        set_irq_flags(j, IRQF_VALID);
                }
                set_irq_chained_handler(bank->irq, gpio_irq_handler);
index 579c69ae9ff78ac47d3b2e01b2830f6da88d80c2..8bcb838e5444278b66827826862b6542a4e3d0c7 100644 (file)
@@ -12,7 +12,7 @@
 #
 #   http://www.arm.linux.org.uk/developer/machines/?action=new
 #
-# Last update: Mon Oct 16 21:13:36 2006
+# Last update: Thu Dec 7 17:19:20 2006
 #
 # machine_is_xxx       CONFIG_xxxx             MACH_TYPE_xxx           number
 #
@@ -79,7 +79,7 @@ psionw                        ARCH_PSIONW             PSIONW                  60
 aln                    SA1100_ALN              ALN                     61
 epxa                   ARCH_CAMELOT            CAMELOT                 62
 gds2200                        SA1100_GDS2200          GDS2200                 63
-psion_series7          SA1100_PSION_SERIES7    PSION_SERIES7           64
+netbook                        SA1100_PSION_SERIES7    PSION_SERIES7           64
 xfile                  SA1100_XFILE            XFILE                   65
 accelent_ep9312                ARCH_ACCELENT_EP9312    ACCELENT_EP9312         66
 ic200                  ARCH_IC200              IC200                   67
@@ -810,9 +810,9 @@ sb3010                      MACH_SB3010             SB3010                  795
 rm9200                 MACH_RM9200             RM9200                  796
 dma03                  MACH_DMA03              DMA03                   797
 road_s101              MACH_ROAD_S101          ROAD_S101               798
-iq_nextgen_a           MACH_IQ_NEXTGEN_A       IQ_NEXTGEN_A            799
+iq81340sc              MACH_IQ81340SC          IQ81340SC               799
 iq_nextgen_b           MACH_IQ_NEXTGEN_B       IQ_NEXTGEN_B            800
-iq_nextgen_c           MACH_IQ_NEXTGEN_C       IQ_NEXTGEN_C            801
+iq81340mc              MACH_IQ81340MC          IQ81340MC               801
 iq_nextgen_d           MACH_IQ_NEXTGEN_D       IQ_NEXTGEN_D            802
 iq_nextgen_e           MACH_IQ_NEXTGEN_E       IQ_NEXTGEN_E            803
 mallow_at91            MACH_MALLOW_AT91        MALLOW_AT91             804
@@ -1165,9 +1165,57 @@ pnx4010                  MACH_PNX4010            PNX4010                 1151
 oxnas                  MACH_OXNAS              OXNAS                   1152
 fiori                  MACH_FIORI              FIORI                   1153
 ml1200                 MACH_ML1200             ML1200                  1154
-cactus                 MACH_CACTUS             CACTUS                  1155
+pecos                  MACH_PECOS              PECOS                   1155
 nb2xxx                 MACH_NB2XXX             NB2XXX                  1156
 hw6900                 MACH_HW6900             HW6900                  1157
 cdcs_quoll             MACH_CDCS_QUOLL         CDCS_QUOLL              1158
 quicksilver            MACH_QUICKSILVER        QUICKSILVER             1159
 uplat926               MACH_UPLAT926           UPLAT926                1160
+dep2410_dep2410                MACH_DEP2410_THOMAS     DEP2410_THOMAS          1161
+dtk2410                        MACH_DTK2410            DTK2410                 1162
+chili                  MACH_CHILI              CHILI                   1163
+demeter                        MACH_DEMETER            DEMETER                 1164
+dionysus               MACH_DIONYSUS           DIONYSUS                1165
+as352x                 MACH_AS352X             AS352X                  1166
+service                        MACH_SERVICE            SERVICE                 1167
+cs_e9301               MACH_CS_E9301           CS_E9301                1168
+micro9m                        MACH_MICRO9M            MICRO9M                 1169
+ia_mospck              MACH_IA_MOSPCK          IA_MOSPCK               1170
+ql201b                 MACH_QL201B             QL201B                  1171
+bbm                    MACH_BBM                BBM                     1174
+exxx                   MACH_EXXX               EXXX                    1175
+wma11b                 MACH_WMA11B             WMA11B                  1176
+pelco_atlas            MACH_PELCO_ATLAS        PELCO_ATLAS             1177
+g500                   MACH_G500               G500                    1178
+bug                    MACH_BUG                BUG                     1179
+mx33ads                        MACH_MX33ADS            MX33ADS                 1180
+chub                   MACH_CHUB               CHUB                    1181
+gta01                  MACH_GTA01              GTA01                   1182
+w90n740                        MACH_W90N740            W90N740                 1183
+medallion_sa2410       MACH_MEDALLION_SA2410   MEDALLION_SA2410        1184
+ia_cpu_9200_2          MACH_IA_CPU_9200_2      IA_CPU_9200_2           1185
+dimmrm9200             MACH_DIMMRM9200         DIMMRM9200              1186
+pm9261                 MACH_PM9261             PM9261                  1187
+mx21                   MACH_MX21               MX21                    1188
+ml7304                 MACH_ML7304             ML7304                  1189
+ucp250                 MACH_UCP250             UCP250                  1190
+intboard               MACH_INTBOARD           INTBOARD                1191
+gulfstream             MACH_GULFSTREAM         GULFSTREAM              1192
+labquest               MACH_LABQUEST           LABQUEST                1193
+vcmx313                        MACH_VCMX313            VCMX313                 1194
+urg200                 MACH_URG200             URG200                  1195
+cpux255lcdnet          MACH_CPUX255LCDNET      CPUX255LCDNET           1196
+netdcu9                        MACH_NETDCU9            NETDCU9                 1197
+netdcu10               MACH_NETDCU10           NETDCU10                1198
+dspg_dga               MACH_DSPG_DGA           DSPG_DGA                1199
+dspg_dvw               MACH_DSPG_DVW           DSPG_DVW                1200
+solos                  MACH_SOLOS              SOLOS                   1201
+at91sam9263ek          MACH_AT91SAM9263EK      AT91SAM9263EK           1202
+osstbox                        MACH_OSSTBOX            OSSTBOX                 1203
+kbat9261               MACH_KBAT9261           KBAT9261                1204
+ct1100                 MACH_CT1100             CT1100                  1205
+akcppxa                        MACH_AKCPPXA            AKCPPXA                 1206
+zevio_1020             MACH_ZEVIO_1020         ZEVIO_1020              1207
+hitrack                        MACH_HITRACK            HITRACK                 1208
+syme1                  MACH_SYME1              SYME1                   1209
+syhl1                  MACH_SYHL1              SYHL1                   1210
index c14fe918bc4cf5e0cfb8aec5871c95be1c761cb3..74eba8b5a8ca41c5576b30c691b56344f0a416ce 100644 (file)
@@ -41,6 +41,14 @@ config RWSEM_GENERIC_SPINLOCK
 config RWSEM_XCHGADD_ALGORITHM
        bool
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 config GENERIC_HWEIGHT
        bool
        default y
index 047d0a408b9deb25c10a9db2d32c144353ccf193..43dd41be71fb80ac1ac7f0898924c77902b9bd5f 100644 (file)
@@ -620,12 +620,10 @@ ecard_probe(int slot, card_type_t type)
        struct ex_ecid cid;
        int i, rc = -ENOMEM;
 
-       ec = kmalloc(sizeof(ecard_t), GFP_KERNEL);
+       ec = kzalloc(sizeof(ecard_t), GFP_KERNEL);
        if (!ec)
                goto nomem;
 
-       memset(ec, 0, sizeof(ecard_t));
-
        ec->slot_no     = slot;
        ec->type        = type;
        ec->irq         = NO_IRQ;
index a1f6d8a9cc32919084d14b5cf9181dbceb013ca6..93c0cee0fb5e142e45c1344548943e48d88bca06 100644 (file)
@@ -215,7 +215,7 @@ int do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
         * If we're in an interrupt or have no user
         * context, we must not take the fault..
         */
-       if (in_interrupt() || !mm)
+       if (in_atomic() || !mm)
                goto no_context;
 
        down_read(&mm->mmap_sem);
index 34def6397c3c5c718227f7e17c7dae4877d9cb03..f2901581d4dacd9aba26982c85918cd674f1dbcc 100644 (file)
@@ -24,7 +24,7 @@
 
 #define MEMC_TABLE_SIZE (256*sizeof(unsigned long))
 
-kmem_cache_t *pte_cache, *pgd_cache;
+struct kmem_cache *pte_cache, *pgd_cache;
 int page_nr;
 
 /*
@@ -162,12 +162,12 @@ void __init create_memmap_holes(struct meminfo *mi)
 {
 }
 
-static void pte_cache_ctor(void *pte, kmem_cache_t *cache, unsigned long flags)
+static void pte_cache_ctor(void *pte, struct kmem_cache *cache, unsigned long flags)
 {
        memzero(pte, sizeof(pte_t) * PTRS_PER_PTE);
 }
 
-static void pgd_cache_ctor(void *pgd, kmem_cache_t *cache, unsigned long flags)
+static void pgd_cache_ctor(void *pgd, struct kmem_cache *cache, unsigned long flags)
 {
        memzero(pgd + MEMC_TABLE_SIZE, USER_PTRS_PER_PGD * sizeof(pgd_t));
 }
index 5f1694eea8426d45da17fd8b7c24f79b5915c234..bb059a4e1df94a757eac011ad007552a8649be69 100644 (file)
@@ -45,6 +45,14 @@ config GENERIC_TIME
 config RWSEM_XCHGADD_ALGORITHM
        bool
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 config GENERIC_BUST_SPINLOCK
        bool
 
index ca41fc1edbe1aa26711343a3fcae488899de7882..d0abbcaf1c1e3dac5a6d7eb34313ca0527003d04 100644 (file)
@@ -154,6 +154,7 @@ ss_probe:
        return 1;
 
 no_kprobe:
+       preempt_enable_no_resched();
        return ret;
 }
 
index 33096651c24f64f494b1c4355f8de60fb155af82..0ec14854a2000f272044706265cf0e400c120e77 100644 (file)
@@ -15,7 +15,7 @@
 #include <linux/errno.h>
 #include <linux/ptrace.h>
 #include <linux/unistd.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 
 #include <asm/uaccess.h>
 #include <asm/ucontext.h>
index 44ab8a7bdae2705b32f316be2dd7b9947487cd63..b68d669f823de0a39f1f8bedebc3f5bd13429264 100644 (file)
@@ -11,7 +11,7 @@
 #include <asm/addrspace.h>
 #include <asm/cacheflush.h>
 
-void dma_cache_sync(void *vaddr, size_t size, int direction)
+void dma_cache_sync(struct device *dev, void *vaddr, size_t size, int direction)
 {
        /*
         * No need to sync an uncached area
index 6a1238a29d6c4d98d46156a1863e4a342478d7db..3474309e049c857ac2192c50fe1429358aff0dfc 100644 (file)
@@ -16,6 +16,14 @@ config RWSEM_GENERIC_SPINLOCK
 config RWSEM_XCHGADD_ALGORITHM
        bool
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 config GENERIC_FIND_NEXT_BIT
        bool
        default y
index e067806b2208b67b63ad419bb25ea0dd967d9ed5..424eb0eb1cd599ecf5b4c86fefad108ae03f54f0 100644 (file)
@@ -504,7 +504,7 @@ static int sync_serial_release(struct inode *inode, struct file *file)
 
 static unsigned int sync_serial_poll(struct file *file, poll_table *wait)
 {
-       int dev = iminor(file->f_dentry->d_inode);
+       int dev = iminor(file->f_path.dentry->d_inode);
        unsigned int mask = 0;
        sync_port* port;
        DEBUGPOLL( static unsigned int prev_mask = 0; );
@@ -531,7 +531,7 @@ static int sync_serial_ioctl(struct inode *inode, struct file *file,
                  unsigned int cmd, unsigned long arg)
 {
        int return_val = 0;
-       int dev = iminor(file->f_dentry->d_inode);
+       int dev = iminor(file->f_path.dentry->d_inode);
        sync_port* port;
        reg_sser_rw_tr_cfg tr_cfg;
        reg_sser_rw_rec_cfg rec_cfg;
@@ -789,7 +789,7 @@ static int sync_serial_ioctl(struct inode *inode, struct file *file,
 static ssize_t sync_serial_write(struct file * file, const char * buf,
                                  size_t count, loff_t *ppos)
 {
-       int dev = iminor(file->f_dentry->d_inode);
+       int dev = iminor(file->f_path.dentry->d_inode);
        DECLARE_WAITQUEUE(wait, current);
        sync_port *port;
        unsigned long c, c1;
@@ -919,7 +919,7 @@ static ssize_t sync_serial_write(struct file * file, const char * buf,
 static ssize_t sync_serial_read(struct file * file, char * buf,
                                size_t count, loff_t *ppos)
 {
-       int dev = iminor(file->f_dentry->d_inode);
+       int dev = iminor(file->f_path.dentry->d_inode);
        int avail;
        sync_port *port;
        unsigned char* start;
index 934c51078ccee4bafca2b68b7752b1745a63ee03..c73e91f1299a773ec8964f512f169429e16b6175 100644 (file)
@@ -232,7 +232,7 @@ do_page_fault(unsigned long address, struct pt_regs *regs,
         * context, we must not take the fault..
         */
 
-       if (in_interrupt() || !mm)
+       if (in_atomic() || !mm)
                goto no_context;
 
        down_read(&mm->mmap_sem);
index cf1c446e003ac6cad36c4a354872d0b41b2a2925..7561d7b72e75408bb05f3998008c2cee2b1debcf 100644 (file)
@@ -41,6 +41,14 @@ config TIME_LOW_RES
        bool
        default y
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default y
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default y
+
 mainmenu "Fujitsu FR-V Kernel Configuration"
 
 source "init/Kconfig"
index eae874a970c62f6750b0c6d41a56ab76078f7ac0..14f64b054c7ebe726ee0388f5ee5fe068dc7669c 100644 (file)
@@ -10,9 +10,9 @@
  */
 
 #include <linux/futex.h>
+#include <linux/uaccess.h>
 #include <asm/futex.h>
 #include <asm/errno.h>
-#include <asm/uaccess.h>
 
 /*
  * the various futex operations; MMU fault checking is ignored under no-MMU
@@ -200,7 +200,7 @@ int futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
        if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
                return -EFAULT;
 
-       inc_preempt_count();
+       pagefault_disable();
 
        switch (op) {
        case FUTEX_OP_SET:
@@ -223,7 +223,7 @@ int futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
                break;
        }
 
-       dec_preempt_count();
+       pagefault_enable();
 
        if (!ret) {
                switch (cmp) {
index a8c61dac1cee29185ee234cb913a680789cbdc13..1a5eb6c301c9b0e833d389953d76650eb70390fe 100644 (file)
@@ -947,7 +947,7 @@ static void __init setup_linux_memory(void)
        if (LOADER_TYPE && INITRD_START) {
                if (INITRD_START + INITRD_SIZE <= (low_top_pfn << PAGE_SHIFT)) {
                        reserve_bootmem(INITRD_START, INITRD_SIZE);
-                       initrd_start = INITRD_START ? INITRD_START + PAGE_OFFSET : 0;
+                       initrd_start = INITRD_START + PAGE_OFFSET;
                        initrd_end = initrd_start + INITRD_SIZE;
                }
                else {
index b8a5882b862562332ee0833a0f75cf5aedc2f419..85baeae9666aeae35f0a1e66277500c99c42a697 100644 (file)
@@ -21,7 +21,7 @@
 #include <linux/ptrace.h>
 #include <linux/unistd.h>
 #include <linux/personality.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 #include <asm/ucontext.h>
 #include <asm/uaccess.h>
 #include <asm/cacheflush.h>
index f5a653033fe0da2966de0112ca4b8a1e1e651f20..9477ccce070eb67a808fc7b31de1638f8a40339b 100644 (file)
@@ -110,14 +110,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
 
 #if 0
        printk("[area] l=%lx (ENOMEM) f='%s'\n",
-              len, filp ? filp->f_dentry->d_name.name : "");
+              len, filp ? filp->f_path.dentry->d_name.name : "");
 #endif
        return -ENOMEM;
 
  success:
 #if 0
        printk("[area] l=%lx ad=%lx f='%s'\n",
-              len, addr, filp ? filp->f_dentry->d_name.name : "");
+              len, addr, filp ? filp->f_path.dentry->d_name.name : "");
 #endif
        return addr;
 } /* end arch_get_unmapped_area() */
index 8b3eb50c510544c57d9a0cbc4093575400ba52cf..3f12296c3688856cec94e3aecc02522e00b6f7e7 100644 (file)
@@ -78,7 +78,7 @@ asmlinkage void do_page_fault(int datammu, unsigned long esr0, unsigned long ear
         * If we're in an interrupt or have no user
         * context, we must not take the fault..
         */
-       if (in_interrupt() || !mm)
+       if (in_atomic() || !mm)
                goto no_context;
 
        down_read(&mm->mmap_sem);
index f76dd03ddd99a3505ba250b2b5d55c15b24c0372..19b13be114a2695a9876b21f897f44b837feee06 100644 (file)
@@ -18,7 +18,7 @@
 #include <asm/cacheflush.h>
 
 pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((aligned(PAGE_SIZE)));
-kmem_cache_t *pgd_cache;
+struct kmem_cache *pgd_cache;
 
 pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
 {
@@ -100,7 +100,7 @@ static inline void pgd_list_del(pgd_t *pgd)
                set_page_private(next, (unsigned long) pprev);
 }
 
-void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused)
+void pgd_ctor(void *pgd, struct kmem_cache *cache, unsigned long unused)
 {
        unsigned long flags;
 
@@ -120,7 +120,7 @@ void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused)
 }
 
 /* never called when PTRS_PER_PMD > 1 */
-void pgd_dtor(void *pgd, kmem_cache_t *cache, unsigned long unused)
+void pgd_dtor(void *pgd, struct kmem_cache *cache, unsigned long unused)
 {
        unsigned long flags; /* can be called from interrupt context */
 
index cabf0bfffc534a06b1e9850d8d814cd98fa988a4..34a84bc4baf59ae515c1a0b0c899deee21604ef4 100644 (file)
@@ -29,6 +29,14 @@ config RWSEM_XCHGADD_ALGORITHM
        bool
        default n
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 config GENERIC_FIND_NEXT_BIT
        bool
        default y
index 1077b71d52264c4f653d41f0889f6a4e22a0ffb6..6adf8f41d2a1f153fdf7ba9b1fc9598cb0674329 100644 (file)
@@ -116,7 +116,7 @@ void __init setup_arch(char **cmdline_p)
 #endif
 #else
        if ((memory_end < CONFIG_BLKDEV_RESERVE_ADDRESS) && 
-           (memory_end > CONFIG_BLKDEV_RESERVE_ADDRESS)
+           (memory_end > CONFIG_BLKDEV_RESERVE_ADDRESS))
            /* overlap userarea */
            memory_end = CONFIG_BLKDEV_RESERVE_ADDRESS; 
 #endif
index 7787f70a05bbaeee9e15188fc21f5cfe2d5f14bb..02955604d7606f76eabf4ee6bd3b0478aad1c10c 100644 (file)
@@ -38,7 +38,7 @@
 #include <linux/personality.h>
 #include <linux/tty.h>
 #include <linux/binfmts.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 
 #include <asm/setup.h>
 #include <asm/uaccess.h>
index 756325dd480e40ba5cfe5056d23e2675d04ed6da..f05288be8878fb86efcf4bcae6b95fdafe69073d 100644 (file)
@@ -70,6 +70,7 @@ SECTIONS
 #endif
         .text :
        {
+       _text = .;
 #if defined(CONFIG_ROMKERNEL)
        *(.int_redirect)
 #endif
index 8ff1c6fb5aa135b678a3aa83047c1e57422ae6f8..c2362c7ba74926580b9614eb19a69252ac504a82 100644 (file)
@@ -49,6 +49,11 @@ config GENERIC_IOMAP
        bool
        default y
 
+config GENERIC_BUG
+       bool
+       default y
+       depends on BUG
+
 config GENERIC_HWEIGHT
        bool
        default y
@@ -182,6 +187,17 @@ config X86_ES7000
 
 endchoice
 
+config PARAVIRT
+       bool "Paravirtualization support (EXPERIMENTAL)"
+       depends on EXPERIMENTAL
+       help
+         Paravirtualization is a way of running multiple instances of
+         Linux on the same machine, under a hypervisor.  This option
+         changes the kernel so it can modify itself when it is run
+         under a hypervisor, improving performance significantly.
+         However, when run without a hypervisor the kernel is
+         theoretically slower.  If in doubt, say N.
+
 config ACPI_SRAT
        bool
        default y
@@ -443,7 +459,8 @@ source "drivers/firmware/Kconfig"
 
 choice
        prompt "High Memory Support"
-       default NOHIGHMEM
+       default HIGHMEM4G if !X86_NUMAQ
+       default HIGHMEM64G if X86_NUMAQ
 
 config NOHIGHMEM
        bool "off"
@@ -710,20 +727,6 @@ config BOOT_IOREMAP
        depends on (((X86_SUMMIT || X86_GENERICARCH) && NUMA) || (X86 && EFI))
        default y
 
-config REGPARM
-       bool "Use register arguments"
-       default y
-       help
-       Compile the kernel with -mregparm=3. This instructs gcc to use
-       a more efficient function call ABI which passes the first three
-       arguments of a function call via registers, which results in denser
-       and faster code.
-
-       If this option is disabled, then the default ABI of passing
-       arguments via the stack is used.
-
-       If unsure, say Y.
-
 config SECCOMP
        bool "Enable seccomp to safely compute untrusted bytecode"
        depends on PROC_FS
@@ -773,23 +776,39 @@ config CRASH_DUMP
           PHYSICAL_START.
          For more details see Documentation/kdump/kdump.txt
 
-config PHYSICAL_START
-       hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP)
+config RELOCATABLE
+       bool "Build a relocatable kernel(EXPERIMENTAL)"
+       depends on EXPERIMENTAL
+       help
+         This build a kernel image that retains relocation information
+          so it can be loaded someplace besides the default 1MB.
+         The relocations tend to the kernel binary about 10% larger,
+          but are discarded at runtime.
+
+         One use is for the kexec on panic case where the recovery kernel
+          must live at a different physical address than the primary
+          kernel.
 
-       default "0x1000000" if CRASH_DUMP
+config PHYSICAL_ALIGN
+       hex "Alignment value to which kernel should be aligned"
        default "0x100000"
+       range 0x2000 0x400000
        help
-         This gives the physical address where the kernel is loaded. Normally
-         for regular kernels this value is 0x100000 (1MB). But in the case
-         of kexec on panic the fail safe kernel needs to run at a different
-         address than the panic-ed kernel. This option is used to set the load
-         address for kernels used to capture crash dump on being kexec'ed
-         after panic. The default value for crash dump kernels is
-         0x1000000 (16MB). This can also be set based on the "X" value as
-         specified in the "crashkernel=YM@XM" command line boot parameter
-         passed to the panic-ed kernel. Typically this parameter is set as
-         crashkernel=64M@16M. Please take a look at
-         Documentation/kdump/kdump.txt for more details about crash dumps.
+         This value puts the alignment restrictions on physical address
+         where kernel is loaded and run from. Kernel is compiled for an
+         address which meets above alignment restriction.
+
+         If bootloader loads the kernel at a non-aligned address and
+         CONFIG_RELOCATABLE is set, kernel will move itself to nearest
+         address aligned to above value and run from there.
+
+         If bootloader loads the kernel at a non-aligned address and
+         CONFIG_RELOCATABLE is not set, kernel will ignore the run time
+         load address and decompress itself to the address it has been
+         compiled for and run from there. The address for which kernel is
+         compiled already meets above alignment restrictions. Hence the
+         end result is that kernel runs from a physical address meeting
+         above alignment restrictions.
 
          Don't change this unless you know what you are doing.
 
index fc4f2abccf06fdfd426b20b8195f1ae25d873c53..2aecfba4ac4f8fe702a2c0fc279877f10ee792f8 100644 (file)
@@ -103,8 +103,15 @@ config MPENTIUMM
          Select this for Intel Pentium M (not Pentium-4 M)
          notebook chips.
 
+config MCORE2
+       bool "Core 2/newer Xeon"
+       help
+         Select this for Intel Core 2 and newer Core 2 Xeons (Xeon 51xx and 53xx)
+         CPUs. You can distingush newer from older Xeons by the CPU family
+         in /proc/cpuinfo. Newer ones have 6.
+
 config MPENTIUM4
-       bool "Pentium-4/Celeron(P4-based)/Pentium-4 M/Xeon"
+       bool "Pentium-4/Celeron(P4-based)/Pentium-4 M/older Xeon"
        help
          Select this for Intel Pentium 4 chips.  This includes the
          Pentium 4, P4-based Celeron and Xeon, and Pentium-4 M
@@ -229,7 +236,7 @@ config X86_L1_CACHE_SHIFT
        default "7" if MPENTIUM4 || X86_GENERIC
        default "4" if X86_ELAN || M486 || M386 || MGEODEGX1
        default "5" if MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX
-       default "6" if MK7 || MK8 || MPENTIUMM
+       default "6" if MK7 || MK8 || MPENTIUMM || MCORE2
 
 config RWSEM_GENERIC_SPINLOCK
        bool
@@ -241,6 +248,14 @@ config RWSEM_XCHGADD_ALGORITHM
        depends on !M386
        default y
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 config GENERIC_CALIBRATE_DELAY
        bool
        default y
@@ -287,17 +302,17 @@ config X86_ALIGNMENT_16
 
 config X86_GOOD_APIC
        bool
-       depends on MK7 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || MK8 || MEFFICEON
+       depends on MK7 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || MK8 || MEFFICEON || MCORE2
        default y
 
 config X86_INTEL_USERCOPY
        bool
-       depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7 || MEFFICEON
+       depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7 || MEFFICEON || MCORE2
        default y
 
 config X86_USE_PPRO_CHECKSUM
        bool
-       depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MEFFICEON || MGEODE_LX
+       depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MEFFICEON || MGEODE_LX || MCORE2
        default y
 
 config X86_USE_3DNOW
@@ -312,5 +327,5 @@ config X86_OOSTORE
 
 config X86_TSC
        bool
-       depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MGEODEGX1 || MGEODE_LX) && !X86_NUMAQ
+       depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MGEODEGX1 || MGEODE_LX || MCORE2) && !X86_NUMAQ
        default y
index b31c0802e1ccf53f1e5a677e802c5e34166ebc54..f68cc6f215f8b1c9bff53c0f6668d4b792f3b30a 100644 (file)
@@ -85,4 +85,14 @@ config DOUBLEFAULT
           option saves about 4k and might cause you much additional grey
           hair.
 
+config DEBUG_PARAVIRT
+       bool "Enable some paravirtualization debugging"
+       default y
+       depends on PARAVIRT && DEBUG_KERNEL
+       help
+         Currently deliberately clobbers regs which are allowed to be
+         clobbered in inlined paravirt hooks, even in native mode.
+         If turning this off solves a problem, then DISABLE_INTERRUPTS() or
+         ENABLE_INTERRUPTS() is lying about what registers can be clobbered.
+
 endmenu
index 0677908dfa0600dd3f5cf9e315d4ad62154aca3f..f7ac1aea1d8a05e635828e1b8356da975123d3c3 100644 (file)
@@ -26,10 +26,12 @@ endif
 
 LDFLAGS                := -m elf_i386
 OBJCOPYFLAGS   := -O binary -R .note -R .comment -S
-LDFLAGS_vmlinux :=
+ifdef CONFIG_RELOCATABLE
+LDFLAGS_vmlinux := --emit-relocs
+endif
 CHECKFLAGS     += -D__i386__
 
-CFLAGS += -pipe -msoft-float
+CFLAGS += -pipe -msoft-float -mregparm=3
 
 # prevent gcc from keeping the stack 16 byte aligned
 CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2)
@@ -37,8 +39,6 @@ CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2)
 # CPU-specific tuning. Anything which can be shared with UML should go here.
 include $(srctree)/arch/i386/Makefile.cpu
 
-cflags-$(CONFIG_REGPARM) += -mregparm=3
-
 # temporary until string.h is fixed
 cflags-y += -ffreestanding
 
index a11befba26d5b78face98824b3aff15f4fcafc87..a32c031c90d7dacd552c53633992155674c9c50e 100644 (file)
@@ -32,6 +32,7 @@ cflags-$(CONFIG_MWINCHIP2)    += $(call cc-option,-march=winchip2,-march=i586)
 cflags-$(CONFIG_MWINCHIP3D)    += $(call cc-option,-march=winchip2,-march=i586)
 cflags-$(CONFIG_MCYRIXIII)     += $(call cc-option,-march=c3,-march=i486) $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0
 cflags-$(CONFIG_MVIAC3_2)      += $(call cc-option,-march=c3-2,-march=i686)
+cflags-$(CONFIG_MCORE2)                += -march=i686 $(call cc-option,-mtune=core2,$(call cc-option,-mtune=generic,-mtune=i686))
 
 # AMD Elan support
 cflags-$(CONFIG_X86_ELAN)      += -march=i486
index 258ea95224f63994df2534cea86ee8859575e42a..a661217f33ec4eeba811cb9d987f626f5f7c3838 100644 (file)
@@ -4,22 +4,42 @@
 # create a compressed vmlinux image from the original vmlinux
 #
 
-targets                := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o
+targets                := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o \
+                       vmlinux.bin.all vmlinux.relocs
 EXTRA_AFLAGS   := -traditional
 
-LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup_32
+LDFLAGS_vmlinux := -T
+CFLAGS_misc.o += -fPIC
+hostprogs-y    := relocs
 
-$(obj)/vmlinux: $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE
+$(obj)/vmlinux: $(src)/vmlinux.lds $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE
        $(call if_changed,ld)
        @:
 
 $(obj)/vmlinux.bin: vmlinux FORCE
        $(call if_changed,objcopy)
 
+quiet_cmd_relocs = RELOCS  $@
+      cmd_relocs = $(obj)/relocs $< > $@;$(obj)/relocs --abs-relocs $<
+$(obj)/vmlinux.relocs: vmlinux $(obj)/relocs FORCE
+       $(call if_changed,relocs)
+
+vmlinux.bin.all-y := $(obj)/vmlinux.bin
+vmlinux.bin.all-$(CONFIG_RELOCATABLE) += $(obj)/vmlinux.relocs
+quiet_cmd_relocbin = BUILD   $@
+      cmd_relocbin = cat $(filter-out FORCE,$^) > $@
+$(obj)/vmlinux.bin.all: $(vmlinux.bin.all-y) FORCE
+       $(call if_changed,relocbin)
+
+ifdef CONFIG_RELOCATABLE
+$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin.all FORCE
+       $(call if_changed,gzip)
+else
 $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
        $(call if_changed,gzip)
+endif
 
 LDFLAGS_piggy.o := -r --format binary --oformat elf32-i386 -T
 
-$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
+$(obj)/piggy.o: $(src)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
        $(call if_changed,ld)
index b5893e4ecd376b54a3044c09e035ff82bf5e923c..f395a4bb38bbe63740e0fe35a77decafe474dff4 100644 (file)
 #include <linux/linkage.h>
 #include <asm/segment.h>
 #include <asm/page.h>
+#include <asm/boot.h>
 
+.section ".text.head"
        .globl startup_32
-       
+
 startup_32:
        cld
        cli
@@ -37,93 +39,142 @@ startup_32:
        movl %eax,%es
        movl %eax,%fs
        movl %eax,%gs
+       movl %eax,%ss
 
-       lss stack_start,%esp
-       xorl %eax,%eax
-1:     incl %eax               # check that A20 really IS enabled
-       movl %eax,0x000000      # loop forever if it isn't
-       cmpl %eax,0x100000
-       je 1b
+/* Calculate the delta between where we were compiled to run
+ * at and where we were actually loaded at.  This can only be done
+ * with a short local call on x86.  Nothing  else will tell us what
+ * address we are running at.  The reserved chunk of the real-mode
+ * data at 0x34-0x3f are used as the stack for this calculation.
+ * Only 4 bytes are needed.
+ */
+       leal 0x40(%esi), %esp
+       call 1f
+1:     popl %ebp
+       subl $1b, %ebp
+
+/* %ebp contains the address we are loaded at by the boot loader and %ebx
+ * contains the address where we should move the kernel image temporarily
+ * for safe in-place decompression.
+ */
+
+#ifdef CONFIG_RELOCATABLE
+       movl    %ebp, %ebx
+       addl    $(CONFIG_PHYSICAL_ALIGN - 1), %ebx
+       andl    $(~(CONFIG_PHYSICAL_ALIGN - 1)), %ebx
+#else
+       movl $LOAD_PHYSICAL_ADDR, %ebx
+#endif
+
+       /* Replace the compressed data size with the uncompressed size */
+       subl input_len(%ebp), %ebx
+       movl output_len(%ebp), %eax
+       addl %eax, %ebx
+       /* Add 8 bytes for every 32K input block */
+       shrl $12, %eax
+       addl %eax, %ebx
+       /* Add 32K + 18 bytes of extra slack */
+       addl $(32768 + 18), %ebx
+       /* Align on a 4K boundary */
+       addl $4095, %ebx
+       andl $~4095, %ebx
+
+/* Copy the compressed kernel to the end of our buffer
+ * where decompression in place becomes safe.
+ */
+       pushl %esi
+       leal _end(%ebp), %esi
+       leal _end(%ebx), %edi
+       movl $(_end - startup_32), %ecx
+       std
+       rep
+       movsb
+       cld
+       popl %esi
+
+/* Compute the kernel start address.
+ */
+#ifdef CONFIG_RELOCATABLE
+       addl    $(CONFIG_PHYSICAL_ALIGN - 1), %ebp
+       andl    $(~(CONFIG_PHYSICAL_ALIGN - 1)), %ebp
+#else
+       movl    $LOAD_PHYSICAL_ADDR, %ebp
+#endif
 
 /*
- * Initialize eflags.  Some BIOS's leave bits like NT set.  This would
- * confuse the debugger if this code is traced.
- * XXX - best to initialize before switching to protected mode.
+ * Jump to the relocated address.
  */
-       pushl $0
-       popfl
+       leal relocated(%ebx), %eax
+       jmp *%eax
+.section ".text"
+relocated:
+
 /*
  * Clear BSS
  */
        xorl %eax,%eax
-       movl $_edata,%edi
-       movl $_end,%ecx
+       leal _edata(%ebx),%edi
+       leal _end(%ebx), %ecx
        subl %edi,%ecx
        cld
        rep
        stosb
+
+/*
+ * Setup the stack for the decompressor
+ */
+       leal stack_end(%ebx), %esp
+
 /*
  * Do the decompression, and jump to the new kernel..
  */
-       subl $16,%esp   # place for structure on the stack
-       movl %esp,%eax
+       movl output_len(%ebx), %eax
+       pushl %eax
+       pushl %ebp      # output address
+       movl input_len(%ebx), %eax
+       pushl %eax      # input_len
+       leal input_data(%ebx), %eax
+       pushl %eax      # input_data
+       leal _end(%ebx), %eax
+       pushl %eax      # end of the image as third argument
        pushl %esi      # real mode pointer as second arg
-       pushl %eax      # address of structure as first arg
        call decompress_kernel
-       orl  %eax,%eax 
-       jnz  3f
-       popl %esi       # discard address
-       popl %esi       # real mode pointer
-       xorl %ebx,%ebx
-       ljmp $(__BOOT_CS), $__PHYSICAL_START
+       addl $20, %esp
+       popl %ecx
 
+#if CONFIG_RELOCATABLE
+/* Find the address of the relocations.
+ */
+       movl %ebp, %edi
+       addl %ecx, %edi
+
+/* Calculate the delta between where vmlinux was compiled to run
+ * and where it was actually loaded.
+ */
+       movl %ebp, %ebx
+       subl $LOAD_PHYSICAL_ADDR, %ebx
+       jz   2f         /* Nothing to be done if loaded at compiled addr. */
 /*
- * We come here, if we were loaded high.
- * We need to move the move-in-place routine down to 0x1000
- * and then start it with the buffer addresses in registers,
- * which we got from the stack.
+ * Process relocations.
  */
-3:
-       movl $move_routine_start,%esi
-       movl $0x1000,%edi
-       movl $move_routine_end,%ecx
-       subl %esi,%ecx
-       addl $3,%ecx
-       shrl $2,%ecx
-       cld
-       rep
-       movsl
-
-       popl %esi       # discard the address
-       popl %ebx       # real mode pointer
-       popl %esi       # low_buffer_start
-       popl %ecx       # lcount
-       popl %edx       # high_buffer_start
-       popl %eax       # hcount
-       movl $__PHYSICAL_START,%edi
-       cli             # make sure we don't get interrupted
-       ljmp $(__BOOT_CS), $0x1000 # and jump to the move routine
+
+1:     subl $4, %edi
+       movl 0(%edi), %ecx
+       testl %ecx, %ecx
+       jz 2f
+       addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
+       jmp 1b
+2:
+#endif
 
 /*
- * Routine (template) for moving the decompressed kernel in place,
- * if we were high loaded. This _must_ PIC-code !
+ * Jump to the decompressed kernel.
  */
-move_routine_start:
-       movl %ecx,%ebp
-       shrl $2,%ecx
-       rep
-       movsl
-       movl %ebp,%ecx
-       andl $3,%ecx
-       rep
-       movsb
-       movl %edx,%esi
-       movl %eax,%ecx  # NOTE: rep movsb won't move if %ecx == 0
-       addl $3,%ecx
-       shrl $2,%ecx
-       rep
-       movsl
-       movl %ebx,%esi  # Restore setup pointer
        xorl %ebx,%ebx
-       ljmp $(__BOOT_CS), $__PHYSICAL_START
-move_routine_end:
+       jmp *%ebp
+
+.bss
+.balign 4
+stack:
+       .fill 4096, 1, 0
+stack_end:
index b2ccd543410d51314a38f75048d71306d005a969..1ce7017fd62706ccb02e1d5b34c683bd6537677c 100644 (file)
@@ -9,11 +9,94 @@
  * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
  */
 
+#undef CONFIG_PARAVIRT
 #include <linux/linkage.h>
 #include <linux/vmalloc.h>
 #include <linux/screen_info.h>
 #include <asm/io.h>
 #include <asm/page.h>
+#include <asm/boot.h>
+
+/* WARNING!!
+ * This code is compiled with -fPIC and it is relocated dynamically
+ * at run time, but no relocation processing is performed.
+ * This means that it is not safe to place pointers in static structures.
+ */
+
+/*
+ * Getting to provable safe in place decompression is hard.
+ * Worst case behaviours need to be analized.
+ * Background information:
+ *
+ * The file layout is:
+ *    magic[2]
+ *    method[1]
+ *    flags[1]
+ *    timestamp[4]
+ *    extraflags[1]
+ *    os[1]
+ *    compressed data blocks[N]
+ *    crc[4] orig_len[4]
+ *
+ * resulting in 18 bytes of non compressed data overhead.
+ *
+ * Files divided into blocks
+ * 1 bit (last block flag)
+ * 2 bits (block type)
+ *
+ * 1 block occurs every 32K -1 bytes or when there 50% compression has been achieved.
+ * The smallest block type encoding is always used.
+ *
+ * stored:
+ *    32 bits length in bytes.
+ *
+ * fixed:
+ *    magic fixed tree.
+ *    symbols.
+ *
+ * dynamic:
+ *    dynamic tree encoding.
+ *    symbols.
+ *
+ *
+ * The buffer for decompression in place is the length of the
+ * uncompressed data, plus a small amount extra to keep the algorithm safe.
+ * The compressed data is placed at the end of the buffer.  The output
+ * pointer is placed at the start of the buffer and the input pointer
+ * is placed where the compressed data starts.  Problems will occur
+ * when the output pointer overruns the input pointer.
+ *
+ * The output pointer can only overrun the input pointer if the input
+ * pointer is moving faster than the output pointer.  A condition only
+ * triggered by data whose compressed form is larger than the uncompressed
+ * form.
+ *
+ * The worst case at the block level is a growth of the compressed data
+ * of 5 bytes per 32767 bytes.
+ *
+ * The worst case internal to a compressed block is very hard to figure.
+ * The worst case can at least be boundined by having one bit that represents
+ * 32764 bytes and then all of the rest of the bytes representing the very
+ * very last byte.
+ *
+ * All of which is enough to compute an amount of extra data that is required
+ * to be safe.  To avoid problems at the block level allocating 5 extra bytes
+ * per 32767 bytes of data is sufficient.  To avoind problems internal to a block
+ * adding an extra 32767 bytes (the worst case uncompressed block size) is
+ * sufficient, to ensure that in the worst case the decompressed data for
+ * block will stop the byte before the compressed data for a block begins.
+ * To avoid problems with the compressed data's meta information an extra 18
+ * bytes are needed.  Leading to the formula:
+ *
+ * extra_bytes = (uncompressed_size >> 12) + 32768 + 18 + decompressor_size.
+ *
+ * Adding 8 bytes per 32K is a bit excessive but much easier to calculate.
+ * Adding 32768 instead of 32767 just makes for round numbers.
+ * Adding the decompressor_size is necessary as it musht live after all
+ * of the data as well.  Last I measured the decompressor is about 14K.
+ * 10K of actuall data and 4K of bss.
+ *
+ */
 
 /*
  * gzip declarations
@@ -30,15 +113,20 @@ typedef unsigned char  uch;
 typedef unsigned short ush;
 typedef unsigned long  ulg;
 
-#define WSIZE 0x8000           /* Window size must be at least 32k, */
-                               /* and a power of two */
+#define WSIZE 0x80000000       /* Window size must be at least 32k,
+                                * and a power of two
+                                * We don't actually have a window just
+                                * a huge output buffer so I report
+                                * a 2G windows size, as that should
+                                * always be larger than our output buffer.
+                                */
 
-static uch *inbuf;          /* input buffer */
-static uch window[WSIZE];    /* Sliding window buffer */
+static uch *inbuf;     /* input buffer */
+static uch *window;    /* Sliding window buffer, (and final output buffer) */
 
-static unsigned insize = 0;  /* valid bytes in inbuf */
-static unsigned inptr = 0;   /* index of next byte to be processed in inbuf */
-static unsigned outcnt = 0;  /* bytes in output buffer */
+static unsigned insize;  /* valid bytes in inbuf */
+static unsigned inptr;   /* index of next byte to be processed in inbuf */
+static unsigned outcnt;  /* bytes in output buffer */
 
 /* gzip flag byte */
 #define ASCII_FLAG   0x01 /* bit 0 set: file probably ASCII text */
@@ -89,8 +177,6 @@ extern unsigned char input_data[];
 extern int input_len;
 
 static long bytes_out = 0;
-static uch *output_data;
-static unsigned long output_ptr = 0;
 
 static void *malloc(int size);
 static void free(void *where);
@@ -100,24 +186,17 @@ static void *memcpy(void *dest, const void *src, unsigned n);
 
 static void putstr(const char *);
 
-extern int end;
-static long free_mem_ptr = (long)&end;
-static long free_mem_end_ptr;
+static unsigned long free_mem_ptr;
+static unsigned long free_mem_end_ptr;
 
-#define INPLACE_MOVE_ROUTINE  0x1000
-#define LOW_BUFFER_START      0x2000
-#define LOW_BUFFER_MAX       0x90000
 #define HEAP_SIZE             0x3000
-static unsigned int low_buffer_end, low_buffer_size;
-static int high_loaded =0;
-static uch *high_buffer_start /* = (uch *)(((ulg)&end) + HEAP_SIZE)*/;
 
 static char *vidmem = (char *)0xb8000;
 static int vidport;
 static int lines, cols;
 
 #ifdef CONFIG_X86_NUMAQ
-static void * xquad_portio = NULL;
+void *xquad_portio;
 #endif
 
 #include "../../../../lib/inflate.c"
@@ -151,7 +230,7 @@ static void gzip_mark(void **ptr)
 
 static void gzip_release(void **ptr)
 {
-       free_mem_ptr = (long) *ptr;
+       free_mem_ptr = (unsigned long) *ptr;
 }
  
 static void scroll(void)
@@ -179,7 +258,7 @@ static void putstr(const char *s)
                                y--;
                        }
                } else {
-                       vidmem [ ( x + cols * y ) * 2 ] = c; 
+                       vidmem [ ( x + cols * y ) * 2 ] = c;
                        if ( ++x >= cols ) {
                                x = 0;
                                if ( ++y >= lines ) {
@@ -224,58 +303,31 @@ static void* memcpy(void* dest, const void* src, unsigned n)
  */
 static int fill_inbuf(void)
 {
-       if (insize != 0) {
-               error("ran out of input data");
-       }
-
-       inbuf = input_data;
-       insize = input_len;
-       inptr = 1;
-       return inbuf[0];
+       error("ran out of input data");
+       return 0;
 }
 
 /* ===========================================================================
  * Write the output window window[0..outcnt-1] and update crc and bytes_out.
  * (Used for the decompressed data only.)
  */
-static void flush_window_low(void)
-{
-    ulg c = crc;         /* temporary variable */
-    unsigned n;
-    uch *in, *out, ch;
-    
-    in = window;
-    out = &output_data[output_ptr]; 
-    for (n = 0; n < outcnt; n++) {
-           ch = *out++ = *in++;
-           c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
-    }
-    crc = c;
-    bytes_out += (ulg)outcnt;
-    output_ptr += (ulg)outcnt;
-    outcnt = 0;
-}
-
-static void flush_window_high(void)
-{
-    ulg c = crc;         /* temporary variable */
-    unsigned n;
-    uch *in,  ch;
-    in = window;
-    for (n = 0; n < outcnt; n++) {
-       ch = *output_data++ = *in++;
-       if ((ulg)output_data == low_buffer_end) output_data=high_buffer_start;
-       c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
-    }
-    crc = c;
-    bytes_out += (ulg)outcnt;
-    outcnt = 0;
-}
-
 static void flush_window(void)
 {
-       if (high_loaded) flush_window_high();
-       else flush_window_low();
+       /* With my window equal to my output buffer
+        * I only need to compute the crc here.
+        */
+       ulg c = crc;         /* temporary variable */
+       unsigned n;
+       uch *in, ch;
+
+       in = window;
+       for (n = 0; n < outcnt; n++) {
+               ch = *in++;
+               c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
+       }
+       crc = c;
+       bytes_out += (ulg)outcnt;
+       outcnt = 0;
 }
 
 static void error(char *x)
@@ -287,66 +339,8 @@ static void error(char *x)
        while(1);       /* Halt */
 }
 
-#define STACK_SIZE (4096)
-
-long user_stack [STACK_SIZE];
-
-struct {
-       long * a;
-       short b;
-       } stack_start = { & user_stack [STACK_SIZE] , __BOOT_DS };
-
-static void setup_normal_output_buffer(void)
-{
-#ifdef STANDARD_MEMORY_BIOS_CALL
-       if (RM_EXT_MEM_K < 1024) error("Less than 2MB of memory");
-#else
-       if ((RM_ALT_MEM_K > RM_EXT_MEM_K ? RM_ALT_MEM_K : RM_EXT_MEM_K) < 1024) error("Less than 2MB of memory");
-#endif
-       output_data = (unsigned char *)__PHYSICAL_START; /* Normally Points to 1M */
-       free_mem_end_ptr = (long)real_mode;
-}
-
-struct moveparams {
-       uch *low_buffer_start;  int lcount;
-       uch *high_buffer_start; int hcount;
-};
-
-static void setup_output_buffer_if_we_run_high(struct moveparams *mv)
-{
-       high_buffer_start = (uch *)(((ulg)&end) + HEAP_SIZE);
-#ifdef STANDARD_MEMORY_BIOS_CALL
-       if (RM_EXT_MEM_K < (3*1024)) error("Less than 4MB of memory");
-#else
-       if ((RM_ALT_MEM_K > RM_EXT_MEM_K ? RM_ALT_MEM_K : RM_EXT_MEM_K) < (3*1024)) error("Less than 4MB of memory");
-#endif 
-       mv->low_buffer_start = output_data = (unsigned char *)LOW_BUFFER_START;
-       low_buffer_end = ((unsigned int)real_mode > LOW_BUFFER_MAX
-         ? LOW_BUFFER_MAX : (unsigned int)real_mode) & ~0xfff;
-       low_buffer_size = low_buffer_end - LOW_BUFFER_START;
-       high_loaded = 1;
-       free_mem_end_ptr = (long)high_buffer_start;
-       if ( (__PHYSICAL_START + low_buffer_size) > ((ulg)high_buffer_start)) {
-               high_buffer_start = (uch *)(__PHYSICAL_START + low_buffer_size);
-               mv->hcount = 0; /* say: we need not to move high_buffer */
-       }
-       else mv->hcount = -1;
-       mv->high_buffer_start = high_buffer_start;
-}
-
-static void close_output_buffer_if_we_run_high(struct moveparams *mv)
-{
-       if (bytes_out > low_buffer_size) {
-               mv->lcount = low_buffer_size;
-               if (mv->hcount)
-                       mv->hcount = bytes_out - low_buffer_size;
-       } else {
-               mv->lcount = bytes_out;
-               mv->hcount = 0;
-       }
-}
-
-asmlinkage int decompress_kernel(struct moveparams *mv, void *rmode)
+asmlinkage void decompress_kernel(void *rmode, unsigned long end,
+                       uch *input_data, unsigned long input_len, uch *output)
 {
        real_mode = rmode;
 
@@ -361,13 +355,25 @@ asmlinkage int decompress_kernel(struct moveparams *mv, void *rmode)
        lines = RM_SCREEN_INFO.orig_video_lines;
        cols = RM_SCREEN_INFO.orig_video_cols;
 
-       if (free_mem_ptr < 0x100000) setup_normal_output_buffer();
-       else setup_output_buffer_if_we_run_high(mv);
+       window = output;        /* Output buffer (Normally at 1M) */
+       free_mem_ptr     = end; /* Heap  */
+       free_mem_end_ptr = end + HEAP_SIZE;
+       inbuf  = input_data;    /* Input buffer */
+       insize = input_len;
+       inptr  = 0;
+
+       if ((u32)output & (CONFIG_PHYSICAL_ALIGN -1))
+               error("Destination address not CONFIG_PHYSICAL_ALIGN aligned");
+       if (end > ((-__PAGE_OFFSET-(512 <<20)-1) & 0x7fffffff))
+               error("Destination address too large");
+#ifndef CONFIG_RELOCATABLE
+       if ((u32)output != LOAD_PHYSICAL_ADDR)
+               error("Wrong destination address");
+#endif
 
        makecrc();
        putstr("Uncompressing Linux... ");
        gunzip();
        putstr("Ok, booting the kernel.\n");
-       if (high_loaded) close_output_buffer_if_we_run_high(mv);
-       return high_loaded;
+       return;
 }
diff --git a/arch/i386/boot/compressed/relocs.c b/arch/i386/boot/compressed/relocs.c
new file mode 100644 (file)
index 0000000..468da89
--- /dev/null
@@ -0,0 +1,625 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <elf.h>
+#include <byteswap.h>
+#define USE_BSD
+#include <endian.h>
+
+#define MAX_SHDRS 100
+static Elf32_Ehdr ehdr;
+static Elf32_Shdr shdr[MAX_SHDRS];
+static Elf32_Sym  *symtab[MAX_SHDRS];
+static Elf32_Rel  *reltab[MAX_SHDRS];
+static char *strtab[MAX_SHDRS];
+static unsigned long reloc_count, reloc_idx;
+static unsigned long *relocs;
+
+/*
+ * Following symbols have been audited. There values are constant and do
+ * not change if bzImage is loaded at a different physical address than
+ * the address for which it has been compiled. Don't warn user about
+ * absolute relocations present w.r.t these symbols.
+ */
+static const char* safe_abs_relocs[] = {
+               "__kernel_vsyscall",
+               "__kernel_rt_sigreturn",
+               "__kernel_sigreturn",
+               "SYSENTER_RETURN",
+};
+
+static int is_safe_abs_reloc(const char* sym_name)
+{
+       int i, array_size;
+
+       array_size = sizeof(safe_abs_relocs)/sizeof(char*);
+
+       for(i = 0; i < array_size; i++) {
+               if (!strcmp(sym_name, safe_abs_relocs[i]))
+                       /* Match found */
+                       return 1;
+       }
+       return 0;
+}
+
+static void die(char *fmt, ...)
+{
+       va_list ap;
+       va_start(ap, fmt);
+       vfprintf(stderr, fmt, ap);
+       va_end(ap);
+       exit(1);
+}
+
+static const char *sym_type(unsigned type)
+{
+       static const char *type_name[] = {
+#define SYM_TYPE(X) [X] = #X
+               SYM_TYPE(STT_NOTYPE),
+               SYM_TYPE(STT_OBJECT),
+               SYM_TYPE(STT_FUNC),
+               SYM_TYPE(STT_SECTION),
+               SYM_TYPE(STT_FILE),
+               SYM_TYPE(STT_COMMON),
+               SYM_TYPE(STT_TLS),
+#undef SYM_TYPE
+       };
+       const char *name = "unknown sym type name";
+       if (type < sizeof(type_name)/sizeof(type_name[0])) {
+               name = type_name[type];
+       }
+       return name;
+}
+
+static const char *sym_bind(unsigned bind)
+{
+       static const char *bind_name[] = {
+#define SYM_BIND(X) [X] = #X
+               SYM_BIND(STB_LOCAL),
+               SYM_BIND(STB_GLOBAL),
+               SYM_BIND(STB_WEAK),
+#undef SYM_BIND
+       };
+       const char *name = "unknown sym bind name";
+       if (bind < sizeof(bind_name)/sizeof(bind_name[0])) {
+               name = bind_name[bind];
+       }
+       return name;
+}
+
+static const char *sym_visibility(unsigned visibility)
+{
+       static const char *visibility_name[] = {
+#define SYM_VISIBILITY(X) [X] = #X
+               SYM_VISIBILITY(STV_DEFAULT),
+               SYM_VISIBILITY(STV_INTERNAL),
+               SYM_VISIBILITY(STV_HIDDEN),
+               SYM_VISIBILITY(STV_PROTECTED),
+#undef SYM_VISIBILITY
+       };
+       const char *name = "unknown sym visibility name";
+       if (visibility < sizeof(visibility_name)/sizeof(visibility_name[0])) {
+               name = visibility_name[visibility];
+       }
+       return name;
+}
+
+static const char *rel_type(unsigned type)
+{
+       static const char *type_name[] = {
+#define REL_TYPE(X) [X] = #X
+               REL_TYPE(R_386_NONE),
+               REL_TYPE(R_386_32),
+               REL_TYPE(R_386_PC32),
+               REL_TYPE(R_386_GOT32),
+               REL_TYPE(R_386_PLT32),
+               REL_TYPE(R_386_COPY),
+               REL_TYPE(R_386_GLOB_DAT),
+               REL_TYPE(R_386_JMP_SLOT),
+               REL_TYPE(R_386_RELATIVE),
+               REL_TYPE(R_386_GOTOFF),
+               REL_TYPE(R_386_GOTPC),
+#undef REL_TYPE
+       };
+       const char *name = "unknown type rel type name";
+       if (type < sizeof(type_name)/sizeof(type_name[0])) {
+               name = type_name[type];
+       }
+       return name;
+}
+
+static const char *sec_name(unsigned shndx)
+{
+       const char *sec_strtab;
+       const char *name;
+       sec_strtab = strtab[ehdr.e_shstrndx];
+       name = "<noname>";
+       if (shndx < ehdr.e_shnum) {
+               name = sec_strtab + shdr[shndx].sh_name;
+       }
+       else if (shndx == SHN_ABS) {
+               name = "ABSOLUTE";
+       }
+       else if (shndx == SHN_COMMON) {
+               name = "COMMON";
+       }
+       return name;
+}
+
+static const char *sym_name(const char *sym_strtab, Elf32_Sym *sym)
+{
+       const char *name;
+       name = "<noname>";
+       if (sym->st_name) {
+               name = sym_strtab + sym->st_name;
+       }
+       else {
+               name = sec_name(shdr[sym->st_shndx].sh_name);
+       }
+       return name;
+}
+
+
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define le16_to_cpu(val) (val)
+#define le32_to_cpu(val) (val)
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+#define le16_to_cpu(val) bswap_16(val)
+#define le32_to_cpu(val) bswap_32(val)
+#endif
+
+static uint16_t elf16_to_cpu(uint16_t val)
+{
+       return le16_to_cpu(val);
+}
+
+static uint32_t elf32_to_cpu(uint32_t val)
+{
+       return le32_to_cpu(val);
+}
+
+static void read_ehdr(FILE *fp)
+{
+       if (fread(&ehdr, sizeof(ehdr), 1, fp) != 1) {
+               die("Cannot read ELF header: %s\n",
+                       strerror(errno));
+       }
+       if (memcmp(ehdr.e_ident, ELFMAG, 4) != 0) {
+               die("No ELF magic\n");
+       }
+       if (ehdr.e_ident[EI_CLASS] != ELFCLASS32) {
+               die("Not a 32 bit executable\n");
+       }
+       if (ehdr.e_ident[EI_DATA] != ELFDATA2LSB) {
+               die("Not a LSB ELF executable\n");
+       }
+       if (ehdr.e_ident[EI_VERSION] != EV_CURRENT) {
+               die("Unknown ELF version\n");
+       }
+       /* Convert the fields to native endian */
+       ehdr.e_type      = elf16_to_cpu(ehdr.e_type);
+       ehdr.e_machine   = elf16_to_cpu(ehdr.e_machine);
+       ehdr.e_version   = elf32_to_cpu(ehdr.e_version);
+       ehdr.e_entry     = elf32_to_cpu(ehdr.e_entry);
+       ehdr.e_phoff     = elf32_to_cpu(ehdr.e_phoff);
+       ehdr.e_shoff     = elf32_to_cpu(ehdr.e_shoff);
+       ehdr.e_flags     = elf32_to_cpu(ehdr.e_flags);
+       ehdr.e_ehsize    = elf16_to_cpu(ehdr.e_ehsize);
+       ehdr.e_phentsize = elf16_to_cpu(ehdr.e_phentsize);
+       ehdr.e_phnum     = elf16_to_cpu(ehdr.e_phnum);
+       ehdr.e_shentsize = elf16_to_cpu(ehdr.e_shentsize);
+       ehdr.e_shnum     = elf16_to_cpu(ehdr.e_shnum);
+       ehdr.e_shstrndx  = elf16_to_cpu(ehdr.e_shstrndx);
+
+       if ((ehdr.e_type != ET_EXEC) && (ehdr.e_type != ET_DYN)) {
+               die("Unsupported ELF header type\n");
+       }
+       if (ehdr.e_machine != EM_386) {
+               die("Not for x86\n");
+       }
+       if (ehdr.e_version != EV_CURRENT) {
+               die("Unknown ELF version\n");
+       }
+       if (ehdr.e_ehsize != sizeof(Elf32_Ehdr)) {
+               die("Bad Elf header size\n");
+       }
+       if (ehdr.e_phentsize != sizeof(Elf32_Phdr)) {
+               die("Bad program header entry\n");
+       }
+       if (ehdr.e_shentsize != sizeof(Elf32_Shdr)) {
+               die("Bad section header entry\n");
+       }
+       if (ehdr.e_shstrndx >= ehdr.e_shnum) {
+               die("String table index out of bounds\n");
+       }
+}
+
+static void read_shdrs(FILE *fp)
+{
+       int i;
+       if (ehdr.e_shnum > MAX_SHDRS) {
+               die("%d section headers supported: %d\n",
+                       ehdr.e_shnum, MAX_SHDRS);
+       }
+       if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0) {
+               die("Seek to %d failed: %s\n",
+                       ehdr.e_shoff, strerror(errno));
+       }
+       if (fread(&shdr, sizeof(shdr[0]), ehdr.e_shnum, fp) != ehdr.e_shnum) {
+               die("Cannot read ELF section headers: %s\n",
+                       strerror(errno));
+       }
+       for(i = 0; i < ehdr.e_shnum; i++) {
+               shdr[i].sh_name      = elf32_to_cpu(shdr[i].sh_name);
+               shdr[i].sh_type      = elf32_to_cpu(shdr[i].sh_type);
+               shdr[i].sh_flags     = elf32_to_cpu(shdr[i].sh_flags);
+               shdr[i].sh_addr      = elf32_to_cpu(shdr[i].sh_addr);
+               shdr[i].sh_offset    = elf32_to_cpu(shdr[i].sh_offset);
+               shdr[i].sh_size      = elf32_to_cpu(shdr[i].sh_size);
+               shdr[i].sh_link      = elf32_to_cpu(shdr[i].sh_link);
+               shdr[i].sh_info      = elf32_to_cpu(shdr[i].sh_info);
+               shdr[i].sh_addralign = elf32_to_cpu(shdr[i].sh_addralign);
+               shdr[i].sh_entsize   = elf32_to_cpu(shdr[i].sh_entsize);
+       }
+
+}
+
+static void read_strtabs(FILE *fp)
+{
+       int i;
+       for(i = 0; i < ehdr.e_shnum; i++) {
+               if (shdr[i].sh_type != SHT_STRTAB) {
+                       continue;
+               }
+               strtab[i] = malloc(shdr[i].sh_size);
+               if (!strtab[i]) {
+                       die("malloc of %d bytes for strtab failed\n",
+                               shdr[i].sh_size);
+               }
+               if (fseek(fp, shdr[i].sh_offset, SEEK_SET) < 0) {
+                       die("Seek to %d failed: %s\n",
+                               shdr[i].sh_offset, strerror(errno));
+               }
+               if (fread(strtab[i], 1, shdr[i].sh_size, fp) != shdr[i].sh_size) {
+                       die("Cannot read symbol table: %s\n",
+                               strerror(errno));
+               }
+       }
+}
+
+static void read_symtabs(FILE *fp)
+{
+       int i,j;
+       for(i = 0; i < ehdr.e_shnum; i++) {
+               if (shdr[i].sh_type != SHT_SYMTAB) {
+                       continue;
+               }
+               symtab[i] = malloc(shdr[i].sh_size);
+               if (!symtab[i]) {
+                       die("malloc of %d bytes for symtab failed\n",
+                               shdr[i].sh_size);
+               }
+               if (fseek(fp, shdr[i].sh_offset, SEEK_SET) < 0) {
+                       die("Seek to %d failed: %s\n",
+                               shdr[i].sh_offset, strerror(errno));
+               }
+               if (fread(symtab[i], 1, shdr[i].sh_size, fp) != shdr[i].sh_size) {
+                       die("Cannot read symbol table: %s\n",
+                               strerror(errno));
+               }
+               for(j = 0; j < shdr[i].sh_size/sizeof(symtab[i][0]); j++) {
+                       symtab[i][j].st_name  = elf32_to_cpu(symtab[i][j].st_name);
+                       symtab[i][j].st_value = elf32_to_cpu(symtab[i][j].st_value);
+                       symtab[i][j].st_size  = elf32_to_cpu(symtab[i][j].st_size);
+                       symtab[i][j].st_shndx = elf16_to_cpu(symtab[i][j].st_shndx);
+               }
+       }
+}
+
+
+static void read_relocs(FILE *fp)
+{
+       int i,j;
+       for(i = 0; i < ehdr.e_shnum; i++) {
+               if (shdr[i].sh_type != SHT_REL) {
+                       continue;
+               }
+               reltab[i] = malloc(shdr[i].sh_size);
+               if (!reltab[i]) {
+                       die("malloc of %d bytes for relocs failed\n",
+                               shdr[i].sh_size);
+               }
+               if (fseek(fp, shdr[i].sh_offset, SEEK_SET) < 0) {
+                       die("Seek to %d failed: %s\n",
+                               shdr[i].sh_offset, strerror(errno));
+               }
+               if (fread(reltab[i], 1, shdr[i].sh_size, fp) != shdr[i].sh_size) {
+                       die("Cannot read symbol table: %s\n",
+                               strerror(errno));
+               }
+               for(j = 0; j < shdr[i].sh_size/sizeof(reltab[0][0]); j++) {
+                       reltab[i][j].r_offset = elf32_to_cpu(reltab[i][j].r_offset);
+                       reltab[i][j].r_info   = elf32_to_cpu(reltab[i][j].r_info);
+               }
+       }
+}
+
+
+static void print_absolute_symbols(void)
+{
+       int i;
+       printf("Absolute symbols\n");
+       printf(" Num:    Value Size  Type       Bind        Visibility  Name\n");
+       for(i = 0; i < ehdr.e_shnum; i++) {
+               char *sym_strtab;
+               Elf32_Sym *sh_symtab;
+               int j;
+               if (shdr[i].sh_type != SHT_SYMTAB) {
+                       continue;
+               }
+               sh_symtab = symtab[i];
+               sym_strtab = strtab[shdr[i].sh_link];
+               for(j = 0; j < shdr[i].sh_size/sizeof(symtab[0][0]); j++) {
+                       Elf32_Sym *sym;
+                       const char *name;
+                       sym = &symtab[i][j];
+                       name = sym_name(sym_strtab, sym);
+                       if (sym->st_shndx != SHN_ABS) {
+                               continue;
+                       }
+                       printf("%5d %08x %5d %10s %10s %12s %s\n",
+                               j, sym->st_value, sym->st_size,
+                               sym_type(ELF32_ST_TYPE(sym->st_info)),
+                               sym_bind(ELF32_ST_BIND(sym->st_info)),
+                               sym_visibility(ELF32_ST_VISIBILITY(sym->st_other)),
+                               name);
+               }
+       }
+       printf("\n");
+}
+
+static void print_absolute_relocs(void)
+{
+       int i, printed = 0;
+
+       for(i = 0; i < ehdr.e_shnum; i++) {
+               char *sym_strtab;
+               Elf32_Sym *sh_symtab;
+               unsigned sec_applies, sec_symtab;
+               int j;
+               if (shdr[i].sh_type != SHT_REL) {
+                       continue;
+               }
+               sec_symtab  = shdr[i].sh_link;
+               sec_applies = shdr[i].sh_info;
+               if (!(shdr[sec_applies].sh_flags & SHF_ALLOC)) {
+                       continue;
+               }
+               sh_symtab = symtab[sec_symtab];
+               sym_strtab = strtab[shdr[sec_symtab].sh_link];
+               for(j = 0; j < shdr[i].sh_size/sizeof(reltab[0][0]); j++) {
+                       Elf32_Rel *rel;
+                       Elf32_Sym *sym;
+                       const char *name;
+                       rel = &reltab[i][j];
+                       sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
+                       name = sym_name(sym_strtab, sym);
+                       if (sym->st_shndx != SHN_ABS) {
+                               continue;
+                       }
+
+                       /* Absolute symbols are not relocated if bzImage is
+                        * loaded at a non-compiled address. Display a warning
+                        * to user at compile time about the absolute
+                        * relocations present.
+                        *
+                        * User need to audit the code to make sure
+                        * some symbols which should have been section
+                        * relative have not become absolute because of some
+                        * linker optimization or wrong programming usage.
+                        *
+                        * Before warning check if this absolute symbol
+                        * relocation is harmless.
+                        */
+                       if (is_safe_abs_reloc(name))
+                               continue;
+
+                       if (!printed) {
+                               printf("WARNING: Absolute relocations"
+                                       " present\n");
+                               printf("Offset     Info     Type     Sym.Value "
+                                       "Sym.Name\n");
+                               printed = 1;
+                       }
+
+                       printf("%08x %08x %10s %08x  %s\n",
+                               rel->r_offset,
+                               rel->r_info,
+                               rel_type(ELF32_R_TYPE(rel->r_info)),
+                               sym->st_value,
+                               name);
+               }
+       }
+
+       if (printed)
+               printf("\n");
+}
+
+static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym))
+{
+       int i;
+       /* Walk through the relocations */
+       for(i = 0; i < ehdr.e_shnum; i++) {
+               char *sym_strtab;
+               Elf32_Sym *sh_symtab;
+               unsigned sec_applies, sec_symtab;
+               int j;
+               if (shdr[i].sh_type != SHT_REL) {
+                       continue;
+               }
+               sec_symtab  = shdr[i].sh_link;
+               sec_applies = shdr[i].sh_info;
+               if (!(shdr[sec_applies].sh_flags & SHF_ALLOC)) {
+                       continue;
+               }
+               sh_symtab = symtab[sec_symtab];
+               sym_strtab = strtab[shdr[sec_symtab].sh_link];
+               for(j = 0; j < shdr[i].sh_size/sizeof(reltab[0][0]); j++) {
+                       Elf32_Rel *rel;
+                       Elf32_Sym *sym;
+                       unsigned r_type;
+                       rel = &reltab[i][j];
+                       sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
+                       r_type = ELF32_R_TYPE(rel->r_info);
+                       /* Don't visit relocations to absolute symbols */
+                       if (sym->st_shndx == SHN_ABS) {
+                               continue;
+                       }
+                       if (r_type == R_386_PC32) {
+                               /* PC relative relocations don't need to be adjusted */
+                       }
+                       else if (r_type == R_386_32) {
+                               /* Visit relocations that need to be adjusted */
+                               visit(rel, sym);
+                       }
+                       else {
+                               die("Unsupported relocation type: %d\n", r_type);
+                       }
+               }
+       }
+}
+
+static void count_reloc(Elf32_Rel *rel, Elf32_Sym *sym)
+{
+       reloc_count += 1;
+}
+
+static void collect_reloc(Elf32_Rel *rel, Elf32_Sym *sym)
+{
+       /* Remember the address that needs to be adjusted. */
+       relocs[reloc_idx++] = rel->r_offset;
+}
+
+static int cmp_relocs(const void *va, const void *vb)
+{
+       const unsigned long *a, *b;
+       a = va; b = vb;
+       return (*a == *b)? 0 : (*a > *b)? 1 : -1;
+}
+
+static void emit_relocs(int as_text)
+{
+       int i;
+       /* Count how many relocations I have and allocate space for them. */
+       reloc_count = 0;
+       walk_relocs(count_reloc);
+       relocs = malloc(reloc_count * sizeof(relocs[0]));
+       if (!relocs) {
+               die("malloc of %d entries for relocs failed\n",
+                       reloc_count);
+       }
+       /* Collect up the relocations */
+       reloc_idx = 0;
+       walk_relocs(collect_reloc);
+
+       /* Order the relocations for more efficient processing */
+       qsort(relocs, reloc_count, sizeof(relocs[0]), cmp_relocs);
+
+       /* Print the relocations */
+       if (as_text) {
+               /* Print the relocations in a form suitable that
+                * gas will like.
+                */
+               printf(".section \".data.reloc\",\"a\"\n");
+               printf(".balign 4\n");
+               for(i = 0; i < reloc_count; i++) {
+                       printf("\t .long 0x%08lx\n", relocs[i]);
+               }
+               printf("\n");
+       }
+       else {
+               unsigned char buf[4];
+               buf[0] = buf[1] = buf[2] = buf[3] = 0;
+               /* Print a stop */
+               printf("%c%c%c%c", buf[0], buf[1], buf[2], buf[3]);
+               /* Now print each relocation */
+               for(i = 0; i < reloc_count; i++) {
+                       buf[0] = (relocs[i] >>  0) & 0xff;
+                       buf[1] = (relocs[i] >>  8) & 0xff;
+                       buf[2] = (relocs[i] >> 16) & 0xff;
+                       buf[3] = (relocs[i] >> 24) & 0xff;
+                       printf("%c%c%c%c", buf[0], buf[1], buf[2], buf[3]);
+               }
+       }
+}
+
+static void usage(void)
+{
+       die("relocs [--abs-syms |--abs-relocs | --text] vmlinux\n");
+}
+
+int main(int argc, char **argv)
+{
+       int show_absolute_syms, show_absolute_relocs;
+       int as_text;
+       const char *fname;
+       FILE *fp;
+       int i;
+
+       show_absolute_syms = 0;
+       show_absolute_relocs = 0;
+       as_text = 0;
+       fname = NULL;
+       for(i = 1; i < argc; i++) {
+               char *arg = argv[i];
+               if (*arg == '-') {
+                       if (strcmp(argv[1], "--abs-syms") == 0) {
+                               show_absolute_syms = 1;
+                               continue;
+                       }
+
+                       if (strcmp(argv[1], "--abs-relocs") == 0) {
+                               show_absolute_relocs = 1;
+                               continue;
+                       }
+                       else if (strcmp(argv[1], "--text") == 0) {
+                               as_text = 1;
+                               continue;
+                       }
+               }
+               else if (!fname) {
+                       fname = arg;
+                       continue;
+               }
+               usage();
+       }
+       if (!fname) {
+               usage();
+       }
+       fp = fopen(fname, "r");
+       if (!fp) {
+               die("Cannot open %s: %s\n",
+                       fname, strerror(errno));
+       }
+       read_ehdr(fp);
+       read_shdrs(fp);
+       read_strtabs(fp);
+       read_symtabs(fp);
+       read_relocs(fp);
+       if (show_absolute_syms) {
+               print_absolute_symbols();
+               return 0;
+       }
+       if (show_absolute_relocs) {
+               print_absolute_relocs();
+               return 0;
+       }
+       emit_relocs(as_text);
+       return 0;
+}
diff --git a/arch/i386/boot/compressed/vmlinux.lds b/arch/i386/boot/compressed/vmlinux.lds
new file mode 100644 (file)
index 0000000..cc4854f
--- /dev/null
@@ -0,0 +1,43 @@
+OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
+OUTPUT_ARCH(i386)
+ENTRY(startup_32)
+SECTIONS
+{
+        /* Be careful parts of head.S assume startup_32 is at
+         * address 0.
+        */
+       . =  0  ;
+       .text.head : {
+               _head = . ;
+               *(.text.head)
+               _ehead = . ;
+       }
+       .data.compressed : {
+               *(.data.compressed)
+       }
+       .text : {
+               _text = .;      /* Text */
+               *(.text)
+               *(.text.*)
+               _etext = . ;
+       }
+       .rodata : {
+               _rodata = . ;
+               *(.rodata)       /* read-only data */
+               *(.rodata.*)
+               _erodata = . ;
+       }
+       .data : {
+               _data = . ;
+               *(.data)
+               *(.data.*)
+               _edata = . ;
+       }
+       .bss : {
+               _bss = . ;
+               *(.bss)
+               *(.bss.*)
+               *(COMMON)
+               _end = . ;
+       }
+}
index 1ed9d791f8638c5a6f9e5bc8d1831779d411b2b6..707a88f7f29ebc24b42b0a793ed132f53d1c0f05 100644 (file)
@@ -1,9 +1,10 @@
 SECTIONS
 {
-  .data : { 
+  .data.compressed : {
        input_len = .;
        LONG(input_data_end - input_data) input_data = .; 
        *(.data) 
+       output_len = . - 4;
        input_data_end = .; 
        }
 }
index 3aec4538a113b9f84d33c3613e7137e18aaa8f61..06edf1c66242466e8853fcedd8afacc19228817a 100644 (file)
@@ -81,7 +81,7 @@ start:
 # This is the setup header, and it must start at %cs:2 (old 0x9020:2)
 
                .ascii  "HdrS"          # header signature
-               .word   0x0204          # header version number (>= 0x0105)
+               .word   0x0205          # header version number (>= 0x0105)
                                        # or else old loadlin-1.5 will fail)
 realmode_swtch:        .word   0, 0            # default_switch, SETUPSEG
 start_sys_seg: .word   SYSSEG
@@ -160,6 +160,17 @@ ramdisk_max:       .long (-__PAGE_OFFSET-(512 << 20)-1) & 0x7fffffff
                                        # The highest safe address for
                                        # the contents of an initrd
 
+kernel_alignment:  .long CONFIG_PHYSICAL_ALIGN         #physical addr alignment
+                                               #required for protected mode
+                                               #kernel
+#ifdef CONFIG_RELOCATABLE
+relocatable_kernel:    .byte 1
+#else
+relocatable_kernel:    .byte 0
+#endif
+pad2:                  .byte 0
+pad3:                  .word 0
+
 trampoline:    call    start_of_setup
                .align 16
                                        # The offset at this point is 0x240
@@ -588,11 +599,6 @@ rmodeswtch_normal:
        call    default_switch
 
 rmodeswtch_end:
-# we get the code32 start address and modify the below 'jmpi'
-# (loader may have changed it)
-       movl    %cs:code32_start, %eax
-       movl    %eax, %cs:code32
-
 # Now we move the system to its rightful place ... but we check if we have a
 # big-kernel. In that case we *must* not move it ...
        testb   $LOADED_HIGH, %cs:loadflags
@@ -788,11 +794,12 @@ a20_err_msg:
 a20_done:
 
 #endif /* CONFIG_X86_VOYAGER */
-# set up gdt and idt
+# set up gdt and idt and 32bit start address
        lidt    idt_48                          # load idt with 0,0
        xorl    %eax, %eax                      # Compute gdt_base
        movw    %ds, %ax                        # (Convert %ds:gdt to a linear ptr)
        shll    $4, %eax
+       addl    %eax, code32
        addl    $gdt, %eax
        movl    %eax, (gdt_48+2)
        lgdt    gdt_48                          # load gdt with whatever is
@@ -851,9 +858,26 @@ flush_instr:
 #      Manual, Mixing 16-bit and 32-bit code, page 16-6)
 
        .byte 0x66, 0xea                        # prefix + jmpi-opcode
-code32:        .long   0x1000                          # will be set to 0x100000
-                                               # for big kernels
+code32:        .long   startup_32                      # will be set to %cs+startup_32
        .word   __BOOT_CS
+.code32
+startup_32:
+       movl $(__BOOT_DS), %eax
+       movl %eax, %ds
+       movl %eax, %es
+       movl %eax, %fs
+       movl %eax, %gs
+       movl %eax, %ss
+
+       xorl %eax, %eax
+1:     incl %eax                               # check that A20 really IS enabled
+       movl %eax, 0x00000000                   # loop forever if it isn't
+       cmpl %eax, 0x00100000
+       je 1b
+
+       # Jump to the 32bit entry point
+       jmpl *(code32_start - start + (DELTA_INITSEG << 4))(%esi)
+.code16
 
 # Here's a bunch of information about your current kernel..
 kernel_version:        .ascii  UTS_RELEASE
index 97aacd6bd7d810a85c15f9d96811167b5b680165..65891f11acedc52640472c1185a47165662a6503 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.19-rc2-git4
-# Sat Oct 21 03:38:56 2006
+# Linux kernel version: 2.6.19-git7
+# Wed Dec  6 23:50:49 2006
 #
 CONFIG_X86_32=y
 CONFIG_GENERIC_TIME=y
@@ -40,13 +40,14 @@ CONFIG_POSIX_MQUEUE=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 # CONFIG_CPUSETS is not set
+CONFIG_SYSFS_DEPRECATED=y
 # CONFIG_RELAY is not set
 CONFIG_INITRAMFS_SOURCE=""
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_SYSCTL=y
 # CONFIG_EMBEDDED is not set
 CONFIG_UID16=y
-# CONFIG_SYSCTL_SYSCALL is not set
+CONFIG_SYSCTL_SYSCALL=y
 CONFIG_KALLSYMS=y
 CONFIG_KALLSYMS_ALL=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
@@ -110,6 +111,7 @@ CONFIG_SMP=y
 # CONFIG_X86_VISWS is not set
 CONFIG_X86_GENERICARCH=y
 # CONFIG_X86_ES7000 is not set
+# CONFIG_PARAVIRT is not set
 CONFIG_X86_CYCLONE_TIMER=y
 # CONFIG_M386 is not set
 # CONFIG_M486 is not set
@@ -120,6 +122,7 @@ CONFIG_X86_CYCLONE_TIMER=y
 # CONFIG_MPENTIUMII is not set
 CONFIG_MPENTIUMIII=y
 # CONFIG_MPENTIUMM is not set
+# CONFIG_MCORE2 is not set
 # CONFIG_MPENTIUM4 is not set
 # CONFIG_MK6 is not set
 # CONFIG_MK7 is not set
@@ -197,7 +200,6 @@ CONFIG_RESOURCES_64BIT=y
 CONFIG_MTRR=y
 # CONFIG_EFI is not set
 # CONFIG_IRQBALANCE is not set
-CONFIG_REGPARM=y
 CONFIG_SECCOMP=y
 # CONFIG_HZ_100 is not set
 CONFIG_HZ_250=y
@@ -205,7 +207,8 @@ CONFIG_HZ_250=y
 CONFIG_HZ=250
 # CONFIG_KEXEC is not set
 # CONFIG_CRASH_DUMP is not set
-CONFIG_PHYSICAL_START=0x100000
+# CONFIG_RELOCATABLE is not set
+CONFIG_PHYSICAL_ALIGN=0x100000
 # CONFIG_HOTPLUG_CPU is not set
 CONFIG_COMPAT_VDSO=y
 CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
@@ -367,6 +370,7 @@ CONFIG_INET_TCP_DIAG=y
 # CONFIG_TCP_CONG_ADVANCED is not set
 CONFIG_TCP_CONG_CUBIC=y
 CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
 CONFIG_IPV6=y
 # CONFIG_IPV6_PRIVACY is not set
 # CONFIG_IPV6_ROUTER_PREF is not set
@@ -677,6 +681,7 @@ CONFIG_SATA_INTEL_COMBINED=y
 # CONFIG_PATA_IT821X is not set
 # CONFIG_PATA_JMICRON is not set
 # CONFIG_PATA_TRIFLEX is not set
+# CONFIG_PATA_MARVELL is not set
 # CONFIG_PATA_MPIIX is not set
 # CONFIG_PATA_OLDPIIX is not set
 # CONFIG_PATA_NETCELL is not set
@@ -850,6 +855,7 @@ CONFIG_BNX2=y
 # CONFIG_IXGB is not set
 # CONFIG_S2IO is not set
 # CONFIG_MYRI10GE is not set
+# CONFIG_NETXEN_NIC is not set
 
 #
 # Token Ring devices
@@ -984,10 +990,6 @@ CONFIG_RTC=y
 # CONFIG_R3964 is not set
 # CONFIG_APPLICOM is not set
 # CONFIG_SONYPI is not set
-
-#
-# Ftape, the floppy tape device driver
-#
 CONFIG_AGP=y
 # CONFIG_AGP_ALI is not set
 # CONFIG_AGP_ATI is not set
@@ -1108,6 +1110,7 @@ CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_BANDWIDTH is not set
 # CONFIG_USB_DYNAMIC_MINORS is not set
 # CONFIG_USB_SUSPEND is not set
+# CONFIG_USB_MULTITHREAD_PROBE is not set
 # CONFIG_USB_OTG is not set
 
 #
@@ -1185,6 +1188,7 @@ CONFIG_USB_HIDINPUT=y
 # CONFIG_USB_KAWETH is not set
 # CONFIG_USB_PEGASUS is not set
 # CONFIG_USB_RTL8150 is not set
+# CONFIG_USB_USBNET_MII is not set
 # CONFIG_USB_USBNET is not set
 CONFIG_USB_MON=y
 
index 1a884b6e6e5c97d472fb5c0e8c10d982f806d2f9..1e8988e558c54971fe08fbe9f868a72c7126a924 100644 (file)
@@ -6,7 +6,7 @@ extra-y := head.o init_task.o vmlinux.lds
 
 obj-y  := process.o signal.o entry.o traps.o irq.o \
                ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \
-               pci-dma.o i386_ksyms.o i387.o bootflag.o \
+               pci-dma.o i386_ksyms.o i387.o bootflag.o e820.o\
                quirks.o i8237.o topology.o alternative.o i8253.o tsc.o
 
 obj-$(CONFIG_STACKTRACE)       += stacktrace.o
@@ -40,6 +40,9 @@ obj-$(CONFIG_EARLY_PRINTK)    += early_printk.o
 obj-$(CONFIG_HPET_TIMER)       += hpet.o
 obj-$(CONFIG_K8_NB)            += k8.o
 
+# Make sure this is linked after any other paravirt_ops structs: see head.S
+obj-$(CONFIG_PARAVIRT)         += paravirt.o
+
 EXTRA_AFLAGS   := -traditional
 
 obj-$(CONFIG_SCx200)           += scx200.o
index 4664b55f623ef2b349a510c0dcd487d8149063c3..12e937c1ce4bbe11feccd1be11d75e728adc1f44 100644 (file)
@@ -156,10 +156,8 @@ static int __init ffh_cstate_init(void)
 
 static void __exit ffh_cstate_exit(void)
 {
-       if (cpu_cstate_entry) {
-               free_percpu(cpu_cstate_entry);
-               cpu_cstate_entry = NULL;
-       }
+       free_percpu(cpu_cstate_entry);
+       cpu_cstate_entry = NULL;
 }
 
 arch_initcall(ffh_cstate_init);
index c9841692bb7cc1170861044ecd973916373b18d3..4b60af7f91dd0c915c42f24d09976254b7c42353 100644 (file)
@@ -10,6 +10,7 @@
 #include <asm/pci-direct.h>
 #include <asm/acpi.h>
 #include <asm/apic.h>
+#include <asm/irq.h>
 
 #ifdef CONFIG_ACPI
 
@@ -49,6 +50,24 @@ static int __init check_bridge(int vendor, int device)
        return 0;
 }
 
+static void check_intel(void)
+{
+       u16 vendor, device;
+
+       vendor = read_pci_config_16(0, 0, 0, PCI_VENDOR_ID);
+
+       if (vendor != PCI_VENDOR_ID_INTEL)
+               return;
+
+       device = read_pci_config_16(0, 0, 0, PCI_DEVICE_ID);
+#ifdef CONFIG_SMP
+       if (device == PCI_DEVICE_ID_INTEL_E7320_MCH ||
+           device == PCI_DEVICE_ID_INTEL_E7520_MCH ||
+           device == PCI_DEVICE_ID_INTEL_E7525_MCH)
+               quirk_intel_irqbalance();
+#endif
+}
+
 void __init check_acpi_pci(void)
 {
        int num, slot, func;
@@ -60,6 +79,8 @@ void __init check_acpi_pci(void)
        if (!early_pci_allowed())
                return;
 
+       check_intel();
+
        /* Poor man's PCI discovery */
        for (num = 0; num < 32; num++) {
                for (slot = 0; slot < 32; slot++) {
index 535f9794fba1aa811cb7a1ea270fa3c285fc0f98..9eca21b49f6b3d0487df153594cdcbbfdebc17c7 100644 (file)
@@ -124,6 +124,20 @@ static unsigned char** find_nop_table(void)
 
 #endif /* CONFIG_X86_64 */
 
+static void nop_out(void *insns, unsigned int len)
+{
+       unsigned char **noptable = find_nop_table();
+
+       while (len > 0) {
+               unsigned int noplen = len;
+               if (noplen > ASM_NOP_MAX)
+                       noplen = ASM_NOP_MAX;
+               memcpy(insns, noptable[noplen], noplen);
+               insns += noplen;
+               len -= noplen;
+       }
+}
+
 extern struct alt_instr __alt_instructions[], __alt_instructions_end[];
 extern struct alt_instr __smp_alt_instructions[], __smp_alt_instructions_end[];
 extern u8 *__smp_locks[], *__smp_locks_end[];
@@ -138,10 +152,9 @@ extern u8 __smp_alt_begin[], __smp_alt_end[];
 
 void apply_alternatives(struct alt_instr *start, struct alt_instr *end)
 {
-       unsigned char **noptable = find_nop_table();
        struct alt_instr *a;
        u8 *instr;
-       int diff, i, k;
+       int diff;
 
        DPRINTK("%s: alt table %p -> %p\n", __FUNCTION__, start, end);
        for (a = start; a < end; a++) {
@@ -159,13 +172,7 @@ void apply_alternatives(struct alt_instr *start, struct alt_instr *end)
 #endif
                memcpy(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);
-               }
+               nop_out(instr + a->replacementlen, diff);
        }
 }
 
@@ -209,7 +216,6 @@ static void alternatives_smp_lock(u8 **start, u8 **end, u8 *text, u8 *text_end)
 
 static void alternatives_smp_unlock(u8 **start, u8 **end, u8 *text, u8 *text_end)
 {
-       unsigned char **noptable = find_nop_table();
        u8 **ptr;
 
        for (ptr = start; ptr < end; ptr++) {
@@ -217,7 +223,7 @@ static void alternatives_smp_unlock(u8 **start, u8 **end, u8 *text, u8 *text_end
                        continue;
                if (*ptr > text_end)
                        continue;
-               **ptr = noptable[1][0];
+               nop_out(*ptr, 1);
        };
 }
 
@@ -343,6 +349,40 @@ void alternatives_smp_switch(int smp)
 
 #endif
 
+#ifdef CONFIG_PARAVIRT
+void apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end)
+{
+       struct paravirt_patch *p;
+
+       for (p = start; p < end; p++) {
+               unsigned int used;
+
+               used = paravirt_ops.patch(p->instrtype, p->clobbers, p->instr,
+                                         p->len);
+#ifdef CONFIG_DEBUG_PARAVIRT
+               {
+               int i;
+               /* Deliberately clobber regs using "not %reg" to find bugs. */
+               for (i = 0; i < 3; i++) {
+                       if (p->len - used >= 2 && (p->clobbers & (1 << i))) {
+                               memcpy(p->instr + used, "\xf7\xd0", 2);
+                               p->instr[used+1] |= i;
+                               used += 2;
+                       }
+               }
+               }
+#endif
+               /* Pad the rest with nops */
+               nop_out(p->instr + used, p->len - used);
+       }
+
+       /* Sync to be conservative, in case we patched following instructions */
+       sync_core();
+}
+extern struct paravirt_patch __start_parainstructions[],
+       __stop_parainstructions[];
+#endif /* CONFIG_PARAVIRT */
+
 void __init alternative_instructions(void)
 {
        unsigned long flags;
@@ -390,5 +430,6 @@ void __init alternative_instructions(void)
                alternatives_smp_switch(0);
        }
 #endif
+       apply_paravirt(__start_parainstructions, __stop_parainstructions);
        local_irq_restore(flags);
 }
index 2fd4b7d927c24f5578b437b7a183da4c24537488..776d9be26af9ea5906bc0e04798878e69d3b51a3 100644 (file)
@@ -647,23 +647,30 @@ static struct {
 static int lapic_suspend(struct sys_device *dev, pm_message_t state)
 {
        unsigned long flags;
+       int maxlvt;
 
        if (!apic_pm_state.active)
                return 0;
 
+       maxlvt = get_maxlvt();
+
        apic_pm_state.apic_id = apic_read(APIC_ID);
        apic_pm_state.apic_taskpri = apic_read(APIC_TASKPRI);
        apic_pm_state.apic_ldr = apic_read(APIC_LDR);
        apic_pm_state.apic_dfr = apic_read(APIC_DFR);
        apic_pm_state.apic_spiv = apic_read(APIC_SPIV);
        apic_pm_state.apic_lvtt = apic_read(APIC_LVTT);
-       apic_pm_state.apic_lvtpc = apic_read(APIC_LVTPC);
+       if (maxlvt >= 4)
+               apic_pm_state.apic_lvtpc = apic_read(APIC_LVTPC);
        apic_pm_state.apic_lvt0 = apic_read(APIC_LVT0);
        apic_pm_state.apic_lvt1 = apic_read(APIC_LVT1);
        apic_pm_state.apic_lvterr = apic_read(APIC_LVTERR);
        apic_pm_state.apic_tmict = apic_read(APIC_TMICT);
        apic_pm_state.apic_tdcr = apic_read(APIC_TDCR);
-       apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR);
+#ifdef CONFIG_X86_MCE_P4THERMAL
+       if (maxlvt >= 5)
+               apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR);
+#endif
        
        local_irq_save(flags);
        disable_local_APIC();
@@ -675,10 +682,13 @@ static int lapic_resume(struct sys_device *dev)
 {
        unsigned int l, h;
        unsigned long flags;
+       int maxlvt;
 
        if (!apic_pm_state.active)
                return 0;
 
+       maxlvt = get_maxlvt();
+
        local_irq_save(flags);
 
        /*
@@ -700,8 +710,12 @@ static int lapic_resume(struct sys_device *dev)
        apic_write(APIC_SPIV, apic_pm_state.apic_spiv);
        apic_write(APIC_LVT0, apic_pm_state.apic_lvt0);
        apic_write(APIC_LVT1, apic_pm_state.apic_lvt1);
-       apic_write(APIC_LVTTHMR, apic_pm_state.apic_thmr);
-       apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc);
+#ifdef CONFIG_X86_MCE_P4THERMAL
+       if (maxlvt >= 5)
+               apic_write(APIC_LVTTHMR, apic_pm_state.apic_thmr);
+#endif
+       if (maxlvt >= 4)
+               apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc);
        apic_write(APIC_LVTT, apic_pm_state.apic_lvtt);
        apic_write(APIC_TDCR, apic_pm_state.apic_tdcr);
        apic_write(APIC_TMICT, apic_pm_state.apic_tmict);
index a60358fe9a49d828a69c3271459ef5f5949e2aca..a97847da9ed59e85508ace8f5a77be90260d8c6a 100644 (file)
 #include <asm/uaccess.h>
 #include <asm/desc.h>
 #include <asm/i8253.h>
+#include <asm/paravirt.h>
 
 #include "io_ports.h"
 
@@ -2235,7 +2236,7 @@ static int __init apm_init(void)
 
        dmi_check_system(apm_dmi_table);
 
-       if (apm_info.bios.version == 0) {
+       if (apm_info.bios.version == 0 || paravirt_enabled()) {
                printk(KERN_INFO "apm: BIOS not found.\n");
                return -ENODEV;
        }
index c80271f8f084c04014d926185cbe896a86fe8d9e..1b2f3cd332707f7fd6beb0e6fdf7b0a4149eb5ad 100644 (file)
@@ -15,6 +15,7 @@
 #include <asm/processor.h>
 #include <asm/thread_info.h>
 #include <asm/elf.h>
+#include <asm/pda.h>
 
 #define DEFINE(sym, val) \
         asm volatile("\n->" #sym " %0 " #val : : "i" (val))
@@ -51,13 +52,35 @@ void foo(void)
        OFFSET(TI_exec_domain, thread_info, exec_domain);
        OFFSET(TI_flags, thread_info, flags);
        OFFSET(TI_status, thread_info, status);
-       OFFSET(TI_cpu, thread_info, cpu);
        OFFSET(TI_preempt_count, thread_info, preempt_count);
        OFFSET(TI_addr_limit, thread_info, addr_limit);
        OFFSET(TI_restart_block, thread_info, restart_block);
        OFFSET(TI_sysenter_return, thread_info, sysenter_return);
        BLANK();
 
+       OFFSET(GDS_size, Xgt_desc_struct, size);
+       OFFSET(GDS_address, Xgt_desc_struct, address);
+       OFFSET(GDS_pad, Xgt_desc_struct, pad);
+       BLANK();
+
+       OFFSET(PT_EBX, pt_regs, ebx);
+       OFFSET(PT_ECX, pt_regs, ecx);
+       OFFSET(PT_EDX, pt_regs, edx);
+       OFFSET(PT_ESI, pt_regs, esi);
+       OFFSET(PT_EDI, pt_regs, edi);
+       OFFSET(PT_EBP, pt_regs, ebp);
+       OFFSET(PT_EAX, pt_regs, eax);
+       OFFSET(PT_DS,  pt_regs, xds);
+       OFFSET(PT_ES,  pt_regs, xes);
+       OFFSET(PT_GS,  pt_regs, xgs);
+       OFFSET(PT_ORIG_EAX, pt_regs, orig_eax);
+       OFFSET(PT_EIP, pt_regs, eip);
+       OFFSET(PT_CS,  pt_regs, xcs);
+       OFFSET(PT_EFLAGS, pt_regs, eflags);
+       OFFSET(PT_OLDESP, pt_regs, esp);
+       OFFSET(PT_OLDSS,  pt_regs, xss);
+       BLANK();
+
        OFFSET(EXEC_DOMAIN_handler, exec_domain, handler);
        OFFSET(RT_SIGFRAME_sigcontext, rt_sigframe, uc.uc_mcontext);
        BLANK();
@@ -74,4 +97,18 @@ void foo(void)
        DEFINE(VDSO_PRELINK, VDSO_PRELINK);
 
        OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
+
+       BLANK();
+       OFFSET(PDA_cpu, i386_pda, cpu_number);
+       OFFSET(PDA_pcurrent, i386_pda, pcurrent);
+
+#ifdef CONFIG_PARAVIRT
+       BLANK();
+       OFFSET(PARAVIRT_enabled, paravirt_ops, paravirt_enabled);
+       OFFSET(PARAVIRT_irq_disable, paravirt_ops, irq_disable);
+       OFFSET(PARAVIRT_irq_enable, paravirt_ops, irq_enable);
+       OFFSET(PARAVIRT_irq_enable_sysexit, paravirt_ops, irq_enable_sysexit);
+       OFFSET(PARAVIRT_iret, paravirt_ops, iret);
+       OFFSET(PARAVIRT_read_cr0, paravirt_ops, read_cr0);
+#endif
 }
index e4758095d87a8d72232f3876a2973adcd06db92a..41cfea57232bb290d7a81061b7f397c53984d23b 100644 (file)
@@ -104,10 +104,7 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
                                        f_vide();
                                rdtscl(d2);
                                d = d2-d;
-                               
-                               /* Knock these two lines out if it debugs out ok */
-                               printk(KERN_INFO "AMD K6 stepping B detected - ");
-                               /* -- cut here -- */
+
                                if (d > 20*K6_BUG_LOOP) 
                                        printk("system stability may be impaired when more than 32 MB are used.\n");
                                else 
index d9f3e3c31f054240c790bbb461c8f261f2726487..1b34c56f8123ac7f4ccb7a7e677bee6ef8f7cb6f 100644 (file)
 #include <asm/apic.h>
 #include <mach_apic.h>
 #endif
+#include <asm/pda.h>
 
 #include "cpu.h"
 
 DEFINE_PER_CPU(struct Xgt_desc_struct, cpu_gdt_descr);
 EXPORT_PER_CPU_SYMBOL(cpu_gdt_descr);
 
-DEFINE_PER_CPU(unsigned char, cpu_16bit_stack[CPU_16BIT_STACK_SIZE]);
-EXPORT_PER_CPU_SYMBOL(cpu_16bit_stack);
+struct i386_pda *_cpu_pda[NR_CPUS] __read_mostly;
+EXPORT_SYMBOL(_cpu_pda);
 
 static int cachesize_override __cpuinitdata = -1;
 static int disable_x86_fxsr __cpuinitdata;
@@ -235,29 +236,14 @@ static int __cpuinit have_cpuid_p(void)
        return flag_is_changeable_p(X86_EFLAGS_ID);
 }
 
-/* Do minimum CPU detection early.
-   Fields really needed: vendor, cpuid_level, family, model, mask, cache alignment.
-   The others are not touched to avoid unwanted side effects.
-
-   WARNING: this function is only called on the BP.  Don't add code here
-   that is supposed to run on all CPUs. */
-static void __init early_cpu_detect(void)
+void __init cpu_detect(struct cpuinfo_x86 *c)
 {
-       struct cpuinfo_x86 *c = &boot_cpu_data;
-
-       c->x86_cache_alignment = 32;
-
-       if (!have_cpuid_p())
-               return;
-
        /* Get vendor name */
        cpuid(0x00000000, &c->cpuid_level,
              (int *)&c->x86_vendor_id[0],
              (int *)&c->x86_vendor_id[8],
              (int *)&c->x86_vendor_id[4]);
 
-       get_cpu_vendor(c, 1);
-
        c->x86 = 4;
        if (c->cpuid_level >= 0x00000001) {
                u32 junk, tfms, cap0, misc;
@@ -274,6 +260,26 @@ static void __init early_cpu_detect(void)
        }
 }
 
+/* Do minimum CPU detection early.
+   Fields really needed: vendor, cpuid_level, family, model, mask, cache alignment.
+   The others are not touched to avoid unwanted side effects.
+
+   WARNING: this function is only called on the BP.  Don't add code here
+   that is supposed to run on all CPUs. */
+static void __init early_cpu_detect(void)
+{
+       struct cpuinfo_x86 *c = &boot_cpu_data;
+
+       c->x86_cache_alignment = 32;
+
+       if (!have_cpuid_p())
+               return;
+
+       cpu_detect(c);
+
+       get_cpu_vendor(c, 1);
+}
+
 static void __cpuinit generic_identify(struct cpuinfo_x86 * c)
 {
        u32 tfms, xlvl;
@@ -308,6 +314,8 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 * c)
 #else
                        c->apicid = (ebx >> 24) & 0xFF;
 #endif
+                       if (c->x86_capability[0] & (1<<19))
+                               c->x86_clflush_size = ((ebx >> 8) & 0xff) * 8;
                } else {
                        /* Have CPUID level 0 only - unheard of */
                        c->x86 = 4;
@@ -372,6 +380,7 @@ void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
        c->x86_vendor_id[0] = '\0'; /* Unset */
        c->x86_model_id[0] = '\0';  /* Unset */
        c->x86_max_cores = 1;
+       c->x86_clflush_size = 32;
        memset(&c->x86_capability, 0, sizeof c->x86_capability);
 
        if (!have_cpuid_p()) {
@@ -591,42 +600,24 @@ void __init early_cpu_init(void)
        disable_pse = 1;
 #endif
 }
-/*
- * cpu_init() initializes state that is per-CPU. Some data is already
- * initialized (naturally) in the bootstrap process, such as the GDT
- * and IDT. We reload them nevertheless, this function acts as a
- * 'CPU state barrier', nothing should get across.
- */
-void __cpuinit cpu_init(void)
+
+/* Make sure %gs is initialized properly in idle threads */
+struct pt_regs * __devinit idle_regs(struct pt_regs *regs)
 {
-       int cpu = smp_processor_id();
-       struct tss_struct * t = &per_cpu(init_tss, cpu);
-       struct thread_struct *thread = &current->thread;
-       struct desc_struct *gdt;
-       __u32 stk16_off = (__u32)&per_cpu(cpu_16bit_stack, cpu);
-       struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
+       memset(regs, 0, sizeof(struct pt_regs));
+       regs->xgs = __KERNEL_PDA;
+       return regs;
+}
 
-       if (cpu_test_and_set(cpu, cpu_initialized)) {
-               printk(KERN_WARNING "CPU#%d already initialized!\n", cpu);
-               for (;;) local_irq_enable();
-       }
-       printk(KERN_INFO "Initializing CPU#%d\n", cpu);
+static __cpuinit int alloc_gdt(int cpu)
+{
+       struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
+       struct desc_struct *gdt;
+       struct i386_pda *pda;
 
-       if (cpu_has_vme || cpu_has_tsc || cpu_has_de)
-               clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
-       if (tsc_disable && cpu_has_tsc) {
-               printk(KERN_NOTICE "Disabling TSC...\n");
-               /**** FIX-HPA: DOES THIS REALLY BELONG HERE? ****/
-               clear_bit(X86_FEATURE_TSC, boot_cpu_data.x86_capability);
-               set_in_cr4(X86_CR4_TSD);
-       }
+       gdt = (struct desc_struct *)cpu_gdt_descr->address;
+       pda = cpu_pda(cpu);
 
-       /* The CPU hotplug case */
-       if (cpu_gdt_descr->address) {
-               gdt = (struct desc_struct *)cpu_gdt_descr->address;
-               memset(gdt, 0, PAGE_SIZE);
-               goto old_gdt;
-       }
        /*
         * This is a horrible hack to allocate the GDT.  The problem
         * is that cpu_init() is called really early for the boot CPU
@@ -634,43 +625,130 @@ void __cpuinit cpu_init(void)
         * CPUs, when bootmem will have gone away
         */
        if (NODE_DATA(0)->bdata->node_bootmem_map) {
-               gdt = (struct desc_struct *)alloc_bootmem_pages(PAGE_SIZE);
-               /* alloc_bootmem_pages panics on failure, so no check */
+               BUG_ON(gdt != NULL || pda != NULL);
+
+               gdt = alloc_bootmem_pages(PAGE_SIZE);
+               pda = alloc_bootmem(sizeof(*pda));
+               /* alloc_bootmem(_pages) panics on failure, so no check */
+
                memset(gdt, 0, PAGE_SIZE);
+               memset(pda, 0, sizeof(*pda));
        } else {
-               gdt = (struct desc_struct *)get_zeroed_page(GFP_KERNEL);
-               if (unlikely(!gdt)) {
-                       printk(KERN_CRIT "CPU%d failed to allocate GDT\n", cpu);
-                       for (;;)
-                               local_irq_enable();
+               /* GDT and PDA might already have been allocated if
+                  this is a CPU hotplug re-insertion. */
+               if (gdt == NULL)
+                       gdt = (struct desc_struct *)get_zeroed_page(GFP_KERNEL);
+
+               if (pda == NULL)
+                       pda = kmalloc_node(sizeof(*pda), GFP_KERNEL, cpu_to_node(cpu));
+
+               if (unlikely(!gdt || !pda)) {
+                       free_pages((unsigned long)gdt, 0);
+                       kfree(pda);
+                       return 0;
                }
        }
-old_gdt:
+
+       cpu_gdt_descr->address = (unsigned long)gdt;
+       cpu_pda(cpu) = pda;
+
+       return 1;
+}
+
+/* Initial PDA used by boot CPU */
+struct i386_pda boot_pda = {
+       ._pda = &boot_pda,
+       .cpu_number = 0,
+       .pcurrent = &init_task,
+};
+
+static inline void set_kernel_gs(void)
+{
+       /* Set %gs for this CPU's PDA.  Memory clobber is to create a
+          barrier with respect to any PDA operations, so the compiler
+          doesn't move any before here. */
+       asm volatile ("mov %0, %%gs" : : "r" (__KERNEL_PDA) : "memory");
+}
+
+/* Initialize the CPU's GDT and PDA.  The boot CPU does this for
+   itself, but secondaries find this done for them. */
+__cpuinit int init_gdt(int cpu, struct task_struct *idle)
+{
+       struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
+       struct desc_struct *gdt;
+       struct i386_pda *pda;
+
+       /* For non-boot CPUs, the GDT and PDA should already have been
+          allocated. */
+       if (!alloc_gdt(cpu)) {
+               printk(KERN_CRIT "CPU%d failed to allocate GDT or PDA\n", cpu);
+               return 0;
+       }
+
+       gdt = (struct desc_struct *)cpu_gdt_descr->address;
+       pda = cpu_pda(cpu);
+
+       BUG_ON(gdt == NULL || pda == NULL);
+
        /*
         * Initialize the per-CPU GDT with the boot GDT,
         * and set up the GDT descriptor:
         */
        memcpy(gdt, cpu_gdt_table, GDT_SIZE);
+       cpu_gdt_descr->size = GDT_SIZE - 1;
 
-       /* Set up GDT entry for 16bit stack */
-       *(__u64 *)(&gdt[GDT_ENTRY_ESPFIX_SS]) |=
-               ((((__u64)stk16_off) << 16) & 0x000000ffffff0000ULL) |
-               ((((__u64)stk16_off) << 32) & 0xff00000000000000ULL) |
-               (CPU_16BIT_STACK_SIZE - 1);
+       pack_descriptor((u32 *)&gdt[GDT_ENTRY_PDA].a,
+                       (u32 *)&gdt[GDT_ENTRY_PDA].b,
+                       (unsigned long)pda, sizeof(*pda) - 1,
+                       0x80 | DESCTYPE_S | 0x2, 0); /* present read-write data segment */
 
-       cpu_gdt_descr->size = GDT_SIZE - 1;
-       cpu_gdt_descr->address = (unsigned long)gdt;
+       memset(pda, 0, sizeof(*pda));
+       pda->_pda = pda;
+       pda->cpu_number = cpu;
+       pda->pcurrent = idle;
+
+       return 1;
+}
+
+/* Common CPU init for both boot and secondary CPUs */
+static void __cpuinit _cpu_init(int cpu, struct task_struct *curr)
+{
+       struct tss_struct * t = &per_cpu(init_tss, cpu);
+       struct thread_struct *thread = &curr->thread;
+       struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
 
+       /* Reinit these anyway, even if they've already been done (on
+          the boot CPU, this will transition from the boot gdt+pda to
+          the real ones). */
        load_gdt(cpu_gdt_descr);
+       set_kernel_gs();
+
+       if (cpu_test_and_set(cpu, cpu_initialized)) {
+               printk(KERN_WARNING "CPU#%d already initialized!\n", cpu);
+               for (;;) local_irq_enable();
+       }
+
+       printk(KERN_INFO "Initializing CPU#%d\n", cpu);
+
+       if (cpu_has_vme || cpu_has_tsc || cpu_has_de)
+               clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
+       if (tsc_disable && cpu_has_tsc) {
+               printk(KERN_NOTICE "Disabling TSC...\n");
+               /**** FIX-HPA: DOES THIS REALLY BELONG HERE? ****/
+               clear_bit(X86_FEATURE_TSC, boot_cpu_data.x86_capability);
+               set_in_cr4(X86_CR4_TSD);
+       }
+
        load_idt(&idt_descr);
 
        /*
         * Set up and load the per-CPU TSS and LDT
         */
        atomic_inc(&init_mm.mm_count);
-       current->active_mm = &init_mm;
-       BUG_ON(current->mm);
-       enter_lazy_tlb(&init_mm, current);
+       curr->active_mm = &init_mm;
+       if (curr->mm)
+               BUG();
+       enter_lazy_tlb(&init_mm, curr);
 
        load_esp0(t, thread);
        set_tss_desc(cpu,t);
@@ -682,8 +760,8 @@ old_gdt:
        __set_tss_desc(cpu, GDT_ENTRY_DOUBLEFAULT_TSS, &doublefault_tss);
 #endif
 
-       /* Clear %fs and %gs. */
-       asm volatile ("movl %0, %%fs; movl %0, %%gs" : : "r" (0));
+       /* Clear %fs. */
+       asm volatile ("mov %0, %%fs" : : "r" (0));
 
        /* Clear all 6 debug registers: */
        set_debugreg(0, 0);
@@ -701,6 +779,37 @@ old_gdt:
        mxcsr_feature_mask_init();
 }
 
+/* Entrypoint to initialize secondary CPU */
+void __cpuinit secondary_cpu_init(void)
+{
+       int cpu = smp_processor_id();
+       struct task_struct *curr = current;
+
+       _cpu_init(cpu, curr);
+}
+
+/*
+ * cpu_init() initializes state that is per-CPU. Some data is already
+ * initialized (naturally) in the bootstrap process, such as the GDT
+ * and IDT. We reload them nevertheless, this function acts as a
+ * 'CPU state barrier', nothing should get across.
+ */
+void __cpuinit cpu_init(void)
+{
+       int cpu = smp_processor_id();
+       struct task_struct *curr = current;
+
+       /* Set up the real GDT and PDA, so we can transition from the
+          boot versions. */
+       if (!init_gdt(cpu, curr)) {
+               /* failed to allocate something; not much we can do... */
+               for (;;)
+                       local_irq_enable();
+       }
+
+       _cpu_init(cpu, curr);
+}
+
 #ifdef CONFIG_HOTPLUG_CPU
 void __cpuinit cpu_uninit(void)
 {
index 94a95aa5227e8be03735f56a6ecd5c84638e2be7..56fe26584957f7b9b733ea4e8fcd41b189ab0936 100644 (file)
@@ -107,7 +107,7 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
         * Note that the workaround only should be initialized once...
         */
        c->f00f_bug = 0;
-       if ( c->x86 == 5 ) {
+       if (!paravirt_enabled() && c->x86 == 5) {
                static int f00f_workaround_enabled = 0;
 
                c->f00f_bug = 1;
@@ -195,8 +195,16 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
        if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
                (c->x86 == 0x6 && c->x86_model >= 0x0e))
                set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability);
-}
 
+       if (cpu_has_ds) {
+               unsigned int l1;
+               rdmsr(MSR_IA32_MISC_ENABLE, l1, l2);
+               if (!(l1 & (1<<11)))
+                       set_bit(X86_FEATURE_BTS, c->x86_capability);
+               if (!(l1 & (1<<12)))
+                       set_bit(X86_FEATURE_PEBS, c->x86_capability);
+       }
+}
 
 static unsigned int __cpuinit intel_size_cache(struct cpuinfo_x86 * c, unsigned int size)
 {
index 5c43be47587f5d4b9875e4c45070027cdb829d95..80b4c5d421b1366915028b2002af39cdae851c95 100644 (file)
@@ -480,12 +480,10 @@ static int __cpuinit detect_cache_attributes(unsigned int cpu)
        if (num_cache_leaves == 0)
                return -ENOENT;
 
-       cpuid4_info[cpu] = kmalloc(
+       cpuid4_info[cpu] = kzalloc(
            sizeof(struct _cpuid4_info) * num_cache_leaves, GFP_KERNEL);
        if (unlikely(cpuid4_info[cpu] == NULL))
                return -ENOMEM;
-       memset(cpuid4_info[cpu], 0,
-           sizeof(struct _cpuid4_info) * num_cache_leaves);
 
        oldmask = current->cpus_allowed;
        retval = set_cpus_allowed(current, cpumask_of_cpu(cpu));
@@ -658,17 +656,14 @@ static int __cpuinit cpuid4_cache_sysfs_init(unsigned int cpu)
                return -ENOENT;
 
        /* Allocate all required memory */
-       cache_kobject[cpu] = kmalloc(sizeof(struct kobject), GFP_KERNEL);
+       cache_kobject[cpu] = kzalloc(sizeof(struct kobject), GFP_KERNEL);
        if (unlikely(cache_kobject[cpu] == NULL))
                goto err_out;
-       memset(cache_kobject[cpu], 0, sizeof(struct kobject));
 
-       index_kobject[cpu] = kmalloc(
+       index_kobject[cpu] = kzalloc(
            sizeof(struct _index_kobject ) * num_cache_leaves, GFP_KERNEL);
        if (unlikely(index_kobject[cpu] == NULL))
                goto err_out;
-       memset(index_kobject[cpu], 0,
-           sizeof(struct _index_kobject) * num_cache_leaves);
 
        return 0;
 
index bad8b4420709c3ee984dc89476929ad953e5d7a9..065005c3f16879c40fe82e59a53ebc8d95f240c8 100644 (file)
@@ -116,7 +116,6 @@ static __cpuinit int thermal_throttle_add_dev(struct sys_device *sys_dev)
        return sysfs_create_group(&sys_dev->kobj, &thermal_throttle_attr_group);
 }
 
-#ifdef CONFIG_HOTPLUG_CPU
 static __cpuinit void thermal_throttle_remove_dev(struct sys_device *sys_dev)
 {
        return sysfs_remove_group(&sys_dev->kobj, &thermal_throttle_attr_group);
@@ -153,7 +152,6 @@ static struct notifier_block thermal_throttle_cpu_notifier =
 {
        .notifier_call = thermal_throttle_cpu_callback,
 };
-#endif /* CONFIG_HOTPLUG_CPU */
 
 static __init int thermal_throttle_init_device(void)
 {
index a25b701ab84e4e83872907ce922149116d8f95c4..191fc05336494bcb30c38c1a3e76d452030cd5d7 100644 (file)
@@ -1,5 +1,3 @@
 obj-y          := main.o if.o generic.o state.o
-obj-y          += amd.o
-obj-y          += cyrix.o
-obj-y          += centaur.o
+obj-$(CONFIG_X86_32) += amd.o cyrix.o centaur.o
 
index 1a1e04b6fd0044c05b30e44bee18648f68e076c0..0949cdbf848afcceff5e997f12ac882075c45876 100644 (file)
@@ -7,7 +7,7 @@
 
 static void
 amd_get_mtrr(unsigned int reg, unsigned long *base,
-            unsigned int *size, mtrr_type * type)
+            unsigned long *size, mtrr_type * type)
 {
        unsigned long low, high;
 
index 33f00ac314ef3e1e51b4488be696ac3133b3ad28..cb9aa3a7a7abe4ae37ce8f7cbc0e2c29b62159a3 100644 (file)
@@ -17,7 +17,7 @@ static u8 centaur_mcr_type;   /* 0 for winchip, 1 for winchip2 */
  */
 
 static int
-centaur_get_free_region(unsigned long base, unsigned long size)
+centaur_get_free_region(unsigned long base, unsigned long size, int replace_reg)
 /*  [SUMMARY] Get a free MTRR.
     <base> The starting (base) address of the region.
     <size> The size (in bytes) of the region.
@@ -26,10 +26,11 @@ centaur_get_free_region(unsigned long base, unsigned long size)
 {
        int i, max;
        mtrr_type ltype;
-       unsigned long lbase;
-       unsigned int lsize;
+       unsigned long lbase, lsize;
 
        max = num_var_ranges;
+       if (replace_reg >= 0 && replace_reg < max)
+               return replace_reg;
        for (i = 0; i < max; ++i) {
                if (centaur_mcr_reserved & (1 << i))
                        continue;
@@ -49,7 +50,7 @@ mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi)
 
 static void
 centaur_get_mcr(unsigned int reg, unsigned long *base,
-               unsigned int *size, mtrr_type * type)
+               unsigned long *size, mtrr_type * type)
 {
        *base = centaur_mcr[reg].high >> PAGE_SHIFT;
        *size = -(centaur_mcr[reg].low & 0xfffff000) >> PAGE_SHIFT;
index 9027a987006b93890f17363f2d4fac4c749e7f23..0737a596db434d7e6f9274c7447e3b8daf81e07c 100644 (file)
@@ -9,7 +9,7 @@ int arr3_protected;
 
 static void
 cyrix_get_arr(unsigned int reg, unsigned long *base,
-             unsigned int *size, mtrr_type * type)
+             unsigned long *size, mtrr_type * type)
 {
        unsigned long flags;
        unsigned char arr, ccr3, rcr, shift;
@@ -77,7 +77,7 @@ cyrix_get_arr(unsigned int reg, unsigned long *base,
 }
 
 static int
-cyrix_get_free_region(unsigned long base, unsigned long size)
+cyrix_get_free_region(unsigned long base, unsigned long size, int replace_reg)
 /*  [SUMMARY] Get a free ARR.
     <base> The starting (base) address of the region.
     <size> The size (in bytes) of the region.
@@ -86,9 +86,24 @@ cyrix_get_free_region(unsigned long base, unsigned long size)
 {
        int i;
        mtrr_type ltype;
-       unsigned long lbase;
-       unsigned int  lsize;
+       unsigned long lbase, lsize;
 
+       switch (replace_reg) {
+       case 7:
+               if (size < 0x40)
+                       break;
+       case 6:
+       case 5:
+       case 4:
+               return replace_reg;
+       case 3:
+               if (arr3_protected)
+                       break;
+       case 2:
+       case 1:
+       case 0:
+               return replace_reg;
+       }
        /* If we are to set up a region >32M then look at ARR7 immediately */
        if (size > 0x2000) {
                cyrix_get_arr(7, &lbase, &lsize, &ltype);
@@ -214,7 +229,7 @@ static void cyrix_set_arr(unsigned int reg, unsigned long base,
 
 typedef struct {
        unsigned long base;
-       unsigned int size;
+       unsigned long size;
        mtrr_type type;
 } arr_state_t;
 
index 0b61eed8bbd819cb3f4d71a59feec3376acec5c6..f77fc53db654655ccf5477e16c3750012a1a1230 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/mm.h>
+#include <linux/module.h>
 #include <asm/io.h>
 #include <asm/mtrr.h>
 #include <asm/msr.h>
@@ -15,12 +16,19 @@ struct mtrr_state {
        struct mtrr_var_range *var_ranges;
        mtrr_type fixed_ranges[NUM_FIXED_RANGES];
        unsigned char enabled;
+       unsigned char have_fixed;
        mtrr_type def_type;
 };
 
 static unsigned long smp_changes_mask;
 static struct mtrr_state mtrr_state = {};
 
+#undef MODULE_PARAM_PREFIX
+#define MODULE_PARAM_PREFIX "mtrr."
+
+static __initdata int mtrr_show;
+module_param_named(show, mtrr_show, bool, 0);
+
 /*  Get the MSR pair relating to a var range  */
 static void __init
 get_mtrr_var_range(unsigned int index, struct mtrr_var_range *vr)
@@ -43,6 +51,14 @@ get_fixed_ranges(mtrr_type * frs)
                rdmsr(MTRRfix4K_C0000_MSR + i, p[6 + i * 2], p[7 + i * 2]);
 }
 
+static void __init print_fixed(unsigned base, unsigned step, const mtrr_type*types)
+{
+       unsigned i;
+
+       for (i = 0; i < 8; ++i, ++types, base += step)
+               printk(KERN_INFO "MTRR %05X-%05X %s\n", base, base + step - 1, mtrr_attrib_to_str(*types));
+}
+
 /*  Grab all of the MTRR state for this CPU into *state  */
 void __init get_mtrr_state(void)
 {
@@ -58,13 +74,49 @@ void __init get_mtrr_state(void)
        } 
        vrs = mtrr_state.var_ranges;
 
+       rdmsr(MTRRcap_MSR, lo, dummy);
+       mtrr_state.have_fixed = (lo >> 8) & 1;
+
        for (i = 0; i < num_var_ranges; i++)
                get_mtrr_var_range(i, &vrs[i]);
-       get_fixed_ranges(mtrr_state.fixed_ranges);
+       if (mtrr_state.have_fixed)
+               get_fixed_ranges(mtrr_state.fixed_ranges);
 
        rdmsr(MTRRdefType_MSR, lo, dummy);
        mtrr_state.def_type = (lo & 0xff);
        mtrr_state.enabled = (lo & 0xc00) >> 10;
+
+       if (mtrr_show) {
+               int high_width;
+
+               printk(KERN_INFO "MTRR default type: %s\n", mtrr_attrib_to_str(mtrr_state.def_type));
+               if (mtrr_state.have_fixed) {
+                       printk(KERN_INFO "MTRR fixed ranges %sabled:\n",
+                              mtrr_state.enabled & 1 ? "en" : "dis");
+                       print_fixed(0x00000, 0x10000, mtrr_state.fixed_ranges + 0);
+                       for (i = 0; i < 2; ++i)
+                               print_fixed(0x80000 + i * 0x20000, 0x04000, mtrr_state.fixed_ranges + (i + 1) * 8);
+                       for (i = 0; i < 8; ++i)
+                               print_fixed(0xC0000 + i * 0x08000, 0x01000, mtrr_state.fixed_ranges + (i + 3) * 8);
+               }
+               printk(KERN_INFO "MTRR variable ranges %sabled:\n",
+                      mtrr_state.enabled & 2 ? "en" : "dis");
+               high_width = ((size_or_mask ? ffs(size_or_mask) - 1 : 32) - (32 - PAGE_SHIFT) + 3) / 4;
+               for (i = 0; i < num_var_ranges; ++i) {
+                       if (mtrr_state.var_ranges[i].mask_lo & (1 << 11))
+                               printk(KERN_INFO "MTRR %u base %0*X%05X000 mask %0*X%05X000 %s\n",
+                                      i,
+                                      high_width,
+                                      mtrr_state.var_ranges[i].base_hi,
+                                      mtrr_state.var_ranges[i].base_lo >> 12,
+                                      high_width,
+                                      mtrr_state.var_ranges[i].mask_hi,
+                                      mtrr_state.var_ranges[i].mask_lo >> 12,
+                                      mtrr_attrib_to_str(mtrr_state.var_ranges[i].base_lo & 0xff));
+                       else
+                               printk(KERN_INFO "MTRR %u disabled\n", i);
+               }
+       }
 }
 
 /*  Some BIOS's are fucked and don't set all MTRRs the same!  */
@@ -95,7 +147,7 @@ void mtrr_wrmsr(unsigned msr, unsigned a, unsigned b)
                        smp_processor_id(), msr, a, b);
 }
 
-int generic_get_free_region(unsigned long base, unsigned long size)
+int generic_get_free_region(unsigned long base, unsigned long size, int replace_reg)
 /*  [SUMMARY] Get a free MTRR.
     <base> The starting (base) address of the region.
     <size> The size (in bytes) of the region.
@@ -104,10 +156,11 @@ int generic_get_free_region(unsigned long base, unsigned long size)
 {
        int i, max;
        mtrr_type ltype;
-       unsigned long lbase;
-       unsigned lsize;
+       unsigned long lbase, lsize;
 
        max = num_var_ranges;
+       if (replace_reg >= 0 && replace_reg < max)
+               return replace_reg;
        for (i = 0; i < max; ++i) {
                mtrr_if->get(i, &lbase, &lsize, &ltype);
                if (lsize == 0)
@@ -117,7 +170,7 @@ int generic_get_free_region(unsigned long base, unsigned long size)
 }
 
 static void generic_get_mtrr(unsigned int reg, unsigned long *base,
-                            unsigned int *size, mtrr_type * type)
+                            unsigned long *size, mtrr_type *type)
 {
        unsigned int mask_lo, mask_hi, base_lo, base_hi;
 
@@ -202,7 +255,9 @@ static int set_mtrr_var_ranges(unsigned int index, struct mtrr_var_range *vr)
        return changed;
 }
 
-static unsigned long set_mtrr_state(u32 deftype_lo, u32 deftype_hi)
+static u32 deftype_lo, deftype_hi;
+
+static unsigned long set_mtrr_state(void)
 /*  [SUMMARY] Set the MTRR state for this CPU.
     <state> The MTRR state information to read.
     <ctxt> Some relevant CPU context.
@@ -217,14 +272,14 @@ static unsigned long set_mtrr_state(u32 deftype_lo, u32 deftype_hi)
                if (set_mtrr_var_ranges(i, &mtrr_state.var_ranges[i]))
                        change_mask |= MTRR_CHANGE_MASK_VARIABLE;
 
-       if (set_fixed_ranges(mtrr_state.fixed_ranges))
+       if (mtrr_state.have_fixed && set_fixed_ranges(mtrr_state.fixed_ranges))
                change_mask |= MTRR_CHANGE_MASK_FIXED;
 
        /*  Set_mtrr_restore restores the old value of MTRRdefType,
           so to set it we fiddle with the saved value  */
        if ((deftype_lo & 0xff) != mtrr_state.def_type
            || ((deftype_lo & 0xc00) >> 10) != mtrr_state.enabled) {
-               deftype_lo |= (mtrr_state.def_type | mtrr_state.enabled << 10);
+               deftype_lo = (deftype_lo & ~0xcff) | mtrr_state.def_type | (mtrr_state.enabled << 10);
                change_mask |= MTRR_CHANGE_MASK_DEFTYPE;
        }
 
@@ -233,7 +288,6 @@ static unsigned long set_mtrr_state(u32 deftype_lo, u32 deftype_hi)
 
 
 static unsigned long cr4 = 0;
-static u32 deftype_lo, deftype_hi;
 static DEFINE_SPINLOCK(set_atomicity_lock);
 
 /*
@@ -271,7 +325,7 @@ static void prepare_set(void) __acquires(set_atomicity_lock)
        rdmsr(MTRRdefType_MSR, deftype_lo, deftype_hi);
 
        /*  Disable MTRRs, and set the default type to uncached  */
-       mtrr_wrmsr(MTRRdefType_MSR, deftype_lo & 0xf300UL, deftype_hi);
+       mtrr_wrmsr(MTRRdefType_MSR, deftype_lo & ~0xcff, deftype_hi);
 }
 
 static void post_set(void) __releases(set_atomicity_lock)
@@ -300,7 +354,7 @@ static void generic_set_all(void)
        prepare_set();
 
        /* Actually set the state */
-       mask = set_mtrr_state(deftype_lo,deftype_hi);
+       mask = set_mtrr_state();
 
        post_set();
        local_irq_restore(flags);
@@ -366,7 +420,7 @@ int generic_validate_add_page(unsigned long base, unsigned long size, unsigned i
                        printk(KERN_WARNING "mtrr: base(0x%lx000) is not 4 MiB aligned\n", base);
                        return -EINVAL;
                }
-               if (!(base + size < 0x70000000 || base > 0x7003FFFF) &&
+               if (!(base + size < 0x70000 || base > 0x7003F) &&
                    (type == MTRR_TYPE_WRCOMB
                     || type == MTRR_TYPE_WRBACK)) {
                        printk(KERN_WARNING "mtrr: writable mtrr between 0x70000000 and 0x7003FFFF may hang the CPU.\n");
index 5ac051bb9d55e36b4daf4a1a06e072992728d18e..5ae1705eafa6281adcfc065702a0d2743575d5e2 100644 (file)
@@ -17,7 +17,7 @@ extern unsigned int *usage_table;
 
 #define FILE_FCOUNT(f) (((struct seq_file *)((f)->private_data))->private)
 
-static char *mtrr_strings[MTRR_NUM_TYPES] =
+static const char *const mtrr_strings[MTRR_NUM_TYPES] =
 {
     "uncachable",               /* 0 */
     "write-combining",          /* 1 */
@@ -28,7 +28,7 @@ static char *mtrr_strings[MTRR_NUM_TYPES] =
     "write-back",               /* 6 */
 };
 
-char *mtrr_attrib_to_str(int x)
+const char *mtrr_attrib_to_str(int x)
 {
        return (x <= 6) ? mtrr_strings[x] : "?";
 }
@@ -44,10 +44,9 @@ mtrr_file_add(unsigned long base, unsigned long size,
 
        max = num_var_ranges;
        if (fcount == NULL) {
-               fcount = kmalloc(max * sizeof *fcount, GFP_KERNEL);
+               fcount = kzalloc(max * sizeof *fcount, GFP_KERNEL);
                if (!fcount)
                        return -ENOMEM;
-               memset(fcount, 0, max * sizeof *fcount);
                FILE_FCOUNT(file) = fcount;
        }
        if (!page) {
@@ -155,6 +154,7 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg)
 {
        int err = 0;
        mtrr_type type;
+       unsigned long size;
        struct mtrr_sentry sentry;
        struct mtrr_gentry gentry;
        void __user *arg = (void __user *) __arg;
@@ -235,15 +235,15 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg)
        case MTRRIOC_GET_ENTRY:
                if (gentry.regnum >= num_var_ranges)
                        return -EINVAL;
-               mtrr_if->get(gentry.regnum, &gentry.base, &gentry.size, &type);
+               mtrr_if->get(gentry.regnum, &gentry.base, &size, &type);
 
                /* Hide entries that go above 4GB */
-               if (gentry.base + gentry.size > 0x100000
-                   || gentry.size == 0x100000)
+               if (gentry.base + size - 1 >= (1UL << (8 * sizeof(gentry.size) - PAGE_SHIFT))
+                   || size >= (1UL << (8 * sizeof(gentry.size) - PAGE_SHIFT)))
                        gentry.base = gentry.size = gentry.type = 0;
                else {
                        gentry.base <<= PAGE_SHIFT;
-                       gentry.size <<= PAGE_SHIFT;
+                       gentry.size = size << PAGE_SHIFT;
                        gentry.type = type;
                }
 
@@ -273,8 +273,14 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg)
        case MTRRIOC_GET_PAGE_ENTRY:
                if (gentry.regnum >= num_var_ranges)
                        return -EINVAL;
-               mtrr_if->get(gentry.regnum, &gentry.base, &gentry.size, &type);
-               gentry.type = type;
+               mtrr_if->get(gentry.regnum, &gentry.base, &size, &type);
+               /* Hide entries that would overflow */
+               if (size != (__typeof__(gentry.size))size)
+                       gentry.base = gentry.size = gentry.type = 0;
+               else {
+                       gentry.size = size;
+                       gentry.type = type;
+               }
                break;
        }
 
@@ -353,8 +359,7 @@ static int mtrr_seq_show(struct seq_file *seq, void *offset)
        char factor;
        int i, max, len;
        mtrr_type type;
-       unsigned long base;
-       unsigned int size;
+       unsigned long base, size;
 
        len = 0;
        max = num_var_ranges;
@@ -373,7 +378,7 @@ static int mtrr_seq_show(struct seq_file *seq, void *offset)
                        }
                        /* RED-PEN: base can be > 32bit */ 
                        len += seq_printf(seq, 
-                                  "reg%02i: base=0x%05lx000 (%4liMB), size=%4i%cB: %s, count=%d\n",
+                                  "reg%02i: base=0x%05lx000 (%4luMB), size=%4lu%cB: %s, count=%d\n",
                             i, base, base >> (20 - PAGE_SHIFT), size, factor,
                             mtrr_attrib_to_str(type), usage_table[i]);
                }
index fff90bda473323a7fd0364d6db35475bbb862cd8..16bb7ea87145411e9ee63f1dd31b982a4f7ed816 100644 (file)
@@ -59,7 +59,11 @@ struct mtrr_ops * mtrr_if = NULL;
 static void set_mtrr(unsigned int reg, unsigned long base,
                     unsigned long size, mtrr_type type);
 
+#ifndef CONFIG_X86_64
 extern int arr3_protected;
+#else
+#define arr3_protected 0
+#endif
 
 void set_mtrr_ops(struct mtrr_ops * ops)
 {
@@ -168,6 +172,13 @@ static void ipi_handler(void *info)
 
 #endif
 
+static inline int types_compatible(mtrr_type type1, mtrr_type type2) {
+       return type1 == MTRR_TYPE_UNCACHABLE ||
+              type2 == MTRR_TYPE_UNCACHABLE ||
+              (type1 == MTRR_TYPE_WRTHROUGH && type2 == MTRR_TYPE_WRBACK) ||
+              (type1 == MTRR_TYPE_WRBACK && type2 == MTRR_TYPE_WRTHROUGH);
+}
+
 /**
  * set_mtrr - update mtrrs on all processors
  * @reg:       mtrr in question
@@ -263,8 +274,8 @@ static void set_mtrr(unsigned int reg, unsigned long base,
 
 /**
  *     mtrr_add_page - Add a memory type region
- *     @base: Physical base address of region in pages (4 KB)
- *     @size: Physical size of region in pages (4 KB)
+ *     @base: Physical base address of region in pages (in units of 4 kB!)
+ *     @size: Physical size of region in pages (4 kB)
  *     @type: Type of MTRR desired
  *     @increment: If this is true do usage counting on the region
  *
@@ -300,11 +311,9 @@ static void set_mtrr(unsigned int reg, unsigned long base,
 int mtrr_add_page(unsigned long base, unsigned long size, 
                  unsigned int type, char increment)
 {
-       int i;
+       int i, replace, error;
        mtrr_type ltype;
-       unsigned long lbase;
-       unsigned int lsize;
-       int error;
+       unsigned long lbase, lsize;
 
        if (!mtrr_if)
                return -ENXIO;
@@ -324,12 +333,18 @@ int mtrr_add_page(unsigned long base, unsigned long size,
                return -ENOSYS;
        }
 
+       if (!size) {
+               printk(KERN_WARNING "mtrr: zero sized request\n");
+               return -EINVAL;
+       }
+
        if (base & size_or_mask || size & size_or_mask) {
                printk(KERN_WARNING "mtrr: base or size exceeds the MTRR width\n");
                return -EINVAL;
        }
 
        error = -EINVAL;
+       replace = -1;
 
        /* No CPU hotplug when we change MTRR entries */
        lock_cpu_hotplug();
@@ -337,21 +352,28 @@ int mtrr_add_page(unsigned long base, unsigned long size,
        mutex_lock(&mtrr_mutex);
        for (i = 0; i < num_var_ranges; ++i) {
                mtrr_if->get(i, &lbase, &lsize, &ltype);
-               if (base >= lbase + lsize)
-                       continue;
-               if ((base < lbase) && (base + size <= lbase))
+               if (!lsize || base > lbase + lsize - 1 || base + size - 1 < lbase)
                        continue;
                /*  At this point we know there is some kind of overlap/enclosure  */
-               if ((base < lbase) || (base + size > lbase + lsize)) {
+               if (base < lbase || base + size - 1 > lbase + lsize - 1) {
+                       if (base <= lbase && base + size - 1 >= lbase + lsize - 1) {
+                               /*  New region encloses an existing region  */
+                               if (type == ltype) {
+                                       replace = replace == -1 ? i : -2;
+                                       continue;
+                               }
+                               else if (types_compatible(type, ltype))
+                                       continue;
+                       }
                        printk(KERN_WARNING
                               "mtrr: 0x%lx000,0x%lx000 overlaps existing"
-                              " 0x%lx000,0x%x000\n", base, size, lbase,
+                              " 0x%lx000,0x%lx000\n", base, size, lbase,
                               lsize);
                        goto out;
                }
                /*  New region is enclosed by an existing region  */
                if (ltype != type) {
-                       if (type == MTRR_TYPE_UNCACHABLE)
+                       if (types_compatible(type, ltype))
                                continue;
                        printk (KERN_WARNING "mtrr: type mismatch for %lx000,%lx000 old: %s new: %s\n",
                             base, size, mtrr_attrib_to_str(ltype),
@@ -364,10 +386,18 @@ int mtrr_add_page(unsigned long base, unsigned long size,
                goto out;
        }
        /*  Search for an empty MTRR  */
-       i = mtrr_if->get_free_region(base, size);
+       i = mtrr_if->get_free_region(base, size, replace);
        if (i >= 0) {
                set_mtrr(i, base, size, type);
-               usage_table[i] = 1;
+               if (likely(replace < 0))
+                       usage_table[i] = 1;
+               else {
+                       usage_table[i] = usage_table[replace] + !!increment;
+                       if (unlikely(replace != i)) {
+                               set_mtrr(replace, 0, 0, 0);
+                               usage_table[replace] = 0;
+                       }
+               }
        } else
                printk(KERN_INFO "mtrr: no more MTRRs available\n");
        error = i;
@@ -455,8 +485,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
 {
        int i, max;
        mtrr_type ltype;
-       unsigned long lbase;
-       unsigned int lsize;
+       unsigned long lbase, lsize;
        int error = -EINVAL;
 
        if (!mtrr_if)
@@ -544,9 +573,11 @@ extern void centaur_init_mtrr(void);
 
 static void __init init_ifs(void)
 {
+#ifndef CONFIG_X86_64
        amd_init_mtrr();
        cyrix_init_mtrr();
        centaur_init_mtrr();
+#endif
 }
 
 /* The suspend/resume methods are only for CPU without MTRR. CPU using generic
@@ -555,7 +586,7 @@ static void __init init_ifs(void)
 struct mtrr_value {
        mtrr_type       ltype;
        unsigned long   lbase;
-       unsigned int    lsize;
+       unsigned long   lsize;
 };
 
 static struct mtrr_value * mtrr_state;
@@ -565,10 +596,8 @@ static int mtrr_save(struct sys_device * sysdev, pm_message_t state)
        int i;
        int size = num_var_ranges * sizeof(struct mtrr_value);
 
-       mtrr_state = kmalloc(size,GFP_ATOMIC);
-       if (mtrr_state)
-               memset(mtrr_state,0,size);
-       else
+       mtrr_state = kzalloc(size,GFP_ATOMIC);
+       if (!mtrr_state)
                return -ENOMEM;
 
        for (i = 0; i < num_var_ranges; i++) {
index 99c9f2682041fad9faafa11a6b63d87b319df9f4..d61ea9db6cfebfd908ca2184621979bc2faf82ab 100644 (file)
@@ -43,15 +43,16 @@ struct mtrr_ops {
        void    (*set_all)(void);
 
        void    (*get)(unsigned int reg, unsigned long *base,
-                      unsigned int *size, mtrr_type * type);
-       int     (*get_free_region) (unsigned long base, unsigned long size);
-
+                      unsigned long *size, mtrr_type * type);
+       int     (*get_free_region)(unsigned long base, unsigned long size,
+                                  int replace_reg);
        int     (*validate_add_page)(unsigned long base, unsigned long size,
                                     unsigned int type);
        int     (*have_wrcomb)(void);
 };
 
-extern int generic_get_free_region(unsigned long base, unsigned long size);
+extern int generic_get_free_region(unsigned long base, unsigned long size,
+                                  int replace_reg);
 extern int generic_validate_add_page(unsigned long base, unsigned long size,
                                     unsigned int type);
 
@@ -62,17 +63,17 @@ extern int positive_have_wrcomb(void);
 /* library functions for processor-specific routines */
 struct set_mtrr_context {
        unsigned long flags;
-       unsigned long deftype_lo;
-       unsigned long deftype_hi;
        unsigned long cr4val;
-       unsigned long ccr3;
+       u32 deftype_lo;
+       u32 deftype_hi;
+       u32 ccr3;
 };
 
 struct mtrr_var_range {
-       unsigned long base_lo;
-       unsigned long base_hi;
-       unsigned long mask_lo;
-       unsigned long mask_hi;
+       u32 base_lo;
+       u32 base_hi;
+       u32 mask_lo;
+       u32 mask_hi;
 };
 
 void set_mtrr_done(struct set_mtrr_context *ctxt);
@@ -92,6 +93,6 @@ extern struct mtrr_ops * mtrr_if;
 extern unsigned int num_var_ranges;
 
 void mtrr_state_warn(void);
-char *mtrr_attrib_to_str(int x);
+const char *mtrr_attrib_to_str(int x);
 void mtrr_wrmsr(unsigned, unsigned, unsigned);
 
index 76aac088a323de6962de5aeb82ffa7911c8d8265..6624d8583c428a20694641aabba7f0ec6ce9308c 100644 (file)
@@ -152,9 +152,10 @@ static int show_cpuinfo(struct seq_file *m, void *v)
                                seq_printf(m, " [%d]", i);
                }
 
-       seq_printf(m, "\nbogomips\t: %lu.%02lu\n\n",
+       seq_printf(m, "\nbogomips\t: %lu.%02lu\n",
                     c->loops_per_jiffy/(500000/HZ),
                     (c->loops_per_jiffy/(5000/HZ)) % 100);
+       seq_printf(m, "clflush size\t: %u\n\n", c->x86_clflush_size);
 
        return 0;
 }
index ab0c327e79dcc3ffde57dce2bfc50b97b9ed69ba..51130b39cd2e8de87f8b2269f150b4d6692018cb 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/major.h>
 #include <linux/fs.h>
 #include <linux/smp_lock.h>
-#include <linux/fs.h>
 #include <linux/device.h>
 #include <linux/cpu.h>
 #include <linux/notifier.h>
@@ -117,7 +116,7 @@ static ssize_t cpuid_read(struct file *file, char __user *buf,
        char __user *tmp = buf;
        u32 data[4];
        u32 reg = *ppos;
-       int cpu = iminor(file->f_dentry->d_inode);
+       int cpu = iminor(file->f_path.dentry->d_inode);
 
        if (count % 16)
                return -EINVAL; /* Invalid chunk size */
@@ -135,7 +134,7 @@ static ssize_t cpuid_read(struct file *file, char __user *buf,
 
 static int cpuid_open(struct inode *inode, struct file *file)
 {
-       unsigned int cpu = iminor(file->f_dentry->d_inode);
+       unsigned int cpu = iminor(file->f_path.dentry->d_inode);
        struct cpuinfo_x86 *c = &(cpu_data)[cpu];
 
        if (cpu >= NR_CPUS || !cpu_online(cpu))
@@ -167,7 +166,6 @@ static int cpuid_device_create(int i)
        return err;
 }
 
-#ifdef CONFIG_HOTPLUG_CPU
 static int cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
 {
        unsigned int cpu = (unsigned long)hcpu;
@@ -187,7 +185,6 @@ static struct notifier_block __cpuinitdata cpuid_class_cpu_notifier =
 {
        .notifier_call = cpuid_class_cpu_callback,
 };
-#endif /* !CONFIG_HOTPLUG_CPU */
 
 static int __init cpuid_init(void)
 {
index 144b432889655aa77a6d8196ac724e383ae402ec..a5e0e990ea9539eaff5c80105af16ad8335add62 100644 (file)
 /* This keeps a track of which one is crashing cpu. */
 static int crashing_cpu;
 
-static u32 *append_elf_note(u32 *buf, char *name, unsigned type, void *data,
-                                                              size_t data_len)
-{
-       struct elf_note note;
-
-       note.n_namesz = strlen(name) + 1;
-       note.n_descsz = data_len;
-       note.n_type   = type;
-       memcpy(buf, &note, sizeof(note));
-       buf += (sizeof(note) +3)/4;
-       memcpy(buf, name, note.n_namesz);
-       buf += (note.n_namesz + 3)/4;
-       memcpy(buf, data, note.n_descsz);
-       buf += (note.n_descsz + 3)/4;
-
-       return buf;
-}
-
-static void final_note(u32 *buf)
-{
-       struct elf_note note;
-
-       note.n_namesz = 0;
-       note.n_descsz = 0;
-       note.n_type   = 0;
-       memcpy(buf, &note, sizeof(note));
-}
-
-static void crash_save_this_cpu(struct pt_regs *regs, int cpu)
-{
-       struct elf_prstatus prstatus;
-       u32 *buf;
-
-       if ((cpu < 0) || (cpu >= NR_CPUS))
-               return;
-
-       /* Using ELF notes here is opportunistic.
-        * I need a well defined structure format
-        * for the data I pass, and I need tags
-        * on the data to indicate what information I have
-        * squirrelled away.  ELF notes happen to provide
-        * all of that, so there is no need to invent something new.
-        */
-       buf = (u32*)per_cpu_ptr(crash_notes, cpu);
-       if (!buf)
-               return;
-       memset(&prstatus, 0, sizeof(prstatus));
-       prstatus.pr_pid = current->pid;
-       elf_core_copy_regs(&prstatus.pr_reg, regs);
-       buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
-                               sizeof(prstatus));
-       final_note(buf);
-}
-
-static void crash_save_self(struct pt_regs *regs)
-{
-       int cpu;
-
-       cpu = safe_smp_processor_id();
-       crash_save_this_cpu(regs, cpu);
-}
-
 #if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC)
 static atomic_t waiting_for_crash_ipi;
 
@@ -121,7 +59,7 @@ static int crash_nmi_callback(struct notifier_block *self,
                crash_fixup_ss_esp(&fixed_regs, regs);
                regs = &fixed_regs;
        }
-       crash_save_this_cpu(regs, cpu);
+       crash_save_cpu(regs, cpu);
        disable_local_APIC();
        atomic_dec(&waiting_for_crash_ipi);
        /* Assume hlt works */
@@ -195,5 +133,5 @@ void machine_crash_shutdown(struct pt_regs *regs)
 #if defined(CONFIG_X86_IO_APIC)
        disable_IO_APIC();
 #endif
-       crash_save_self(regs);
+       crash_save_cpu(regs, safe_smp_processor_id());
 }
diff --git a/arch/i386/kernel/e820.c b/arch/i386/kernel/e820.c
new file mode 100644 (file)
index 0000000..2f7d0a9
--- /dev/null
@@ -0,0 +1,894 @@
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/bootmem.h>
+#include <linux/ioport.h>
+#include <linux/string.h>
+#include <linux/kexec.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/efi.h>
+#include <linux/pfn.h>
+#include <linux/uaccess.h>
+
+#include <asm/pgtable.h>
+#include <asm/page.h>
+#include <asm/e820.h>
+
+#ifdef CONFIG_EFI
+int efi_enabled = 0;
+EXPORT_SYMBOL(efi_enabled);
+#endif
+
+struct e820map e820;
+struct change_member {
+       struct e820entry *pbios; /* pointer to original bios entry */
+       unsigned long long addr; /* address for this change point */
+};
+static struct change_member change_point_list[2*E820MAX] __initdata;
+static struct change_member *change_point[2*E820MAX] __initdata;
+static struct e820entry *overlap_list[E820MAX] __initdata;
+static struct e820entry new_bios[E820MAX] __initdata;
+/* For PCI or other memory-mapped resources */
+unsigned long pci_mem_start = 0x10000000;
+#ifdef CONFIG_PCI
+EXPORT_SYMBOL(pci_mem_start);
+#endif
+extern int user_defined_memmap;
+struct resource data_resource = {
+       .name   = "Kernel data",
+       .start  = 0,
+       .end    = 0,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_MEM
+};
+
+struct resource code_resource = {
+       .name   = "Kernel code",
+       .start  = 0,
+       .end    = 0,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_MEM
+};
+
+static struct resource system_rom_resource = {
+       .name   = "System ROM",
+       .start  = 0xf0000,
+       .end    = 0xfffff,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
+};
+
+static struct resource extension_rom_resource = {
+       .name   = "Extension ROM",
+       .start  = 0xe0000,
+       .end    = 0xeffff,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
+};
+
+static struct resource adapter_rom_resources[] = { {
+       .name   = "Adapter ROM",
+       .start  = 0xc8000,
+       .end    = 0,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
+}, {
+       .name   = "Adapter ROM",
+       .start  = 0,
+       .end    = 0,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
+}, {
+       .name   = "Adapter ROM",
+       .start  = 0,
+       .end    = 0,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
+}, {
+       .name   = "Adapter ROM",
+       .start  = 0,
+       .end    = 0,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
+}, {
+       .name   = "Adapter ROM",
+       .start  = 0,
+       .end    = 0,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
+}, {
+       .name   = "Adapter ROM",
+       .start  = 0,
+       .end    = 0,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
+} };
+
+static struct resource video_rom_resource = {
+       .name   = "Video ROM",
+       .start  = 0xc0000,
+       .end    = 0xc7fff,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
+};
+
+static struct resource video_ram_resource = {
+       .name   = "Video RAM area",
+       .start  = 0xa0000,
+       .end    = 0xbffff,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_MEM
+};
+
+static struct resource standard_io_resources[] = { {
+       .name   = "dma1",
+       .start  = 0x0000,
+       .end    = 0x001f,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
+}, {
+       .name   = "pic1",
+       .start  = 0x0020,
+       .end    = 0x0021,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
+}, {
+       .name   = "timer0",
+       .start  = 0x0040,
+       .end    = 0x0043,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
+}, {
+       .name   = "timer1",
+       .start  = 0x0050,
+       .end    = 0x0053,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
+}, {
+       .name   = "keyboard",
+       .start  = 0x0060,
+       .end    = 0x006f,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
+}, {
+       .name   = "dma page reg",
+       .start  = 0x0080,
+       .end    = 0x008f,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
+}, {
+       .name   = "pic2",
+       .start  = 0x00a0,
+       .end    = 0x00a1,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
+}, {
+       .name   = "dma2",
+       .start  = 0x00c0,
+       .end    = 0x00df,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
+}, {
+       .name   = "fpu",
+       .start  = 0x00f0,
+       .end    = 0x00ff,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
+} };
+
+static int romsignature(const unsigned char *x)
+{
+       unsigned short sig;
+       int ret = 0;
+       if (probe_kernel_address((const unsigned short *)x, sig) == 0)
+               ret = (sig == 0xaa55);
+       return ret;
+}
+
+static int __init romchecksum(unsigned char *rom, unsigned long length)
+{
+       unsigned char *p, sum = 0;
+
+       for (p = rom; p < rom + length; p++)
+               sum += *p;
+       return sum == 0;
+}
+
+static void __init probe_roms(void)
+{
+       unsigned long start, length, upper;
+       unsigned char *rom;
+       int           i;
+
+       /* video rom */
+       upper = adapter_rom_resources[0].start;
+       for (start = video_rom_resource.start; start < upper; start += 2048) {
+               rom = isa_bus_to_virt(start);
+               if (!romsignature(rom))
+                       continue;
+
+               video_rom_resource.start = start;
+
+               /* 0 < length <= 0x7f * 512, historically */
+               length = rom[2] * 512;
+
+               /* if checksum okay, trust length byte */
+               if (length && romchecksum(rom, length))
+                       video_rom_resource.end = start + length - 1;
+
+               request_resource(&iomem_resource, &video_rom_resource);
+               break;
+       }
+
+       start = (video_rom_resource.end + 1 + 2047) & ~2047UL;
+       if (start < upper)
+               start = upper;
+
+       /* system rom */
+       request_resource(&iomem_resource, &system_rom_resource);
+       upper = system_rom_resource.start;
+
+       /* check for extension rom (ignore length byte!) */
+       rom = isa_bus_to_virt(extension_rom_resource.start);
+       if (romsignature(rom)) {
+               length = extension_rom_resource.end - extension_rom_resource.start + 1;
+               if (romchecksum(rom, length)) {
+                       request_resource(&iomem_resource, &extension_rom_resource);
+                       upper = extension_rom_resource.start;
+               }
+       }
+
+       /* check for adapter roms on 2k boundaries */
+       for (i = 0; i < ARRAY_SIZE(adapter_rom_resources) && start < upper; start += 2048) {
+               rom = isa_bus_to_virt(start);
+               if (!romsignature(rom))
+                       continue;
+
+               /* 0 < length <= 0x7f * 512, historically */
+               length = rom[2] * 512;
+
+               /* but accept any length that fits if checksum okay */
+               if (!length || start + length > upper || !romchecksum(rom, length))
+                       continue;
+
+               adapter_rom_resources[i].start = start;
+               adapter_rom_resources[i].end = start + length - 1;
+               request_resource(&iomem_resource, &adapter_rom_resources[i]);
+
+               start = adapter_rom_resources[i++].end & ~2047UL;
+       }
+}
+
+/*
+ * Request address space for all standard RAM and ROM resources
+ * and also for regions reported as reserved by the e820.
+ */
+static void __init
+legacy_init_iomem_resources(struct resource *code_resource, struct resource *data_resource)
+{
+       int i;
+
+       probe_roms();
+       for (i = 0; i < e820.nr_map; i++) {
+               struct resource *res;
+#ifndef CONFIG_RESOURCES_64BIT
+               if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL)
+                       continue;
+#endif
+               res = kzalloc(sizeof(struct resource), GFP_ATOMIC);
+               switch (e820.map[i].type) {
+               case E820_RAM:  res->name = "System RAM"; break;
+               case E820_ACPI: res->name = "ACPI Tables"; break;
+               case E820_NVS:  res->name = "ACPI Non-volatile Storage"; break;
+               default:        res->name = "reserved";
+               }
+               res->start = e820.map[i].addr;
+               res->end = res->start + e820.map[i].size - 1;
+               res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+               if (request_resource(&iomem_resource, res)) {
+                       kfree(res);
+                       continue;
+               }
+               if (e820.map[i].type == E820_RAM) {
+                       /*
+                        *  We don't know which RAM region contains kernel data,
+                        *  so we try it repeatedly and let the resource manager
+                        *  test it.
+                        */
+                       request_resource(res, code_resource);
+                       request_resource(res, data_resource);
+#ifdef CONFIG_KEXEC
+                       request_resource(res, &crashk_res);
+#endif
+               }
+       }
+}
+
+/*
+ * Request address space for all standard resources
+ *
+ * This is called just before pcibios_init(), which is also a
+ * subsys_initcall, but is linked in later (in arch/i386/pci/common.c).
+ */
+static int __init request_standard_resources(void)
+{
+       int i;
+
+       printk("Setting up standard PCI resources\n");
+       if (efi_enabled)
+               efi_initialize_iomem_resources(&code_resource, &data_resource);
+       else
+               legacy_init_iomem_resources(&code_resource, &data_resource);
+
+       /* EFI systems may still have VGA */
+       request_resource(&iomem_resource, &video_ram_resource);
+
+       /* request I/O space for devices used on all i[345]86 PCs */
+       for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++)
+               request_resource(&ioport_resource, &standard_io_resources[i]);
+       return 0;
+}
+
+subsys_initcall(request_standard_resources);
+
+void __init add_memory_region(unsigned long long start,
+                             unsigned long long size, int type)
+{
+       int x;
+
+       if (!efi_enabled) {
+                       x = e820.nr_map;
+
+               if (x == E820MAX) {
+                   printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
+                   return;
+               }
+
+               e820.map[x].addr = start;
+               e820.map[x].size = size;
+               e820.map[x].type = type;
+               e820.nr_map++;
+       }
+} /* add_memory_region */
+
+/*
+ * Sanitize the BIOS e820 map.
+ *
+ * Some e820 responses include overlapping entries.  The following
+ * replaces the original e820 map with a new one, removing overlaps.
+ *
+ */
+int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
+{
+       struct change_member *change_tmp;
+       unsigned long current_type, last_type;
+       unsigned long long last_addr;
+       int chgidx, still_changing;
+       int overlap_entries;
+       int new_bios_entry;
+       int old_nr, new_nr, chg_nr;
+       int i;
+
+       /*
+               Visually we're performing the following (1,2,3,4 = memory types)...
+
+               Sample memory map (w/overlaps):
+                  ____22__________________
+                  ______________________4_
+                  ____1111________________
+                  _44_____________________
+                  11111111________________
+                  ____________________33__
+                  ___________44___________
+                  __________33333_________
+                  ______________22________
+                  ___________________2222_
+                  _________111111111______
+                  _____________________11_
+                  _________________4______
+
+               Sanitized equivalent (no overlap):
+                  1_______________________
+                  _44_____________________
+                  ___1____________________
+                  ____22__________________
+                  ______11________________
+                  _________1______________
+                  __________3_____________
+                  ___________44___________
+                  _____________33_________
+                  _______________2________
+                  ________________1_______
+                  _________________4______
+                  ___________________2____
+                  ____________________33__
+                  ______________________4_
+       */
+       printk("sanitize start\n");
+       /* if there's only one memory region, don't bother */
+       if (*pnr_map < 2) {
+               printk("sanitize bail 0\n");
+               return -1;
+       }
+
+       old_nr = *pnr_map;
+
+       /* bail out if we find any unreasonable addresses in bios map */
+       for (i=0; i<old_nr; i++)
+               if (biosmap[i].addr + biosmap[i].size < biosmap[i].addr) {
+                       printk("sanitize bail 1\n");
+                       return -1;
+               }
+
+       /* create pointers for initial change-point information (for sorting) */
+       for (i=0; i < 2*old_nr; i++)
+               change_point[i] = &change_point_list[i];
+
+       /* record all known change-points (starting and ending addresses),
+          omitting those that are for empty memory regions */
+       chgidx = 0;
+       for (i=0; i < old_nr; i++)      {
+               if (biosmap[i].size != 0) {
+                       change_point[chgidx]->addr = biosmap[i].addr;
+                       change_point[chgidx++]->pbios = &biosmap[i];
+                       change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size;
+                       change_point[chgidx++]->pbios = &biosmap[i];
+               }
+       }
+       chg_nr = chgidx;        /* true number of change-points */
+
+       /* sort change-point list by memory addresses (low -> high) */
+       still_changing = 1;
+       while (still_changing)  {
+               still_changing = 0;
+               for (i=1; i < chg_nr; i++)  {
+                       /* if <current_addr> > <last_addr>, swap */
+                       /* or, if current=<start_addr> & last=<end_addr>, swap */
+                       if ((change_point[i]->addr < change_point[i-1]->addr) ||
+                               ((change_point[i]->addr == change_point[i-1]->addr) &&
+                                (change_point[i]->addr == change_point[i]->pbios->addr) &&
+                                (change_point[i-1]->addr != change_point[i-1]->pbios->addr))
+                          )
+                       {
+                               change_tmp = change_point[i];
+                               change_point[i] = change_point[i-1];
+                               change_point[i-1] = change_tmp;
+                               still_changing=1;
+                       }
+               }
+       }
+
+       /* create a new bios memory map, removing overlaps */
+       overlap_entries=0;       /* number of entries in the overlap table */
+       new_bios_entry=0;        /* index for creating new bios map entries */
+       last_type = 0;           /* start with undefined memory type */
+       last_addr = 0;           /* start with 0 as last starting address */
+       /* loop through change-points, determining affect on the new bios map */
+       for (chgidx=0; chgidx < chg_nr; chgidx++)
+       {
+               /* keep track of all overlapping bios entries */
+               if (change_point[chgidx]->addr == change_point[chgidx]->pbios->addr)
+               {
+                       /* add map entry to overlap list (> 1 entry implies an overlap) */
+                       overlap_list[overlap_entries++]=change_point[chgidx]->pbios;
+               }
+               else
+               {
+                       /* remove entry from list (order independent, so swap with last) */
+                       for (i=0; i<overlap_entries; i++)
+                       {
+                               if (overlap_list[i] == change_point[chgidx]->pbios)
+                                       overlap_list[i] = overlap_list[overlap_entries-1];
+                       }
+                       overlap_entries--;
+               }
+               /* if there are overlapping entries, decide which "type" to use */
+               /* (larger value takes precedence -- 1=usable, 2,3,4,4+=unusable) */
+               current_type = 0;
+               for (i=0; i<overlap_entries; i++)
+                       if (overlap_list[i]->type > current_type)
+                               current_type = overlap_list[i]->type;
+               /* continue building up new bios map based on this information */
+               if (current_type != last_type)  {
+                       if (last_type != 0)      {
+                               new_bios[new_bios_entry].size =
+                                       change_point[chgidx]->addr - last_addr;
+                               /* move forward only if the new size was non-zero */
+                               if (new_bios[new_bios_entry].size != 0)
+                                       if (++new_bios_entry >= E820MAX)
+                                               break;  /* no more space left for new bios entries */
+                       }
+                       if (current_type != 0)  {
+                               new_bios[new_bios_entry].addr = change_point[chgidx]->addr;
+                               new_bios[new_bios_entry].type = current_type;
+                               last_addr=change_point[chgidx]->addr;
+                       }
+                       last_type = current_type;
+               }
+       }
+       new_nr = new_bios_entry;   /* retain count for new bios entries */
+
+       /* copy new bios mapping into original location */
+       memcpy(biosmap, new_bios, new_nr*sizeof(struct e820entry));
+       *pnr_map = new_nr;
+
+       printk("sanitize end\n");
+       return 0;
+}
+
+/*
+ * Copy the BIOS e820 map into a safe place.
+ *
+ * Sanity-check it while we're at it..
+ *
+ * If we're lucky and live on a modern system, the setup code
+ * will have given us a memory map that we can use to properly
+ * set up memory.  If we aren't, we'll fake a memory map.
+ *
+ * We check to see that the memory map contains at least 2 elements
+ * before we'll use it, because the detection code in setup.S may
+ * not be perfect and most every PC known to man has two memory
+ * regions: one from 0 to 640k, and one from 1mb up.  (The IBM
+ * thinkpad 560x, for example, does not cooperate with the memory
+ * detection code.)
+ */
+int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
+{
+       /* Only one memory region (or negative)? Ignore it */
+       if (nr_map < 2)
+               return -1;
+
+       do {
+               unsigned long long start = biosmap->addr;
+               unsigned long long size = biosmap->size;
+               unsigned long long end = start + size;
+               unsigned long type = biosmap->type;
+               printk("copy_e820_map() start: %016Lx size: %016Lx end: %016Lx type: %ld\n", start, size, end, type);
+
+               /* Overflow in 64 bits? Ignore the memory map. */
+               if (start > end)
+                       return -1;
+
+               /*
+                * Some BIOSes claim RAM in the 640k - 1M region.
+                * Not right. Fix it up.
+                */
+               if (type == E820_RAM) {
+                       printk("copy_e820_map() type is E820_RAM\n");
+                       if (start < 0x100000ULL && end > 0xA0000ULL) {
+                               printk("copy_e820_map() lies in range...\n");
+                               if (start < 0xA0000ULL) {
+                                       printk("copy_e820_map() start < 0xA0000ULL\n");
+                                       add_memory_region(start, 0xA0000ULL-start, type);
+                               }
+                               if (end <= 0x100000ULL) {
+                                       printk("copy_e820_map() end <= 0x100000ULL\n");
+                                       continue;
+                               }
+                               start = 0x100000ULL;
+                               size = end - start;
+                       }
+               }
+               add_memory_region(start, size, type);
+       } while (biosmap++,--nr_map);
+       return 0;
+}
+
+/*
+ * Callback for efi_memory_walk.
+ */
+static int __init
+efi_find_max_pfn(unsigned long start, unsigned long end, void *arg)
+{
+       unsigned long *max_pfn = arg, pfn;
+
+       if (start < end) {
+               pfn = PFN_UP(end -1);
+               if (pfn > *max_pfn)
+                       *max_pfn = pfn;
+       }
+       return 0;
+}
+
+static int __init
+efi_memory_present_wrapper(unsigned long start, unsigned long end, void *arg)
+{
+       memory_present(0, PFN_UP(start), PFN_DOWN(end));
+       return 0;
+}
+
+/*
+ * Find the highest page frame number we have available
+ */
+void __init find_max_pfn(void)
+{
+       int i;
+
+       max_pfn = 0;
+       if (efi_enabled) {
+               efi_memmap_walk(efi_find_max_pfn, &max_pfn);
+               efi_memmap_walk(efi_memory_present_wrapper, NULL);
+               return;
+       }
+
+       for (i = 0; i < e820.nr_map; i++) {
+               unsigned long start, end;
+               /* RAM? */
+               if (e820.map[i].type != E820_RAM)
+                       continue;
+               start = PFN_UP(e820.map[i].addr);
+               end = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
+               if (start >= end)
+                       continue;
+               if (end > max_pfn)
+                       max_pfn = end;
+               memory_present(0, start, end);
+       }
+}
+
+/*
+ * Free all available memory for boot time allocation.  Used
+ * as a callback function by efi_memory_walk()
+ */
+
+static int __init
+free_available_memory(unsigned long start, unsigned long end, void *arg)
+{
+       /* check max_low_pfn */
+       if (start >= (max_low_pfn << PAGE_SHIFT))
+               return 0;
+       if (end >= (max_low_pfn << PAGE_SHIFT))
+               end = max_low_pfn << PAGE_SHIFT;
+       if (start < end)
+               free_bootmem(start, end - start);
+
+       return 0;
+}
+/*
+ * Register fully available low RAM pages with the bootmem allocator.
+ */
+void __init register_bootmem_low_pages(unsigned long max_low_pfn)
+{
+       int i;
+
+       if (efi_enabled) {
+               efi_memmap_walk(free_available_memory, NULL);
+               return;
+       }
+       for (i = 0; i < e820.nr_map; i++) {
+               unsigned long curr_pfn, last_pfn, size;
+               /*
+                * Reserve usable low memory
+                */
+               if (e820.map[i].type != E820_RAM)
+                       continue;
+               /*
+                * We are rounding up the start address of usable memory:
+                */
+               curr_pfn = PFN_UP(e820.map[i].addr);
+               if (curr_pfn >= max_low_pfn)
+                       continue;
+               /*
+                * ... and at the end of the usable range downwards:
+                */
+               last_pfn = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
+
+               if (last_pfn > max_low_pfn)
+                       last_pfn = max_low_pfn;
+
+               /*
+                * .. finally, did all the rounding and playing
+                * around just make the area go away?
+                */
+               if (last_pfn <= curr_pfn)
+                       continue;
+
+               size = last_pfn - curr_pfn;
+               free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(size));
+       }
+}
+
+void __init register_memory(void)
+{
+       unsigned long gapstart, gapsize, round;
+       unsigned long long last;
+       int i;
+
+       /*
+        * Search for the bigest gap in the low 32 bits of the e820
+        * memory space.
+        */
+       last = 0x100000000ull;
+       gapstart = 0x10000000;
+       gapsize = 0x400000;
+       i = e820.nr_map;
+       while (--i >= 0) {
+               unsigned long long start = e820.map[i].addr;
+               unsigned long long end = start + e820.map[i].size;
+
+               /*
+                * Since "last" is at most 4GB, we know we'll
+                * fit in 32 bits if this condition is true
+                */
+               if (last > end) {
+                       unsigned long gap = last - end;
+
+                       if (gap > gapsize) {
+                               gapsize = gap;
+                               gapstart = end;
+                       }
+               }
+               if (start < last)
+                       last = start;
+       }
+
+       /*
+        * See how much we want to round up: start off with
+        * rounding to the next 1MB area.
+        */
+       round = 0x100000;
+       while ((gapsize >> 4) > round)
+               round += round;
+       /* Fun with two's complement */
+       pci_mem_start = (gapstart + round) & -round;
+
+       printk("Allocating PCI resources starting at %08lx (gap: %08lx:%08lx)\n",
+               pci_mem_start, gapstart, gapsize);
+}
+
+void __init print_memory_map(char *who)
+{
+       int i;
+
+       for (i = 0; i < e820.nr_map; i++) {
+               printk(" %s: %016Lx - %016Lx ", who,
+                       e820.map[i].addr,
+                       e820.map[i].addr + e820.map[i].size);
+               switch (e820.map[i].type) {
+               case E820_RAM:  printk("(usable)\n");
+                               break;
+               case E820_RESERVED:
+                               printk("(reserved)\n");
+                               break;
+               case E820_ACPI:
+                               printk("(ACPI data)\n");
+                               break;
+               case E820_NVS:
+                               printk("(ACPI NVS)\n");
+                               break;
+               default:        printk("type %lu\n", e820.map[i].type);
+                               break;
+               }
+       }
+}
+
+static __init __always_inline void efi_limit_regions(unsigned long long size)
+{
+       unsigned long long current_addr = 0;
+       efi_memory_desc_t *md, *next_md;
+       void *p, *p1;
+       int i, j;
+
+       j = 0;
+       p1 = memmap.map;
+       for (p = p1, i = 0; p < memmap.map_end; p += memmap.desc_size, i++) {
+               md = p;
+               next_md = p1;
+               current_addr = md->phys_addr +
+                       PFN_PHYS(md->num_pages);
+               if (is_available_memory(md)) {
+                       if (md->phys_addr >= size) continue;
+                       memcpy(next_md, md, memmap.desc_size);
+                       if (current_addr >= size) {
+                               next_md->num_pages -=
+                                       PFN_UP(current_addr-size);
+                       }
+                       p1 += memmap.desc_size;
+                       next_md = p1;
+                       j++;
+               } else if ((md->attribute & EFI_MEMORY_RUNTIME) ==
+                          EFI_MEMORY_RUNTIME) {
+                       /* In order to make runtime services
+                        * available we have to include runtime
+                        * memory regions in memory map */
+                       memcpy(next_md, md, memmap.desc_size);
+                       p1 += memmap.desc_size;
+                       next_md = p1;
+                       j++;
+               }
+       }
+       memmap.nr_map = j;
+       memmap.map_end = memmap.map +
+               (memmap.nr_map * memmap.desc_size);
+}
+
+void __init limit_regions(unsigned long long size)
+{
+       unsigned long long current_addr;
+       int i;
+
+       print_memory_map("limit_regions start");
+       if (efi_enabled) {
+               efi_limit_regions(size);
+               return;
+       }
+       for (i = 0; i < e820.nr_map; i++) {
+               current_addr = e820.map[i].addr + e820.map[i].size;
+               if (current_addr < size)
+                       continue;
+
+               if (e820.map[i].type != E820_RAM)
+                       continue;
+
+               if (e820.map[i].addr >= size) {
+                       /*
+                        * This region starts past the end of the
+                        * requested size, skip it completely.
+                        */
+                       e820.nr_map = i;
+               } else {
+                       e820.nr_map = i + 1;
+                       e820.map[i].size -= current_addr - size;
+               }
+               print_memory_map("limit_regions endfor");
+               return;
+       }
+       print_memory_map("limit_regions endfunc");
+}
+
+ /*
+  * This function checks if the entire range <start,end> is mapped with type.
+  *
+  * Note: this function only works correct if the e820 table is sorted and
+  * not-overlapping, which is the case
+  */
+int __init
+e820_all_mapped(unsigned long s, unsigned long e, unsigned type)
+{
+       u64 start = s;
+       u64 end = e;
+       int i;
+       for (i = 0; i < e820.nr_map; i++) {
+               struct e820entry *ei = &e820.map[i];
+               if (type && ei->type != type)
+                       continue;
+               /* is the region (part) in overlap with the current region ?*/
+               if (ei->addr >= end || ei->addr + ei->size <= start)
+                       continue;
+               /* if the region is at the beginning of <start,end> we move
+                * start to the end of the region since it's ok until there
+                */
+               if (ei->addr <= start)
+                       start = ei->addr + ei->size;
+               /* if start is now at or beyond end, we're done, full
+                * coverage */
+               if (start >= end)
+                       return 1; /* we're done */
+       }
+       return 0;
+}
+
+static int __init parse_memmap(char *arg)
+{
+       if (!arg)
+               return -EINVAL;
+
+       if (strcmp(arg, "exactmap") == 0) {
+#ifdef CONFIG_CRASH_DUMP
+               /* If we are doing a crash dump, we
+                * still need to know the real mem
+                * size before original memory map is
+                * reset.
+                */
+               find_max_pfn();
+               saved_max_pfn = max_pfn;
+#endif
+               e820.nr_map = 0;
+               user_defined_memmap = 1;
+       } else {
+               /* If the user specifies memory size, we
+                * limit the BIOS-provided memory map to
+                * that size. exactmap can be used to specify
+                * the exact map. mem=number can be used to
+                * trim the existing memory map.
+                */
+               unsigned long long start_at, mem_size;
+
+               mem_size = memparse(arg, &arg);
+               if (*arg == '@') {
+                       start_at = memparse(arg+1, &arg);
+                       add_memory_region(start_at, mem_size, E820_RAM);
+               } else if (*arg == '#') {
+                       start_at = memparse(arg+1, &arg);
+                       add_memory_region(start_at, mem_size, E820_ACPI);
+               } else if (*arg == '$') {
+                       start_at = memparse(arg+1, &arg);
+                       add_memory_region(start_at, mem_size, E820_RESERVED);
+               } else {
+                       limit_regions(mem_size);
+                       user_defined_memmap = 1;
+               }
+       }
+       return 0;
+}
+early_param("memmap", parse_memmap);
index 8b40648d0ef00f2570ea2f19e07da3e1f851d41f..b92c7f0a358aa79836a2ccbc56cd7bf386555a80 100644 (file)
@@ -194,17 +194,24 @@ inline int efi_set_rtc_mmss(unsigned long nowtime)
        return 0;
 }
 /*
- * This should only be used during kernel init and before runtime
- * services have been remapped, therefore, we'll need to call in physical
- * mode.  Note, this call isn't used later, so mark it __init.
+ * This is used during kernel init before runtime
+ * services have been remapped and also during suspend, therefore,
+ * we'll need to call both in physical and virtual modes.
  */
-inline unsigned long __init efi_get_time(void)
+inline unsigned long efi_get_time(void)
 {
        efi_status_t status;
        efi_time_t eft;
        efi_time_cap_t cap;
 
-       status = phys_efi_get_time(&eft, &cap);
+       if (efi.get_time) {
+               /* if we are in virtual mode use remapped function */
+               status = efi.get_time(&eft, &cap);
+       } else {
+               /* we are in physical mode */
+               status = phys_efi_get_time(&eft, &cap);
+       }
+
        if (status != EFI_SUCCESS)
                printk("Oops: efitime: can't read time status: 0x%lx\n",status);
 
index 5a63d6fdb70e4ff75d09b69874334b758d5af07a..de34b7fed3c1718d88886fa3e24a94fa49ac662f 100644 (file)
  *     18(%esp) - %eax
  *     1C(%esp) - %ds
  *     20(%esp) - %es
- *     24(%esp) - orig_eax
- *     28(%esp) - %eip
- *     2C(%esp) - %cs
- *     30(%esp) - %eflags
- *     34(%esp) - %oldesp
- *     38(%esp) - %oldss
+ *     24(%esp) - %gs
+ *     28(%esp) - orig_eax
+ *     2C(%esp) - %eip
+ *     30(%esp) - %cs
+ *     34(%esp) - %eflags
+ *     38(%esp) - %oldesp
+ *     3C(%esp) - %oldss
  *
  * "current" is in register %ebx during any slow entries.
  */
 #include <asm/smp.h>
 #include <asm/page.h>
 #include <asm/desc.h>
+#include <asm/percpu.h>
 #include <asm/dwarf2.h>
 #include "irq_vectors.h"
 
-#define nr_syscalls ((syscall_table_size)/4)
+/*
+ * We use macros for low-level operations which need to be overridden
+ * for paravirtualization.  The following will never clobber any registers:
+ *   INTERRUPT_RETURN (aka. "iret")
+ *   GET_CR0_INTO_EAX (aka. "movl %cr0, %eax")
+ *   ENABLE_INTERRUPTS_SYSEXIT (aka "sti; sysexit").
+ *
+ * For DISABLE_INTERRUPTS/ENABLE_INTERRUPTS (aka "cli"/"sti"), you must
+ * specify what registers can be overwritten (CLBR_NONE, CLBR_EAX/EDX/ECX/ANY).
+ * Allowing a register to be clobbered can shrink the paravirt replacement
+ * enough to patch inline, increasing performance.
+ */
 
-EBX            = 0x00
-ECX            = 0x04
-EDX            = 0x08
-ESI            = 0x0C
-EDI            = 0x10
-EBP            = 0x14
-EAX            = 0x18
-DS             = 0x1C
-ES             = 0x20
-ORIG_EAX       = 0x24
-EIP            = 0x28
-CS             = 0x2C
-EFLAGS         = 0x30
-OLDESP         = 0x34
-OLDSS          = 0x38
+#define nr_syscalls ((syscall_table_size)/4)
 
 CF_MASK                = 0x00000001
 TF_MASK                = 0x00000100
@@ -76,23 +75,16 @@ DF_MASK             = 0x00000400
 NT_MASK                = 0x00004000
 VM_MASK                = 0x00020000
 
-/* These are replaces for paravirtualization */
-#define DISABLE_INTERRUPTS             cli
-#define ENABLE_INTERRUPTS              sti
-#define ENABLE_INTERRUPTS_SYSEXIT      sti; sysexit
-#define INTERRUPT_RETURN               iret
-#define GET_CR0_INTO_EAX               movl %cr0, %eax
-
 #ifdef CONFIG_PREEMPT
-#define preempt_stop           DISABLE_INTERRUPTS; TRACE_IRQS_OFF
+#define preempt_stop(clobbers) DISABLE_INTERRUPTS(clobbers); TRACE_IRQS_OFF
 #else
-#define preempt_stop
+#define preempt_stop(clobbers)
 #define resume_kernel          restore_nocheck
 #endif
 
 .macro TRACE_IRQS_IRET
 #ifdef CONFIG_TRACE_IRQFLAGS
-       testl $IF_MASK,EFLAGS(%esp)     # interrupts off?
+       testl $IF_MASK,PT_EFLAGS(%esp)     # interrupts off?
        jz 1f
        TRACE_IRQS_ON
 1:
@@ -107,6 +99,9 @@ VM_MASK              = 0x00020000
 
 #define SAVE_ALL \
        cld; \
+       pushl %gs; \
+       CFI_ADJUST_CFA_OFFSET 4;\
+       /*CFI_REL_OFFSET gs, 0;*/\
        pushl %es; \
        CFI_ADJUST_CFA_OFFSET 4;\
        /*CFI_REL_OFFSET es, 0;*/\
@@ -136,7 +131,9 @@ VM_MASK             = 0x00020000
        CFI_REL_OFFSET ebx, 0;\
        movl $(__USER_DS), %edx; \
        movl %edx, %ds; \
-       movl %edx, %es;
+       movl %edx, %es; \
+       movl $(__KERNEL_PDA), %edx; \
+       movl %edx, %gs
 
 #define RESTORE_INT_REGS \
        popl %ebx;      \
@@ -169,17 +166,22 @@ VM_MASK           = 0x00020000
 2:     popl %es;       \
        CFI_ADJUST_CFA_OFFSET -4;\
        /*CFI_RESTORE es;*/\
-.section .fixup,"ax";  \
-3:     movl $0,(%esp); \
-       jmp 1b;         \
+3:     popl %gs;       \
+       CFI_ADJUST_CFA_OFFSET -4;\
+       /*CFI_RESTORE gs;*/\
+.pushsection .fixup,"ax";      \
 4:     movl $0,(%esp); \
+       jmp 1b;         \
+5:     movl $0,(%esp); \
        jmp 2b;         \
-.previous;             \
+6:     movl $0,(%esp); \
+       jmp 3b;         \
 .section __ex_table,"a";\
        .align 4;       \
-       .long 1b,3b;    \
-       .long 2b,4b;    \
-.previous
+       .long 1b,4b;    \
+       .long 2b,5b;    \
+       .long 3b,6b;    \
+.popsection
 
 #define RING0_INT_FRAME \
        CFI_STARTPROC simple;\
@@ -198,18 +200,18 @@ VM_MASK           = 0x00020000
 #define RING0_PTREGS_FRAME \
        CFI_STARTPROC simple;\
        CFI_SIGNAL_FRAME;\
-       CFI_DEF_CFA esp, OLDESP-EBX;\
-       /*CFI_OFFSET cs, CS-OLDESP;*/\
-       CFI_OFFSET eip, EIP-OLDESP;\
-       /*CFI_OFFSET es, ES-OLDESP;*/\
-       /*CFI_OFFSET ds, DS-OLDESP;*/\
-       CFI_OFFSET eax, EAX-OLDESP;\
-       CFI_OFFSET ebp, EBP-OLDESP;\
-       CFI_OFFSET edi, EDI-OLDESP;\
-       CFI_OFFSET esi, ESI-OLDESP;\
-       CFI_OFFSET edx, EDX-OLDESP;\
-       CFI_OFFSET ecx, ECX-OLDESP;\
-       CFI_OFFSET ebx, EBX-OLDESP
+       CFI_DEF_CFA esp, PT_OLDESP-PT_EBX;\
+       /*CFI_OFFSET cs, PT_CS-PT_OLDESP;*/\
+       CFI_OFFSET eip, PT_EIP-PT_OLDESP;\
+       /*CFI_OFFSET es, PT_ES-PT_OLDESP;*/\
+       /*CFI_OFFSET ds, PT_DS-PT_OLDESP;*/\
+       CFI_OFFSET eax, PT_EAX-PT_OLDESP;\
+       CFI_OFFSET ebp, PT_EBP-PT_OLDESP;\
+       CFI_OFFSET edi, PT_EDI-PT_OLDESP;\
+       CFI_OFFSET esi, PT_ESI-PT_OLDESP;\
+       CFI_OFFSET edx, PT_EDX-PT_OLDESP;\
+       CFI_OFFSET ecx, PT_ECX-PT_OLDESP;\
+       CFI_OFFSET ebx, PT_EBX-PT_OLDESP
 
 ENTRY(ret_from_fork)
        CFI_STARTPROC
@@ -237,17 +239,18 @@ ENTRY(ret_from_fork)
        ALIGN
        RING0_PTREGS_FRAME
 ret_from_exception:
-       preempt_stop
+       preempt_stop(CLBR_ANY)
 ret_from_intr:
        GET_THREAD_INFO(%ebp)
 check_userspace:
-       movl EFLAGS(%esp), %eax         # mix EFLAGS and CS
-       movb CS(%esp), %al
+       movl PT_EFLAGS(%esp), %eax      # mix EFLAGS and CS
+       movb PT_CS(%esp), %al
        andl $(VM_MASK | SEGMENT_RPL_MASK), %eax
        cmpl $USER_RPL, %eax
        jb resume_kernel                # not returning to v8086 or userspace
+
 ENTRY(resume_userspace)
-       DISABLE_INTERRUPTS              # make sure we don't miss an interrupt
+       DISABLE_INTERRUPTS(CLBR_ANY)    # make sure we don't miss an interrupt
                                        # setting need_resched or sigpending
                                        # between sampling and the iret
        movl TI_flags(%ebp), %ecx
@@ -258,14 +261,14 @@ ENTRY(resume_userspace)
 
 #ifdef CONFIG_PREEMPT
 ENTRY(resume_kernel)
-       DISABLE_INTERRUPTS
+       DISABLE_INTERRUPTS(CLBR_ANY)
        cmpl $0,TI_preempt_count(%ebp)  # non-zero preempt_count ?
        jnz restore_nocheck
 need_resched:
        movl TI_flags(%ebp), %ecx       # need_resched set ?
        testb $_TIF_NEED_RESCHED, %cl
        jz restore_all
-       testl $IF_MASK,EFLAGS(%esp)     # interrupts off (exception path) ?
+       testl $IF_MASK,PT_EFLAGS(%esp)  # interrupts off (exception path) ?
        jz restore_all
        call preempt_schedule_irq
        jmp need_resched
@@ -287,7 +290,7 @@ sysenter_past_esp:
         * No need to follow this irqs on/off section: the syscall
         * disabled irqs and here we enable it straight after entry:
         */
-       ENABLE_INTERRUPTS
+       ENABLE_INTERRUPTS(CLBR_NONE)
        pushl $(__USER_DS)
        CFI_ADJUST_CFA_OFFSET 4
        /*CFI_REL_OFFSET ss, 0*/
@@ -331,20 +334,27 @@ sysenter_past_esp:
        cmpl $(nr_syscalls), %eax
        jae syscall_badsys
        call *sys_call_table(,%eax,4)
-       movl %eax,EAX(%esp)
-       DISABLE_INTERRUPTS
+       movl %eax,PT_EAX(%esp)
+       DISABLE_INTERRUPTS(CLBR_ECX|CLBR_EDX)
        TRACE_IRQS_OFF
        movl TI_flags(%ebp), %ecx
        testw $_TIF_ALLWORK_MASK, %cx
        jne syscall_exit_work
 /* if something modifies registers it must also disable sysexit */
-       movl EIP(%esp), %edx
-       movl OLDESP(%esp), %ecx
+       movl PT_EIP(%esp), %edx
+       movl PT_OLDESP(%esp), %ecx
        xorl %ebp,%ebp
        TRACE_IRQS_ON
+1:     mov  PT_GS(%esp), %gs
        ENABLE_INTERRUPTS_SYSEXIT
        CFI_ENDPROC
-
+.pushsection .fixup,"ax"
+2:     movl $0,PT_GS(%esp)
+       jmp 1b
+.section __ex_table,"a"
+       .align 4
+       .long 1b,2b
+.popsection
 
        # system call handler stub
 ENTRY(system_call)
@@ -353,7 +363,7 @@ ENTRY(system_call)
        CFI_ADJUST_CFA_OFFSET 4
        SAVE_ALL
        GET_THREAD_INFO(%ebp)
-       testl $TF_MASK,EFLAGS(%esp)
+       testl $TF_MASK,PT_EFLAGS(%esp)
        jz no_singlestep
        orl $_TIF_SINGLESTEP,TI_flags(%ebp)
 no_singlestep:
@@ -365,9 +375,9 @@ no_singlestep:
        jae syscall_badsys
 syscall_call:
        call *sys_call_table(,%eax,4)
-       movl %eax,EAX(%esp)             # store the return value
+       movl %eax,PT_EAX(%esp)          # store the return value
 syscall_exit:
-       DISABLE_INTERRUPTS              # make sure we don't miss an interrupt
+       DISABLE_INTERRUPTS(CLBR_ANY)    # make sure we don't miss an interrupt
                                        # setting need_resched or sigpending
                                        # between sampling and the iret
        TRACE_IRQS_OFF
@@ -376,12 +386,12 @@ syscall_exit:
        jne syscall_exit_work
 
 restore_all:
-       movl EFLAGS(%esp), %eax         # mix EFLAGS, SS and CS
-       # Warning: OLDSS(%esp) contains the wrong/random values if we
+       movl PT_EFLAGS(%esp), %eax      # mix EFLAGS, SS and CS
+       # Warning: PT_OLDSS(%esp) contains the wrong/random values if we
        # are returning to the kernel.
        # See comments in process.c:copy_thread() for details.
-       movb OLDSS(%esp), %ah
-       movb CS(%esp), %al
+       movb PT_OLDSS(%esp), %ah
+       movb PT_CS(%esp), %al
        andl $(VM_MASK | (SEGMENT_TI_MASK << 8) | SEGMENT_RPL_MASK), %eax
        cmpl $((SEGMENT_LDT << 8) | USER_RPL), %eax
        CFI_REMEMBER_STATE
@@ -390,13 +400,13 @@ restore_nocheck:
        TRACE_IRQS_IRET
 restore_nocheck_notrace:
        RESTORE_REGS
-       addl $4, %esp
+       addl $4, %esp                   # skip orig_eax/error_code
        CFI_ADJUST_CFA_OFFSET -4
 1:     INTERRUPT_RETURN
 .section .fixup,"ax"
 iret_exc:
        TRACE_IRQS_ON
-       ENABLE_INTERRUPTS
+       ENABLE_INTERRUPTS(CLBR_NONE)
        pushl $0                        # no error code
        pushl $do_iret_error
        jmp error_code
@@ -408,33 +418,42 @@ iret_exc:
 
        CFI_RESTORE_STATE
 ldt_ss:
-       larl OLDSS(%esp), %eax
+       larl PT_OLDSS(%esp), %eax
        jnz restore_nocheck
        testl $0x00400000, %eax         # returning to 32bit stack?
        jnz restore_nocheck             # allright, normal return
+
+#ifdef CONFIG_PARAVIRT
+       /*
+        * The kernel can't run on a non-flat stack if paravirt mode
+        * is active.  Rather than try to fixup the high bits of
+        * ESP, bypass this code entirely.  This may break DOSemu
+        * and/or Wine support in a paravirt VM, although the option
+        * is still available to implement the setting of the high
+        * 16-bits in the INTERRUPT_RETURN paravirt-op.
+        */
+       cmpl $0, paravirt_ops+PARAVIRT_enabled
+       jne restore_nocheck
+#endif
+
        /* If returning to userspace with 16bit stack,
         * try to fix the higher word of ESP, as the CPU
         * won't restore it.
         * This is an "official" bug of all the x86-compatible
         * CPUs, which we can try to work around to make
         * dosemu and wine happy. */
-       subl $8, %esp           # reserve space for switch16 pointer
-       CFI_ADJUST_CFA_OFFSET 8
-       DISABLE_INTERRUPTS
+       movl PT_OLDESP(%esp), %eax
+       movl %esp, %edx
+       call patch_espfix_desc
+       pushl $__ESPFIX_SS
+       CFI_ADJUST_CFA_OFFSET 4
+       pushl %eax
+       CFI_ADJUST_CFA_OFFSET 4
+       DISABLE_INTERRUPTS(CLBR_EAX)
        TRACE_IRQS_OFF
-       movl %esp, %eax
-       /* Set up the 16bit stack frame with switch32 pointer on top,
-        * and a switch16 pointer on top of the current frame. */
-       call setup_x86_bogus_stack
-       CFI_ADJUST_CFA_OFFSET -8        # frame has moved
-       TRACE_IRQS_IRET
-       RESTORE_REGS
-       lss 20+4(%esp), %esp    # switch to 16bit stack
-1:     INTERRUPT_RETURN
-.section __ex_table,"a"
-       .align 4
-       .long 1b,iret_exc
-.previous
+       lss (%esp), %esp
+       CFI_ADJUST_CFA_OFFSET -8
+       jmp restore_nocheck
        CFI_ENDPROC
 
        # perform work that needs to be done immediately before resumption
@@ -445,7 +464,7 @@ work_pending:
        jz work_notifysig
 work_resched:
        call schedule
-       DISABLE_INTERRUPTS              # make sure we don't miss an interrupt
+       DISABLE_INTERRUPTS(CLBR_ANY)    # make sure we don't miss an interrupt
                                        # setting need_resched or sigpending
                                        # between sampling and the iret
        TRACE_IRQS_OFF
@@ -458,7 +477,8 @@ work_resched:
 
 work_notifysig:                                # deal with pending signals and
                                        # notify-resume requests
-       testl $VM_MASK, EFLAGS(%esp)
+#ifdef CONFIG_VM86
+       testl $VM_MASK, PT_EFLAGS(%esp)
        movl %esp, %eax
        jne work_notifysig_v86          # returning to kernel-space or
                                        # vm86-space
@@ -468,29 +488,30 @@ work_notifysig:                           # deal with pending signals and
 
        ALIGN
 work_notifysig_v86:
-#ifdef CONFIG_VM86
        pushl %ecx                      # save ti_flags for do_notify_resume
        CFI_ADJUST_CFA_OFFSET 4
        call save_v86_state             # %eax contains pt_regs pointer
        popl %ecx
        CFI_ADJUST_CFA_OFFSET -4
        movl %eax, %esp
+#else
+       movl %esp, %eax
+#endif
        xorl %edx, %edx
        call do_notify_resume
        jmp resume_userspace_sig
-#endif
 
        # perform syscall exit tracing
        ALIGN
 syscall_trace_entry:
-       movl $-ENOSYS,EAX(%esp)
+       movl $-ENOSYS,PT_EAX(%esp)
        movl %esp, %eax
        xorl %edx,%edx
        call do_syscall_trace
        cmpl $0, %eax
        jne resume_userspace            # ret != 0 -> running under PTRACE_SYSEMU,
                                        # so must skip actual syscall
-       movl ORIG_EAX(%esp), %eax
+       movl PT_ORIG_EAX(%esp), %eax
        cmpl $(nr_syscalls), %eax
        jnae syscall_call
        jmp syscall_exit
@@ -501,7 +522,7 @@ syscall_exit_work:
        testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP), %cl
        jz work_pending
        TRACE_IRQS_ON
-       ENABLE_INTERRUPTS               # could let do_syscall_trace() call
+       ENABLE_INTERRUPTS(CLBR_ANY)     # could let do_syscall_trace() call
                                        # schedule() instead
        movl %esp, %eax
        movl $1, %edx
@@ -515,39 +536,38 @@ syscall_fault:
        CFI_ADJUST_CFA_OFFSET 4
        SAVE_ALL
        GET_THREAD_INFO(%ebp)
-       movl $-EFAULT,EAX(%esp)
+       movl $-EFAULT,PT_EAX(%esp)
        jmp resume_userspace
 
 syscall_badsys:
-       movl $-ENOSYS,EAX(%esp)
+       movl $-ENOSYS,PT_EAX(%esp)
        jmp resume_userspace
        CFI_ENDPROC
 
 #define FIXUP_ESPFIX_STACK \
-       movl %esp, %eax; \
-       /* switch to 32bit stack using the pointer on top of 16bit stack */ \
-       lss %ss:CPU_16BIT_STACK_SIZE-8, %esp; \
-       /* copy data from 16bit stack to 32bit stack */ \
-       call fixup_x86_bogus_stack; \
-       /* put ESP to the proper location */ \
-       movl %eax, %esp;
-#define UNWIND_ESPFIX_STACK \
+       /* since we are on a wrong stack, we cant make it a C code :( */ \
+       movl %gs:PDA_cpu, %ebx; \
+       PER_CPU(cpu_gdt_descr, %ebx); \
+       movl GDS_address(%ebx), %ebx; \
+       GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah); \
+       addl %esp, %eax; \
+       pushl $__KERNEL_DS; \
+       CFI_ADJUST_CFA_OFFSET 4; \
        pushl %eax; \
        CFI_ADJUST_CFA_OFFSET 4; \
+       lss (%esp), %esp; \
+       CFI_ADJUST_CFA_OFFSET -8;
+#define UNWIND_ESPFIX_STACK \
        movl %ss, %eax; \
-       /* see if on 16bit stack */ \
+       /* see if on espfix stack */ \
        cmpw $__ESPFIX_SS, %ax; \
-       je 28f; \
-27:    popl %eax; \
-       CFI_ADJUST_CFA_OFFSET -4; \
-.section .fixup,"ax"; \
-28:    movl $__KERNEL_DS, %eax; \
+       jne 27f; \
+       movl $__KERNEL_DS, %eax; \
        movl %eax, %ds; \
        movl %eax, %es; \
-       /* switch to 32bit stack */ \
+       /* switch to normal stack */ \
        FIXUP_ESPFIX_STACK; \
-       jmp 27b; \
-.previous
+27:;
 
 /*
  * Build the entry stubs and pointer table with
@@ -608,13 +628,16 @@ KPROBE_ENTRY(page_fault)
        CFI_ADJUST_CFA_OFFSET 4
        ALIGN
 error_code:
+       /* the function address is in %gs's slot on the stack */
+       pushl %es
+       CFI_ADJUST_CFA_OFFSET 4
+       /*CFI_REL_OFFSET es, 0*/
        pushl %ds
        CFI_ADJUST_CFA_OFFSET 4
        /*CFI_REL_OFFSET ds, 0*/
        pushl %eax
        CFI_ADJUST_CFA_OFFSET 4
        CFI_REL_OFFSET eax, 0
-       xorl %eax, %eax
        pushl %ebp
        CFI_ADJUST_CFA_OFFSET 4
        CFI_REL_OFFSET ebp, 0
@@ -627,7 +650,6 @@ error_code:
        pushl %edx
        CFI_ADJUST_CFA_OFFSET 4
        CFI_REL_OFFSET edx, 0
-       decl %eax                       # eax = -1
        pushl %ecx
        CFI_ADJUST_CFA_OFFSET 4
        CFI_REL_OFFSET ecx, 0
@@ -635,18 +657,20 @@ error_code:
        CFI_ADJUST_CFA_OFFSET 4
        CFI_REL_OFFSET ebx, 0
        cld
-       pushl %es
+       pushl %gs
        CFI_ADJUST_CFA_OFFSET 4
-       /*CFI_REL_OFFSET es, 0*/
+       /*CFI_REL_OFFSET gs, 0*/
+       movl $(__KERNEL_PDA), %ecx
+       movl %ecx, %gs
        UNWIND_ESPFIX_STACK
        popl %ecx
        CFI_ADJUST_CFA_OFFSET -4
        /*CFI_REGISTER es, ecx*/
-       movl ES(%esp), %edi             # get the function address
-       movl ORIG_EAX(%esp), %edx       # get the error code
-       movl %eax, ORIG_EAX(%esp)
-       movl %ecx, ES(%esp)
-       /*CFI_REL_OFFSET es, ES*/
+       movl PT_GS(%esp), %edi          # get the function address
+       movl PT_ORIG_EAX(%esp), %edx    # get the error code
+       movl $-1, PT_ORIG_EAX(%esp)     # no syscall to restart
+       mov  %ecx, PT_GS(%esp)
+       /*CFI_REL_OFFSET gs, ES*/
        movl $(__USER_DS), %ecx
        movl %ecx, %ds
        movl %ecx, %es
@@ -682,7 +706,7 @@ ENTRY(device_not_available)
        GET_CR0_INTO_EAX
        testl $0x4, %eax                # EM (math emulation bit)
        jne device_not_available_emulate
-       preempt_stop
+       preempt_stop(CLBR_ANY)
        call math_state_restore
        jmp ret_from_exception
 device_not_available_emulate:
@@ -754,7 +778,7 @@ KPROBE_ENTRY(nmi)
        cmpw $__ESPFIX_SS, %ax
        popl %eax
        CFI_ADJUST_CFA_OFFSET -4
-       je nmi_16bit_stack
+       je nmi_espfix_stack
        cmpl $sysenter_entry,(%esp)
        je nmi_stack_fixup
        pushl %eax
@@ -797,7 +821,7 @@ nmi_debug_stack_check:
        FIX_STACK(24,nmi_stack_correct, 1)
        jmp nmi_stack_correct
 
-nmi_16bit_stack:
+nmi_espfix_stack:
        /* We have a RING0_INT_FRAME here.
         *
         * create the pointer to lss back
@@ -806,7 +830,6 @@ nmi_16bit_stack:
        CFI_ADJUST_CFA_OFFSET 4
        pushl %esp
        CFI_ADJUST_CFA_OFFSET 4
-       movzwl %sp, %esp
        addw $4, (%esp)
        /* copy the iret frame of 12 bytes */
        .rept 3
@@ -817,11 +840,11 @@ nmi_16bit_stack:
        CFI_ADJUST_CFA_OFFSET 4
        SAVE_ALL
        FIXUP_ESPFIX_STACK              # %eax == %esp
-       CFI_ADJUST_CFA_OFFSET -20       # the frame has now moved
        xorl %edx,%edx                  # zero error code
        call do_nmi
        RESTORE_REGS
-       lss 12+4(%esp), %esp            # back to 16bit stack
+       lss 12+4(%esp), %esp            # back to espfix stack
+       CFI_ADJUST_CFA_OFFSET -24
 1:     INTERRUPT_RETURN
        CFI_ENDPROC
 .section __ex_table,"a"
@@ -830,6 +853,19 @@ nmi_16bit_stack:
 .previous
 KPROBE_END(nmi)
 
+#ifdef CONFIG_PARAVIRT
+ENTRY(native_iret)
+1:     iret
+.section __ex_table,"a"
+       .align 4
+       .long 1b,iret_exc
+.previous
+
+ENTRY(native_irq_enable_sysexit)
+       sti
+       sysexit
+#endif
+
 KPROBE_ENTRY(int3)
        RING0_INT_FRAME
        pushl $-1                       # mark this as an int
@@ -949,26 +985,27 @@ ENTRY(arch_unwind_init_running)
        movl    4(%esp), %edx
        movl    (%esp), %ecx
        leal    4(%esp), %eax
-       movl    %ebx, EBX(%edx)
+       movl    %ebx, PT_EBX(%edx)
        xorl    %ebx, %ebx
-       movl    %ebx, ECX(%edx)
-       movl    %ebx, EDX(%edx)
-       movl    %esi, ESI(%edx)
-       movl    %edi, EDI(%edx)
-       movl    %ebp, EBP(%edx)
-       movl    %ebx, EAX(%edx)
-       movl    $__USER_DS, DS(%edx)
-       movl    $__USER_DS, ES(%edx)
-       movl    %ebx, ORIG_EAX(%edx)
-       movl    %ecx, EIP(%edx)
+       movl    %ebx, PT_ECX(%edx)
+       movl    %ebx, PT_EDX(%edx)
+       movl    %esi, PT_ESI(%edx)
+       movl    %edi, PT_EDI(%edx)
+       movl    %ebp, PT_EBP(%edx)
+       movl    %ebx, PT_EAX(%edx)
+       movl    $__USER_DS, PT_DS(%edx)
+       movl    $__USER_DS, PT_ES(%edx)
+       movl    $0, PT_GS(%edx)
+       movl    %ebx, PT_ORIG_EAX(%edx)
+       movl    %ecx, PT_EIP(%edx)
        movl    12(%esp), %ecx
-       movl    $__KERNEL_CS, CS(%edx)
-       movl    %ebx, EFLAGS(%edx)
-       movl    %eax, OLDESP(%edx)
+       movl    $__KERNEL_CS, PT_CS(%edx)
+       movl    %ebx, PT_EFLAGS(%edx)
+       movl    %eax, PT_OLDESP(%edx)
        movl    8(%esp), %eax
        movl    %ecx, 8(%esp)
-       movl    EBX(%edx), %ebx
-       movl    $__KERNEL_DS, OLDSS(%edx)
+       movl    PT_EBX(%edx), %ebx
+       movl    $__KERNEL_DS, PT_OLDSS(%edx)
        jmpl    *%eax
        CFI_ENDPROC
 ENDPROC(arch_unwind_init_running)
index ca31f18d277c5487e3afab809783f9d79beb4fbe..edef5084ce17104b6c46f900d70d22b480ed8794 100644 (file)
  */
 ENTRY(startup_32)
 
+#ifdef CONFIG_PARAVIRT
+        movl %cs, %eax
+        testl $0x3, %eax
+        jnz startup_paravirt
+#endif
+
 /*
  * Set segments to known values.
  */
@@ -302,6 +308,7 @@ is386:      movl $2,%ecx            # set MP
        movl %eax,%cr0
 
        call check_x87
+       call setup_pda
        lgdt cpu_gdt_descr
        lidt idt_descr
        ljmp $(__KERNEL_CS),$1f
@@ -312,10 +319,13 @@ is386:    movl $2,%ecx            # set MP
        movl %eax,%ds
        movl %eax,%es
 
-       xorl %eax,%eax                  # Clear FS/GS and LDT
+       xorl %eax,%eax                  # Clear FS and LDT
        movl %eax,%fs
-       movl %eax,%gs
        lldt %ax
+
+       movl $(__KERNEL_PDA),%eax
+       mov  %eax,%gs
+
        cld                     # gcc2 wants the direction flag cleared at all times
        pushl $0                # fake return address for unwinder
 #ifdef CONFIG_SMP
@@ -345,6 +355,23 @@ check_x87:
        .byte 0xDB,0xE4         /* fsetpm for 287, ignored by 387 */
        ret
 
+/*
+ * Point the GDT at this CPU's PDA.  On boot this will be
+ * cpu_gdt_table and boot_pda; for secondary CPUs, these will be
+ * that CPU's GDT and PDA.
+ */
+setup_pda:
+       /* get the PDA pointer */
+       movl start_pda, %eax
+
+       /* slot the PDA address into the GDT */
+       mov cpu_gdt_descr+2, %ecx
+       mov %ax, (__KERNEL_PDA+0+2)(%ecx)               /* base & 0x0000ffff */
+       shr $16, %eax
+       mov %al, (__KERNEL_PDA+4+0)(%ecx)               /* base & 0x00ff0000 */
+       mov %ah, (__KERNEL_PDA+4+3)(%ecx)               /* base & 0xff000000 */
+       ret
+
 /*
  *  setup_idt
  *
@@ -465,6 +492,33 @@ ignore_int:
 #endif
        iret
 
+#ifdef CONFIG_PARAVIRT
+startup_paravirt:
+       cld
+       movl $(init_thread_union+THREAD_SIZE),%esp
+
+       /* We take pains to preserve all the regs. */
+       pushl   %edx
+       pushl   %ecx
+       pushl   %eax
+
+       /* paravirt.o is last in link, and that probe fn never returns */
+       pushl   $__start_paravirtprobe
+1:
+       movl    0(%esp), %eax
+       pushl   (%eax)
+       movl    8(%esp), %eax
+       call    *(%esp)
+       popl    %eax
+
+       movl    4(%esp), %eax
+       movl    8(%esp), %ecx
+       movl    12(%esp), %edx
+
+       addl    $4, (%esp)
+       jmp     1b
+#endif
+
 /*
  * Real beginning of normal "text" segment
  */
@@ -484,6 +538,8 @@ ENTRY(empty_zero_page)
  * This starts the data section.
  */
 .data
+ENTRY(start_pda)
+       .long boot_pda
 
 ENTRY(stack_start)
        .long init_thread_union+THREAD_SIZE
@@ -525,7 +581,7 @@ idt_descr:
 
 # boot GDT descriptor (later on used by CPU#0):
        .word 0                         # 32 bit align gdt_desc.address
-cpu_gdt_descr:
+ENTRY(cpu_gdt_descr)
        .word GDT_ENTRIES*8-1
        .long cpu_gdt_table
 
@@ -584,8 +640,8 @@ ENTRY(cpu_gdt_table)
        .quad 0x00009a000000ffff        /* 0xc0 APM CS 16 code (16 bit) */
        .quad 0x004092000000ffff        /* 0xc8 APM DS    data */
 
-       .quad 0x0000920000000000        /* 0xd0 - ESPFIX 16-bit SS */
-       .quad 0x0000000000000000        /* 0xd8 - unused */
+       .quad 0x00c0920000000000        /* 0xd0 - ESPFIX SS */
+       .quad 0x00cf92000000ffff        /* 0xd8 - PDA */
        .quad 0x0000000000000000        /* 0xe0 - unused */
        .quad 0x0000000000000000        /* 0xe8 - unused */
        .quad 0x0000000000000000        /* 0xf0 - unused */
index 17647a530b2f4b927b5a8f40e1d7d88f0acd482c..45a8685bb60bb5e21e638cd6c0b6df95586606f2 100644 (file)
@@ -34,6 +34,7 @@ static int __init init_hpet_clocksource(void)
        unsigned long hpet_period;
        void __iomem* hpet_base;
        u64 tmp;
+       int err;
 
        if (!is_hpet_enabled())
                return -ENODEV;
@@ -61,7 +62,11 @@ static int __init init_hpet_clocksource(void)
        do_div(tmp, FSEC_PER_NSEC);
        clocksource_hpet.mult = (u32)tmp;
 
-       return clocksource_register(&clocksource_hpet);
+       err = clocksource_register(&clocksource_hpet);
+       if (err)
+               iounmap(hpet_base);
+
+       return err;
 }
 
 module_init(init_hpet_clocksource);
index 62996cd17084245dafd53bcfab9555c20cc38c60..c8d45821c788f77467535569816d820d395f8a4b 100644 (file)
@@ -381,7 +381,10 @@ void __init init_ISA_irqs (void)
        }
 }
 
-void __init init_IRQ(void)
+/* Overridden in paravirt.c */
+void init_IRQ(void) __attribute__((weak, alias("native_init_IRQ")));
+
+void __init native_init_IRQ(void)
 {
        int i;
 
index 3b7a63e0ed1a5b07121ae63c9e35863ae0469a2b..e21dcde0790e62cd389b6062803e9bd014a51048 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/pci.h>
 #include <linux/msi.h>
 #include <linux/htirq.h>
+#include <linux/freezer.h>
 
 #include <asm/io.h>
 #include <asm/smp.h>
@@ -153,14 +154,20 @@ static struct IO_APIC_route_entry ioapic_read_entry(int apic, int pin)
  * the interrupt, and we need to make sure the entry is fully populated
  * before that happens.
  */
-static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
+static void
+__ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
 {
-       unsigned long flags;
        union entry_union eu;
        eu.entry = e;
-       spin_lock_irqsave(&ioapic_lock, flags);
        io_apic_write(apic, 0x11 + 2*pin, eu.w2);
        io_apic_write(apic, 0x10 + 2*pin, eu.w1);
+}
+
+static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
+{
+       unsigned long flags;
+       spin_lock_irqsave(&ioapic_lock, flags);
+       __ioapic_write_entry(apic, pin, e);
        spin_unlock_irqrestore(&ioapic_lock, flags);
 }
 
@@ -836,8 +843,7 @@ static int __init find_isa_irq_pin(int irq, int type)
 
                if ((mp_bus_id_to_type[lbus] == MP_BUS_ISA ||
                     mp_bus_id_to_type[lbus] == MP_BUS_EISA ||
-                    mp_bus_id_to_type[lbus] == MP_BUS_MCA ||
-                    mp_bus_id_to_type[lbus] == MP_BUS_NEC98
+                    mp_bus_id_to_type[lbus] == MP_BUS_MCA
                    ) &&
                    (mp_irqs[i].mpc_irqtype == type) &&
                    (mp_irqs[i].mpc_srcbusirq == irq))
@@ -856,8 +862,7 @@ static int __init find_isa_irq_apic(int irq, int type)
 
                if ((mp_bus_id_to_type[lbus] == MP_BUS_ISA ||
                     mp_bus_id_to_type[lbus] == MP_BUS_EISA ||
-                    mp_bus_id_to_type[lbus] == MP_BUS_MCA ||
-                    mp_bus_id_to_type[lbus] == MP_BUS_NEC98
+                    mp_bus_id_to_type[lbus] == MP_BUS_MCA
                    ) &&
                    (mp_irqs[i].mpc_irqtype == type) &&
                    (mp_irqs[i].mpc_srcbusirq == irq))
@@ -987,12 +992,6 @@ static int EISA_ELCR(unsigned int irq)
 #define default_MCA_trigger(idx)       (1)
 #define default_MCA_polarity(idx)      (0)
 
-/* NEC98 interrupts are always polarity zero edge triggered,
- * when listed as conforming in the MP table. */
-
-#define default_NEC98_trigger(idx)     (0)
-#define default_NEC98_polarity(idx)    (0)
-
 static int __init MPBIOS_polarity(int idx)
 {
        int bus = mp_irqs[idx].mpc_srcbus;
@@ -1027,11 +1026,6 @@ static int __init MPBIOS_polarity(int idx)
                                        polarity = default_MCA_polarity(idx);
                                        break;
                                }
-                               case MP_BUS_NEC98: /* NEC 98 pin */
-                               {
-                                       polarity = default_NEC98_polarity(idx);
-                                       break;
-                               }
                                default:
                                {
                                        printk(KERN_WARNING "broken BIOS!!\n");
@@ -1101,11 +1095,6 @@ static int MPBIOS_trigger(int idx)
                                        trigger = default_MCA_trigger(idx);
                                        break;
                                }
-                               case MP_BUS_NEC98: /* NEC 98 pin */
-                               {
-                                       trigger = default_NEC98_trigger(idx);
-                                       break;
-                               }
                                default:
                                {
                                        printk(KERN_WARNING "broken BIOS!!\n");
@@ -1167,7 +1156,6 @@ static int pin_2_irq(int idx, int apic, int pin)
                case MP_BUS_ISA: /* ISA pin */
                case MP_BUS_EISA:
                case MP_BUS_MCA:
-               case MP_BUS_NEC98:
                {
                        irq = mp_irqs[idx].mpc_srcbusirq;
                        break;
@@ -1235,7 +1223,7 @@ static inline int IO_APIC_irq_trigger(int irq)
 }
 
 /* irq_vectors is indexed by the sum of all RTEs in all I/O APICs. */
-u8 irq_vector[NR_IRQ_VECTORS] __read_mostly = { FIRST_DEVICE_VECTOR , 0 };
+static u8 irq_vector[NR_IRQ_VECTORS] __read_mostly = { FIRST_DEVICE_VECTOR , 0 };
 
 static int __assign_irq_vector(int irq)
 {
@@ -1360,8 +1348,8 @@ static void __init setup_IO_APIC_irqs(void)
                        if (!apic && (irq < 16))
                                disable_8259A_irq(irq);
                }
-               ioapic_write_entry(apic, pin, entry);
                spin_lock_irqsave(&ioapic_lock, flags);
+               __ioapic_write_entry(apic, pin, entry);
                set_native_irq_info(irq, TARGET_CPUS);
                spin_unlock_irqrestore(&ioapic_lock, flags);
        }
@@ -1926,6 +1914,15 @@ static void __init setup_ioapic_ids_from_mpc(void)
 static void __init setup_ioapic_ids_from_mpc(void) { }
 #endif
 
+static int no_timer_check __initdata;
+
+static int __init notimercheck(char *s)
+{
+       no_timer_check = 1;
+       return 1;
+}
+__setup("no_timer_check", notimercheck);
+
 /*
  * There is a nasty bug in some older SMP boards, their mptable lies
  * about the timer IRQ. We do the following to work around the situation:
@@ -1934,10 +1931,13 @@ static void __init setup_ioapic_ids_from_mpc(void) { }
  *     - if this function detects that timer IRQs are defunct, then we fall
  *       back to ISA timer IRQs
  */
-static int __init timer_irq_works(void)
+int __init timer_irq_works(void)
 {
        unsigned long t1 = jiffies;
 
+       if (no_timer_check)
+               return 1;
+
        local_irq_enable();
        /* Let ten ticks pass... */
        mdelay((10 * 1000) / HZ);
@@ -2161,9 +2161,15 @@ static inline void unlock_ExtINT_logic(void)
        unsigned char save_control, save_freq_select;
 
        pin  = find_isa_irq_pin(8, mp_INT);
+       if (pin == -1) {
+               WARN_ON_ONCE(1);
+               return;
+       }
        apic = find_isa_irq_apic(8, mp_INT);
-       if (pin == -1)
+       if (apic == -1) {
+               WARN_ON_ONCE(1);
                return;
+       }
 
        entry0 = ioapic_read_entry(apic, pin);
        clear_IO_APIC_pin(apic, pin);
@@ -2208,7 +2214,7 @@ int timer_uses_ioapic_pin_0;
  * is so screwy.  Thanks to Brian Perkins for testing/hacking this beast
  * fanatically on his truly buggy board.
  */
-static inline void check_timer(void)
+static inline void __init check_timer(void)
 {
        int apic1, pin1, apic2, pin2;
        int vector;
@@ -2856,8 +2862,8 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int a
        if (!ioapic && (irq < 16))
                disable_8259A_irq(irq);
 
-       ioapic_write_entry(ioapic, pin, entry);
        spin_lock_irqsave(&ioapic_lock, flags);
+       __ioapic_write_entry(ioapic, pin, entry);
        set_native_irq_info(irq, TARGET_CPUS);
        spin_unlock_irqrestore(&ioapic_lock, flags);
 
index fc79e1e859c498a9d640ba40fcff7494fe6110b6..af1d53344993cac32221d7209bf853bed4f5febc 100644 (file)
@@ -184,7 +184,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
 void __kprobes arch_remove_kprobe(struct kprobe *p)
 {
        mutex_lock(&kprobe_mutex);
-       free_insn_slot(p->ainsn.insn);
+       free_insn_slot(p->ainsn.insn, (p->ainsn.boostable == 1));
        mutex_unlock(&kprobe_mutex);
 }
 
@@ -333,7 +333,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
                return 1;
 
 ss_probe:
-#ifndef CONFIG_PREEMPT
+#if !defined(CONFIG_PREEMPT) || defined(CONFIG_PM)
        if (p->ainsn.boostable == 1 && !p->post_handler){
                /* Boost up -- we can execute copied instructions directly */
                reset_current_kprobe();
index 445211eb2d57cdfcab06bb2a0b1f3b2b6b6ad5da..b410e5fb034f285346ef41c4cc6929db3081790b 100644 (file)
@@ -160,16 +160,14 @@ static int read_default_ldt(void __user * ptr, unsigned long bytecount)
 {
        int err;
        unsigned long size;
-       void *address;
 
        err = 0;
-       address = &default_ldt[0];
        size = 5*sizeof(struct desc_struct);
        if (size > bytecount)
                size = bytecount;
 
        err = size;
-       if (copy_to_user(ptr, address, size))
+       if (clear_user(ptr, size))
                err = -EFAULT;
 
        return err;
index eb57a851789dc9061aeacf0a2a83813a45f93be6..b83672b895278798957b4a9748e96965c3d23e08 100644 (file)
@@ -283,10 +283,9 @@ static int __init mca_init(void)
        bus->f.mca_transform_memory = mca_dummy_transform_memory;
 
        /* get the motherboard device */
-       mca_dev = kmalloc(sizeof(struct mca_device), GFP_KERNEL);
+       mca_dev = kzalloc(sizeof(struct mca_device), GFP_KERNEL);
        if(unlikely(!mca_dev))
                goto out_nomem;
-       memset(mca_dev, 0, sizeof(struct mca_device));
 
        /*
         * We do not expect many MCA interrupts during initialization,
@@ -310,11 +309,9 @@ static int __init mca_init(void)
        mca_dev->slot = MCA_MOTHERBOARD;
        mca_register_device(MCA_PRIMARY_BUS, mca_dev);
 
-       mca_dev = kmalloc(sizeof(struct mca_device), GFP_ATOMIC);
+       mca_dev = kzalloc(sizeof(struct mca_device), GFP_ATOMIC);
        if(unlikely(!mca_dev))
                goto out_unlock_nomem;
-       memset(mca_dev, 0, sizeof(struct mca_device));
-
 
        /* Put motherboard into video setup mode, read integrated video
         * POS registers, and turn motherboard setup off.
@@ -349,10 +346,9 @@ static int __init mca_init(void)
        }
        if(which_scsi) {
                /* found a scsi card */
-               mca_dev = kmalloc(sizeof(struct mca_device), GFP_ATOMIC);
+               mca_dev = kzalloc(sizeof(struct mca_device), GFP_ATOMIC);
                if(unlikely(!mca_dev))
                        goto out_unlock_nomem;
-               memset(mca_dev, 0, sizeof(struct mca_device));
 
                for(j = 0; j < 8; j++)
                        mca_dev->pos[j] = pos[j];
@@ -378,10 +374,9 @@ static int __init mca_init(void)
                if(!mca_read_and_store_pos(pos))
                        continue;
 
-               mca_dev = kmalloc(sizeof(struct mca_device), GFP_ATOMIC);
+               mca_dev = kzalloc(sizeof(struct mca_device), GFP_ATOMIC);
                if(unlikely(!mca_dev))
                        goto out_unlock_nomem;
-               memset(mca_dev, 0, sizeof(struct mca_device));
 
                for(j=0; j<8; j++)
                        mca_dev->pos[j]=pos[j];
index 23f5984d06540f9c42183b232ad98e488b5218ae..972346604f9d1b7d23841e317ff46c7559f49851 100644 (file)
@@ -703,7 +703,6 @@ static struct sysdev_driver mc_sysdev_driver = {
        .resume = mc_sysdev_resume,
 };
 
-#ifdef CONFIG_HOTPLUG_CPU
 static __cpuinit int
 mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
 {
@@ -726,7 +725,6 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
 static struct notifier_block mc_cpu_notifier = {
        .notifier_call = mc_cpu_callback,
 };
-#endif
 
 static int __init microcode_init (void)
 {
index 470cf97e7cd3104bbfd6eb2de379d0bd0be9c460..3db0a5442eb1bab48d9bbdfa93a0a9ccd5b74fa0 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/fs.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
+#include <linux/bug.h>
 
 #if 0
 #define DEBUGP printk
@@ -108,7 +109,8 @@ int module_finalize(const Elf_Ehdr *hdr,
                    const Elf_Shdr *sechdrs,
                    struct module *me)
 {
-       const Elf_Shdr *s, *text = NULL, *alt = NULL, *locks = NULL;
+       const Elf_Shdr *s, *text = NULL, *alt = NULL, *locks = NULL,
+               *para = NULL;
        char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
 
        for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) { 
@@ -118,6 +120,8 @@ int module_finalize(const Elf_Ehdr *hdr,
                        alt = s;
                if (!strcmp(".smp_locks", secstrings + s->sh_name))
                        locks= s;
+               if (!strcmp(".parainstructions", secstrings + s->sh_name))
+                       para = s;
        }
 
        if (alt) {
@@ -132,10 +136,17 @@ int module_finalize(const Elf_Ehdr *hdr,
                                            lseg, lseg + locks->sh_size,
                                            tseg, tseg + text->sh_size);
        }
-       return 0;
+
+       if (para) {
+               void *pseg = (void *)para->sh_addr;
+               apply_paravirt(pseg, pseg + para->sh_size);
+       }
+
+       return module_bug_finalize(hdr, sechdrs, me);
 }
 
 void module_arch_cleanup(struct module *mod)
 {
        alternatives_smp_module_del(mod);
+       module_bug_cleanup(mod);
 }
index 442aaf8c77ebf593fd249f9f4e69db8df3070be9..2ce67228dff8a28e634b714b03e1898aa9fd3b7c 100644 (file)
@@ -249,8 +249,6 @@ static void __init MP_bus_info (struct mpc_config_bus *m)
                mp_current_pci_id++;
        } else if (strncmp(str, BUSTYPE_MCA, sizeof(BUSTYPE_MCA)-1) == 0) {
                mp_bus_id_to_type[m->mpc_busid] = MP_BUS_MCA;
-       } else if (strncmp(str, BUSTYPE_NEC98, sizeof(BUSTYPE_NEC98)-1) == 0) {
-               mp_bus_id_to_type[m->mpc_busid] = MP_BUS_NEC98;
        } else {
                printk(KERN_WARNING "Unknown bustype %s - ignoring\n", str);
        }
index a773f776c9ea3bef1627644e367f224f62105921..4a472a17d1c684f07c39054478599c14aeff6ab9 100644 (file)
@@ -172,7 +172,7 @@ static ssize_t msr_read(struct file *file, char __user * buf,
        u32 __user *tmp = (u32 __user *) buf;
        u32 data[2];
        u32 reg = *ppos;
-       int cpu = iminor(file->f_dentry->d_inode);
+       int cpu = iminor(file->f_path.dentry->d_inode);
        int err;
 
        if (count % 8)
@@ -195,15 +195,14 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
 {
        const u32 __user *tmp = (const u32 __user *)buf;
        u32 data[2];
-       size_t rv;
        u32 reg = *ppos;
-       int cpu = iminor(file->f_dentry->d_inode);
+       int cpu = iminor(file->f_path.dentry->d_inode);
        int err;
 
        if (count % 8)
                return -EINVAL; /* Invalid chunk size */
 
-       for (rv = 0; count; count -= 8) {
+       for (; count; count -= 8) {
                if (copy_from_user(&data, tmp, 8))
                        return -EFAULT;
                err = do_wrmsr(cpu, reg, data[0], data[1]);
@@ -217,7 +216,7 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
 
 static int msr_open(struct inode *inode, struct file *file)
 {
-       unsigned int cpu = iminor(file->f_dentry->d_inode);
+       unsigned int cpu = iminor(file->f_path.dentry->d_inode);
        struct cpuinfo_x86 *c = &(cpu_data)[cpu];
 
        if (cpu >= NR_CPUS || !cpu_online(cpu))
@@ -250,7 +249,6 @@ static int msr_device_create(int i)
        return err;
 }
 
-#ifdef CONFIG_HOTPLUG_CPU
 static int msr_class_cpu_callback(struct notifier_block *nfb,
                                unsigned long action, void *hcpu)
 {
@@ -271,7 +269,6 @@ static struct notifier_block __cpuinitdata msr_class_cpu_notifier =
 {
        .notifier_call = msr_class_cpu_callback,
 };
-#endif
 
 static int __init msr_init(void)
 {
index eaafe233a5da83f4abbb2c17e670b8a46fa4edaa..f5bc7e1be8016b504a65270a0a6f2d6aafe1e0eb 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/percpu.h>
 #include <linux/dmi.h>
 #include <linux/kprobes.h>
+#include <linux/cpumask.h>
 
 #include <asm/smp.h>
 #include <asm/nmi.h>
@@ -42,6 +43,8 @@ int nmi_watchdog_enabled;
 static DEFINE_PER_CPU(unsigned long, perfctr_nmi_owner);
 static DEFINE_PER_CPU(unsigned long, evntsel_nmi_owner[3]);
 
+static cpumask_t backtrace_mask = CPU_MASK_NONE;
+
 /* this number is calculated from Intel's MSR_P4_CRU_ESCR5 register and it's
  * offset from MSR_P4_BSU_ESCR0.  It will be the max for all platforms (for now)
  */
@@ -867,14 +870,16 @@ static unsigned int
 
 void touch_nmi_watchdog (void)
 {
-       int i;
+       if (nmi_watchdog > 0) {
+               unsigned cpu;
 
-       /*
-        * Just reset the alert counters, (other CPUs might be
-        * spinning on locks we hold):
-        */
-       for_each_possible_cpu(i)
-               alert_counter[i] = 0;
+               /*
+                * Just reset the alert counters, (other CPUs might be
+                * spinning on locks we hold):
+                */
+               for_each_present_cpu (cpu)
+                       alert_counter[cpu] = 0;
+       }
 
        /*
         * Tickle the softlockup detector too:
@@ -907,6 +912,16 @@ __kprobes int nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
                touched = 1;
        }
 
+       if (cpu_isset(cpu, backtrace_mask)) {
+               static DEFINE_SPINLOCK(lock);   /* Serialise the printks */
+
+               spin_lock(&lock);
+               printk("NMI backtrace for cpu %d\n", cpu);
+               dump_stack();
+               spin_unlock(&lock);
+               cpu_clear(cpu, backtrace_mask);
+       }
+
        sum = per_cpu(irq_stat, cpu).apic_timer_irqs;
 
        /* if the apic timer isn't firing, this cpu isn't doing much */
@@ -1033,6 +1048,19 @@ int proc_nmi_enabled(struct ctl_table *table, int write, struct file *file,
 
 #endif
 
+void __trigger_all_cpu_backtrace(void)
+{
+       int i;
+
+       backtrace_mask = cpu_online_map;
+       /* Wait for up to 10 seconds for all CPUs to do the backtrace */
+       for (i = 0; i < 10 * 1000; i++) {
+               if (cpus_empty(backtrace_mask))
+                       break;
+               mdelay(1);
+       }
+}
+
 EXPORT_SYMBOL(nmi_active);
 EXPORT_SYMBOL(nmi_watchdog);
 EXPORT_SYMBOL(avail_to_resrv_perfctr_nmi);
diff --git a/arch/i386/kernel/paravirt.c b/arch/i386/kernel/paravirt.c
new file mode 100644 (file)
index 0000000..3dceab5
--- /dev/null
@@ -0,0 +1,569 @@
+/*  Paravirtualization interfaces
+    Copyright (C) 2006 Rusty Russell IBM Corporation
+
+    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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+#include <linux/errno.h>
+#include <linux/module.h>
+#include <linux/efi.h>
+#include <linux/bcd.h>
+#include <linux/start_kernel.h>
+
+#include <asm/bug.h>
+#include <asm/paravirt.h>
+#include <asm/desc.h>
+#include <asm/setup.h>
+#include <asm/arch_hooks.h>
+#include <asm/time.h>
+#include <asm/irq.h>
+#include <asm/delay.h>
+#include <asm/fixmap.h>
+#include <asm/apic.h>
+#include <asm/tlbflush.h>
+
+/* nop stub */
+static void native_nop(void)
+{
+}
+
+static void __init default_banner(void)
+{
+       printk(KERN_INFO "Booting paravirtualized kernel on %s\n",
+              paravirt_ops.name);
+}
+
+char *memory_setup(void)
+{
+       return paravirt_ops.memory_setup();
+}
+
+/* Simple instruction patching code. */
+#define DEF_NATIVE(name, code)                                 \
+       extern const char start_##name[], end_##name[];         \
+       asm("start_" #name ": " code "; end_" #name ":")
+DEF_NATIVE(cli, "cli");
+DEF_NATIVE(sti, "sti");
+DEF_NATIVE(popf, "push %eax; popf");
+DEF_NATIVE(pushf, "pushf; pop %eax");
+DEF_NATIVE(pushf_cli, "pushf; pop %eax; cli");
+DEF_NATIVE(iret, "iret");
+DEF_NATIVE(sti_sysexit, "sti; sysexit");
+
+static const struct native_insns
+{
+       const char *start, *end;
+} native_insns[] = {
+       [PARAVIRT_IRQ_DISABLE] = { start_cli, end_cli },
+       [PARAVIRT_IRQ_ENABLE] = { start_sti, end_sti },
+       [PARAVIRT_RESTORE_FLAGS] = { start_popf, end_popf },
+       [PARAVIRT_SAVE_FLAGS] = { start_pushf, end_pushf },
+       [PARAVIRT_SAVE_FLAGS_IRQ_DISABLE] = { start_pushf_cli, end_pushf_cli },
+       [PARAVIRT_INTERRUPT_RETURN] = { start_iret, end_iret },
+       [PARAVIRT_STI_SYSEXIT] = { start_sti_sysexit, end_sti_sysexit },
+};
+
+static unsigned native_patch(u8 type, u16 clobbers, void *insns, unsigned len)
+{
+       unsigned int insn_len;
+
+       /* Don't touch it if we don't have a replacement */
+       if (type >= ARRAY_SIZE(native_insns) || !native_insns[type].start)
+               return len;
+
+       insn_len = native_insns[type].end - native_insns[type].start;
+
+       /* Similarly if we can't fit replacement. */
+       if (len < insn_len)
+               return len;
+
+       memcpy(insns, native_insns[type].start, insn_len);
+       return insn_len;
+}
+
+static fastcall unsigned long native_get_debugreg(int regno)
+{
+       unsigned long val = 0;  /* Damn you, gcc! */
+
+       switch (regno) {
+       case 0:
+               asm("movl %%db0, %0" :"=r" (val)); break;
+       case 1:
+               asm("movl %%db1, %0" :"=r" (val)); break;
+       case 2:
+               asm("movl %%db2, %0" :"=r" (val)); break;
+       case 3:
+               asm("movl %%db3, %0" :"=r" (val)); break;
+       case 6:
+               asm("movl %%db6, %0" :"=r" (val)); break;
+       case 7:
+               asm("movl %%db7, %0" :"=r" (val)); break;
+       default:
+               BUG();
+       }
+       return val;
+}
+
+static fastcall void native_set_debugreg(int regno, unsigned long value)
+{
+       switch (regno) {
+       case 0:
+               asm("movl %0,%%db0"     : /* no output */ :"r" (value));
+               break;
+       case 1:
+               asm("movl %0,%%db1"     : /* no output */ :"r" (value));
+               break;
+       case 2:
+               asm("movl %0,%%db2"     : /* no output */ :"r" (value));
+               break;
+       case 3:
+               asm("movl %0,%%db3"     : /* no output */ :"r" (value));
+               break;
+       case 6:
+               asm("movl %0,%%db6"     : /* no output */ :"r" (value));
+               break;
+       case 7:
+               asm("movl %0,%%db7"     : /* no output */ :"r" (value));
+               break;
+       default:
+               BUG();
+       }
+}
+
+void init_IRQ(void)
+{
+       paravirt_ops.init_IRQ();
+}
+
+static fastcall void native_clts(void)
+{
+       asm volatile ("clts");
+}
+
+static fastcall unsigned long native_read_cr0(void)
+{
+       unsigned long val;
+       asm volatile("movl %%cr0,%0\n\t" :"=r" (val));
+       return val;
+}
+
+static fastcall void native_write_cr0(unsigned long val)
+{
+       asm volatile("movl %0,%%cr0": :"r" (val));
+}
+
+static fastcall unsigned long native_read_cr2(void)
+{
+       unsigned long val;
+       asm volatile("movl %%cr2,%0\n\t" :"=r" (val));
+       return val;
+}
+
+static fastcall void native_write_cr2(unsigned long val)
+{
+       asm volatile("movl %0,%%cr2": :"r" (val));
+}
+
+static fastcall unsigned long native_read_cr3(void)
+{
+       unsigned long val;
+       asm volatile("movl %%cr3,%0\n\t" :"=r" (val));
+       return val;
+}
+
+static fastcall void native_write_cr3(unsigned long val)
+{
+       asm volatile("movl %0,%%cr3": :"r" (val));
+}
+
+static fastcall unsigned long native_read_cr4(void)
+{
+       unsigned long val;
+       asm volatile("movl %%cr4,%0\n\t" :"=r" (val));
+       return val;
+}
+
+static fastcall unsigned long native_read_cr4_safe(void)
+{
+       unsigned long val;
+       /* This could fault if %cr4 does not exist */
+       asm("1: movl %%cr4, %0          \n"
+               "2:                             \n"
+               ".section __ex_table,\"a\"      \n"
+               ".long 1b,2b                    \n"
+               ".previous                      \n"
+               : "=r" (val): "0" (0));
+       return val;
+}
+
+static fastcall void native_write_cr4(unsigned long val)
+{
+       asm volatile("movl %0,%%cr4": :"r" (val));
+}
+
+static fastcall unsigned long native_save_fl(void)
+{
+       unsigned long f;
+       asm volatile("pushfl ; popl %0":"=g" (f): /* no input */);
+       return f;
+}
+
+static fastcall void native_restore_fl(unsigned long f)
+{
+       asm volatile("pushl %0 ; popfl": /* no output */
+                            :"g" (f)
+                            :"memory", "cc");
+}
+
+static fastcall void native_irq_disable(void)
+{
+       asm volatile("cli": : :"memory");
+}
+
+static fastcall void native_irq_enable(void)
+{
+       asm volatile("sti": : :"memory");
+}
+
+static fastcall void native_safe_halt(void)
+{
+       asm volatile("sti; hlt": : :"memory");
+}
+
+static fastcall void native_halt(void)
+{
+       asm volatile("hlt": : :"memory");
+}
+
+static fastcall void native_wbinvd(void)
+{
+       asm volatile("wbinvd": : :"memory");
+}
+
+static fastcall unsigned long long native_read_msr(unsigned int msr, int *err)
+{
+       unsigned long long val;
+
+       asm volatile("2: rdmsr ; xorl %0,%0\n"
+                    "1:\n\t"
+                    ".section .fixup,\"ax\"\n\t"
+                    "3:  movl %3,%0 ; jmp 1b\n\t"
+                    ".previous\n\t"
+                    ".section __ex_table,\"a\"\n"
+                    "   .align 4\n\t"
+                    "   .long  2b,3b\n\t"
+                    ".previous"
+                    : "=r" (*err), "=A" (val)
+                    : "c" (msr), "i" (-EFAULT));
+
+       return val;
+}
+
+static fastcall int native_write_msr(unsigned int msr, unsigned long long val)
+{
+       int err;
+       asm volatile("2: wrmsr ; xorl %0,%0\n"
+                    "1:\n\t"
+                    ".section .fixup,\"ax\"\n\t"
+                    "3:  movl %4,%0 ; jmp 1b\n\t"
+                    ".previous\n\t"
+                    ".section __ex_table,\"a\"\n"
+                    "   .align 4\n\t"
+                    "   .long  2b,3b\n\t"
+                    ".previous"
+                    : "=a" (err)
+                    : "c" (msr), "0" ((u32)val), "d" ((u32)(val>>32)),
+                      "i" (-EFAULT));
+       return err;
+}
+
+static fastcall unsigned long long native_read_tsc(void)
+{
+       unsigned long long val;
+       asm volatile("rdtsc" : "=A" (val));
+       return val;
+}
+
+static fastcall unsigned long long native_read_pmc(void)
+{
+       unsigned long long val;
+       asm volatile("rdpmc" : "=A" (val));
+       return val;
+}
+
+static fastcall void native_load_tr_desc(void)
+{
+       asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
+}
+
+static fastcall void native_load_gdt(const struct Xgt_desc_struct *dtr)
+{
+       asm volatile("lgdt %0"::"m" (*dtr));
+}
+
+static fastcall void native_load_idt(const struct Xgt_desc_struct *dtr)
+{
+       asm volatile("lidt %0"::"m" (*dtr));
+}
+
+static fastcall void native_store_gdt(struct Xgt_desc_struct *dtr)
+{
+       asm ("sgdt %0":"=m" (*dtr));
+}
+
+static fastcall void native_store_idt(struct Xgt_desc_struct *dtr)
+{
+       asm ("sidt %0":"=m" (*dtr));
+}
+
+static fastcall unsigned long native_store_tr(void)
+{
+       unsigned long tr;
+       asm ("str %0":"=r" (tr));
+       return tr;
+}
+
+static fastcall void native_load_tls(struct thread_struct *t, unsigned int cpu)
+{
+#define C(i) get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i]
+       C(0); C(1); C(2);
+#undef C
+}
+
+static inline void native_write_dt_entry(void *dt, int entry, u32 entry_low, u32 entry_high)
+{
+       u32 *lp = (u32 *)((char *)dt + entry*8);
+       lp[0] = entry_low;
+       lp[1] = entry_high;
+}
+
+static fastcall void native_write_ldt_entry(void *dt, int entrynum, u32 low, u32 high)
+{
+       native_write_dt_entry(dt, entrynum, low, high);
+}
+
+static fastcall void native_write_gdt_entry(void *dt, int entrynum, u32 low, u32 high)
+{
+       native_write_dt_entry(dt, entrynum, low, high);
+}
+
+static fastcall void native_write_idt_entry(void *dt, int entrynum, u32 low, u32 high)
+{
+       native_write_dt_entry(dt, entrynum, low, high);
+}
+
+static fastcall void native_load_esp0(struct tss_struct *tss,
+                                     struct thread_struct *thread)
+{
+       tss->esp0 = thread->esp0;
+
+       /* This can only happen when SEP is enabled, no need to test "SEP"arately */
+       if (unlikely(tss->ss1 != thread->sysenter_cs)) {
+               tss->ss1 = thread->sysenter_cs;
+               wrmsr(MSR_IA32_SYSENTER_CS, thread->sysenter_cs, 0);
+       }
+}
+
+static fastcall void native_io_delay(void)
+{
+       asm volatile("outb %al,$0x80");
+}
+
+static fastcall void native_flush_tlb(void)
+{
+       __native_flush_tlb();
+}
+
+/*
+ * Global pages have to be flushed a bit differently. Not a real
+ * performance problem because this does not happen often.
+ */
+static fastcall void native_flush_tlb_global(void)
+{
+       __native_flush_tlb_global();
+}
+
+static fastcall void native_flush_tlb_single(u32 addr)
+{
+       __native_flush_tlb_single(addr);
+}
+
+#ifndef CONFIG_X86_PAE
+static fastcall void native_set_pte(pte_t *ptep, pte_t pteval)
+{
+       *ptep = pteval;
+}
+
+static fastcall void native_set_pte_at(struct mm_struct *mm, u32 addr, pte_t *ptep, pte_t pteval)
+{
+       *ptep = pteval;
+}
+
+static fastcall void native_set_pmd(pmd_t *pmdp, pmd_t pmdval)
+{
+       *pmdp = pmdval;
+}
+
+#else /* CONFIG_X86_PAE */
+
+static fastcall void native_set_pte(pte_t *ptep, pte_t pte)
+{
+       ptep->pte_high = pte.pte_high;
+       smp_wmb();
+       ptep->pte_low = pte.pte_low;
+}
+
+static fastcall void native_set_pte_at(struct mm_struct *mm, u32 addr, pte_t *ptep, pte_t pte)
+{
+       ptep->pte_high = pte.pte_high;
+       smp_wmb();
+       ptep->pte_low = pte.pte_low;
+}
+
+static fastcall void native_set_pte_present(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte)
+{
+       ptep->pte_low = 0;
+       smp_wmb();
+       ptep->pte_high = pte.pte_high;
+       smp_wmb();
+       ptep->pte_low = pte.pte_low;
+}
+
+static fastcall void native_set_pte_atomic(pte_t *ptep, pte_t pteval)
+{
+       set_64bit((unsigned long long *)ptep,pte_val(pteval));
+}
+
+static fastcall void native_set_pmd(pmd_t *pmdp, pmd_t pmdval)
+{
+       set_64bit((unsigned long long *)pmdp,pmd_val(pmdval));
+}
+
+static fastcall void native_set_pud(pud_t *pudp, pud_t pudval)
+{
+       *pudp = pudval;
+}
+
+static fastcall void native_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
+{
+       ptep->pte_low = 0;
+       smp_wmb();
+       ptep->pte_high = 0;
+}
+
+static fastcall void native_pmd_clear(pmd_t *pmd)
+{
+       u32 *tmp = (u32 *)pmd;
+       *tmp = 0;
+       smp_wmb();
+       *(tmp + 1) = 0;
+}
+#endif /* CONFIG_X86_PAE */
+
+/* These are in entry.S */
+extern fastcall void native_iret(void);
+extern fastcall void native_irq_enable_sysexit(void);
+
+static int __init print_banner(void)
+{
+       paravirt_ops.banner();
+       return 0;
+}
+core_initcall(print_banner);
+
+/* We simply declare start_kernel to be the paravirt probe of last resort. */
+paravirt_probe(start_kernel);
+
+struct paravirt_ops paravirt_ops = {
+       .name = "bare hardware",
+       .paravirt_enabled = 0,
+       .kernel_rpl = 0,
+
+       .patch = native_patch,
+       .banner = default_banner,
+       .arch_setup = native_nop,
+       .memory_setup = machine_specific_memory_setup,
+       .get_wallclock = native_get_wallclock,
+       .set_wallclock = native_set_wallclock,
+       .time_init = time_init_hook,
+       .init_IRQ = native_init_IRQ,
+
+       .cpuid = native_cpuid,
+       .get_debugreg = native_get_debugreg,
+       .set_debugreg = native_set_debugreg,
+       .clts = native_clts,
+       .read_cr0 = native_read_cr0,
+       .write_cr0 = native_write_cr0,
+       .read_cr2 = native_read_cr2,
+       .write_cr2 = native_write_cr2,
+       .read_cr3 = native_read_cr3,
+       .write_cr3 = native_write_cr3,
+       .read_cr4 = native_read_cr4,
+       .read_cr4_safe = native_read_cr4_safe,
+       .write_cr4 = native_write_cr4,
+       .save_fl = native_save_fl,
+       .restore_fl = native_restore_fl,
+       .irq_disable = native_irq_disable,
+       .irq_enable = native_irq_enable,
+       .safe_halt = native_safe_halt,
+       .halt = native_halt,
+       .wbinvd = native_wbinvd,
+       .read_msr = native_read_msr,
+       .write_msr = native_write_msr,
+       .read_tsc = native_read_tsc,
+       .read_pmc = native_read_pmc,
+       .load_tr_desc = native_load_tr_desc,
+       .set_ldt = native_set_ldt,
+       .load_gdt = native_load_gdt,
+       .load_idt = native_load_idt,
+       .store_gdt = native_store_gdt,
+       .store_idt = native_store_idt,
+       .store_tr = native_store_tr,
+       .load_tls = native_load_tls,
+       .write_ldt_entry = native_write_ldt_entry,
+       .write_gdt_entry = native_write_gdt_entry,
+       .write_idt_entry = native_write_idt_entry,
+       .load_esp0 = native_load_esp0,
+
+       .set_iopl_mask = native_set_iopl_mask,
+       .io_delay = native_io_delay,
+       .const_udelay = __const_udelay,
+
+#ifdef CONFIG_X86_LOCAL_APIC
+       .apic_write = native_apic_write,
+       .apic_write_atomic = native_apic_write_atomic,
+       .apic_read = native_apic_read,
+#endif
+
+       .flush_tlb_user = native_flush_tlb,
+       .flush_tlb_kernel = native_flush_tlb_global,
+       .flush_tlb_single = native_flush_tlb_single,
+
+       .set_pte = native_set_pte,
+       .set_pte_at = native_set_pte_at,
+       .set_pmd = native_set_pmd,
+       .pte_update = (void *)native_nop,
+       .pte_update_defer = (void *)native_nop,
+#ifdef CONFIG_X86_PAE
+       .set_pte_atomic = native_set_pte_atomic,
+       .set_pte_present = native_set_pte_present,
+       .set_pud = native_set_pud,
+       .pte_clear = native_pte_clear,
+       .pmd_clear = native_pmd_clear,
+#endif
+
+       .irq_enable_sysexit = native_irq_enable_sysexit,
+       .iret = native_iret,
+};
+EXPORT_SYMBOL(paravirt_ops);
index 5c8c6ef1fc5e650c3af994b0c5d569b3e693fbca..41af692c1584908b6864356b757294b64b787de2 100644 (file)
@@ -92,14 +92,12 @@ int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
        if (!mem_base)
                goto out;
 
-       dev->dma_mem = kmalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL);
+       dev->dma_mem = kzalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL);
        if (!dev->dma_mem)
                goto out;
-       memset(dev->dma_mem, 0, sizeof(struct dma_coherent_mem));
-       dev->dma_mem->bitmap = kmalloc(bitmap_size, GFP_KERNEL);
+       dev->dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
        if (!dev->dma_mem->bitmap)
                goto free1_out;
-       memset(dev->dma_mem->bitmap, 0, bitmap_size);
 
        dev->dma_mem->virt_base = mem_base;
        dev->dma_mem->device_base = device_addr;
index dd53c58f64f1bd944dd65190fc5d8f98bf6c8643..99308510a17c7fdab49f6a90a1f09e9f9917cf37 100644 (file)
@@ -56,6 +56,7 @@
 
 #include <asm/tlbflush.h>
 #include <asm/cpu.h>
+#include <asm/pda.h>
 
 asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
 
@@ -99,22 +100,18 @@ EXPORT_SYMBOL(enable_hlt);
  */
 void default_idle(void)
 {
-       local_irq_enable();
-
        if (!hlt_counter && boot_cpu_data.hlt_works_ok) {
                current_thread_info()->status &= ~TS_POLLING;
                smp_mb__after_clear_bit();
-               while (!need_resched()) {
-                       local_irq_disable();
-                       if (!need_resched())
-                               safe_halt();
-                       else
-                               local_irq_enable();
-               }
+               local_irq_disable();
+               if (!need_resched())
+                       safe_halt();    /* enables interrupts racelessly */
+               else
+                       local_irq_enable();
                current_thread_info()->status |= TS_POLLING;
        } else {
-               while (!need_resched())
-                       cpu_relax();
+               /* loop is done by the caller */
+               cpu_relax();
        }
 }
 #ifdef CONFIG_APM_MODULE
@@ -128,14 +125,7 @@ EXPORT_SYMBOL(default_idle);
  */
 static void poll_idle (void)
 {
-       local_irq_enable();
-
-       asm volatile(
-               "2:"
-               "testl %0, %1;"
-               "rep; nop;"
-               "je 2b;"
-               : : "i"(_TIF_NEED_RESCHED), "m" (current_thread_info()->flags));
+       cpu_relax();
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
@@ -256,8 +246,7 @@ void mwait_idle_with_hints(unsigned long eax, unsigned long ecx)
 static void mwait_idle(void)
 {
        local_irq_enable();
-       while (!need_resched())
-               mwait_idle_with_hints(0, 0);
+       mwait_idle_with_hints(0, 0);
 }
 
 void __devinit select_idle_routine(const struct cpuinfo_x86 *c)
@@ -314,8 +303,8 @@ void show_regs(struct pt_regs * regs)
                regs->eax,regs->ebx,regs->ecx,regs->edx);
        printk("ESI: %08lx EDI: %08lx EBP: %08lx",
                regs->esi, regs->edi, regs->ebp);
-       printk(" DS: %04x ES: %04x\n",
-               0xffff & regs->xds,0xffff & regs->xes);
+       printk(" DS: %04x ES: %04x GS: %04x\n",
+              0xffff & regs->xds,0xffff & regs->xes, 0xffff & regs->xgs);
 
        cr0 = read_cr0();
        cr2 = read_cr2();
@@ -346,6 +335,7 @@ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
 
        regs.xds = __USER_DS;
        regs.xes = __USER_DS;
+       regs.xgs = __KERNEL_PDA;
        regs.orig_eax = -1;
        regs.eip = (unsigned long) kernel_thread_helper;
        regs.xcs = __KERNEL_CS | get_kernel_rpl();
@@ -431,7 +421,6 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long esp,
        p->thread.eip = (unsigned long) ret_from_fork;
 
        savesegment(fs,p->thread.fs);
-       savesegment(gs,p->thread.gs);
 
        tsk = current;
        if (unlikely(test_tsk_thread_flag(tsk, TIF_IO_BITMAP))) {
@@ -508,7 +497,7 @@ void dump_thread(struct pt_regs * regs, struct user * dump)
        dump->regs.ds = regs->xds;
        dump->regs.es = regs->xes;
        savesegment(fs,dump->regs.fs);
-       savesegment(gs,dump->regs.gs);
+       dump->regs.gs = regs->xgs;
        dump->regs.orig_eax = regs->orig_eax;
        dump->regs.eip = regs->eip;
        dump->regs.cs = regs->xcs;
@@ -648,22 +637,27 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas
 
        __unlazy_fpu(prev_p);
 
+
+       /* we're going to use this soon, after a few expensive things */
+       if (next_p->fpu_counter > 5)
+               prefetch(&next->i387.fxsave);
+
        /*
         * Reload esp0.
         */
        load_esp0(tss, next);
 
        /*
-        * Save away %fs and %gs. No need to save %es and %ds, as
-        * those are always kernel segments while inside the kernel.
-        * Doing this before setting the new TLS descriptors avoids
-        * the situation where we temporarily have non-reloadable
-        * segments in %fs and %gs.  This could be an issue if the
-        * NMI handler ever used %fs or %gs (it does not today), or
-        * if the kernel is running inside of a hypervisor layer.
+        * Save away %fs. No need to save %gs, as it was saved on the
+        * stack on entry.  No need to save %es and %ds, as those are
+        * always kernel segments while inside the kernel.  Doing this
+        * before setting the new TLS descriptors avoids the situation
+        * where we temporarily have non-reloadable segments in %fs
+        * and %gs.  This could be an issue if the NMI handler ever
+        * used %fs or %gs (it does not today), or if the kernel is
+        * running inside of a hypervisor layer.
         */
        savesegment(fs, prev->fs);
-       savesegment(gs, prev->gs);
 
        /*
         * Load the per-thread Thread-Local Storage descriptor.
@@ -671,22 +665,14 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas
        load_TLS(next, cpu);
 
        /*
-        * Restore %fs and %gs if needed.
+        * Restore %fs if needed.
         *
-        * Glibc normally makes %fs be zero, and %gs is one of
-        * the TLS segments.
+        * Glibc normally makes %fs be zero.
         */
        if (unlikely(prev->fs | next->fs))
                loadsegment(fs, next->fs);
 
-       if (prev->gs | next->gs)
-               loadsegment(gs, next->gs);
-
-       /*
-        * Restore IOPL if needed.
-        */
-       if (unlikely(prev->iopl != next->iopl))
-               set_iopl_mask(next->iopl);
+       write_pda(pcurrent, next_p);
 
        /*
         * Now maybe handle debug registers and/or IO bitmaps
@@ -697,6 +683,13 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas
 
        disable_tsc(prev_p, next_p);
 
+       /* If the task has used fpu the last 5 timeslices, just do a full
+        * restore of the math state immediately to avoid the trap; the
+        * chances of needing FPU soon are obviously high now
+        */
+       if (next_p->fpu_counter > 5)
+               math_state_restore();
+
        return prev_p;
 }
 
index 775f50e9395bb048a2e193ef60483af172c7c045..f3f94ac5736a254c4a97eb58aa7335a70328df18 100644 (file)
@@ -94,13 +94,9 @@ static int putreg(struct task_struct *child,
                                return -EIO;
                        child->thread.fs = value;
                        return 0;
-               case GS:
-                       if (value && (value & 3) != 3)
-                               return -EIO;
-                       child->thread.gs = value;
-                       return 0;
                case DS:
                case ES:
+               case GS:
                        if (value && (value & 3) != 3)
                                return -EIO;
                        value &= 0xffff;
@@ -116,8 +112,8 @@ static int putreg(struct task_struct *child,
                        value |= get_stack_long(child, EFL_OFFSET) & ~FLAG_MASK;
                        break;
        }
-       if (regno > GS*4)
-               regno -= 2*4;
+       if (regno > ES*4)
+               regno -= 1*4;
        put_stack_long(child, regno - sizeof(struct pt_regs), value);
        return 0;
 }
@@ -131,18 +127,16 @@ static unsigned long getreg(struct task_struct *child,
                case FS:
                        retval = child->thread.fs;
                        break;
-               case GS:
-                       retval = child->thread.gs;
-                       break;
                case DS:
                case ES:
+               case GS:
                case SS:
                case CS:
                        retval = 0xffff;
                        /* fall through */
                default:
-                       if (regno > GS*4)
-                               regno -= 2*4;
+                       if (regno > ES*4)
+                               regno -= 1*4;
                        regno = regno - sizeof(struct pt_regs);
                        retval &= get_stack_long(child, regno);
        }
index 9f6ab1789bb05fc81593c47211b16bc45be894e1..a01320a7b63651ba6ec32914c1b5db16e44455d8 100644 (file)
@@ -3,10 +3,23 @@
  */
 #include <linux/pci.h>
 #include <linux/irq.h>
+#include <asm/pci-direct.h>
+#include <asm/genapic.h>
+#include <asm/cpu.h>
 
 #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_SMP) && defined(CONFIG_PCI)
+static void __devinit verify_quirk_intel_irqbalance(struct pci_dev *dev)
+{
+#ifdef CONFIG_X86_64
+       if (genapic !=  &apic_flat)
+               panic("APIC mode must be flat on this system\n");
+#elif defined(CONFIG_X86_GENERICARCH)
+       if (genapic != &apic_default)
+               panic("APIC mode must be default(flat) on this system. Use apic=default\n");
+#endif
+}
 
-static void __devinit quirk_intel_irqbalance(struct pci_dev *dev)
+void __init quirk_intel_irqbalance(void)
 {
        u8 config, rev;
        u32 word;
@@ -16,18 +29,18 @@ static void __devinit quirk_intel_irqbalance(struct pci_dev *dev)
         * based platforms.
         * Disable SW irqbalance/affinity on those platforms.
         */
-       pci_read_config_byte(dev, PCI_CLASS_REVISION, &rev);
+       rev = read_pci_config_byte(0, 0, 0, PCI_CLASS_REVISION);
        if (rev > 0x9)
                return;
 
        printk(KERN_INFO "Intel E7520/7320/7525 detected.");
 
-       /* enable access to config space*/
-       pci_read_config_byte(dev, 0xf4, &config);
-       pci_write_config_byte(dev, 0xf4, config|0x2);
+       /* enable access to config space */
+       config = read_pci_config_byte(0, 0, 0, 0xf4);
+       write_pci_config_byte(0, 0, 0, 0xf4, config|0x2);
 
        /* read xTPR register */
-       raw_pci_ops->read(0, 0, 0x40, 0x4c, 2, &word);
+       word = read_pci_config_16(0, 0, 0x40, 0x4c);
 
        if (!(word & (1 << 13))) {
                printk(KERN_INFO "Disabling irq balancing and affinity\n");
@@ -37,14 +50,25 @@ static void __devinit quirk_intel_irqbalance(struct pci_dev *dev)
                noirqdebug_setup("");
 #ifdef CONFIG_PROC_FS
                no_irq_affinity = 1;
+#endif
+#ifdef CONFIG_HOTPLUG_CPU
+               printk(KERN_INFO "Disabling cpu hotplug control\n");
+               enable_cpu_hotplug = 0;
+#endif
+#ifdef CONFIG_X86_64
+               /* force the genapic selection to flat mode so that
+                * interrupts can be redirected to more than one CPU.
+                */
+               genapic_force = &apic_flat;
 #endif
        }
 
-       /* put back the original value for config space*/
+       /* put back the original value for config space */
        if (!(config & 0x2))
-               pci_write_config_byte(dev, 0xf4, config);
+               write_pci_config_byte(0, 0, 0, 0xf4, config);
 }
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,   PCI_DEVICE_ID_INTEL_E7320_MCH,  quirk_intel_irqbalance);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,   PCI_DEVICE_ID_INTEL_E7525_MCH,  quirk_intel_irqbalance);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,   PCI_DEVICE_ID_INTEL_E7520_MCH,  quirk_intel_irqbalance);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,   PCI_DEVICE_ID_INTEL_E7320_MCH,  verify_quirk_intel_irqbalance);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,   PCI_DEVICE_ID_INTEL_E7525_MCH,  verify_quirk_intel_irqbalance);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,   PCI_DEVICE_ID_INTEL_E7520_MCH,  verify_quirk_intel_irqbalance);
+
 #endif
index 84278e0093a2a9d6d0d9b5593ce432f8e749cb59..3514b4153f7fd7d1aadc31acce100dd86ed8ad95 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/dmi.h>
 #include <linux/ctype.h>
 #include <linux/pm.h>
+#include <linux/reboot.h>
 #include <asm/uaccess.h>
 #include <asm/apic.h>
 #include <asm/desc.h>
index 141041dde74d0c8fe91913b445b2d68626776aed..79df6e612dbd03a20bfcc959dbb1ceba7158c1dd 100644 (file)
@@ -63,9 +63,6 @@
 #include <setup_arch.h>
 #include <bios_ebda.h>
 
-/* Forward Declaration. */
-void __init find_max_pfn(void);
-
 /* This value is set up by the early boot code to point to the value
    immediately after the boot time page tables.  It contains a *physical*
    address, and must not be in the .bss segment! */
@@ -76,11 +73,8 @@ int disable_pse __devinitdata = 0;
 /*
  * Machine setup..
  */
-
-#ifdef CONFIG_EFI
-int efi_enabled = 0;
-EXPORT_SYMBOL(efi_enabled);
-#endif
+extern struct resource code_resource;
+extern struct resource data_resource;
 
 /* cpu data as detected by the assembly code in head.S */
 struct cpuinfo_x86 new_cpu_data __initdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
@@ -99,12 +93,6 @@ unsigned int machine_submodel_id;
 unsigned int BIOS_revision;
 unsigned int mca_pentium_flag;
 
-/* For PCI or other memory-mapped resources */
-unsigned long pci_mem_start = 0x10000000;
-#ifdef CONFIG_PCI
-EXPORT_SYMBOL(pci_mem_start);
-#endif
-
 /* Boot loader ID as an integer, for the benefit of proc_dointvec */
 int bootloader_type;
 
@@ -134,7 +122,6 @@ struct ist_info ist_info;
        defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE)
 EXPORT_SYMBOL(ist_info);
 #endif
-struct e820map e820;
 
 extern void early_cpu_init(void);
 extern int root_mountflags;
@@ -149,516 +136,6 @@ static char command_line[COMMAND_LINE_SIZE];
 
 unsigned char __initdata boot_params[PARAM_SIZE];
 
-static struct resource data_resource = {
-       .name   = "Kernel data",
-       .start  = 0,
-       .end    = 0,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_MEM
-};
-
-static struct resource code_resource = {
-       .name   = "Kernel code",
-       .start  = 0,
-       .end    = 0,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_MEM
-};
-
-static struct resource system_rom_resource = {
-       .name   = "System ROM",
-       .start  = 0xf0000,
-       .end    = 0xfffff,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-};
-
-static struct resource extension_rom_resource = {
-       .name   = "Extension ROM",
-       .start  = 0xe0000,
-       .end    = 0xeffff,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-};
-
-static struct resource adapter_rom_resources[] = { {
-       .name   = "Adapter ROM",
-       .start  = 0xc8000,
-       .end    = 0,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
-       .name   = "Adapter ROM",
-       .start  = 0,
-       .end    = 0,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
-       .name   = "Adapter ROM",
-       .start  = 0,
-       .end    = 0,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
-       .name   = "Adapter ROM",
-       .start  = 0,
-       .end    = 0,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
-       .name   = "Adapter ROM",
-       .start  = 0,
-       .end    = 0,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
-       .name   = "Adapter ROM",
-       .start  = 0,
-       .end    = 0,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-} };
-
-static struct resource video_rom_resource = {
-       .name   = "Video ROM",
-       .start  = 0xc0000,
-       .end    = 0xc7fff,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-};
-
-static struct resource video_ram_resource = {
-       .name   = "Video RAM area",
-       .start  = 0xa0000,
-       .end    = 0xbffff,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_MEM
-};
-
-static struct resource standard_io_resources[] = { {
-       .name   = "dma1",
-       .start  = 0x0000,
-       .end    = 0x001f,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
-       .name   = "pic1",
-       .start  = 0x0020,
-       .end    = 0x0021,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
-       .name   = "timer0",
-       .start  = 0x0040,
-       .end    = 0x0043,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
-       .name   = "timer1",
-       .start  = 0x0050,
-       .end    = 0x0053,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
-       .name   = "keyboard",
-       .start  = 0x0060,
-       .end    = 0x006f,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
-       .name   = "dma page reg",
-       .start  = 0x0080,
-       .end    = 0x008f,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
-       .name   = "pic2",
-       .start  = 0x00a0,
-       .end    = 0x00a1,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
-       .name   = "dma2",
-       .start  = 0x00c0,
-       .end    = 0x00df,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
-       .name   = "fpu",
-       .start  = 0x00f0,
-       .end    = 0x00ff,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
-} };
-
-#define romsignature(x) (*(unsigned short *)(x) == 0xaa55)
-
-static int __init romchecksum(unsigned char *rom, unsigned long length)
-{
-       unsigned char *p, sum = 0;
-
-       for (p = rom; p < rom + length; p++)
-               sum += *p;
-       return sum == 0;
-}
-
-static void __init probe_roms(void)
-{
-       unsigned long start, length, upper;
-       unsigned char *rom;
-       int           i;
-
-       /* video rom */
-       upper = adapter_rom_resources[0].start;
-       for (start = video_rom_resource.start; start < upper; start += 2048) {
-               rom = isa_bus_to_virt(start);
-               if (!romsignature(rom))
-                       continue;
-
-               video_rom_resource.start = start;
-
-               /* 0 < length <= 0x7f * 512, historically */
-               length = rom[2] * 512;
-
-               /* if checksum okay, trust length byte */
-               if (length && romchecksum(rom, length))
-                       video_rom_resource.end = start + length - 1;
-
-               request_resource(&iomem_resource, &video_rom_resource);
-               break;
-       }
-
-       start = (video_rom_resource.end + 1 + 2047) & ~2047UL;
-       if (start < upper)
-               start = upper;
-
-       /* system rom */
-       request_resource(&iomem_resource, &system_rom_resource);
-       upper = system_rom_resource.start;
-
-       /* check for extension rom (ignore length byte!) */
-       rom = isa_bus_to_virt(extension_rom_resource.start);
-       if (romsignature(rom)) {
-               length = extension_rom_resource.end - extension_rom_resource.start + 1;
-               if (romchecksum(rom, length)) {
-                       request_resource(&iomem_resource, &extension_rom_resource);
-                       upper = extension_rom_resource.start;
-               }
-       }
-
-       /* check for adapter roms on 2k boundaries */
-       for (i = 0; i < ARRAY_SIZE(adapter_rom_resources) && start < upper; start += 2048) {
-               rom = isa_bus_to_virt(start);
-               if (!romsignature(rom))
-                       continue;
-
-               /* 0 < length <= 0x7f * 512, historically */
-               length = rom[2] * 512;
-
-               /* but accept any length that fits if checksum okay */
-               if (!length || start + length > upper || !romchecksum(rom, length))
-                       continue;
-
-               adapter_rom_resources[i].start = start;
-               adapter_rom_resources[i].end = start + length - 1;
-               request_resource(&iomem_resource, &adapter_rom_resources[i]);
-
-               start = adapter_rom_resources[i++].end & ~2047UL;
-       }
-}
-
-static void __init limit_regions(unsigned long long size)
-{
-       unsigned long long current_addr = 0;
-       int i;
-
-       if (efi_enabled) {
-               efi_memory_desc_t *md;
-               void *p;
-
-               for (p = memmap.map, i = 0; p < memmap.map_end;
-                       p += memmap.desc_size, i++) {
-                       md = p;
-                       current_addr = md->phys_addr + (md->num_pages << 12);
-                       if (md->type == EFI_CONVENTIONAL_MEMORY) {
-                               if (current_addr >= size) {
-                                       md->num_pages -=
-                                               (((current_addr-size) + PAGE_SIZE-1) >> PAGE_SHIFT);
-                                       memmap.nr_map = i + 1;
-                                       return;
-                               }
-                       }
-               }
-       }
-       for (i = 0; i < e820.nr_map; i++) {
-               current_addr = e820.map[i].addr + e820.map[i].size;
-               if (current_addr < size)
-                       continue;
-
-               if (e820.map[i].type != E820_RAM)
-                       continue;
-
-               if (e820.map[i].addr >= size) {
-                       /*
-                        * This region starts past the end of the
-                        * requested size, skip it completely.
-                        */
-                       e820.nr_map = i;
-               } else {
-                       e820.nr_map = i + 1;
-                       e820.map[i].size -= current_addr - size;
-               }
-               return;
-       }
-}
-
-void __init add_memory_region(unsigned long long start,
-                             unsigned long long size, int type)
-{
-       int x;
-
-       if (!efi_enabled) {
-                       x = e820.nr_map;
-
-               if (x == E820MAX) {
-                   printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
-                   return;
-               }
-
-               e820.map[x].addr = start;
-               e820.map[x].size = size;
-               e820.map[x].type = type;
-               e820.nr_map++;
-       }
-} /* add_memory_region */
-
-#define E820_DEBUG     1
-
-static void __init print_memory_map(char *who)
-{
-       int i;
-
-       for (i = 0; i < e820.nr_map; i++) {
-               printk(" %s: %016Lx - %016Lx ", who,
-                       e820.map[i].addr,
-                       e820.map[i].addr + e820.map[i].size);
-               switch (e820.map[i].type) {
-               case E820_RAM:  printk("(usable)\n");
-                               break;
-               case E820_RESERVED:
-                               printk("(reserved)\n");
-                               break;
-               case E820_ACPI:
-                               printk("(ACPI data)\n");
-                               break;
-               case E820_NVS:
-                               printk("(ACPI NVS)\n");
-                               break;
-               default:        printk("type %lu\n", e820.map[i].type);
-                               break;
-               }
-       }
-}
-
-/*
- * Sanitize the BIOS e820 map.
- *
- * Some e820 responses include overlapping entries.  The following 
- * replaces the original e820 map with a new one, removing overlaps.
- *
- */
-struct change_member {
-       struct e820entry *pbios; /* pointer to original bios entry */
-       unsigned long long addr; /* address for this change point */
-};
-static struct change_member change_point_list[2*E820MAX] __initdata;
-static struct change_member *change_point[2*E820MAX] __initdata;
-static struct e820entry *overlap_list[E820MAX] __initdata;
-static struct e820entry new_bios[E820MAX] __initdata;
-
-int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
-{
-       struct change_member *change_tmp;
-       unsigned long current_type, last_type;
-       unsigned long long last_addr;
-       int chgidx, still_changing;
-       int overlap_entries;
-       int new_bios_entry;
-       int old_nr, new_nr, chg_nr;
-       int i;
-
-       /*
-               Visually we're performing the following (1,2,3,4 = memory types)...
-
-               Sample memory map (w/overlaps):
-                  ____22__________________
-                  ______________________4_
-                  ____1111________________
-                  _44_____________________
-                  11111111________________
-                  ____________________33__
-                  ___________44___________
-                  __________33333_________
-                  ______________22________
-                  ___________________2222_
-                  _________111111111______
-                  _____________________11_
-                  _________________4______
-
-               Sanitized equivalent (no overlap):
-                  1_______________________
-                  _44_____________________
-                  ___1____________________
-                  ____22__________________
-                  ______11________________
-                  _________1______________
-                  __________3_____________
-                  ___________44___________
-                  _____________33_________
-                  _______________2________
-                  ________________1_______
-                  _________________4______
-                  ___________________2____
-                  ____________________33__
-                  ______________________4_
-       */
-
-       /* if there's only one memory region, don't bother */
-       if (*pnr_map < 2)
-               return -1;
-
-       old_nr = *pnr_map;
-
-       /* bail out if we find any unreasonable addresses in bios map */
-       for (i=0; i<old_nr; i++)
-               if (biosmap[i].addr + biosmap[i].size < biosmap[i].addr)
-                       return -1;
-
-       /* create pointers for initial change-point information (for sorting) */
-       for (i=0; i < 2*old_nr; i++)
-               change_point[i] = &change_point_list[i];
-
-       /* record all known change-points (starting and ending addresses),
-          omitting those that are for empty memory regions */
-       chgidx = 0;
-       for (i=0; i < old_nr; i++)      {
-               if (biosmap[i].size != 0) {
-                       change_point[chgidx]->addr = biosmap[i].addr;
-                       change_point[chgidx++]->pbios = &biosmap[i];
-                       change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size;
-                       change_point[chgidx++]->pbios = &biosmap[i];
-               }
-       }
-       chg_nr = chgidx;        /* true number of change-points */
-
-       /* sort change-point list by memory addresses (low -> high) */
-       still_changing = 1;
-       while (still_changing)  {
-               still_changing = 0;
-               for (i=1; i < chg_nr; i++)  {
-                       /* if <current_addr> > <last_addr>, swap */
-                       /* or, if current=<start_addr> & last=<end_addr>, swap */
-                       if ((change_point[i]->addr < change_point[i-1]->addr) ||
-                               ((change_point[i]->addr == change_point[i-1]->addr) &&
-                                (change_point[i]->addr == change_point[i]->pbios->addr) &&
-                                (change_point[i-1]->addr != change_point[i-1]->pbios->addr))
-                          )
-                       {
-                               change_tmp = change_point[i];
-                               change_point[i] = change_point[i-1];
-                               change_point[i-1] = change_tmp;
-                               still_changing=1;
-                       }
-               }
-       }
-
-       /* create a new bios memory map, removing overlaps */
-       overlap_entries=0;       /* number of entries in the overlap table */
-       new_bios_entry=0;        /* index for creating new bios map entries */
-       last_type = 0;           /* start with undefined memory type */
-       last_addr = 0;           /* start with 0 as last starting address */
-       /* loop through change-points, determining affect on the new bios map */
-       for (chgidx=0; chgidx < chg_nr; chgidx++)
-       {
-               /* keep track of all overlapping bios entries */
-               if (change_point[chgidx]->addr == change_point[chgidx]->pbios->addr)
-               {
-                       /* add map entry to overlap list (> 1 entry implies an overlap) */
-                       overlap_list[overlap_entries++]=change_point[chgidx]->pbios;
-               }
-               else
-               {
-                       /* remove entry from list (order independent, so swap with last) */
-                       for (i=0; i<overlap_entries; i++)
-                       {
-                               if (overlap_list[i] == change_point[chgidx]->pbios)
-                                       overlap_list[i] = overlap_list[overlap_entries-1];
-                       }
-                       overlap_entries--;
-               }
-               /* if there are overlapping entries, decide which "type" to use */
-               /* (larger value takes precedence -- 1=usable, 2,3,4,4+=unusable) */
-               current_type = 0;
-               for (i=0; i<overlap_entries; i++)
-                       if (overlap_list[i]->type > current_type)
-                               current_type = overlap_list[i]->type;
-               /* continue building up new bios map based on this information */
-               if (current_type != last_type)  {
-                       if (last_type != 0)      {
-                               new_bios[new_bios_entry].size =
-                                       change_point[chgidx]->addr - last_addr;
-                               /* move forward only if the new size was non-zero */
-                               if (new_bios[new_bios_entry].size != 0)
-                                       if (++new_bios_entry >= E820MAX)
-                                               break;  /* no more space left for new bios entries */
-                       }
-                       if (current_type != 0)  {
-                               new_bios[new_bios_entry].addr = change_point[chgidx]->addr;
-                               new_bios[new_bios_entry].type = current_type;
-                               last_addr=change_point[chgidx]->addr;
-                       }
-                       last_type = current_type;
-               }
-       }
-       new_nr = new_bios_entry;   /* retain count for new bios entries */
-
-       /* copy new bios mapping into original location */
-       memcpy(biosmap, new_bios, new_nr*sizeof(struct e820entry));
-       *pnr_map = new_nr;
-
-       return 0;
-}
-
-/*
- * Copy the BIOS e820 map into a safe place.
- *
- * Sanity-check it while we're at it..
- *
- * If we're lucky and live on a modern system, the setup code
- * will have given us a memory map that we can use to properly
- * set up memory.  If we aren't, we'll fake a memory map.
- *
- * We check to see that the memory map contains at least 2 elements
- * before we'll use it, because the detection code in setup.S may
- * not be perfect and most every PC known to man has two memory
- * regions: one from 0 to 640k, and one from 1mb up.  (The IBM
- * thinkpad 560x, for example, does not cooperate with the memory
- * detection code.)
- */
-int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
-{
-       /* Only one memory region (or negative)? Ignore it */
-       if (nr_map < 2)
-               return -1;
-
-       do {
-               unsigned long long start = biosmap->addr;
-               unsigned long long size = biosmap->size;
-               unsigned long long end = start + size;
-               unsigned long type = biosmap->type;
-
-               /* Overflow in 64 bits? Ignore the memory map. */
-               if (start > end)
-                       return -1;
-
-               /*
-                * Some BIOSes claim RAM in the 640k - 1M region.
-                * Not right. Fix it up.
-                */
-               if (type == E820_RAM) {
-                       if (start < 0x100000ULL && end > 0xA0000ULL) {
-                               if (start < 0xA0000ULL)
-                                       add_memory_region(start, 0xA0000ULL-start, type);
-                               if (end <= 0x100000ULL)
-                                       continue;
-                               start = 0x100000ULL;
-                               size = end - start;
-                       }
-               }
-               add_memory_region(start, size, type);
-       } while (biosmap++,--nr_map);
-       return 0;
-}
-
 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
 struct edd edd;
 #ifdef CONFIG_EDD_MODULE
@@ -682,7 +159,7 @@ static inline void copy_edd(void)
 }
 #endif
 
-static int __initdata user_defined_memmap = 0;
+int __initdata user_defined_memmap = 0;
 
 /*
  * "mem=nopentium" disables the 4MB page tables.
@@ -719,51 +196,6 @@ static int __init parse_mem(char *arg)
 }
 early_param("mem", parse_mem);
 
-static int __init parse_memmap(char *arg)
-{
-       if (!arg)
-               return -EINVAL;
-
-       if (strcmp(arg, "exactmap") == 0) {
-#ifdef CONFIG_CRASH_DUMP
-               /* If we are doing a crash dump, we
-                * still need to know the real mem
-                * size before original memory map is
-                * reset.
-                */
-               find_max_pfn();
-               saved_max_pfn = max_pfn;
-#endif
-               e820.nr_map = 0;
-               user_defined_memmap = 1;
-       } else {
-               /* If the user specifies memory size, we
-                * limit the BIOS-provided memory map to
-                * that size. exactmap can be used to specify
-                * the exact map. mem=number can be used to
-                * trim the existing memory map.
-                */
-               unsigned long long start_at, mem_size;
-
-               mem_size = memparse(arg, &arg);
-               if (*arg == '@') {
-                       start_at = memparse(arg+1, &arg);
-                       add_memory_region(start_at, mem_size, E820_RAM);
-               } else if (*arg == '#') {
-                       start_at = memparse(arg+1, &arg);
-                       add_memory_region(start_at, mem_size, E820_ACPI);
-               } else if (*arg == '$') {
-                       start_at = memparse(arg+1, &arg);
-                       add_memory_region(start_at, mem_size, E820_RESERVED);
-               } else {
-                       limit_regions(mem_size);
-                       user_defined_memmap = 1;
-               }
-       }
-       return 0;
-}
-early_param("memmap", parse_memmap);
-
 #ifdef CONFIG_PROC_VMCORE
 /* elfcorehdr= specifies the location of elf core header
  * stored by the crashed kernel.
@@ -827,90 +259,6 @@ static int __init parse_reservetop(char *arg)
 }
 early_param("reservetop", parse_reservetop);
 
-/*
- * Callback for efi_memory_walk.
- */
-static int __init
-efi_find_max_pfn(unsigned long start, unsigned long end, void *arg)
-{
-       unsigned long *max_pfn = arg, pfn;
-
-       if (start < end) {
-               pfn = PFN_UP(end -1);
-               if (pfn > *max_pfn)
-                       *max_pfn = pfn;
-       }
-       return 0;
-}
-
-static int __init
-efi_memory_present_wrapper(unsigned long start, unsigned long end, void *arg)
-{
-       memory_present(0, PFN_UP(start), PFN_DOWN(end));
-       return 0;
-}
-
- /*
-  * This function checks if the entire range <start,end> is mapped with type.
-  *
-  * Note: this function only works correct if the e820 table is sorted and
-  * not-overlapping, which is the case
-  */
-int __init
-e820_all_mapped(unsigned long s, unsigned long e, unsigned type)
-{
-       u64 start = s;
-       u64 end = e;
-       int i;
-       for (i = 0; i < e820.nr_map; i++) {
-               struct e820entry *ei = &e820.map[i];
-               if (type && ei->type != type)
-                       continue;
-               /* is the region (part) in overlap with the current region ?*/
-               if (ei->addr >= end || ei->addr + ei->size <= start)
-                       continue;
-               /* if the region is at the beginning of <start,end> we move
-                * start to the end of the region since it's ok until there
-                */
-               if (ei->addr <= start)
-                       start = ei->addr + ei->size;
-               /* if start is now at or beyond end, we're done, full
-                * coverage */
-               if (start >= end)
-                       return 1; /* we're done */
-       }
-       return 0;
-}
-
-/*
- * Find the highest page frame number we have available
- */
-void __init find_max_pfn(void)
-{
-       int i;
-
-       max_pfn = 0;
-       if (efi_enabled) {
-               efi_memmap_walk(efi_find_max_pfn, &max_pfn);
-               efi_memmap_walk(efi_memory_present_wrapper, NULL);
-               return;
-       }
-
-       for (i = 0; i < e820.nr_map; i++) {
-               unsigned long start, end;
-               /* RAM? */
-               if (e820.map[i].type != E820_RAM)
-                       continue;
-               start = PFN_UP(e820.map[i].addr);
-               end = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
-               if (start >= end)
-                       continue;
-               if (end > max_pfn)
-                       max_pfn = end;
-               memory_present(0, start, end);
-       }
-}
-
 /*
  * Determine low and high memory ranges:
  */
@@ -970,68 +318,6 @@ unsigned long __init find_max_low_pfn(void)
        return max_low_pfn;
 }
 
-/*
- * Free all available memory for boot time allocation.  Used
- * as a callback function by efi_memory_walk()
- */
-
-static int __init
-free_available_memory(unsigned long start, unsigned long end, void *arg)
-{
-       /* check max_low_pfn */
-       if (start >= (max_low_pfn << PAGE_SHIFT))
-               return 0;
-       if (end >= (max_low_pfn << PAGE_SHIFT))
-               end = max_low_pfn << PAGE_SHIFT;
-       if (start < end)
-               free_bootmem(start, end - start);
-
-       return 0;
-}
-/*
- * Register fully available low RAM pages with the bootmem allocator.
- */
-static void __init register_bootmem_low_pages(unsigned long max_low_pfn)
-{
-       int i;
-
-       if (efi_enabled) {
-               efi_memmap_walk(free_available_memory, NULL);
-               return;
-       }
-       for (i = 0; i < e820.nr_map; i++) {
-               unsigned long curr_pfn, last_pfn, size;
-               /*
-                * Reserve usable low memory
-                */
-               if (e820.map[i].type != E820_RAM)
-                       continue;
-               /*
-                * We are rounding up the start address of usable memory:
-                */
-               curr_pfn = PFN_UP(e820.map[i].addr);
-               if (curr_pfn >= max_low_pfn)
-                       continue;
-               /*
-                * ... and at the end of the usable range downwards:
-                */
-               last_pfn = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
-
-               if (last_pfn > max_low_pfn)
-                       last_pfn = max_low_pfn;
-
-               /*
-                * .. finally, did all the rounding and playing
-                * around just make the area go away?
-                */
-               if (last_pfn <= curr_pfn)
-                       continue;
-
-               size = last_pfn - curr_pfn;
-               free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(size));
-       }
-}
-
 /*
  * workaround for Dell systems that neglect to reserve EBDA
  */
@@ -1118,8 +404,8 @@ void __init setup_bootmem_allocator(void)
         * the (very unlikely) case of us accidentally initializing the
         * bootmem allocator with an invalid RAM area.
         */
-       reserve_bootmem(__PHYSICAL_START, (PFN_PHYS(min_low_pfn) +
-                        bootmap_size + PAGE_SIZE-1) - (__PHYSICAL_START));
+       reserve_bootmem(__pa_symbol(_text), (PFN_PHYS(min_low_pfn) +
+                        bootmap_size + PAGE_SIZE-1) - __pa_symbol(_text));
 
        /*
         * reserve physical page 0 - it's a special BIOS page on many boxes,
@@ -1162,8 +448,7 @@ void __init setup_bootmem_allocator(void)
        if (LOADER_TYPE && INITRD_START) {
                if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
                        reserve_bootmem(INITRD_START, INITRD_SIZE);
-                       initrd_start =
-                               INITRD_START ? INITRD_START + PAGE_OFFSET : 0;
+                       initrd_start = INITRD_START + PAGE_OFFSET;
                        initrd_end = initrd_start+INITRD_SIZE;
                }
                else {
@@ -1200,126 +485,6 @@ void __init remapped_pgdat_init(void)
        }
 }
 
-/*
- * Request address space for all standard RAM and ROM resources
- * and also for regions reported as reserved by the e820.
- */
-static void __init
-legacy_init_iomem_resources(struct resource *code_resource, struct resource *data_resource)
-{
-       int i;
-
-       probe_roms();
-       for (i = 0; i < e820.nr_map; i++) {
-               struct resource *res;
-#ifndef CONFIG_RESOURCES_64BIT
-               if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL)
-                       continue;
-#endif
-               res = kzalloc(sizeof(struct resource), GFP_ATOMIC);
-               switch (e820.map[i].type) {
-               case E820_RAM:  res->name = "System RAM"; break;
-               case E820_ACPI: res->name = "ACPI Tables"; break;
-               case E820_NVS:  res->name = "ACPI Non-volatile Storage"; break;
-               default:        res->name = "reserved";
-               }
-               res->start = e820.map[i].addr;
-               res->end = res->start + e820.map[i].size - 1;
-               res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
-               if (request_resource(&iomem_resource, res)) {
-                       kfree(res);
-                       continue;
-               }
-               if (e820.map[i].type == E820_RAM) {
-                       /*
-                        *  We don't know which RAM region contains kernel data,
-                        *  so we try it repeatedly and let the resource manager
-                        *  test it.
-                        */
-                       request_resource(res, code_resource);
-                       request_resource(res, data_resource);
-#ifdef CONFIG_KEXEC
-                       request_resource(res, &crashk_res);
-#endif
-               }
-       }
-}
-
-/*
- * Request address space for all standard resources
- *
- * This is called just before pcibios_init(), which is also a
- * subsys_initcall, but is linked in later (in arch/i386/pci/common.c).
- */
-static int __init request_standard_resources(void)
-{
-       int i;
-
-       printk("Setting up standard PCI resources\n");
-       if (efi_enabled)
-               efi_initialize_iomem_resources(&code_resource, &data_resource);
-       else
-               legacy_init_iomem_resources(&code_resource, &data_resource);
-
-       /* EFI systems may still have VGA */
-       request_resource(&iomem_resource, &video_ram_resource);
-
-       /* request I/O space for devices used on all i[345]86 PCs */
-       for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++)
-               request_resource(&ioport_resource, &standard_io_resources[i]);
-       return 0;
-}
-
-subsys_initcall(request_standard_resources);
-
-static void __init register_memory(void)
-{
-       unsigned long gapstart, gapsize, round;
-       unsigned long long last;
-       int i;
-
-       /*
-        * Search for the bigest gap in the low 32 bits of the e820
-        * memory space.
-        */
-       last = 0x100000000ull;
-       gapstart = 0x10000000;
-       gapsize = 0x400000;
-       i = e820.nr_map;
-       while (--i >= 0) {
-               unsigned long long start = e820.map[i].addr;
-               unsigned long long end = start + e820.map[i].size;
-
-               /*
-                * Since "last" is at most 4GB, we know we'll
-                * fit in 32 bits if this condition is true
-                */
-               if (last > end) {
-                       unsigned long gap = last - end;
-
-                       if (gap > gapsize) {
-                               gapsize = gap;
-                               gapstart = end;
-                       }
-               }
-               if (start < last)
-                       last = start;
-       }
-
-       /*
-        * See how much we want to round up: start off with
-        * rounding to the next 1MB area.
-        */
-       round = 0x100000;
-       while ((gapsize >> 4) > round)
-               round += round;
-       /* Fun with two's complement */
-       pci_mem_start = (gapstart + round) & -round;
-
-       printk("Allocating PCI resources starting at %08lx (gap: %08lx:%08lx)\n",
-               pci_mem_start, gapstart, gapsize);
-}
-
 #ifdef CONFIG_MCA
 static void set_mca_bus(int x)
 {
@@ -1329,6 +494,12 @@ static void set_mca_bus(int x)
 static void set_mca_bus(int x) { }
 #endif
 
+/* Overridden in paravirt.c if CONFIG_PARAVIRT */
+char * __attribute__((weak)) memory_setup(void)
+{
+       return machine_specific_memory_setup();
+}
+
 /*
  * Determine if we were loaded by an EFI loader.  If so, then we have also been
  * passed the efi memmap, systab, etc., so we should use these data structures
@@ -1381,7 +552,7 @@ void __init setup_arch(char **cmdline_p)
                efi_init();
        else {
                printk(KERN_INFO "BIOS-provided physical RAM map:\n");
-               print_memory_map(machine_specific_memory_setup());
+               print_memory_map(memory_setup());
        }
 
        copy_edd();
index 43002cfb40c4e2811bf5006c9126fa2ff1cfdd46..65d7620eaa093756e083ed5d0f9786ccfc1bd917 100644 (file)
@@ -128,7 +128,7 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *peax
                         X86_EFLAGS_TF | X86_EFLAGS_SF | X86_EFLAGS_ZF | \
                         X86_EFLAGS_AF | X86_EFLAGS_PF | X86_EFLAGS_CF)
 
-       GET_SEG(gs);
+       COPY_SEG(gs);
        GET_SEG(fs);
        COPY_SEG(es);
        COPY_SEG(ds);
@@ -244,9 +244,7 @@ setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate,
 {
        int tmp, err = 0;
 
-       tmp = 0;
-       savesegment(gs, tmp);
-       err |= __put_user(tmp, (unsigned int __user *)&sc->gs);
+       err |= __put_user(regs->xgs, (unsigned int __user *)&sc->gs);
        savesegment(fs, tmp);
        err |= __put_user(tmp, (unsigned int __user *)&sc->fs);
 
index 31e5c6573aae450b3a1f94fe7129de94fc4ea26e..5285aff8367fec481d33a7ed94c0278815202286 100644 (file)
@@ -321,7 +321,6 @@ static inline void leave_mm (unsigned long cpu)
 
 fastcall void smp_invalidate_interrupt(struct pt_regs *regs)
 {
-       struct pt_regs *old_regs = set_irq_regs(regs);
        unsigned long cpu;
 
        cpu = get_cpu();
@@ -352,7 +351,6 @@ fastcall void smp_invalidate_interrupt(struct pt_regs *regs)
        smp_mb__after_clear_bit();
 out:
        put_cpu_no_resched();
-       set_irq_regs(old_regs);
 }
 
 static void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm,
@@ -607,14 +605,11 @@ void smp_send_stop(void)
  */
 fastcall void smp_reschedule_interrupt(struct pt_regs *regs)
 {
-       struct pt_regs *old_regs = set_irq_regs(regs);
        ack_APIC_irq();
-       set_irq_regs(old_regs);
 }
 
 fastcall void smp_call_function_interrupt(struct pt_regs *regs)
 {
-       struct pt_regs *old_regs = set_irq_regs(regs);
        void (*func) (void *info) = call_data->func;
        void *info = call_data->info;
        int wait = call_data->wait;
@@ -637,7 +632,6 @@ fastcall void smp_call_function_interrupt(struct pt_regs *regs)
                mb();
                atomic_inc(&call_data->finished);
        }
-       set_irq_regs(old_regs);
 }
 
 /*
@@ -699,6 +693,10 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
                put_cpu();
                return -EBUSY;
        }
+
+       /* Can deadlock when called with interrupts disabled */
+       WARN_ON(irqs_disabled());
+
        spin_lock_bh(&call_lock);
        __smp_call_function_single(cpu, func, info, nonatomic, wait);
        spin_unlock_bh(&call_lock);
index 02a9b66b6ac38ae95aa199e8d91e7576d10daeba..1e00b03163b9910735db18f3de8f36e6f971b195 100644 (file)
  *             Dave Jones      :       Report invalid combinations of Athlon CPUs.
 *              Rusty Russell   :       Hacked into shape for new "hotplug" boot process. */
 
+
+/* SMP boot always wants to use real time delay to allow sufficient time for
+ * the APs to come online */
+#define USE_REAL_TIME_DELAY
+
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -52,6 +57,8 @@
 #include <asm/desc.h>
 #include <asm/arch_hooks.h>
 #include <asm/nmi.h>
+#include <asm/pda.h>
+#include <asm/genapic.h>
 
 #include <mach_apic.h>
 #include <mach_wakecpu.h>
@@ -536,11 +543,11 @@ set_cpu_sibling_map(int cpu)
 static void __devinit start_secondary(void *unused)
 {
        /*
-        * Dont put anything before smp_callin(), SMP
+        * Don't put *anything* before secondary_cpu_init(), SMP
         * booting is too fragile that we want to limit the
         * things done here to the most necessary things.
         */
-       cpu_init();
+       secondary_cpu_init();
        preempt_disable();
        smp_callin();
        while (!cpu_isset(smp_processor_id(), smp_commenced_mask))
@@ -599,13 +606,16 @@ void __devinit initialize_secondary(void)
                "movl %0,%%esp\n\t"
                "jmp *%1"
                :
-               :"r" (current->thread.esp),"r" (current->thread.eip));
+               :"m" (current->thread.esp),"m" (current->thread.eip));
 }
 
+/* Static state in head.S used to set up a CPU */
 extern struct {
        void * esp;
        unsigned short ss;
 } stack_start;
+extern struct i386_pda *start_pda;
+extern struct Xgt_desc_struct cpu_gdt_descr;
 
 #ifdef CONFIG_NUMA
 
@@ -936,9 +946,6 @@ static int __devinit do_boot_cpu(int apicid, int cpu)
        unsigned long start_eip;
        unsigned short nmi_high = 0, nmi_low = 0;
 
-       ++cpucount;
-       alternatives_smp_switch(1);
-
        /*
         * We can't use kernel_thread since we must avoid to
         * reschedule the child.
@@ -946,15 +953,30 @@ static int __devinit do_boot_cpu(int apicid, int cpu)
        idle = alloc_idle_task(cpu);
        if (IS_ERR(idle))
                panic("failed fork for CPU %d", cpu);
+
+       /* Pre-allocate and initialize the CPU's GDT and PDA so it
+          doesn't have to do any memory allocation during the
+          delicate CPU-bringup phase. */
+       if (!init_gdt(cpu, idle)) {
+               printk(KERN_INFO "Couldn't allocate GDT/PDA for CPU %d\n", cpu);
+               return -1;      /* ? */
+       }
+
        idle->thread.eip = (unsigned long) start_secondary;
        /* start_eip had better be page-aligned! */
        start_eip = setup_trampoline();
 
+       ++cpucount;
+       alternatives_smp_switch(1);
+
        /* So we see what's up   */
        printk("Booting processor %d/%d eip %lx\n", cpu, apicid, start_eip);
        /* Stack for startup_32 can be just as for start_secondary onwards */
        stack_start.esp = (void *) idle->thread.esp;
 
+       start_pda = cpu_pda(cpu);
+       cpu_gdt_descr = per_cpu(cpu_gdt_descr, cpu);
+
        irq_ctx_init(cpu);
 
        x86_cpu_to_apicid[cpu] = apicid;
@@ -1096,7 +1118,7 @@ static int __cpuinit __smp_prepare_cpu(int cpu)
 
        /* init low mem mapping */
        clone_pgd_range(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS,
-                       KERNEL_PGD_PTRS);
+                       min_t(unsigned long, KERNEL_PGD_PTRS, USER_PGD_PTRS));
        flush_tlb_all();
        schedule_work(&info.task);
        wait_for_completion(&done);
@@ -1109,34 +1131,15 @@ exit:
 }
 #endif
 
-static void smp_tune_scheduling (void)
+static void smp_tune_scheduling(void)
 {
        unsigned long cachesize;       /* kB   */
-       unsigned long bandwidth = 350; /* MB/s */
-       /*
-        * Rough estimation for SMP scheduling, this is the number of
-        * cycles it takes for a fully memory-limited process to flush
-        * the SMP-local cache.
-        *
-        * (For a P5 this pretty much means we will choose another idle
-        *  CPU almost always at wakeup time (this is due to the small
-        *  L1 cache), on PIIs it's around 50-100 usecs, depending on
-        *  the cache size)
-        */
 
-       if (!cpu_khz) {
-               /*
-                * this basically disables processor-affinity
-                * scheduling on SMP without a TSC.
-                */
-               return;
-       } else {
+       if (cpu_khz) {
                cachesize = boot_cpu_data.x86_cache_size;
-               if (cachesize == -1) {
-                       cachesize = 16; /* Pentiums, 2x8kB cache */
-                       bandwidth = 100;
-               }
-               max_cache_size = cachesize * 1024;
+
+               if (cachesize > 0)
+                       max_cache_size = cachesize * 1024;
        }
 }
 
@@ -1462,6 +1465,12 @@ int __devinit __cpu_up(unsigned int cpu)
        cpu_set(cpu, smp_commenced_mask);
        while (!cpu_isset(cpu, cpu_online_map))
                cpu_relax();
+
+#ifdef CONFIG_X86_GENERICARCH
+       if (num_online_cpus() > 8 && genapic == &apic_default)
+               panic("Default flat APIC routing can't be used with > 8 cpus\n");
+#endif
+
        return 0;
 }
 
index 713ba39d32c66db0e2ad4ca0580088ffccef785f..7de9117b5a3ada15bf9e401afc9695e849bac8af 100644 (file)
  * Should the kernel map a VDSO page into processes and pass its
  * address down to glibc upon exec()?
  */
+#ifdef CONFIG_PARAVIRT
+unsigned int __read_mostly vdso_enabled = 0;
+#else
 unsigned int __read_mostly vdso_enabled = 1;
+#endif
 
 EXPORT_SYMBOL_GPL(vdso_enabled);
 
@@ -132,7 +136,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int exstack)
                goto up_fail;
        }
 
-       vma = kmem_cache_zalloc(vm_area_cachep, SLAB_KERNEL);
+       vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
        if (!vma) {
                ret = -ENOMEM;
                goto up_fail;
index 78af572fd17c3e4a903aaf59062744455808e77a..c505b16c099038381efc87791d37e49c0aeb158c 100644 (file)
@@ -56,6 +56,7 @@
 #include <asm/uaccess.h>
 #include <asm/processor.h>
 #include <asm/timer.h>
+#include <asm/time.h>
 
 #include "mach_time.h"
 
@@ -116,10 +117,7 @@ static int set_rtc_mmss(unsigned long nowtime)
        /* gets recalled with irq locally disabled */
        /* XXX - does irqsave resolve this? -johnstul */
        spin_lock_irqsave(&rtc_lock, flags);
-       if (efi_enabled)
-               retval = efi_set_rtc_mmss(nowtime);
-       else
-               retval = mach_set_rtc_mmss(nowtime);
+       retval = set_wallclock(nowtime);
        spin_unlock_irqrestore(&rtc_lock, flags);
 
        return retval;
@@ -223,10 +221,7 @@ unsigned long get_cmos_time(void)
 
        spin_lock_irqsave(&rtc_lock, flags);
 
-       if (efi_enabled)
-               retval = efi_get_time();
-       else
-               retval = mach_get_cmos_time();
+       retval = get_wallclock();
 
        spin_unlock_irqrestore(&rtc_lock, flags);
 
@@ -370,7 +365,7 @@ static void __init hpet_time_init(void)
                printk("Using HPET for base-timer\n");
        }
 
-       time_init_hook();
+       do_time_init();
 }
 #endif
 
@@ -392,5 +387,5 @@ void __init time_init(void)
 
        do_settimeofday(&ts);
 
-       time_init_hook();
+       do_time_init();
 }
index 1a2a979cf6a344f1603b33605a319831ee667a95..1e4702dfcd017e7649961465eaeb734116d9178b 100644 (file)
@@ -132,14 +132,20 @@ int __init hpet_enable(void)
         * the single HPET timer for system time.
         */
 #ifdef CONFIG_HPET_EMULATE_RTC
-       if (!(id & HPET_ID_NUMBER))
+       if (!(id & HPET_ID_NUMBER)) {
+               iounmap(hpet_virt_address);
+               hpet_virt_address = NULL;
                return -1;
+       }
 #endif
 
 
        hpet_period = hpet_readl(HPET_PERIOD);
-       if ((hpet_period < HPET_MIN_PERIOD) || (hpet_period > HPET_MAX_PERIOD))
+       if ((hpet_period < HPET_MIN_PERIOD) || (hpet_period > HPET_MAX_PERIOD)) {
+               iounmap(hpet_virt_address);
+               hpet_virt_address = NULL;
                return -1;
+       }
 
        /*
         * 64 bit math
@@ -156,8 +162,11 @@ int __init hpet_enable(void)
 
        hpet_use_timer = id & HPET_ID_LEGSUP;
 
-       if (hpet_timer_stop_set_go(hpet_tick))
+       if (hpet_timer_stop_set_go(hpet_tick)) {
+               iounmap(hpet_virt_address);
+               hpet_virt_address = NULL;
                return -1;
+       }
 
        use_hpet = 1;
 
index 07d6da36a8253f39bbce04e90ab4edc0ece8aed4..79cf608e14ca16254db381dcba319979047745fc 100644 (file)
@@ -40,14 +40,18 @@ int arch_register_cpu(int num)
         * restrictions and assumptions in kernel. This basically
         * doesnt add a control file, one cannot attempt to offline
         * BSP.
+        *
+        * Also certain PCI quirks require not to enable hotplug control
+        * for all CPU's.
         */
-       if (!num)
-               cpu_devices[num].cpu.no_control = 1;
+       if (num && enable_cpu_hotplug)
+               cpu_devices[num].cpu.hotpluggable = 1;
 
        return register_cpu(&cpu_devices[num].cpu, num);
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
+int enable_cpu_hotplug = 1;
 
 void arch_unregister_cpu(int num) {
        return unregister_cpu(&cpu_devices[num].cpu);
index fe9c5e8e7e6f5066e5f92865f0c6d71ec2887050..2b30dbf8d1170167283d57a7cbe3b0099231c788 100644 (file)
@@ -29,6 +29,8 @@
 #include <linux/kexec.h>
 #include <linux/unwind.h>
 #include <linux/uaccess.h>
+#include <linux/nmi.h>
+#include <linux/bug.h>
 
 #ifdef CONFIG_EISA
 #include <linux/ioport.h>
@@ -61,9 +63,6 @@ int panic_on_unrecovered_nmi;
 
 asmlinkage int system_call(void);
 
-struct desc_struct default_ldt[] = { { 0, 0 }, { 0, 0 }, { 0, 0 },
-               { 0, 0 }, { 0, 0 } };
-
 /* Do we ignore FPU interrupts ? */
 char ignore_fpu_irq = 0;
 
@@ -94,7 +93,7 @@ asmlinkage void alignment_check(void);
 asmlinkage void spurious_interrupt_bug(void);
 asmlinkage void machine_check(void);
 
-static int kstack_depth_to_print = 24;
+int kstack_depth_to_print = 24;
 #ifdef CONFIG_STACK_UNWIND
 static int call_trace = 1;
 #else
@@ -163,16 +162,25 @@ dump_trace_unwind(struct unwind_frame_info *info, void *data)
 {
        struct ops_and_data *oad = (struct ops_and_data *)data;
        int n = 0;
+       unsigned long sp = UNW_SP(info);
 
+       if (arch_unw_user_mode(info))
+               return -1;
        while (unwind(info) == 0 && UNW_PC(info)) {
                n++;
                oad->ops->address(oad->data, UNW_PC(info));
                if (arch_unw_user_mode(info))
                        break;
+               if ((sp & ~(PAGE_SIZE - 1)) == (UNW_SP(info) & ~(PAGE_SIZE - 1))
+                   && sp > UNW_SP(info))
+                       break;
+               sp = UNW_SP(info);
        }
        return n;
 }
 
+#define MSG(msg) ops->warning(data, msg)
+
 void dump_trace(struct task_struct *task, struct pt_regs *regs,
                unsigned long *stack,
                struct stacktrace_ops *ops, void *data)
@@ -191,29 +199,31 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
                        if (unwind_init_frame_info(&info, task, regs) == 0)
                                unw_ret = dump_trace_unwind(&info, &oad);
                } else if (task == current)
-                       unw_ret = unwind_init_running(&info, dump_trace_unwind, &oad);
+                       unw_ret = unwind_init_running(&info, dump_trace_unwind,
+                                                     &oad);
                else {
                        if (unwind_init_blocked(&info, task) == 0)
                                unw_ret = dump_trace_unwind(&info, &oad);
                }
                if (unw_ret > 0) {
                        if (call_trace == 1 && !arch_unw_user_mode(&info)) {
-                               ops->warning_symbol(data, "DWARF2 unwinder stuck at %s\n",
+                               ops->warning_symbol(data,
+                                            "DWARF2 unwinder stuck at %s",
                                             UNW_PC(&info));
                                if (UNW_SP(&info) >= PAGE_OFFSET) {
-                                       ops->warning(data, "Leftover inexact backtrace:\n");
+                                       MSG("Leftover inexact backtrace:");
                                        stack = (void *)UNW_SP(&info);
                                        if (!stack)
                                                return;
                                        ebp = UNW_FP(&info);
                                } else
-                                       ops->warning(data, "Full inexact backtrace again:\n");
+                                       MSG("Full inexact backtrace again:");
                        } else if (call_trace >= 1)
                                return;
                        else
-                               ops->warning(data, "Full inexact backtrace again:\n");
+                               MSG("Full inexact backtrace again:");
                } else
-                       ops->warning(data, "Inexact backtrace:\n");
+                       MSG("Inexact backtrace:");
        }
        if (!stack) {
                unsigned long dummy;
@@ -247,6 +257,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
                stack = (unsigned long*)context->previous_esp;
                if (!stack)
                        break;
+               touch_nmi_watchdog();
        }
 }
 EXPORT_SYMBOL(dump_trace);
@@ -379,7 +390,7 @@ void show_registers(struct pt_regs *regs)
         * time of the fault..
         */
        if (in_kernel) {
-               u8 __user *eip;
+               u8 *eip;
                int code_bytes = 64;
                unsigned char c;
 
@@ -388,18 +399,20 @@ void show_registers(struct pt_regs *regs)
 
                printk(KERN_EMERG "Code: ");
 
-               eip = (u8 __user *)regs->eip - 43;
-               if (eip < (u8 __user *)PAGE_OFFSET || __get_user(c, eip)) {
+               eip = (u8 *)regs->eip - 43;
+               if (eip < (u8 *)PAGE_OFFSET ||
+                       probe_kernel_address(eip, c)) {
                        /* try starting at EIP */
-                       eip = (u8 __user *)regs->eip;
+                       eip = (u8 *)regs->eip;
                        code_bytes = 32;
                }
                for (i = 0; i < code_bytes; i++, eip++) {
-                       if (eip < (u8 __user *)PAGE_OFFSET || __get_user(c, eip)) {
+                       if (eip < (u8 *)PAGE_OFFSET ||
+                               probe_kernel_address(eip, c)) {
                                printk(" Bad EIP value.");
                                break;
                        }
-                       if (eip == (u8 __user *)regs->eip)
+                       if (eip == (u8 *)regs->eip)
                                printk("<%02x> ", c);
                        else
                                printk("%02x ", c);
@@ -408,43 +421,22 @@ void show_registers(struct pt_regs *regs)
        printk("\n");
 }      
 
-static void handle_BUG(struct pt_regs *regs)
+int is_valid_bugaddr(unsigned long eip)
 {
-       unsigned long eip = regs->eip;
        unsigned short ud2;
 
        if (eip < PAGE_OFFSET)
-               return;
-       if (probe_kernel_address((unsigned short __user *)eip, ud2))
-               return;
-       if (ud2 != 0x0b0f)
-               return;
-
-       printk(KERN_EMERG "------------[ cut here ]------------\n");
-
-#ifdef CONFIG_DEBUG_BUGVERBOSE
-       do {
-               unsigned short line;
-               char *file;
-               char c;
-
-               if (probe_kernel_address((unsigned short __user *)(eip + 2),
-                                       line))
-                       break;
-               if (__get_user(file, (char * __user *)(eip + 4)) ||
-                   (unsigned long)file < PAGE_OFFSET || __get_user(c, file))
-                       file = "<bad filename>";
+               return 0;
+       if (probe_kernel_address((unsigned short *)eip, ud2))
+               return 0;
 
-               printk(KERN_EMERG "kernel BUG at %s:%d!\n", file, line);
-               return;
-       } while (0);
-#endif
-       printk(KERN_EMERG "Kernel BUG at [verbose debug info unavailable]\n");
+       return ud2 == 0x0b0f;
 }
 
-/* This is gone through when something in the kernel
- * has done something bad and is about to be terminated.
-*/
+/*
+ * This is gone through when something in the kernel has done something bad and
+ * is about to be terminated.
+ */
 void die(const char * str, struct pt_regs * regs, long err)
 {
        static struct {
@@ -452,7 +444,7 @@ void die(const char * str, struct pt_regs * regs, long err)
                u32 lock_owner;
                int lock_owner_depth;
        } die = {
-               .lock =                 SPIN_LOCK_UNLOCKED,
+               .lock =                 __SPIN_LOCK_UNLOCKED(die.lock),
                .lock_owner =           -1,
                .lock_owner_depth =     0
        };
@@ -476,7 +468,8 @@ void die(const char * str, struct pt_regs * regs, long err)
                unsigned long esp;
                unsigned short ss;
 
-               handle_BUG(regs);
+               report_bug(regs->eip);
+
                printk(KERN_EMERG "%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
 #ifdef CONFIG_PREEMPT
                printk(KERN_EMERG "PREEMPT ");
@@ -707,8 +700,7 @@ mem_parity_error(unsigned char reason, struct pt_regs * regs)
 {
        printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x on "
                "CPU %d.\n", reason, smp_processor_id());
-       printk(KERN_EMERG "You probably have a hardware problem with your RAM "
-                       "chips\n");
+       printk(KERN_EMERG "You have some hardware problem, likely on the PCI bus.\n");
        if (panic_on_unrecovered_nmi)
                 panic("NMI: Not continuing");
 
@@ -773,7 +765,6 @@ void __kprobes die_nmi(struct pt_regs *regs, const char *msg)
        printk(" on CPU%d, eip %08lx, registers:\n",
                smp_processor_id(), regs->eip);
        show_registers(regs);
-       printk(KERN_EMERG "console shuts up ...\n");
        console_silent();
        spin_unlock(&nmi_print_lock);
        bust_spinlocks(0);
@@ -1088,49 +1079,24 @@ fastcall void do_spurious_interrupt_bug(struct pt_regs * regs,
 #endif
 }
 
-fastcall void setup_x86_bogus_stack(unsigned char * stk)
-{
-       unsigned long *switch16_ptr, *switch32_ptr;
-       struct pt_regs *regs;
-       unsigned long stack_top, stack_bot;
-       unsigned short iret_frame16_off;
-       int cpu = smp_processor_id();
-       /* reserve the space on 32bit stack for the magic switch16 pointer */
-       memmove(stk, stk + 8, sizeof(struct pt_regs));
-       switch16_ptr = (unsigned long *)(stk + sizeof(struct pt_regs));
-       regs = (struct pt_regs *)stk;
-       /* now the switch32 on 16bit stack */
-       stack_bot = (unsigned long)&per_cpu(cpu_16bit_stack, cpu);
-       stack_top = stack_bot + CPU_16BIT_STACK_SIZE;
-       switch32_ptr = (unsigned long *)(stack_top - 8);
-       iret_frame16_off = CPU_16BIT_STACK_SIZE - 8 - 20;
-       /* copy iret frame on 16bit stack */
-       memcpy((void *)(stack_bot + iret_frame16_off), &regs->eip, 20);
-       /* fill in the switch pointers */
-       switch16_ptr[0] = (regs->esp & 0xffff0000) | iret_frame16_off;
-       switch16_ptr[1] = __ESPFIX_SS;
-       switch32_ptr[0] = (unsigned long)stk + sizeof(struct pt_regs) +
-               8 - CPU_16BIT_STACK_SIZE;
-       switch32_ptr[1] = __KERNEL_DS;
-}
-
-fastcall unsigned char * fixup_x86_bogus_stack(unsigned short sp)
+fastcall unsigned long patch_espfix_desc(unsigned long uesp,
+                                         unsigned long kesp)
 {
-       unsigned long *switch32_ptr;
-       unsigned char *stack16, *stack32;
-       unsigned long stack_top, stack_bot;
-       int len;
        int cpu = smp_processor_id();
-       stack_bot = (unsigned long)&per_cpu(cpu_16bit_stack, cpu);
-       stack_top = stack_bot + CPU_16BIT_STACK_SIZE;
-       switch32_ptr = (unsigned long *)(stack_top - 8);
-       /* copy the data from 16bit stack to 32bit stack */
-       len = CPU_16BIT_STACK_SIZE - 8 - sp;
-       stack16 = (unsigned char *)(stack_bot + sp);
-       stack32 = (unsigned char *)
-               (switch32_ptr[0] + CPU_16BIT_STACK_SIZE - 8 - len);
-       memcpy(stack32, stack16, len);
-       return stack32;
+       struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
+       struct desc_struct *gdt = (struct desc_struct *)cpu_gdt_descr->address;
+       unsigned long base = (kesp - uesp) & -THREAD_SIZE;
+       unsigned long new_kesp = kesp - base;
+       unsigned long lim_pages = (new_kesp | (THREAD_SIZE - 1)) >> PAGE_SHIFT;
+       __u64 desc = *(__u64 *)&gdt[GDT_ENTRY_ESPFIX_SS];
+       /* Set up base for espfix segment */
+       desc &= 0x00f0ff0000000000ULL;
+       desc |= ((((__u64)base) << 16) & 0x000000ffffff0000ULL) |
+               ((((__u64)base) << 32) & 0xff00000000000000ULL) |
+               ((((__u64)lim_pages) << 32) & 0x000f000000000000ULL) |
+               (lim_pages & 0xffff);
+       *(__u64 *)&gdt[GDT_ENTRY_ESPFIX_SS] = desc;
+       return new_kesp;
 }
 
 /*
@@ -1143,7 +1109,7 @@ fastcall unsigned char * fixup_x86_bogus_stack(unsigned short sp)
  * Must be called with kernel preemption disabled (in this case,
  * local interrupts are disabled at the call-site in entry.S).
  */
-asmlinkage void math_state_restore(struct pt_regs regs)
+asmlinkage void math_state_restore(void)
 {
        struct thread_info *thread = current_thread_info();
        struct task_struct *tsk = thread->task;
@@ -1153,6 +1119,7 @@ asmlinkage void math_state_restore(struct pt_regs regs)
                init_fpu(tsk);
        restore_fpu(tsk);
        thread->status |= TS_USEDFPU;   /* So we fnsave on switch_to() */
+       tsk->fpu_counter++;
 }
 
 #ifndef CONFIG_MATH_EMULATION
index 9810c8c9075060bb5bb54d2c4e6657214ccb44a9..1bbe45dca7a0ec626a3b2963d9031e579811d195 100644 (file)
@@ -13,7 +13,6 @@
 
 #include <asm/delay.h>
 #include <asm/tsc.h>
-#include <asm/delay.h>
 #include <asm/io.h>
 
 #include "mach_timer.h"
index cbcd61d6120b2fdf13b1f59a46721eb8c3c89b10..be2f96e67f78d80c51ba6c1b9a5fde49563ff415 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/highmem.h>
 #include <linux/ptrace.h>
 #include <linux/audit.h>
+#include <linux/stddef.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
 /*
  * 8- and 16-bit register defines..
  */
-#define AL(regs)       (((unsigned char *)&((regs)->eax))[0])
-#define AH(regs)       (((unsigned char *)&((regs)->eax))[1])
-#define IP(regs)       (*(unsigned short *)&((regs)->eip))
-#define SP(regs)       (*(unsigned short *)&((regs)->esp))
+#define AL(regs)       (((unsigned char *)&((regs)->pt.eax))[0])
+#define AH(regs)       (((unsigned char *)&((regs)->pt.eax))[1])
+#define IP(regs)       (*(unsigned short *)&((regs)->pt.eip))
+#define SP(regs)       (*(unsigned short *)&((regs)->pt.esp))
 
 /*
  * virtual flags (16 and 32-bit versions)
 #define SAFE_MASK      (0xDD5)
 #define RETURN_MASK    (0xDFF)
 
-#define VM86_REGS_PART2 orig_eax
-#define VM86_REGS_SIZE1 \
-        ( (unsigned)( & (((struct kernel_vm86_regs *)0)->VM86_REGS_PART2) ) )
-#define VM86_REGS_SIZE2 (sizeof(struct kernel_vm86_regs) - VM86_REGS_SIZE1)
+/* convert kernel_vm86_regs to vm86_regs */
+static int copy_vm86_regs_to_user(struct vm86_regs __user *user,
+                                 const struct kernel_vm86_regs *regs)
+{
+       int ret = 0;
+
+       /* kernel_vm86_regs is missing xfs, so copy everything up to
+          (but not including) xgs, and then rest after xgs. */
+       ret += copy_to_user(user, regs, offsetof(struct kernel_vm86_regs, pt.xgs));
+       ret += copy_to_user(&user->__null_gs, &regs->pt.xgs,
+                           sizeof(struct kernel_vm86_regs) -
+                           offsetof(struct kernel_vm86_regs, pt.xgs));
+
+       return ret;
+}
+
+/* convert vm86_regs to kernel_vm86_regs */
+static int copy_vm86_regs_from_user(struct kernel_vm86_regs *regs,
+                                   const struct vm86_regs __user *user,
+                                   unsigned extra)
+{
+       int ret = 0;
+
+       ret += copy_from_user(regs, user, offsetof(struct kernel_vm86_regs, pt.xgs));
+       ret += copy_from_user(&regs->pt.xgs, &user->__null_gs,
+                             sizeof(struct kernel_vm86_regs) -
+                             offsetof(struct kernel_vm86_regs, pt.xgs) +
+                             extra);
+
+       return ret;
+}
 
 struct pt_regs * FASTCALL(save_v86_state(struct kernel_vm86_regs * regs));
 struct pt_regs * fastcall save_v86_state(struct kernel_vm86_regs * regs)
@@ -112,10 +140,8 @@ struct pt_regs * fastcall save_v86_state(struct kernel_vm86_regs * regs)
                printk("no vm86_info: BAD\n");
                do_exit(SIGSEGV);
        }
-       set_flags(regs->eflags, VEFLAGS, VIF_MASK | current->thread.v86mask);
-       tmp = copy_to_user(&current->thread.vm86_info->regs,regs, VM86_REGS_SIZE1);
-       tmp += copy_to_user(&current->thread.vm86_info->regs.VM86_REGS_PART2,
-               &regs->VM86_REGS_PART2, VM86_REGS_SIZE2);
+       set_flags(regs->pt.eflags, VEFLAGS, VIF_MASK | current->thread.v86mask);
+       tmp = copy_vm86_regs_to_user(&current->thread.vm86_info->regs,regs);
        tmp += put_user(current->thread.screen_bitmap,&current->thread.vm86_info->screen_bitmap);
        if (tmp) {
                printk("vm86: could not access userspace vm86_info\n");
@@ -129,9 +155,11 @@ struct pt_regs * fastcall save_v86_state(struct kernel_vm86_regs * regs)
        current->thread.saved_esp0 = 0;
        put_cpu();
 
-       loadsegment(fs, current->thread.saved_fs);
-       loadsegment(gs, current->thread.saved_gs);
        ret = KVM86->regs32;
+
+       loadsegment(fs, current->thread.saved_fs);
+       ret->xgs = current->thread.saved_gs;
+
        return ret;
 }
 
@@ -183,9 +211,9 @@ asmlinkage int sys_vm86old(struct pt_regs regs)
        tsk = current;
        if (tsk->thread.saved_esp0)
                goto out;
-       tmp  = copy_from_user(&info, v86, VM86_REGS_SIZE1);
-       tmp += copy_from_user(&info.regs.VM86_REGS_PART2, &v86->regs.VM86_REGS_PART2,
-               (long)&info.vm86plus - (long)&info.regs.VM86_REGS_PART2);
+       tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
+                                      offsetof(struct kernel_vm86_struct, vm86plus) -
+                                      sizeof(info.regs));
        ret = -EFAULT;
        if (tmp)
                goto out;
@@ -233,9 +261,9 @@ asmlinkage int sys_vm86(struct pt_regs regs)
        if (tsk->thread.saved_esp0)
                goto out;
        v86 = (struct vm86plus_struct __user *)regs.ecx;
-       tmp  = copy_from_user(&info, v86, VM86_REGS_SIZE1);
-       tmp += copy_from_user(&info.regs.VM86_REGS_PART2, &v86->regs.VM86_REGS_PART2,
-               (long)&info.regs32 - (long)&info.regs.VM86_REGS_PART2);
+       tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
+                                      offsetof(struct kernel_vm86_struct, regs32) -
+                                      sizeof(info.regs));
        ret = -EFAULT;
        if (tmp)
                goto out;
@@ -252,15 +280,15 @@ out:
 static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk)
 {
        struct tss_struct *tss;
-       long eax;
 /*
  * make sure the vm86() system call doesn't try to do anything silly
  */
-       info->regs.__null_ds = 0;
-       info->regs.__null_es = 0;
+       info->regs.pt.xds = 0;
+       info->regs.pt.xes = 0;
+       info->regs.pt.xgs = 0;
 
-/* we are clearing fs,gs later just before "jmp resume_userspace",
- * because starting with Linux 2.1.x they aren't no longer saved/restored
+/* we are clearing fs later just before "jmp resume_userspace",
+ * because it is not saved/restored.
  */
 
 /*
@@ -268,10 +296,10 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
  * has set it up safely, so this makes sure interrupt etc flags are
  * inherited from protected mode.
  */
-       VEFLAGS = info->regs.eflags;
-       info->regs.eflags &= SAFE_MASK;
-       info->regs.eflags |= info->regs32->eflags & ~SAFE_MASK;
-       info->regs.eflags |= VM_MASK;
+       VEFLAGS = info->regs.pt.eflags;
+       info->regs.pt.eflags &= SAFE_MASK;
+       info->regs.pt.eflags |= info->regs32->eflags & ~SAFE_MASK;
+       info->regs.pt.eflags |= VM_MASK;
 
        switch (info->cpu_type) {
                case CPU_286:
@@ -294,7 +322,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
        info->regs32->eax = 0;
        tsk->thread.saved_esp0 = tsk->thread.esp0;
        savesegment(fs, tsk->thread.saved_fs);
-       savesegment(gs, tsk->thread.saved_gs);
+       tsk->thread.saved_gs = info->regs32->xgs;
 
        tss = &per_cpu(init_tss, get_cpu());
        tsk->thread.esp0 = (unsigned long) &info->VM86_TSS_ESP0;
@@ -306,19 +334,18 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
        tsk->thread.screen_bitmap = info->screen_bitmap;
        if (info->flags & VM86_SCREEN_BITMAP)
                mark_screen_rdonly(tsk->mm);
-       __asm__ __volatile__("xorl %eax,%eax; movl %eax,%fs; movl %eax,%gs\n\t");
-       __asm__ __volatile__("movl %%eax, %0\n" :"=r"(eax));
 
        /*call audit_syscall_exit since we do not exit via the normal paths */
        if (unlikely(current->audit_context))
-               audit_syscall_exit(AUDITSC_RESULT(eax), eax);
+               audit_syscall_exit(AUDITSC_RESULT(0), 0);
 
        __asm__ __volatile__(
                "movl %0,%%esp\n\t"
                "movl %1,%%ebp\n\t"
+               "mov  %2, %%fs\n\t"
                "jmp resume_userspace"
                : /* no outputs */
-               :"r" (&info->regs), "r" (task_thread_info(tsk)));
+               :"r" (&info->regs), "r" (task_thread_info(tsk)), "r" (0));
        /* we never return here */
 }
 
@@ -348,12 +375,12 @@ static inline void clear_IF(struct kernel_vm86_regs * regs)
 
 static inline void clear_TF(struct kernel_vm86_regs * regs)
 {
-       regs->eflags &= ~TF_MASK;
+       regs->pt.eflags &= ~TF_MASK;
 }
 
 static inline void clear_AC(struct kernel_vm86_regs * regs)
 {
-       regs->eflags &= ~AC_MASK;
+       regs->pt.eflags &= ~AC_MASK;
 }
 
 /* It is correct to call set_IF(regs) from the set_vflags_*
@@ -370,7 +397,7 @@ static inline void clear_AC(struct kernel_vm86_regs * regs)
 static inline void set_vflags_long(unsigned long eflags, struct kernel_vm86_regs * regs)
 {
        set_flags(VEFLAGS, eflags, current->thread.v86mask);
-       set_flags(regs->eflags, eflags, SAFE_MASK);
+       set_flags(regs->pt.eflags, eflags, SAFE_MASK);
        if (eflags & IF_MASK)
                set_IF(regs);
        else
@@ -380,7 +407,7 @@ static inline void set_vflags_long(unsigned long eflags, struct kernel_vm86_regs
 static inline void set_vflags_short(unsigned short flags, struct kernel_vm86_regs * regs)
 {
        set_flags(VFLAGS, flags, current->thread.v86mask);
-       set_flags(regs->eflags, flags, SAFE_MASK);
+       set_flags(regs->pt.eflags, flags, SAFE_MASK);
        if (flags & IF_MASK)
                set_IF(regs);
        else
@@ -389,7 +416,7 @@ static inline void set_vflags_short(unsigned short flags, struct kernel_vm86_reg
 
 static inline unsigned long get_vflags(struct kernel_vm86_regs * regs)
 {
-       unsigned long flags = regs->eflags & RETURN_MASK;
+       unsigned long flags = regs->pt.eflags & RETURN_MASK;
 
        if (VEFLAGS & VIF_MASK)
                flags |= IF_MASK;
@@ -493,7 +520,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
        unsigned long __user *intr_ptr;
        unsigned long segoffs;
 
-       if (regs->cs == BIOSSEG)
+       if (regs->pt.xcs == BIOSSEG)
                goto cannot_handle;
        if (is_revectored(i, &KVM86->int_revectored))
                goto cannot_handle;
@@ -505,9 +532,9 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
        if ((segoffs >> 16) == BIOSSEG)
                goto cannot_handle;
        pushw(ssp, sp, get_vflags(regs), cannot_handle);
-       pushw(ssp, sp, regs->cs, cannot_handle);
+       pushw(ssp, sp, regs->pt.xcs, cannot_handle);
        pushw(ssp, sp, IP(regs), cannot_handle);
-       regs->cs = segoffs >> 16;
+       regs->pt.xcs = segoffs >> 16;
        SP(regs) -= 6;
        IP(regs) = segoffs & 0xffff;
        clear_TF(regs);
@@ -524,7 +551,7 @@ int handle_vm86_trap(struct kernel_vm86_regs * regs, long error_code, int trapno
        if (VMPI.is_vm86pus) {
                if ( (trapno==3) || (trapno==1) )
                        return_to_32bit(regs, VM86_TRAP + (trapno << 8));
-               do_int(regs, trapno, (unsigned char __user *) (regs->ss << 4), SP(regs));
+               do_int(regs, trapno, (unsigned char __user *) (regs->pt.xss << 4), SP(regs));
                return 0;
        }
        if (trapno !=1)
@@ -560,10 +587,10 @@ void handle_vm86_fault(struct kernel_vm86_regs * regs, long error_code)
                handle_vm86_trap(regs, 0, 1); \
        return; } while (0)
 
-       orig_flags = *(unsigned short *)&regs->eflags;
+       orig_flags = *(unsigned short *)&regs->pt.eflags;
 
-       csp = (unsigned char __user *) (regs->cs << 4);
-       ssp = (unsigned char __user *) (regs->ss << 4);
+       csp = (unsigned char __user *) (regs->pt.xcs << 4);
+       ssp = (unsigned char __user *) (regs->pt.xss << 4);
        sp = SP(regs);
        ip = IP(regs);
 
@@ -650,7 +677,7 @@ void handle_vm86_fault(struct kernel_vm86_regs * regs, long error_code)
                        SP(regs) += 6;
                }
                IP(regs) = newip;
-               regs->cs = newcs;
+               regs->pt.xcs = newcs;
                CHECK_IF_IN_TRAP;
                if (data32) {
                        set_vflags_long(newflags, regs);
index c6f84a0322ba30438dda746a630ef68e4ace7306..16d3c7133ad79364a9c1a805a84e3fa9abf20ade 100644 (file)
@@ -1,13 +1,26 @@
 /* ld script to make i386 Linux kernel
  * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>;
+ *
+ * Don't define absolute symbols until and unless you know that symbol
+ * value is should remain constant even if kernel image is relocated
+ * at run time. Absolute symbols are not relocated. If symbol value should
+ * change if kernel is relocated, make the symbol section relative and
+ * put it inside the section definition.
  */
 
+/* Don't define absolute symbols until and unless you know that symbol
+ * value is should remain constant even if kernel image is relocated
+ * at run time. Absolute symbols are not relocated. If symbol value should
+ * change if kernel is relocated, make the symbol section relative and
+ * put it inside the section definition.
+ */
 #define LOAD_OFFSET __PAGE_OFFSET
 
 #include <asm-generic/vmlinux.lds.h>
 #include <asm/thread_info.h>
 #include <asm/page.h>
 #include <asm/cache.h>
+#include <asm/boot.h>
 
 OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
 OUTPUT_ARCH(i386)
@@ -21,34 +34,37 @@ PHDRS {
 }
 SECTIONS
 {
-  . = __KERNEL_START;
+  . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
   phys_startup_32 = startup_32 - LOAD_OFFSET;
   /* read-only */
-  _text = .;                   /* Text and read-only data */
   .text : AT(ADDR(.text) - LOAD_OFFSET) {
+       _text = .;                      /* Text and read-only data */
        *(.text)
        SCHED_TEXT
        LOCK_TEXT
        KPROBES_TEXT
        *(.fixup)
        *(.gnu.warning)
-       } :text = 0x9090
-
-  _etext = .;                  /* End of text section */
+       _etext = .;                     /* End of text section */
+  } :text = 0x9090
 
   . = ALIGN(16);               /* Exception table */
-  __start___ex_table = .;
-  __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
-  __stop___ex_table = .;
+  __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
+       __start___ex_table = .;
+        *(__ex_table)
+       __stop___ex_table = .;
+  }
 
   RODATA
 
+  BUG_TABLE
+
   . = ALIGN(4);
-  __tracedata_start = .;
   .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
+       __tracedata_start = .;
        *(.tracedata)
+       __tracedata_end = .;
   }
-  __tracedata_end = .;
 
   /* writeable */
   . = ALIGN(4096);
@@ -57,11 +73,19 @@ SECTIONS
        CONSTRUCTORS
        } :data
 
+  .paravirtprobe : AT(ADDR(.paravirtprobe) - LOAD_OFFSET) {
+       __start_paravirtprobe = .;
+       *(.paravirtprobe)
+       __stop_paravirtprobe = .;
+  }
+
   . = ALIGN(4096);
-  __nosave_begin = .;
-  .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { *(.data.nosave) }
-  . = ALIGN(4096);
-  __nosave_end = .;
+  .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
+       __nosave_begin = .;
+       *(.data.nosave)
+       . = ALIGN(4096);
+       __nosave_end = .;
+  }
 
   . = ALIGN(4096);
   .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
@@ -75,17 +99,10 @@ SECTIONS
 
   /* rarely changed data like cpu maps */
   . = ALIGN(32);
-  .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) { *(.data.read_mostly) }
-  _edata = .;                  /* End of data section */
-
-#ifdef CONFIG_STACK_UNWIND
-  . = ALIGN(4);
-  .eh_frame : AT(ADDR(.eh_frame) - LOAD_OFFSET) {
-       __start_unwind = .;
-       *(.eh_frame)
-       __end_unwind = .;
+  .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
+       *(.data.read_mostly)
+       _edata = .;             /* End of data section */
   }
-#endif
 
   . = ALIGN(THREAD_SIZE);      /* init_task */
   .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
@@ -94,88 +111,102 @@ SECTIONS
 
   /* might get freed after init */
   . = ALIGN(4096);
-  __smp_alt_begin = .;
-  __smp_alt_instructions = .;
   .smp_altinstructions : AT(ADDR(.smp_altinstructions) - LOAD_OFFSET) {
+       __smp_alt_begin = .;
+       __smp_alt_instructions = .;
        *(.smp_altinstructions)
+       __smp_alt_instructions_end = .;
   }
-  __smp_alt_instructions_end = .;
   . = ALIGN(4);
-  __smp_locks = .;
   .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
+       __smp_locks = .;
        *(.smp_locks)
+       __smp_locks_end = .;
   }
-  __smp_locks_end = .;
   .smp_altinstr_replacement : AT(ADDR(.smp_altinstr_replacement) - LOAD_OFFSET) {
        *(.smp_altinstr_replacement)
+       __smp_alt_end = .;
   }
+  /* will be freed after init
+   * Following ALIGN() is required to make sure no other data falls on the
+   * same page where __smp_alt_end is pointing as that page might be freed
+   * after boot. Always make sure that ALIGN() directive is present after
+   * the section which contains __smp_alt_end.
+   */
   . = ALIGN(4096);
-  __smp_alt_end = .;
 
   /* will be freed after init */
   . = ALIGN(4096);             /* Init code and data */
-  __init_begin = .;
   .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
+       __init_begin = .;
        _sinittext = .;
        *(.init.text)
        _einittext = .;
   }
   .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
   . = ALIGN(16);
-  __setup_start = .;
-  .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { *(.init.setup) }
-  __setup_end = .;
-  __initcall_start = .;
+  .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
+       __setup_start = .;
+       *(.init.setup)
+       __setup_end = .;
+   }
   .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
+       __initcall_start = .;
        INITCALLS
+       __initcall_end = .;
   }
-  __initcall_end = .;
-  __con_initcall_start = .;
   .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
+       __con_initcall_start = .;
        *(.con_initcall.init)
+       __con_initcall_end = .;
   }
-  __con_initcall_end = .;
   SECURITY_INIT
   . = ALIGN(4);
-  __alt_instructions = .;
   .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
+       __alt_instructions = .;
        *(.altinstructions)
+       __alt_instructions_end = .;
   }
-  __alt_instructions_end = .; 
   .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
        *(.altinstr_replacement)
   }
+  . = ALIGN(4);
+  .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
+       __start_parainstructions = .;
+       *(.parainstructions)
+       __stop_parainstructions = .;
+  }
   /* .exit.text is discard at runtime, not link time, to deal with references
      from .altinstructions and .eh_frame */
   .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
   .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
   . = ALIGN(4096);
-  __initramfs_start = .;
-  .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) }
-  __initramfs_end = .;
+  .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
+       __initramfs_start = .;
+       *(.init.ramfs)
+       __initramfs_end = .;
+  }
   . = ALIGN(L1_CACHE_BYTES);
-  __per_cpu_start = .;
-  .data.percpu  : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) }
-  __per_cpu_end = .;
+  .data.percpu  : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
+       __per_cpu_start = .;
+       *(.data.percpu)
+       __per_cpu_end = .;
+  }
   . = ALIGN(4096);
-  __init_end = .;
   /* freed after init ends here */
        
-  __bss_start = .;             /* BSS */
-  .bss.page_aligned : AT(ADDR(.bss.page_aligned) - LOAD_OFFSET) {
-       *(.bss.page_aligned)
-  }
   .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
+       __init_end = .;
+       __bss_start = .;                /* BSS */
+       *(.bss.page_aligned)
        *(.bss)
+       . = ALIGN(4);
+       __bss_stop = .;
+       _end = . ;
+       /* This is where the kernel creates the early boot page tables */
+       . = ALIGN(4096);
+       pg0 = . ;
   }
-  . = ALIGN(4);
-  __bss_stop = .; 
-
-  _end = . ;
-
-  /* This is where the kernel creates the early boot page tables */
-  . = ALIGN(4096);
-  pg0 = .;
 
   /* Sections to be discarded */
   /DISCARD/ : {
index 94b1fd9cbe3cdaef7aaed0b5dcb84bfcff12d7a4..a7b3999bb37a8e4ab63b8f189de86e2619ee89fb 100644 (file)
@@ -45,7 +45,9 @@ static int __init parse_apic(char *arg)
                        return 0;
                }
        }
-       return -ENOENT;
+
+       /* Parsed again by __setup for debug/verbose */
+       return 0;
 }
 early_param("apic", parse_apic);
 
index 885c7cbfd4785b69edca7789b620299988a6e4d0..233ee20907b9bdd17d86282afee90ad77716a2a6 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/smp.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/module.h>
 
 #include <asm/fixmap.h>
 #include <asm/arch_hooks.h>
@@ -142,6 +143,8 @@ void __init time_init_hook(void)
 
 unsigned long sgivwfb_mem_phys;
 unsigned long sgivwfb_mem_size;
+EXPORT_SYMBOL(sgivwfb_mem_phys);
+EXPORT_SYMBOL(sgivwfb_mem_size);
 
 long long mem_size __initdata = 0;
 
index f50c6c6ad680e8eb7c2092757d18291fa3e68ab6..943a9473b138c25752e4011f517b6126baeeb2ac 100644 (file)
@@ -776,7 +776,7 @@ voyager_cat_init(void)
                for(asic=0; asic < (*modpp)->num_asics; asic++) {
                        int j;
                        voyager_asic_t *asicp = *asicpp 
-                               = kmalloc(sizeof(voyager_asic_t), GFP_KERNEL); /*&voyager_asic_storage[asic_count++];*/
+                               = kzalloc(sizeof(voyager_asic_t), GFP_KERNEL); /*&voyager_asic_storage[asic_count++];*/
                        voyager_sp_table_t *sp_table;
                        voyager_at_t *asic_table;
                        voyager_jtt_t *jtag_table;
@@ -785,7 +785,6 @@ voyager_cat_init(void)
                                printk("**WARNING** kmalloc failure in cat_init\n");
                                continue;
                        }
-                       memset(asicp, 0, sizeof(voyager_asic_t));
                        asicpp = &(asicp->next);
                        asicp->asic_location = asic;
                        sp_table = (voyager_sp_table_t *)(eprom_buf + sp_offset);
@@ -851,8 +850,7 @@ voyager_cat_init(void)
 #endif
 
                {
-                       struct resource *res = kmalloc(sizeof(struct resource),GFP_KERNEL);
-                       memset(res, 0, sizeof(struct resource));
+                       struct resource *res = kzalloc(sizeof(struct resource),GFP_KERNEL);
                        res->name = kmalloc(128, GFP_KERNEL);
                        sprintf((char *)res->name, "Voyager %s Quad CPI", cat_module_name(i));
                        res->start = qic_addr;
index f3fea2ad50fea81c5a4a3decfcdfc52d041b5f61..55428e656a3f9a90bddcb50770e92e7434fab16c 100644 (file)
@@ -28,6 +28,7 @@
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
 #include <asm/arch_hooks.h>
+#include <asm/pda.h>
 
 /* TLB state -- visible externally, indexed physically */
 DEFINE_PER_CPU(struct tlb_state, cpu_tlbstate) ____cacheline_aligned = { &init_mm, 0 };
@@ -422,6 +423,7 @@ find_smp_config(void)
             VOYAGER_SUS_IN_CONTROL_PORT);
 
        current_thread_info()->cpu = boot_cpu_id;
+       write_pda(cpu_number, boot_cpu_id);
 }
 
 /*
@@ -458,7 +460,7 @@ start_secondary(void *unused)
        /* external functions not defined in the headers */
        extern void calibrate_delay(void);
 
-       cpu_init();
+       secondary_cpu_init();
 
        /* OK, we're in the routine */
        ack_CPI(VIC_CPU_BOOT_CPI);
@@ -578,6 +580,15 @@ do_boot_cpu(__u8 cpu)
        /* init_tasks (in sched.c) is indexed logically */
        stack_start.esp = (void *) idle->thread.esp;
 
+       /* Pre-allocate and initialize the CPU's GDT and PDA so it
+          doesn't have to do any memory allocation during the
+          delicate CPU-bringup phase. */
+       if (!init_gdt(cpu, idle)) {
+               printk(KERN_INFO "Couldn't allocate GDT/PDA for CPU %d\n", cpu);
+               cpucount--;
+               return;
+       }
+
        irq_ctx_init(cpu);
 
        /* Note: Don't modify initial ss override */
@@ -1963,4 +1974,5 @@ void __init
 smp_setup_processor_id(void)
 {
        current_thread_info()->cpu = hard_smp_processor_id();
+       write_pda(cpu_number, hard_smp_processor_id());
 }
index d62b20a3e660f5341c2bccf77c0a91885addc5e5..65120f52385332c67aa1b5275f407bc377a79c17 100644 (file)
@@ -57,6 +57,7 @@
 #define TAG_Special    Const(2)        /* De-normal, + or - infinity,
                                           or Not a Number */
 #define TAG_Empty      Const(3)        /* empty */
+#define TAG_Error      Const(0x80)     /* probably need to abort */
 
 #define LOADED_DATA    Const(10101)    /* Special st() number to identify
                                           loaded data (not on stack). */
index d93f16ef828f5986f7930b4aabbdd55ca92fd9cb..ddf8fa3bbd01d7c15ef03abf6c7c55c5356ebd57 100644 (file)
@@ -742,7 +742,8 @@ int save_i387_soft(void *s387, struct _fpstate __user * buf)
   S387->fcs &= ~0xf8000000;
   S387->fos |= 0xffff0000;
 #endif /* PECULIAR_486 */
-  __copy_to_user(d, &S387->cwd, 7*4);
+  if (__copy_to_user(d, &S387->cwd, 7*4))
+    return -1;
   RE_ENTRANT_CHECK_ON;
 
   d += 7*4;
index bf26341c8bdeaa01e771a73130065786e769ed71..a3ae28c49dddad063de9c177f7d0f13480df3da5 100644 (file)
@@ -68,6 +68,7 @@
 
 #define FPU_access_ok(x,y,z)   if ( !access_ok(x,y,z) ) \
                                math_abort(FPU_info,SIGSEGV)
+#define FPU_abort              math_abort(FPU_info, SIGSEGV)
 
 #undef FPU_IGNORE_CODE_SEGV
 #ifdef FPU_IGNORE_CODE_SEGV
index 85314be2fef8d9fc89995ba628f214fc2f153d9a..eebd6fb1c8a8a1933b0ffd1c3563aeac0b31a731 100644 (file)
@@ -227,6 +227,8 @@ int FPU_load_store(u_char type, fpu_addr_modes addr_modes,
     case 027:      /* fild m64int */
       clear_C1();
       loaded_tag = FPU_load_int64((long long __user *)data_address);
+      if (loaded_tag == TAG_Error)
+       return 0;
       FPU_settag0(loaded_tag);
       break;
     case 030:     /* fstenv  m14/28byte */
index f06ed41d191d53f5496c295bfaf1ca3b07179b69..e976caef64982849f3caa918ec5181bb3958b237 100644 (file)
@@ -244,7 +244,8 @@ int FPU_load_int64(long long __user *_s)
 
   RE_ENTRANT_CHECK_OFF;
   FPU_access_ok(VERIFY_READ, _s, 8);
-  copy_from_user(&s,_s,8);
+  if (copy_from_user(&s,_s,8))
+    FPU_abort;
   RE_ENTRANT_CHECK_ON;
 
   if (s == 0)
@@ -907,7 +908,8 @@ int FPU_store_int64(FPU_REG *st0_ptr, u_char st0_tag, long long __user *d)
 
   RE_ENTRANT_CHECK_OFF;
   FPU_access_ok(VERIFY_WRITE,d,8);
-  copy_to_user(d, &tll, 8);
+  if (copy_to_user(d, &tll, 8))
+    FPU_abort;
   RE_ENTRANT_CHECK_ON;
 
   return 1;
@@ -1336,7 +1338,8 @@ u_char __user *fstenv(fpu_addr_modes addr_modes, u_char __user *d)
       I387.soft.fcs &= ~0xf8000000;
       I387.soft.fos |= 0xffff0000;
 #endif /* PECULIAR_486 */
-      __copy_to_user(d, &control_word, 7*4);
+      if (__copy_to_user(d, &control_word, 7*4))
+       FPU_abort;
       RE_ENTRANT_CHECK_ON;
       d += 0x1c;
     }
@@ -1359,9 +1362,11 @@ void fsave(fpu_addr_modes addr_modes, u_char __user *data_address)
   FPU_access_ok(VERIFY_WRITE,d,80);
 
   /* Copy all registers in stack order. */
-  __copy_to_user(d, register_base+offset, other);
+  if (__copy_to_user(d, register_base+offset, other))
+    FPU_abort;
   if ( offset )
-    __copy_to_user(d+other, register_base, offset);
+    if (__copy_to_user(d+other, register_base, offset))
+      FPU_abort;
   RE_ENTRANT_CHECK_ON;
 
   finit();
index 4de11f508c3a0ffb161aa95e8cd910471323aae4..4de95a17a7d4de6e7cefc8604da03f3dda0fa56f 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #undef CONFIG_X86_PAE
+#undef CONFIG_PARAVIRT
 #include <asm/page.h>
 #include <asm/pgtable.h>
 #include <asm/tlbflush.h>
index ddbdb0336f28f1c6d4d303d11055a929b7daf286..103b76e56a9484ea579f0a14f4626859a2e4bf8b 100644 (file)
@@ -168,7 +168,7 @@ static void __init allocate_pgdat(int nid)
        if (nid && node_has_online_mem(nid))
                NODE_DATA(nid) = (pg_data_t *)node_remap_start_vaddr[nid];
        else {
-               NODE_DATA(nid) = (pg_data_t *)(__va(min_low_pfn << PAGE_SHIFT));
+               NODE_DATA(nid) = (pg_data_t *)(pfn_to_kaddr(min_low_pfn));
                min_low_pfn += PFN_UP(sizeof(pg_data_t));
        }
 }
index 2581575786c135a0a0201cf63caf754a8654a755..aaaa4d225f7e25ad86c66511fcdf06d598ce9a09 100644 (file)
@@ -22,9 +22,9 @@
 #include <linux/highmem.h>
 #include <linux/module.h>
 #include <linux/kprobes.h>
+#include <linux/uaccess.h>
 
 #include <asm/system.h>
-#include <asm/uaccess.h>
 #include <asm/desc.h>
 #include <asm/kdebug.h>
 #include <asm/segment.h>
@@ -167,7 +167,7 @@ static inline unsigned long get_segment_eip(struct pt_regs *regs,
 static int __is_prefetch(struct pt_regs *regs, unsigned long addr)
 { 
        unsigned long limit;
-       unsigned long instr = get_segment_eip (regs, &limit);
+       unsigned char *instr = (unsigned char *)get_segment_eip (regs, &limit);
        int scan_more = 1;
        int prefetch = 0; 
        int i;
@@ -177,9 +177,9 @@ static int __is_prefetch(struct pt_regs *regs, unsigned long addr)
                unsigned char instr_hi;
                unsigned char instr_lo;
 
-               if (instr > limit)
+               if (instr > (unsigned char *)limit)
                        break;
-               if (__get_user(opcode, (unsigned char __user *) instr))
+               if (probe_kernel_address(instr, opcode))
                        break; 
 
                instr_hi = opcode & 0xf0; 
@@ -204,9 +204,9 @@ static int __is_prefetch(struct pt_regs *regs, unsigned long addr)
                case 0x00:
                        /* Prefetch instruction is 0x0F0D or 0x0F18 */
                        scan_more = 0;
-                       if (instr > limit)
+                       if (instr > (unsigned char *)limit)
                                break;
-                       if (__get_user(opcode, (unsigned char __user *) instr))
+                       if (probe_kernel_address(instr, opcode))
                                break;
                        prefetch = (instr_lo == 0xF) &&
                                (opcode == 0x0D || opcode == 0x18);
index f9f647cdbc7ba3550e83d82c0c9e6996b3ae8878..e0fa6cb655a82574a50c3e8fc9334c2f71b9c156 100644 (file)
@@ -32,7 +32,7 @@ void *kmap_atomic(struct page *page, enum km_type type)
        unsigned long vaddr;
 
        /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
-       inc_preempt_count();
+       pagefault_disable();
        if (!PageHighMem(page))
                return page_address(page);
 
@@ -50,26 +50,22 @@ void kunmap_atomic(void *kvaddr, enum km_type type)
        unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
        enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
 
-#ifdef CONFIG_DEBUG_HIGHMEM
-       if (vaddr >= PAGE_OFFSET && vaddr < (unsigned long)high_memory) {
-               dec_preempt_count();
-               preempt_check_resched();
-               return;
-       }
-
-       if (vaddr != __fix_to_virt(FIX_KMAP_BEGIN+idx))
-               BUG();
-#endif
        /*
         * Force other mappings to Oops if they'll try to access this pte
         * without first remap it.  Keeping stale mappings around is a bad idea
         * also, in case the page changes cacheability attributes or becomes
         * a protected page in a hypervisor.
         */
-       kpte_clear_flush(kmap_pte-idx, vaddr);
+       if (vaddr == __fix_to_virt(FIX_KMAP_BEGIN+idx))
+               kpte_clear_flush(kmap_pte-idx, vaddr);
+       else {
+#ifdef CONFIG_DEBUG_HIGHMEM
+               BUG_ON(vaddr < PAGE_OFFSET);
+               BUG_ON(vaddr >= (unsigned long)high_memory);
+#endif
+       }
 
-       dec_preempt_count();
-       preempt_check_resched();
+       pagefault_enable();
 }
 
 /* This is the same as kmap_atomic() but can map memory that doesn't
@@ -80,7 +76,7 @@ void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
        enum fixed_addresses idx;
        unsigned long vaddr;
 
-       inc_preempt_count();
+       pagefault_disable();
 
        idx = type + KM_TYPE_NR*smp_processor_id();
        vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
index 1719a8141f81aee9f480087be3e54a68eef4adef..34728e4afe4806ad88982922ebbf9654023e4b64 100644 (file)
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
 
+static unsigned long page_table_shareable(struct vm_area_struct *svma,
+                               struct vm_area_struct *vma,
+                               unsigned long addr, pgoff_t idx)
+{
+       unsigned long saddr = ((idx - svma->vm_pgoff) << PAGE_SHIFT) +
+                               svma->vm_start;
+       unsigned long sbase = saddr & PUD_MASK;
+       unsigned long s_end = sbase + PUD_SIZE;
+
+       /*
+        * match the virtual addresses, permission and the alignment of the
+        * page table page.
+        */
+       if (pmd_index(addr) != pmd_index(saddr) ||
+           vma->vm_flags != svma->vm_flags ||
+           sbase < svma->vm_start || svma->vm_end < s_end)
+               return 0;
+
+       return saddr;
+}
+
+static int vma_shareable(struct vm_area_struct *vma, unsigned long addr)
+{
+       unsigned long base = addr & PUD_MASK;
+       unsigned long end = base + PUD_SIZE;
+
+       /*
+        * check on proper vm_flags and page table alignment
+        */
+       if (vma->vm_flags & VM_MAYSHARE &&
+           vma->vm_start <= base && end <= vma->vm_end)
+               return 1;
+       return 0;
+}
+
+/*
+ * search for a shareable pmd page for hugetlb.
+ */
+static void huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
+{
+       struct vm_area_struct *vma = find_vma(mm, addr);
+       struct address_space *mapping = vma->vm_file->f_mapping;
+       pgoff_t idx = ((addr - vma->vm_start) >> PAGE_SHIFT) +
+                       vma->vm_pgoff;
+       struct prio_tree_iter iter;
+       struct vm_area_struct *svma;
+       unsigned long saddr;
+       pte_t *spte = NULL;
+
+       if (!vma_shareable(vma, addr))
+               return;
+
+       spin_lock(&mapping->i_mmap_lock);
+       vma_prio_tree_foreach(svma, &iter, &mapping->i_mmap, idx, idx) {
+               if (svma == vma)
+                       continue;
+
+               saddr = page_table_shareable(svma, vma, addr, idx);
+               if (saddr) {
+                       spte = huge_pte_offset(svma->vm_mm, saddr);
+                       if (spte) {
+                               get_page(virt_to_page(spte));
+                               break;
+                       }
+               }
+       }
+
+       if (!spte)
+               goto out;
+
+       spin_lock(&mm->page_table_lock);
+       if (pud_none(*pud))
+               pud_populate(mm, pud, (unsigned long) spte & PAGE_MASK);
+       else
+               put_page(virt_to_page(spte));
+       spin_unlock(&mm->page_table_lock);
+out:
+       spin_unlock(&mapping->i_mmap_lock);
+}
+
+/*
+ * unmap huge page backed by shared pte.
+ *
+ * Hugetlb pte page is ref counted at the time of mapping.  If pte is shared
+ * indicated by page_count > 1, unmap is achieved by clearing pud and
+ * decrementing the ref count. If count == 1, the pte page is not shared.
+ *
+ * called with vma->vm_mm->page_table_lock held.
+ *
+ * returns: 1 successfully unmapped a shared pte page
+ *         0 the underlying pte page is not shared, or it is the last user
+ */
+int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
+{
+       pgd_t *pgd = pgd_offset(mm, *addr);
+       pud_t *pud = pud_offset(pgd, *addr);
+
+       BUG_ON(page_count(virt_to_page(ptep)) == 0);
+       if (page_count(virt_to_page(ptep)) == 1)
+               return 0;
+
+       pud_clear(pud);
+       put_page(virt_to_page(ptep));
+       *addr = ALIGN(*addr, HPAGE_SIZE * PTRS_PER_PTE) - HPAGE_SIZE;
+       return 1;
+}
+
 pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
 {
        pgd_t *pgd;
@@ -25,8 +132,11 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
 
        pgd = pgd_offset(mm, addr);
        pud = pud_alloc(mm, pgd, addr);
-       if (pud)
+       if (pud) {
+               if (pud_none(*pud))
+                       huge_pmd_share(mm, addr, pud);
                pte = (pte_t *) pmd_alloc(mm, pud, addr);
+       }
        BUG_ON(pte && !pte_none(*pte) && !pte_huge(*pte));
 
        return pte;
index 167416155ee41606007452bc6d14f2b845757326..84697dfc7348b93c6be087584b8653a0e6fd427b 100644 (file)
@@ -192,8 +192,6 @@ static inline int page_kills_ppro(unsigned long pagenr)
        return 0;
 }
 
-extern int is_available_memory(efi_memory_desc_t *);
-
 int page_is_ram(unsigned long pagenr)
 {
        int i;
@@ -699,8 +697,8 @@ int remove_memory(u64 start, u64 size)
 #endif
 #endif
 
-kmem_cache_t *pgd_cache;
-kmem_cache_t *pmd_cache;
+struct kmem_cache *pgd_cache;
+struct kmem_cache *pmd_cache;
 
 void __init pgtable_cache_init(void)
 {
index 8564b6ae17e330aa7ca48489a3f71bbf458415ba..ad91528bdc14f0cd341a6e3be8d04f29bd9b4e52 100644 (file)
@@ -67,11 +67,17 @@ static struct page *split_large_page(unsigned long address, pgprot_t prot,
        return base;
 } 
 
-static void flush_kernel_map(void *dummy) 
+static void flush_kernel_map(void *arg)
 { 
-       /* Could use CLFLUSH here if the CPU supports it (Hammer,P4) */
-       if (boot_cpu_data.x86_model >= 4) 
+       unsigned long adr = (unsigned long)arg;
+
+       if (adr && cpu_has_clflush) {
+               int i;
+               for (i = 0; i < PAGE_SIZE; i += boot_cpu_data.x86_clflush_size)
+                       asm volatile("clflush (%0)" :: "r" (adr + i));
+       } else if (boot_cpu_data.x86_model >= 4)
                wbinvd();
+
        /* Flush all to work around Errata in early athlons regarding 
         * large page flushing. 
         */
@@ -173,9 +179,9 @@ __change_page_attr(struct page *page, pgprot_t prot)
        return 0;
 } 
 
-static inline void flush_map(void)
+static inline void flush_map(void *adr)
 {
-       on_each_cpu(flush_kernel_map, NULL, 1, 1);
+       on_each_cpu(flush_kernel_map, adr, 1, 1);
 }
 
 /*
@@ -217,9 +223,13 @@ void global_flush_tlb(void)
        spin_lock_irq(&cpa_lock);
        list_replace_init(&df_list, &l);
        spin_unlock_irq(&cpa_lock);
-       flush_map();
-       list_for_each_entry_safe(pg, next, &l, lru)
+       if (!cpu_has_clflush)
+               flush_map(0);
+       list_for_each_entry_safe(pg, next, &l, lru) {
+               if (cpu_has_clflush)
+                       flush_map(page_address(pg));
                __free_page(pg);
+       }
 }
 
 #ifdef CONFIG_DEBUG_PAGEALLOC
index 10126e3f81745f5591eab2e66dc4426394c3c2cb..f349eaf450b0db542c5c3e56c3b598da94562a66 100644 (file)
@@ -95,8 +95,11 @@ static void set_pte_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags)
                return;
        }
        pte = pte_offset_kernel(pmd, vaddr);
-       /* <pfn,flags> stored as-is, to permit clearing entries */
-       set_pte(pte, pfn_pte(pfn, flags));
+       if (pgprot_val(flags))
+               /* <pfn,flags> stored as-is, to permit clearing entries */
+               set_pte(pte, pfn_pte(pfn, flags));
+       else
+               pte_clear(&init_mm, vaddr, pte);
 
        /*
         * It's enough to flush this one mapping.
@@ -193,7 +196,7 @@ struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
        return pte;
 }
 
-void pmd_ctor(void *pmd, kmem_cache_t *cache, unsigned long flags)
+void pmd_ctor(void *pmd, struct kmem_cache *cache, unsigned long flags)
 {
        memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
 }
@@ -233,7 +236,7 @@ static inline void pgd_list_del(pgd_t *pgd)
                set_page_private(next, (unsigned long)pprev);
 }
 
-void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused)
+void pgd_ctor(void *pgd, struct kmem_cache *cache, unsigned long unused)
 {
        unsigned long flags;
 
@@ -253,7 +256,7 @@ void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused)
 }
 
 /* never called when PTRS_PER_PMD > 1 */
-void pgd_dtor(void *pgd, kmem_cache_t *cache, unsigned long unused)
+void pgd_dtor(void *pgd, struct kmem_cache *cache, unsigned long unused)
 {
        unsigned long flags; /* can be called from interrupt context */
 
index 713d6c866cae0b9f8ecc56c82fc04cebde642d80..42df4b6606dfdbc6f21d2cce0cbb6e8ae3e3ea42 100644 (file)
@@ -45,6 +45,13 @@ void write_pci_config(u8 bus, u8 slot, u8 func, u8 offset,
        outl(val, 0xcfc);
 }
 
+void write_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset, u8 val)
+{
+       PDprintk("%x writing to %x: %x\n", slot, offset, val);
+       outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
+       outb(val, 0xcfc);
+}
+
 int early_pci_allowed(void)
 {
        return (pci_probe & (PCI_PROBE_CONF1|PCI_PROBE_NOEARLY)) ==
index e65551cd82162522ed0dfd919cb6e653f6e1b7b5..f2cb942f828197ae61b36c2314cc8b2fcee75446 100644 (file)
@@ -764,7 +764,7 @@ static void __init pirq_find_router(struct irq_router *r)
        DBG(KERN_DEBUG "PCI: Attempting to find IRQ router for %04x:%04x\n",
            rt->rtr_vendor, rt->rtr_device);
 
-       pirq_router_dev = pci_find_slot(rt->rtr_bus, rt->rtr_devfn);
+       pirq_router_dev = pci_get_bus_and_slot(rt->rtr_bus, rt->rtr_devfn);
        if (!pirq_router_dev) {
                DBG(KERN_DEBUG "PCI: Interrupt router not found at "
                        "%02x:%02x\n", rt->rtr_bus, rt->rtr_devfn);
@@ -784,6 +784,8 @@ static void __init pirq_find_router(struct irq_router *r)
                pirq_router_dev->vendor,
                pirq_router_dev->device,
                pci_name(pirq_router_dev));
+
+       /* The device remains referenced for the kernel lifetime */
 }
 
 static struct irq_info *pirq_get_info(struct pci_dev *dev)
index ed1512a175ab08e200751ed5078f2373a9b5760f..5f5193401beadea0302538b348dacd1a76b261c7 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/uaccess.h>
 #include "pci.h"
 #include "pci-functions.h"
 
@@ -314,6 +315,10 @@ static struct pci_raw_ops * __devinit pci_find_bios(void)
        for (check = (union bios32 *) __va(0xe0000);
             check <= (union bios32 *) __va(0xffff0);
             ++check) {
+               long sig;
+               if (probe_kernel_address(&check->fields.signature, sig))
+                       continue;
+
                if (check->fields.signature != BIOS32_SIGNATURE)
                        continue;
                length = check->fields.length * 16;
@@ -331,11 +336,13 @@ static struct pci_raw_ops * __devinit pci_find_bios(void)
                }
                DBG("PCI: BIOS32 Service Directory structure at 0x%p\n", check);
                if (check->fields.entry >= 0x100000) {
-                       printk("PCI: BIOS32 entry (0x%p) in high memory, cannot use.\n", check);
+                       printk("PCI: BIOS32 entry (0x%p) in high memory, "
+                                       "cannot use.\n", check);
                        return NULL;
                } else {
                        unsigned long bios32_entry = check->fields.entry;
-                       DBG("PCI: BIOS32 Service Directory entry at 0x%lx\n", bios32_entry);
+                       DBG("PCI: BIOS32 Service Directory entry at 0x%lx\n",
+                                       bios32_entry);
                        bios32_indirect.address = bios32_entry + PAGE_OFFSET;
                        if (check_pcibios())
                                return &pci_bios_access;
index 8cfa4e8a719d6ea2dd9cf140862cb2c6a64b669a..2de7bbf03cd7f0d35a93aa5e7b778127699367ef 100644 (file)
@@ -1,2 +1,2 @@
 obj-$(CONFIG_PM)               += cpu.o
-obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o
+obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o suspend.o
index 5a1abeff033ba7ed33ecb97151aba3186aa62446..2c15500f8713e001bd8c71fbc59136525a408fb9 100644 (file)
@@ -26,8 +26,8 @@ void __save_processor_state(struct saved_context *ctxt)
        /*
         * descriptor tables
         */
-       store_gdt(&ctxt->gdt_limit);
-       store_idt(&ctxt->idt_limit);
+       store_gdt(&ctxt->gdt);
+       store_idt(&ctxt->idt);
        store_tr(ctxt->tr);
 
        /*
@@ -99,8 +99,8 @@ void __restore_processor_state(struct saved_context *ctxt)
         * now restore the descriptor tables to their proper values
         * ltr is done i fix_processor_context().
         */
-       load_gdt(&ctxt->gdt_limit);
-       load_idt(&ctxt->idt_limit);
+       load_gdt(&ctxt->gdt);
+       load_idt(&ctxt->idt);
 
        /*
         * segment registers
diff --git a/arch/i386/power/suspend.c b/arch/i386/power/suspend.c
new file mode 100644 (file)
index 0000000..db5e98d
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+ * Suspend support specific for i386 - temporary page tables
+ *
+ * Distribute under GPLv2
+ *
+ * Copyright (c) 2006 Rafael J. Wysocki <rjw@sisk.pl>
+ */
+
+#include <linux/suspend.h>
+#include <linux/bootmem.h>
+
+#include <asm/system.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+
+/* Defined in arch/i386/power/swsusp.S */
+extern int restore_image(void);
+
+/* Pointer to the temporary resume page tables */
+pgd_t *resume_pg_dir;
+
+/* The following three functions are based on the analogous code in
+ * arch/i386/mm/init.c
+ */
+
+/*
+ * Create a middle page table on a resume-safe page and put a pointer to it in
+ * the given global directory entry.  This only returns the gd entry
+ * in non-PAE compilation mode, since the middle layer is folded.
+ */
+static pmd_t *resume_one_md_table_init(pgd_t *pgd)
+{
+       pud_t *pud;
+       pmd_t *pmd_table;
+
+#ifdef CONFIG_X86_PAE
+       pmd_table = (pmd_t *)get_safe_page(GFP_ATOMIC);
+       if (!pmd_table)
+               return NULL;
+
+       set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
+       pud = pud_offset(pgd, 0);
+
+       BUG_ON(pmd_table != pmd_offset(pud, 0));
+#else
+       pud = pud_offset(pgd, 0);
+       pmd_table = pmd_offset(pud, 0);
+#endif
+
+       return pmd_table;
+}
+
+/*
+ * Create a page table on a resume-safe page and place a pointer to it in
+ * a middle page directory entry.
+ */
+static pte_t *resume_one_page_table_init(pmd_t *pmd)
+{
+       if (pmd_none(*pmd)) {
+               pte_t *page_table = (pte_t *)get_safe_page(GFP_ATOMIC);
+               if (!page_table)
+                       return NULL;
+
+               set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
+
+               BUG_ON(page_table != pte_offset_kernel(pmd, 0));
+
+               return page_table;
+       }
+
+       return pte_offset_kernel(pmd, 0);
+}
+
+/*
+ * This maps the physical memory to kernel virtual address space, a total
+ * of max_low_pfn pages, by creating page tables starting from address
+ * PAGE_OFFSET.  The page tables are allocated out of resume-safe pages.
+ */
+static int resume_physical_mapping_init(pgd_t *pgd_base)
+{
+       unsigned long pfn;
+       pgd_t *pgd;
+       pmd_t *pmd;
+       pte_t *pte;
+       int pgd_idx, pmd_idx;
+
+       pgd_idx = pgd_index(PAGE_OFFSET);
+       pgd = pgd_base + pgd_idx;
+       pfn = 0;
+
+       for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
+               pmd = resume_one_md_table_init(pgd);
+               if (!pmd)
+                       return -ENOMEM;
+
+               if (pfn >= max_low_pfn)
+                       continue;
+
+               for (pmd_idx = 0; pmd_idx < PTRS_PER_PMD; pmd++, pmd_idx++) {
+                       if (pfn >= max_low_pfn)
+                               break;
+
+                       /* Map with big pages if possible, otherwise create
+                        * normal page tables.
+                        * NOTE: We can mark everything as executable here
+                        */
+                       if (cpu_has_pse) {
+                               set_pmd(pmd, pfn_pmd(pfn, PAGE_KERNEL_LARGE_EXEC));
+                               pfn += PTRS_PER_PTE;
+                       } else {
+                               pte_t *max_pte;
+
+                               pte = resume_one_page_table_init(pmd);
+                               if (!pte)
+                                       return -ENOMEM;
+
+                               max_pte = pte + PTRS_PER_PTE;
+                               for (; pte < max_pte; pte++, pfn++) {
+                                       if (pfn >= max_low_pfn)
+                                               break;
+
+                                       set_pte(pte, pfn_pte(pfn, PAGE_KERNEL_EXEC));
+                               }
+                       }
+               }
+       }
+       return 0;
+}
+
+static inline void resume_init_first_level_page_table(pgd_t *pg_dir)
+{
+#ifdef CONFIG_X86_PAE
+       int i;
+
+       /* Init entries of the first-level page table to the zero page */
+       for (i = 0; i < PTRS_PER_PGD; i++)
+               set_pgd(pg_dir + i,
+                       __pgd(__pa(empty_zero_page) | _PAGE_PRESENT));
+#endif
+}
+
+int swsusp_arch_resume(void)
+{
+       int error;
+
+       resume_pg_dir = (pgd_t *)get_safe_page(GFP_ATOMIC);
+       if (!resume_pg_dir)
+               return -ENOMEM;
+
+       resume_init_first_level_page_table(resume_pg_dir);
+       error = resume_physical_mapping_init(resume_pg_dir);
+       if (error)
+               return error;
+
+       /* We have got enough memory and from now on we cannot recover */
+       restore_image();
+       return 0;
+}
index 8a2b50a0aaad25ded242877a5d0548d51f5e6543..53662e05b393e2c294734c71577705a5beb550c0 100644 (file)
@@ -28,8 +28,9 @@ ENTRY(swsusp_arch_suspend)
        call swsusp_save
        ret
 
-ENTRY(swsusp_arch_resume)
-       movl    $swsusp_pg_dir-__PAGE_OFFSET, %ecx
+ENTRY(restore_image)
+       movl    resume_pg_dir, %ecx
+       subl    $__PAGE_OFFSET, %ecx
        movl    %ecx, %cr3
 
        movl    restore_pblist, %edx
@@ -51,6 +52,10 @@ copy_loop:
        .p2align 4,,7
 
 done:
+       /* go back to the original page tables */
+       movl    $swapper_pg_dir, %ecx
+       subl    $__PAGE_OFFSET, %ecx
+       movl    %ecx, %cr3
        /* Flush TLB, including "global" things (vmalloc) */
        movl    mmu_cr4_features, %eax
        movl    %eax, %edx
index 683b12c6f76cafd6930787bb8663c5face2bb5a2..fcacfe291b9b7450b5537ec8cbb0aab258e92f5e 100644 (file)
@@ -34,6 +34,14 @@ config RWSEM_XCHGADD_ALGORITHM
        bool
        default y
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 config GENERIC_FIND_NEXT_BIT
        bool
        default y
@@ -434,6 +442,29 @@ config IA64_ESI
 
 source "drivers/sn/Kconfig"
 
+config KEXEC
+       bool "kexec system call (EXPERIMENTAL)"
+       depends on EXPERIMENTAL && !IA64_HP_SIM && (!SMP || HOTPLUG_CPU)
+       help
+         kexec is a system call that implements the ability to shutdown your
+         current kernel, and to start another kernel.  It is like a reboot
+         but it is indepedent of the system firmware.   And like a reboot
+         you can start any kernel with it, not just Linux.
+
+         The name comes from the similiarity to the exec system call.
+
+         It is an ongoing process to be certain the hardware in a machine
+         is properly shutdown, so do not be surprised if this code does not
+         initially work for you.  It may help to enable device hotplugging
+         support.  As of this writing the exact hardware interface is
+         strongly in flux, so no good recommendation can be made.
+
+config CRASH_DUMP
+         bool "kernel crash dumps (EXPERIMENTAL)"
+         depends on EXPERIMENTAL && IA64_MCA_RECOVERY && !IA64_HP_SIM && (!SMP || HOTPLUG_CPU)
+         help
+           Generate crash dump after being started by kexec.
+
 source "drivers/firmware/Kconfig"
 
 source "fs/Kconfig.binfmt"
index 14691cda05c38da33ad2e8b124ea6eada5223790..ce49fe3a3b5654f88256d24b8fe6fc2410ccfc0b 100644 (file)
@@ -1672,15 +1672,13 @@ ioc_sac_init(struct ioc *ioc)
         * SAC (single address cycle) addressable, so allocate a
         * pseudo-device to enforce that.
         */
-       sac = kmalloc(sizeof(*sac), GFP_KERNEL);
+       sac = kzalloc(sizeof(*sac), GFP_KERNEL);
        if (!sac)
                panic(PFX "Couldn't allocate struct pci_dev");
-       memset(sac, 0, sizeof(*sac));
 
-       controller = kmalloc(sizeof(*controller), GFP_KERNEL);
+       controller = kzalloc(sizeof(*controller), GFP_KERNEL);
        if (!controller)
                panic(PFX "Couldn't allocate struct pci_controller");
-       memset(controller, 0, sizeof(*controller));
 
        controller->iommu = ioc;
        sac->sysdata = controller;
@@ -1737,12 +1735,10 @@ ioc_init(u64 hpa, void *handle)
        struct ioc *ioc;
        struct ioc_iommu *info;
 
-       ioc = kmalloc(sizeof(*ioc), GFP_KERNEL);
+       ioc = kzalloc(sizeof(*ioc), GFP_KERNEL);
        if (!ioc)
                return NULL;
 
-       memset(ioc, 0, sizeof(*ioc));
-
        ioc->next = ioc_list;
        ioc_list = ioc;
 
index b62f0c4d2c7cb6909b03f8d9d3143bd7bec32a32..1f16ebb9a800f27faf1e82fee40c31c8b57aba29 100644 (file)
@@ -684,12 +684,11 @@ static int get_async_struct(int line, struct async_struct **ret_info)
                *ret_info = sstate->info;
                return 0;
        }
-       info = kmalloc(sizeof(struct async_struct), GFP_KERNEL);
+       info = kzalloc(sizeof(struct async_struct), GFP_KERNEL);
        if (!info) {
                sstate->count--;
                return -ENOMEM;
        }
-       memset(info, 0, sizeof(struct async_struct));
        init_waitqueue_head(&info->open_wait);
        init_waitqueue_head(&info->close_wait);
        init_waitqueue_head(&info->delta_msr_wait);
index daa6b91bc921907435c47151303cc8ef81d6ff59..578737ec7629374253ea7b53029b8a3fe7d6848c 100644 (file)
@@ -91,7 +91,7 @@ ia64_elf32_init (struct pt_regs *regs)
         * it with privilege level 3 because the IVE uses non-privileged accesses to these
         * tables.  IA-32 segmentation is used to protect against IA-32 accesses to them.
         */
-       vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+       vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
        if (vma) {
                memset(vma, 0, sizeof(*vma));
                vma->vm_mm = current->mm;
@@ -117,7 +117,7 @@ ia64_elf32_init (struct pt_regs *regs)
         * code is locked in specific gate page, which is pointed by pretcode
         * when setup_frame_ia32
         */
-       vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+       vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
        if (vma) {
                memset(vma, 0, sizeof(*vma));
                vma->vm_mm = current->mm;
@@ -142,7 +142,7 @@ ia64_elf32_init (struct pt_regs *regs)
         * Install LDT as anonymous memory.  This gives us all-zero segment descriptors
         * until a task modifies them via modify_ldt().
         */
-       vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+       vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
        if (vma) {
                memset(vma, 0, sizeof(*vma));
                vma->vm_mm = current->mm;
@@ -214,7 +214,7 @@ ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack)
                bprm->loader += stack_base;
        bprm->exec += stack_base;
 
-       mpnt = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+       mpnt = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
        if (!mpnt)
                return -ENOMEM;
 
index c187743965a02029df7090843ae30e2059afe4d6..6af400a12ca1335ca324a0e6c388ad7ec50c8819 100644 (file)
@@ -249,7 +249,7 @@ ia32_init (void)
 
 #if PAGE_SHIFT > IA32_PAGE_SHIFT
        {
-               extern kmem_cache_t *partial_page_cachep;
+               extern struct kmem_cache *partial_page_cachep;
 
                partial_page_cachep = kmem_cache_create("partial_page_cache",
                                                        sizeof(struct partial_page), 0, 0,
index 703a67c934f84c6619bfa7693c247eb9fca6e143..cfa0bc0026b5dd42b283242dfb13effc0e71ca7f 100644 (file)
@@ -330,8 +330,6 @@ struct old_linux32_dirent {
 void ia64_elf32_init(struct pt_regs *regs);
 #define ELF_PLAT_INIT(_r, load_addr)   ia64_elf32_init(_r)
 
-#define elf_addr_t     u32
-
 /* This macro yields a bitmask that programs can use to figure out
    what instruction set this CPU supports.  */
 #define ELF_HWCAP      0
index 9d6a3f210148f3e1b9a775b8615a88841803e479..957681c39ad9957a287929c093aa060908b7c9c4 100644 (file)
@@ -235,7 +235,7 @@ mmap_subpage (struct file *file, unsigned long start, unsigned long end, int pro
 
        if (!(flags & MAP_ANONYMOUS)) {
                /* read the file contents */
-               inode = file->f_dentry->d_inode;
+               inode = file->f_path.dentry->d_inode;
                if (!inode->i_fop || !file->f_op->read
                    || ((*file->f_op->read)(file, (char __user *) start, end - start, &off) < 0))
                {
@@ -254,7 +254,7 @@ mmap_subpage (struct file *file, unsigned long start, unsigned long end, int pro
 }
 
 /* SLAB cache for partial_page structures */
-kmem_cache_t *partial_page_cachep;
+struct kmem_cache *partial_page_cachep;
 
 /*
  * init partial_page_list.
@@ -837,7 +837,7 @@ emulate_mmap (struct file *file, unsigned long start, unsigned long len, int pro
 
        if (!is_congruent) {
                /* read the file contents */
-               inode = file->f_dentry->d_inode;
+               inode = file->f_path.dentry->d_inode;
                if (!inode->i_fop || !file->f_op->read
                    || ((*file->f_op->read)(file, (char __user *) pstart, pend - pstart, &poff)
                        < 0))
index cfa099b04cda9da905309449534663de3895dc60..8ae384eb5357c85f4f4dda37b8d0158e92a7b096 100644 (file)
@@ -28,6 +28,7 @@ obj-$(CONFIG_IA64_CYCLONE)    += cyclone.o
 obj-$(CONFIG_CPU_FREQ)         += cpufreq/
 obj-$(CONFIG_IA64_MCA_RECOVERY)        += mca_recovery.o
 obj-$(CONFIG_KPROBES)          += kprobes.o jprobes.o
+obj-$(CONFIG_KEXEC)            += machine_kexec.o relocate_kernel.o crash.o
 obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR)  += uncached.o
 obj-$(CONFIG_AUDIT)            += audit.o
 obj-$(CONFIG_PCI_MSI)          += msi_ia64.o
index 86faf221a070e59f48d1a11cf308d5ca2899f750..088f130197ae5240f63db2dc02bbc4b7fa213025 100644 (file)
@@ -68,7 +68,8 @@ processor_get_pstate (
 
        dprintk("processor_get_pstate\n");
 
-       retval = ia64_pal_get_pstate(&pstate_index);
+       retval = ia64_pal_get_pstate(&pstate_index,
+                                    PAL_GET_PSTATE_TYPE_INSTANT);
        *value = (u32) pstate_index;
 
        if (retval)
@@ -91,7 +92,7 @@ extract_clock (
        dprintk("extract_clock\n");
 
        for (i = 0; i < data->acpi_data.state_count; i++) {
-               if (value >= data->acpi_data.states[i].control)
+               if (value == data->acpi_data.states[i].status)
                        return data->acpi_data.states[i].core_frequency;
        }
        return data->acpi_data.states[i-1].core_frequency;
@@ -117,11 +118,7 @@ processor_get_freq (
                goto migrate_end;
        }
 
-       /*
-        * processor_get_pstate gets the average frequency since the
-        * last get. So, do two PAL_get_freq()...
-        */
-       ret = processor_get_pstate(&value);
+       /* processor_get_pstate gets the instantaneous frequency */
        ret = processor_get_pstate(&value);
 
        if (ret) {
diff --git a/arch/ia64/kernel/crash.c b/arch/ia64/kernel/crash.c
new file mode 100644 (file)
index 0000000..0aabedf
--- /dev/null
@@ -0,0 +1,245 @@
+/*
+ * arch/ia64/kernel/crash.c
+ *
+ * Architecture specific (ia64) functions for kexec based crash dumps.
+ *
+ * Created by: Khalid Aziz <khalid.aziz@hp.com>
+ * Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
+ * Copyright (C) 2005 Intel Corp       Zou Nan hai <nanhai.zou@intel.com>
+ *
+ */
+#include <linux/smp.h>
+#include <linux/delay.h>
+#include <linux/crash_dump.h>
+#include <linux/bootmem.h>
+#include <linux/kexec.h>
+#include <linux/elfcore.h>
+#include <linux/sysctl.h>
+#include <linux/init.h>
+
+#include <asm/kdebug.h>
+#include <asm/mca.h>
+#include <asm/uaccess.h>
+
+int kdump_status[NR_CPUS];
+atomic_t kdump_cpu_freezed;
+atomic_t kdump_in_progress;
+int kdump_on_init = 1;
+ssize_t
+copy_oldmem_page(unsigned long pfn, char *buf,
+               size_t csize, unsigned long offset, int userbuf)
+{
+       void  *vaddr;
+
+       if (!csize)
+               return 0;
+       vaddr = __va(pfn<<PAGE_SHIFT);
+       if (userbuf) {
+               if (copy_to_user(buf, (vaddr + offset), csize)) {
+                       return -EFAULT;
+               }
+       } else
+               memcpy(buf, (vaddr + offset), csize);
+       return csize;
+}
+
+static inline Elf64_Word
+*append_elf_note(Elf64_Word *buf, char *name, unsigned type, void *data,
+               size_t data_len)
+{
+       struct elf_note *note = (struct elf_note *)buf;
+       note->n_namesz = strlen(name) + 1;
+       note->n_descsz = data_len;
+       note->n_type   = type;
+       buf += (sizeof(*note) + 3)/4;
+       memcpy(buf, name, note->n_namesz);
+       buf += (note->n_namesz + 3)/4;
+       memcpy(buf, data, data_len);
+       buf += (data_len + 3)/4;
+       return buf;
+}
+
+static void
+final_note(void *buf)
+{
+       memset(buf, 0, sizeof(struct elf_note));
+}
+
+extern void ia64_dump_cpu_regs(void *);
+
+static DEFINE_PER_CPU(struct elf_prstatus, elf_prstatus);
+
+void
+crash_save_this_cpu()
+{
+       void *buf;
+       unsigned long cfm, sof, sol;
+
+       int cpu = smp_processor_id();
+       struct elf_prstatus *prstatus = &per_cpu(elf_prstatus, cpu);
+
+       elf_greg_t *dst = (elf_greg_t *)&(prstatus->pr_reg);
+       memset(prstatus, 0, sizeof(*prstatus));
+       prstatus->pr_pid = current->pid;
+
+       ia64_dump_cpu_regs(dst);
+       cfm = dst[43];
+       sol = (cfm >> 7) & 0x7f;
+       sof = cfm & 0x7f;
+       dst[46] = (unsigned long)ia64_rse_skip_regs((unsigned long *)dst[46],
+                       sof - sol);
+
+       buf = (u64 *) per_cpu_ptr(crash_notes, cpu);
+       if (!buf)
+               return;
+       buf = append_elf_note(buf, "CORE", NT_PRSTATUS, prstatus,
+                       sizeof(*prstatus));
+       final_note(buf);
+}
+
+static int
+kdump_wait_cpu_freeze(void)
+{
+       int cpu_num = num_online_cpus() - 1;
+       int timeout = 1000;
+       while(timeout-- > 0) {
+               if (atomic_read(&kdump_cpu_freezed) == cpu_num)
+                       return 0;
+               udelay(1000);
+       }
+       return 1;
+}
+
+void
+machine_crash_shutdown(struct pt_regs *pt)
+{
+       /* This function is only called after the system
+        * has paniced or is otherwise in a critical state.
+        * The minimum amount of code to allow a kexec'd kernel
+        * to run successfully needs to happen here.
+        *
+        * In practice this means shooting down the other cpus in
+        * an SMP system.
+        */
+       kexec_disable_iosapic();
+#ifdef CONFIG_SMP
+       kdump_smp_send_stop();
+       if (kdump_wait_cpu_freeze() && kdump_on_init)   {
+               //not all cpu response to IPI, send INIT to freeze them
+               kdump_smp_send_init();
+       }
+#endif
+}
+
+static void
+machine_kdump_on_init(void)
+{
+       local_irq_disable();
+       kexec_disable_iosapic();
+       machine_kexec(ia64_kimage);
+}
+
+void
+kdump_cpu_freeze(struct unw_frame_info *info, void *arg)
+{
+       int cpuid;
+       local_irq_disable();
+       cpuid = smp_processor_id();
+       crash_save_this_cpu();
+       current->thread.ksp = (__u64)info->sw - 16;
+       atomic_inc(&kdump_cpu_freezed);
+       kdump_status[cpuid] = 1;
+       mb();
+       if (cpuid == 0) {
+               for (;;)
+                       cpu_relax();
+       } else
+               ia64_jump_to_sal(&sal_boot_rendez_state[cpuid]);
+}
+
+static int
+kdump_init_notifier(struct notifier_block *self, unsigned long val, void *data)
+{
+       struct ia64_mca_notify_die *nd;
+       struct die_args *args = data;
+
+       if (!kdump_on_init)
+               return NOTIFY_DONE;
+
+       if (val != DIE_INIT_MONARCH_ENTER &&
+           val != DIE_INIT_SLAVE_ENTER &&
+           val != DIE_MCA_RENDZVOUS_LEAVE &&
+           val != DIE_MCA_MONARCH_LEAVE)
+               return NOTIFY_DONE;
+
+       nd = (struct ia64_mca_notify_die *)args->err;
+       /* Reason code 1 means machine check rendezous*/
+       if ((val == DIE_INIT_MONARCH_ENTER || DIE_INIT_SLAVE_ENTER) &&
+                nd->sos->rv_rc == 1)
+               return NOTIFY_DONE;
+
+       switch (val) {
+               case DIE_INIT_MONARCH_ENTER:
+                       machine_kdump_on_init();
+                       break;
+               case DIE_INIT_SLAVE_ENTER:
+                       unw_init_running(kdump_cpu_freeze, NULL);
+                       break;
+               case DIE_MCA_RENDZVOUS_LEAVE:
+                       if (atomic_read(&kdump_in_progress))
+                               unw_init_running(kdump_cpu_freeze, NULL);
+                       break;
+               case DIE_MCA_MONARCH_LEAVE:
+                    /* die_register->signr indicate if MCA is recoverable */
+                       if (!args->signr)
+                               machine_kdump_on_init();
+                       break;
+       }
+       return NOTIFY_DONE;
+}
+
+#ifdef CONFIG_SYSCTL
+static ctl_table kdump_on_init_table[] = {
+       {
+               .ctl_name = CTL_UNNUMBERED,
+               .procname = "kdump_on_init",
+               .data = &kdump_on_init,
+               .maxlen = sizeof(int),
+               .mode = 0644,
+               .proc_handler = &proc_dointvec,
+       },
+       { .ctl_name = 0 }
+};
+
+static ctl_table sys_table[] = {
+       {
+         .ctl_name = CTL_KERN,
+         .procname = "kernel",
+         .mode = 0555,
+         .child = kdump_on_init_table,
+       },
+       { .ctl_name = 0 }
+};
+#endif
+
+static int
+machine_crash_setup(void)
+{
+       char *from = strstr(saved_command_line, "elfcorehdr=");
+       static struct notifier_block kdump_init_notifier_nb = {
+               .notifier_call = kdump_init_notifier,
+       };
+       int ret;
+       if (from)
+               elfcorehdr_addr = memparse(from+11, &from);
+       saved_max_pfn = (unsigned long)-1;
+       if((ret = register_die_notifier(&kdump_init_notifier_nb)) != 0)
+               return ret;
+#ifdef CONFIG_SYSCTL
+       register_sysctl_table(sys_table, 0);
+#endif
+       return 0;
+}
+
+__initcall(machine_crash_setup);
+
index bb8770a177b5f3c6eac55a11e83ac9cbc9d389e9..0b25a7d4e1e4006f3de7f52edff67c56e5b0f4a0 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/types.h>
 #include <linux/time.h>
 #include <linux/efi.h>
+#include <linux/kexec.h>
 
 #include <asm/io.h>
 #include <asm/kregs.h>
@@ -41,7 +42,7 @@ extern efi_status_t efi_call_phys (void *, ...);
 struct efi efi;
 EXPORT_SYMBOL(efi);
 static efi_runtime_services_t *runtime;
-static unsigned long mem_limit = ~0UL, max_addr = ~0UL;
+static unsigned long mem_limit = ~0UL, max_addr = ~0UL, min_addr = 0UL;
 
 #define efi_call_virt(f, args...)      (*(f))(args)
 
@@ -224,7 +225,7 @@ efi_gettimeofday (struct timespec *ts)
 }
 
 static int
-is_available_memory (efi_memory_desc_t *md)
+is_memory_available (efi_memory_desc_t *md)
 {
        if (!(md->attribute & EFI_MEMORY_WB))
                return 0;
@@ -421,6 +422,8 @@ efi_init (void)
                        mem_limit = memparse(cp + 4, &cp);
                } else if (memcmp(cp, "max_addr=", 9) == 0) {
                        max_addr = GRANULEROUNDDOWN(memparse(cp + 9, &cp));
+               } else if (memcmp(cp, "min_addr=", 9) == 0) {
+                       min_addr = GRANULEROUNDDOWN(memparse(cp + 9, &cp));
                } else {
                        while (*cp != ' ' && *cp)
                                ++cp;
@@ -428,6 +431,8 @@ efi_init (void)
                                ++cp;
                }
        }
+       if (min_addr != 0UL)
+               printk(KERN_INFO "Ignoring memory below %luMB\n", min_addr >> 20);
        if (max_addr != ~0UL)
                printk(KERN_INFO "Ignoring memory above %luMB\n", max_addr >> 20);
 
@@ -887,14 +892,15 @@ find_memmap_space (void)
                        }
                        contig_high = GRANULEROUNDDOWN(contig_high);
                }
-               if (!is_available_memory(md) || md->type == EFI_LOADER_DATA)
+               if (!is_memory_available(md) || md->type == EFI_LOADER_DATA)
                        continue;
 
                /* Round ends inward to granule boundaries */
                as = max(contig_low, md->phys_addr);
                ae = min(contig_high, efi_md_end(md));
 
-               /* keep within max_addr= command line arg */
+               /* keep within max_addr= and min_addr= command line arg */
+               as = max(as, min_addr);
                ae = min(ae, max_addr);
                if (ae <= as)
                        continue;
@@ -962,7 +968,7 @@ efi_memmap_init(unsigned long *s, unsigned long *e)
                        }
                        contig_high = GRANULEROUNDDOWN(contig_high);
                }
-               if (!is_available_memory(md))
+               if (!is_memory_available(md))
                        continue;
 
                /*
@@ -1004,7 +1010,8 @@ efi_memmap_init(unsigned long *s, unsigned long *e)
                } else
                        ae = efi_md_end(md);
 
-               /* keep within max_addr= command line arg */
+               /* keep within max_addr= and min_addr= command line arg */
+               as = max(as, min_addr);
                ae = min(ae, max_addr);
                if (ae <= as)
                        continue;
@@ -1116,6 +1123,58 @@ efi_initialize_iomem_resources(struct resource *code_resource,
                         */
                        insert_resource(res, code_resource);
                        insert_resource(res, data_resource);
+#ifdef CONFIG_KEXEC
+                        insert_resource(res, &efi_memmap_res);
+                        insert_resource(res, &boot_param_res);
+                       if (crashk_res.end > crashk_res.start)
+                               insert_resource(res, &crashk_res);
+#endif
                }
        }
 }
+
+#ifdef CONFIG_KEXEC
+/* find a block of memory aligned to 64M exclude reserved regions
+   rsvd_regions are sorted
+ */
+unsigned long
+kdump_find_rsvd_region (unsigned long size,
+               struct rsvd_region *r, int n)
+{
+  int i;
+  u64 start, end;
+  u64 alignment = 1UL << _PAGE_SIZE_64M;
+  void *efi_map_start, *efi_map_end, *p;
+  efi_memory_desc_t *md;
+  u64 efi_desc_size;
+
+  efi_map_start = __va(ia64_boot_param->efi_memmap);
+  efi_map_end   = efi_map_start + ia64_boot_param->efi_memmap_size;
+  efi_desc_size = ia64_boot_param->efi_memdesc_size;
+
+  for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
+         md = p;
+         if (!efi_wb(md))
+                 continue;
+         start = ALIGN(md->phys_addr, alignment);
+         end = efi_md_end(md);
+         for (i = 0; i < n; i++) {
+               if (__pa(r[i].start) >= start && __pa(r[i].end) < end) {
+                       if (__pa(r[i].start) > start + size)
+                               return start;
+                       start = ALIGN(__pa(r[i].end), alignment);
+                       if (i < n-1 && __pa(r[i+1].start) < start + size)
+                               continue;
+                       else
+                               break;
+               }
+         }
+         if (end > start + size)
+               return start;
+  }
+
+  printk(KERN_WARNING "Cannot reserve 0x%lx byte of memory for crashdump\n",
+       size);
+  return ~0UL;
+}
+#endif
index 3390b7c5a63fab53035d6fa2986798347237f047..15234ed3a3419f28dccd01209deb71767e45681f 100644 (file)
@@ -1575,7 +1575,7 @@ sys_call_table:
        data8 sys_mq_timedreceive               // 1265
        data8 sys_mq_notify
        data8 sys_mq_getsetattr
-       data8 sys_ni_syscall                    // reserved for kexec_load
+       data8 sys_kexec_load
        data8 sys_ni_syscall                    // reserved for vserver
        data8 sys_waitid                        // 1270
        data8 sys_add_key
index 879c1817bd1c8589c1ff7c85a659e777b67abc50..bd17190bebb637ece33a8225381a11f49d31b0eb 100644 (file)
@@ -14,6 +14,7 @@ EXPORT_SYMBOL(strlen);
 
 #include <asm/checksum.h>
 EXPORT_SYMBOL(ip_fast_csum);           /* hand-coded assembly */
+EXPORT_SYMBOL(csum_ipv6_magic);
 
 #include <asm/semaphore.h>
 EXPORT_SYMBOL(__down);
index 60d64950e3c202f5ed6ae3c666e24195ff6700d5..0fc5fb7865cfc40fd1664faf3a37abee6e4ee99a 100644 (file)
@@ -288,6 +288,27 @@ nop (unsigned int irq)
        /* do nothing... */
 }
 
+
+#ifdef CONFIG_KEXEC
+void
+kexec_disable_iosapic(void)
+{
+       struct iosapic_intr_info *info;
+       struct iosapic_rte_info *rte;
+       u8 vec = 0;
+       for (info = iosapic_intr_info; info <
+                       iosapic_intr_info + IA64_NUM_VECTORS; ++info, ++vec) {
+               list_for_each_entry(rte, &info->rtes,
+                               rte_list) {
+                       iosapic_write(rte->addr,
+                                       IOSAPIC_RTE_LOW(rte->rte_index),
+                                       IOSAPIC_MASK|vec);
+                       iosapic_eoi(rte->addr, vec);
+               }
+       }
+}
+#endif
+
 static void
 mask_irq (unsigned int irq)
 {
index 51217d63285ea35122d9373647e2dd40c5cd0346..76e778951e20820208b7dea7ecc88c94e375d311 100644 (file)
@@ -481,7 +481,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
 void __kprobes arch_remove_kprobe(struct kprobe *p)
 {
        mutex_lock(&kprobe_mutex);
-       free_insn_slot(p->ainsn.insn);
+       free_insn_slot(p->ainsn.insn, 0);
        mutex_unlock(&kprobe_mutex);
 }
 /*
@@ -851,7 +851,7 @@ static void ia64_get_bsp_cfm(struct unw_frame_info *info, void *arg)
                        return;
                }
        } while (unw_unwind(info) >= 0);
-       lp->bsp = 0;
+       lp->bsp = NULL;
        lp->cfm = 0;
        return;
 }
diff --git a/arch/ia64/kernel/machine_kexec.c b/arch/ia64/kernel/machine_kexec.c
new file mode 100644 (file)
index 0000000..468233f
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * arch/ia64/kernel/machine_kexec.c
+ *
+ * Handle transition of Linux booting another kernel
+ * Copyright (C) 2005 Hewlett-Packard Development Comapny, L.P.
+ * Copyright (C) 2005 Khalid Aziz <khalid.aziz@hp.com>
+ * Copyright (C) 2006 Intel Corp, Zou Nan hai <nanhai.zou@intel.com>
+ *
+ * This source code is licensed under the GNU General Public License,
+ * Version 2.  See the file COPYING for more details.
+ */
+
+#include <linux/mm.h>
+#include <linux/kexec.h>
+#include <linux/cpu.h>
+#include <linux/irq.h>
+#include <asm/mmu_context.h>
+#include <asm/setup.h>
+#include <asm/delay.h>
+#include <asm/meminit.h>
+
+typedef void (*relocate_new_kernel_t)(unsigned long, unsigned long,
+               struct ia64_boot_param *, unsigned long);
+
+struct kimage *ia64_kimage;
+
+struct resource efi_memmap_res = {
+        .name  = "EFI Memory Map",
+        .start = 0,
+        .end   = 0,
+        .flags = IORESOURCE_BUSY | IORESOURCE_MEM
+};
+
+struct resource boot_param_res = {
+        .name  = "Boot parameter",
+        .start = 0,
+        .end   = 0,
+        .flags = IORESOURCE_BUSY | IORESOURCE_MEM
+};
+
+
+/*
+ * Do what every setup is needed on image and the
+ * reboot code buffer to allow us to avoid allocations
+ * later.
+ */
+int machine_kexec_prepare(struct kimage *image)
+{
+       void *control_code_buffer;
+       const unsigned long *func;
+
+       func = (unsigned long *)&relocate_new_kernel;
+       /* Pre-load control code buffer to minimize work in kexec path */
+       control_code_buffer = page_address(image->control_code_page);
+       memcpy((void *)control_code_buffer, (const void *)func[0],
+                       relocate_new_kernel_size);
+       flush_icache_range((unsigned long)control_code_buffer,
+                       (unsigned long)control_code_buffer + relocate_new_kernel_size);
+       ia64_kimage = image;
+
+       return 0;
+}
+
+void machine_kexec_cleanup(struct kimage *image)
+{
+}
+
+void machine_shutdown(void)
+{
+       int cpu;
+
+       for_each_online_cpu(cpu) {
+               if (cpu != smp_processor_id())
+                       cpu_down(cpu);
+       }
+       kexec_disable_iosapic();
+}
+
+/*
+ * Do not allocate memory (or fail in any way) in machine_kexec().
+ * We are past the point of no return, committed to rebooting now.
+ */
+extern void *efi_get_pal_addr(void);
+static void ia64_machine_kexec(struct unw_frame_info *info, void *arg)
+{
+       struct kimage *image = arg;
+       relocate_new_kernel_t rnk;
+       void *pal_addr = efi_get_pal_addr();
+       unsigned long code_addr = (unsigned long)page_address(image->control_code_page);
+       unsigned long vector;
+       int ii;
+
+       if (image->type == KEXEC_TYPE_CRASH) {
+               crash_save_this_cpu();
+               current->thread.ksp = (__u64)info->sw - 16;
+       }
+
+       /* Interrupts aren't acceptable while we reboot */
+       local_irq_disable();
+
+       /* Mask CMC and Performance Monitor interrupts */
+       ia64_setreg(_IA64_REG_CR_PMV, 1 << 16);
+       ia64_setreg(_IA64_REG_CR_CMCV, 1 << 16);
+
+       /* Mask ITV and Local Redirect Registers */
+       ia64_set_itv(1 << 16);
+       ia64_set_lrr0(1 << 16);
+       ia64_set_lrr1(1 << 16);
+
+       /* terminate possible nested in-service interrupts */
+       for (ii = 0; ii < 16; ii++)
+               ia64_eoi();
+
+       /* unmask TPR and clear any pending interrupts */
+       ia64_setreg(_IA64_REG_CR_TPR, 0);
+       ia64_srlz_d();
+       vector = ia64_get_ivr();
+       while (vector != IA64_SPURIOUS_INT_VECTOR) {
+               ia64_eoi();
+               vector = ia64_get_ivr();
+       }
+       platform_kernel_launch_event();
+       rnk = (relocate_new_kernel_t)&code_addr;
+       (*rnk)(image->head, image->start, ia64_boot_param,
+                    GRANULEROUNDDOWN((unsigned long) pal_addr));
+       BUG();
+}
+
+void machine_kexec(struct kimage *image)
+{
+       unw_init_running(ia64_machine_kexec, image);
+       for(;;);
+}
index 6bedd97570ca97dceddbd7ab46270160e5a1f771..87c1c4f428727dde681e4b2b765e21ae5cecbb95 100644 (file)
@@ -82,6 +82,7 @@
 #include <asm/system.h>
 #include <asm/sal.h>
 #include <asm/mca.h>
+#include <asm/kexec.h>
 
 #include <asm/irq.h>
 #include <asm/hw_irq.h>
@@ -1238,6 +1239,10 @@ ia64_mca_handler(struct pt_regs *regs, struct switch_stack *sw,
        } else {
                /* Dump buffered message to console */
                ia64_mlogbuf_finish(1);
+#ifdef CONFIG_CRASH_DUMP
+               atomic_set(&kdump_in_progress, 1);
+               monarch_cpu = -1;
+#endif
        }
        if (notify_die(DIE_MCA_MONARCH_LEAVE, "MCA", regs, (long)&nd, 0, recover)
                        == NOTIFY_STOP)
index 0b546e2b36ac61c113b73ada6e98775a30294e25..a71df9ae03976ccbba7eb5154a639e941938ca44 100644 (file)
@@ -16,6 +16,7 @@
  * 02/05/2001   S.Eranian      fixed module support
  * 10/23/2001  S.Eranian       updated pal_perf_mon_info bug fixes
  * 03/24/2004  Ashok Raj       updated to work with CPU Hotplug
+ * 10/26/2006   Russ Anderson  updated processor features to rev 2.2 spec
  */
 #include <linux/types.h>
 #include <linux/errno.h>
@@ -314,13 +315,20 @@ vm_info(char *page)
                     "Protection Key Registers(PKR)  : %d\n"
                     "Implemented bits in PKR.key    : %d\n"
                     "Hash Tag ID                    : 0x%x\n"
-                    "Size of RR.rid                 : %d\n",
+                    "Size of RR.rid                 : %d\n"
+                    "Max Purges                     : ",
                     vm_info_1.pal_vm_info_1_s.phys_add_size,
                     vm_info_2.pal_vm_info_2_s.impl_va_msb+1,
                     vm_info_1.pal_vm_info_1_s.max_pkr+1,
                     vm_info_1.pal_vm_info_1_s.key_size,
                     vm_info_1.pal_vm_info_1_s.hash_tag_id,
                     vm_info_2.pal_vm_info_2_s.rid_size);
+               if (vm_info_2.pal_vm_info_2_s.max_purges == PAL_MAX_PURGES)
+                       p += sprintf(p, "unlimited\n");
+               else
+                       p += sprintf(p, "%d\n",
+                               vm_info_2.pal_vm_info_2_s.max_purges ?
+                               vm_info_2.pal_vm_info_2_s.max_purges : 1);
        }
 
        if (ia64_pal_mem_attrib(&attrib) == 0) {
@@ -467,7 +475,11 @@ static const char *proc_features[]={
        NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL,
        NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
        NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,
-       NULL,NULL,NULL,NULL,NULL,
+       "Unimplemented instruction address fault",
+       "INIT, PMI, and LINT pins",
+       "Simple unimplemented instr addresses",
+       "Variable P-state performance",
+       "Virtual machine features implemented",
        "XIP,XPSR,XFS implemented",
        "XR1-XR3 implemented",
        "Disable dynamic predicate prediction",
@@ -475,7 +487,11 @@ static const char *proc_features[]={
        "Disable dynamic data cache prefetch",
        "Disable dynamic inst cache prefetch",
        "Disable dynamic branch prediction",
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+       NULL, NULL, NULL, NULL,
+       "Disable P-states",
+       "Enable MCA on Data Poisoning",
+       "Enable vmsw instruction",
+       "Enable extern environmental notification",
        "Disable BINIT on processor time-out",
        "Disable dynamic power management (DPM)",
        "Disable coherency",
@@ -952,7 +968,6 @@ remove_palinfo_proc_entries(unsigned int hcpu)
        }
 }
 
-#ifdef CONFIG_HOTPLUG_CPU
 static int palinfo_cpu_callback(struct notifier_block *nfb,
                                        unsigned long action, void *hcpu)
 {
@@ -974,7 +989,6 @@ static struct notifier_block palinfo_cpu_notifier =
        .notifier_call = palinfo_cpu_callback,
        .priority = 0,
 };
-#endif
 
 static int __init
 palinfo_init(void)
index 3aaede0d6981783037b1eaec5d0a0b7e364d57ef..aa94f60fa8e7724ee04f83e665e9b762c97540ca 100644 (file)
@@ -853,9 +853,8 @@ pfm_context_alloc(void)
         * allocate context descriptor 
         * must be able to free with interrupts disabled
         */
-       ctx = kmalloc(sizeof(pfm_context_t), GFP_KERNEL);
+       ctx = kzalloc(sizeof(pfm_context_t), GFP_KERNEL);
        if (ctx) {
-               memset(ctx, 0, sizeof(pfm_context_t));
                DPRINT(("alloc ctx @%p\n", ctx));
        }
        return ctx;
@@ -2189,13 +2188,13 @@ pfm_alloc_fd(struct file **cfile)
        /*
         * allocate a new dcache entry
         */
-       file->f_dentry = d_alloc(pfmfs_mnt->mnt_sb->s_root, &this);
-       if (!file->f_dentry) goto out;
+       file->f_path.dentry = d_alloc(pfmfs_mnt->mnt_sb->s_root, &this);
+       if (!file->f_path.dentry) goto out;
 
-       file->f_dentry->d_op = &pfmfs_dentry_operations;
+       file->f_path.dentry->d_op = &pfmfs_dentry_operations;
 
-       d_add(file->f_dentry, inode);
-       file->f_vfsmnt = mntget(pfmfs_mnt);
+       d_add(file->f_path.dentry, inode);
+       file->f_path.mnt = mntget(pfmfs_mnt);
        file->f_mapping = inode->i_mapping;
 
        file->f_op    = &pfm_file_ops;
@@ -2302,7 +2301,7 @@ pfm_smpl_buffer_alloc(struct task_struct *task, pfm_context_t *ctx, unsigned lon
        DPRINT(("smpl_buf @%p\n", smpl_buf));
 
        /* allocate vma */
-       vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+       vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
        if (!vma) {
                DPRINT(("Cannot allocate vma\n"));
                goto error_kmem;
index cd06ac6a686ccc239233627efe86cab144b5d443..7f8da4c7ca67db4babab4d95a5d80885754f630e 100644 (file)
@@ -45,16 +45,16 @@ static pfm_reg_desc_t pfm_mont_pmc_desc[PMU_MAX_PMCS]={
 /* pmc29 */ { PFM_REG_NOTIMPL, },
 /* pmc30 */ { PFM_REG_NOTIMPL, },
 /* pmc31 */ { PFM_REG_NOTIMPL, },
-/* pmc32 */ { PFM_REG_CONFIG,  0, 0x30f01ffffffffff, 0x30f01ffffffffff, NULL, pfm_mont_pmc_check, {0,0, 0, 0}, {0,0, 0, 0}},
-/* pmc33 */ { PFM_REG_CONFIG,  0, 0x0,  0x1ffffffffff, NULL, pfm_mont_pmc_check, {0,0, 0, 0}, {0,0, 0, 0}},
-/* pmc34 */ { PFM_REG_CONFIG,  0, 0xf01ffffffffff, 0xf01ffffffffff, NULL, pfm_mont_pmc_check, {0,0, 0, 0}, {0,0, 0, 0}},
-/* pmc35 */ { PFM_REG_CONFIG,  0, 0x0,  0x1ffffffffff, NULL, pfm_mont_pmc_check, {0,0, 0, 0}, {0,0, 0, 0}},
+/* pmc32 */ { PFM_REG_CONFIG,  0, 0x30f01ffffffffffUL, 0x30f01ffffffffffUL, NULL, pfm_mont_pmc_check, {0,0, 0, 0}, {0,0, 0, 0}},
+/* pmc33 */ { PFM_REG_CONFIG,  0, 0x0,  0x1ffffffffffUL, NULL, pfm_mont_pmc_check, {0,0, 0, 0}, {0,0, 0, 0}},
+/* pmc34 */ { PFM_REG_CONFIG,  0, 0xf01ffffffffffUL, 0xf01ffffffffffUL, NULL, pfm_mont_pmc_check, {0,0, 0, 0}, {0,0, 0, 0}},
+/* pmc35 */ { PFM_REG_CONFIG,  0, 0x0,  0x1ffffffffffUL, NULL, pfm_mont_pmc_check, {0,0, 0, 0}, {0,0, 0, 0}},
 /* pmc36 */ { PFM_REG_CONFIG,  0, 0xfffffff0, 0xf, NULL, pfm_mont_pmc_check, {0,0, 0, 0}, {0,0, 0, 0}},
 /* pmc37 */ { PFM_REG_MONITOR, 4, 0x0, 0x3fff, NULL, pfm_mont_pmc_check, {RDEP_MONT_IEAR, 0, 0, 0}, {0, 0, 0, 0}},
 /* pmc38 */ { PFM_REG_CONFIG,  0, 0xdb6, 0x2492, NULL, pfm_mont_pmc_check, {0,0, 0, 0}, {0,0, 0, 0}},
 /* pmc39 */ { PFM_REG_MONITOR, 6, 0x0, 0xffcf, NULL, pfm_mont_pmc_check, {RDEP_MONT_ETB,0, 0, 0}, {0,0, 0, 0}},
 /* pmc40 */ { PFM_REG_MONITOR, 6, 0x2000000, 0xf01cf, NULL, pfm_mont_pmc_check, {RDEP_MONT_DEAR,0, 0, 0}, {0,0, 0, 0}},
-/* pmc41 */ { PFM_REG_CONFIG,  0, 0x00002078fefefefe, 0x1e00018181818, NULL, pfm_mont_pmc_check, {0,0, 0, 0}, {0,0, 0, 0}},
+/* pmc41 */ { PFM_REG_CONFIG,  0, 0x00002078fefefefeUL, 0x1e00018181818UL, NULL, pfm_mont_pmc_check, {0,0, 0, 0}, {0,0, 0, 0}},
 /* pmc42 */ { PFM_REG_MONITOR, 6, 0x0, 0x7ff4f, NULL, pfm_mont_pmc_check, {RDEP_MONT_ETB,0, 0, 0}, {0,0, 0, 0}},
            { PFM_REG_END    , 0, 0x0, -1, NULL, NULL, {0,}, {0,}}, /* end marker */
 };
@@ -185,7 +185,7 @@ pfm_mont_pmc_check(struct task_struct *task, pfm_context_t *ctx, unsigned int cn
        DPRINT(("cnum=%u val=0x%lx, using_dbreg=%d loaded=%d\n", cnum, tmpval, ctx->ctx_fl_using_dbreg, is_loaded));
 
        if (cnum == 41 && is_loaded 
-           && (tmpval & 0x1e00000000000) && (tmpval & 0x18181818UL) != 0x18181818UL && ctx->ctx_fl_using_dbreg == 0) {
+           && (tmpval & 0x1e00000000000UL) && (tmpval & 0x18181818UL) != 0x18181818UL && ctx->ctx_fl_using_dbreg == 0) {
 
                DPRINT(("pmc[%d]=0x%lx has active pmc41 settings, clearing dbr\n", cnum, tmpval));
 
diff --git a/arch/ia64/kernel/relocate_kernel.S b/arch/ia64/kernel/relocate_kernel.S
new file mode 100644 (file)
index 0000000..ae473e3
--- /dev/null
@@ -0,0 +1,334 @@
+/*
+ * arch/ia64/kernel/relocate_kernel.S
+ *
+ * Relocate kexec'able kernel and start it
+ *
+ * Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
+ * Copyright (C) 2005 Khalid Aziz  <khalid.aziz@hp.com>
+ * Copyright (C) 2005 Intel Corp,  Zou Nan hai <nanhai.zou@intel.com>
+ *
+ * This source code is licensed under the GNU General Public License,
+ * Version 2.  See the file COPYING for more details.
+ */
+#include <asm/asmmacro.h>
+#include <asm/kregs.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+#include <asm/mca_asm.h>
+
+       /* Must be relocatable PIC code callable as a C function
+        */
+GLOBAL_ENTRY(relocate_new_kernel)
+       .prologue
+       alloc r31=ar.pfs,4,0,0,0
+        .body
+.reloc_entry:
+{
+       rsm psr.i| psr.ic
+       mov r2=ip
+}
+       ;;
+{
+        flushrs                         // must be first insn in group
+        srlz.i
+}
+       ;;
+       dep r2=0,r2,61,3                //to physical address
+       ;;
+       //first switch to physical mode
+       add r3=1f-.reloc_entry, r2
+       movl r16 = IA64_PSR_AC|IA64_PSR_BN|IA64_PSR_IC
+       mov ar.rsc=0                    // put RSE in enforced lazy mode
+       ;;
+       add sp=(memory_stack_end - 16 - .reloc_entry),r2
+       add r8=(register_stack - .reloc_entry),r2
+       ;;
+       mov r18=ar.rnat
+       mov ar.bspstore=r8
+       ;;
+        mov cr.ipsr=r16
+        mov cr.iip=r3
+        mov cr.ifs=r0
+       srlz.i
+       ;;
+       mov ar.rnat=r18
+       rfi
+       ;;
+1:
+       //physical mode code begin
+       mov b6=in1
+       dep r28=0,in2,61,3      //to physical address
+
+       // purge all TC entries
+#define O(member)       IA64_CPUINFO_##member##_OFFSET
+        GET_THIS_PADDR(r2, cpu_info)    // load phys addr of cpu_info into r2
+        ;;
+        addl r17=O(PTCE_STRIDE),r2
+        addl r2=O(PTCE_BASE),r2
+        ;;
+        ld8 r18=[r2],(O(PTCE_COUNT)-O(PTCE_BASE));;            // r18=ptce_base
+        ld4 r19=[r2],4                                  // r19=ptce_count[0]
+        ld4 r21=[r17],4                                 // r21=ptce_stride[0]
+        ;;
+        ld4 r20=[r2]                                    // r20=ptce_count[1]
+        ld4 r22=[r17]                                   // r22=ptce_stride[1]
+        mov r24=r0
+        ;;
+        adds r20=-1,r20
+        ;;
+#undef O
+2:
+        cmp.ltu p6,p7=r24,r19
+(p7)    br.cond.dpnt.few 4f
+        mov ar.lc=r20
+3:
+        ptc.e r18
+        ;;
+        add r18=r22,r18
+        br.cloop.sptk.few 3b
+        ;;
+        add r18=r21,r18
+        add r24=1,r24
+        ;;
+        br.sptk.few 2b
+4:
+        srlz.i
+        ;;
+       //purge TR entry for kernel text and data
+        movl r16=KERNEL_START
+        mov r18=KERNEL_TR_PAGE_SHIFT<<2
+        ;;
+        ptr.i r16, r18
+        ptr.d r16, r18
+        ;;
+        srlz.i
+        ;;
+
+       // purge TR entry for percpu data
+        movl r16=PERCPU_ADDR
+        mov r18=PERCPU_PAGE_SHIFT<<2
+        ;;
+        ptr.d r16,r18
+        ;;
+        srlz.d
+       ;;
+
+        // purge TR entry for pal code
+        mov r16=in3
+        mov r18=IA64_GRANULE_SHIFT<<2
+        ;;
+        ptr.i r16,r18
+        ;;
+        srlz.i
+       ;;
+
+        // purge TR entry for stack
+        mov r16=IA64_KR(CURRENT_STACK)
+        ;;
+        shl r16=r16,IA64_GRANULE_SHIFT
+        movl r19=PAGE_OFFSET
+        ;;
+        add r16=r19,r16
+        mov r18=IA64_GRANULE_SHIFT<<2
+        ;;
+        ptr.d r16,r18
+        ;;
+        srlz.i
+       ;;
+
+       //copy segments
+       movl r16=PAGE_MASK
+        mov  r30=in0                    // in0 is page_list
+        br.sptk.few .dest_page
+       ;;
+.loop:
+       ld8  r30=[in0], 8;;
+.dest_page:
+       tbit.z p0, p6=r30, 0;;          // 0x1 dest page
+(p6)   and r17=r30, r16
+(p6)   br.cond.sptk.few .loop;;
+
+       tbit.z p0, p6=r30, 1;;          // 0x2 indirect page
+(p6)   and in0=r30, r16
+(p6)   br.cond.sptk.few .loop;;
+
+       tbit.z p0, p6=r30, 2;;          // 0x4 end flag
+(p6)   br.cond.sptk.few .end_loop;;
+
+       tbit.z p6, p0=r30, 3;;          // 0x8 source page
+(p6)   br.cond.sptk.few .loop
+
+       and r18=r30, r16
+
+       // simple copy page, may optimize later
+       movl r14=PAGE_SIZE/8 - 1;;
+       mov ar.lc=r14;;
+1:
+       ld8 r14=[r18], 8;;
+       st8 [r17]=r14;;
+       fc.i r17
+       add r17=8, r17
+       br.ctop.sptk.few 1b
+       br.sptk.few .loop
+       ;;
+
+.end_loop:
+       sync.i                  // for fc.i
+       ;;
+       srlz.i
+       ;;
+       srlz.d
+       ;;
+       br.call.sptk.many b0=b6;;
+
+.align  32
+memory_stack:
+       .fill           8192, 1, 0
+memory_stack_end:
+register_stack:
+       .fill           8192, 1, 0
+register_stack_end:
+relocate_new_kernel_end:
+END(relocate_new_kernel)
+
+.global relocate_new_kernel_size
+relocate_new_kernel_size:
+       data8   relocate_new_kernel_end - relocate_new_kernel
+
+GLOBAL_ENTRY(ia64_dump_cpu_regs)
+        .prologue
+        alloc loc0=ar.pfs,1,2,0,0
+        .body
+        mov     ar.rsc=0                // put RSE in enforced lazy mode
+        add     loc1=4*8, in0           // save r4 and r5 first
+        ;;
+{
+        flushrs                         // flush dirty regs to backing store
+        srlz.i
+}
+        st8 [loc1]=r4, 8
+        ;;
+        st8 [loc1]=r5, 8
+        ;;
+        add loc1=32*8, in0
+        mov r4=ar.rnat
+        ;;
+        st8 [in0]=r0, 8                        // r0
+        st8 [loc1]=r4, 8               // rnat
+        mov r5=pr
+        ;;
+        st8 [in0]=r1, 8                        // r1
+        st8 [loc1]=r5, 8               // pr
+        mov r4=b0
+        ;;
+        st8 [in0]=r2, 8                        // r2
+        st8 [loc1]=r4, 8               // b0
+        mov r5=b1;
+        ;;
+        st8 [in0]=r3, 24               // r3
+        st8 [loc1]=r5, 8               // b1
+        mov r4=b2
+        ;;
+        st8 [in0]=r6, 8                        // r6
+        st8 [loc1]=r4, 8               // b2
+       mov r5=b3
+        ;;
+        st8 [in0]=r7, 8                        // r7
+        st8 [loc1]=r5, 8               // b3
+        mov r4=b4
+        ;;
+        st8 [in0]=r8, 8                        // r8
+        st8 [loc1]=r4, 8               // b4
+        mov r5=b5
+        ;;
+        st8 [in0]=r9, 8                        // r9
+        st8 [loc1]=r5, 8               // b5
+        mov r4=b6
+        ;;
+        st8 [in0]=r10, 8               // r10
+        st8 [loc1]=r5, 8               // b6
+        mov r5=b7
+        ;;
+        st8 [in0]=r11, 8               // r11
+        st8 [loc1]=r5, 8               // b7
+        mov r4=b0
+        ;;
+        st8 [in0]=r12, 8               // r12
+        st8 [loc1]=r4, 8               // ip
+        mov r5=loc0
+       ;;
+        st8 [in0]=r13, 8               // r13
+        extr.u r5=r5, 0, 38            // ar.pfs.pfm
+       mov r4=r0                       // user mask
+        ;;
+        st8 [in0]=r14, 8               // r14
+        st8 [loc1]=r5, 8               // cfm
+        ;;
+        st8 [in0]=r15, 8               // r15
+        st8 [loc1]=r4, 8               // user mask
+       mov r5=ar.rsc
+        ;;
+        st8 [in0]=r16, 8               // r16
+        st8 [loc1]=r5, 8               // ar.rsc
+        mov r4=ar.bsp
+        ;;
+        st8 [in0]=r17, 8               // r17
+        st8 [loc1]=r4, 8               // ar.bsp
+        mov r5=ar.bspstore
+        ;;
+        st8 [in0]=r18, 8               // r18
+        st8 [loc1]=r5, 8               // ar.bspstore
+        mov r4=ar.rnat
+        ;;
+        st8 [in0]=r19, 8               // r19
+        st8 [loc1]=r4, 8               // ar.rnat
+        mov r5=ar.ccv
+        ;;
+        st8 [in0]=r20, 8               // r20
+       st8 [loc1]=r5, 8                // ar.ccv
+        mov r4=ar.unat
+        ;;
+        st8 [in0]=r21, 8               // r21
+        st8 [loc1]=r4, 8               // ar.unat
+        mov r5 = ar.fpsr
+        ;;
+        st8 [in0]=r22, 8               // r22
+        st8 [loc1]=r5, 8               // ar.fpsr
+        mov r4 = ar.unat
+        ;;
+        st8 [in0]=r23, 8               // r23
+        st8 [loc1]=r4, 8               // unat
+        mov r5 = ar.fpsr
+        ;;
+        st8 [in0]=r24, 8               // r24
+        st8 [loc1]=r5, 8               // fpsr
+        mov r4 = ar.pfs
+        ;;
+        st8 [in0]=r25, 8               // r25
+        st8 [loc1]=r4, 8               // ar.pfs
+        mov r5 = ar.lc
+        ;;
+        st8 [in0]=r26, 8               // r26
+        st8 [loc1]=r5, 8               // ar.lc
+        mov r4 = ar.ec
+        ;;
+        st8 [in0]=r27, 8               // r27
+        st8 [loc1]=r4, 8               // ar.ec
+        mov r5 = ar.csd
+        ;;
+        st8 [in0]=r28, 8               // r28
+        st8 [loc1]=r5, 8               // ar.csd
+        mov r4 = ar.ssd
+        ;;
+        st8 [in0]=r29, 8               // r29
+        st8 [loc1]=r4, 8               // ar.ssd
+        ;;
+        st8 [in0]=r30, 8               // r30
+        ;;
+       st8 [in0]=r31, 8                // r31
+        mov ar.pfs=loc0
+        ;;
+        br.ret.sptk.many rp
+END(ia64_dump_cpu_regs)
+
+
index e63b8ca5344a202d85b8cb1d25a4edb08c486894..e375a2f0f2c34f67848948bdd918e0a867ace9f8 100644 (file)
@@ -302,7 +302,7 @@ salinfo_event_open(struct inode *inode, struct file *file)
 static ssize_t
 salinfo_event_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct proc_dir_entry *entry = PDE(inode);
        struct salinfo_data *data = entry->data;
        char cmd[32];
@@ -464,7 +464,7 @@ retry:
 static ssize_t
 salinfo_log_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct proc_dir_entry *entry = PDE(inode);
        struct salinfo_data *data = entry->data;
        u8 *buf;
@@ -525,7 +525,7 @@ salinfo_log_clear(struct salinfo_data *data, int cpu)
 static ssize_t
 salinfo_log_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct proc_dir_entry *entry = PDE(inode);
        struct salinfo_data *data = entry->data;
        char cmd[32];
@@ -575,7 +575,6 @@ static struct file_operations salinfo_data_fops = {
        .write   = salinfo_log_write,
 };
 
-#ifdef CONFIG_HOTPLUG_CPU
 static int __devinit
 salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
 {
@@ -620,7 +619,6 @@ static struct notifier_block salinfo_cpu_notifier =
        .notifier_call = salinfo_cpu_callback,
        .priority = 0,
 };
-#endif /* CONFIG_HOTPLUG_CPU */
 
 static int __init
 salinfo_init(void)
index d10404a4175630c6d18ccfe5aa5e265face6ec68..14e1200376a9c432dfdf136bd11d12fb8481b70e 100644 (file)
@@ -43,6 +43,8 @@
 #include <linux/initrd.h>
 #include <linux/pm.h>
 #include <linux/cpufreq.h>
+#include <linux/kexec.h>
+#include <linux/crash_dump.h>
 
 #include <asm/ia32.h>
 #include <asm/machvec.h>
@@ -252,6 +254,41 @@ reserve_memory (void)
        efi_memmap_init(&rsvd_region[n].start, &rsvd_region[n].end);
        n++;
 
+#ifdef CONFIG_KEXEC
+       /* crashkernel=size@offset specifies the size to reserve for a crash
+        * kernel.(offset is ingored for keep compatibility with other archs)
+        * By reserving this memory we guarantee that linux never set's it
+        * up as a DMA target.Useful for holding code to do something
+        * appropriate after a kernel panic.
+        */
+       {
+               char *from = strstr(saved_command_line, "crashkernel=");
+               unsigned long base, size;
+               if (from) {
+                       size = memparse(from + 12, &from);
+                       if (size) {
+                               sort_regions(rsvd_region, n);
+                               base = kdump_find_rsvd_region(size,
+                               rsvd_region, n);
+                               if (base != ~0UL) {
+                                       rsvd_region[n].start =
+                                               (unsigned long)__va(base);
+                                       rsvd_region[n].end =
+                                               (unsigned long)__va(base + size);
+                                       n++;
+                                       crashk_res.start = base;
+                                       crashk_res.end = base + size - 1;
+                               }
+                       }
+               }
+               efi_memmap_res.start = ia64_boot_param->efi_memmap;
+                efi_memmap_res.end = efi_memmap_res.start +
+                        ia64_boot_param->efi_memmap_size;
+                boot_param_res.start = __pa(ia64_boot_param);
+                boot_param_res.end = boot_param_res.start +
+                        sizeof(*ia64_boot_param);
+       }
+#endif
        /* end of memory marker */
        rsvd_region[n].start = ~0UL;
        rsvd_region[n].end   = ~0UL;
@@ -263,6 +300,7 @@ reserve_memory (void)
        sort_regions(rsvd_region, num_rsvd_regions);
 }
 
+
 /**
  * find_initrd - get initrd parameters from the boot parameter structure
  *
index 6ab95ceaf9d4f34aa32a382a9e32cb68bb98b23b..b1b9aa4364b901205619b230155b70abaaf97fa1 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/delay.h>
 #include <linux/efi.h>
 #include <linux/bitops.h>
+#include <linux/kexec.h>
 
 #include <asm/atomic.h>
 #include <asm/current.h>
@@ -66,6 +67,7 @@ static volatile struct call_data_struct *call_data;
 
 #define IPI_CALL_FUNC          0
 #define IPI_CPU_STOP           1
+#define IPI_KDUMP_CPU_STOP     3
 
 /* This needs to be cacheline aligned because it is written to by *other* CPUs.  */
 static DEFINE_PER_CPU(u64, ipi_operation) ____cacheline_aligned;
@@ -155,7 +157,11 @@ handle_IPI (int irq, void *dev_id)
                              case IPI_CPU_STOP:
                                stop_this_cpu();
                                break;
-
+#ifdef CONFIG_CRASH_DUMP
+                             case IPI_KDUMP_CPU_STOP:
+                               unw_init_running(kdump_cpu_freeze, NULL);
+                               break;
+#endif
                              default:
                                printk(KERN_CRIT "Unknown IPI on CPU %d: %lu\n", this_cpu, which);
                                break;
@@ -213,6 +219,26 @@ send_IPI_self (int op)
        send_IPI_single(smp_processor_id(), op);
 }
 
+#ifdef CONFIG_CRASH_DUMP
+void
+kdump_smp_send_stop()
+{
+       send_IPI_allbutself(IPI_KDUMP_CPU_STOP);
+}
+
+void
+kdump_smp_send_init()
+{
+       unsigned int cpu, self_cpu;
+       self_cpu = smp_processor_id();
+       for_each_online_cpu(cpu) {
+               if (cpu != self_cpu) {
+                       if(kdump_status[cpu] == 0)
+                               platform_send_ipi(cpu, 0, IA64_IPI_DM_INIT, 0);
+               }
+       }
+}
+#endif
 /*
  * Called with preeemption disabled.
  */
index 5629b45e89c6bc50892c4a8e69b66d0f0be67d86..687500ddb4b872a59676396dd04cbed4c7a214ef 100644 (file)
@@ -31,11 +31,11 @@ int arch_register_cpu(int num)
 {
 #if defined (CONFIG_ACPI) && defined (CONFIG_HOTPLUG_CPU)
        /*
-        * If CPEI cannot be re-targetted, and this is
-        * CPEI target, then dont create the control file
+        * If CPEI can be re-targetted or if this is not
+        * CPEI target, then it is hotpluggable
         */
-       if (!can_cpei_retarget() && is_cpu_cpei_target(num))
-               sysfs_cpus[num].cpu.no_control = 1;
+       if (can_cpei_retarget() || !is_cpu_cpei_target(num))
+               sysfs_cpus[num].cpu.hotpluggable = 1;
        map_cpu_to_node(num, node_cpuid[num].nid);
 #endif
 
index 19674ca2acfcec658089d64f4ea89fbf48dcc096..1f86aeb2c9485bb70054280b103fa8280bbad3dc 100644 (file)
@@ -8,8 +8,8 @@
  *      in0: address of buffer to checksum (char *)
  *      in1: length of the buffer (int)
  *
- * Copyright (C) 2002 Intel Corp.
- * Copyright (C) 2002 Ken Chen <kenneth.w.chen@intel.com>
+ * Copyright (C) 2002, 2006 Intel Corp.
+ * Copyright (C) 2002, 2006 Ken Chen <kenneth.w.chen@intel.com>
  */
 
 #include <asm/asmmacro.h>
@@ -25,6 +25,9 @@
 
 #define in0    r32
 #define in1    r33
+#define in2    r34
+#define in3    r35
+#define in4    r36
 #define ret0   r8
 
 GLOBAL_ENTRY(ip_fast_csum)
@@ -65,8 +68,9 @@ GLOBAL_ENTRY(ip_fast_csum)
        zxt2    r20=r20
        ;;
        add     r20=ret0,r20
+       mov     r9=0xffff
        ;;
-       andcm   ret0=-1,r20
+       andcm   ret0=r9,r20
        .restore sp             // reset frame state
        br.ret.sptk.many b0
        ;;
@@ -88,3 +92,51 @@ GLOBAL_ENTRY(ip_fast_csum)
        mov     b0=r34
        br.ret.sptk.many b0
 END(ip_fast_csum)
+
+GLOBAL_ENTRY(csum_ipv6_magic)
+       ld4     r20=[in0],4
+       ld4     r21=[in1],4
+       dep     r15=in3,in2,32,16
+       ;;
+       ld4     r22=[in0],4
+       ld4     r23=[in1],4
+       mux1    r15=r15,@rev
+       ;;
+       ld4     r24=[in0],4
+       ld4     r25=[in1],4
+       shr.u   r15=r15,16
+       add     r16=r20,r21
+       add     r17=r22,r23
+       ;;
+       ld4     r26=[in0],4
+       ld4     r27=[in1],4
+       add     r18=r24,r25
+       add     r8=r16,r17
+       ;;
+       add     r19=r26,r27
+       add     r8=r8,r18
+       ;;
+       add     r8=r8,r19
+       add     r15=r15,in4
+       ;;
+       add     r8=r8,r15
+       ;;
+       shr.u   r10=r8,32       // now fold sum into short
+       zxt4    r11=r8
+       ;;
+       add     r8=r10,r11
+       ;;
+       shr.u   r10=r8,16       // yeah, keep it rolling
+       zxt2    r11=r8
+       ;;
+       add     r8=r10,r11
+       ;;
+       shr.u   r10=r8,16       // three times lucky
+       zxt2    r11=r8
+       ;;
+       add     r8=r10,r11
+       mov     r9=0xffff
+       ;;
+       andcm   r8=r9,r8
+       br.ret.sptk.many b0
+END(csum_ipv6_magic)
index f3a9585e98a8337a8cbd8b06c6916d5a8b3a8612..0c7e94edc20e9eaf9b30217246bbe5de3bafd191 100644 (file)
@@ -64,6 +64,11 @@ huge_pte_offset (struct mm_struct *mm, unsigned long addr)
        return pte;
 }
 
+int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
+{
+       return 0;
+}
+
 #define mk_pte_huge(entry) { pte_val(entry) |= _PAGE_P; }
 
 /*
index ff87a5cba399f873348858fa7775a608ab2c3fb7..56dc2024220e424d2dd6e1d5de57c4c65e17a0e0 100644 (file)
@@ -156,7 +156,7 @@ ia64_init_addr_space (void)
         * the problem.  When the process attempts to write to the register backing store
         * for the first time, it will get a SEGFAULT in this case.
         */
-       vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+       vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
        if (vma) {
                memset(vma, 0, sizeof(*vma));
                vma->vm_mm = current->mm;
@@ -175,7 +175,7 @@ ia64_init_addr_space (void)
 
        /* map NaT-page at address zero to speed up speculative dereferencing of NULL: */
        if (!(current->personality & MMAP_PAGE_ZERO)) {
-               vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+               vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
                if (vma) {
                        memset(vma, 0, sizeof(*vma));
                        vma->vm_mm = current->mm;
index eb92cef9cd0de15190d303b0d076c77c480e2944..474d179966dc02e221ee81d8083ae566e255e804 100644 (file)
@@ -125,11 +125,10 @@ alloc_pci_controller (int seg)
 {
        struct pci_controller *controller;
 
-       controller = kmalloc(sizeof(*controller), GFP_KERNEL);
+       controller = kzalloc(sizeof(*controller), GFP_KERNEL);
        if (!controller)
                return NULL;
 
-       memset(controller, 0, sizeof(*controller));
        controller->segment = seg;
        controller->node = -1;
        return controller;
index 0b49459a878a92a1047f916bd40af84b489701a9..8c5bee01eaa28cf5e4666aa617194ed927cf581c 100644 (file)
@@ -117,7 +117,10 @@ struct sn_irq_info *sn_retarget_vector(struct sn_irq_info *sn_irq_info,
                                       nasid_t nasid, int slice)
 {
        int vector;
+       int cpuid;
+#ifdef CONFIG_SMP
        int cpuphys;
+#endif
        int64_t bridge;
        int local_widget, status;
        nasid_t local_nasid;
@@ -146,7 +149,6 @@ struct sn_irq_info *sn_retarget_vector(struct sn_irq_info *sn_irq_info,
        vector = sn_irq_info->irq_irq;
        /* Free the old PROM new_irq_info structure */
        sn_intr_free(local_nasid, local_widget, new_irq_info);
-       /* Update kernels new_irq_info with new target info */
        unregister_intr_pda(new_irq_info);
 
        /* allocate a new PROM new_irq_info struct */
@@ -160,8 +162,10 @@ struct sn_irq_info *sn_retarget_vector(struct sn_irq_info *sn_irq_info,
                return NULL;
        }
 
-       cpuphys = nasid_slice_to_cpuid(nasid, slice);
-       new_irq_info->irq_cpuid = cpuphys;
+       /* Update kernels new_irq_info with new target info */
+       cpuid = nasid_slice_to_cpuid(new_irq_info->irq_nasid,
+                                    new_irq_info->irq_slice);
+       new_irq_info->irq_cpuid = cpuid;
        register_intr_pda(new_irq_info);
 
        pci_provider = sn_pci_provider[new_irq_info->irq_bridge_type];
@@ -180,6 +184,7 @@ struct sn_irq_info *sn_retarget_vector(struct sn_irq_info *sn_irq_info,
        call_rcu(&sn_irq_info->rcu, sn_irq_info_free);
 
 #ifdef CONFIG_SMP
+       cpuphys = cpu_physical_id(cpuid);
        set_irq_affinity_info((vector & 0xff), cpuphys, 0);
 #endif
 
@@ -299,6 +304,9 @@ void sn_irq_fixup(struct pci_dev *pci_dev, struct sn_irq_info *sn_irq_info)
        nasid_t nasid = sn_irq_info->irq_nasid;
        int slice = sn_irq_info->irq_slice;
        int cpu = nasid_slice_to_cpuid(nasid, slice);
+#ifdef CONFIG_SMP
+       int cpuphys;
+#endif
 
        pci_dev_get(pci_dev);
        sn_irq_info->irq_cpuid = cpu;
@@ -311,6 +319,10 @@ void sn_irq_fixup(struct pci_dev *pci_dev, struct sn_irq_info *sn_irq_info)
        spin_unlock(&sn_irq_info_lock);
 
        register_intr_pda(sn_irq_info);
+#ifdef CONFIG_SMP
+       cpuphys = cpu_physical_id(cpu);
+       set_irq_affinity_info(sn_irq_info->irq_irq, cpuphys, 0);
+#endif
 }
 
 void sn_irq_unfixup(struct pci_dev *pci_dev)
index 6ffd1f850d41bd4980b48e35a9955a14671dc6a3..b3a435fd70fbc717d8c819e3f253aa50612d09f1 100644 (file)
@@ -136,10 +136,6 @@ int sn_setup_msi_irq(unsigned int irq, struct pci_dev *pdev)
         */
        msg.data = 0x100 + irq;
 
-#ifdef CONFIG_SMP
-       set_irq_affinity_info(irq, sn_irq_info->irq_cpuid, 0);
-#endif
-
        write_msi_msg(irq, &msg);
        set_irq_chip_and_handler(irq, &sn_msi_chip, handle_edge_irq);
 
index 1d009f93244d2444edf7324ac2f44f6e09be7953..a934ad069425ba080a69f9385677acc6c4913fab 100644 (file)
@@ -769,5 +769,13 @@ int sn_prom_feature_available(int id)
                return 0;
        return test_bit(id, sn_prom_features);
 }
+
+void
+sn_kernel_launch_event(void)
+{
+       /* ignore status until we understand possible failure, if any*/
+       if (ia64_sn_kernel_launch_event())
+               printk(KERN_ERR "KEXEC is not supported in this PROM, Please update the PROM.\n");
+}
 EXPORT_SYMBOL(sn_prom_feature_available);
 
index 41fd490af3b47a93c70e829a561506151f1e6e09..f383dab973f5ea62d86f914a5774357be3ea7a4d 100644 (file)
@@ -214,6 +214,14 @@ config RWSEM_XCHGADD_ALGORITHM
        bool
        default n
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 config GENERIC_FIND_NEXT_BIT
        bool
        default y
index bce8af5e3bb2ab6f542b198770cdb8b0e1e72ab1..ee3c8be12fa0efba5244d5c1f1b393760f131e89 100644 (file)
@@ -2,6 +2,7 @@
  * arch/m32r/boot/compressed/m32r_sio.c
  *
  * 2003-02-12: Takeo Takahashi
+ * 2006-11-30: OPSPUT support by Kazuhiro Inaoka
  *
  */
 
@@ -16,7 +17,7 @@ static int puts(const char *s)
        return 0;
 }
 
-#if defined(CONFIG_PLAT_M32700UT_Alpha) || defined(CONFIG_PLAT_M32700UT)
+#if defined(CONFIG_PLAT_M32700UT_Alpha) || defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_OPSPUT)
 #include <asm/m32r.h>
 #include <asm/io.h>
 
@@ -31,7 +32,11 @@ static int puts(const char *s)
 #define BOOT_SIO0TXB   (volatile unsigned short *)(0x02c00000 + 0x2000c)
 #else
 #undef PLD_BASE
+#if defined(CONFIG_PLAT_OPSPUT)
+#define PLD_BASE       0x1cc00000
+#else
 #define PLD_BASE       0xa4c00000
+#endif
 #define BOOT_SIO0STS   PLD_ESIO0STS
 #define BOOT_SIO0TXB   PLD_ESIO0TXB
 #endif
index ac6d840b382b3ccea8205da499f87bedb0e890c7..a2c472c0549f1bccab78502aed0a51bcceb384da 100644 (file)
  *     updated in fork.c:copy_thread, signal.c:do_signal,
  *     ptrace.c and ptrace.h
  *
- * M32Rx/M32R2                         M32R
- *       @(sp)      - r4               ditto
- *       @(0x04,sp) - r5               ditto
- *       @(0x08,sp) - r6               ditto
- *       @(0x0c,sp) - *pt_regs         ditto
- *       @(0x10,sp) - r0               ditto
- *       @(0x14,sp) - r1               ditto
- *       @(0x18,sp) - r2               ditto
- *       @(0x1c,sp) - r3               ditto
- *       @(0x20,sp) - r7               ditto
- *       @(0x24,sp) - r8               ditto
- *       @(0x28,sp) - r9               ditto
- *       @(0x2c,sp) - r10              ditto
- *       @(0x30,sp) - r11              ditto
- *       @(0x34,sp) - r12              ditto
- *       @(0x38,sp) - syscall_nr       ditto
- *       @(0x3c,sp) - acc0h            @(0x3c,sp) - acch
- *       @(0x40,sp) - acc0l            @(0x40,sp) - accl
- *       @(0x44,sp) - acc1h            @(0x44,sp) - dummy_acc1h
- *       @(0x48,sp) - acc1l            @(0x48,sp) - dummy_acc1l
- *       @(0x4c,sp) - psw              ditto
- *       @(0x50,sp) - bpc              ditto
- *       @(0x54,sp) - bbpsw            ditto
- *       @(0x58,sp) - bbpc             ditto
- *       @(0x5c,sp) - spu (cr3)                ditto
- *       @(0x60,sp) - fp (r13)         ditto
- *       @(0x64,sp) - lr (r14)         ditto
- *       @(0x68,sp) - spi (cr2)                ditto
- *       @(0x6c,sp) - orig_r0          ditto
+ * M32R/M32Rx/M32R2
+ *       @(sp)      - r4
+ *       @(0x04,sp) - r5
+ *       @(0x08,sp) - r6
+ *       @(0x0c,sp) - *pt_regs
+ *       @(0x10,sp) - r0
+ *       @(0x14,sp) - r1
+ *       @(0x18,sp) - r2
+ *       @(0x1c,sp) - r3
+ *       @(0x20,sp) - r7
+ *       @(0x24,sp) - r8
+ *       @(0x28,sp) - r9
+ *       @(0x2c,sp) - r10
+ *       @(0x30,sp) - r11
+ *       @(0x34,sp) - r12
+ *       @(0x38,sp) - syscall_nr
+ *       @(0x3c,sp) - acc0h
+ *       @(0x40,sp) - acc0l
+ *       @(0x44,sp) - acc1h            ; ISA_DSP_LEVEL2 only
+ *       @(0x48,sp) - acc1l            ; ISA_DSP_LEVEL2 only
+ *       @(0x4c,sp) - psw
+ *       @(0x50,sp) - bpc
+ *       @(0x54,sp) - bbpsw
+ *       @(0x58,sp) - bbpc
+ *       @(0x5c,sp) - spu (cr3)
+ *       @(0x60,sp) - fp (r13)
+ *       @(0x64,sp) - lr (r14)
+ *       @(0x68,sp) - spi (cr2)
+ *       @(0x6c,sp) - orig_r0
  */
 
 #include <linux/linkage.h>
 #define R11(reg)               @(0x30,reg)
 #define R12(reg)               @(0x34,reg)
 #define SYSCALL_NR(reg)                @(0x38,reg)
-#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
 #define ACC0H(reg)             @(0x3C,reg)
 #define ACC0L(reg)             @(0x40,reg)
 #define ACC1H(reg)             @(0x44,reg)
 #define ACC1L(reg)             @(0x48,reg)
-#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
-#define ACCH(reg)              @(0x3C,reg)
-#define ACCL(reg)              @(0x40,reg)
-#else
-#error unknown isa configuration
-#endif
 #define PSW(reg)               @(0x4C,reg)
 #define BPC(reg)               @(0x50,reg)
 #define BBPSW(reg)             @(0x54,reg)
@@ -603,8 +596,6 @@ ENTRY(ace_handler)
        beqz    r1, inst
 oprand:
        ld      r2, @(low(MDEVA_offset),r2)     ; set address
-       srli    r2, #12
-       slli    r2, #12
        srli    r1, #1
        bra     1f
 inst:
index da6c5f5c1f82b5fe2aa2c4f1a63664609d685e89..3cbb1f717e506b590ecd32db2acec026aafd1616 100644 (file)
@@ -30,14 +30,34 @@ extern void pcc_iowrite_byte(int, unsigned long, void *, size_t, size_t, int);
 extern void pcc_iowrite_word(int, unsigned long, void *, size_t, size_t, int);
 #endif /* CONFIG_PCMCIA && CONFIG_M32R_CFC */
 
-#define PORT2ADDR(port)  _port2addr(port)
-#define PORT2ADDR_USB(port) _port2addr_usb(port)
+#define PORT2ADDR(port)                _port2addr(port)
+#define PORT2ADDR_USB(port)    _port2addr_usb(port)
 
 static inline void *_port2addr(unsigned long port)
 {
        return (void *)(port | NONCACHE_OFFSET);
 }
 
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+static inline void *__port2addr_ata(unsigned long port)
+{
+       static int      dummy_reg;
+
+       switch (port) {
+       case 0x1f0:     return (void *)(0x0c002000 | NONCACHE_OFFSET);
+       case 0x1f1:     return (void *)(0x0c012800 | NONCACHE_OFFSET);
+       case 0x1f2:     return (void *)(0x0c012002 | NONCACHE_OFFSET);
+       case 0x1f3:     return (void *)(0x0c012802 | NONCACHE_OFFSET);
+       case 0x1f4:     return (void *)(0x0c012004 | NONCACHE_OFFSET);
+       case 0x1f5:     return (void *)(0x0c012804 | NONCACHE_OFFSET);
+       case 0x1f6:     return (void *)(0x0c012006 | NONCACHE_OFFSET);
+       case 0x1f7:     return (void *)(0x0c012806 | NONCACHE_OFFSET);
+       case 0x3f6:     return (void *)(0x0c01200e | NONCACHE_OFFSET);
+       default:        return (void *)&dummy_reg;
+       }
+}
+#endif
+
 /*
  * OPSPUT-LAN is located in the extended bus space
  * from 0x10000000 to 0x13ffffff on physical address.
@@ -97,6 +117,12 @@ unsigned char _inb(unsigned long port)
 {
        if (port >= LAN_IOSTART && port < LAN_IOEND)
                return _ne_inb(PORT2ADDR_NE(port));
+
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+       else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+               return *(volatile unsigned char *)__port2addr_ata(port);
+       }
+#endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
        else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
                unsigned char b;
@@ -112,6 +138,11 @@ unsigned short _inw(unsigned long port)
 {
        if (port >= LAN_IOSTART && port < LAN_IOEND)
                return _ne_inw(PORT2ADDR_NE(port));
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+       else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+               return *(volatile unsigned short *)__port2addr_ata(port);
+       }
+#endif
 #if defined(CONFIG_USB)
        else if(port >= 0x340 && port < 0x3a0)
                return *(volatile unsigned short *)PORT2ADDR_USB(port);
@@ -164,6 +195,11 @@ void _outb(unsigned char b, unsigned long port)
        if (port >= LAN_IOSTART && port < LAN_IOEND)
                _ne_outb(b, PORT2ADDR_NE(port));
        else
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+       if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+               *(volatile unsigned char *)__port2addr_ata(port) = b;
+       } else
+#endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
        if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
                pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
@@ -177,6 +213,11 @@ void _outw(unsigned short w, unsigned long port)
        if (port >= LAN_IOSTART && port < LAN_IOEND)
                _ne_outw(w, PORT2ADDR_NE(port));
        else
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+       if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+               *(volatile unsigned short *)__port2addr_ata(port) = w;
+       } else
+#endif
 #if defined(CONFIG_USB)
        if(port >= 0x340 && port < 0x3a0)
                *(volatile unsigned short *)PORT2ADDR_USB(port) = w;
@@ -222,6 +263,14 @@ void _insb(unsigned int port, void *addr, unsigned long count)
 {
        if (port >= LAN_IOSTART && port < LAN_IOEND)
                _ne_insb(PORT2ADDR_NE(port), addr, count);
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+       else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+               unsigned char *buf = addr;
+               unsigned char *portp = __port2addr_ata(port);
+               while (count--)
+                       *buf++ = *(volatile unsigned char *)portp;
+       }
+#endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
        else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
                pcc_ioread_byte(0, port, (void *)addr, sizeof(unsigned char),
@@ -253,6 +302,12 @@ void _insw(unsigned int port, void *addr, unsigned long count)
        } else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
                pcc_ioread_word(9, port, (void *)addr, sizeof(unsigned short),
                                count, 1);
+#endif
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+       } else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+               portp = __port2addr_ata(port);
+               while (count--)
+                       *buf++ = *(volatile unsigned short *)portp;
 #endif
        } else {
                portp = PORT2ADDR(port);
@@ -280,6 +335,12 @@ void _outsb(unsigned int port, const void *addr, unsigned long count)
                portp = PORT2ADDR_NE(port);
                while (count--)
                        _ne_outb(*buf++, portp);
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+       } else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+               portp = __port2addr_ata(port);
+               while (count--)
+                       *(volatile unsigned char *)portp = *buf++;
+#endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
        } else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
                pcc_iowrite_byte(0, port, (void *)addr, sizeof(unsigned char),
@@ -305,6 +366,12 @@ void _outsw(unsigned int port, const void *addr, unsigned long count)
                portp = PORT2ADDR_NE(port);
                while (count--)
                        *(volatile unsigned short *)portp = *buf++;
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+       } else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+               portp = __port2addr_ata(port);
+               while (count--)
+                       *(volatile unsigned short *)portp = *buf++;
+#endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
        } else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
                pcc_iowrite_word(9, port, (void *)addr, sizeof(unsigned short),
index 0e7778be33ccc93503e5b28a4f902f01e13674b4..936205f7aba079284ad4ad82318850f13659b1b0 100644 (file)
@@ -196,9 +196,7 @@ static unsigned long __init setup_memory(void)
        if (LOADER_TYPE && INITRD_START) {
                if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
                        reserve_bootmem(INITRD_START, INITRD_SIZE);
-                       initrd_start = INITRD_START ?
-                               INITRD_START + PAGE_OFFSET : 0;
-
+                       initrd_start = INITRD_START + PAGE_OFFSET;
                        initrd_end = initrd_start + INITRD_SIZE;
                        printk("initrd:start[%08lx],size[%08lx]\n",
                                initrd_start, INITRD_SIZE);
index 61d3b01cbe072e76957bef61704172b32427d427..62d6b71de45f9b108658b2b16f23a48c0763f534 100644 (file)
@@ -218,13 +218,13 @@ static void shutdown_opsput_lanpld_irq(unsigned int irq)
 
 static struct hw_interrupt_type opsput_lanpld_irq_type =
 {
-       "OPSPUT-PLD-LAN-IRQ",
-       startup_opsput_lanpld_irq,
-       shutdown_opsput_lanpld_irq,
-       enable_opsput_lanpld_irq,
-       disable_opsput_lanpld_irq,
-       mask_and_ack_opsput_lanpld,
-       end_opsput_lanpld_irq
+       .typename = "OPSPUT-PLD-LAN-IRQ",
+       .startup = startup_opsput_lanpld_irq,
+       .shutdown = shutdown_opsput_lanpld_irq,
+       .enable = enable_opsput_lanpld_irq,
+       .disable = disable_opsput_lanpld_irq,
+       .ack = mask_and_ack_opsput_lanpld,
+       .end = end_opsput_lanpld_irq
 };
 
 /*
@@ -374,7 +374,6 @@ void __init init_IRQ(void)
        disable_opsput_pld_irq(PLD_IRQ_SIO0_SND);
 #endif  /* CONFIG_SERIAL_M32R_PLDSIO */
 
-#if defined(CONFIG_M32R_CFC)
        /* INT#1: CFC IREQ on PLD */
        irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED;
        irq_desc[PLD_IRQ_CFIREQ].chip = &opsput_pld_irq_type;
@@ -398,8 +397,6 @@ void __init init_IRQ(void)
        irq_desc[PLD_IRQ_CFC_EJECT].depth = 1;  /* disable nested irq */
        pld_icu_data[irq2pldirq(PLD_IRQ_CFC_EJECT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02;    /* 'H' edge sense */
        disable_opsput_pld_irq(PLD_IRQ_CFC_EJECT);
-#endif /* CONFIG_M32R_CFC */
-
 
        /*
         * INT0# is used for LAN, DIO
index b60cea4aebaa6d9e663cae8eef42084d4b30fd26..092ea86bb0794a473780c2b474197f2bcf4ef1ee 100644 (file)
@@ -21,7 +21,7 @@
 #include <linux/unistd.h>
 #include <linux/stddef.h>
 #include <linux/personality.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 #include <asm/cacheflush.h>
 #include <asm/ucontext.h>
 #include <asm/uaccess.h>
index abb34ccd59862453a6c20265a8268fc58789d1ce..c7efdb0aefc5998768b0984137b035ce3f1cd7c3 100644 (file)
@@ -105,9 +105,7 @@ unsigned long __init setup_memory(void)
                if (INITRD_START + INITRD_SIZE <= PFN_PHYS(max_low_pfn)) {
                        reserve_bootmem_node(NODE_DATA(0), INITRD_START,
                                INITRD_SIZE);
-                       initrd_start = INITRD_START ?
-                               INITRD_START + PAGE_OFFSET : 0;
-
+                       initrd_start = INITRD_START + PAGE_OFFSET;
                        initrd_end = initrd_start + INITRD_SIZE;
                        printk("initrd:start[%08lx],size[%08lx]\n",
                                initrd_start, INITRD_SIZE);
index 8d5f551b5754305e87474b617b8e437925b48f76..9b9feb0f161075c09fb9f012017449e240f40cfa 100644 (file)
@@ -173,7 +173,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code,
                goto good_area;
        if (!(vma->vm_flags & VM_GROWSDOWN))
                goto bad_area;
-#if 0
+
        if (error_code & ACE_USERMODE) {
                /*
                 * accessing the stack below "spu" is always a bug.
@@ -184,7 +184,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code,
                if (address + 4 < regs->spu)
                        goto bad_area;
        }
-#endif
+
        if (expand_stack(vma, address))
                goto bad_area;
 /*
index 7bc14461a6ac5082f785f887a73964cbcbe3b280..70a577c89c7c84d279d9ce9f9c08f1c0bbaa08db 100644 (file)
@@ -17,6 +17,14 @@ config RWSEM_GENERIC_SPINLOCK
 config RWSEM_XCHGADD_ALGORITHM
        bool
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 config GENERIC_HWEIGHT
        bool
        default y
index de1304c91112e1a42bd56ebe4de4bf40ef528584..fa015d80161701ccf3e8a390f8e373e072ba08f8 100644 (file)
@@ -52,10 +52,9 @@ void *amiga_chip_alloc(unsigned long size, const char *name)
 #ifdef DEBUG
     printk("amiga_chip_alloc: allocate %ld bytes\n", size);
 #endif
-    res = kmalloc(sizeof(struct resource), GFP_KERNEL);
+    res = kzalloc(sizeof(struct resource), GFP_KERNEL);
     if (!res)
        return NULL;
-    memset(res, 0, sizeof(struct resource));
     res->name = name;
 
     if (allocate_resource(&chipram_res, res, size, 0, UINT_MAX, PAGE_SIZE, NULL, NULL) < 0) {
index 6ca57b6564da1ab138f318cd8247f885acd3180d..bee2b1443e368763d9473bc86894b3ed0b60a5b2 100644 (file)
@@ -375,10 +375,9 @@ struct pci_bus_info * __init init_hades_pci(void)
         * Allocate memory for bus info structure.
         */
 
-       bus = kmalloc(sizeof(struct pci_bus_info), GFP_KERNEL);
+       bus = kzalloc(sizeof(struct pci_bus_info), GFP_KERNEL);
        if (!bus)
                return NULL;
-       memset(bus, 0, sizeof(struct pci_bus_info));
 
        /*
         * Claim resources. The m68k has no separate I/O space, both
index d64b5804e98097998807e529e487bb27cae35376..d01deb46ebbcb60ee092085c0bef142a0c049da6 100644 (file)
@@ -174,7 +174,7 @@ int stdma_islocked(void)
 void __init stdma_init(void)
 {
        stdma_isr = NULL;
-       request_irq(IRQ_MFP_FDC, stdma_int, IRQ_TYPE_SLOW,
+       request_irq(IRQ_MFP_FDC, stdma_int, IRQ_TYPE_SLOW | SA_SHIRQ,
                    "ST-DMA: floppy/ACSI/IDE/Falcon-SCSI", stdma_int);
 }
 
index bffd69a4a1abae3b28b84b906583833803e89689..4b5f050204e860ca7f2991e487d83602517b916f 100644 (file)
@@ -67,16 +67,6 @@ ENTRY(_start)
 1:     lea     init_task,%curptr                       | get initial thread...
        lea     init_thread_union+THREAD_SIZE,%sp       | ...and its stack.
 
-/* copy bootinfo records from the loader to _end */
-       lea     _end, %a1
-       lea     BI_START, %a0
-       /* number of longs to copy */
-       movel   %a0@, %d0
-1:     addl    #4, %a0
-       movel   %a0@, %a1@
-       addl    #4, %a1
-       dbf     %d0, 1b
-
 /* Point MSP at an invalid page to trap if it's used. --m */
        movl    #(PAGESIZE),%d0
        movc    %d0,%msp
index 2550b4ae273234a5c7600f47163e413cd8e5b5d3..8c7eccbfc982e31205f37cb7a062b713faa60efd 100644 (file)
@@ -8,7 +8,7 @@ ENTRY(_start)
 jiffies = jiffies_64 + 4;
 SECTIONS
 {
-  . = 0xE004000;
+  . = 0xE002000;
   _text = .;                   /* Text and read-only data */
   .text : {
        *(.head)
index 911f2ce3f53e11ec6d1e0deeba875735d5c2a13b..2adbeb16e1b8aba1bc98e148121d9dc0d9b207c2 100644 (file)
@@ -99,7 +99,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
         * If we're in an interrupt or have no user
         * context, we must not take the fault..
         */
-       if (in_interrupt() || !mm)
+       if (in_atomic() || !mm)
                goto no_context;
 
        down_read(&mm->mmap_sem);
index 0f88812822b1315f83585600bef314921edab9da..13c0b4ad01eb5977384b333a7f761303bfa1b56c 100644 (file)
@@ -299,7 +299,7 @@ void cache_clear (unsigned long paddr, int len)
        mach_l2_flush(0);
 #endif
 }
-EXPORT_SYMBOL(cache_clear);    /* probably can be unexported */
+EXPORT_SYMBOL(cache_clear);
 
 
 /*
@@ -352,7 +352,7 @@ void cache_push (unsigned long paddr, int len)
        mach_l2_flush(1);
 #endif
 }
-EXPORT_SYMBOL(cache_push);     /* probably can be unexported */
+EXPORT_SYMBOL(cache_push);
 
 #ifndef CONFIG_SINGLE_MEMORY_CHUNK
 int mm_end_of_chunk (unsigned long addr, int len)
index ac6640ade0b1f519ee0ce7363d2ac5131843615c..6a6513aa1ce8595dad72ec7456091380e4130882 100644 (file)
@@ -49,7 +49,6 @@ void __init paging_init(void)
        unsigned long zones_size[MAX_NR_ZONES] = { 0, };
        unsigned long size;
 
-
 #ifdef TEST_VERIFY_AREA
        wp_works_ok = 0;
 #endif
@@ -94,7 +93,11 @@ void __init paging_init(void)
        /* memory sizing is a hack stolen from motorola.c..  hope it works for us */
        zones_size[ZONE_DMA] = ((unsigned long)high_memory - PAGE_OFFSET) >> PAGE_SHIFT;
 
-       free_area_init(zones_size);
+       /* I really wish I knew why the following change made things better...  -- Sam */
+/*     free_area_init(zones_size); */
+       free_area_init_node(0, NODE_DATA(0), zones_size,
+                           (__pa(PAGE_OFFSET) >> PAGE_SHIFT) + 1, NULL);
+
 
 }
 
index aa70dde54228266f55027b7544e4de6520215af9..25993c2a8fbbeb4c540218980f05d22c60a9dfcb 100644 (file)
@@ -25,6 +25,14 @@ config RWSEM_XCHGADD_ALGORITHM
        bool
        default n
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 config GENERIC_FIND_NEXT_BIT
        bool
        default y
index 58afa8be604ea1f1f6ab308e3634ea258f63c4bc..2b2a10da64a4b3af8e8daebaadc876314bc8fcd9 100644 (file)
@@ -60,6 +60,7 @@ SECTIONS {
 #endif
 
        .text : {
+               _text = .;
                _stext = . ;
                *(.text)
                SCHED_TEXT
index d8af858fe3f5eb2b319bfc2101e152e33b14b6c1..fd2ff0698a851e213a4e0b1e7b814a3d338847e6 100644 (file)
@@ -165,6 +165,7 @@ config MIPS_COBALT
        select SYS_SUPPORTS_32BIT_KERNEL
        select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
        select SYS_SUPPORTS_LITTLE_ENDIAN
+       select GENERIC_HARDIRQS_NO__DO_IRQ
 
 config MACH_DECSTATION
        bool "DECstations"
@@ -225,6 +226,7 @@ config MACH_JAZZ
        select SYS_SUPPORTS_32BIT_KERNEL
        select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
        select SYS_SUPPORTS_100HZ
+       select GENERIC_HARDIRQS_NO__DO_IRQ
        help
         This a family of machines based on the MIPS R4030 chipset which was
         used by several vendors to build RISC/os and Windows NT workstations.
@@ -459,6 +461,11 @@ config PNX8550_JBS
        select PNX8550
        select SYS_SUPPORTS_LITTLE_ENDIAN
 
+config PNX8550_STB810
+       bool "Support for Philips PNX8550 based STB810 board"
+       select PNX8550
+       select SYS_SUPPORTS_LITTLE_ENDIAN
+
 config DDB5477
        bool "NEC DDB Vrc-5477"
        select DDB5XXX_COMMON
@@ -482,6 +489,7 @@ config MACH_VR41XX
        select SYS_HAS_CPU_VR41XX
        select SYS_SUPPORTS_32BIT_KERNEL
        select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
+       select GENERIC_HARDIRQS_NO__DO_IRQ
 
 config PMC_YOSEMITE
        bool "PMC-Sierra Yosemite eval board"
@@ -515,6 +523,7 @@ config QEMU
        select SYS_SUPPORTS_BIG_ENDIAN
        select SYS_SUPPORTS_LITTLE_ENDIAN
        select ARCH_SPARSEMEM_ENABLE
+       select GENERIC_HARDIRQS_NO__DO_IRQ
        help
          Qemu is a software emulator which among other architectures also
          can simulate a MIPS32 4Kc system.  This patch adds support for the
@@ -701,8 +710,8 @@ config SIBYTE_CRHONE
        select SYS_SUPPORTS_HIGHMEM
        select SYS_SUPPORTS_LITTLE_ENDIAN
 
-config SNI_RM200_PCI
-       bool "SNI RM200 PCI"
+config SNI_RM
+       bool "SNI RM200/300/400"
        select ARC if CPU_LITTLE_ENDIAN
        select ARC32 if CPU_LITTLE_ENDIAN
        select ARCH_MAY_HAVE_PC_FDC
@@ -725,8 +734,8 @@ config SNI_RM200_PCI
        select SYS_SUPPORTS_HIGHMEM
        select SYS_SUPPORTS_LITTLE_ENDIAN
        help
-         The SNI RM200 PCI was a MIPS-based platform manufactured by Siemens
-         Nixdorf Informationssysteme (SNI), parent company of Pyramid
+         The SNI RM200/300/400 are MIPS-based machines manufactured by
+         Siemens Nixdorf Informationssysteme (SNI), parent company of Pyramid
          Technology and now in turn merged with Fujitsu.  Say Y here to
          support this machine type.
 
@@ -754,6 +763,7 @@ config TOSHIBA_RBTX4927
        select SYS_SUPPORTS_64BIT_KERNEL
        select SYS_SUPPORTS_BIG_ENDIAN
        select TOSHIBA_BOARDS
+       select GENERIC_HARDIRQS_NO__DO_IRQ
        help
          This Toshiba board is based on the TX4927 processor. Say Y here to
          support this machine type
@@ -773,6 +783,7 @@ config TOSHIBA_RBTX4938
        select SYS_SUPPORTS_LITTLE_ENDIAN
        select SYS_SUPPORTS_BIG_ENDIAN
        select TOSHIBA_BOARDS
+       select GENERIC_HARDIRQS_NO__DO_IRQ
        help
          This Toshiba board is based on the TX4938 processor. Say Y here to
          support this machine type
@@ -819,6 +830,14 @@ config RWSEM_GENERIC_SPINLOCK
 config RWSEM_XCHGADD_ALGORITHM
        bool
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 config GENERIC_FIND_NEXT_BIT
        bool
        default y
@@ -1062,16 +1081,16 @@ config HAVE_STD_PC_SERIAL_PORT
 
 config ARC_CONSOLE
        bool "ARC console support"
-       depends on SGI_IP22 || SNI_RM200_PCI
+       depends on SGI_IP22 || SNI_RM
 
 config ARC_MEMORY
        bool
-       depends on MACH_JAZZ || SNI_RM200_PCI || SGI_IP32
+       depends on MACH_JAZZ || SNI_RM || SGI_IP32
        default y
 
 config ARC_PROMLIB
        bool
-       depends on MACH_JAZZ || SNI_RM200_PCI || SGI_IP22 || SGI_IP32
+       depends on MACH_JAZZ || SNI_RM || SGI_IP22 || SGI_IP32
        default y
 
 config ARC64
index 641aa30b36385a6860f304709d82b5ab7871345a..d1b026a0337d843ef074b6036f02de7e73fc5d8b 100644 (file)
@@ -463,6 +463,11 @@ libs-$(CONFIG_PNX8550_JBS) += arch/mips/philips/pnx8550/jbs/
 #cflags-$(CONFIG_PNX8550_JBS)  += -Iinclude/asm-mips/mach-pnx8550
 load-$(CONFIG_PNX8550_JBS)     += 0xffffffff80060000
 
+# Philips PNX8550 STB810 board
+#
+libs-$(CONFIG_PNX8550_STB810)  += arch/mips/philips/pnx8550/stb810/
+load-$(CONFIG_PNX8550_STB810)  += 0xffffffff80060000
+
 # NEC EMMA2RH boards
 #
 core-$(CONFIG_EMMA2RH)          += arch/mips/emma2rh/common/
@@ -569,11 +574,11 @@ libs-$(CONFIG_SIBYTE_BIGSUR)      += arch/mips/sibyte/swarm/
 load-$(CONFIG_SIBYTE_BIGSUR)   := 0xffffffff80100000
 
 #
-# SNI RM200 PCI
+# SNI RM
 #
-core-$(CONFIG_SNI_RM200_PCI)   += arch/mips/sni/
-cflags-$(CONFIG_SNI_RM200_PCI) += -Iinclude/asm-mips/mach-rm200
-load-$(CONFIG_SNI_RM200_PCI)   += 0xffffffff80600000
+core-$(CONFIG_SNI_RM)          += arch/mips/sni/
+cflags-$(CONFIG_SNI_RM)                += -Iinclude/asm-mips/mach-rm
+load-$(CONFIG_SNI_RM)          += 0xffffffff80600000
 
 #
 # Toshiba JMR-TX3927 board
@@ -695,7 +700,7 @@ ifdef CONFIG_QEMU
 all:   vmlinux.bin
 endif
 
-ifdef CONFIG_SNI_RM200_PCI
+ifdef CONFIG_SNI_RM
 all:   vmlinux.ecoff
 endif
 
index 35931bedc3df2449452d3e74222065120f56d704..ac1891687520a6514197b265a262aa96422bd382 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MIPS_ATLAS=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index ba3bf733d27d5d9621c235bdf38413146e548899..9554257c6f3a474319ada563e7e014f7cc1d0448 100644 (file)
@@ -57,7 +57,7 @@ CONFIG_SIBYTE_BIGSUR=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index e5358121d2da0ff928e2e89ca3487f91f3d2d36c..49590d443712ea31509ab0c832528d532185bd58 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MACH_VR41XX=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index adf1e8c98c654de024b5acfd580b1e1a45e7dc1d..0607fc239087edf414d44576a57b345fdc558950 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MIPS_COBALT=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 4fd29ffdfb8dafd22e9fbf43ded53215e7807124..1a57b3375483d3b0d84ce6b54d47cbf17d4c1cae 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MIPS_DB1000=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 025b960ba990fb0e95cb78a1680f1aca76edbebf..0055ec41f207ce6e20e5e56369c21b62b5d8189d 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MIPS_DB1100=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 80c9dd98f897fc1e088c176517861fb6aed9619a..c41823b81be0066ead05d8c2773e2bfafd79f6cd 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MIPS_DB1200=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 6caa90b0e1766fd3991fc1c1ea285147746574f1..7d6d92187880364e34631c04c133eeba8ec959d1 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MIPS_DB1500=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index c6cae86c6ab7c5f73a08d493807b644e9d5b4cc0..c681c91763aac90700a79280aab3448103e9b714 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MIPS_DB1550=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 72f24001c99e88a24061d7b47303d4a84ed66269..dd4bb0080211a5ff146f4a68cb663ae4c2c98687 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_DDB5477=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index fe1387eb83c9850cd49d94c98a4888d0f662b6df..8a31ce4be12ce0266cc0d333f1f04bec903fa28d 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MACH_DECSTATION=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 6133c28beb8c757db6f17b52ef4c1e2dd38234f3..6fa4f914f6e48347d539961fb49a0ec595b67e5f 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MACH_VR41XX=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index a484b7d396fc8a9ab4c0830b21b2f47c3506b80f..4c9d0405a5df991ec6a40687e415750b486774bd 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MARKEINS=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 21bfcdebf8f53664cc0207f778ad57f78b62ec26..d5b49735683b8a453acf300b36c712805ca8266b 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MIPS_EV64120=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 1a5b06cfb4d6b9d63685801055bb4247e222a017..697140c6562f76655174a1f7d06fa873824a57a2 100644 (file)
@@ -60,7 +60,7 @@ CONFIG_BASLER_EXCITE=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 21d53e0c9ee84c5126881129026a9224eddcdd20..f9812d1e45797ddb9792aceb8dc80f8f20ccaeb7 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_SGI_IP22=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index e3e94c7e5ee1b6ff81bcd089658dff3dba2782f4..96090f28373bbfe025871a72dc7adf0c5fa88a77 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_SGI_IP27=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index b4ab2bea972331c9f0d84544b9cbe9cd9899e3bb..61e069a0f1aa890405a42a06a85fd684fc68099c 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_SGI_IP32=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 9d4d17ace123b50eacc4192b5c11fafba99e35a8..88966666f4c683e0f1644251b08eb4b12ed6cc84 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MOMENCO_JAGUAR_ATX=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 382083ebea0ab8e2d63b59e696b8d9609e08b619..835764d834f77e313c0aff349914ee4e6884c7de 100644 (file)
@@ -57,7 +57,7 @@ CONFIG_MACH_JAZZ=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index d03746667a96c6e390de1d7cef39585517e29ffa..50fd9557e6466925afb378ca0ac1c45feca21056 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MIPS=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 CONFIG_TOSHIBA_JMR3927=y
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 1db8249b4c0fa1aaafb33355137ee42c846e8b85..05f539f84f58848a20b9df18a1ff034b16f5a2d2 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_LASAT=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 101e80347dcefe3edb49e2c2f134910869f66631..1f9300f37f52f36528da5f07b3c6a1c797e89a63 100644 (file)
@@ -57,7 +57,7 @@ CONFIG_MIPS_MALTA=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index a3cbd23bf217d72ba338faf2cec97c3e1edd456a..03efcfd0503bbe85aee49c6af0564afae4201747 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MIPS_SIM=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 6570b47426cef5e326fa10d6dd22201da934b228..e4221aafbc4c6095560b7f0be6e17e8bfbfd3466 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MACH_VR41XX=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 440d65f93a949bb6fbee4239b10caf9a57c7985a..32b1afdd1c208eeef2ac1b37d9352d4298b6b067 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MOMENCO_OCELOT_3=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index c2c7ae77da3e68fc03562dab396f9e4499f46c6e..ebe75c1c71af80a9fe5c796f83bed59809b78480 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MOMENCO_OCELOT_C=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 67efe270e0cc4cf6d3ee14db47ee357db8f54d02..5a9603c12902a18e973945d296da5c11378207ec 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MOMENCO_OCELOT=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index a10f34de5f7ef5cc929dac8d5f33d726c70fe275..46a942c253cfe7eb1a65279271bcb1eb0b5edf5f 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MOMENCO_OCELOT_G=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 9e672f63a0aa854f297e4dfa2288aeb7f2e9a2fa..7d3c688181d596fe20cad471db093d5b44f0149e 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MIPS_PB1100=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index d0c0f4af1bff7c533b4b626108373d7a187d3221..a77805af08190f329d009bf7a953468841fdb695 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MIPS_PB1500=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 3db7427d1b5578d94c426226b66f530e474d5d1e..8318d74d6adb51fc72a657391a385fb9c1527014 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MIPS_PB1550=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 280a8001eacfd0a907261697db0f6721c0ddf976..fcb8fea3052ca0d207f7b67836af289830125dff 100644 (file)
@@ -57,7 +57,7 @@ CONFIG_PNX8550_JBS=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
diff --git a/arch/mips/configs/pnx8550-stb810_defconfig b/arch/mips/configs/pnx8550-stb810_defconfig
new file mode 100644 (file)
index 0000000..f38a2c1
--- /dev/null
@@ -0,0 +1,1229 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.19
+# Thu Dec  7 16:35:12 2006
+#
+CONFIG_MIPS=y
+
+#
+# Machine selection
+#
+# CONFIG_MIPS_MTX1 is not set
+# CONFIG_MIPS_BOSPORUS is not set
+# CONFIG_MIPS_PB1000 is not set
+# CONFIG_MIPS_PB1100 is not set
+# CONFIG_MIPS_PB1500 is not set
+# CONFIG_MIPS_PB1550 is not set
+# CONFIG_MIPS_PB1200 is not set
+# CONFIG_MIPS_DB1000 is not set
+# CONFIG_MIPS_DB1100 is not set
+# CONFIG_MIPS_DB1500 is not set
+# CONFIG_MIPS_DB1550 is not set
+# CONFIG_MIPS_DB1200 is not set
+# CONFIG_MIPS_MIRAGE is not set
+# CONFIG_BASLER_EXCITE is not set
+# CONFIG_MIPS_COBALT is not set
+# CONFIG_MACH_DECSTATION is not set
+# CONFIG_MIPS_EV64120 is not set
+# CONFIG_MACH_JAZZ is not set
+# CONFIG_LASAT is not set
+# CONFIG_MIPS_ATLAS is not set
+# CONFIG_MIPS_MALTA is not set
+# CONFIG_MIPS_SEAD is not set
+# CONFIG_WR_PPMC is not set
+# CONFIG_MIPS_SIM is not set
+# CONFIG_MOMENCO_JAGUAR_ATX is not set
+# CONFIG_MOMENCO_OCELOT is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
+# CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_G is not set
+# CONFIG_MIPS_XXS1500 is not set
+# CONFIG_PNX8550_V2PCI is not set
+# CONFIG_PNX8550_JBS is not set
+CONFIG_PNX8550_STB810=y
+# CONFIG_DDB5477 is not set
+# CONFIG_MACH_VR41XX is not set
+# CONFIG_PMC_YOSEMITE is not set
+# CONFIG_QEMU is not set
+# CONFIG_MARKEINS is not set
+# CONFIG_SGI_IP22 is not set
+# CONFIG_SGI_IP27 is not set
+# CONFIG_SGI_IP32 is not set
+# CONFIG_SIBYTE_BIGSUR is not set
+# CONFIG_SIBYTE_SWARM is not set
+# CONFIG_SIBYTE_SENTOSA is not set
+# CONFIG_SIBYTE_RHONE is not set
+# CONFIG_SIBYTE_CARMEL is not set
+# CONFIG_SIBYTE_PTSWARM is not set
+# CONFIG_SIBYTE_LITTLESUR is not set
+# CONFIG_SIBYTE_CRHINE is not set
+# CONFIG_SIBYTE_CRHONE is not set
+# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_TOSHIBA_JMR3927 is not set
+# CONFIG_TOSHIBA_RBTX4927 is not set
+# CONFIG_TOSHIBA_RBTX4938 is not set
+# CONFIG_KEXEC is not set
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_TIME=y
+CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
+CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
+# CONFIG_CPU_BIG_ENDIAN is not set
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
+CONFIG_PNX8550=y
+CONFIG_SOC_PNX8550=y
+CONFIG_MIPS_L1_CACHE_SHIFT=5
+
+#
+# CPU selection
+#
+CONFIG_CPU_MIPS32_R1=y
+# CONFIG_CPU_MIPS32_R2 is not set
+# CONFIG_CPU_MIPS64_R1 is not set
+# CONFIG_CPU_MIPS64_R2 is not set
+# CONFIG_CPU_R3000 is not set
+# CONFIG_CPU_TX39XX is not set
+# CONFIG_CPU_VR41XX is not set
+# CONFIG_CPU_R4300 is not set
+# CONFIG_CPU_R4X00 is not set
+# CONFIG_CPU_TX49XX is not set
+# CONFIG_CPU_R5000 is not set
+# CONFIG_CPU_R5432 is not set
+# CONFIG_CPU_R6000 is not set
+# CONFIG_CPU_NEVADA is not set
+# CONFIG_CPU_R8000 is not set
+# CONFIG_CPU_R10000 is not set
+# CONFIG_CPU_RM7000 is not set
+# CONFIG_CPU_RM9000 is not set
+# CONFIG_CPU_SB1 is not set
+CONFIG_SYS_HAS_CPU_MIPS32_R1=y
+CONFIG_CPU_MIPS32=y
+CONFIG_CPU_MIPSR1=y
+CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
+CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
+
+#
+# Kernel type
+#
+CONFIG_32BIT=y
+# CONFIG_64BIT is not set
+CONFIG_PAGE_SIZE_4KB=y
+# CONFIG_PAGE_SIZE_8KB is not set
+# CONFIG_PAGE_SIZE_16KB is not set
+# CONFIG_PAGE_SIZE_64KB is not set
+CONFIG_CPU_HAS_PREFETCH=y
+CONFIG_MIPS_MT_DISABLED=y
+# CONFIG_MIPS_MT_SMP is not set
+# CONFIG_MIPS_MT_SMTC is not set
+# CONFIG_MIPS_VPE_LOADER is not set
+# CONFIG_64BIT_PHYS_ADDR is not set
+CONFIG_CPU_HAS_LLSC=y
+CONFIG_CPU_HAS_SYNC=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_CPU_SUPPORTS_HIGHMEM=y
+CONFIG_ARCH_FLATMEM_ENABLE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
+# CONFIG_HZ_48 is not set
+# CONFIG_HZ_100 is not set
+# CONFIG_HZ_128 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_256 is not set
+# CONFIG_HZ_1000 is not set
+# CONFIG_HZ_1024 is not set
+CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
+CONFIG_HZ=250
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT is not set
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+# CONFIG_IPC_NS is not set
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_TASKSTATS is not set
+# CONFIG_UTS_NS is not set
+# CONFIG_AUDIT is not set
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_SYSFS_DEPRECATED=y
+# CONFIG_RELAY is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
+CONFIG_EMBEDDED=y
+# CONFIG_SYSCTL_SYSCALL is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+# CONFIG_HOTPLUG is not set
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SHMEM=y
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_RT_MUTEXES=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+# CONFIG_MODULE_UNLOAD is not set
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Block layer
+#
+CONFIG_BLOCK=y
+# CONFIG_LBD is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_LSF is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+CONFIG_DEFAULT_AS=y
+# CONFIG_DEFAULT_DEADLINE is not set
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="anticipatory"
+
+#
+# Bus options (PCI, PCMCIA, EISA, ISA, TC)
+#
+CONFIG_HW_HAS_PCI=y
+CONFIG_PCI=y
+# CONFIG_PCI_MULTITHREAD_PROBE is not set
+# CONFIG_PCI_DEBUG is not set
+CONFIG_MMU=y
+
+#
+# PCCARD (PCMCIA/CardBus) support
+#
+
+#
+# PCI Hotplug Support
+#
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_MISC is not set
+CONFIG_TRAD_SIGNALS=y
+
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_UMEM is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_SX8 is not set
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=8192
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+
+#
+# Misc devices
+#
+# CONFIG_SGI_IOC4 is not set
+# CONFIG_TIFM_CORE is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_IDE_MAX_HWIFS=4
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_BLK_DEV_IDEDISK=y
+# CONFIG_IDEDISK_MULTI_MODE is not set
+CONFIG_BLK_DEV_IDECD=m
+# CONFIG_BLK_DEV_IDETAPE is not set
+# CONFIG_BLK_DEV_IDEFLOPPY is not set
+CONFIG_BLK_DEV_IDESCSI=y
+# CONFIG_IDE_TASK_IOCTL is not set
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=y
+CONFIG_BLK_DEV_IDEPCI=y
+CONFIG_IDEPCI_SHARE_IRQ=y
+CONFIG_BLK_DEV_OFFBOARD=y
+CONFIG_BLK_DEV_GENERIC=y
+# CONFIG_BLK_DEV_OPTI621 is not set
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
+# CONFIG_IDEDMA_PCI_AUTO is not set
+# CONFIG_BLK_DEV_AEC62XX is not set
+# CONFIG_BLK_DEV_ALI15X3 is not set
+# CONFIG_BLK_DEV_AMD74XX is not set
+# CONFIG_BLK_DEV_CMD64X is not set
+# CONFIG_BLK_DEV_TRIFLEX is not set
+# CONFIG_BLK_DEV_CY82C693 is not set
+# CONFIG_BLK_DEV_CS5520 is not set
+# CONFIG_BLK_DEV_CS5530 is not set
+# CONFIG_BLK_DEV_HPT34X is not set
+CONFIG_BLK_DEV_HPT366=y
+# CONFIG_BLK_DEV_JMICRON is not set
+# CONFIG_BLK_DEV_SC1200 is not set
+# CONFIG_BLK_DEV_PIIX is not set
+# CONFIG_BLK_DEV_IT821X is not set
+# CONFIG_BLK_DEV_NS87415 is not set
+# CONFIG_BLK_DEV_PDC202XX_OLD is not set
+# CONFIG_BLK_DEV_PDC202XX_NEW is not set
+# CONFIG_BLK_DEV_SVWKS is not set
+# CONFIG_BLK_DEV_SIIMAGE is not set
+# CONFIG_BLK_DEV_SLC90E66 is not set
+# CONFIG_BLK_DEV_TRM290 is not set
+# CONFIG_BLK_DEV_VIA82CXXX is not set
+# CONFIG_IDE_ARM is not set
+CONFIG_BLK_DEV_IDEDMA=y
+# CONFIG_IDEDMA_IVB is not set
+# CONFIG_IDEDMA_AUTO is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+CONFIG_SCSI=y
+# CONFIG_SCSI_NETLINK is not set
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+# CONFIG_BLK_DEV_SR is not set
+# CONFIG_CHR_DEV_SG is not set
+# CONFIG_CHR_DEV_SCH is not set
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+CONFIG_SCSI_CONSTANTS=y
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transports
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+CONFIG_SCSI_ISCSI_ATTRS=m
+# CONFIG_SCSI_SAS_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
+
+#
+# SCSI low-level drivers
+#
+CONFIG_ISCSI_TCP=m
+# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
+# CONFIG_SCSI_3W_9XXX is not set
+# CONFIG_SCSI_ACARD 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_AIC94XX is not set
+# CONFIG_SCSI_DPT_I2O is not set
+# CONFIG_SCSI_ARCMSR is not set
+# CONFIG_MEGARAID_NEWGEN is not set
+# CONFIG_MEGARAID_LEGACY is not set
+# CONFIG_MEGARAID_SAS is not set
+# CONFIG_SCSI_HPTIOP is not set
+# CONFIG_SCSI_DMX3191D is not set
+# CONFIG_SCSI_FUTURE_DOMAIN is not set
+# CONFIG_SCSI_IPS is not set
+# CONFIG_SCSI_INITIO is not set
+# CONFIG_SCSI_INIA100 is not set
+# CONFIG_SCSI_STEX is not set
+# CONFIG_SCSI_SYM53C8XX_2 is not set
+# CONFIG_SCSI_QLOGIC_1280 is not set
+# CONFIG_SCSI_QLA_FC is not set
+# CONFIG_SCSI_QLA_ISCSI is not set
+# CONFIG_SCSI_LPFC is not set
+# CONFIG_SCSI_DC395x is not set
+# CONFIG_SCSI_DC390T is not set
+# CONFIG_SCSI_NSP32 is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# Serial ATA (prod) and Parallel ATA (experimental) drivers
+#
+# CONFIG_ATA is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Fusion MPT device support
+#
+# CONFIG_FUSION is not set
+# CONFIG_FUSION_SPI is not set
+# CONFIG_FUSION_FC is not set
+# CONFIG_FUSION_SAS is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+# CONFIG_IEEE1394 is not set
+
+#
+# I2O device support
+#
+# CONFIG_I2O is not set
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+
+#
+# PHY device support
+#
+# CONFIG_PHYLIB is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_CASSINI is not set
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_DM9000 is not set
+
+#
+# Tulip family network device support
+#
+# CONFIG_NET_TULIP is not set
+# CONFIG_HP100 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_B44 is not set
+# CONFIG_FORCEDETH is not set
+# CONFIG_DGRS is not set
+# CONFIG_EEPRO100 is not set
+# CONFIG_E100 is not set
+# CONFIG_FEALNX is not set
+CONFIG_NATSEMI=y
+# CONFIG_NE2K_PCI is not set
+# CONFIG_8139CP is not set
+# CONFIG_8139TOO 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
+
+#
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_E1000 is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_R8169 is not set
+# CONFIG_SIS190 is not set
+# CONFIG_SKGE is not set
+# CONFIG_SKY2 is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_VIA_VELOCITY is not set
+# CONFIG_TIGON3 is not set
+# CONFIG_BNX2 is not set
+# CONFIG_QLA3XXX is not set
+
+#
+# Ethernet (10000 Mbit)
+#
+# CONFIG_CHELSIO_T1 is not set
+# CONFIG_IXGB is not set
+# CONFIG_S2IO is not set
+# CONFIG_MYRI10GE is not set
+# CONFIG_NETXEN_NIC is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_NET_FC is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
+
+#
+# Userland interfaces
+#
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Hardware I/O ports
+#
+CONFIG_SERIO=y
+# CONFIG_SERIO_I8042 is not set
+# CONFIG_SERIO_SERPORT is not set
+# CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_LIBPS2=y
+# CONFIG_SERIO_RAW is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+# CONFIG_SERIAL_PNX8XXX is not set
+# CONFIG_SERIAL_JSM is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+CONFIG_HW_RANDOM=y
+# CONFIG_RTC is not set
+# CONFIG_GEN_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# TPM devices
+#
+# CONFIG_TCG_TPM is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Hardware Monitoring support
+#
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
+# CONFIG_SENSORS_ABITUGURU is not set
+# CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_VT1211 is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+# CONFIG_USB_DABUSB is not set
+
+#
+# Graphics support
+#
+CONFIG_FIRMWARE_EDID=y
+# CONFIG_FB is not set
+
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+CONFIG_USB_ARCH_HAS_EHCI=y
+CONFIG_USB=y
+# CONFIG_USB_DEBUG is not set
+
+#
+# Miscellaneous USB options
+#
+# CONFIG_USB_DEVICEFS is not set
+# CONFIG_USB_BANDWIDTH is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_MULTITHREAD_PROBE is not set
+# CONFIG_USB_OTG is not set
+
+#
+# USB Host Controller Drivers
+#
+# CONFIG_USB_EHCI_HCD is not set
+# CONFIG_USB_ISP116X_HCD is not set
+CONFIG_USB_OHCI_HCD=y
+# CONFIG_USB_OHCI_BIG_ENDIAN is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+# CONFIG_USB_UHCI_HCD is not set
+# CONFIG_USB_SL811_HCD is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# may also be needed; see USB_STORAGE Help for more information
+#
+CONFIG_USB_STORAGE=y
+# CONFIG_USB_STORAGE_DEBUG is not set
+CONFIG_USB_STORAGE_DATAFAB=y
+CONFIG_USB_STORAGE_FREECOM=y
+CONFIG_USB_STORAGE_ISD200=y
+CONFIG_USB_STORAGE_DPCM=y
+CONFIG_USB_STORAGE_USBAT=y
+CONFIG_USB_STORAGE_SDDR09=y
+CONFIG_USB_STORAGE_SDDR55=y
+CONFIG_USB_STORAGE_JUMPSHOT=y
+# CONFIG_USB_STORAGE_ALAUDA is not set
+# CONFIG_USB_STORAGE_KARMA is not set
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Input Devices
+#
+# CONFIG_USB_HID is not set
+
+#
+# USB HID Boot Protocol drivers
+#
+# CONFIG_USB_KBD is not set
+# CONFIG_USB_MOUSE is not set
+# CONFIG_USB_AIPTEK is not set
+# CONFIG_USB_WACOM is not set
+# CONFIG_USB_ACECAD is not set
+# CONFIG_USB_KBTAB is not set
+# CONFIG_USB_POWERMATE is not set
+# CONFIG_USB_TOUCHSCREEN is not set
+# CONFIG_USB_YEALINK is not set
+# CONFIG_USB_XPAD is not set
+# CONFIG_USB_ATI_REMOTE is not set
+# CONFIG_USB_ATI_REMOTE2 is not set
+# CONFIG_USB_KEYSPAN_REMOTE is not set
+# CONFIG_USB_APPLETOUCH is not set
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_MICROTEK is not set
+
+#
+# USB Network Adapters
+#
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_RTL8150 is not set
+# CONFIG_USB_USBNET_MII is not set
+# CONFIG_USB_USBNET is not set
+CONFIG_USB_MON=y
+
+#
+# USB port drivers
+#
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+
+#
+# USB Miscellaneous drivers
+#
+# CONFIG_USB_EMI62 is not set
+# CONFIG_USB_EMI26 is not set
+# CONFIG_USB_ADUTUX is not set
+# CONFIG_USB_AUERSWALD is not set
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_LEGOTOWER is not set
+# CONFIG_USB_LCD is not set
+# CONFIG_USB_LED is not set
+# CONFIG_USB_CYPRESS_CY7C63 is not set
+# CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_PHIDGET is not set
+# CONFIG_USB_IDMOUSE is not set
+# CONFIG_USB_FTDI_ELAN is not set
+# CONFIG_USB_APPLEDISPLAY is not set
+# CONFIG_USB_LD is not set
+# CONFIG_USB_TRANCEVIBRATOR is not set
+
+#
+# USB DSL modem support
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
+
+#
+# InfiniBand support
+#
+# CONFIG_INFINIBAND is not set
+
+#
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+#
+
+#
+# Real Time Clock
+#
+# CONFIG_RTC_CLASS is not set
+
+#
+# DMA Engine support
+#
+# CONFIG_DMA_ENGINE is not set
+
+#
+# DMA Clients
+#
+
+#
+# DMA Devices
+#
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_EXT4DEV_FS is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+# CONFIG_QUOTA is not set
+# CONFIG_DNOTIFY is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_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_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+# CONFIG_PROC_KCORE is not set
+CONFIG_PROC_SYSCTL=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_POSIX_ACL is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+# CONFIG_CONFIGFS_FS is not set
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_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_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
+# CONFIG_NFS_V4 is not set
+# CONFIG_NFS_DIRECTIO is not set
+CONFIG_NFSD=m
+# CONFIG_NFSD_V3 is not set
+# CONFIG_NFSD_TCP is not set
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+# CONFIG_NLS_CODEPAGE_437 is not set
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+# CONFIG_NLS_ISO8859_1 is not set
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+# CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_UNUSED_SYMBOLS is not set
+CONFIG_DEBUG_KERNEL=y
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_DETECT_SOFTLOCKUP=y
+# CONFIG_SCHEDSTATS is not set
+CONFIG_DEBUG_SLAB=y
+# CONFIG_DEBUG_SLAB_LEAK is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_RWSEMS is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_DEBUG_FS is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_LIST is not set
+CONFIG_FORCED_INLINING=y
+CONFIG_HEADERS_CHECK=y
+# CONFIG_RCU_TORTURE_TEST is not set
+CONFIG_CROSSCOMPILE=y
+CONFIG_CMDLINE="console=ttyS1,38400n8 kgdb=ttyS0 root=/dev/nfs ip=bootp"
+# CONFIG_DEBUG_STACK_USAGE is not set
+# CONFIG_KGDB is not set
+# CONFIG_RUNTIME_DEBUG is not set
+# CONFIG_MIPS_UNCACHED is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_ALGAPI=m
+CONFIG_CRYPTO_BLKCIPHER=m
+CONFIG_CRYPTO_MANAGER=m
+# CONFIG_CRYPTO_HMAC is not set
+# CONFIG_CRYPTO_NULL is not set
+# CONFIG_CRYPTO_MD4 is not set
+CONFIG_CRYPTO_MD5=m
+# CONFIG_CRYPTO_SHA1 is not set
+# CONFIG_CRYPTO_SHA256 is not set
+# CONFIG_CRYPTO_SHA512 is not set
+# CONFIG_CRYPTO_WP512 is not set
+# CONFIG_CRYPTO_TGR192 is not set
+CONFIG_CRYPTO_ECB=m
+CONFIG_CRYPTO_CBC=m
+# CONFIG_CRYPTO_DES is not set
+# CONFIG_CRYPTO_BLOWFISH is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_AES is not set
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_ARC4 is not set
+# CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_ANUBIS is not set
+# CONFIG_CRYPTO_DEFLATE is not set
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+CONFIG_CRYPTO_CRC32C=m
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Hardware crypto devices
+#
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+# CONFIG_CRC16 is not set
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=m
+CONFIG_PLIST=y
index 64b9fbf44a64dce63f4f55c43cf5fa08e148a3bb..5bc3248e50e4b138e7d812f3d24d5aa98b5c59dc 100644 (file)
@@ -57,7 +57,7 @@ CONFIG_PNX8550_V2PCI=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 9b0dab822bd0d3d63572c96889324214612e4b85..aa61f0f030a5c438939bd562ba4ccf461bd995ec 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_QEMU=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index dd0296036026d3ed0f0fe5e194c7e65bdd783b3b..f9e8f41d17f218a7d8c26bc94634fdcb757c672f 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MIPS=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 CONFIG_TOSHIBA_RBTX4938=y
index d8a498d64d625575812bdba03502cca0e03b3dc8..496aa67b9f82a98d268839efb0338e36f13db4ca 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MIPS=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-CONFIG_SNI_RM200_PCI=y
+CONFIG_SNI_RM=y
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 805a4fe450f5ea07329343687e8231d05163e6cf..e33c17200b390b47c3b1370bfce5744e7daf82b8 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_SIBYTE_SWARM=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 6fcb656d8d87e69cada3001ffad816cc65cb787e..83fb932f9d4bd1217cea5a103d6caf34681c71c7 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MIPS_SEAD=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index dc312f19ada7ea36c8c87302bb5658312e9345f3..e9d4eae45bfa4486beba69a613bbe8a122c7d849 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MACH_VR41XX=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 85615d99b01aeb63e552242ee3e3e9d9ab2c0631..c19597fb0c322d985fc9cd2e0e5431778d05328b 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MACH_VR41XX=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index f7e8194809a143cce88097282da1eadc2e74bb55..97d94f96990f38fc5fb0f57a06751f0ca8abda4f 100644 (file)
@@ -57,7 +57,7 @@ CONFIG_MACH_VR41XX=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 863f6a7cadfd7b35008d59dae3cf0606990340b9..553734a47b62d256f9dd6c4b7561f0c97200a5b4 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_MACH_VR41XX=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index c10267d61cc90e36655c39e41953156b2c9dd030..d3dfb702bb7c50829f06090a80550abafdc4322e 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_WR_PPMC=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 4d3c1329f3cf8e4b0b66f8797d6f67e29c199c2a..b9f74d6745ee60e2dc33d93601f06e80285daf90 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_PMC_YOSEMITE=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 21d53e0c9ee84c5126881129026a9224eddcdd20..f9812d1e45797ddb9792aceb8dc80f8f20ccaeb7 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_SGI_IP22=y
 # CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
 # CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
index 4a9f1ecefaf2225f3a60a2f402cfc1328d6fb93a..9b34238d41c09d7a91887469fc3ff02eef223704 100644 (file)
@@ -90,7 +90,6 @@ struct elf_prpsinfo32
        char    pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
 };
 
-#define elf_addr_t     u32
 #define elf_caddr_t    u32
 #define init_elf_binfmt init_elfn32_binfmt
 
index e318137798958bc03bcf3069b92829d816923cff..993f7ec70f3544cbef175b600fdd71624e1099d8 100644 (file)
@@ -92,7 +92,6 @@ struct elf_prpsinfo32
        char    pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
 };
 
-#define elf_addr_t     u32
 #define elf_caddr_t    u32
 #define init_elf_binfmt init_elf32_binfmt
 
index a2e095adaa3fb25fe3ab63841c4b773690327af4..9a7811d13db2ac607439bd238968a6f17a87841c 100644 (file)
 EXPORT(stext)                                  # used for profiling
 EXPORT(_stext)
 
-#if defined(CONFIG_QEMU) || defined(CONFIG_MIPS_SIM)
+#ifdef CONFIG_MIPS_SIM
        /*
         * Give us a fighting chance of running if execution beings at the
         * kernel load address.  This is needed because this platform does
index ab12c8f0151852e74a66f781fe875ffc362b2368..37cad5de515c782c51d67e432640084c53b53de2 100644 (file)
@@ -52,10 +52,6 @@ static struct linux_binfmt irix_format = {
        irix_core_dump, PAGE_SIZE
 };
 
-#ifndef elf_addr_t
-#define elf_addr_t unsigned long
-#endif
-
 #ifdef DEBUG
 /* Debugging routines. */
 static char *get_elf_p_type(Elf32_Word p_type)
@@ -1013,7 +1009,7 @@ static int notesize(struct memelfnote *en)
        int sz;
 
        sz = sizeof(struct elf_note);
-       sz += roundup(strlen(en->name), 4);
+       sz += roundup(strlen(en->name) + 1, 4);
        sz += roundup(en->datasz, 4);
 
        return sz;
@@ -1032,7 +1028,7 @@ static int writenote(struct memelfnote *men, struct file *file)
 {
        struct elf_note en;
 
-       en.n_namesz = strlen(men->name);
+       en.n_namesz = strlen(men->name) + 1;
        en.n_descsz = men->datasz;
        en.n_type = men->type;
 
@@ -1149,7 +1145,7 @@ static int irix_core_dump(long signr, struct pt_regs * regs, struct file *file)
        psinfo.pr_pid = prstatus.pr_pid = current->pid;
        psinfo.pr_ppid = prstatus.pr_ppid = current->parent->pid;
        psinfo.pr_pgrp = prstatus.pr_pgrp = process_group(current);
-       psinfo.pr_sid = prstatus.pr_sid = current->signal->session;
+       psinfo.pr_sid = prstatus.pr_sid = process_session(current);
        if (current->pid == current->tgid) {
                /*
                 * This is the record for the group leader.  Add in the
index 8c8c8324f775301e7ccfd16dfe77918771cd7e93..5a99e3e0c96dcdab47d209ad4b4f3297d69e560a 100644 (file)
@@ -415,7 +415,7 @@ static unsigned int file_poll(struct file *file, poll_table * wait)
        int minor;
        unsigned int mask = 0;
 
-       minor = iminor(file->f_dentry->d_inode);
+       minor = iminor(file->f_path.dentry->d_inode);
 
        poll_wait(file, &channel_wqs[minor].rt_queue, wait);
        poll_wait(file, &channel_wqs[minor].lx_queue, wait);
@@ -437,7 +437,7 @@ static unsigned int file_poll(struct file *file, poll_table * wait)
 static ssize_t file_read(struct file *file, char __user * buffer, size_t count,
                         loff_t * ppos)
 {
-       int minor = iminor(file->f_dentry->d_inode);
+       int minor = iminor(file->f_path.dentry->d_inode);
 
        /* data available? */
        if (!rtlx_read_poll(minor, (file->f_flags & O_NONBLOCK) ? 0 : 1)) {
@@ -454,7 +454,7 @@ static ssize_t file_write(struct file *file, const char __user * buffer,
        struct rtlx_channel *rt;
        DECLARE_WAITQUEUE(wait, current);
 
-       minor = iminor(file->f_dentry->d_inode);
+       minor = iminor(file->f_path.dentry->d_inode);
        rt = &rtlx->channel[minor];
 
        /* any space left... */
index 93c74fefff766e9c3cc035a57011a3e62d992a1a..6c2406a93f2b99f1912d48d94788c5b65ebe2279 100644 (file)
@@ -732,7 +732,7 @@ asmlinkage int irix_fstatfs(unsigned int fd, struct irix_statfs __user *buf)
                goto out;
        }
 
-       error = vfs_statfs(file->f_dentry, &kbuf);
+       error = vfs_statfs(file->f_path.dentry, &kbuf);
        if (error)
                goto out_f;
 
@@ -1041,7 +1041,7 @@ asmlinkage unsigned long irix_mmap32(unsigned long addr, size_t len, int prot,
                        unsigned long old_pos;
                        long max_size = offset + len;
 
-                       if (max_size > file->f_dentry->d_inode->i_size) {
+                       if (max_size > file->f_path.dentry->d_inode->i_size) {
                                old_pos = sys_lseek (fd, max_size - 1, 0);
                                sys_write (fd, (void __user *) "", 1);
                                sys_lseek (fd, old_pos, 0);
@@ -1406,7 +1406,7 @@ asmlinkage int irix_fstatvfs(int fd, struct irix_statvfs __user *buf)
                error = -EBADF;
                goto out;
        }
-       error = vfs_statfs(file->f_dentry, &kbuf);
+       error = vfs_statfs(file->f_path.dentry, &kbuf);
        if (error)
                goto out_f;
 
@@ -1526,7 +1526,7 @@ asmlinkage int irix_mmap64(struct pt_regs *regs)
                        unsigned long old_pos;
                        long max_size = off2 + len;
 
-                       if (max_size > file->f_dentry->d_inode->i_size) {
+                       if (max_size > file->f_path.dentry->d_inode->i_size) {
                                old_pos = sys_lseek (fd, max_size - 1, 0);
                                sys_write (fd, (void __user *) "", 1);
                                sys_lseek (fd, old_pos, 0);
@@ -1658,7 +1658,7 @@ asmlinkage int irix_fstatvfs64(int fd, struct irix_statvfs __user *buf)
                error = -EBADF;
                goto out;
        }
-       error = vfs_statfs(file->f_dentry, &kbuf);
+       error = vfs_statfs(file->f_path.dentry, &kbuf);
        if (error)
                goto out_f;
 
index 51ddd216689850d5d0113dee662782ef82c3da8f..666bef484dcbc613559fc2d887c30fc6cc457390 100644 (file)
@@ -1179,7 +1179,7 @@ static ssize_t vpe_write(struct file *file, const char __user * buffer,
        size_t ret = count;
        struct vpe *v;
 
-       minor = iminor(file->f_dentry->d_inode);
+       minor = iminor(file->f_path.dentry->d_inode);
        if ((v = get_vpe(minor)) == NULL)
                return -ENODEV;
 
index 6dd7ae1b7c25401a7c1cfda8817d6c28b4d10eb1..da35d45554911d64cbd68d37e0ec36c5917231e3 100644 (file)
@@ -286,11 +286,11 @@ int proc_lasat_eeprom_value(ctl_table *table, int write, struct file *filp,
                mutex_unlock(&lasat_info_mutex);
                return r;
        }
-       if (filp && filp->f_dentry)
+       if (filp && filp->f_path.dentry)
        {
-               if (!strcmp(filp->f_dentry->d_name.name, "prid"))
+               if (!strcmp(filp->f_path.dentry->d_name.name, "prid"))
                        lasat_board_info.li_eeprom_info.prid = lasat_board_info.li_prid;
-               if (!strcmp(filp->f_dentry->d_name.name, "debugaccess"))
+               if (!strcmp(filp->f_path.dentry->d_name.name, "debugaccess"))
                        lasat_board_info.li_eeprom_info.debugaccess = lasat_board_info.li_debugaccess;
        }
        lasat_write_eeprom_info();
index 15611d9df7ac6771d30be99e716f5ab2c60a21d4..9db357294be1efdbea0021db9fe653e5e872054d 100644 (file)
 #include <asm/regdef.h>
 
 #ifdef CONFIG_64BIT
-#define T0     ta0
-#define T1     ta1
-#define T2     ta2
-#define T3     ta3
-#define T4     t0
-#define T7     t3
-#else
-#define T0     t0
-#define T1     t1
-#define T2     t2
-#define T3     t3
-#define T4     t4
-#define T7     t7
+/*
+ * As we are sharing code base with the mips32 tree (which use the o32 ABI
+ * register definitions). We need to redefine the register definitions from
+ * the n64 ABI register naming to the o32 ABI register naming.
+ */
+#undef t0
+#undef t1
+#undef t2
+#undef t3
+#define t0     $8
+#define t1     $9
+#define t2     $10
+#define t3     $11
+#define t4     $12
+#define t5     $13
+#define t6     $14
+#define t7     $15
+
+#define USE_DOUBLE
 #endif
 
+#ifdef USE_DOUBLE
+
+#define LOAD   ld
+#define ADD    daddu
+#define NBYTES 8
+
+#else
+
+#define LOAD   lw
+#define ADD    addu
+#define NBYTES 4
+
+#endif /* USE_DOUBLE */
+
+#define UNIT(unit)  ((unit)*NBYTES)
+
 #define ADDC(sum,reg)                                          \
-       addu    sum, reg;                                       \
+       ADD     sum, reg;                                       \
        sltu    v1, sum, reg;                                   \
-       addu    sum, v1
+       ADD     sum, v1
 
-#define CSUM_BIGCHUNK(src, offset, sum, _t0, _t1, _t2, _t3)    \
-       lw      _t0, (offset + 0x00)(src);                      \
-       lw      _t1, (offset + 0x04)(src);                      \
-       lw      _t2, (offset + 0x08)(src);                      \
-       lw      _t3, (offset + 0x0c)(src);                      \
-       ADDC(sum, _t0);                                         \
-       ADDC(sum, _t1);                                         \
-       ADDC(sum, _t2);                                         \
-       ADDC(sum, _t3);                                         \
-       lw      _t0, (offset + 0x10)(src);                      \
-       lw      _t1, (offset + 0x14)(src);                      \
-       lw      _t2, (offset + 0x18)(src);                      \
-       lw      _t3, (offset + 0x1c)(src);                      \
+#define CSUM_BIGCHUNK1(src, offset, sum, _t0, _t1, _t2, _t3)   \
+       LOAD    _t0, (offset + UNIT(0))(src);                   \
+       LOAD    _t1, (offset + UNIT(1))(src);                   \
+       LOAD    _t2, (offset + UNIT(2))(src);                   \
+       LOAD    _t3, (offset + UNIT(3))(src);                   \
        ADDC(sum, _t0);                                         \
        ADDC(sum, _t1);                                         \
        ADDC(sum, _t2);                                         \
-       ADDC(sum, _t3);                                         \
+       ADDC(sum, _t3)
+
+#ifdef USE_DOUBLE
+#define CSUM_BIGCHUNK(src, offset, sum, _t0, _t1, _t2, _t3)    \
+       CSUM_BIGCHUNK1(src, offset, sum, _t0, _t1, _t2, _t3)
+#else
+#define CSUM_BIGCHUNK(src, offset, sum, _t0, _t1, _t2, _t3)    \
+       CSUM_BIGCHUNK1(src, offset, sum, _t0, _t1, _t2, _t3);   \
+       CSUM_BIGCHUNK1(src, offset + 0x10, sum, _t0, _t1, _t2, _t3)
+#endif
 
 /*
  * a0: source address
 
        .text
        .set    noreorder
-
-/* unknown src alignment and < 8 bytes to go  */
-small_csumcpy:
-       move    a1, T2
-
-       andi    T0, a1, 4
-       beqz    T0, 1f
-        andi   T0, a1, 2
-
-       /* Still a full word to go  */
-       ulw     T1, (src)
-       PTR_ADDIU       src, 4
-       ADDC(sum, T1)
-
-1:     move    T1, zero
-       beqz    T0, 1f
-        andi   T0, a1, 1
-
-       /* Still a halfword to go  */
-       ulhu    T1, (src)
-       PTR_ADDIU       src, 2
-
-1:     beqz    T0, 1f
-        sll    T1, T1, 16
-
-       lbu     T2, (src)
-        nop
-
-#ifdef __MIPSEB__
-       sll     T2, T2, 8
-#endif
-       or      T1, T2
-
-1:     ADDC(sum, T1)
-
-       /* fold checksum */
-       sll     v1, sum, 16
-       addu    sum, v1
-       sltu    v1, sum, v1
-       srl     sum, sum, 16
-       addu    sum, v1
-
-       /* odd buffer alignment? */
-       beqz    T7, 1f
-        nop
-       sll     v1, sum, 8
-       srl     sum, sum, 8
-       or      sum, v1
-       andi    sum, 0xffff
-1:
-       .set    reorder
-       /* Add the passed partial csum.  */
-       ADDC(sum, a2)
-       jr      ra
-       .set    noreorder
-
-/* ------------------------------------------------------------------------- */
-
        .align  5
 LEAF(csum_partial)
        move    sum, zero
-       move    T7, zero
+       move    t7, zero
 
        sltiu   t8, a1, 0x8
        bnez    t8, small_csumcpy               /* < 8 bytes to copy */
-        move   T2, a1
+        move   t2, a1
 
-       beqz    a1, out
-        andi   T7, src, 0x1                    /* odd buffer? */
+       andi    t7, src, 0x1                    /* odd buffer? */
 
 hword_align:
-       beqz    T7, word_align
+       beqz    t7, word_align
         andi   t8, src, 0x2
 
-       lbu     T0, (src)
+       lbu     t0, (src)
        LONG_SUBU       a1, a1, 0x1
 #ifdef __MIPSEL__
-       sll     T0, T0, 8
+       sll     t0, t0, 8
 #endif
-       ADDC(sum, T0)
+       ADDC(sum, t0)
        PTR_ADDU        src, src, 0x1
        andi    t8, src, 0x2
 
@@ -148,9 +112,9 @@ word_align:
        beqz    t8, dword_align
         sltiu  t8, a1, 56
 
-       lhu     T0, (src)
+       lhu     t0, (src)
        LONG_SUBU       a1, a1, 0x2
-       ADDC(sum, T0)
+       ADDC(sum, t0)
        sltiu   t8, a1, 56
        PTR_ADDU        src, src, 0x2
 
@@ -162,9 +126,9 @@ dword_align:
        beqz    t8, qword_align
         andi   t8, src, 0x8
 
-       lw      T0, 0x00(src)
+       lw      t0, 0x00(src)
        LONG_SUBU       a1, a1, 0x4
-       ADDC(sum, T0)
+       ADDC(sum, t0)
        PTR_ADDU        src, src, 0x4
        andi    t8, src, 0x8
 
@@ -172,11 +136,17 @@ qword_align:
        beqz    t8, oword_align
         andi   t8, src, 0x10
 
-       lw      T0, 0x00(src)
-       lw      T1, 0x04(src)
+#ifdef USE_DOUBLE
+       ld      t0, 0x00(src)
+       LONG_SUBU       a1, a1, 0x8
+       ADDC(sum, t0)
+#else
+       lw      t0, 0x00(src)
+       lw      t1, 0x04(src)
        LONG_SUBU       a1, a1, 0x8
-       ADDC(sum, T0)
-       ADDC(sum, T1)
+       ADDC(sum, t0)
+       ADDC(sum, t1)
+#endif
        PTR_ADDU        src, src, 0x8
        andi    t8, src, 0x10
 
@@ -184,75 +154,120 @@ oword_align:
        beqz    t8, begin_movement
         LONG_SRL       t8, a1, 0x7
 
-       lw      T3, 0x08(src)
-       lw      T4, 0x0c(src)
-       lw      T0, 0x00(src)
-       lw      T1, 0x04(src)
-       ADDC(sum, T3)
-       ADDC(sum, T4)
-       ADDC(sum, T0)
-       ADDC(sum, T1)
+#ifdef USE_DOUBLE
+       ld      t0, 0x00(src)
+       ld      t1, 0x08(src)
+       ADDC(sum, t0)
+       ADDC(sum, t1)
+#else
+       CSUM_BIGCHUNK1(src, 0x00, sum, t0, t1, t3, t4)
+#endif
        LONG_SUBU       a1, a1, 0x10
        PTR_ADDU        src, src, 0x10
        LONG_SRL        t8, a1, 0x7
 
 begin_movement:
        beqz    t8, 1f
-        andi   T2, a1, 0x40
+        andi   t2, a1, 0x40
 
 move_128bytes:
-       CSUM_BIGCHUNK(src, 0x00, sum, T0, T1, T3, T4)
-       CSUM_BIGCHUNK(src, 0x20, sum, T0, T1, T3, T4)
-       CSUM_BIGCHUNK(src, 0x40, sum, T0, T1, T3, T4)
-       CSUM_BIGCHUNK(src, 0x60, sum, T0, T1, T3, T4)
+       CSUM_BIGCHUNK(src, 0x00, sum, t0, t1, t3, t4)
+       CSUM_BIGCHUNK(src, 0x20, sum, t0, t1, t3, t4)
+       CSUM_BIGCHUNK(src, 0x40, sum, t0, t1, t3, t4)
+       CSUM_BIGCHUNK(src, 0x60, sum, t0, t1, t3, t4)
        LONG_SUBU       t8, t8, 0x01
        bnez    t8, move_128bytes
         PTR_ADDU       src, src, 0x80
 
 1:
-       beqz    T2, 1f
-        andi   T2, a1, 0x20
+       beqz    t2, 1f
+        andi   t2, a1, 0x20
 
 move_64bytes:
-       CSUM_BIGCHUNK(src, 0x00, sum, T0, T1, T3, T4)
-       CSUM_BIGCHUNK(src, 0x20, sum, T0, T1, T3, T4)
+       CSUM_BIGCHUNK(src, 0x00, sum, t0, t1, t3, t4)
+       CSUM_BIGCHUNK(src, 0x20, sum, t0, t1, t3, t4)
        PTR_ADDU        src, src, 0x40
 
 1:
-       beqz    T2, do_end_words
+       beqz    t2, do_end_words
         andi   t8, a1, 0x1c
 
 move_32bytes:
-       CSUM_BIGCHUNK(src, 0x00, sum, T0, T1, T3, T4)
+       CSUM_BIGCHUNK(src, 0x00, sum, t0, t1, t3, t4)
        andi    t8, a1, 0x1c
        PTR_ADDU        src, src, 0x20
 
 do_end_words:
-       beqz    t8, maybe_end_cruft
-        LONG_SRL       t8, t8, 0x2
+       beqz    t8, small_csumcpy
+        andi   t2, a1, 0x3
+       LONG_SRL        t8, t8, 0x2
 
 end_words:
-       lw      T0, (src)
+       lw      t0, (src)
        LONG_SUBU       t8, t8, 0x1
-       ADDC(sum, T0)
+       ADDC(sum, t0)
        bnez    t8, end_words
         PTR_ADDU       src, src, 0x4
 
-maybe_end_cruft:
-       andi    T2, a1, 0x3
+/* unknown src alignment and < 8 bytes to go  */
+small_csumcpy:
+       move    a1, t2
 
-small_memcpy:
- j small_csumcpy; move a1, T2          /* XXX ??? */
-       beqz    t2, out
-        move   a1, T2
+       andi    t0, a1, 4
+       beqz    t0, 1f
+        andi   t0, a1, 2
 
-end_bytes:
-       lb      T0, (src)
-       LONG_SUBU       a1, a1, 0x1
-       bnez    a2, end_bytes
-        PTR_ADDU       src, src, 0x1
+       /* Still a full word to go  */
+       ulw     t1, (src)
+       PTR_ADDIU       src, 4
+       ADDC(sum, t1)
+
+1:     move    t1, zero
+       beqz    t0, 1f
+        andi   t0, a1, 1
+
+       /* Still a halfword to go  */
+       ulhu    t1, (src)
+       PTR_ADDIU       src, 2
+
+1:     beqz    t0, 1f
+        sll    t1, t1, 16
+
+       lbu     t2, (src)
+        nop
 
-out:
+#ifdef __MIPSEB__
+       sll     t2, t2, 8
+#endif
+       or      t1, t2
+
+1:     ADDC(sum, t1)
+
+       /* fold checksum */
+#ifdef USE_DOUBLE
+       dsll32  v1, sum, 0
+       daddu   sum, v1
+       sltu    v1, sum, v1
+       dsra32  sum, sum, 0
+       addu    sum, v1
+#endif
+       sll     v1, sum, 16
+       addu    sum, v1
+       sltu    v1, sum, v1
+       srl     sum, sum, 16
+       addu    sum, v1
+
+       /* odd buffer alignment? */
+       beqz    t7, 1f
+        nop
+       sll     v1, sum, 8
+       srl     sum, sum, 8
+       or      sum, v1
+       andi    sum, 0xffff
+1:
+       .set    reorder
+       /* Add the passed partial csum.  */
+       ADDC(sum, a2)
        jr      ra
-        move   v0, sum
+       .set    noreorder
        END(csum_partial)
index 7fa5fd16e46bfe846b5c47063d7d85e5dab54f57..5697c6e250a37d0b69baf49cb1a792b95081a318 100644 (file)
@@ -190,14 +190,14 @@ int dma_supported(struct device *dev, u64 mask)
 
 EXPORT_SYMBOL(dma_supported);
 
-int dma_is_consistent(dma_addr_t dma_addr)
+int dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
 {
        return 1;
 }
 
 EXPORT_SYMBOL(dma_is_consistent);
 
-void dma_cache_sync(void *vaddr, size_t size,
+void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
               enum dma_data_direction direction)
 {
        BUG_ON(direction == DMA_NONE);
index 8da19fd22ac6f0bbbf5b64d3408e611b5f215f99..f088344db4659e2b4e6229464e00d0ad6068a904 100644 (file)
@@ -197,14 +197,14 @@ int dma_supported(struct device *dev, u64 mask)
 
 EXPORT_SYMBOL(dma_supported);
 
-int dma_is_consistent(dma_addr_t dma_addr)
+int dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
 {
        return 1;
 }
 
 EXPORT_SYMBOL(dma_is_consistent);
 
-void dma_cache_sync(void *vaddr, size_t size,
+void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
               enum dma_data_direction direction)
 {
        BUG_ON(direction == DMA_NONE);
index ec54ed0d26ff23fbf257e6e6193cf9a8eeb06815..b42b6f7456e6c552721f2b44762c74c518d68d28 100644 (file)
@@ -363,14 +363,15 @@ int dma_supported(struct device *dev, u64 mask)
 
 EXPORT_SYMBOL(dma_supported);
 
-int dma_is_consistent(dma_addr_t dma_addr)
+int dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
 {
        return 1;
 }
 
 EXPORT_SYMBOL(dma_is_consistent);
 
-void dma_cache_sync(void *vaddr, size_t size, enum dma_data_direction direction)
+void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
+       enum dma_data_direction direction)
 {
        if (direction == DMA_NONE)
                return;
index 2eeffe5c2a3a40315c69cd0a6defc907cb4eb292..8cecef0957c359ff55827b85b91b5b74e74a4648 100644 (file)
@@ -299,14 +299,15 @@ int dma_supported(struct device *dev, u64 mask)
 
 EXPORT_SYMBOL(dma_supported);
 
-int dma_is_consistent(dma_addr_t dma_addr)
+int dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
 {
        return 1;
 }
 
 EXPORT_SYMBOL(dma_is_consistent);
 
-void dma_cache_sync(void *vaddr, size_t size, enum dma_data_direction direction)
+void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
+       enum dma_data_direction direction)
 {
        if (direction == DMA_NONE)
                return;
index 99ebf3ccc222b78ef8743b9f0bb5b6cba15d894c..675502ada5a27d5f958e6b58bea8e4219ff77ff1 100644 (file)
@@ -39,7 +39,7 @@ void *__kmap_atomic(struct page *page, enum km_type type)
        unsigned long vaddr;
 
        /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
-       inc_preempt_count();
+       pagefault_disable();
        if (!PageHighMem(page))
                return page_address(page);
 
@@ -62,8 +62,7 @@ void __kunmap_atomic(void *kvaddr, enum km_type type)
        enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
 
        if (vaddr < FIXADDR_START) { // FIXME
-               dec_preempt_count();
-               preempt_check_resched();
+               pagefault_enable();
                return;
        }
 
@@ -78,8 +77,7 @@ void __kunmap_atomic(void *kvaddr, enum km_type type)
        local_flush_tlb_one(vaddr);
 #endif
 
-       dec_preempt_count();
-       preempt_check_resched();
+       pagefault_enable();
 }
 
 #ifndef CONFIG_LIMITED_DMA
@@ -92,7 +90,7 @@ void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
        enum fixed_addresses idx;
        unsigned long vaddr;
 
-       inc_preempt_count();
+       pagefault_disable();
 
        idx = type + KM_TYPE_NR*smp_processor_id();
        vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
index cea7d0ea36e44c42b30d1a4b36bf7c461f7b4b66..fc2c96f0a1fd6bd532b233da431ca7dc4f6db5ff 100644 (file)
@@ -6,98 +6,13 @@
  * (C) Copyright 1995 1996 Linus Torvalds
  * (C) Copyright 2001, 2002 Ralf Baechle
  */
+#include <linux/mm.h>
 #include <linux/module.h>
 #include <asm/addrspace.h>
 #include <asm/byteorder.h>
 
 #include <linux/vmalloc.h>
-#include <asm/cacheflush.h>
-#include <asm/io.h>
-#include <asm/tlbflush.h>
-
-static inline void remap_area_pte(pte_t * pte, unsigned long address,
-       phys_t size, phys_t phys_addr, unsigned long flags)
-{
-       phys_t end;
-       unsigned long pfn;
-       pgprot_t pgprot = __pgprot(_PAGE_GLOBAL | _PAGE_PRESENT | __READABLE
-                                  | __WRITEABLE | flags);
-
-       address &= ~PMD_MASK;
-       end = address + size;
-       if (end > PMD_SIZE)
-               end = PMD_SIZE;
-       if (address >= end)
-               BUG();
-       pfn = phys_addr >> PAGE_SHIFT;
-       do {
-               if (!pte_none(*pte)) {
-                       printk("remap_area_pte: page already exists\n");
-                       BUG();
-               }
-               set_pte(pte, pfn_pte(pfn, pgprot));
-               address += PAGE_SIZE;
-               pfn++;
-               pte++;
-       } while (address && (address < end));
-}
-
-static inline int remap_area_pmd(pmd_t * pmd, unsigned long address,
-       phys_t size, phys_t phys_addr, unsigned long flags)
-{
-       phys_t end;
-
-       address &= ~PGDIR_MASK;
-       end = address + size;
-       if (end > PGDIR_SIZE)
-               end = PGDIR_SIZE;
-       phys_addr -= address;
-       if (address >= end)
-               BUG();
-       do {
-               pte_t * pte = pte_alloc_kernel(pmd, address);
-               if (!pte)
-                       return -ENOMEM;
-               remap_area_pte(pte, address, end - address, address + phys_addr, flags);
-               address = (address + PMD_SIZE) & PMD_MASK;
-               pmd++;
-       } while (address && (address < end));
-       return 0;
-}
-
-static int remap_area_pages(unsigned long address, phys_t phys_addr,
-       phys_t size, unsigned long flags)
-{
-       int error;
-       pgd_t * dir;
-       unsigned long end = address + size;
-
-       phys_addr -= address;
-       dir = pgd_offset(&init_mm, address);
-       flush_cache_all();
-       if (address >= end)
-               BUG();
-       do {
-               pud_t *pud;
-               pmd_t *pmd;
-
-               error = -ENOMEM;
-               pud = pud_alloc(&init_mm, dir, address);
-               if (!pud)
-                       break;
-               pmd = pmd_alloc(&init_mm, pud, address);
-               if (!pmd)
-                       break;
-               if (remap_area_pmd(pmd, address, end - address,
-                                        phys_addr + address, flags))
-                       break;
-               error = 0;
-               address = (address + PGDIR_SIZE) & PGDIR_MASK;
-               dir++;
-       } while (address && (address < end));
-       flush_tlb_all();
-       return error;
-}
+#include <linux/io.h>
 
 /*
  * Generic mapping function (not visible outside):
@@ -121,6 +36,7 @@ void __iomem * __ioremap(phys_t phys_addr, phys_t size, unsigned long flags)
        unsigned long offset;
        phys_t last_addr;
        void * addr;
+       pgprot_t pgprot;
 
        phys_addr = fixup_bigphys_addr(phys_addr, size);
 
@@ -152,6 +68,9 @@ void __iomem * __ioremap(phys_t phys_addr, phys_t size, unsigned long flags)
                                return NULL;
        }
 
+       pgprot = __pgprot(_PAGE_GLOBAL | _PAGE_PRESENT | __READABLE
+                         | __WRITEABLE | flags);
+
        /*
         * Mappings have to be page-aligned
         */
@@ -166,7 +85,8 @@ void __iomem * __ioremap(phys_t phys_addr, phys_t size, unsigned long flags)
        if (!area)
                return NULL;
        addr = area->addr;
-       if (remap_area_pages((unsigned long) addr, phys_addr, size, flags)) {
+       if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size,
+                              phys_addr, pgprot)) {
                vunmap(addr);
                return NULL;
        }
index 70cb55b89df6db38e250662ec44b1bf365298693..82b20c28bef8f8782a83ef4495728b12a119325b 100644 (file)
@@ -43,7 +43,7 @@ obj-$(CONFIG_SGI_IP32)                += fixup-ip32.o ops-mace.o pci-ip32.o
 obj-$(CONFIG_SIBYTE_SB1250)    += fixup-sb1250.o pci-sb1250.o
 obj-$(CONFIG_SIBYTE_BCM112X)   += fixup-sb1250.o pci-sb1250.o
 obj-$(CONFIG_SIBYTE_BCM1x80)   += pci-bcm1480.o pci-bcm1480ht.o
-obj-$(CONFIG_SNI_RM200_PCI)    += fixup-sni.o ops-sni.o
+obj-$(CONFIG_SNI_RM)           += fixup-sni.o ops-sni.o
 obj-$(CONFIG_TANBAC_TB0219)    += fixup-tb0219.o
 obj-$(CONFIG_TANBAC_TB0226)    += fixup-tb0226.o
 obj-$(CONFIG_TANBAC_TB0287)    += fixup-tb0287.o
index 4256b3b30b775434f21b72b915fd3c41b0ee11c1..50546dab66893106b1671508b3fe11db0e39fb62 100644 (file)
@@ -33,7 +33,7 @@
 #define        DBG(x...)
 #endif
 
-extern char irq_tab_jbs[][5];
+extern char pnx8550_irq_tab[][5];
 
 void __init pcibios_fixup_resources(struct pci_dev *dev)
 {
@@ -47,7 +47,7 @@ void __init pcibios_fixup(void)
 
 int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
-       return irq_tab_jbs[slot][pin];
+       return pnx8550_irq_tab[slot][pin];
 }
 
 /* Do platform specific device initialization at pci_enable_device() time */
index f8952c1359cd8b0752ec97e91154527d3a768d3d..eb6ec11fef07b003303d4da27f822490140eef3a 100644 (file)
@@ -35,23 +35,15 @@ char * prom_getcmdline(void)
        return &(arcs_cmdline[0]);
 }
 
-void  prom_init_cmdline(void)
+void __init prom_init_cmdline(void)
 {
-       char *cp;
-       int actr;
-
-       actr = 1; /* Always ignore argv[0] */
+       int i;
 
-       cp = &(arcs_cmdline[0]);
-       while(actr < prom_argc) {
-               strcpy(cp, prom_argv[actr]);
-               cp += strlen(prom_argv[actr]);
-               *cp++ = ' ';
-               actr++;
+       arcs_cmdline[0] = '\0';
+       for (i = 0; i < prom_argc; i++) {
+               strcat(arcs_cmdline, prom_argv[i]);
+               strcat(arcs_cmdline, " ");
        }
-       if (cp != &(arcs_cmdline[0])) /* get rid of trailing space */
-               --cp;
-       *cp = '\0';
 }
 
 char *prom_getenv(char *envname)
index f78e0423dc98108fbe84869d5d46ebe2e0e3f751..98c3429e6e50327ce94d45c080c29c019eca604f 100644 (file)
@@ -28,9 +28,9 @@
 #include <linux/init.h>
 #include <int.h>
 
-char irq_tab_jbs[][5] __initdata = {
[8] = { -1, PNX8550_INT_PCI_INTA, 0xff, 0xff, 0xff},
[9] = { -1, PNX8550_INT_PCI_INTA, 0xff, 0xff, 0xff},
[17] =        { -1, PNX8550_INT_PCI_INTA, 0xff, 0xff, 0xff},
+char pnx8550_irq_tab[][5] __initdata = {
      [8]     = { -1, PNX8550_INT_PCI_INTA, 0xff, 0xff, 0xff},
      [9]     = { -1, PNX8550_INT_PCI_INTA, 0xff, 0xff, 0xff},
      [17]    = { -1, PNX8550_INT_PCI_INTA, 0xff, 0xff, 0xff},
 };
 
diff --git a/arch/mips/philips/pnx8550/stb810/Makefile b/arch/mips/philips/pnx8550/stb810/Makefile
new file mode 100644 (file)
index 0000000..f14b592
--- /dev/null
@@ -0,0 +1,4 @@
+
+# Makefile for the Philips STB810 Board.
+
+lib-y := prom_init.o board_setup.o irqmap.o
diff --git a/arch/mips/philips/pnx8550/stb810/board_setup.c b/arch/mips/philips/pnx8550/stb810/board_setup.c
new file mode 100644 (file)
index 0000000..345d71e
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *  STB810 specific board startup routines.
+ *
+ *  Based on the arch/mips/philips/pnx8550/jbs/board_setup.c
+ *
+ *  Author: MontaVista Software, Inc.
+ *          source@mvista.com
+ *
+ *  Copyright 2005 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 as published by the
+ *  Free Software Foundation; either version 2 of the License, or (at your
+ *  option) any later version.
+ */
+
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/ioport.h>
+#include <linux/mm.h>
+#include <linux/console.h>
+#include <linux/mc146818rtc.h>
+#include <linux/delay.h>
+
+#include <asm/cpu.h>
+#include <asm/bootinfo.h>
+#include <asm/irq.h>
+#include <asm/mipsregs.h>
+#include <asm/reboot.h>
+#include <asm/pgtable.h>
+
+#include <glb.h>
+
+void __init board_setup(void)
+{
+       unsigned long config0, configpr;
+
+       config0 = read_c0_config();
+
+       /* clear all three cache coherency fields */
+       config0 &= ~(0x7 | (7<<25) | (7<<28));
+       config0 |= (CONF_CM_DEFAULT | (CONF_CM_DEFAULT<<25) |
+                       (CONF_CM_DEFAULT<<28));
+       write_c0_config(config0);
+
+       configpr = read_c0_config7();
+       configpr |= (1<<19); /* enable tlb */
+       write_c0_config7(configpr);
+}
diff --git a/arch/mips/philips/pnx8550/stb810/irqmap.c b/arch/mips/philips/pnx8550/stb810/irqmap.c
new file mode 100644 (file)
index 0000000..5ee11e1
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ *  Philips STB810 board irqmap.
+ *
+ *  Author: MontaVista Software, Inc.
+ *          source@mvista.com
+ *
+ *  Copyright 2005 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 as published by the
+ *  Free Software Foundation; either version 2 of the License, or (at your
+ *  option) any later version.
+ */
+
+#include <linux/init.h>
+#include <int.h>
+
+char pnx8550_irq_tab[][5] __initdata = {
+       [8]     = { -1, PNX8550_INT_PCI_INTA, 0xff, 0xff, 0xff},
+       [9]     = { -1, PNX8550_INT_PCI_INTA, 0xff, 0xff, 0xff},
+       [10]    = { -1, PNX8550_INT_PCI_INTA, 0xff, 0xff, 0xff},
+};
+
diff --git a/arch/mips/philips/pnx8550/stb810/prom_init.c b/arch/mips/philips/pnx8550/stb810/prom_init.c
new file mode 100644 (file)
index 0000000..ea5b4e0
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *  STB810 specific prom routines
+ *
+ *  Author: MontaVista Software, Inc.
+ *          source@mvista.com
+ *
+ *  Copyright 2005 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 as published by the
+ *  Free Software Foundation; either version 2 of the License, or (at your
+ *  option) any later version.
+ */
+
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <linux/bootmem.h>
+#include <asm/addrspace.h>
+#include <asm/bootinfo.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+
+int prom_argc;
+char **prom_argv, **prom_envp;
+extern void  __init prom_init_cmdline(void);
+extern char *prom_getenv(char *envname);
+
+const char *get_system_type(void)
+{
+       return "Philips PNX8550/STB810";
+}
+
+void __init prom_init(void)
+{
+       unsigned long memsize;
+
+       prom_argc = (int) fw_arg0;
+       prom_argv = (char **) fw_arg1;
+       prom_envp = (char **) fw_arg2;
+
+       prom_init_cmdline();
+
+       mips_machgroup = MACH_GROUP_PHILIPS;
+       mips_machtype = MACH_PHILIPS_STB810;
+
+       memsize = 0x08000000; /* Trimedia uses memory above */
+       add_memory_region(0, memsize, BOOT_MEM_RAM);
+}
index 5a5ea6c0b9f6d2b49531c187945414c357aeba48..b54b529a29f9af209944eb2a77dc1aa916f53550 100644 (file)
@@ -158,7 +158,6 @@ JP7 is not bus master -- do NOT use -- only 4 pci bus master's allowed -- SouthB
 #define TOSHIBA_RBTX4927_IRQ_ISA_ENABLE    ( 1 << 23 )
 #define TOSHIBA_RBTX4927_IRQ_ISA_DISABLE   ( 1 << 24 )
 #define TOSHIBA_RBTX4927_IRQ_ISA_MASK      ( 1 << 25 )
-#define TOSHIBA_RBTX4927_IRQ_ISA_ENDIRQ    ( 1 << 26 )
 
 #define TOSHIBA_RBTX4927_SETUP_ALL         0xffffffff
 #endif
@@ -175,7 +174,6 @@ static const u32 toshiba_rbtx4927_irq_debug_flag =
 //                                                 | TOSHIBA_RBTX4927_IRQ_ISA_ENABLE
 //                                                 | TOSHIBA_RBTX4927_IRQ_ISA_DISABLE
 //                                                 | TOSHIBA_RBTX4927_IRQ_ISA_MASK
-//                                                 | TOSHIBA_RBTX4927_IRQ_ISA_ENDIRQ
     );
 #endif
 
@@ -226,7 +224,6 @@ static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq);
 static void toshiba_rbtx4927_irq_isa_enable(unsigned int irq);
 static void toshiba_rbtx4927_irq_isa_disable(unsigned int irq);
 static void toshiba_rbtx4927_irq_isa_mask_and_ack(unsigned int irq);
-static void toshiba_rbtx4927_irq_isa_end(unsigned int irq);
 #endif
 
 #define TOSHIBA_RBTX4927_IOC_NAME "RBTX4927-IOC"
@@ -249,7 +246,6 @@ static struct irq_chip toshiba_rbtx4927_irq_isa_type = {
        .mask = toshiba_rbtx4927_irq_isa_disable,
        .mask_ack = toshiba_rbtx4927_irq_isa_mask_and_ack,
        .unmask = toshiba_rbtx4927_irq_isa_enable,
-       .end = toshiba_rbtx4927_irq_isa_end,
 };
 #endif
 
@@ -402,7 +398,8 @@ static void __init toshiba_rbtx4927_irq_isa_init(void)
 
        for (i = TOSHIBA_RBTX4927_IRQ_ISA_BEG;
             i <= TOSHIBA_RBTX4927_IRQ_ISA_END; i++)
-               set_irq_chip(i, &toshiba_rbtx4927_irq_isa_type);
+               set_irq_chip_and_handler(i, &toshiba_rbtx4927_irq_isa_type,
+                                        handle_level_irq);
 
        setup_irq(TOSHIBA_RBTX4927_IRQ_NEST_ISA_ON_IOC,
                  &toshiba_rbtx4927_irq_isa_master);
@@ -470,26 +467,6 @@ static void toshiba_rbtx4927_irq_isa_mask_and_ack(unsigned int irq)
 #endif
 
 
-#ifdef CONFIG_TOSHIBA_FPCIB0
-static void toshiba_rbtx4927_irq_isa_end(unsigned int irq)
-{
-       TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_ISA_ENDIRQ,
-                                    "irq=%d\n", irq);
-
-       if (irq < TOSHIBA_RBTX4927_IRQ_ISA_BEG
-           || irq > TOSHIBA_RBTX4927_IRQ_ISA_END) {
-               TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_EROR,
-                                            "bad irq=%d\n", irq);
-               panic("\n");
-       }
-
-       if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
-               toshiba_rbtx4927_irq_isa_enable(irq);
-       }
-}
-#endif
-
-
 void __init arch_init_irq(void)
 {
        extern void tx4927_irq_init(void);
index c8dfd8092cab72c6d0a1fc39098a30a0c55e9c4c..92f41f6f934a3bea38e9b9184ec68c9c4710370d 100644 (file)
@@ -6,7 +6,6 @@ config CASIO_E55
        select ISA
        select SYS_SUPPORTS_32BIT_KERNEL
        select SYS_SUPPORTS_LITTLE_ENDIAN
-       select GENERIC_HARDIRQS_NO__DO_IRQ
 
 config IBM_WORKPAD
        bool "Support for IBM WorkPad z50"
@@ -16,7 +15,6 @@ config IBM_WORKPAD
        select ISA
        select SYS_SUPPORTS_32BIT_KERNEL
        select SYS_SUPPORTS_LITTLE_ENDIAN
-       select GENERIC_HARDIRQS_NO__DO_IRQ
 
 config NEC_CMBVR4133
        bool "Support for NEC CMB-VR4133"
@@ -41,7 +39,6 @@ config TANBAC_TB022X
        select IRQ_CPU
        select SYS_SUPPORTS_32BIT_KERNEL
        select SYS_SUPPORTS_LITTLE_ENDIAN
-       select GENERIC_HARDIRQS_NO__DO_IRQ
        help
          The TANBAC VR4131 multichip module(TB0225) and
          the TANBAC VR4131DIMM(TB0229) are MIPS-based platforms
@@ -74,7 +71,6 @@ config VICTOR_MPC30X
        select IRQ_CPU
        select SYS_SUPPORTS_32BIT_KERNEL
        select SYS_SUPPORTS_LITTLE_ENDIAN
-       select GENERIC_HARDIRQS_NO__DO_IRQ
 
 config ZAO_CAPCELLA
        bool "Support for ZAO Networks Capcella"
@@ -84,7 +80,6 @@ config ZAO_CAPCELLA
        select IRQ_CPU
        select SYS_SUPPORTS_32BIT_KERNEL
        select SYS_SUPPORTS_LITTLE_ENDIAN
-       select GENERIC_HARDIRQS_NO__DO_IRQ
 
 config PCI_VR41XX
        bool "Add PCI control unit support of NEC VR4100 series"
index a039bb7251ffa4e0fc40b61421c6ccdf07b47c0f..128ed8d6f1119d0ae995c8adc68b60a55ed61d2a 100644 (file)
@@ -45,19 +45,12 @@ static void ack_i8259_irq(unsigned int irq)
        mask_and_ack_8259A(irq - I8259_IRQ_BASE);
 }
 
-static void end_i8259_irq(unsigned int irq)
-{
-       if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
-               enable_8259A_irq(irq - I8259_IRQ_BASE);
-}
-
 static struct irq_chip i8259_irq_type = {
        .typename       = "XT-PIC",
        .ack            = ack_i8259_irq,
        .mask           = disable_i8259_irq,
        .mask_ack       = ack_i8259_irq,
        .unmask         = enable_i8259_irq,
-       .end            = end_i8259_irq,
 };
 
 static int i8259_get_irq_number(int irq)
@@ -92,7 +85,7 @@ void __init rockhopper_init_irq(void)
        }
 
        for (i = I8259_IRQ_BASE; i <= I8259_IRQ_LAST; i++)
-               set_irq_chip(i, &i8259_irq_type);
+               set_irq_chip_and_handler(i, &i8259_irq_type, handle_level_irq);
 
        setup_irq(I8259_SLAVE_IRQ, &i8259_slave_cascade);
 
index d2101237442e8bbfa345788f4b49c950d6848a17..0f9ff618c6d7205c7d86f856cd78b9898b89e85a 100644 (file)
@@ -25,6 +25,14 @@ config RWSEM_GENERIC_SPINLOCK
 config RWSEM_XCHGADD_ALGORITHM
        bool
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 config GENERIC_FIND_NEXT_BIT
        bool
        default y
index 2e2dc4f2c853edee44818110eee1d44e5d85d1b9..d88309209f568815de1aa3bba81f2744fba2c4ac 100644 (file)
@@ -237,7 +237,7 @@ asmlinkage long hpux_fstatfs(unsigned int fd, struct hpux_statfs __user * buf)
        file = fget(fd);
        if (!file)
                goto out;
-       error = vfs_statfs_hpux(file->f_dentry, &tmp);
+       error = vfs_statfs_hpux(file->f_path.dentry, &tmp);
        if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
                error = -EFAULT;
        fput(file);
index 1e64e7b88110157df77334416f7d8a703bea4449..ecb10a4f63c6af15324cb7343951701b04aaba1f 100644 (file)
@@ -75,7 +75,6 @@ struct elf_prpsinfo32
        char    pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
 };
 
-#define elf_addr_t     unsigned int
 #define init_elf_binfmt init_elf32_binfmt
 
 #define ELF_PLATFORM  ("PARISC32\0")
index 64785e46f93b777297f23d7ae5139fe7bfb280c3..641f9c920eeef58e0e627467db3b6bf2c06b731a 100644 (file)
@@ -152,7 +152,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,
        const struct exception_table_entry *fix;
        unsigned long acc_type;
 
-       if (in_interrupt() || !mm)
+       if (in_atomic() || !mm)
                goto no_context;
 
        down_read(&mm->mmap_sem);
index 47a1d2ac941968086d089320ab86aaedb4f3c68f..44b42c7f639d073b0339396a8ecd8d4c908f7340 100644 (file)
@@ -9,110 +9,8 @@
 #include <linux/vmalloc.h>
 #include <linux/errno.h>
 #include <linux/module.h>
-#include <asm/io.h>
+#include <linux/io.h>
 #include <asm/pgalloc.h>
-#include <asm/tlbflush.h>
-#include <asm/cacheflush.h>
-
-static inline void 
-remap_area_pte(pte_t *pte, unsigned long address, unsigned long size,
-              unsigned long phys_addr, unsigned long flags)
-{
-       unsigned long end, pfn;
-       pgprot_t pgprot = __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY |
-                                  _PAGE_ACCESSED | flags);
-
-       address &= ~PMD_MASK;
-
-       end = address + size;
-       if (end > PMD_SIZE)
-               end = PMD_SIZE;
-
-       BUG_ON(address >= end);
-
-       pfn = phys_addr >> PAGE_SHIFT;
-       do {
-               BUG_ON(!pte_none(*pte));
-
-               set_pte(pte, pfn_pte(pfn, pgprot));
-
-               address += PAGE_SIZE;
-               pfn++;
-               pte++;
-       } while (address && (address < end));
-}
-
-static inline int 
-remap_area_pmd(pmd_t *pmd, unsigned long address, unsigned long size,
-              unsigned long phys_addr, unsigned long flags)
-{
-       unsigned long end;
-
-       address &= ~PGDIR_MASK;
-
-       end = address + size;
-       if (end > PGDIR_SIZE)
-               end = PGDIR_SIZE;
-
-       BUG_ON(address >= end);
-
-       phys_addr -= address;
-       do {
-               pte_t *pte = pte_alloc_kernel(pmd, address);
-               if (!pte)
-                       return -ENOMEM;
-
-               remap_area_pte(pte, address, end - address, 
-                              address + phys_addr, flags);
-
-               address = (address + PMD_SIZE) & PMD_MASK;
-               pmd++;
-       } while (address && (address < end));
-
-       return 0;
-}
-
-static int 
-remap_area_pages(unsigned long address, unsigned long phys_addr,
-                unsigned long size, unsigned long flags)
-{
-       pgd_t *dir;
-       int error = 0;
-       unsigned long end = address + size;
-
-       BUG_ON(address >= end);
-
-       phys_addr -= address;
-       dir = pgd_offset_k(address);
-
-       flush_cache_all();
-
-       do {
-               pud_t *pud;
-               pmd_t *pmd;
-
-               error = -ENOMEM;
-               pud = pud_alloc(&init_mm, dir, address);
-               if (!pud)
-                       break;
-
-               pmd = pmd_alloc(&init_mm, pud, address);
-               if (!pmd)
-                       break;
-
-               if (remap_area_pmd(pmd, address, end - address,
-                                  phys_addr + address, flags))
-                       break;
-
-               error = 0;
-               address = (address + PGDIR_SIZE) & PGDIR_MASK;
-               dir++;
-       } while (address && (address < end));
-
-       flush_tlb_all();
-
-       return error;
-}
 
 /*
  * Generic mapping function (not visible outside):
@@ -131,6 +29,7 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l
        void *addr;
        struct vm_struct *area;
        unsigned long offset, last_addr;
+       pgprot_t pgprot;
 
 #ifdef CONFIG_EISA
        unsigned long end = phys_addr + size - 1;
@@ -164,6 +63,9 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l
                }
        }
 
+       pgprot = __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY |
+                         _PAGE_ACCESSED | flags);
+
        /*
         * Mappings have to be page-aligned
         */
@@ -179,7 +81,8 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l
                return NULL;
 
        addr = area->addr;
-       if (remap_area_pages((unsigned long) addr, phys_addr, size, flags)) {
+       if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size,
+                              phys_addr, pgprot)) {
                vfree(addr);
                return NULL;
        }
index 291c95ac4b313d4f791367f583ead200a4b11788..56c3c4065eb0c354fab33618ded153b43a1648b7 100644 (file)
@@ -41,6 +41,14 @@ config RWSEM_XCHGADD_ALGORITHM
        bool
        default y
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default y
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default y if 64BIT
+
 config GENERIC_HWEIGHT
        bool
        default y
index 89b03c8da9d289ba6133dc41f83ec405fdb794ae..d3f2080d2eeeb3719778352b7f39c4bb2ce7b637 100644 (file)
@@ -46,61 +46,6 @@ int crashing_cpu = -1;
 static cpumask_t cpus_in_crash = CPU_MASK_NONE;
 cpumask_t cpus_in_sr = CPU_MASK_NONE;
 
-static u32 *append_elf_note(u32 *buf, char *name, unsigned type, void *data,
-                                                              size_t data_len)
-{
-       struct elf_note note;
-
-       note.n_namesz = strlen(name) + 1;
-       note.n_descsz = data_len;
-       note.n_type   = type;
-       memcpy(buf, &note, sizeof(note));
-       buf += (sizeof(note) +3)/4;
-       memcpy(buf, name, note.n_namesz);
-       buf += (note.n_namesz + 3)/4;
-       memcpy(buf, data, note.n_descsz);
-       buf += (note.n_descsz + 3)/4;
-
-       return buf;
-}
-
-static void final_note(u32 *buf)
-{
-       struct elf_note note;
-
-       note.n_namesz = 0;
-       note.n_descsz = 0;
-       note.n_type   = 0;
-       memcpy(buf, &note, sizeof(note));
-}
-
-static void crash_save_this_cpu(struct pt_regs *regs, int cpu)
-{
-       struct elf_prstatus prstatus;
-       u32 *buf;
-
-       if ((cpu < 0) || (cpu >= NR_CPUS))
-               return;
-
-       /* Using ELF notes here is opportunistic.
-        * I need a well defined structure format
-        * for the data I pass, and I need tags
-        * on the data to indicate what information I have
-        * squirrelled away.  ELF notes happen to provide
-        * all of that that no need to invent something new.
-        */
-       buf = (u32*)per_cpu_ptr(crash_notes, cpu);
-       if (!buf) 
-               return;
-
-       memset(&prstatus, 0, sizeof(prstatus));
-       prstatus.pr_pid = current->pid;
-       elf_core_copy_regs(&prstatus.pr_reg, regs);
-       buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
-                       sizeof(prstatus));
-       final_note(buf);
-}
-
 #ifdef CONFIG_SMP
 static atomic_t enter_on_soft_reset = ATOMIC_INIT(0);
 
@@ -113,7 +58,7 @@ void crash_ipi_callback(struct pt_regs *regs)
 
        hard_irq_disable();
        if (!cpu_isset(cpu, cpus_in_crash))
-               crash_save_this_cpu(regs, cpu);
+               crash_save_cpu(regs, cpu);
        cpu_set(cpu, cpus_in_crash);
 
        /*
@@ -306,7 +251,7 @@ void default_machine_crash_shutdown(struct pt_regs *regs)
         * such that another IPI will not be sent.
         */
        crashing_cpu = smp_processor_id();
-       crash_save_this_cpu(regs, crashing_cpu);
+       crash_save_cpu(regs, crashing_cpu);
        crash_kexec_prepare_cpus(crashing_cpu);
        cpu_set(crashing_cpu, cpus_in_crash);
        if (ppc_md.kexec_cpu_down)
index 7b8d12b9026c48487fbad3a4b83ca682108db260..4657563f88139ea60d4f4e4775c0cd8a33b15d42 100644 (file)
@@ -85,7 +85,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
 void __kprobes arch_remove_kprobe(struct kprobe *p)
 {
        mutex_lock(&kprobe_mutex);
-       free_insn_slot(p->ainsn.insn);
+       free_insn_slot(p->ainsn.insn, 0);
        mutex_unlock(&kprobe_mutex);
 }
 
index f598cb5195395d3ee3c53b584f8fdf71de0d4302..dd7001cacf75cfc09040b05961c39bb7c0471cfd 100644 (file)
@@ -83,7 +83,7 @@ __initcall(proc_ppc64_init);
 static loff_t page_map_seek( struct file *file, loff_t off, int whence)
 {
        loff_t new;
-       struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *dp = PDE(file->f_path.dentry->d_inode);
 
        switch(whence) {
        case 0:
@@ -106,13 +106,13 @@ static loff_t page_map_seek( struct file *file, loff_t off, int whence)
 static ssize_t page_map_read( struct file *file, char __user *buf, size_t nbytes,
                              loff_t *ppos)
 {
-       struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *dp = PDE(file->f_path.dentry->d_inode);
        return simple_read_from_buffer(buf, nbytes, ppos, dp->data, dp->size);
 }
 
 static int page_map_mmap( struct file *file, struct vm_area_struct *vma )
 {
-       struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *dp = PDE(file->f_path.dentry->d_inode);
 
        if ((vma->vm_end - vma->vm_start) > dp->size)
                return -EINVAL;
index b9561d300516d7d6f98b2de749102207ce43f050..0c4fcd34bfe585ce199271ec7f73fcc549e9d171 100644 (file)
@@ -101,7 +101,7 @@ struct flash_block_list_header { /* just the header of flash_block_list */
 static struct flash_block_list_header rtas_firmware_flash_list = {0, NULL};
 
 /* Use slab cache to guarantee 4k alignment */
-static kmem_cache_t *flash_block_cache = NULL;
+static struct kmem_cache *flash_block_cache = NULL;
 
 #define FLASH_BLOCK_LIST_VERSION (1UL)
 
@@ -193,7 +193,7 @@ static void free_flash_list(struct flash_block_list *f)
 
 static int rtas_flash_release(struct inode *inode, struct file *file)
 {
-       struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *dp = PDE(file->f_path.dentry->d_inode);
        struct rtas_update_flash_t *uf;
        
        uf = (struct rtas_update_flash_t *) dp->data;
@@ -255,7 +255,7 @@ static void get_flash_status_msg(int status, char *buf)
 static ssize_t rtas_flash_read(struct file *file, char __user *buf,
                               size_t count, loff_t *ppos)
 {
-       struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *dp = PDE(file->f_path.dentry->d_inode);
        struct rtas_update_flash_t *uf;
        char msg[RTAS_MSG_MAXLEN];
        int msglen;
@@ -286,7 +286,7 @@ static ssize_t rtas_flash_read(struct file *file, char __user *buf,
 }
 
 /* constructor for flash_block_cache */
-void rtas_block_ctor(void *ptr, kmem_cache_t *cache, unsigned long flags)
+void rtas_block_ctor(void *ptr, struct kmem_cache *cache, unsigned long flags)
 {
        memset(ptr, 0, RTAS_BLK_SIZE);
 }
@@ -299,7 +299,7 @@ void rtas_block_ctor(void *ptr, kmem_cache_t *cache, unsigned long flags)
 static ssize_t rtas_flash_write(struct file *file, const char __user *buffer,
                                size_t count, loff_t *off)
 {
-       struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *dp = PDE(file->f_path.dentry->d_inode);
        struct rtas_update_flash_t *uf;
        char *p;
        int next_free;
@@ -391,7 +391,7 @@ static void manage_flash(struct rtas_manage_flash_t *args_buf)
 static ssize_t manage_flash_read(struct file *file, char __user *buf,
                               size_t count, loff_t *ppos)
 {
-       struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *dp = PDE(file->f_path.dentry->d_inode);
        struct rtas_manage_flash_t *args_buf;
        char msg[RTAS_MSG_MAXLEN];
        int msglen;
@@ -421,7 +421,7 @@ static ssize_t manage_flash_read(struct file *file, char __user *buf,
 static ssize_t manage_flash_write(struct file *file, const char __user *buf,
                                size_t count, loff_t *off)
 {
-       struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *dp = PDE(file->f_path.dentry->d_inode);
        struct rtas_manage_flash_t *args_buf;
        const char reject_str[] = "0";
        const char commit_str[] = "1";
@@ -492,7 +492,7 @@ static int get_validate_flash_msg(struct rtas_validate_flash_t *args_buf,
 static ssize_t validate_flash_read(struct file *file, char __user *buf,
                               size_t count, loff_t *ppos)
 {
-       struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *dp = PDE(file->f_path.dentry->d_inode);
        struct rtas_validate_flash_t *args_buf;
        char msg[RTAS_MSG_MAXLEN];
        int msglen;
@@ -520,7 +520,7 @@ static ssize_t validate_flash_read(struct file *file, char __user *buf,
 static ssize_t validate_flash_write(struct file *file, const char __user *buf,
                                    size_t count, loff_t *off)
 {
-       struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *dp = PDE(file->f_path.dentry->d_inode);
        struct rtas_validate_flash_t *args_buf;
        int rc;
 
@@ -569,7 +569,7 @@ done:
 
 static int validate_flash_release(struct inode *inode, struct file *file)
 {
-       struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *dp = PDE(file->f_path.dentry->d_inode);
        struct rtas_validate_flash_t *args_buf;
 
        args_buf = (struct rtas_validate_flash_t *) dp->data;
index 320353f0926f99334aa3821d30cca981f28b4ff5..e4ebe1a6228e5e9a9ad32da2dd7f601f5f6afc61 100644 (file)
@@ -36,7 +36,7 @@
 #include <linux/stddef.h>
 #include <linux/tty.h>
 #include <linux/binfmts.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 #endif
 
 #include <asm/uaccess.h>
index 22123a0d5416cc35960093f22cd7f0e2f5a45819..63ed265b7f0936765a1cc7bc9356404acf679e68 100644 (file)
@@ -239,7 +239,7 @@ static void unregister_cpu_online(unsigned int cpu)
        struct cpu *c = &per_cpu(cpu_devices, cpu);
        struct sys_device *s = &c->sysdev;
 
-       BUG_ON(c->no_control);
+       BUG_ON(!c->hotpluggable);
 
        if (!firmware_has_feature(FW_FEATURE_ISERIES) &&
                        cpu_has_feature(CPU_FTR_SMT))
@@ -424,10 +424,10 @@ static int __init topology_init(void)
                 * CPU.  For instance, the boot cpu might never be valid
                 * for hotplugging.
                 */
-               if (!ppc_md.cpu_die)
-                       c->no_control = 1;
+               if (ppc_md.cpu_die)
+                       c->hotpluggable = 1;
 
-               if (cpu_online(cpu) || (c->no_control == 0)) {
+               if (cpu_online(cpu) || c->hotpluggable) {
                        register_cpu(c, cpu);
 
                        sysdev_create_file(&c->sysdev, &attr_physical_id);
index c913ad5cad2918e3daebe1251de37a18292f67c9..a4b28c73bba067e3fc7734b1c87dc46b67f1ceea 100644 (file)
@@ -264,7 +264,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
 
 
        /* Allocate a VMA structure and fill it up */
-       vma = kmem_cache_zalloc(vm_area_cachep, SLAB_KERNEL);
+       vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
        if (vma == NULL) {
                rc = -ENOMEM;
                goto fail_mmapsem;
index e8342d86753675d0ad20b3866bcdb12165d30d49..04b98671a0608d6ced7470712291bde24d3e01ac 100644 (file)
@@ -33,6 +33,7 @@ SECTIONS
 
        /* Text and gots */
        .text : {
+               _text = .;
                *(.text .text.*)
                SCHED_TEXT
                LOCK_TEXT
index 506d89768d455ba8625ed480d4122c7d1c8264c9..89c836d548096a96110c020a0383f5a711bf40fa 100644 (file)
@@ -146,6 +146,11 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
        return hugepte_offset(hpdp, addr);
 }
 
+int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
+{
+       return 0;
+}
+
 static void free_hugepte_range(struct mmu_gather *tlb, hugepd_t *hpdp)
 {
        pte_t *hugepte = hugepd_page(*hpdp);
@@ -1042,7 +1047,7 @@ repeat:
        return err;
 }
 
-static void zero_ctor(void *addr, kmem_cache_t *cache, unsigned long flags)
+static void zero_ctor(void *addr, struct kmem_cache *cache, unsigned long flags)
 {
        memset(addr, 0, kmem_cache_size(cache));
 }
index 9a178549cbcf327358e40cd6bfb0509fd91296d9..d12a87ec5ae99a5a5fde14e02d9e0bc64d50579d 100644 (file)
@@ -141,7 +141,7 @@ static int __init setup_kcore(void)
 }
 module_init(setup_kcore);
 
-static void zero_ctor(void *addr, kmem_cache_t *cache, unsigned long flags)
+static void zero_ctor(void *addr, struct kmem_cache *cache, unsigned long flags)
 {
        memset(addr, 0, kmem_cache_size(cache));
 }
@@ -166,9 +166,9 @@ static const char *pgtable_cache_name[ARRAY_SIZE(pgtable_cache_size)] = {
 /* Hugepages need one extra cache, initialized in hugetlbpage.c.  We
  * can't put into the tables above, because HPAGE_SHIFT is not compile
  * time constant. */
-kmem_cache_t *pgtable_cache[ARRAY_SIZE(pgtable_cache_size)+1];
+struct kmem_cache *pgtable_cache[ARRAY_SIZE(pgtable_cache_size)+1];
 #else
-kmem_cache_t *pgtable_cache[ARRAY_SIZE(pgtable_cache_size)];
+struct kmem_cache *pgtable_cache[ARRAY_SIZE(pgtable_cache_size)];
 #endif
 
 void pgtable_cache_init(void)
index c7d010749a181b14688a8f121c5deb5883d03b19..738b9244382fa5c851a9fcc353a43aaf28c14e2e 100644 (file)
@@ -40,7 +40,7 @@
 
 #include "spufs.h"
 
-static kmem_cache_t *spufs_inode_cache;
+static struct kmem_cache *spufs_inode_cache;
 char *isolated_loader;
 
 static struct inode *
@@ -48,7 +48,7 @@ spufs_alloc_inode(struct super_block *sb)
 {
        struct spufs_inode_info *ei;
 
-       ei = kmem_cache_alloc(spufs_inode_cache, SLAB_KERNEL);
+       ei = kmem_cache_alloc(spufs_inode_cache, GFP_KERNEL);
        if (!ei)
                return NULL;
 
@@ -65,7 +65,7 @@ spufs_destroy_inode(struct inode *inode)
 }
 
 static void
-spufs_init_once(void *p, kmem_cache_t * cachep, unsigned long flags)
+spufs_init_once(void *p, struct kmem_cache * cachep, unsigned long flags)
 {
        struct spufs_inode_info *ei = p;
 
@@ -205,7 +205,7 @@ static int spufs_dir_close(struct inode *inode, struct file *file)
        struct dentry *dir;
        int ret;
 
-       dir = file->f_dentry;
+       dir = file->f_path.dentry;
        parent = dir->d_parent->d_inode;
        ctx = SPUFS_I(dir->d_inode)->i_ctx;
 
@@ -363,7 +363,7 @@ static int spufs_gang_close(struct inode *inode, struct file *file)
        struct dentry *dir;
        int ret;
 
-       dir = file->f_dentry;
+       dir = file->f_path.dentry;
        parent = dir->d_parent->d_inode;
 
        ret = spufs_rmgang(parent, dir);
index a6d1ae4dc2a330797f7952008aef3495fd1cc67b..8e37bdf4dfdad4e7633540126a0227a35df7b2da 100644 (file)
@@ -46,7 +46,7 @@ static long do_spu_run(struct file *filp,
        if (filp->f_op != &spufs_context_fops)
                goto out;
 
-       i = SPUFS_I(filp->f_dentry->d_inode);
+       i = SPUFS_I(filp->f_path.dentry->d_inode);
        ret = spufs_run_spu(filp, i->i_ctx, &npc, &status);
 
        if (put_user(npc, unpc))
index b5737d68d6c4e41930ce2335456c24bcf82212df..cff15ae24f6ba8bf1184ce7cf2ad71e5f5a063f8 100644 (file)
@@ -1178,7 +1178,7 @@ static ssize_t proc_mf_change_vmlinux(struct file *file,
                                      const char __user *buf,
                                      size_t count, loff_t *ppos)
 {
-       struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *dp = PDE(file->f_path.dentry->d_inode);
        ssize_t rc;
        dma_addr_t dma_addr;
        char *page;
index 446e17d162a545e004c18779e61e8c5b4e398414..80181c4c49ebd7c356506ca45d8625b316c2c509 100644 (file)
@@ -85,7 +85,7 @@ static int hcall_inst_seq_open(struct inode *inode, struct file *file)
 
        rc = seq_open(file, &hcall_inst_seq_ops);
        seq = file->private_data;
-       seq->private = file->f_dentry->d_inode->i_private;
+       seq->private = file->f_path.dentry->d_inode->i_private;
 
        return rc;
 }
index 77a5bb1d9c3085f80292673f64002a60d77e4dd4..45368a57d7ddd02541a8db3a009031bab995cadb 100644 (file)
@@ -47,7 +47,7 @@ static struct proc_dir_entry *proc_ppc64_scan_log_dump;       /* The proc file */
 static ssize_t scanlog_read(struct file *file, char __user *buf,
                            size_t count, loff_t *ppos)
 {
-        struct inode * inode = file->f_dentry->d_inode;
+        struct inode * inode = file->f_path.dentry->d_inode;
        struct proc_dir_entry *dp;
        unsigned int *data;
        int status;
index 959d31c26cbb121836d2a56a3b39d8087defeba3..c71ef3c2e7bf4459dbf565e70287a8b01e6e96fa 100644 (file)
@@ -2165,7 +2165,7 @@ static int sq_release(struct inode *inode, struct file *file)
        int rc = 0;
 
        if (sq.busy)
-               rc = sq_fsync(file, file->f_dentry);
+               rc = sq_fsync(file, file->f_path.dentry);
        sound.soft = sound.dsp;
        sound.hard = sound.dsp;
        sound_silence();
@@ -2218,25 +2218,25 @@ static int sq_ioctl(struct inode *inode, struct file *file, u_int cmd,
                return 0;
        case SNDCTL_DSP_POST:
        case SNDCTL_DSP_SYNC:
-               return sq_fsync(file, file->f_dentry);
+               return sq_fsync(file, file->f_path.dentry);
 
                /* ++TeSche: before changing any of these it's
                 * probably wise to wait until sound playing has
                 * settled down. */
        case SNDCTL_DSP_SPEED:
-               sq_fsync(file, file->f_dentry);
+               sq_fsync(file, file->f_path.dentry);
                IOCTL_IN(arg, data);
                return IOCTL_OUT(arg, sound_set_speed(data));
        case SNDCTL_DSP_STEREO:
-               sq_fsync(file, file->f_dentry);
+               sq_fsync(file, file->f_path.dentry);
                IOCTL_IN(arg, data);
                return IOCTL_OUT(arg, sound_set_stereo(data));
        case SOUND_PCM_WRITE_CHANNELS:
-               sq_fsync(file, file->f_dentry);
+               sq_fsync(file, file->f_path.dentry);
                IOCTL_IN(arg, data);
                return IOCTL_OUT(arg, sound_set_stereo(data-1)+1);
        case SNDCTL_DSP_SETFMT:
-               sq_fsync(file, file->f_dentry);
+               sq_fsync(file, file->f_path.dentry);
                IOCTL_IN(arg, data);
                return IOCTL_OUT(arg, sound_set_format(data));
        case SNDCTL_DSP_GETFMTS:
index edf71a4ecc95d391138424bde84c90c3d209e171..692b5ba53209c27bdc7ac898d2be43c36889b887 100644 (file)
@@ -19,6 +19,14 @@ config RWSEM_XCHGADD_ALGORITHM
        bool
        default y
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default y
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 config GENERIC_HWEIGHT
        bool
        default y
@@ -52,6 +60,11 @@ config ARCH_MAY_HAVE_PC_FDC
        bool
        default y
 
+config GENERIC_BUG
+       bool
+       default y
+       depends on BUG
+
 source "init/Kconfig"
 
 menu "Processor"
index 2f835b9e95e488996d968c271581ae8a0f3117fe..810f7aa72e924528796aae3306af03587a8204b6 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/prctl.h>
+#include <linux/bug.h>
 
 #include <asm/pgtable.h>
 #include <asm/uaccess.h>
@@ -559,64 +560,9 @@ static void emulate_single_step(struct pt_regs *regs)
        }
 }
 
-/*
- * Look through the list of trap instructions that are used for BUG(),
- * BUG_ON() and WARN_ON() and see if we hit one.  At this point we know
- * that the exception was caused by a trap instruction of some kind.
- * Returns 1 if we should continue (i.e. it was a WARN_ON) or 0
- * otherwise.
- */
-extern struct bug_entry __start___bug_table[], __stop___bug_table[];
-
-#ifndef CONFIG_MODULES
-#define module_find_bug(x)     NULL
-#endif
-
-struct bug_entry *find_bug(unsigned long bugaddr)
-{
-       struct bug_entry *bug;
-
-       for (bug = __start___bug_table; bug < __stop___bug_table; ++bug)
-               if (bugaddr == bug->bug_addr)
-                       return bug;
-       return module_find_bug(bugaddr);
-}
-
-int check_bug_trap(struct pt_regs *regs)
+int is_valid_bugaddr(unsigned long addr)
 {
-       struct bug_entry *bug;
-       unsigned long addr;
-
-       if (regs->msr & MSR_PR)
-               return 0;       /* not in kernel */
-       addr = regs->nip;       /* address of trap instruction */
-       if (addr < PAGE_OFFSET)
-               return 0;
-       bug = find_bug(regs->nip);
-       if (bug == NULL)
-               return 0;
-       if (bug->line & BUG_WARNING_TRAP) {
-               /* this is a WARN_ON rather than BUG/BUG_ON */
-#ifdef CONFIG_XMON
-               xmon_printf(KERN_ERR "Badness in %s at %s:%ld\n",
-                      bug->function, bug->file,
-                      bug->line & ~BUG_WARNING_TRAP);
-#endif /* CONFIG_XMON */               
-               printk(KERN_ERR "Badness in %s at %s:%ld\n",
-                      bug->function, bug->file,
-                      bug->line & ~BUG_WARNING_TRAP);
-               dump_stack();
-               return 1;
-       }
-#ifdef CONFIG_XMON
-       xmon_printf(KERN_CRIT "kernel BUG in %s at %s:%ld!\n",
-              bug->function, bug->file, bug->line);
-       xmon(regs);
-#endif /* CONFIG_XMON */
-       printk(KERN_CRIT "kernel BUG in %s at %s:%ld!\n",
-              bug->function, bug->file, bug->line);
-
-       return 0;
+       return addr >= PAGE_OFFSET;
 }
 
 void program_check_exception(struct pt_regs *regs)
@@ -671,7 +617,9 @@ void program_check_exception(struct pt_regs *regs)
                /* trap exception */
                if (debugger_bpt(regs))
                        return;
-               if (check_bug_trap(regs)) {
+
+               if (!(regs->msr & MSR_PR) &&  /* not user-mode */
+                   report_bug(regs->nip) == BUG_TRAP_TYPE_WARN) {
                        regs->nip += 4;
                        return;
                }
index 16e8661e1fec331cf5fee951288ca6440de0e09b..61921268a0d00c290e7dfd1db163a8311d934461 100644 (file)
@@ -31,6 +31,7 @@ SECTIONS
   .plt : { *(.plt) }
   .text      :
   {
+    _text = .;
     *(.text)
     SCHED_TEXT
     LOCK_TEXT
index 583d9ff0a571a4c75a1370472e9c03ff7333a076..ff690564edbd329181e2310c0b6ed8a4364565b6 100644 (file)
@@ -22,6 +22,14 @@ config RWSEM_XCHGADD_ALGORITHM
        bool
        default y
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 config GENERIC_HWEIGHT
        bool
        default y
@@ -233,8 +241,14 @@ config WARN_STACK_SIZE
          This allows you to specify the maximum frame size a function may
          have without the compiler complaining about it.
 
+config ARCH_POPULATES_NODE_MAP
+       def_bool y
+
 source "mm/Kconfig"
 
+config HOLES_IN_ZONE
+       def_bool y
+
 comment "I/O subsystem configuration"
 
 config MACHCHK_WARNING
@@ -258,14 +272,6 @@ config QDIO
 
          If unsure, say Y.
 
-config QDIO_PERF_STATS
-       bool "Performance statistics in /proc"
-       depends on QDIO
-       help
-         Say Y here to get performance statistics in /proc/qdio_perf
-
-         If unsure, say N.
-
 config QDIO_DEBUG
        bool "Extended debugging information"
        depends on QDIO
index 67d5cf9cba83b2dcdc1288dcfd8fc0efd596f7c9..b8c2372902634c22db1f20162b966445ebf434a2 100644 (file)
@@ -561,7 +561,6 @@ appldata_offline_cpu(int cpu)
        spin_unlock(&appldata_timer_lock);
 }
 
-#ifdef CONFIG_HOTPLUG_CPU
 static int __cpuinit
 appldata_cpu_notify(struct notifier_block *self,
                    unsigned long action, void *hcpu)
@@ -582,7 +581,6 @@ appldata_cpu_notify(struct notifier_block *self,
 static struct notifier_block appldata_nb = {
        .notifier_call = appldata_cpu_notify,
 };
-#endif
 
 /*
  * appldata_init()
index 7cd51e73e27432c74761c6afbb98457753fdecfd..a6ec919ba83f14200569bad2a50b8192733e3ab2 100644 (file)
@@ -134,7 +134,6 @@ CONFIG_RESOURCES_64BIT=y
 #
 CONFIG_MACHCHK_WARNING=y
 CONFIG_QDIO=y
-# CONFIG_QDIO_PERF_STATS is not set
 # CONFIG_QDIO_DEBUG is not set
 
 #
index cd702ae45d6ddda9d52df2a5632278fcd34a5414..b6716c4b993400aa5e0236fa2189980349dc0df0 100644 (file)
@@ -109,7 +109,7 @@ static void hypfs_drop_inode(struct inode *inode)
 
 static int hypfs_open(struct inode *inode, struct file *filp)
 {
-       char *data = filp->f_dentry->d_inode->i_private;
+       char *data = filp->f_path.dentry->d_inode->i_private;
        struct hypfs_sb_info *fs_info;
 
        if (filp->f_mode & FMODE_WRITE) {
@@ -174,7 +174,7 @@ static ssize_t hypfs_aio_write(struct kiocb *iocb, const struct iovec *iov,
        struct hypfs_sb_info *fs_info;
        size_t count = iov_length(iov, nr_segs);
 
-       sb = iocb->ki_filp->f_dentry->d_inode->i_sb;
+       sb = iocb->ki_filp->f_path.dentry->d_inode->i_sb;
        fs_info = sb->s_fs_info;
        /*
         * Currently we only allow one update per second for two reasons:
index 9565a2dcfadcda474a4d5820a2a642d517c56be5..5c46054195cb29e484d9e9bb0c9c072f7fd91222 100644 (file)
@@ -176,7 +176,6 @@ struct elf_prpsinfo32
 
 #include <linux/highuid.h>
 
-#define elf_addr_t     u32
 /*
 #define init_elf_binfmt init_elf32_binfmt
 */
index 43f3d0c7e132372f05279073a6b60f869d2ef323..ef5266fbce62105e2574dc916ab87dbba2f08b70 100644 (file)
@@ -603,13 +603,13 @@ debug_open(struct inode *inode, struct file *file)
        debug_info_t *debug_info, *debug_info_snapshot;
 
        down(&debug_lock);
-       debug_info = file->f_dentry->d_inode->i_private;
+       debug_info = file->f_path.dentry->d_inode->i_private;
        /* find debug view */
        for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
                if (!debug_info->views[i])
                        continue;
                else if (debug_info->debugfs_entries[i] ==
-                        file->f_dentry) {
+                        file->f_path.dentry) {
                        goto found;     /* found view ! */
                }
        }
index 67914fe7f317cb6be4b9e864816e3020f8596e4f..576368c4f60585c4aa27fadea3fbd91e83327423 100644 (file)
@@ -200,7 +200,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
 void __kprobes arch_remove_kprobe(struct kprobe *p)
 {
        mutex_lock(&kprobe_mutex);
-       free_insn_slot(p->ainsn.insn);
+       free_insn_slot(p->ainsn.insn, 0);
        mutex_unlock(&kprobe_mutex);
 }
 
index b928fecdc743e61760364be8492a1735ebef0f9c..49ef206ec8806c6a6dc4ed0b0d9e211979065cf1 100644 (file)
@@ -64,9 +64,8 @@ unsigned int console_devno = -1;
 unsigned int console_irq = -1;
 unsigned long machine_flags = 0;
 
-struct mem_chunk memory_chunk[MEMORY_CHUNKS];
+struct mem_chunk __initdata memory_chunk[MEMORY_CHUNKS];
 volatile int __cpu_logical_map[NR_CPUS]; /* logical cpu to cpu address */
-unsigned long __initdata zholes_size[MAX_NR_ZONES];
 static unsigned long __initdata memory_end;
 
 /*
@@ -354,21 +353,6 @@ void machine_power_off(void)
  */
 void (*pm_power_off)(void) = machine_power_off;
 
-static void __init
-add_memory_hole(unsigned long start, unsigned long end)
-{
-       unsigned long dma_pfn = MAX_DMA_ADDRESS >> PAGE_SHIFT;
-
-       if (end <= dma_pfn)
-               zholes_size[ZONE_DMA] += end - start + 1;
-       else if (start > dma_pfn)
-               zholes_size[ZONE_NORMAL] += end - start + 1;
-       else {
-               zholes_size[ZONE_DMA] += dma_pfn - start + 1;
-               zholes_size[ZONE_NORMAL] += end - dma_pfn;
-       }
-}
-
 static int __init early_parse_mem(char *p)
 {
        memory_end = memparse(p, &p);
@@ -521,7 +505,6 @@ setup_memory(void)
 {
         unsigned long bootmap_size;
        unsigned long start_pfn, end_pfn, init_pfn;
-       unsigned long last_rw_end;
        int i;
 
        /*
@@ -577,39 +560,27 @@ setup_memory(void)
        /*
         * Register RAM areas with the bootmem allocator.
         */
-       last_rw_end = start_pfn;
 
        for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) {
-               unsigned long start_chunk, end_chunk;
+               unsigned long start_chunk, end_chunk, pfn;
 
                if (memory_chunk[i].type != CHUNK_READ_WRITE)
                        continue;
-               start_chunk = (memory_chunk[i].addr + PAGE_SIZE - 1);
-               start_chunk >>= PAGE_SHIFT;
-               end_chunk = (memory_chunk[i].addr + memory_chunk[i].size);
-               end_chunk >>= PAGE_SHIFT;
-               if (start_chunk < start_pfn)
-                       start_chunk = start_pfn;
-               if (end_chunk > end_pfn)
-                       end_chunk = end_pfn;
-               if (start_chunk < end_chunk) {
-                       /* Initialize storage key for RAM pages */
-                       for (init_pfn = start_chunk ; init_pfn < end_chunk;
-                            init_pfn++)
-                               page_set_storage_key(init_pfn << PAGE_SHIFT,
-                                                    PAGE_DEFAULT_KEY);
-                       free_bootmem(start_chunk << PAGE_SHIFT,
-                                    (end_chunk - start_chunk) << PAGE_SHIFT);
-                       if (last_rw_end < start_chunk)
-                               add_memory_hole(last_rw_end, start_chunk - 1);
-                       last_rw_end = end_chunk;
-               }
+               start_chunk = PFN_DOWN(memory_chunk[i].addr);
+               end_chunk = start_chunk + PFN_DOWN(memory_chunk[i].size) - 1;
+               end_chunk = min(end_chunk, end_pfn);
+               if (start_chunk >= end_chunk)
+                       continue;
+               add_active_range(0, start_chunk, end_chunk);
+               pfn = max(start_chunk, start_pfn);
+               for (; pfn <= end_chunk; pfn++)
+                       page_set_storage_key(PFN_PHYS(pfn), PAGE_DEFAULT_KEY);
        }
 
        psw_set_key(PAGE_DEFAULT_KEY);
 
-       if (last_rw_end < end_pfn - 1)
-               add_memory_hole(last_rw_end, end_pfn - 1);
+       free_bootmem_with_active_regions(0, max_pfn);
+       reserve_bootmem(0, PFN_PHYS(start_pfn));
 
        /*
         * Reserve the bootmem bitmap itself as well. We do this in two
index 8741bdc09299bf320deb725988e7156ab9a8eac4..633249c3ba9180ea2aa75534b0b64458a6825191 100644 (file)
@@ -8,8 +8,8 @@
  */
 
 #include <linux/errno.h>
-#include <asm/uaccess.h>
 #include <linux/mm.h>
+#include <asm/uaccess.h>
 #include <asm/futex.h>
 
 static inline int __handle_fault(struct mm_struct *mm, unsigned long address,
@@ -60,8 +60,9 @@ out:
 
 out_of_memory:
        up_read(&mm->mmap_sem);
-       if (current->pid == 1) {
+       if (is_init(current)) {
                yield();
+               down_read(&mm->mmap_sem);
                goto survive;
        }
        printk("VM: killing process %s\n", current->comm);
index 2d549ed2e11399dfe17975fcae72aa512b9f52fe..bbaca66fa29356af1b0c7ea5589622f28aec4519 100644 (file)
@@ -11,7 +11,7 @@
 
 #include <linux/errno.h>
 #include <linux/mm.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <asm/futex.h>
 
 #ifndef __s390x__
@@ -258,7 +258,7 @@ int futex_atomic_op(int op, int __user *uaddr, int oparg, int *old)
 {
        int oldval = 0, newval, ret;
 
-       inc_preempt_count();
+       pagefault_disable();
 
        switch (op) {
        case FUTEX_OP_SET:
@@ -284,7 +284,7 @@ int futex_atomic_op(int op, int __user *uaddr, int oparg, int *old)
        default:
                ret = -ENOSYS;
        }
-       dec_preempt_count();
+       pagefault_enable();
        *old = oldval;
        return ret;
 }
index aa9a42b6e62d14668055f8c165388ac611687893..8e09db1edbb91a8cb835d35e7af6605d65c2364e 100644 (file)
@@ -2,6 +2,6 @@
 # Makefile for the linux s390-specific parts of the memory manager.
 #
 
-obj-y   := init.o fault.o ioremap.o extmem.o mmap.o
+obj-y   := init.o fault.o ioremap.o extmem.o mmap.o vmem.o
 obj-$(CONFIG_CMM) += cmm.o
 
index 9e9bc48463a546493f432df4164a1a49f3409259..775bf19e742be2051a74b74fe0c3b06367d8769b 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/bootmem.h>
 #include <linux/ctype.h>
 #include <asm/page.h>
+#include <asm/pgtable.h>
 #include <asm/ebcdic.h>
 #include <asm/errno.h>
 #include <asm/extmem.h>
@@ -237,65 +238,6 @@ query_segment_type (struct dcss_segment *seg)
        return rc;
 }
 
-/*
- * check if the given segment collides with guest storage.
- * returns 1 if this is the case, 0 if no collision was found
- */
-static int
-segment_overlaps_storage(struct dcss_segment *seg)
-{
-       int i;
-
-       for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) {
-               if (memory_chunk[i].type != CHUNK_READ_WRITE)
-                       continue;
-               if ((memory_chunk[i].addr >> 20) > (seg->end >> 20))
-                       continue;
-               if (((memory_chunk[i].addr + memory_chunk[i].size - 1) >> 20)
-                               < (seg->start_addr >> 20))
-                       continue;
-               return 1;
-       }
-       return 0;
-}
-
-/*
- * check if segment collides with other segments that are currently loaded
- * returns 1 if this is the case, 0 if no collision was found
- */
-static int
-segment_overlaps_others (struct dcss_segment *seg)
-{
-       struct list_head *l;
-       struct dcss_segment *tmp;
-
-       BUG_ON(!mutex_is_locked(&dcss_lock));
-       list_for_each(l, &dcss_list) {
-               tmp = list_entry(l, struct dcss_segment, list);
-               if ((tmp->start_addr >> 20) > (seg->end >> 20))
-                       continue;
-               if ((tmp->end >> 20) < (seg->start_addr >> 20))
-                       continue;
-               if (seg == tmp)
-                       continue;
-               return 1;
-       }
-       return 0;
-}
-
-/*
- * check if segment exceeds the kernel mapping range (detected or set via mem=)
- * returns 1 if this is the case, 0 if segment fits into the range
- */
-static inline int
-segment_exceeds_range (struct dcss_segment *seg)
-{
-       int seg_last_pfn = (seg->end) >> PAGE_SHIFT;
-       if (seg_last_pfn > max_pfn)
-               return 1;
-       return 0;
-}
-
 /*
  * get info about a segment
  * possible return values:
@@ -341,24 +283,26 @@ __segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long
        rc = query_segment_type (seg);
        if (rc < 0)
                goto out_free;
-       if (segment_exceeds_range(seg)) {
-               PRINT_WARN ("segment_load: not loading segment %s - exceeds"
-                               " kernel mapping range\n",name);
-               rc = -ERANGE;
+
+       rc = add_shared_memory(seg->start_addr, seg->end - seg->start_addr + 1);
+
+       switch (rc) {
+       case 0:
+               break;
+       case -ENOSPC:
+               PRINT_WARN("segment_load: not loading segment %s - overlaps "
+                          "storage/segment\n", name);
                goto out_free;
-       }
-       if (segment_overlaps_storage(seg)) {
-               PRINT_WARN ("segment_load: not loading segment %s - overlaps"
-                               " storage\n",name);
-               rc = -ENOSPC;
+       case -ERANGE:
+               PRINT_WARN("segment_load: not loading segment %s - exceeds "
+                          "kernel mapping range\n", name);
                goto out_free;
-       }
-       if (segment_overlaps_others(seg)) {
-               PRINT_WARN ("segment_load: not loading segment %s - overlaps"
-                               " other segments\n",name);
-               rc = -EBUSY;
+       default:
+               PRINT_WARN("segment_load: not loading segment %s (rc: %d)\n",
+                          name, rc);
                goto out_free;
        }
+
        if (do_nonshared)
                dcss_command = DCSS_LOADNSR;
        else
@@ -372,7 +316,7 @@ __segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long
                rc = dcss_diag_translate_rc (seg->end);
                dcss_diag(DCSS_PURGESEG, seg->dcss_name,
                                &seg->start_addr, &seg->end);
-               goto out_free;
+               goto out_shared;
        }
        seg->do_nonshared = do_nonshared;
        atomic_set(&seg->ref_count, 1);
@@ -391,6 +335,8 @@ __segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long
                                (void*)seg->start_addr, (void*)seg->end,
                                segtype_string[seg->vm_segtype]);
        goto out;
+ out_shared:
+       remove_shared_memory(seg->start_addr, seg->end - seg->start_addr + 1);
  out_free:
        kfree(seg);
  out:
@@ -530,12 +476,12 @@ segment_unload(char *name)
                                "please report to linux390@de.ibm.com\n",name);
                goto out_unlock;
        }
-       if (atomic_dec_return(&seg->ref_count) == 0) {
-               list_del(&seg->list);
-               dcss_diag(DCSS_PURGESEG, seg->dcss_name,
-                         &dummy, &dummy);
-               kfree(seg);
-       }
+       if (atomic_dec_return(&seg->ref_count) != 0)
+               goto out_unlock;
+       remove_shared_memory(seg->start_addr, seg->end - seg->start_addr + 1);
+       list_del(&seg->list);
+       dcss_diag(DCSS_PURGESEG, seg->dcss_name, &dummy, &dummy);
+       kfree(seg);
 out_unlock:
        mutex_unlock(&dcss_lock);
 }
index e1881c31b1cbc2384f28fb76e7e56990d8638151..4bb21be3b00709bf6f0dbea0ae3d06686d209d81 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/pagemap.h>
 #include <linux/bootmem.h>
 #include <linux/pfn.h>
+#include <linux/poison.h>
 
 #include <asm/processor.h>
 #include <asm/system.h>
@@ -69,6 +70,8 @@ void show_mem(void)
         printk("Free swap:       %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
         i = max_mapnr;
         while (i-- > 0) {
+               if (!pfn_valid(i))
+                       continue;
                page = pfn_to_page(i);
                 total++;
                if (PageReserved(page))
@@ -84,150 +87,52 @@ void show_mem(void)
         printk("%d pages swap cached\n",cached);
 }
 
-extern unsigned long __initdata zholes_size[];
-/*
- * paging_init() sets up the page tables
- */
-
-#ifndef CONFIG_64BIT
-void __init paging_init(void)
+static void __init setup_ro_region(void)
 {
-        pgd_t * pg_dir;
-        pte_t * pg_table;
-        pte_t   pte;
-       int     i;
-        unsigned long tmp;
-        unsigned long pfn = 0;
-        unsigned long pgdir_k = (__pa(swapper_pg_dir) & PAGE_MASK) | _KERNSEG_TABLE;
-        static const int ssm_mask = 0x04000000L;
-       unsigned long ro_start_pfn, ro_end_pfn;
-       unsigned long zones_size[MAX_NR_ZONES];
-
-       ro_start_pfn = PFN_DOWN((unsigned long)&__start_rodata);
-       ro_end_pfn = PFN_UP((unsigned long)&__end_rodata);
-
-       memset(zones_size, 0, sizeof(zones_size));
-       zones_size[ZONE_DMA] = max_low_pfn;
-       free_area_init_node(0, &contig_page_data, zones_size,
-                           __pa(PAGE_OFFSET) >> PAGE_SHIFT,
-                           zholes_size);
-
-       /* unmap whole virtual address space */
-       
-        pg_dir = swapper_pg_dir;
-
-       for (i = 0; i < PTRS_PER_PGD; i++)
-               pmd_clear((pmd_t *) pg_dir++);
-               
-       /*
-        * map whole physical memory to virtual memory (identity mapping) 
-        */
-
-        pg_dir = swapper_pg_dir;
-
-        while (pfn < max_low_pfn) {
-                /*
-                 * pg_table is physical at this point
-                 */
-               pg_table = (pte_t *) alloc_bootmem_pages(PAGE_SIZE);
-
-               pmd_populate_kernel(&init_mm, (pmd_t *) pg_dir, pg_table);
-                pg_dir++;
-
-                for (tmp = 0 ; tmp < PTRS_PER_PTE ; tmp++,pg_table++) {
-                       if (pfn >= ro_start_pfn && pfn < ro_end_pfn)
-                               pte = pfn_pte(pfn, __pgprot(_PAGE_RO));
-                       else
-                               pte = pfn_pte(pfn, PAGE_KERNEL);
-                        if (pfn >= max_low_pfn)
-                               pte_val(pte) = _PAGE_TYPE_EMPTY;
-                       set_pte(pg_table, pte);
-                        pfn++;
-                }
-        }
-
-       S390_lowcore.kernel_asce = pgdir_k;
-
-        /* enable virtual mapping in kernel mode */
-       __ctl_load(pgdir_k, 1, 1);
-       __ctl_load(pgdir_k, 7, 7);
-       __ctl_load(pgdir_k, 13, 13);
-       __raw_local_irq_ssm(ssm_mask);
-
-        local_flush_tlb();
+       pgd_t *pgd;
+       pmd_t *pmd;
+       pte_t *pte;
+       pte_t new_pte;
+       unsigned long address, end;
+
+       address = ((unsigned long)&__start_rodata) & PAGE_MASK;
+       end = PFN_ALIGN((unsigned long)&__end_rodata);
+
+       for (; address < end; address += PAGE_SIZE) {
+               pgd = pgd_offset_k(address);
+               pmd = pmd_offset(pgd, address);
+               pte = pte_offset_kernel(pmd, address);
+               new_pte = mk_pte_phys(address, __pgprot(_PAGE_RO));
+               set_pte(pte, new_pte);
+       }
 }
 
-#else /* CONFIG_64BIT */
+extern void vmem_map_init(void);
 
+/*
+ * paging_init() sets up the page tables
+ */
 void __init paging_init(void)
 {
-        pgd_t * pg_dir;
-       pmd_t * pm_dir;
-        pte_t * pt_dir;
-        pte_t   pte;
-       int     i,j,k;
-        unsigned long pfn = 0;
-        unsigned long pgdir_k = (__pa(swapper_pg_dir) & PAGE_MASK) |
-          _KERN_REGION_TABLE;
+       pgd_t *pg_dir;
+       int i;
+       unsigned long pgdir_k;
        static const int ssm_mask = 0x04000000L;
-       unsigned long zones_size[MAX_NR_ZONES];
-       unsigned long dma_pfn, high_pfn;
-       unsigned long ro_start_pfn, ro_end_pfn;
-
-       memset(zones_size, 0, sizeof(zones_size));
-       dma_pfn = MAX_DMA_ADDRESS >> PAGE_SHIFT;
-       high_pfn = max_low_pfn;
-       ro_start_pfn = PFN_DOWN((unsigned long)&__start_rodata);
-       ro_end_pfn = PFN_UP((unsigned long)&__end_rodata);
-
-       if (dma_pfn > high_pfn)
-               zones_size[ZONE_DMA] = high_pfn;
-       else {
-               zones_size[ZONE_DMA] = dma_pfn;
-               zones_size[ZONE_NORMAL] = high_pfn - dma_pfn;
-       }
-
-       /* Initialize mem_map[].  */
-       free_area_init_node(0, &contig_page_data, zones_size,
-                           __pa(PAGE_OFFSET) >> PAGE_SHIFT, zholes_size);
+       unsigned long max_zone_pfns[MAX_NR_ZONES];
 
-       /*
-        * map whole physical memory to virtual memory (identity mapping) 
-        */
-
-        pg_dir = swapper_pg_dir;
-       
-        for (i = 0 ; i < PTRS_PER_PGD ; i++,pg_dir++) {
+       pg_dir = swapper_pg_dir;
        
-                if (pfn >= max_low_pfn) {
-                        pgd_clear(pg_dir);
-                        continue;
-                }          
-        
-               pm_dir = (pmd_t *) alloc_bootmem_pages(PAGE_SIZE * 4);
-                pgd_populate(&init_mm, pg_dir, pm_dir);
-
-                for (j = 0 ; j < PTRS_PER_PMD ; j++,pm_dir++) {
-                        if (pfn >= max_low_pfn) {
-                                pmd_clear(pm_dir);
-                                continue; 
-                        }          
-                        
-                       pt_dir = (pte_t *) alloc_bootmem_pages(PAGE_SIZE);
-                        pmd_populate_kernel(&init_mm, pm_dir, pt_dir);
-       
-                        for (k = 0 ; k < PTRS_PER_PTE ; k++,pt_dir++) {
-                               if (pfn >= ro_start_pfn && pfn < ro_end_pfn)
-                                       pte = pfn_pte(pfn, __pgprot(_PAGE_RO));
-                               else
-                                       pte = pfn_pte(pfn, PAGE_KERNEL);
-                               if (pfn >= max_low_pfn)
-                                       pte_val(pte) = _PAGE_TYPE_EMPTY;
-                                set_pte(pt_dir, pte);
-                                pfn++;
-                        }
-                }
-        }
+#ifdef CONFIG_64BIT
+       pgdir_k = (__pa(swapper_pg_dir) & PAGE_MASK) | _KERN_REGION_TABLE;
+       for (i = 0; i < PTRS_PER_PGD; i++)
+               pgd_clear(pg_dir + i);
+#else
+       pgdir_k = (__pa(swapper_pg_dir) & PAGE_MASK) | _KERNSEG_TABLE;
+       for (i = 0; i < PTRS_PER_PGD; i++)
+               pmd_clear((pmd_t *)(pg_dir + i));
+#endif
+       vmem_map_init();
+       setup_ro_region();
 
        S390_lowcore.kernel_asce = pgdir_k;
 
@@ -237,9 +142,11 @@ void __init paging_init(void)
        __ctl_load(pgdir_k, 13, 13);
        __raw_local_irq_ssm(ssm_mask);
 
-        local_flush_tlb();
+       memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+       max_zone_pfns[ZONE_DMA] = PFN_DOWN(MAX_DMA_ADDRESS);
+       max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
+       free_area_init_nodes(max_zone_pfns);
 }
-#endif /* CONFIG_64BIT */
 
 void __init mem_init(void)
 {
@@ -269,6 +176,8 @@ void __init mem_init(void)
        printk("Write protected kernel read-only data: %#lx - %#lx\n",
               (unsigned long)&__start_rodata,
               PFN_ALIGN((unsigned long)&__end_rodata) - 1);
+       printk("Virtual memmap size: %ldk\n",
+              (max_pfn * sizeof(struct page)) >> 10);
 }
 
 void free_initmem(void)
@@ -279,6 +188,7 @@ void free_initmem(void)
         for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
                ClearPageReserved(virt_to_page(addr));
                init_page_count(virt_to_page(addr));
+               memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
                free_page(addr);
                totalram_pages++;
         }
index 0f6e9ecbefe279eac6a9eca550860ef5aecc81b6..3d2100a4e2097dc5f52e49f97db94ed7b51e0b28 100644 (file)
 
 #include <linux/vmalloc.h>
 #include <linux/mm.h>
-#include <asm/io.h>
+#include <linux/io.h>
 #include <asm/pgalloc.h>
-#include <asm/cacheflush.h>
-#include <asm/tlbflush.h>
-
-static inline void remap_area_pte(pte_t * pte, unsigned long address, unsigned long size,
-        unsigned long phys_addr, unsigned long flags)
-{
-        unsigned long end;
-        unsigned long pfn;
-
-        address &= ~PMD_MASK;
-        end = address + size;
-        if (end > PMD_SIZE)
-                end = PMD_SIZE;
-       if (address >= end)
-               BUG();
-        pfn = phys_addr >> PAGE_SHIFT;
-        do {
-                if (!pte_none(*pte)) {
-                        printk("remap_area_pte: page already exists\n");
-                       BUG();
-               }
-                set_pte(pte, pfn_pte(pfn, __pgprot(flags)));
-                address += PAGE_SIZE;
-                pfn++;
-                pte++;
-        } while (address && (address < end));
-}
-
-static inline int remap_area_pmd(pmd_t * pmd, unsigned long address, unsigned long size,
-        unsigned long phys_addr, unsigned long flags)
-{
-       unsigned long end;
-
-       address &= ~PGDIR_MASK;
-       end = address + size;
-       if (end > PGDIR_SIZE)
-               end = PGDIR_SIZE;
-       phys_addr -= address;
-       if (address >= end)
-               BUG();
-       do {
-               pte_t * pte = pte_alloc_kernel(pmd, address);
-               if (!pte)
-                       return -ENOMEM;
-               remap_area_pte(pte, address, end - address, address + phys_addr, flags);
-               address = (address + PMD_SIZE) & PMD_MASK;
-               pmd++;
-       } while (address && (address < end));
-       return 0;
-}
-
-static int remap_area_pages(unsigned long address, unsigned long phys_addr,
-                                unsigned long size, unsigned long flags)
-{
-       int error;
-       pgd_t * dir;
-       unsigned long end = address + size;
-
-       phys_addr -= address;
-       dir = pgd_offset(&init_mm, address);
-       flush_cache_all();
-       if (address >= end)
-               BUG();
-       do {
-               pmd_t *pmd;
-               pmd = pmd_alloc(&init_mm, dir, address);
-               error = -ENOMEM;
-               if (!pmd)
-                       break;
-               if (remap_area_pmd(pmd, address, end - address,
-                                        phys_addr + address, flags))
-                       break;
-               error = 0;
-               address = (address + PGDIR_SIZE) & PGDIR_MASK;
-               dir++;
-       } while (address && (address < end));
-       flush_tlb_all();
-       return 0;
-}
 
 /*
  * Generic mapping function (not visible outside):
@@ -122,7 +43,8 @@ void * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flag
        if (!area)
                return NULL;
        addr = area->addr;
-       if (remap_area_pages((unsigned long) addr, phys_addr, size, flags)) {
+       if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size,
+                              phys_addr, __pgprot(flags))) {
                vfree(addr);
                return NULL;
        }
diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c
new file mode 100644 (file)
index 0000000..7f2944d
--- /dev/null
@@ -0,0 +1,381 @@
+/*
+ *  arch/s390/mm/vmem.c
+ *
+ *    Copyright IBM Corp. 2006
+ *    Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
+ */
+
+#include <linux/bootmem.h>
+#include <linux/pfn.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/list.h>
+#include <asm/pgalloc.h>
+#include <asm/pgtable.h>
+#include <asm/setup.h>
+#include <asm/tlbflush.h>
+
+unsigned long vmalloc_end;
+EXPORT_SYMBOL(vmalloc_end);
+
+static struct page *vmem_map;
+static DEFINE_MUTEX(vmem_mutex);
+
+struct memory_segment {
+       struct list_head list;
+       unsigned long start;
+       unsigned long size;
+};
+
+static LIST_HEAD(mem_segs);
+
+void memmap_init(unsigned long size, int nid, unsigned long zone,
+                unsigned long start_pfn)
+{
+       struct page *start, *end;
+       struct page *map_start, *map_end;
+       int i;
+
+       start = pfn_to_page(start_pfn);
+       end = start + size;
+
+       for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) {
+               unsigned long cstart, cend;
+
+               cstart = PFN_DOWN(memory_chunk[i].addr);
+               cend = cstart + PFN_DOWN(memory_chunk[i].size);
+
+               map_start = mem_map + cstart;
+               map_end = mem_map + cend;
+
+               if (map_start < start)
+                       map_start = start;
+               if (map_end > end)
+                       map_end = end;
+
+               map_start -= ((unsigned long) map_start & (PAGE_SIZE - 1))
+                       / sizeof(struct page);
+               map_end += ((PFN_ALIGN((unsigned long) map_end)
+                            - (unsigned long) map_end)
+                           / sizeof(struct page));
+
+               if (map_start < map_end)
+                       memmap_init_zone((unsigned long)(map_end - map_start),
+                                        nid, zone, page_to_pfn(map_start));
+       }
+}
+
+static inline void *vmem_alloc_pages(unsigned int order)
+{
+       if (slab_is_available())
+               return (void *)__get_free_pages(GFP_KERNEL, order);
+       return alloc_bootmem_pages((1 << order) * PAGE_SIZE);
+}
+
+static inline pmd_t *vmem_pmd_alloc(void)
+{
+       pmd_t *pmd;
+       int i;
+
+       pmd = vmem_alloc_pages(PMD_ALLOC_ORDER);
+       if (!pmd)
+               return NULL;
+       for (i = 0; i < PTRS_PER_PMD; i++)
+               pmd_clear(pmd + i);
+       return pmd;
+}
+
+static inline pte_t *vmem_pte_alloc(void)
+{
+       pte_t *pte;
+       pte_t empty_pte;
+       int i;
+
+       pte = vmem_alloc_pages(PTE_ALLOC_ORDER);
+       if (!pte)
+               return NULL;
+       pte_val(empty_pte) = _PAGE_TYPE_EMPTY;
+       for (i = 0; i < PTRS_PER_PTE; i++)
+               set_pte(pte + i, empty_pte);
+       return pte;
+}
+
+/*
+ * Add a physical memory range to the 1:1 mapping.
+ */
+static int vmem_add_range(unsigned long start, unsigned long size)
+{
+       unsigned long address;
+       pgd_t *pg_dir;
+       pmd_t *pm_dir;
+       pte_t *pt_dir;
+       pte_t  pte;
+       int ret = -ENOMEM;
+
+       for (address = start; address < start + size; address += PAGE_SIZE) {
+               pg_dir = pgd_offset_k(address);
+               if (pgd_none(*pg_dir)) {
+                       pm_dir = vmem_pmd_alloc();
+                       if (!pm_dir)
+                               goto out;
+                       pgd_populate(&init_mm, pg_dir, pm_dir);
+               }
+
+               pm_dir = pmd_offset(pg_dir, address);
+               if (pmd_none(*pm_dir)) {
+                       pt_dir = vmem_pte_alloc();
+                       if (!pt_dir)
+                               goto out;
+                       pmd_populate_kernel(&init_mm, pm_dir, pt_dir);
+               }
+
+               pt_dir = pte_offset_kernel(pm_dir, address);
+               pte = pfn_pte(address >> PAGE_SHIFT, PAGE_KERNEL);
+               set_pte(pt_dir, pte);
+       }
+       ret = 0;
+out:
+       flush_tlb_kernel_range(start, start + size);
+       return ret;
+}
+
+/*
+ * Remove a physical memory range from the 1:1 mapping.
+ * Currently only invalidates page table entries.
+ */
+static void vmem_remove_range(unsigned long start, unsigned long size)
+{
+       unsigned long address;
+       pgd_t *pg_dir;
+       pmd_t *pm_dir;
+       pte_t *pt_dir;
+       pte_t  pte;
+
+       pte_val(pte) = _PAGE_TYPE_EMPTY;
+       for (address = start; address < start + size; address += PAGE_SIZE) {
+               pg_dir = pgd_offset_k(address);
+               if (pgd_none(*pg_dir))
+                       continue;
+               pm_dir = pmd_offset(pg_dir, address);
+               if (pmd_none(*pm_dir))
+                       continue;
+               pt_dir = pte_offset_kernel(pm_dir, address);
+               set_pte(pt_dir, pte);
+       }
+       flush_tlb_kernel_range(start, start + size);
+}
+
+/*
+ * Add a backed mem_map array to the virtual mem_map array.
+ */
+static int vmem_add_mem_map(unsigned long start, unsigned long size)
+{
+       unsigned long address, start_addr, end_addr;
+       struct page *map_start, *map_end;
+       pgd_t *pg_dir;
+       pmd_t *pm_dir;
+       pte_t *pt_dir;
+       pte_t  pte;
+       int ret = -ENOMEM;
+
+       map_start = vmem_map + PFN_DOWN(start);
+       map_end = vmem_map + PFN_DOWN(start + size);
+
+       start_addr = (unsigned long) map_start & PAGE_MASK;
+       end_addr = PFN_ALIGN((unsigned long) map_end);
+
+       for (address = start_addr; address < end_addr; address += PAGE_SIZE) {
+               pg_dir = pgd_offset_k(address);
+               if (pgd_none(*pg_dir)) {
+                       pm_dir = vmem_pmd_alloc();
+                       if (!pm_dir)
+                               goto out;
+                       pgd_populate(&init_mm, pg_dir, pm_dir);
+               }
+
+               pm_dir = pmd_offset(pg_dir, address);
+               if (pmd_none(*pm_dir)) {
+                       pt_dir = vmem_pte_alloc();
+                       if (!pt_dir)
+                               goto out;
+                       pmd_populate_kernel(&init_mm, pm_dir, pt_dir);
+               }
+
+               pt_dir = pte_offset_kernel(pm_dir, address);
+               if (pte_none(*pt_dir)) {
+                       unsigned long new_page;
+
+                       new_page =__pa(vmem_alloc_pages(0));
+                       if (!new_page)
+                               goto out;
+                       pte = pfn_pte(new_page >> PAGE_SHIFT, PAGE_KERNEL);
+                       set_pte(pt_dir, pte);
+               }
+       }
+       ret = 0;
+out:
+       flush_tlb_kernel_range(start_addr, end_addr);
+       return ret;
+}
+
+static int vmem_add_mem(unsigned long start, unsigned long size)
+{
+       int ret;
+
+       ret = vmem_add_range(start, size);
+       if (ret)
+               return ret;
+       return vmem_add_mem_map(start, size);
+}
+
+/*
+ * Add memory segment to the segment list if it doesn't overlap with
+ * an already present segment.
+ */
+static int insert_memory_segment(struct memory_segment *seg)
+{
+       struct memory_segment *tmp;
+
+       if (PFN_DOWN(seg->start + seg->size) > max_pfn ||
+           seg->start + seg->size < seg->start)
+               return -ERANGE;
+
+       list_for_each_entry(tmp, &mem_segs, list) {
+               if (seg->start >= tmp->start + tmp->size)
+                       continue;
+               if (seg->start + seg->size <= tmp->start)
+                       continue;
+               return -ENOSPC;
+       }
+       list_add(&seg->list, &mem_segs);
+       return 0;
+}
+
+/*
+ * Remove memory segment from the segment list.
+ */
+static void remove_memory_segment(struct memory_segment *seg)
+{
+       list_del(&seg->list);
+}
+
+static void __remove_shared_memory(struct memory_segment *seg)
+{
+       remove_memory_segment(seg);
+       vmem_remove_range(seg->start, seg->size);
+}
+
+int remove_shared_memory(unsigned long start, unsigned long size)
+{
+       struct memory_segment *seg;
+       int ret;
+
+       mutex_lock(&vmem_mutex);
+
+       ret = -ENOENT;
+       list_for_each_entry(seg, &mem_segs, list) {
+               if (seg->start == start && seg->size == size)
+                       break;
+       }
+
+       if (seg->start != start || seg->size != size)
+               goto out;
+
+       ret = 0;
+       __remove_shared_memory(seg);
+       kfree(seg);
+out:
+       mutex_unlock(&vmem_mutex);
+       return ret;
+}
+
+int add_shared_memory(unsigned long start, unsigned long size)
+{
+       struct memory_segment *seg;
+       struct page *page;
+       unsigned long pfn, num_pfn, end_pfn;
+       int ret;
+
+       mutex_lock(&vmem_mutex);
+       ret = -ENOMEM;
+       seg = kzalloc(sizeof(*seg), GFP_KERNEL);
+       if (!seg)
+               goto out;
+       seg->start = start;
+       seg->size = size;
+
+       ret = insert_memory_segment(seg);
+       if (ret)
+               goto out_free;
+
+       ret = vmem_add_mem(start, size);
+       if (ret)
+               goto out_remove;
+
+       pfn = PFN_DOWN(start);
+       num_pfn = PFN_DOWN(size);
+       end_pfn = pfn + num_pfn;
+
+       page = pfn_to_page(pfn);
+       memset(page, 0, num_pfn * sizeof(struct page));
+
+       for (; pfn < end_pfn; pfn++) {
+               page = pfn_to_page(pfn);
+               init_page_count(page);
+               reset_page_mapcount(page);
+               SetPageReserved(page);
+               INIT_LIST_HEAD(&page->lru);
+       }
+       goto out;
+
+out_remove:
+       __remove_shared_memory(seg);
+out_free:
+       kfree(seg);
+out:
+       mutex_unlock(&vmem_mutex);
+       return ret;
+}
+
+/*
+ * map whole physical memory to virtual memory (identity mapping)
+ */
+void __init vmem_map_init(void)
+{
+       unsigned long map_size;
+       int i;
+
+       map_size = ALIGN(max_low_pfn, MAX_ORDER_NR_PAGES) * sizeof(struct page);
+       vmalloc_end = PFN_ALIGN(VMALLOC_END_INIT) - PFN_ALIGN(map_size);
+       vmem_map = (struct page *) vmalloc_end;
+       NODE_DATA(0)->node_mem_map = vmem_map;
+
+       for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++)
+               vmem_add_mem(memory_chunk[i].addr, memory_chunk[i].size);
+}
+
+/*
+ * Convert memory chunk array to a memory segment list so there is a single
+ * list that contains both r/w memory and shared memory segments.
+ */
+static int __init vmem_convert_memory_chunk(void)
+{
+       struct memory_segment *seg;
+       int i;
+
+       mutex_lock(&vmem_mutex);
+       for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) {
+               if (!memory_chunk[i].size)
+                       continue;
+               seg = kzalloc(sizeof(*seg), GFP_KERNEL);
+               if (!seg)
+                       panic("Out of memory...\n");
+               seg->start = memory_chunk[i].addr;
+               seg->size = memory_chunk[i].size;
+               insert_memory_segment(seg);
+       }
+       mutex_unlock(&vmem_mutex);
+       return 0;
+}
+
+core_initcall(vmem_convert_memory_chunk);
index d83d64af31f277d5451507d2b60fcc13c3a0af33..8e24c40662e301fc10b65e5c3aca02210f62ab67 100644 (file)
@@ -59,6 +59,14 @@ config LOCKDEP_SUPPORT
        bool
        default y
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 source "init/Kconfig"
 
 menu "System type"
index 55f43506995ae61e740a1b22ed84d5cc67993ea3..0c9ea38d2caa0268a53179b75aec501bac0c443e 100644 (file)
@@ -38,7 +38,7 @@ struct sq_mapping {
 
 static struct sq_mapping *sq_mapping_list;
 static DEFINE_SPINLOCK(sq_mapping_lock);
-static kmem_cache_t *sq_cache;
+static struct kmem_cache *sq_cache;
 static unsigned long *sq_bitmap;
 
 #define store_queue_barrier()                  \
index 696ca75752d9d73b51a3614cf46ffbe4064f9708..f8dd6b7bfab05439bc5623bb34ce22230669c06b 100644 (file)
@@ -332,8 +332,7 @@ void __init setup_arch(char **cmdline_p)
        if (LOADER_TYPE && INITRD_START) {
                if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
                        reserve_bootmem_node(NODE_DATA(0), INITRD_START+__MEMORY_START, INITRD_SIZE);
-                       initrd_start =
-                               INITRD_START ? INITRD_START + PAGE_OFFSET + __MEMORY_START : 0;
+                       initrd_start = INITRD_START + PAGE_OFFSET + __MEMORY_START;
                        initrd_end = initrd_start + INITRD_SIZE;
                } else {
                        printk("initrd extends beyond end of memory "
index c706f3bfd897ffec5ad434c1f5eb34355acb5ede..ceee7914340121bb7ba33664b528869233bb123b 100644 (file)
@@ -99,10 +99,6 @@ EXPORT_SYMBOL(__down_trylock);
 EXPORT_SYMBOL(synchronize_irq);
 #endif
 
-#ifdef CONFIG_PM
-EXPORT_SYMBOL(pm_suspend);
-#endif
-
 EXPORT_SYMBOL(csum_partial);
 #ifdef CONFIG_IPV6
 EXPORT_SYMBOL(csum_ipv6_magic);
index 50d7c4993bef7178875e4868d6c8d9d2b62326b6..bb1c480a59c74f2713a39482e5d89fba8314e886 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/elf.h>
 #include <linux/personality.h>
 #include <linux/binfmts.h>
+#include <linux/freezer.h>
 
 #include <asm/ucontext.h>
 #include <asm/uaccess.h>
index 075d6cc1a2d79453c5aea27073cc1c8c79e64094..deb46941f315c6aa711e72b4f8b828ee73b011a6 100644 (file)
@@ -97,7 +97,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
                goto up_fail;
        }
 
-       vma = kmem_cache_zalloc(vm_area_cachep, SLAB_KERNEL);
+       vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
        if (!vma) {
                ret = -ENOMEM;
                goto up_fail;
index 329059d6b54a79b2bdfb2eacdb2c4477f5936386..cf2c2ee35a376dab1ef632f27fd1be51bf5e38cd 100644 (file)
@@ -63,6 +63,11 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
        return pte;
 }
 
+int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
+{
+       return 0;
+}
+
 struct page *follow_huge_addr(struct mm_struct *mm,
                              unsigned long address, int write)
 {
index 11d54c14982155341968b3ad76eab08499f1f9c7..90b494a0cf45b5f78c1c98c5d8b9c7b28c8868ac 100644 (file)
 #include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/pci.h>
-#include <asm/io.h>
+#include <linux/io.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
 #include <asm/addrspace.h>
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
 
-static inline void remap_area_pte(pte_t * pte, unsigned long address,
-       unsigned long size, unsigned long phys_addr, unsigned long flags)
-{
-       unsigned long end;
-       unsigned long pfn;
-       pgprot_t pgprot = __pgprot(pgprot_val(PAGE_KERNEL_NOCACHE) | flags);
-
-       address &= ~PMD_MASK;
-       end = address + size;
-       if (end > PMD_SIZE)
-               end = PMD_SIZE;
-       if (address >= end)
-               BUG();
-       pfn = phys_addr >> PAGE_SHIFT;
-       do {
-               if (!pte_none(*pte)) {
-                       printk("remap_area_pte: page already exists\n");
-                       BUG();
-               }
-               set_pte(pte, pfn_pte(pfn, pgprot));
-               address += PAGE_SIZE;
-               pfn++;
-               pte++;
-       } while (address && (address < end));
-}
-
-static inline int remap_area_pmd(pmd_t * pmd, unsigned long address,
-       unsigned long size, unsigned long phys_addr, unsigned long flags)
-{
-       unsigned long end;
-
-       address &= ~PGDIR_MASK;
-       end = address + size;
-       if (end > PGDIR_SIZE)
-               end = PGDIR_SIZE;
-       phys_addr -= address;
-       if (address >= end)
-               BUG();
-       do {
-               pte_t * pte = pte_alloc_kernel(pmd, address);
-               if (!pte)
-                       return -ENOMEM;
-               remap_area_pte(pte, address, end - address, address + phys_addr, flags);
-               address = (address + PMD_SIZE) & PMD_MASK;
-               pmd++;
-       } while (address && (address < end));
-       return 0;
-}
-
-int remap_area_pages(unsigned long address, unsigned long phys_addr,
-                    unsigned long size, unsigned long flags)
-{
-       int error;
-       pgd_t * dir;
-       unsigned long end = address + size;
-
-       phys_addr -= address;
-       dir = pgd_offset_k(address);
-       flush_cache_all();
-       if (address >= end)
-               BUG();
-       do {
-               pud_t *pud;
-               pmd_t *pmd;
-
-               error = -ENOMEM;
-
-               pud = pud_alloc(&init_mm, dir, address);
-               if (!pud)
-                       break;
-               pmd = pmd_alloc(&init_mm, pud, address);
-               if (!pmd)
-                       break;
-               if (remap_area_pmd(pmd, address, end - address,
-                                       phys_addr + address, flags))
-                       break;
-               error = 0;
-               address = (address + PGDIR_SIZE) & PGDIR_MASK;
-               dir++;
-       } while (address && (address < end));
-       flush_tlb_all();
-       return error;
-}
-
 /*
  * Remap an arbitrary physical address space into the kernel virtual
  * address space. Needed when the kernel wants to access high addresses
@@ -121,6 +37,7 @@ void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,
 {
        struct vm_struct * area;
        unsigned long offset, last_addr, addr, orig_addr;
+       pgprot_t pgprot;
 
        /* Don't allow wraparound or zero size */
        last_addr = phys_addr + size - 1;
@@ -190,8 +107,9 @@ void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,
        }
 #endif
 
+       pgprot = __pgprot(pgprot_val(PAGE_KERNEL_NOCACHE) | flags);
        if (likely(size))
-               if (remap_area_pages(addr, phys_addr, size, flags)) {
+               if (ioremap_page_range(addr, addr + size, phys_addr, pgprot)) {
                        vunmap((void *)orig_addr);
                        return NULL;
                }
index 92e745341e4d67335a23d7c09b934c48c8a02cca..b60ad83a7635ceceb19bc8896b5774f7f0c5c001 100644 (file)
@@ -30,7 +30,7 @@
 
 #define NR_PMB_ENTRIES 16
 
-static kmem_cache_t *pmb_cache;
+static struct kmem_cache *pmb_cache;
 static unsigned long pmb_map;
 
 static struct pmb_entry pmb_init_map[] = {
@@ -283,7 +283,7 @@ void pmb_unmap(unsigned long addr)
        } while (pmbe);
 }
 
-static void pmb_cache_ctor(void *pmb, kmem_cache_t *cachep, unsigned long flags)
+static void pmb_cache_ctor(void *pmb, struct kmem_cache *cachep, unsigned long flags)
 {
        struct pmb_entry *pmbe = pmb;
 
@@ -297,7 +297,7 @@ static void pmb_cache_ctor(void *pmb, kmem_cache_t *cachep, unsigned long flags)
        spin_unlock_irq(&pmb_list_lock);
 }
 
-static void pmb_cache_dtor(void *pmb, kmem_cache_t *cachep, unsigned long flags)
+static void pmb_cache_dtor(void *pmb, struct kmem_cache *cachep, unsigned long flags)
 {
        spin_lock_irq(&pmb_list_lock);
        pmb_list_del(pmb);
index c265185b22a72b92a0d48c3f68fd1ca100bc45da..60402eec4b4d3f34589e8ccaa78f351bc331d6ce 100644 (file)
@@ -142,7 +142,7 @@ static u64 sh7750_read_counter(int counter)
  */
 static inline int to_counter(struct file *file)
 {
-       const unsigned char *name = file->f_dentry->d_parent->d_name.name;
+       const unsigned char *name = file->f_path.dentry->d_parent->d_name.name;
 
        return (int)simple_strtol(name, NULL, 10);
 }
index 58c678e0666786709a6da152d24fa3d9df158dfd..7bc0744b7ab6aca55207c96740c48c793fa286e4 100644 (file)
@@ -39,6 +39,14 @@ config RWSEM_XCHGADD_ALGORITHM
 config GENERIC_ISA_DMA
        bool
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 source init/Kconfig
 
 menu "System type"
index ffb310e33cefbe505ba25521e7b50a2e5bb5d2d4..b9e7d54d7b8553d89d2c9988c561f4227d38d19b 100644 (file)
@@ -243,9 +243,7 @@ void __init setup_arch(char **cmdline_p)
                if (INITRD_START + INITRD_SIZE <= (PFN_PHYS(last_pfn))) {
                        reserve_bootmem_node(NODE_DATA(0), INITRD_START + __MEMORY_START, INITRD_SIZE);
 
-                       initrd_start =
-                         (long) INITRD_START ? INITRD_START + PAGE_OFFSET +  __MEMORY_START : 0;
-
+                       initrd_start = (long) INITRD_START + PAGE_OFFSET + __MEMORY_START;
                        initrd_end = initrd_start + INITRD_SIZE;
                } else {
                        printk("initrd extends beyond end of memory "
index 9e2ffc45c0e0ffe480c614da00edee056903fec3..1666d3efb52e2fccbb56cca8808d40ab17512097 100644 (file)
@@ -22,7 +22,7 @@
 #include <linux/errno.h>
 #include <linux/wait.h>
 #include <linux/personality.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 #include <linux/ptrace.h>
 #include <linux/unistd.h>
 #include <linux/stddef.h>
index 8e2f6c28b7390fc712a8d07f8e8e567fbd7b6853..4f72ab33bb2b0a7cb9caae2b09a135f96c8a6ed9 100644 (file)
@@ -154,7 +154,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long writeaccess,
         * If we're in an interrupt or have no user
         * context, we must not take the fault..
         */
-       if (in_interrupt() || !mm)
+       if (in_atomic() || !mm)
                goto no_context;
 
        /* TLB misses upon some cache flushes get done under cli() */
index 187cf01750b80fe43ce2f8f32375b360a16a819f..4b455f61114670282914c7b6bf7354974d63864e 100644 (file)
@@ -53,6 +53,11 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
        return pte;
 }
 
+int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
+{
+       return 0;
+}
+
 void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
                     pte_t *ptep, pte_t entry)
 {
index 80c56754f51309f0d9f2c09238fe4ce8a04082d9..ff26c02511aa6eac58ed79bb284f7bb76604e2f0 100644 (file)
@@ -18,7 +18,7 @@
 #include <linux/vmalloc.h>
 #include <linux/sched.h>
 #include <linux/string.h>
-#include <asm/io.h>
+#include <linux/io.h>
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
 #include <linux/ioport.h>
 static void shmedia_mapioaddr(unsigned long, unsigned long);
 static unsigned long shmedia_ioremap(struct resource *, u32, int);
 
-static inline void remap_area_pte(pte_t * pte, unsigned long address, unsigned long size,
-       unsigned long phys_addr, unsigned long flags)
-{
-       unsigned long end;
-       unsigned long pfn;
-       pgprot_t pgprot = __pgprot(_PAGE_PRESENT  | _PAGE_READ   |
-                                  _PAGE_WRITE    | _PAGE_DIRTY  |
-                                  _PAGE_ACCESSED | _PAGE_SHARED | flags);
-
-       address &= ~PMD_MASK;
-       end = address + size;
-       if (end > PMD_SIZE)
-               end = PMD_SIZE;
-       if (address >= end)
-               BUG();
-
-       pfn = phys_addr >> PAGE_SHIFT;
-
-       pr_debug("    %s: pte %p address %lx size %lx phys_addr %lx\n",
-                __FUNCTION__,pte,address,size,phys_addr);
-
-       do {
-               if (!pte_none(*pte)) {
-                       printk("remap_area_pte: page already exists\n");
-                       BUG();
-               }
-
-               set_pte(pte, pfn_pte(pfn, pgprot));
-               address += PAGE_SIZE;
-               pfn++;
-               pte++;
-       } while (address && (address < end));
-}
-
-static inline int remap_area_pmd(pmd_t * pmd, unsigned long address, unsigned long size,
-       unsigned long phys_addr, unsigned long flags)
-{
-       unsigned long end;
-
-       address &= ~PGDIR_MASK;
-       end = address + size;
-
-       if (end > PGDIR_SIZE)
-               end = PGDIR_SIZE;
-
-       phys_addr -= address;
-
-       if (address >= end)
-               BUG();
-
-       do {
-               pte_t * pte = pte_alloc_kernel(pmd, address);
-               if (!pte)
-                       return -ENOMEM;
-               remap_area_pte(pte, address, end - address, address + phys_addr, flags);
-               address = (address + PMD_SIZE) & PMD_MASK;
-               pmd++;
-       } while (address && (address < end));
-       return 0;
-}
-
-static int remap_area_pages(unsigned long address, unsigned long phys_addr,
-                                unsigned long size, unsigned long flags)
-{
-       int error;
-       pgd_t * dir;
-       unsigned long end = address + size;
-
-       phys_addr -= address;
-       dir = pgd_offset_k(address);
-       flush_cache_all();
-       if (address >= end)
-               BUG();
-       do {
-               pmd_t *pmd = pmd_alloc(&init_mm, dir, address);
-               error = -ENOMEM;
-               if (!pmd)
-                       break;
-               if (remap_area_pmd(pmd, address, end - address,
-                                  phys_addr + address, flags)) {
-                        break;
-               }
-               error = 0;
-               address = (address + PGDIR_SIZE) & PGDIR_MASK;
-               dir++;
-       } while (address && (address < end));
-       flush_tlb_all();
-       return 0;
-}
-
 /*
  * Generic mapping function (not visible outside):
  */
@@ -136,12 +46,17 @@ void * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flag
        void * addr;
        struct vm_struct * area;
        unsigned long offset, last_addr;
+       pgprot_t pgprot;
 
        /* Don't allow wraparound or zero size */
        last_addr = phys_addr + size - 1;
        if (!size || last_addr < phys_addr)
                return NULL;
 
+       pgprot = __pgprot(_PAGE_PRESENT  | _PAGE_READ   |
+                         _PAGE_WRITE    | _PAGE_DIRTY  |
+                         _PAGE_ACCESSED | _PAGE_SHARED | flags);
+
        /*
         * Mappings have to be page-aligned
         */
@@ -158,7 +73,8 @@ void * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flag
                return NULL;
        area->phys_addr = phys_addr;
        addr = area->addr;
-       if (remap_area_pages((unsigned long)addr, phys_addr, size, flags)) {
+       if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size,
+                              phys_addr, pgprot)) {
                vunmap(addr);
                return NULL;
        }
index 92a7c8a636d3c8679ec34eab437ab4a8273d55e4..d0dec1ea2eed93345091981a64c6028f9ae474ff 100644 (file)
@@ -166,6 +166,14 @@ config ARCH_MAY_HAVE_PC_FDC
        bool
        default y
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 config SUN_PM
        bool
        default y
index 6f3ac548ee66dbe908eb157308962e9db489576b..0bf8c165fc929240d24b3d26bf414e9d2551eb60 100644 (file)
@@ -94,8 +94,8 @@ asmlinkage unsigned long sunos_mmap(unsigned long addr, unsigned long len,
         * SunOS is so stupid some times... hmph!
         */
        if (file) {
-               if (imajor(file->f_dentry->d_inode) == MEM_MAJOR &&
-                   iminor(file->f_dentry->d_inode) == 5) {
+               if (imajor(file->f_path.dentry->d_inode) == MEM_MAJOR &&
+                   iminor(file->f_path.dentry->d_inode) == 5) {
                        flags |= MAP_ANONYMOUS;
                        fput(file);
                        file = NULL;
@@ -655,7 +655,7 @@ sunos_nfs_get_server_fd (int fd, struct sockaddr_in *addr)
        if (!file)
                goto out;
 
-       inode = file->f_dentry->d_inode;
+       inode = file->f_path.dentry->d_inode;
 
        socket = SOCKET_I(inode);
        local.sin_family = AF_INET;
index 5cc5ff7f8824d04f12665e12423b970fbf273553..b73e6b9067eddf5ba48ea26d503c607f67d2ea60 100644 (file)
@@ -11,6 +11,7 @@ SECTIONS
   . = 0x10000 + SIZEOF_HEADERS;
   .text 0xf0004000 :
   {
+    _text = .;
     *(.text)
     SCHED_TEXT
     LOCK_TEXT
index 4d8ed9c651823ae82b3d30c6a5d947eb422a18b9..01fc6c25429255c27be0e6a94e36179e2693b86d 100644 (file)
@@ -35,7 +35,7 @@ void *kmap_atomic(struct page *page, enum km_type type)
        unsigned long vaddr;
 
        /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
-       inc_preempt_count();
+       pagefault_disable();
        if (!PageHighMem(page))
                return page_address(page);
 
@@ -70,8 +70,7 @@ void kunmap_atomic(void *kvaddr, enum km_type type)
        unsigned long idx = type + KM_TYPE_NR*smp_processor_id();
 
        if (vaddr < FIXADDR_START) { // FIXME
-               dec_preempt_count();
-               preempt_check_resched();
+               pagefault_enable();
                return;
        }
 
@@ -97,8 +96,7 @@ void kunmap_atomic(void *kvaddr, enum km_type type)
 #endif
 #endif
 
-       dec_preempt_count();
-       preempt_check_resched();
+       pagefault_enable();
 }
 
 /* We may be fed a pagetable here by ptep_to_xxx and others. */
index b627f8dbcaad5da32b4b5ffe1cad244d820bc898..d391d11f245ab0d8d06ce6a9e92c95a1b4b989f8 100644 (file)
@@ -34,6 +34,14 @@ config ARCH_MAY_HAVE_PC_FDC
        bool
        default y
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 config AUDIT_ARCH
        bool
        default y
index d7caa60a00743ce1fc8b496cc3f657a9ea2f6122..f205fc7cbcd0da686c38f732be25bf52740ee58d 100644 (file)
@@ -209,7 +209,7 @@ static int load_aout32_binary(struct linux_binprm * bprm, struct pt_regs * regs)
        if ((N_MAGIC(ex) != ZMAGIC && N_MAGIC(ex) != OMAGIC &&
             N_MAGIC(ex) != QMAGIC && N_MAGIC(ex) != NMAGIC) ||
            N_TRSIZE(ex) || N_DRSIZE(ex) ||
-           bprm->file->f_dentry->d_inode->i_size < ex.a_text+ex.a_data+N_SYMSIZE(ex)+N_TXTOFF(ex)) {
+           bprm->file->f_path.dentry->d_inode->i_size < ex.a_text+ex.a_data+N_SYMSIZE(ex)+N_TXTOFF(ex)) {
                return -ENOEXEC;
        }
 
@@ -349,7 +349,7 @@ static int load_aout32_library(struct file *file)
        int retval;
        struct exec ex;
 
-       inode = file->f_dentry->d_inode;
+       inode = file->f_path.dentry->d_inode;
 
        retval = -ENOEXEC;
        error = kernel_read(file, 0, (char *) &ex, sizeof(ex));
index a98f3ae175a343e48c88977e83fc2c3f96e04865..9ad84ff10a177320a2bfaf3d30f553380c9d042e 100644 (file)
@@ -141,7 +141,6 @@ cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value)
        value->tv_sec = jiffies / HZ;
 }
 
-#define elf_addr_t     u32
 #undef start_thread
 #define start_thread start_thread32
 #define init_elf_binfmt init_elf32_binfmt
index 7da72d3b322ae854853ed5f4724219ad8bcb3363..4446f66590fac2f10485b76e11b3f3c6752499ce 100644 (file)
@@ -83,7 +83,7 @@ asmlinkage u32 sunos_mmap(u32 addr, u32 len, u32 prot, u32 flags, u32 fd, u32 of
                file = fget(fd);
                if (!file)
                        goto out;
-               inode = file->f_dentry->d_inode;
+               inode = file->f_path.dentry->d_inode;
                if (imajor(inode) == MEM_MAJOR && iminor(inode) == 5) {
                        flags |= MAP_ANONYMOUS;
                        fput(file);
@@ -615,7 +615,7 @@ sunos_nfs_get_server_fd (int fd, struct sockaddr_in *addr)
        if (!file)
                return 0;
 
-       inode = file->f_dentry->d_inode;
+       inode = file->f_path.dentry->d_inode;
 
        socket = SOCKET_I(inode);
        local.sin_family = AF_INET;
index bd9de8c2a2aa1c29158134d0bdaf04754efc8703..4a6063f33e7a4155e084cd50ba58a2617f3fa3c3 100644 (file)
@@ -13,6 +13,7 @@ SECTIONS
   . = 0x4000;
   .text 0x0000000000404000 :
   {
+    _text = .;
     *(.text)
     SCHED_TEXT
     LOCK_TEXT
index 53b9b1f528e54ae75d9caeb90e3fa7bd90b67c8a..33fd0b265e707afdee93ec63322e9bff01220882 100644 (file)
@@ -235,6 +235,11 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
        return pte;
 }
 
+int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
+{
+       return 0;
+}
+
 void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
                     pte_t *ptep, pte_t entry)
 {
index 09cb7fccc03a758ca2e0f8351734e8a550830c02..a8e8802eed4d2679d1c70ac563051379c7d3c4e1 100644 (file)
@@ -176,9 +176,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
 
 int bigkernel = 0;
 
-kmem_cache_t *pgtable_cache __read_mostly;
+struct kmem_cache *pgtable_cache __read_mostly;
 
-static void zero_ctor(void *addr, kmem_cache_t *cache, unsigned long flags)
+static void zero_ctor(void *addr, struct kmem_cache *cache, unsigned long flags)
 {
        clear_page(addr);
 }
index beaa02810f0e9e27ee6b65b8016984610bbdda0a..236d02f41a01ae576a0d0ab60670ecba29656668 100644 (file)
@@ -239,7 +239,7 @@ static void setup_tsb_params(struct mm_struct *mm, unsigned long tsb_idx, unsign
        }
 }
 
-static kmem_cache_t *tsb_caches[8] __read_mostly;
+static struct kmem_cache *tsb_caches[8] __read_mostly;
 
 static const char *tsb_cache_names[8] = {
        "tsb_8KB",
index 12a940cc791f3cc0f96c6c39f99d199d514e3048..61be597bf43037d3df41bd85997db373f7cbde61 100644 (file)
@@ -449,7 +449,7 @@ asmlinkage int solaris_fstatvfs(unsigned int fd, u32 buf)
        error = -EBADF;
        file = fget(fd);
        if (file) {
-               error = report_statvfs(file->f_vfsmnt, file->f_dentry->d_inode, buf);
+               error = report_statvfs(file->f_path.mnt, file->f_path.dentry->d_inode, buf);
                fput(file);
        }
 
@@ -481,7 +481,7 @@ asmlinkage int solaris_fstatvfs64(unsigned int fd, u32 buf)
        file = fget(fd);
        if (file) {
                lock_kernel();
-               error = report_statvfs64(file->f_vfsmnt, file->f_dentry->d_inode, buf);
+               error = report_statvfs64(file->f_path.mnt, file->f_path.dentry->d_inode, buf);
                unlock_kernel();
                fput(file);
        }
index be0a054e3ed6b1d3c22b652978a56d916aa25c0f..330743c5b3d8cf378e82577d6c1bb3957a99cf6b 100644 (file)
@@ -299,8 +299,8 @@ static inline int solaris_sockmod(unsigned int fd, unsigned int cmd, u32 arg)
        rcu_read_lock();
        fdt = files_fdtable(current->files);
        if (! fdt->fd[fd] ||
-           ! fdt->fd[fd]->f_dentry ||
-           ! (ino = fdt->fd[fd]->f_dentry->d_inode) ||
+           ! fdt->fd[fd]->f_path.dentry ||
+           ! (ino = fdt->fd[fd]->f_path.dentry->d_inode) ||
            ! S_ISSOCK(ino->i_mode)) {
                rcu_read_unlock();
                return TBADF;
@@ -480,7 +480,7 @@ static inline int solaris_S(struct file *filp, unsigned int fd, unsigned int cmd
         struct sol_socket_struct *sock;
         struct module_info *mi;
 
-        ino = filp->f_dentry->d_inode;
+        ino = filp->f_path.dentry->d_inode;
         if (!S_ISSOCK(ino->i_mode))
                return -EBADF;
         sock = filp->private_data;
index 9ed997982f8dbe245e2f3a15fab1257ee9c10c56..bca16e8c95c325d406f7bac43701f611f75837f9 100644 (file)
@@ -77,7 +77,7 @@ static u32 do_solaris_mmap(u32 addr, u32 len, u32 prot, u32 flags, u32 fd, u64 o
                if (!file)
                        goto out;
                else {
-                       struct inode * inode = file->f_dentry->d_inode;
+                       struct inode * inode = file->f_path.dentry->d_inode;
                        if(imajor(inode) == MEM_MAJOR &&
                           iminor(inode) == 5) {
                                flags |= MAP_ANONYMOUS;
@@ -423,9 +423,7 @@ asmlinkage int solaris_procids(int cmd, s32 pid, s32 pgid)
                           Solaris setpgrp and setsid? */
                        ret = sys_setpgid(0, 0);
                        if (ret) return ret;
-                       mutex_lock(&tty_mutex);
-                       current->signal->tty = NULL;
-                       mutex_unlock(&tty_mutex);
+                       proc_clear_tty(current);
                        return process_group(current);
                }
        case 2: /* getsid */
index 7c90e41fd3bea4cdcfc6f257323c8e9790a1fec3..89a4757f192f5bee16b90fed7b793ce622bf36c7 100644 (file)
@@ -96,13 +96,13 @@ static int socksys_open(struct inode * inode, struct file * filp)
         * No shit.  WTF is it supposed to do, anyway?
         *
         * Try instead:
-        * d_delete(filp->f_dentry), then d_instantiate with sock inode
+        * d_delete(filp->f_path.dentry), then d_instantiate with sock inode
         */
-       dentry = filp->f_dentry;
-       filp->f_dentry = dget(fcheck(fd)->f_dentry);
-       filp->f_dentry->d_inode->i_rdev = inode->i_rdev;
-       filp->f_dentry->d_inode->i_flock = inode->i_flock;
-       SOCKET_I(filp->f_dentry->d_inode)->file = filp;
+       dentry = filp->f_path.dentry;
+       filp->f_path.dentry = dget(fcheck(fd)->f_path.dentry);
+       filp->f_path.dentry->d_inode->i_rdev = inode->i_rdev;
+       filp->f_path.dentry->d_inode->i_flock = inode->i_flock;
+       SOCKET_I(filp->f_path.dentry->d_inode)->file = filp;
        filp->f_op = &socksys_file_ops;
         sock = (struct sol_socket_struct*) 
                mykmalloc(sizeof(struct sol_socket_struct), GFP_KERNEL);
@@ -148,7 +148,7 @@ static unsigned int socksys_poll(struct file * filp, poll_table * wait)
        struct inode *ino;
        unsigned int mask = 0;
 
-       ino=filp->f_dentry->d_inode;
+       ino=filp->f_path.dentry->d_inode;
        if (ino && S_ISSOCK(ino->i_mode)) {
                struct sol_socket_struct *sock;
                sock = (struct sol_socket_struct*)filp->private_data;
index b84e5456b0250b2f17dfd3fe8b78578348177dc8..a9d32ceabf26e5bed3c6cf2dc2810a2d94e2a07d 100644 (file)
@@ -147,7 +147,7 @@ static void timod_wake_socket(unsigned int fd)
 
        SOLD("wakeing socket");
        fdt = files_fdtable(current->files);
-       sock = SOCKET_I(fdt->fd[fd]->f_dentry->d_inode);
+       sock = SOCKET_I(fdt->fd[fd]->f_path.dentry->d_inode);
        wake_up_interruptible(&sock->wait);
        read_lock(&sock->sk->sk_callback_lock);
        if (sock->fasync_list && !test_bit(SOCK_ASYNC_WAITDATA, &sock->flags))
@@ -361,7 +361,7 @@ int timod_putmsg(unsigned int fd, char __user *ctl_buf, int ctl_len,
 
        fdt = files_fdtable(current->files);
        filp = fdt->fd[fd];
-       ino = filp->f_dentry->d_inode;
+       ino = filp->f_path.dentry->d_inode;
        sock = (struct sol_socket_struct *)filp->private_data;
        SOLD("entry");
        if (get_user(ret, (int __user *)A(ctl_buf)))
@@ -644,7 +644,7 @@ int timod_getmsg(unsigned int fd, char __user *ctl_buf, int ctl_maxlen, s32 __us
        SOLDD(("%u %p %d %p %p %d %p %d\n", fd, ctl_buf, ctl_maxlen, ctl_len, data_buf, data_maxlen, data_len, *flags_p));
        fdt = files_fdtable(current->files);
        filp = fdt->fd[fd];
-       ino = filp->f_dentry->d_inode;
+       ino = filp->f_path.dentry->d_inode;
        sock = (struct sol_socket_struct *)filp->private_data;
        SOLDD(("%p %p\n", sock->pfirst, sock->pfirst ? sock->pfirst->next : NULL));
        if ( ctl_maxlen > 0 && !sock->pfirst && SOCKET_I(ino)->type == SOCK_STREAM
@@ -865,7 +865,7 @@ asmlinkage int solaris_getmsg(unsigned int fd, u32 arg1, u32 arg2, u32 arg3)
        filp = fdt->fd[fd];
        if(!filp) goto out;
 
-       ino = filp->f_dentry->d_inode;
+       ino = filp->f_path.dentry->d_inode;
        if (!ino || !S_ISSOCK(ino->i_mode))
                goto out;
 
@@ -933,7 +933,7 @@ asmlinkage int solaris_putmsg(unsigned int fd, u32 arg1, u32 arg2, u32 arg3)
        filp = fdt->fd[fd];
        if(!filp) goto out;
 
-       ino = filp->f_dentry->d_inode;
+       ino = filp->f_path.dentry->d_inode;
        if (!ino) goto out;
 
        if (!S_ISSOCK(ino->i_mode) &&
index 5ac1f2963ae383e391cb601c730ed645e0707b6a..d32a80e6668c08c008714d8c0ef1f26ce6a4645b 100644 (file)
@@ -47,6 +47,11 @@ config GENERIC_CALIBRATE_DELAY
        bool
        default y
 
+config GENERIC_BUG
+       bool
+       default y
+       depends on BUG
+
 # Used in kernel/irq/manage.c and include/linux/irq.h
 config IRQ_RELEASE_METHOD
        bool
index 824386974f88902469f2d95713ae9e4bf6a2928f..9c2e7a758f211804d8618f7bae98c82e42f57fc5 100644 (file)
@@ -98,4 +98,4 @@ static int register_daemon(void)
        return 0;
 }
 
-__initcall(register_daemon);
+late_initcall(register_daemon);
index 426633e5d6e387cc43604557751a6ca641dcbdc1..83301e1ef67cbe24dbe6ee73f70b21c756ff87f8 100644 (file)
@@ -31,9 +31,9 @@ static irqreturn_t line_interrupt(int irq, void *data)
        return IRQ_HANDLED;
 }
 
-static void line_timer_cb(void *arg)
+static void line_timer_cb(struct work_struct *work)
 {
-       struct line *line = arg;
+       struct line *line = container_of(work, struct line, task.work);
 
        if(!line->throttled)
                chan_interrupt(&line->chan_list, &line->task, line->tty,
@@ -246,7 +246,7 @@ out_up:
        return ret;
 }
 
-void line_set_termios(struct tty_struct *tty, struct termios * old)
+void line_set_termios(struct tty_struct *tty, struct ktermios * old)
 {
        /* nothing */
 }
@@ -443,7 +443,7 @@ int line_open(struct line *lines, struct tty_struct *tty)
                 * is registered.
                 */
                enable_chan(line);
-               INIT_WORK(&line->task, line_timer_cb, line);
+               INIT_DELAYED_WORK(&line->task, line_timer_cb);
 
                if(!line->sigio){
                        chan_enable_winch(&line->chan_list, tty);
index c090fbd464e7c9c7713d0eb6456aa859d69eb831..52ccb7b53cd24d946d7d1d92260832cea552ea4d 100644 (file)
@@ -127,4 +127,4 @@ static int register_mcast(void)
        return 0;
 }
 
-__initcall(register_mcast);
+late_initcall(register_mcast);
index 6e1ef8558283254faf6c28f462cf71b90cb6626f..e67362acf0e7b554089d7206230812c6e970405a 100644 (file)
@@ -109,4 +109,4 @@ static int register_pcap(void)
        return 0;
 }
 
-__initcall(register_pcap);
+late_initcall(register_pcap);
index 788da5439a2defd3b18837e74828b3ec75457ef6..25634bd1f585e13c9563695f2ec2bc13c8318718 100644 (file)
@@ -95,4 +95,4 @@ static int register_slip(void)
        return 0;
 }
 
-__initcall(register_slip);
+late_initcall(register_slip);
index ae322e1c8a8753e3794c18cafa20d5d3af6d9b2d..b3ed8fb874ab2ae0b3e8d54c5aa76d3fcd9a5d81 100644 (file)
@@ -119,4 +119,4 @@ static int register_slirp(void)
        return 0;
 }
 
-__initcall(register_slirp);
+late_initcall(register_slirp);
index 572d286ed2c666e21faa970fd2a88f5658056c9a..9003a343e1484691880fb6ebf20cf0963609f7d6 100644 (file)
@@ -27,7 +27,7 @@ struct chan {
        void *data;
 };
 
-extern void chan_interrupt(struct list_head *chans, struct work_struct *task,
+extern void chan_interrupt(struct list_head *chans, struct delayed_work *task,
                           struct tty_struct *tty, int irq);
 extern int parse_chan_pair(char *str, struct line *line, int device,
                           const struct chan_opts *opts);
index 7be24811bb3094b127667941f06c7297c085f2e9..5f232ae89fbb8440a7dd4b4830011bb401f437d4 100644 (file)
@@ -51,7 +51,7 @@ struct line {
        char *tail;
 
        int sigio;
-       struct work_struct task;
+       struct delayed_work task;
        const struct line_driver *driver;
        int have_irq;
 };
@@ -76,7 +76,7 @@ extern int line_setup(struct line *lines, unsigned int sizeof_lines,
 extern int line_write(struct tty_struct *tty, const unsigned char *buf,
                      int len);
 extern void line_put_char(struct tty_struct *tty, unsigned char ch);
-extern void line_set_termios(struct tty_struct *tty, struct termios * old);
+extern void line_set_termios(struct tty_struct *tty, struct ktermios * old);
 extern int line_chars_in_buffer(struct tty_struct *tty);
 extern void line_flush_buffer(struct tty_struct *tty);
 extern void line_flush_chars(struct tty_struct *tty);
index 6670cc992ecb55de9c98e9ca19131c6c1a556592..52b398bcafcf73ad738cbff7d6e0bd754eb7ddae 100644 (file)
@@ -75,7 +75,7 @@ union uml_pt_regs {
 #endif
 #ifdef UML_CONFIG_MODE_SKAS
        struct skas_regs {
-               unsigned long regs[HOST_FRAME_SIZE];
+               unsigned long regs[MAX_REG_NR];
                unsigned long fp[HOST_FP_SIZE];
                unsigned long xfp[HOST_XFP_SIZE];
                 struct faultinfo faultinfo;
index b492b12b4a1054c6d4c69ceb51cabdbc41c713ce..4fffae75ba531d1083f2f0c41b4a27ec3b40bd38 100644 (file)
@@ -9,6 +9,7 @@
 #include <sys/mman.h>
 #include <asm/ptrace.h>
 #include <asm/unistd.h>
+#include <asm/page.h>
 #include "stub-data.h"
 #include "kern_constants.h"
 #include "uml-config.h"
index 617bb9efc93424ef59fb413cf0394f7266ad12d1..66cb400c2c92bb18e103036ff299e76b52512b96 100644 (file)
@@ -108,7 +108,7 @@ union uml_pt_regs {
                 * file size, while i386 uses FRAME_SIZE.  Therefore, we need
                 * to use UM_FRAME_SIZE here instead of HOST_FRAME_SIZE.
                 */
-               unsigned long regs[UM_FRAME_SIZE];
+               unsigned long regs[MAX_REG_NR];
                unsigned long fp[HOST_FP_SIZE];
                 struct faultinfo faultinfo;
                long syscall;
index 0561c43b4685c7935f4fb33600229a7c15793bf1..8d56ec6cca79606e8ee8d075e455e1f2b8d532d6 100644 (file)
@@ -39,12 +39,13 @@ static long execve1(char *file, char __user * __user *argv,
                    char __user *__user *env)
 {
         long error;
+       struct tty_struct *tty;
 
 #ifdef CONFIG_TTY_LOG
        mutex_lock(&tty_mutex);
-       task_lock(current);     /* FIXME:  is this needed ? */
-       log_exec(argv, current->signal->tty);
-       task_unlock(current);
+       tty = get_current_tty();
+       if (tty)
+               log_exec(argv, tty);
        mutex_unlock(&tty_mutex);
 #endif
         error = do_execve(file, argv, env, &current->thread.regs);
index 16385e2ada854ebd1c965364a6d065f709294c3f..70541821775f3167c4c6871f8dd2a65917df18c4 100644 (file)
@@ -105,4 +105,4 @@ static int register_ethertap(void)
        return 0;
 }
 
-__initcall(register_ethertap);
+late_initcall(register_ethertap);
index 0edbac63c52708009ac792442fee6eb75dc2fbb5..76570a2c25c33bae1a799a61fb54078301304b29 100644 (file)
@@ -90,4 +90,4 @@ static int register_tuntap(void)
        return 0;
 }
 
-__initcall(register_tuntap);
+late_initcall(register_tuntap);
index 0e32adf03be1940a0cace32c2e4842d3eef7a78a..098720be019a09d25fba077207a5e80ad3da3ab6 100644 (file)
@@ -1,4 +1,4 @@
-obj-y = bugs.o checksum.o delay.o fault.o ksyms.o ldt.o ptrace.o \
+obj-y = bug.o bugs.o checksum.o delay.o fault.o ksyms.o ldt.o ptrace.o \
        ptrace_user.o setjmp.o signal.o sigcontext.o syscalls.o sysrq.o \
        sys_call_table.o tls.o
 
diff --git a/arch/um/sys-i386/bug.c b/arch/um/sys-i386/bug.c
new file mode 100644 (file)
index 0000000..200c8ba
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2006 Jeff Dike (jdike@addtoit.com)
+ * Licensed under the GPL V2
+ */
+
+#include <linux/uaccess.h>
+
+/* Mostly copied from i386/x86_86 - eliminated the eip < PAGE_OFFSET because
+ * that's not relevent in skas mode.
+ */
+
+int is_valid_bugaddr(unsigned long eip)
+{
+       unsigned short ud2;
+
+       if (probe_kernel_address((unsigned short __user *)eip, ud2))
+               return 0;
+
+       return ud2 == 0x0b0f;
+}
index e299ee5a753d7b1adddad393e926a4609509cfdb..49057d8bc668b88a5ac4a45a3559171253abfaed 100644 (file)
@@ -3,7 +3,6 @@
  * Licensed under the GPL
  */
 
-#include "linux/stddef.h"
 #include "linux/sched.h"
 #include "linux/slab.h"
 #include "linux/types.h"
index 5f3cc66858209f67c6caf9ebc9f46a808e907498..01212c88fcc4ffc490926f35d7af7861d2006e11 100644 (file)
@@ -4,9 +4,9 @@
  */
 
 #include <stdio.h>
+#include <stddef.h>
 #include <errno.h>
 #include <unistd.h>
-#include <linux/stddef.h>
 #include "ptrace_user.h"
 /* Grr, asm/user.h includes asm/ptrace.h, so has to follow ptrace_user.h */
 #include <asm/user.h>
index 6f4ef2b7fa4a04d8f3ddec2fd8a860534155d7bc..447306b20aea66245d3e5430a7acd11b733dd973 100644 (file)
@@ -2,7 +2,7 @@
 #include <signal.h>
 #include <asm/ptrace.h>
 #include <asm/user.h>
-#include <linux/stddef.h>
+#include <stddef.h>
 #include <sys/poll.h>
 
 #define DEFINE(sym, val) \
index f41768b8e25eb25978093f8481e294dadbc1c8f4..4d9e5efa6fb900025c9319f7a12a91825ba7417d 100644 (file)
@@ -4,7 +4,7 @@
 # Licensed under the GPL
 #
 
-obj-y = bugs.o delay.o fault.o ldt.o mem.o ptrace.o ptrace_user.o \
+obj-y = bug.o bugs.o delay.o fault.o ldt.o mem.o ptrace.o ptrace_user.o \
        setjmp.o sigcontext.o signal.o syscalls.o syscall_table.o sysrq.o \
        ksyms.o tls.o
 
diff --git a/arch/um/sys-x86_64/bug.c b/arch/um/sys-x86_64/bug.c
new file mode 100644 (file)
index 0000000..200c8ba
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2006 Jeff Dike (jdike@addtoit.com)
+ * Licensed under the GPL V2
+ */
+
+#include <linux/uaccess.h>
+
+/* Mostly copied from i386/x86_86 - eliminated the eip < PAGE_OFFSET because
+ * that's not relevent in skas mode.
+ */
+
+int is_valid_bugaddr(unsigned long eip)
+{
+       unsigned short ud2;
+
+       if (probe_kernel_address((unsigned short __user *)eip, ud2))
+               return 0;
+
+       return ud2 == 0x0b0f;
+}
index 37ec644603ab886eb3221f7606488ce760dceb85..bcf825875d1706f4c108d4d75a5f24bbd814ba6b 100644 (file)
@@ -38,6 +38,14 @@ config TIME_LOW_RES
        bool
        default y
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 # Turn off some random 386 crap that can affect device config
 config ISA
        bool
index 88d087f527c9ff20b3e7bc591685e6c0cf309367..3a5fd07fe064cef52b7e0a7a0ec42bfb04192168 100644 (file)
@@ -90,6 +90,7 @@
 
 /* Kernel text segment, and some constant data areas.  */
 #define TEXT_CONTENTS                                                        \
+               _text = .;                                                    \
                __stext = . ;                                                 \
                *(.text)                                                      \
                SCHED_TEXT                                                    \
index 010d2265f1cfb05086017020c3533cb737cca614..3ac581d1720220cddf2601eed541064352bc3152 100644 (file)
@@ -96,6 +96,19 @@ config AUDIT_ARCH
        bool
        default y
 
+config GENERIC_BUG
+       bool
+       default y
+       depends on BUG
+
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 source "init/Kconfig"
 
 
@@ -122,7 +135,7 @@ endchoice
 
 choice
        prompt "Processor family"
-       default MK8
+       default GENERIC_CPU
 
 config MK8
        bool "AMD-Opteron/Athlon64"
@@ -130,16 +143,31 @@ config MK8
          Optimize for AMD Opteron/Athlon64/Hammer/K8 CPUs.
 
 config MPSC
-       bool "Intel EM64T"
+       bool "Intel P4 / older Netburst based Xeon"
        help
-         Optimize for Intel Pentium 4 and Xeon CPUs with Intel
-         Extended Memory 64 Technology(EM64T). For details see
+         Optimize for Intel Pentium 4 and older Nocona/Dempsey Xeon CPUs
+         with Intel Extended Memory 64 Technology(EM64T). For details see
          <http://www.intel.com/technology/64bitextensions/>.
+         Note the the latest Xeons (Xeon 51xx and 53xx) are not based on the
+          Netburst core and shouldn't use this option. You can distingush them
+         using the cpu family field
+         in /proc/cpuinfo. Family 15 is a older Xeon, Family 6 a newer one
+         (this rule only applies to system that support EM64T)
+
+config MCORE2
+       bool "Intel Core2 / newer Xeon"
+       help
+         Optimize for Intel Core2 and newer Xeons (51xx)
+         You can distingush the newer Xeons from the older ones using
+         the cpu family field in /proc/cpuinfo. 15 is a older Xeon
+         (use CONFIG_MPSC then), 6 is a newer one. This rule only
+         applies to CPUs that support EM64T.
 
 config GENERIC_CPU
        bool "Generic-x86-64"
        help
          Generic x86-64 CPU.
+         Run equally well on all x86-64 CPUs.
 
 endchoice
 
@@ -149,12 +177,12 @@ endchoice
 config X86_L1_CACHE_BYTES
        int
        default "128" if GENERIC_CPU || MPSC
-       default "64" if MK8
+       default "64" if MK8 || MCORE2
 
 config X86_L1_CACHE_SHIFT
        int
        default "7" if GENERIC_CPU || MPSC
-       default "6" if MK8
+       default "6" if MK8 || MCORE2
 
 config X86_INTERNODE_CACHE_BYTES
        int
@@ -344,11 +372,6 @@ config ARCH_DISCONTIGMEM_ENABLE
        depends on NUMA
        default y
 
-
-config ARCH_DISCONTIGMEM_ENABLE
-       def_bool y
-       depends on NUMA
-
 config ARCH_DISCONTIGMEM_DEFAULT
        def_bool y
        depends on NUMA
@@ -455,6 +478,17 @@ config CALGARY_IOMMU
          Normally the kernel will make the right choice by itself.
          If unsure, say Y.
 
+config CALGARY_IOMMU_ENABLED_BY_DEFAULT
+       bool "Should Calgary be enabled by default?"
+       default y
+       depends on CALGARY_IOMMU
+       help
+         Should Calgary be enabled by default? if you choose 'y', Calgary
+         will be used (if it exists). If you choose 'n', Calgary will not be
+         used even if it exists. If you choose 'n' and would like to use
+         Calgary anyway, pass 'iommu=calgary' on the kernel command line.
+         If unsure, say Y.
+
 # need this always selected by IOMMU for the VIA workaround
 config SWIOTLB
        bool
index 6e38d4daeed7f6786c7e3067bd5329f0da2cb5ef..b471b8550d0362c2bfe15b71f1e0903c034e3399 100644 (file)
@@ -30,6 +30,10 @@ cflags-y     :=
 cflags-kernel-y        :=
 cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
 cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
+# gcc doesn't support -march=core2 yet as of gcc 4.3, but I hope it
+# will eventually. Use -mtune=generic as fallback
+cflags-$(CONFIG_MCORE2) += \
+       $(call cc-option,-march=core2,$(call cc-option,-mtune=generic))
 cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
 
 cflags-y += -m64
index 0f5d44e86be56d8b3f61a2f204d24a720b6ef92d..96f226cfb3395b4e5a83f749bc33e46694ca1b00 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.19-rc2-git4
-# Sat Oct 21 03:38:52 2006
+# Linux kernel version: 2.6.19-git7
+# Wed Dec  6 23:50:47 2006
 #
 CONFIG_X86_64=y
 CONFIG_64BIT=y
@@ -47,13 +47,14 @@ CONFIG_POSIX_MQUEUE=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 # CONFIG_CPUSETS is not set
+CONFIG_SYSFS_DEPRECATED=y
 # CONFIG_RELAY is not set
 CONFIG_INITRAMFS_SOURCE=""
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_SYSCTL=y
 # CONFIG_EMBEDDED is not set
 CONFIG_UID16=y
-# CONFIG_SYSCTL_SYSCALL is not set
+CONFIG_SYSCTL_SYSCALL=y
 CONFIG_KALLSYMS=y
 CONFIG_KALLSYMS_ALL=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
@@ -87,9 +88,7 @@ CONFIG_STOP_MACHINE=y
 # Block layer
 #
 CONFIG_BLOCK=y
-CONFIG_LBD=y
 # CONFIG_BLK_DEV_IO_TRACE is not set
-# CONFIG_LSF is not set
 
 #
 # IO Schedulers
@@ -111,10 +110,11 @@ CONFIG_X86_PC=y
 # CONFIG_X86_VSMP is not set
 # CONFIG_MK8 is not set
 # CONFIG_MPSC is not set
-CONFIG_GENERIC_CPU=y
-CONFIG_X86_L1_CACHE_BYTES=128
-CONFIG_X86_L1_CACHE_SHIFT=7
-CONFIG_X86_INTERNODE_CACHE_BYTES=128
+CONFIG_MCORE2=y
+# CONFIG_GENERIC_CPU is not set
+CONFIG_X86_L1_CACHE_BYTES=64
+CONFIG_X86_L1_CACHE_SHIFT=6
+CONFIG_X86_INTERNODE_CACHE_BYTES=64
 CONFIG_X86_TSC=y
 CONFIG_X86_GOOD_APIC=y
 # CONFIG_MICROCODE is not set
@@ -322,6 +322,7 @@ CONFIG_INET_TCP_DIAG=y
 # CONFIG_TCP_CONG_ADVANCED is not set
 CONFIG_TCP_CONG_CUBIC=y
 CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
 CONFIG_IPV6=y
 # CONFIG_IPV6_PRIVACY is not set
 # CONFIG_IPV6_ROUTER_PREF is not set
@@ -624,6 +625,7 @@ CONFIG_SATA_INTEL_COMBINED=y
 # CONFIG_PATA_IT821X is not set
 # CONFIG_PATA_JMICRON is not set
 # CONFIG_PATA_TRIFLEX is not set
+# CONFIG_PATA_MARVELL is not set
 # CONFIG_PATA_MPIIX is not set
 # CONFIG_PATA_OLDPIIX is not set
 # CONFIG_PATA_NETCELL is not set
@@ -795,6 +797,7 @@ CONFIG_BNX2=y
 CONFIG_S2IO=m
 # CONFIG_S2IO_NAPI is not set
 # CONFIG_MYRI10GE is not set
+# CONFIG_NETXEN_NIC is not set
 
 #
 # Token Ring devices
@@ -927,10 +930,6 @@ CONFIG_RTC=y
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 # CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
 CONFIG_AGP=y
 CONFIG_AGP_AMD64=y
 CONFIG_AGP_INTEL=y
@@ -1135,6 +1134,7 @@ CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_BANDWIDTH is not set
 # CONFIG_USB_DYNAMIC_MINORS is not set
 # CONFIG_USB_SUSPEND is not set
+# CONFIG_USB_MULTITHREAD_PROBE is not set
 # CONFIG_USB_OTG is not set
 
 #
@@ -1212,6 +1212,7 @@ CONFIG_USB_HIDINPUT=y
 # CONFIG_USB_KAWETH is not set
 # CONFIG_USB_PEGASUS is not set
 # CONFIG_USB_RTL8150 is not set
+# CONFIG_USB_USBNET_MII is not set
 # CONFIG_USB_USBNET is not set
 CONFIG_USB_MON=y
 
index 396d3c10001173745cb08cfe0569101319987fdb..be87df506f39dded7f4426bf518f4d36656d46d3 100644 (file)
@@ -272,7 +272,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
        if ((N_MAGIC(ex) != ZMAGIC && N_MAGIC(ex) != OMAGIC &&
             N_MAGIC(ex) != QMAGIC && N_MAGIC(ex) != NMAGIC) ||
            N_TRSIZE(ex) || N_DRSIZE(ex) ||
-           i_size_read(bprm->file->f_dentry->d_inode) < ex.a_text+ex.a_data+N_SYMSIZE(ex)+N_TXTOFF(ex)) {
+           i_size_read(bprm->file->f_path.dentry->d_inode) < ex.a_text+ex.a_data+N_SYMSIZE(ex)+N_TXTOFF(ex)) {
                return -ENOEXEC;
        }
 
@@ -357,7 +357,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
                {
                        printk(KERN_WARNING 
                               "fd_offset is not page aligned. Please convert program: %s\n",
-                              bprm->file->f_dentry->d_name.name);
+                              bprm->file->f_path.dentry->d_name.name);
                        error_time = jiffies;
                }
 #endif
@@ -440,7 +440,7 @@ static int load_aout_library(struct file *file)
        int retval;
        struct exec ex;
 
-       inode = file->f_dentry->d_inode;
+       inode = file->f_path.dentry->d_inode;
 
        retval = -ENOEXEC;
        error = kernel_read(file, 0, (char *) &ex, sizeof(ex));
@@ -471,7 +471,7 @@ static int load_aout_library(struct file *file)
                {
                        printk(KERN_WARNING 
                               "N_TXTOFF is not page aligned. Please convert library: %s\n",
-                              file->f_dentry->d_name.name);
+                              file->f_path.dentry->d_name.name);
                        error_time = jiffies;
                }
 #endif
index 82ef182de6aee197be2c796e799d24d37dff0ae3..543ef4f405e9b9589062e97d2ace859e27fbef83 100644 (file)
@@ -305,8 +305,6 @@ MODULE_AUTHOR("Eric Youngdale, Andi Kleen");
 #undef MODULE_DESCRIPTION
 #undef MODULE_AUTHOR
 
-#define elf_addr_t __u32
-
 static void elf32_init(struct pt_regs *);
 
 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
@@ -351,7 +349,7 @@ int ia32_setup_arg_pages(struct linux_binprm *bprm, unsigned long stack_top,
                bprm->loader += stack_base;
        bprm->exec += stack_base;
 
-       mpnt = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+       mpnt = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
        if (!mpnt) 
                return -ENOMEM; 
 
index 0e0a266d976fb1ee5c1b446c119b2fa2c6e34afb..ff499ef2a1ba10674cba34782c546cbeac43a51a 100644 (file)
@@ -584,6 +584,11 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
        regs->rdx = (unsigned long) &frame->info;
        regs->rcx = (unsigned long) &frame->uc;
 
+       /* Make -mregparm=3 work */
+       regs->rax = sig;
+       regs->rdx = (unsigned long) &frame->info;
+       regs->rcx = (unsigned long) &frame->uc;
+
        asm volatile("movl %0,%%ds" :: "r" (__USER32_DS)); 
        asm volatile("movl %0,%%es" :: "r" (__USER32_DS)); 
        
index 3a01329473ab42642210804fc586122d433007f8..3e5ed20cba457c7f5e0ff149cab3ec124d20ef52 100644 (file)
@@ -49,7 +49,7 @@ int syscall32_setup_pages(struct linux_binprm *bprm, int exstack)
        struct mm_struct *mm = current->mm;
        int ret;
 
-       vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+       vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
        if (!vma)
                return -ENOMEM;
 
index 4d9d5ed942b293f3383c42beb3418373143050ea..124b2d27b4acd2e912d0d7db6f9dbe1a85bb5019 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/sysdev.h>
 #include <linux/module.h>
+#include <linux/ioport.h>
 
 #include <asm/atomic.h>
 #include <asm/smp.h>
@@ -45,6 +46,12 @@ int apic_calibrate_pmtmr __initdata;
 
 int disable_apic_timer __initdata;
 
+static struct resource *ioapic_resources;
+static struct resource lapic_resource = {
+       .name = "Local APIC",
+       .flags = IORESOURCE_MEM | IORESOURCE_BUSY,
+};
+
 /*
  * cpu_mask that denotes the CPUs that needs timer interrupt coming in as
  * IPIs in place of local APIC timers
@@ -133,7 +140,6 @@ void clear_local_APIC(void)
                apic_write(APIC_LVTERR, APIC_LVT_MASKED);
        if (maxlvt >= 4)
                apic_write(APIC_LVTPC, APIC_LVT_MASKED);
-       v = GET_APIC_VERSION(apic_read(APIC_LVR));
        apic_write(APIC_ESR, 0);
        apic_read(APIC_ESR);
 }
@@ -452,23 +458,30 @@ static struct {
 static int lapic_suspend(struct sys_device *dev, pm_message_t state)
 {
        unsigned long flags;
+       int maxlvt;
 
        if (!apic_pm_state.active)
                return 0;
 
+       maxlvt = get_maxlvt();
+
        apic_pm_state.apic_id = apic_read(APIC_ID);
        apic_pm_state.apic_taskpri = apic_read(APIC_TASKPRI);
        apic_pm_state.apic_ldr = apic_read(APIC_LDR);
        apic_pm_state.apic_dfr = apic_read(APIC_DFR);
        apic_pm_state.apic_spiv = apic_read(APIC_SPIV);
        apic_pm_state.apic_lvtt = apic_read(APIC_LVTT);
-       apic_pm_state.apic_lvtpc = apic_read(APIC_LVTPC);
+       if (maxlvt >= 4)
+               apic_pm_state.apic_lvtpc = apic_read(APIC_LVTPC);
        apic_pm_state.apic_lvt0 = apic_read(APIC_LVT0);
        apic_pm_state.apic_lvt1 = apic_read(APIC_LVT1);
        apic_pm_state.apic_lvterr = apic_read(APIC_LVTERR);
        apic_pm_state.apic_tmict = apic_read(APIC_TMICT);
        apic_pm_state.apic_tdcr = apic_read(APIC_TDCR);
-       apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR);
+#ifdef CONFIG_X86_MCE_INTEL
+       if (maxlvt >= 5)
+               apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR);
+#endif
        local_irq_save(flags);
        disable_local_APIC();
        local_irq_restore(flags);
@@ -479,10 +492,13 @@ static int lapic_resume(struct sys_device *dev)
 {
        unsigned int l, h;
        unsigned long flags;
+       int maxlvt;
 
        if (!apic_pm_state.active)
                return 0;
 
+       maxlvt = get_maxlvt();
+
        local_irq_save(flags);
        rdmsr(MSR_IA32_APICBASE, l, h);
        l &= ~MSR_IA32_APICBASE_BASE;
@@ -496,8 +512,12 @@ static int lapic_resume(struct sys_device *dev)
        apic_write(APIC_SPIV, apic_pm_state.apic_spiv);
        apic_write(APIC_LVT0, apic_pm_state.apic_lvt0);
        apic_write(APIC_LVT1, apic_pm_state.apic_lvt1);
-       apic_write(APIC_LVTTHMR, apic_pm_state.apic_thmr);
-       apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc);
+#ifdef CONFIG_X86_MCE_INTEL
+       if (maxlvt >= 5)
+               apic_write(APIC_LVTTHMR, apic_pm_state.apic_thmr);
+#endif
+       if (maxlvt >= 4)
+               apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc);
        apic_write(APIC_LVTT, apic_pm_state.apic_lvtt);
        apic_write(APIC_TDCR, apic_pm_state.apic_tdcr);
        apic_write(APIC_TMICT, apic_pm_state.apic_tmict);
@@ -585,6 +605,64 @@ static int __init detect_init_APIC (void)
        return 0;
 }
 
+#ifdef CONFIG_X86_IO_APIC
+static struct resource * __init ioapic_setup_resources(void)
+{
+#define IOAPIC_RESOURCE_NAME_SIZE 11
+       unsigned long n;
+       struct resource *res;
+       char *mem;
+       int i;
+
+       if (nr_ioapics <= 0)
+               return NULL;
+
+       n = IOAPIC_RESOURCE_NAME_SIZE + sizeof(struct resource);
+       n *= nr_ioapics;
+
+       mem = alloc_bootmem(n);
+       res = (void *)mem;
+
+       if (mem != NULL) {
+               memset(mem, 0, n);
+               mem += sizeof(struct resource) * nr_ioapics;
+
+               for (i = 0; i < nr_ioapics; i++) {
+                       res[i].name = mem;
+                       res[i].flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+                       sprintf(mem,  "IOAPIC %u", i);
+                       mem += IOAPIC_RESOURCE_NAME_SIZE;
+               }
+       }
+
+       ioapic_resources = res;
+
+       return res;
+}
+
+static int __init ioapic_insert_resources(void)
+{
+       int i;
+       struct resource *r = ioapic_resources;
+
+       if (!r) {
+               printk("IO APIC resources could be not be allocated.\n");
+               return -1;
+       }
+
+       for (i = 0; i < nr_ioapics; i++) {
+               insert_resource(&iomem_resource, r);
+               r++;
+       }
+
+       return 0;
+}
+
+/* Insert the IO APIC resources after PCI initialization has occured to handle
+ * IO APICS that are mapped in on a BAR in PCI space. */
+late_initcall(ioapic_insert_resources);
+#endif
+
 void __init init_apic_mappings(void)
 {
        unsigned long apic_phys;
@@ -604,6 +682,11 @@ void __init init_apic_mappings(void)
        apic_mapped = 1;
        apic_printk(APIC_VERBOSE,"mapped APIC to %16lx (%16lx)\n", APIC_BASE, apic_phys);
 
+       /* Put local APIC into the resource map. */
+       lapic_resource.start = apic_phys;
+       lapic_resource.end = lapic_resource.start + PAGE_SIZE - 1;
+       insert_resource(&iomem_resource, &lapic_resource);
+
        /*
         * Fetch the APIC ID of the BSP in case we have a
         * default configuration (or the MP table is broken).
@@ -613,7 +696,9 @@ void __init init_apic_mappings(void)
        {
                unsigned long ioapic_phys, idx = FIX_IO_APIC_BASE_0;
                int i;
+               struct resource *ioapic_res;
 
+               ioapic_res = ioapic_setup_resources();
                for (i = 0; i < nr_ioapics; i++) {
                        if (smp_found_config) {
                                ioapic_phys = mp_ioapics[i].mpc_apicaddr;
@@ -625,6 +710,12 @@ void __init init_apic_mappings(void)
                        apic_printk(APIC_VERBOSE,"mapped IOAPIC to %016lx (%016lx)\n",
                                        __fix_to_virt(idx), ioapic_phys);
                        idx++;
+
+                       if (ioapic_res != NULL) {
+                               ioapic_res->start = ioapic_phys;
+                               ioapic_res->end = ioapic_phys + (4 * 1024) - 1;
+                               ioapic_res++;
+                       }
                }
        }
 }
@@ -644,10 +735,9 @@ void __init init_apic_mappings(void)
 
 static void __setup_APIC_LVTT(unsigned int clocks)
 {
-       unsigned int lvtt_value, tmp_value, ver;
+       unsigned int lvtt_value, tmp_value;
        int cpu = smp_processor_id();
 
-       ver = GET_APIC_VERSION(apic_read(APIC_LVR));
        lvtt_value = APIC_LVT_TIMER_PERIODIC | LOCAL_TIMER_VECTOR;
 
        if (cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask))
index 3525f884af82772592adf860d926de115b3b2d8a..95a7a2c13131d0f9c99818f8859fb792eabb57c6 100644 (file)
 /* This keeps a track of which one is crashing cpu. */
 static int crashing_cpu;
 
-static u32 *append_elf_note(u32 *buf, char *name, unsigned type,
-                                               void *data, size_t data_len)
-{
-       struct elf_note note;
-
-       note.n_namesz = strlen(name) + 1;
-       note.n_descsz = data_len;
-       note.n_type   = type;
-       memcpy(buf, &note, sizeof(note));
-       buf += (sizeof(note) +3)/4;
-       memcpy(buf, name, note.n_namesz);
-       buf += (note.n_namesz + 3)/4;
-       memcpy(buf, data, note.n_descsz);
-       buf += (note.n_descsz + 3)/4;
-
-       return buf;
-}
-
-static void final_note(u32 *buf)
-{
-       struct elf_note note;
-
-       note.n_namesz = 0;
-       note.n_descsz = 0;
-       note.n_type   = 0;
-       memcpy(buf, &note, sizeof(note));
-}
-
-static void crash_save_this_cpu(struct pt_regs *regs, int cpu)
-{
-       struct elf_prstatus prstatus;
-       u32 *buf;
-
-       if ((cpu < 0) || (cpu >= NR_CPUS))
-               return;
-
-       /* Using ELF notes here is opportunistic.
-        * I need a well defined structure format
-        * for the data I pass, and I need tags
-        * on the data to indicate what information I have
-        * squirrelled away.  ELF notes happen to provide
-        * all of that, no need to invent something new.
-        */
-
-       buf = (u32*)per_cpu_ptr(crash_notes, cpu);
-
-       if (!buf)
-               return;
-
-       memset(&prstatus, 0, sizeof(prstatus));
-       prstatus.pr_pid = current->pid;
-       elf_core_copy_regs(&prstatus.pr_reg, regs);
-       buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
-                                       sizeof(prstatus));
-       final_note(buf);
-}
-
-static void crash_save_self(struct pt_regs *regs)
-{
-       int cpu;
-
-       cpu = smp_processor_id();
-       crash_save_this_cpu(regs, cpu);
-}
-
 #ifdef CONFIG_SMP
 static atomic_t waiting_for_crash_ipi;
 
@@ -117,7 +52,7 @@ static int crash_nmi_callback(struct notifier_block *self,
                return NOTIFY_STOP;
        local_irq_disable();
 
-       crash_save_this_cpu(regs, cpu);
+       crash_save_cpu(regs, cpu);
        disable_local_APIC();
        atomic_dec(&waiting_for_crash_ipi);
        /* Assume hlt works */
@@ -196,5 +131,5 @@ void machine_crash_shutdown(struct pt_regs *regs)
 
        disable_IO_APIC();
 
-       crash_save_self(regs);
+       crash_save_cpu(regs, smp_processor_id());
 }
index 68273bff58ccf251f1f83c5da27e4a71b8f97f5b..829698f6d0490962c387f884f550678b90f8db19 100644 (file)
@@ -69,11 +69,18 @@ static void nvidia_bugs(void)
 
 static void ati_bugs(void)
 {
-       if (timer_over_8254 == 1) {
-               timer_over_8254 = 0;
-               printk(KERN_INFO
-               "ATI board detected. Disabling timer routing over 8254.\n");
-       }
+}
+
+static void intel_bugs(void)
+{
+       u16 device = read_pci_config_16(0, 0, 0, PCI_DEVICE_ID);
+
+#ifdef CONFIG_SMP
+       if (device == PCI_DEVICE_ID_INTEL_E7320_MCH ||
+           device == PCI_DEVICE_ID_INTEL_E7520_MCH ||
+           device == PCI_DEVICE_ID_INTEL_E7525_MCH)
+               quirk_intel_irqbalance();
+#endif
 }
 
 struct chipset {
@@ -85,6 +92,7 @@ static struct chipset early_qrk[] = {
        { PCI_VENDOR_ID_NVIDIA, nvidia_bugs },
        { PCI_VENDOR_ID_VIA, via_bugs },
        { PCI_VENDOR_ID_ATI, ati_bugs },
+       { PCI_VENDOR_ID_INTEL, intel_bugs},
        {}
 };
 
index 7d401b00d8227dbd6182524259a402822a903db6..601d332c4b79edc11252d6a835bbe77e6a2812e9 100644 (file)
@@ -230,7 +230,6 @@ ENTRY(system_call)
        CFI_REL_OFFSET rip,RIP-ARGOFFSET
        GET_THREAD_INFO(%rcx)
        testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%rcx)
-       CFI_REMEMBER_STATE
        jnz tracesys
        cmpq $__NR_syscall_max,%rax
        ja badsys
@@ -241,7 +240,6 @@ ENTRY(system_call)
  * Syscall return path ending with SYSRET (fast path)
  * Has incomplete stack frame and undefined top of stack. 
  */            
-       .globl ret_from_sys_call
 ret_from_sys_call:
        movl $_TIF_ALLWORK_MASK,%edi
        /* edi: flagmask */
@@ -251,8 +249,8 @@ sysret_check:
        TRACE_IRQS_OFF
        movl threadinfo_flags(%rcx),%edx
        andl %edi,%edx
-       CFI_REMEMBER_STATE
        jnz  sysret_careful 
+       CFI_REMEMBER_STATE
        /*
         * sysretq will re-enable interrupts:
         */
@@ -265,10 +263,10 @@ sysret_check:
        swapgs
        sysretq
 
+       CFI_RESTORE_STATE
        /* Handle reschedules */
        /* edx: work, edi: workmask */  
 sysret_careful:
-       CFI_RESTORE_STATE
        bt $TIF_NEED_RESCHED,%edx
        jnc sysret_signal
        TRACE_IRQS_ON
@@ -306,7 +304,6 @@ badsys:
 
        /* Do syscall tracing */
 tracesys:                       
-       CFI_RESTORE_STATE
        SAVE_REST
        movq $-ENOSYS,RAX(%rsp)
        FIXUP_TOP_OF_STACK %rdi
@@ -322,32 +319,13 @@ tracesys:
        call *sys_call_table(,%rax,8)
 1:     movq %rax,RAX-ARGOFFSET(%rsp)
        /* Use IRET because user could have changed frame */
-       jmp int_ret_from_sys_call
-       CFI_ENDPROC
-END(system_call)
                
 /* 
  * Syscall return path ending with IRET.
  * Has correct top of stack, but partial stack frame.
- */    
-ENTRY(int_ret_from_sys_call)
-       CFI_STARTPROC   simple
-       CFI_SIGNAL_FRAME
-       CFI_DEF_CFA     rsp,SS+8-ARGOFFSET
-       /*CFI_REL_OFFSET        ss,SS-ARGOFFSET*/
-       CFI_REL_OFFSET  rsp,RSP-ARGOFFSET
-       /*CFI_REL_OFFSET        rflags,EFLAGS-ARGOFFSET*/
-       /*CFI_REL_OFFSET        cs,CS-ARGOFFSET*/
-       CFI_REL_OFFSET  rip,RIP-ARGOFFSET
-       CFI_REL_OFFSET  rdx,RDX-ARGOFFSET
-       CFI_REL_OFFSET  rcx,RCX-ARGOFFSET
-       CFI_REL_OFFSET  rax,RAX-ARGOFFSET
-       CFI_REL_OFFSET  rdi,RDI-ARGOFFSET
-       CFI_REL_OFFSET  rsi,RSI-ARGOFFSET
-       CFI_REL_OFFSET  r8,R8-ARGOFFSET
-       CFI_REL_OFFSET  r9,R9-ARGOFFSET
-       CFI_REL_OFFSET  r10,R10-ARGOFFSET
-       CFI_REL_OFFSET  r11,R11-ARGOFFSET
+ */
+       .globl int_ret_from_sys_call
+int_ret_from_sys_call:
        cli
        TRACE_IRQS_OFF
        testl $3,CS-ARGOFFSET(%rsp)
@@ -394,8 +372,6 @@ int_very_careful:
        popq %rdi
        CFI_ADJUST_CFA_OFFSET -8
        andl $~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP),%edi
-       cli
-       TRACE_IRQS_OFF
        jmp int_restore_rest
        
 int_signal:
@@ -411,7 +387,7 @@ int_restore_rest:
        TRACE_IRQS_OFF
        jmp int_with_check
        CFI_ENDPROC
-END(int_ret_from_sys_call)
+END(system_call)
                
 /* 
  * Certain special system calls that need to save a complete full stack frame.
index 8e78a75d1866ffc433cb2eb4d28dc7047a0e9a64..b007433f96bbc540b2d71ef9b50f81d8349a2174 100644 (file)
@@ -33,7 +33,7 @@ extern struct genapic apic_flat;
 extern struct genapic apic_physflat;
 
 struct genapic *genapic = &apic_flat;
-
+struct genapic *genapic_force;
 
 /*
  * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
@@ -46,6 +46,13 @@ void __init clustered_apic_check(void)
        u8 cluster_cnt[NUM_APIC_CLUSTERS];
        int max_apic = 0;
 
+       /* genapic selection can be forced because of certain quirks.
+        */
+       if (genapic_force) {
+               genapic = genapic_force;
+               goto print;
+       }
+
 #if defined(CONFIG_ACPI)
        /*
         * Some x86_64 machines use physical APIC mode regardless of how many
index 9561eb3c5b5c5e78eed93277096eaf9d68752a64..cc230b93cd1c7081ea4483ac2aa8ec8192eb972a 100644 (file)
@@ -57,10 +57,12 @@ void __init x86_64_start_kernel(char * real_mode_data)
 {
        int i;
 
-       for (i = 0; i < 256; i++)
+       /* clear bss before set_intr_gate with early_idt_handler */
+       clear_bss();
+
+       for (i = 0; i < IDT_ENTRIES; i++)
                set_intr_gate(i, early_idt_handler);
        asm volatile("lidt %0" :: "m" (idt_descr));
-       clear_bss();
 
        early_printk("Kernel alive\n");
 
index 3aa1e9bb781df686854f34816b0fff661ccb9847..1d58c13bc6bc0d16d0b859846e3549c7131c5d61 100644 (file)
@@ -82,11 +82,8 @@ int save_i387(struct _fpstate __user *buf)
        struct task_struct *tsk = current;
        int err = 0;
 
-       { 
-               extern void bad_user_i387_struct(void); 
-               if (sizeof(struct user_i387_struct) != sizeof(tsk->thread.i387.fxsave))
-                       bad_user_i387_struct();
-       } 
+       BUILD_BUG_ON(sizeof(struct user_i387_struct) !=
+                       sizeof(tsk->thread.i387.fxsave));
 
        if ((unsigned long)buf % 16) 
                printk("save_i387: bad fpstate %p\n",buf); 
index c4ef801b765b8004033c83d2f6b1ac94b822fb9f..d73c79e821f172ee3efe48f490e97b947bb8c153 100644 (file)
@@ -76,7 +76,8 @@ BUILD_16_IRQS(0xc) BUILD_16_IRQS(0xd) BUILD_16_IRQS(0xe) BUILD_16_IRQS(0xf)
        IRQ(x,8), IRQ(x,9), IRQ(x,a), IRQ(x,b), \
        IRQ(x,c), IRQ(x,d), IRQ(x,e), IRQ(x,f)
 
-void (*interrupt[NR_IRQS])(void) = {
+/* for the irq vectors */
+static void (*interrupt[NR_VECTORS - FIRST_EXTERNAL_VECTOR])(void) = {
                                          IRQLIST_16(0x2), IRQLIST_16(0x3),
        IRQLIST_16(0x4), IRQLIST_16(0x5), IRQLIST_16(0x6), IRQLIST_16(0x7),
        IRQLIST_16(0x8), IRQLIST_16(0x9), IRQLIST_16(0xa), IRQLIST_16(0xb),
index c80081a6ba415584553eea8c78377663914e4347..2a1dcd5f69c2599e3b3e4b41b355a10f672f79d7 100644 (file)
@@ -55,10 +55,6 @@ int sis_apic_bug; /* not actually supported, dummy for compile */
 
 static int no_timer_check;
 
-static int disable_timer_pin_1 __initdata;
-
-int timer_over_8254 __initdata = 1;
-
 /* Where if anywhere is the i8259 connect in external int mode */
 static struct { int pin, apic; } ioapic_i8259 = { -1, -1 };
 
@@ -178,14 +174,20 @@ static struct IO_APIC_route_entry ioapic_read_entry(int apic, int pin)
  * the interrupt, and we need to make sure the entry is fully populated
  * before that happens.
  */
-static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
+static void
+__ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
 {
-       unsigned long flags;
        union entry_union eu;
        eu.entry = e;
-       spin_lock_irqsave(&ioapic_lock, flags);
        io_apic_write(apic, 0x11 + 2*pin, eu.w2);
        io_apic_write(apic, 0x10 + 2*pin, eu.w1);
+}
+
+static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
+{
+       unsigned long flags;
+       spin_lock_irqsave(&ioapic_lock, flags);
+       __ioapic_write_entry(apic, pin, e);
        spin_unlock_irqrestore(&ioapic_lock, flags);
 }
 
@@ -348,29 +350,6 @@ static int __init disable_ioapic_setup(char *str)
 }
 early_param("noapic", disable_ioapic_setup);
 
-/* Actually the next is obsolete, but keep it for paranoid reasons -AK */
-static int __init disable_timer_pin_setup(char *arg)
-{
-       disable_timer_pin_1 = 1;
-       return 1;
-}
-__setup("disable_timer_pin_1", disable_timer_pin_setup);
-
-static int __init setup_disable_8254_timer(char *s)
-{
-       timer_over_8254 = -1;
-       return 1;
-}
-static int __init setup_enable_8254_timer(char *s)
-{
-       timer_over_8254 = 2;
-       return 1;
-}
-
-__setup("disable_8254_timer", setup_disable_8254_timer);
-__setup("enable_8254_timer", setup_enable_8254_timer);
-
-
 /*
  * Find the IRQ entry number of a certain pin.
  */
@@ -750,6 +729,22 @@ static int assign_irq_vector(int irq, cpumask_t mask, cpumask_t *result)
        return vector;
 }
 
+static void __clear_irq_vector(int irq)
+{
+       cpumask_t mask;
+       int cpu, vector;
+
+       BUG_ON(!irq_vector[irq]);
+
+       vector = irq_vector[irq];
+       cpus_and(mask, irq_domain[irq], cpu_online_map);
+       for_each_cpu_mask(cpu, mask)
+               per_cpu(vector_irq, cpu)[vector] = -1;
+
+       irq_vector[irq] = 0;
+       irq_domain[irq] = CPU_MASK_NONE;
+}
+
 void __setup_vector_irq(int cpu)
 {
        /* Initialize vector_irq on a new cpu */
@@ -794,27 +789,65 @@ static void ioapic_register_intr(int irq, int vector, unsigned long trigger)
                                              handle_edge_irq, "edge");
        }
 }
-
-static void __init setup_IO_APIC_irqs(void)
+static void __init setup_IO_APIC_irq(int apic, int pin, int idx, int irq)
 {
        struct IO_APIC_route_entry entry;
-       int apic, pin, idx, irq, first_notcon = 1, vector;
+       int vector;
        unsigned long flags;
 
-       apic_printk(APIC_VERBOSE, KERN_DEBUG "init IO_APIC IRQs\n");
 
-       for (apic = 0; apic < nr_ioapics; apic++) {
-       for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) {
+       /*
+        * add it to the IO-APIC irq-routing table:
+        */
+       memset(&entry,0,sizeof(entry));
 
-               /*
-                * add it to the IO-APIC irq-routing table:
-                */
-               memset(&entry,0,sizeof(entry));
+       entry.delivery_mode = INT_DELIVERY_MODE;
+       entry.dest_mode = INT_DEST_MODE;
+       entry.mask = 0;                         /* enable IRQ */
+       entry.dest.logical.logical_dest = cpu_mask_to_apicid(TARGET_CPUS);
+
+       entry.trigger = irq_trigger(idx);
+       entry.polarity = irq_polarity(idx);
 
-               entry.delivery_mode = INT_DELIVERY_MODE;
-               entry.dest_mode = INT_DEST_MODE;
-               entry.mask = 0;                         /* enable IRQ */
+       if (irq_trigger(idx)) {
+               entry.trigger = 1;
+               entry.mask = 1;
                entry.dest.logical.logical_dest = cpu_mask_to_apicid(TARGET_CPUS);
+       }
+
+       if (!apic && !IO_APIC_IRQ(irq))
+               return;
+
+       if (IO_APIC_IRQ(irq)) {
+               cpumask_t mask;
+               vector = assign_irq_vector(irq, TARGET_CPUS, &mask);
+               if (vector < 0)
+                       return;
+
+               entry.dest.logical.logical_dest = cpu_mask_to_apicid(mask);
+               entry.vector = vector;
+
+               ioapic_register_intr(irq, vector, IOAPIC_AUTO);
+               if (!apic && (irq < 16))
+                       disable_8259A_irq(irq);
+       }
+
+       ioapic_write_entry(apic, pin, entry);
+
+       spin_lock_irqsave(&ioapic_lock, flags);
+       set_native_irq_info(irq, TARGET_CPUS);
+       spin_unlock_irqrestore(&ioapic_lock, flags);
+
+}
+
+static void __init setup_IO_APIC_irqs(void)
+{
+       int apic, pin, idx, irq, first_notcon = 1;
+
+       apic_printk(APIC_VERBOSE, KERN_DEBUG "init IO_APIC IRQs\n");
+
+       for (apic = 0; apic < nr_ioapics; apic++) {
+       for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) {
 
                idx = find_irq_entry(apic,pin,mp_INT);
                if (idx == -1) {
@@ -826,39 +859,11 @@ static void __init setup_IO_APIC_irqs(void)
                        continue;
                }
 
-               entry.trigger = irq_trigger(idx);
-               entry.polarity = irq_polarity(idx);
-
-               if (irq_trigger(idx)) {
-                       entry.trigger = 1;
-                       entry.mask = 1;
-                       entry.dest.logical.logical_dest = cpu_mask_to_apicid(TARGET_CPUS);
-               }
-
                irq = pin_2_irq(idx, apic, pin);
                add_pin_to_irq(irq, apic, pin);
 
-               if (!apic && !IO_APIC_IRQ(irq))
-                       continue;
-
-               if (IO_APIC_IRQ(irq)) {
-                       cpumask_t mask;
-                       vector = assign_irq_vector(irq, TARGET_CPUS, &mask);
-                       if (vector < 0)
-                               continue;
-
-                       entry.dest.logical.logical_dest = cpu_mask_to_apicid(mask);
-                       entry.vector = vector;
-
-                       ioapic_register_intr(irq, vector, IOAPIC_AUTO);
-                       if (!apic && (irq < 16))
-                               disable_8259A_irq(irq);
-               }
-               ioapic_write_entry(apic, pin, entry);
+               setup_IO_APIC_irq(apic, pin, idx, irq);
 
-               spin_lock_irqsave(&ioapic_lock, flags);
-               set_native_irq_info(irq, TARGET_CPUS);
-               spin_unlock_irqrestore(&ioapic_lock, flags);
        }
        }
 
@@ -1563,10 +1568,33 @@ static inline void unlock_ExtINT_logic(void)
  * a wide range of boards and BIOS bugs.  Fortunately only the timer IRQ
  * is so screwy.  Thanks to Brian Perkins for testing/hacking this beast
  * fanatically on his truly buggy board.
- *
- * FIXME: really need to revamp this for modern platforms only.
  */
-static inline void check_timer(void)
+
+static int try_apic_pin(int apic, int pin, char *msg)
+{
+       apic_printk(APIC_VERBOSE, KERN_INFO
+                   "..TIMER: trying IO-APIC=%d PIN=%d %s",
+                   apic, pin, msg);
+
+       /*
+        * Ok, does IRQ0 through the IOAPIC work?
+        */
+       if (!no_timer_check && timer_irq_works()) {
+               nmi_watchdog_default();
+               if (nmi_watchdog == NMI_IO_APIC) {
+                       disable_8259A_irq(0);
+                       setup_nmi();
+                       enable_8259A_irq(0);
+               }
+               return 1;
+       }
+       clear_IO_APIC_pin(apic, pin);
+       apic_printk(APIC_QUIET, KERN_ERR " .. failed\n");
+       return 0;
+}
+
+/* The function from hell */
+static void check_timer(void)
 {
        int apic1, pin1, apic2, pin2;
        int vector;
@@ -1587,61 +1615,43 @@ static inline void check_timer(void)
         */
        apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT);
        init_8259A(1);
-       if (timer_over_8254 > 0)
-               enable_8259A_irq(0);
 
        pin1  = find_isa_irq_pin(0, mp_INT);
        apic1 = find_isa_irq_apic(0, mp_INT);
        pin2  = ioapic_i8259.pin;
        apic2 = ioapic_i8259.apic;
 
-       apic_printk(APIC_VERBOSE,KERN_INFO "..TIMER: vector=0x%02X apic1=%d pin1=%d apic2=%d pin2=%d\n",
-               vector, apic1, pin1, apic2, pin2);
+       /* Do this first, otherwise we get double interrupts on ATI boards */
+       if ((pin1 != -1) && try_apic_pin(apic1, pin1,"with 8259 IRQ0 disabled"))
+               return;
 
-       if (pin1 != -1) {
-               /*
-                * Ok, does IRQ0 through the IOAPIC work?
-                */
-               unmask_IO_APIC_irq(0);
-               if (!no_timer_check && timer_irq_works()) {
-                       nmi_watchdog_default();
-                       if (nmi_watchdog == NMI_IO_APIC) {
-                               disable_8259A_irq(0);
-                               setup_nmi();
-                               enable_8259A_irq(0);
-                       }
-                       if (disable_timer_pin_1 > 0)
-                               clear_IO_APIC_pin(0, pin1);
-                       return;
-               }
-               clear_IO_APIC_pin(apic1, pin1);
-               apic_printk(APIC_QUIET,KERN_ERR "..MP-BIOS bug: 8254 timer not "
-                               "connected to IO-APIC\n");
-       }
+       /* Now try again with IRQ0 8259A enabled.
+          Assumes timer is on IO-APIC 0 ?!? */
+       enable_8259A_irq(0);
+       unmask_IO_APIC_irq(0);
+       if (try_apic_pin(apic1, pin1, "with 8259 IRQ0 enabled"))
+               return;
+       disable_8259A_irq(0);
+
+       /* Always try pin0 and pin2 on APIC 0 to handle buggy timer overrides
+          on Nvidia boards */
+       if (!(apic1 == 0 && pin1 == 0) &&
+           try_apic_pin(0, 0, "fallback with 8259 IRQ0 disabled"))
+               return;
+       if (!(apic1 == 0 && pin1 == 2) &&
+           try_apic_pin(0, 2, "fallback with 8259 IRQ0 disabled"))
+               return;
 
-       apic_printk(APIC_VERBOSE,KERN_INFO "...trying to set up timer (IRQ0) "
-                               "through the 8259A ... ");
+       /* Then try pure 8259A routing on the 8259 as reported by BIOS*/
+       enable_8259A_irq(0);
        if (pin2 != -1) {
-               apic_printk(APIC_VERBOSE,"\n..... (found apic %d pin %d) ...",
-                       apic2, pin2);
-               /*
-                * legacy devices should be connected to IO APIC #0
-                */
                setup_ExtINT_IRQ0_pin(apic2, pin2, vector);
-               if (timer_irq_works()) {
-                       apic_printk(APIC_VERBOSE," works.\n");
-                       nmi_watchdog_default();
-                       if (nmi_watchdog == NMI_IO_APIC) {
-                               setup_nmi();
-                       }
+               if (try_apic_pin(apic2,pin2,"8259A broadcast ExtINT from BIOS"))
                        return;
-               }
-               /*
-                * Cleanup, just in case ...
-                */
-               clear_IO_APIC_pin(apic2, pin2);
        }
-       apic_printk(APIC_VERBOSE," failed.\n");
+
+       /* Tried all possibilities to go through the IO-APIC. Now come the
+          really cheesy fallbacks. */
 
        if (nmi_watchdog == NMI_IO_APIC) {
                printk(KERN_WARNING "timer doesn't work through the IO-APIC - disabling NMI Watchdog!\n");
@@ -1837,7 +1847,7 @@ void destroy_irq(unsigned int irq)
        dynamic_irq_cleanup(irq);
 
        spin_lock_irqsave(&vector_lock, flags);
-       irq_vector[irq] = 0;
+       __clear_irq_vector(irq);
        spin_unlock_irqrestore(&vector_lock, flags);
 }
 
@@ -2139,7 +2149,15 @@ void __init setup_ioapic_dest(void)
                        if (irq_entry == -1)
                                continue;
                        irq = pin_2_irq(irq_entry, ioapic, pin);
-                       set_ioapic_affinity_irq(irq, TARGET_CPUS);
+
+                       /* setup_IO_APIC_irqs could fail to get vector for some device
+                        * when you have too many devices, because at that time only boot
+                        * cpu is online.
+                        */
+                       if(!irq_vector[irq])
+                               setup_IO_APIC_irq(ioapic, pin, irq_entry, irq);
+                       else
+                               set_ioapic_affinity_irq(irq, TARGET_CPUS);
                }
 
        }
index e46c55856d40ae6fb85daf785ca438dccba1b042..0c06af6c13bcb6c4d4e8331da76279442ce378a3 100644 (file)
@@ -120,7 +120,7 @@ asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
 
        if (likely(irq < NR_IRQS))
                generic_handle_irq(irq);
-       else
+       else if (printk_ratelimit())
                printk(KERN_EMERG "%s: %d.%d No irq handler for vector\n",
                        __func__, smp_processor_id(), vector);
 
index ac241567e682eb45c4a7918b805082cddd52f5cb..209c8c0bec717c226f9338faced9ac243b7904c9 100644 (file)
@@ -224,7 +224,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
 void __kprobes arch_remove_kprobe(struct kprobe *p)
 {
        mutex_lock(&kprobe_mutex);
-       free_insn_slot(p->ainsn.insn);
+       free_insn_slot(p->ainsn.insn, 0);
        mutex_unlock(&kprobe_mutex);
 }
 
index c7587fc390157525360146a9b94aeb59db16c7ba..ac085038af2924aab65b5eb82c77fdc26d5430d6 100644 (file)
@@ -641,7 +641,6 @@ static __cpuinit int mce_create_device(unsigned int cpu)
        return err;
 }
 
-#ifdef CONFIG_HOTPLUG_CPU
 static void mce_remove_device(unsigned int cpu)
 {
        int i;
@@ -652,6 +651,7 @@ static void mce_remove_device(unsigned int cpu)
        sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_tolerant);
        sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_check_interval);
        sysdev_unregister(&per_cpu(device_mce,cpu));
+       memset(&per_cpu(device_mce, cpu).kobj, 0, sizeof(struct kobject));
 }
 
 /* Get notified when a cpu comes on/off. Be hotplug friendly. */
@@ -674,7 +674,6 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
 static struct notifier_block mce_cpu_notifier = {
        .notifier_call = mce_cpu_callback,
 };
-#endif
 
 static __init int mce_init_device(void)
 {
index 883fe747f64c3346e21f9d8c7ceed22244287b47..fa09debad4b7c18b34966ebb3bd13bcca0937b9e 100644 (file)
@@ -551,7 +551,6 @@ out:
        return err;
 }
 
-#ifdef CONFIG_HOTPLUG_CPU
 /*
  * let's be hotplug friendly.
  * in case of multiple core processors, the first core always takes ownership
@@ -594,12 +593,14 @@ static void threshold_remove_bank(unsigned int cpu, int bank)
 
        sprintf(name, "threshold_bank%i", bank);
 
+#ifdef CONFIG_SMP
        /* sibling symlink */
        if (shared_bank[bank] && b->blocks->cpu != cpu) {
                sysfs_remove_link(&per_cpu(device_mce, cpu).kobj, name);
                per_cpu(threshold_banks, cpu)[bank] = NULL;
                return;
        }
+#endif
 
        /* remove all sibling symlinks before unregistering */
        for_each_cpu_mask(i, b->cpus) {
@@ -656,7 +657,6 @@ static int threshold_cpu_callback(struct notifier_block *nfb,
 static struct notifier_block threshold_cpu_notifier = {
        .notifier_call = threshold_cpu_callback,
 };
-#endif /* CONFIG_HOTPLUG_CPU */
 
 static __init int threshold_init_device(void)
 {
index 9d0958ff547f61a21066a3d4b2b3bd1373157209..a888e67f5874dad3415220cc9fd0c9f962c4661c 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/string.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
+#include <linux/bug.h>
 
 #include <asm/system.h>
 #include <asm/page.h>
@@ -173,10 +174,12 @@ int module_finalize(const Elf_Ehdr *hdr,
                                            lseg, lseg + locks->sh_size,
                                            tseg, tseg + text->sh_size);
        }
-       return 0;
+
+       return module_bug_finalize(hdr, sechdrs, me);
 }
 
 void module_arch_cleanup(struct module *mod)
 {
        alternatives_smp_module_del(mod);
+       module_bug_cleanup(mod);
 }
index b147ab19fbd4d65cef63c494ed8f2ea80dddd90e..08072568847d997ce0cc50d05ff3831ef33a07d9 100644 (file)
@@ -35,8 +35,6 @@
 int smp_found_config;
 unsigned int __initdata maxcpus = NR_CPUS;
 
-int acpi_found_madt;
-
 /*
  * Various Linux-internal data structures created from the
  * MP-table.
index 7af9cb3e2d99a8e71e54d89c170245580b2d470e..27e95e7922c16e6f2d637f9b677927cc049b989e 100644 (file)
  *  Mikael Pettersson  : PM converted to driver model. Disable/enable API.
  */
 
+#include <linux/nmi.h>
 #include <linux/mm.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/sysdev.h>
-#include <linux/nmi.h>
 #include <linux/sysctl.h>
 #include <linux/kprobes.h>
+#include <linux/cpumask.h>
 
 #include <asm/smp.h>
 #include <asm/nmi.h>
@@ -41,6 +42,8 @@ int panic_on_unrecovered_nmi;
 static DEFINE_PER_CPU(unsigned, perfctr_nmi_owner);
 static DEFINE_PER_CPU(unsigned, evntsel_nmi_owner[2]);
 
+static cpumask_t backtrace_mask = CPU_MASK_NONE;
+
 /* this number is calculated from Intel's MSR_P4_CRU_ESCR5 register and it's
  * offset from MSR_P4_BSU_ESCR0.  It will be the max for all platforms (for now)
  */
@@ -782,6 +785,7 @@ int __kprobes nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
 {
        int sum;
        int touched = 0;
+       int cpu = smp_processor_id();
        struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
        u64 dummy;
        int rc=0;
@@ -799,6 +803,16 @@ int __kprobes nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
                touched = 1;
        }
 
+       if (cpu_isset(cpu, backtrace_mask)) {
+               static DEFINE_SPINLOCK(lock);   /* Serialise the printks */
+
+               spin_lock(&lock);
+               printk("NMI backtrace for cpu %d\n", cpu);
+               dump_stack();
+               spin_unlock(&lock);
+               cpu_clear(cpu, backtrace_mask);
+       }
+
 #ifdef CONFIG_X86_MCE
        /* Could check oops_in_progress here too, but it's safer
           not too */
@@ -931,6 +945,19 @@ int proc_nmi_enabled(struct ctl_table *table, int write, struct file *file,
 
 #endif
 
+void __trigger_all_cpu_backtrace(void)
+{
+       int i;
+
+       backtrace_mask = cpu_online_map;
+       /* Wait for up to 10 seconds for all CPUs to do the backtrace */
+       for (i = 0; i < 10 * 1000; i++) {
+               if (cpus_empty(backtrace_mask))
+                       break;
+               mdelay(1);
+       }
+}
+
 EXPORT_SYMBOL(nmi_active);
 EXPORT_SYMBOL(nmi_watchdog);
 EXPORT_SYMBOL(avail_to_resrv_perfctr_nmi);
index 37a770859e7180ae38e06c22d6064fbe1a4ebeab..3215675ab128b35ce7c793cd234b62f5a8ac795a 100644 (file)
 #include <asm/pci-direct.h>
 #include <asm/system.h>
 #include <asm/dma.h>
+#include <asm/rio.h>
+
+#ifdef CONFIG_CALGARY_IOMMU_ENABLED_BY_DEFAULT
+int use_calgary __read_mostly = 1;
+#else
+int use_calgary __read_mostly = 0;
+#endif /* CONFIG_CALGARY_DEFAULT_ENABLED */
 
 #define PCI_DEVICE_ID_IBM_CALGARY 0x02a1
 #define PCI_VENDOR_DEVICE_ID_CALGARY \
@@ -115,14 +122,35 @@ static const unsigned long phb_offsets[] = {
        0xB000 /* PHB3 */
 };
 
+/* PHB debug registers */
+
+static const unsigned long phb_debug_offsets[] = {
+       0x4000  /* PHB 0 DEBUG */,
+       0x5000  /* PHB 1 DEBUG */,
+       0x6000  /* PHB 2 DEBUG */,
+       0x7000  /* PHB 3 DEBUG */
+};
+
+/*
+ * STUFF register for each debug PHB,
+ * byte 1 = start bus number, byte 2 = end bus number
+ */
+
+#define PHB_DEBUG_STUFF_OFFSET 0x0020
+
 unsigned int specified_table_size = TCE_TABLE_SIZE_UNSPECIFIED;
 static int translate_empty_slots __read_mostly = 0;
 static int calgary_detected __read_mostly = 0;
 
+static struct rio_table_hdr    *rio_table_hdr __initdata;
+static struct scal_detail      *scal_devs[MAX_NUMNODES] __initdata;
+static struct rio_detail       *rio_devs[MAX_NUMNODES * 4] __initdata;
+
 struct calgary_bus_info {
        void *tce_space;
        unsigned char translation_disabled;
        signed char phbid;
+       void __iomem *bbar;
 };
 
 static struct calgary_bus_info bus_info[MAX_PHB_BUS_NUM] = { { NULL, 0, 0 }, };
@@ -475,6 +503,11 @@ static struct dma_mapping_ops calgary_dma_ops = {
        .unmap_sg = calgary_unmap_sg,
 };
 
+static inline void __iomem * busno_to_bbar(unsigned char num)
+{
+       return bus_info[num].bbar;
+}
+
 static inline int busno_to_phbid(unsigned char num)
 {
        return bus_info[num].phbid;
@@ -620,14 +653,9 @@ static void __init calgary_reserve_peripheral_mem_2(struct pci_dev *dev)
 static void __init calgary_reserve_regions(struct pci_dev *dev)
 {
        unsigned int npages;
-       void __iomem *bbar;
-       unsigned char busnum;
        u64 start;
        struct iommu_table *tbl = dev->sysdata;
 
-       bbar = tbl->bbar;
-       busnum = dev->bus->number;
-
        /* reserve bad_dma_address in case it's a legal address */
        iommu_range_reserve(tbl, bad_dma_address, 1);
 
@@ -740,7 +768,7 @@ static void __init calgary_increase_split_completion_timeout(void __iomem *bbar,
 {
        u64 val64;
        void __iomem *target;
-       unsigned long phb_shift = -1;
+       unsigned int phb_shift = ~0; /* silence gcc */
        u64 mask;
 
        switch (busno_to_phbid(busnum)) {
@@ -828,33 +856,6 @@ static void __init calgary_disable_translation(struct pci_dev *dev)
        del_timer_sync(&tbl->watchdog_timer);
 }
 
-static inline unsigned int __init locate_register_space(struct pci_dev *dev)
-{
-       int rionodeid;
-       u32 address;
-
-       /*
-        * Each Calgary has four busses. The first four busses (first Calgary)
-        * have RIO node ID 2, then the next four (second Calgary) have RIO
-        * node ID 3, the next four (third Calgary) have node ID 2 again, etc.
-        * We use a gross hack - relying on the dev->bus->number ordering,
-        * modulo 14 - to decide which Calgary a given bus is on. Busses 0, 1,
-        * 2 and 4 are on the first Calgary (id 2), 6, 8, a and c are on the
-        * second (id 3), and then it repeats modulo 14.
-        */
-       rionodeid = (dev->bus->number % 14 > 4) ? 3 : 2;
-       /*
-        * register space address calculation as follows:
-        * FE0MB-8MB*OneBasedChassisNumber+1MB*(RioNodeId-ChassisBase)
-        * ChassisBase is always zero for x366/x260/x460
-        * RioNodeId is 2 for first Calgary, 3 for second Calgary
-        */
-       address = START_ADDRESS -
-               (0x800000 * (ONE_BASED_CHASSIS_NUM + dev->bus->number / 14)) +
-               (0x100000) * (rionodeid - CHASSIS_BASE);
-       return address;
-}
-
 static void __init calgary_init_one_nontraslated(struct pci_dev *dev)
 {
        pci_dev_get(dev);
@@ -864,23 +865,15 @@ static void __init calgary_init_one_nontraslated(struct pci_dev *dev)
 
 static int __init calgary_init_one(struct pci_dev *dev)
 {
-       u32 address;
        void __iomem *bbar;
        int ret;
 
        BUG_ON(dev->bus->number >= MAX_PHB_BUS_NUM);
 
-       address = locate_register_space(dev);
-       /* map entire 1MB of Calgary config space */
-       bbar = ioremap_nocache(address, 1024 * 1024);
-       if (!bbar) {
-               ret = -ENODATA;
-               goto done;
-       }
-
+       bbar = busno_to_bbar(dev->bus->number);
        ret = calgary_setup_tar(dev, bbar);
        if (ret)
-               goto iounmap;
+               goto done;
 
        pci_dev_get(dev);
        dev->bus->self = dev;
@@ -888,17 +881,66 @@ static int __init calgary_init_one(struct pci_dev *dev)
 
        return 0;
 
-iounmap:
-       iounmap(bbar);
 done:
        return ret;
 }
 
+static int __init calgary_locate_bbars(void)
+{
+       int ret;
+       int rioidx, phb, bus;
+       void __iomem *bbar;
+       void __iomem *target;
+       unsigned long offset;
+       u8 start_bus, end_bus;
+       u32 val;
+
+       ret = -ENODATA;
+       for (rioidx = 0; rioidx < rio_table_hdr->num_rio_dev; rioidx++) {
+               struct rio_detail *rio = rio_devs[rioidx];
+
+               if ((rio->type != COMPAT_CALGARY) && (rio->type != ALT_CALGARY))
+                       continue;
+
+               /* map entire 1MB of Calgary config space */
+               bbar = ioremap_nocache(rio->BBAR, 1024 * 1024);
+               if (!bbar)
+                       goto error;
+
+               for (phb = 0; phb < PHBS_PER_CALGARY; phb++) {
+                       offset = phb_debug_offsets[phb] | PHB_DEBUG_STUFF_OFFSET;
+                       target = calgary_reg(bbar, offset);
+
+                       val = be32_to_cpu(readl(target));
+                       start_bus = (u8)((val & 0x00FF0000) >> 16);
+                       end_bus = (u8)((val & 0x0000FF00) >> 8);
+                       for (bus = start_bus; bus <= end_bus; bus++) {
+                               bus_info[bus].bbar = bbar;
+                               bus_info[bus].phbid = phb;
+                       }
+               }
+       }
+
+       return 0;
+
+error:
+       /* scan bus_info and iounmap any bbars we previously ioremap'd */
+       for (bus = 0; bus < ARRAY_SIZE(bus_info); bus++)
+               if (bus_info[bus].bbar)
+                       iounmap(bus_info[bus].bbar);
+
+       return ret;
+}
+
 static int __init calgary_init(void)
 {
-       int ret = -ENODEV;
+       int ret;
        struct pci_dev *dev = NULL;
 
+       ret = calgary_locate_bbars();
+       if (ret)
+               return ret;
+
        do {
                dev = pci_get_device(PCI_VENDOR_ID_IBM,
                                     PCI_DEVICE_ID_IBM_CALGARY,
@@ -921,7 +963,7 @@ static int __init calgary_init(void)
 
 error:
        do {
-               dev = pci_find_device_reverse(PCI_VENDOR_ID_IBM,
+               dev = pci_get_device_reverse(PCI_VENDOR_ID_IBM,
                                              PCI_DEVICE_ID_IBM_CALGARY,
                                              dev);
                if (!dev)
@@ -962,13 +1004,56 @@ static inline int __init determine_tce_table_size(u64 ram)
        return ret;
 }
 
+static int __init build_detail_arrays(void)
+{
+       unsigned long ptr;
+       int i, scal_detail_size, rio_detail_size;
+
+       if (rio_table_hdr->num_scal_dev > MAX_NUMNODES){
+               printk(KERN_WARNING
+                       "Calgary: MAX_NUMNODES too low! Defined as %d, "
+                       "but system has %d nodes.\n",
+                       MAX_NUMNODES, rio_table_hdr->num_scal_dev);
+               return -ENODEV;
+       }
+
+       switch (rio_table_hdr->version){
+       case 2:
+               scal_detail_size = 11;
+               rio_detail_size = 13;
+               break;
+       case 3:
+               scal_detail_size = 12;
+               rio_detail_size = 15;
+               break;
+       default:
+               printk(KERN_WARNING
+                      "Calgary: Invalid Rio Grande Table Version: %d\n",
+                      rio_table_hdr->version);
+               return -EPROTO;
+       }
+
+       ptr = ((unsigned long)rio_table_hdr) + 3;
+       for (i = 0; i < rio_table_hdr->num_scal_dev;
+                   i++, ptr += scal_detail_size)
+               scal_devs[i] = (struct scal_detail *)ptr;
+
+       for (i = 0; i < rio_table_hdr->num_rio_dev;
+                   i++, ptr += rio_detail_size)
+               rio_devs[i] = (struct rio_detail *)ptr;
+
+       return 0;
+}
+
 void __init detect_calgary(void)
 {
        u32 val;
        int bus;
        void *tbl;
        int calgary_found = 0;
-       int phb = -1;
+       unsigned long ptr;
+       int offset;
+       int ret;
 
        /*
         * if the user specified iommu=off or iommu=soft or we found
@@ -977,25 +1062,47 @@ void __init detect_calgary(void)
        if (swiotlb || no_iommu || iommu_detected)
                return;
 
+       if (!use_calgary)
+               return;
+
        if (!early_pci_allowed())
                return;
 
+       ptr = (unsigned long)phys_to_virt(get_bios_ebda());
+
+       rio_table_hdr = NULL;
+       offset = 0x180;
+       while (offset) {
+               /* The block id is stored in the 2nd word */
+               if (*((unsigned short *)(ptr + offset + 2)) == 0x4752){
+                       /* set the pointer past the offset & block id */
+                       rio_table_hdr = (struct rio_table_hdr *)(ptr + offset + 4);
+                       break;
+               }
+               /* The next offset is stored in the 1st word. 0 means no more */
+               offset = *((unsigned short *)(ptr + offset));
+       }
+       if (!rio_table_hdr) {
+               printk(KERN_ERR "Calgary: Unable to locate "
+                               "Rio Grande Table in EBDA - bailing!\n");
+               return;
+       }
+
+       ret = build_detail_arrays();
+       if (ret) {
+               printk(KERN_ERR "Calgary: build_detail_arrays ret %d\n", ret);
+               return;
+       }
+
        specified_table_size = determine_tce_table_size(end_pfn * PAGE_SIZE);
 
        for (bus = 0; bus < MAX_PHB_BUS_NUM; bus++) {
                int dev;
                struct calgary_bus_info *info = &bus_info[bus];
-               info->phbid = -1;
 
                if (read_pci_config(bus, 0, 0, 0) != PCI_VENDOR_DEVICE_ID_CALGARY)
                        continue;
 
-               /*
-                * There are 4 PHBs per Calgary chip.  Set phb to which phb (0-3)
-                * it is connected to releative to the clagary chip.
-                */
-               phb = (phb + 1) % PHBS_PER_CALGARY;
-
                if (info->translation_disabled)
                        continue;
 
@@ -1010,7 +1117,6 @@ void __init detect_calgary(void)
                                if (!tbl)
                                        goto cleanup;
                                info->tce_space = tbl;
-                               info->phbid = phb;
                                calgary_found = 1;
                                break;
                        }
index f8d857453f8afaf5fc839060cf1ad07dc69d13dc..683b7a5c1ab30170d716a99fe90c633187f4a827 100644 (file)
@@ -296,6 +296,11 @@ __init int iommu_setup(char *p)
                gart_parse_options(p);
 #endif
 
+#ifdef CONFIG_CALGARY_IOMMU
+               if (!strncmp(p, "calgary", 7))
+                       use_calgary = 1;
+#endif /* CONFIG_CALGARY_IOMMU */
+
                p += strcspn(p, ",");
                if (*p == ',')
                        ++p;
index 16261a8a3303ed044fba4b31eb612a9f9c3454aa..fc1960f1f243982f8ecd6746ce0bddb8828ab633 100644 (file)
@@ -601,10 +601,9 @@ void __init gart_iommu_init(void)
            (!force_iommu && end_pfn <= MAX_DMA32_PFN) ||
            !iommu_aperture ||
            (no_agp && init_k8_gatt(&info) < 0)) {
-               printk(KERN_INFO "PCI-DMA: Disabling IOMMU.\n");
                if (end_pfn > MAX_DMA32_PFN) {
                        printk(KERN_ERR "WARNING more than 4GB of memory "
-                                       "but IOMMU not available.\n"
+                                       "but GART IOMMU not available.\n"
                               KERN_ERR "WARNING 32bit PCI may malfunction.\n");
                }
                return;
index 7451a4c43c1681639c0aa5fbb2640d509ccac603..a418ee4c8c62a0d14102b22939dfa8c5b16d0f79 100644 (file)
@@ -108,17 +108,15 @@ void exit_idle(void)
  */
 static void default_idle(void)
 {
-       local_irq_enable();
-
        current_thread_info()->status &= ~TS_POLLING;
        smp_mb__after_clear_bit();
-       while (!need_resched()) {
-               local_irq_disable();
-               if (!need_resched())
-                       safe_halt();
-               else
-                       local_irq_enable();
-       }
+       local_irq_disable();
+       if (!need_resched()) {
+               /* Enables interrupts one instruction before HLT.
+                  x86 special cases this so there is no race. */
+               safe_halt();
+       } else
+               local_irq_enable();
        current_thread_info()->status |= TS_POLLING;
 }
 
@@ -130,15 +128,7 @@ static void default_idle(void)
 static void poll_idle (void)
 {
        local_irq_enable();
-
-       asm volatile(
-               "2:"
-               "testl %0,%1;"
-               "rep; nop;"
-               "je 2b;"
-               : :
-               "i" (_TIF_NEED_RESCHED),
-               "m" (current_thread_info()->flags));
+       cpu_relax();
 }
 
 void cpu_idle_wait(void)
@@ -219,6 +209,12 @@ void cpu_idle (void)
                                idle = default_idle;
                        if (cpu_is_offline(smp_processor_id()))
                                play_dead();
+                       /*
+                        * Idle routines should keep interrupts disabled
+                        * from here on, until they go to idle.
+                        * Otherwise, idle callbacks can misfire.
+                        */
+                       local_irq_disable();
                        enter_idle();
                        idle();
                        /* In many cases the interrupt that ended idle
@@ -256,9 +252,16 @@ void mwait_idle_with_hints(unsigned long eax, unsigned long ecx)
 /* Default MONITOR/MWAIT with no hints, used for default C1 state */
 static void mwait_idle(void)
 {
-       local_irq_enable();
-       while (!need_resched())
-               mwait_idle_with_hints(0,0);
+       if (!need_resched()) {
+               __monitor((void *)&current_thread_info()->flags, 0, 0);
+               smp_mb();
+               if (!need_resched())
+                       __sti_mwait(0, 0);
+               else
+                       local_irq_enable();
+       } else {
+               local_irq_enable();
+       }
 }
 
 void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
index fc944b5e8f4a6050612a0c9220c713e2f47d3a51..af425a8049fb5620596a0bc61bf005d399df3e32 100644 (file)
@@ -471,8 +471,7 @@ void __init setup_arch(char **cmdline_p)
        if (LOADER_TYPE && INITRD_START) {
                if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) {
                        reserve_bootmem_generic(INITRD_START, INITRD_SIZE);
-                       initrd_start =
-                               INITRD_START ? INITRD_START + PAGE_OFFSET : 0;
+                       initrd_start = INITRD_START + PAGE_OFFSET;
                        initrd_end = initrd_start+INITRD_SIZE;
                }
                else {
@@ -732,11 +731,8 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
        /* Fix cpuid4 emulation for more */
        num_cache_leaves = 3;
 
-       /* When there is only one core no need to synchronize RDTSC */
-       if (num_possible_cpus() == 1)
-               set_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
-       else
-               clear_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
+       /* RDTSC can be speculated around */
+       clear_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
 }
 
 static void __cpuinit detect_ht(struct cpuinfo_x86 *c)
@@ -835,6 +831,15 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
                        set_bit(X86_FEATURE_ARCH_PERFMON, &c->x86_capability);
        }
 
+       if (cpu_has_ds) {
+               unsigned int l1, l2;
+               rdmsr(MSR_IA32_MISC_ENABLE, l1, l2);
+               if (!(l1 & (1<<11)))
+                       set_bit(X86_FEATURE_BTS, c->x86_capability);
+               if (!(l1 & (1<<12)))
+                       set_bit(X86_FEATURE_PEBS, c->x86_capability);
+       }
+
        n = c->extended_cpuid_level;
        if (n >= 0x80000008) {
                unsigned eax = cpuid_eax(0x80000008);
@@ -854,7 +859,10 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
                set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability);
        if (c->x86 == 6)
                set_bit(X86_FEATURE_REP_GOOD, &c->x86_capability);
-       set_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
+       if (c->x86 == 15)
+               set_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
+       else
+               clear_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
        c->x86_max_cores = intel_num_cpu_cores(c);
 
        srat_detect_node();
index 9f74c883568c419909b6542449161d5b109f6b51..af1ec4d23cf89131f16e5063f31c81a6810c63ba 100644 (file)
@@ -379,12 +379,17 @@ int smp_call_function_single (int cpu, void (*func) (void *info), void *info,
                put_cpu();
                return 0;
        }
+
+       /* Can deadlock when called with interrupts disabled */
+       WARN_ON(irqs_disabled());
+
        spin_lock_bh(&call_lock);
        __smp_call_function_single(cpu, func, info, nonatomic, wait);
        spin_unlock_bh(&call_lock);
        put_cpu();
        return 0;
 }
+EXPORT_SYMBOL(smp_call_function_single);
 
 /*
  * this function sends a 'generic call function' IPI to all other CPUs
index 9800147c4c68e86fa9fefa848c4d7e73cdfb59e5..daf19332f0dd02ed7ab4257e5c887989dfeb0ef8 100644 (file)
@@ -60,6 +60,7 @@
 #include <asm/irq.h>
 #include <asm/hw_irq.h>
 #include <asm/numa.h>
+#include <asm/genapic.h>
 
 /* Number of siblings per CPU package */
 int smp_num_siblings = 1;
@@ -1169,6 +1170,13 @@ int __cpuinit __cpu_up(unsigned int cpu)
 
        while (!cpu_isset(cpu, cpu_online_map))
                cpu_relax();
+
+       if (num_online_cpus() > 8 && genapic == &apic_flat) {
+               printk(KERN_WARNING
+                      "flat APIC routing can't be used with > 8 cpus\n");
+               BUG();
+       }
+
        err = 0;
 
        return err;
index 0d65b22f229ccfbf895ff2aa12e3dd2d9977cdd8..b54ccc07f37944dba409ac9a27761c5d5e0ce848 100644 (file)
 #include <linux/kprobes.h>
 #include <linux/kexec.h>
 #include <linux/unwind.h>
+#include <linux/uaccess.h>
+#include <linux/bug.h>
 
 #include <asm/system.h>
-#include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/atomic.h>
 #include <asm/debugreg.h>
@@ -108,7 +109,7 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
        preempt_enable_no_resched();
 }
 
-static int kstack_depth_to_print = 12;
+int kstack_depth_to_print = 12;
 #ifdef CONFIG_STACK_UNWIND
 static int call_trace = 1;
 #else
@@ -225,16 +226,25 @@ static int dump_trace_unwind(struct unwind_frame_info *info, void *context)
 {
        struct ops_and_data *oad = (struct ops_and_data *)context;
        int n = 0;
+       unsigned long sp = UNW_SP(info);
 
+       if (arch_unw_user_mode(info))
+               return -1;
        while (unwind(info) == 0 && UNW_PC(info)) {
                n++;
                oad->ops->address(oad->data, UNW_PC(info));
                if (arch_unw_user_mode(info))
                        break;
+               if ((sp & ~(PAGE_SIZE - 1)) == (UNW_SP(info) & ~(PAGE_SIZE - 1))
+                   && sp > UNW_SP(info))
+                       break;
+               sp = UNW_SP(info);
        }
        return n;
 }
 
+#define MSG(txt) ops->warning(data, txt)
+
 /*
  * x86-64 can have upto three kernel stacks: 
  * process stack
@@ -248,11 +258,12 @@ static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
         return p > t && p < t + THREAD_SIZE - 3;
 }
 
-void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * stack,
+void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
+               unsigned long *stack,
                struct stacktrace_ops *ops, void *data)
 {
-       const unsigned cpu = smp_processor_id();
-       unsigned long *irqstack_end = (unsigned long *)cpu_pda(cpu)->irqstackptr;
+       const unsigned cpu = get_cpu();
+       unsigned long *irqstack_end = (unsigned long*)cpu_pda(cpu)->irqstackptr;
        unsigned used = 0;
        struct thread_info *tinfo;
 
@@ -268,28 +279,30 @@ void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * s
                        if (unwind_init_frame_info(&info, tsk, regs) == 0)
                                unw_ret = dump_trace_unwind(&info, &oad);
                } else if (tsk == current)
-                       unw_ret = unwind_init_running(&info, dump_trace_unwind, &oad);
+                       unw_ret = unwind_init_running(&info, dump_trace_unwind,
+                                                     &oad);
                else {
                        if (unwind_init_blocked(&info, tsk) == 0)
                                unw_ret = dump_trace_unwind(&info, &oad);
                }
                if (unw_ret > 0) {
                        if (call_trace == 1 && !arch_unw_user_mode(&info)) {
-                               ops->warning_symbol(data, "DWARF2 unwinder stuck at %s\n",
+                               ops->warning_symbol(data,
+                                            "DWARF2 unwinder stuck at %s",
                                             UNW_PC(&info));
                                if ((long)UNW_SP(&info) < 0) {
-                                       ops->warning(data, "Leftover inexact backtrace:\n");
+                                       MSG("Leftover inexact backtrace:");
                                        stack = (unsigned long *)UNW_SP(&info);
                                        if (!stack)
-                                               return;
+                                               goto out;
                                } else
-                                       ops->warning(data, "Full inexact backtrace again:\n");
+                                       MSG("Full inexact backtrace again:");
                        } else if (call_trace >= 1)
-                               return;
+                               goto out;
                        else
-                               ops->warning(data, "Full inexact backtrace again:\n");
+                               MSG("Full inexact backtrace again:");
                } else
-                       ops->warning(data, "Inexact backtrace:\n");
+                       MSG("Inexact backtrace:");
        }
        if (!stack) {
                unsigned long dummy;
@@ -297,12 +310,6 @@ void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * s
                if (tsk && tsk != current)
                        stack = (unsigned long *)tsk->thread.rsp;
        }
-       /*
-        * Align the stack pointer on word boundary, later loops
-        * rely on that (and corruption / debug info bugs can cause
-        * unaligned values here):
-        */
-       stack = (unsigned long *)((unsigned long)stack & ~(sizeof(long)-1));
 
        /*
         * Print function call entries within a stack. 'cond' is the
@@ -312,9 +319,9 @@ void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * s
 #define HANDLE_STACK(cond) \
        do while (cond) { \
                unsigned long addr = *stack++; \
-               if (oops_in_progress ?          \
-                       __kernel_text_address(addr) : \
-                       kernel_text_address(addr)) { \
+               /* Use unlocked access here because except for NMIs     \
+                  we should be already protected against module unloads */ \
+               if (__kernel_text_address(addr)) { \
                        /* \
                         * If the address is either in the text segment of the \
                         * kernel, or in the region which contains vmalloc'ed \
@@ -380,6 +387,8 @@ void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * s
        tinfo = current_thread_info();
        HANDLE_STACK (valid_stack_ptr(tinfo, stack));
 #undef HANDLE_STACK
+out:
+       put_cpu();
 }
 EXPORT_SYMBOL(dump_trace);
 
@@ -516,30 +525,15 @@ bad:
        printk("\n");
 }      
 
-void handle_BUG(struct pt_regs *regs)
-{ 
-       struct bug_frame f;
-       long len;
-       const char *prefix = "";
+int is_valid_bugaddr(unsigned long rip)
+{
+       unsigned short ud2;
 
-       if (user_mode(regs))
-               return; 
-       if (__copy_from_user(&f, (const void __user *) regs->rip,
-                            sizeof(struct bug_frame)))
-               return; 
-       if (f.filename >= 0 ||
-           f.ud2[0] != 0x0f || f.ud2[1] != 0x0b) 
-               return;
-       len = __strnlen_user((char *)(long)f.filename, PATH_MAX) - 1;
-       if (len < 0 || len >= PATH_MAX)
-               f.filename = (int)(long)"unmapped filename";
-       else if (len > 50) {
-               f.filename += len - 50;
-               prefix = "...";
-       }
-       printk("----------- [cut here ] --------- [please bite here ] ---------\n");
-       printk(KERN_ALERT "Kernel BUG at %s%.50s:%d\n", prefix, (char *)(long)f.filename, f.line);
-} 
+       if (__copy_from_user(&ud2, (const void __user *) rip, sizeof(ud2)))
+               return 0;
+
+       return ud2 == 0x0b0f;
+}
 
 #ifdef CONFIG_BUG
 void out_of_line_bug(void)
@@ -619,7 +613,9 @@ void die(const char * str, struct pt_regs * regs, long err)
 {
        unsigned long flags = oops_begin();
 
-       handle_BUG(regs);
+       if (!user_mode(regs))
+               report_bug(regs->rip);
+
        __die(str, regs, err);
        oops_end(flags);
        do_exit(SIGSEGV); 
@@ -786,8 +782,7 @@ mem_parity_error(unsigned char reason, struct pt_regs * regs)
 {
        printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x.\n",
                reason);
-       printk(KERN_EMERG "You probably have a hardware problem with your "
-               "RAM chips\n");
+       printk(KERN_EMERG "You have some hardware problem, likely on the PCI bus.\n");
 
        if (panic_on_unrecovered_nmi)
                panic("NMI: Not continuing");
index d9534e750d4fa548e7f2a016b94fb022ee7689c0..6c417788c54b3658489e063c11b8c1146d013e74 100644 (file)
@@ -51,14 +51,7 @@ SECTIONS
 
   RODATA
 
-#ifdef CONFIG_STACK_UNWIND
-  . = ALIGN(8);
-  .eh_frame : AT(ADDR(.eh_frame) - LOAD_OFFSET) {
-       __start_unwind = .;
-       *(.eh_frame)
-       __end_unwind = .;
-  }
-#endif
+  BUG_TABLE
 
   . = ALIGN(PAGE_SIZE);        /* Align data segment to page size boundary */
                                /* Data */
index 92546c1526f1fece35fb8ed07bfeefc7b3414c0d..4a673f5397a05fbbf5aec90b5067bbafcd8e1ad5 100644 (file)
@@ -42,6 +42,7 @@
 #include <asm/topology.h>
 
 #define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr)))
+#define __syscall_clobber "r11","rcx","memory"
 
 int __sysctl_vsyscall __section_sysctl_vsyscall = 1;
 seqlock_t __xtime_lock __section_xtime_lock = SEQLOCK_UNLOCKED;
@@ -274,7 +275,6 @@ static void __cpuinit cpu_vsyscall_init(void *arg)
        vsyscall_set_cpu(raw_smp_processor_id());
 }
 
-#ifdef CONFIG_HOTPLUG_CPU
 static int __cpuinit
 cpu_vsyscall_notifier(struct notifier_block *n, unsigned long action, void *arg)
 {
@@ -283,13 +283,13 @@ cpu_vsyscall_notifier(struct notifier_block *n, unsigned long action, void *arg)
                smp_call_function_single(cpu, cpu_vsyscall_init, NULL, 0, 1);
        return NOTIFY_DONE;
 }
-#endif
 
 static void __init map_vsyscall(void)
 {
        extern char __vsyscall_0;
        unsigned long physaddr_page0 = __pa_symbol(&__vsyscall_0);
 
+       /* Note that VSYSCALL_MAPPED_PAGES must agree with the code below. */
        __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_page0, PAGE_KERNEL_VSYSCALL);
 }
 
index 06ae630de82b1138c948f0131e7a93b99c50cddf..bc503f506903a486a9a2fb4c56afd144466fff18 100644 (file)
@@ -9,8 +9,6 @@
 #include <linux/module.h>
 #include <asm/checksum.h>
 
-#define __force_inline inline __attribute__((always_inline))
-
 static inline unsigned short from32to16(unsigned a) 
 {
        unsigned short b = a >> 16; 
@@ -33,7 +31,7 @@ static inline unsigned short from32to16(unsigned a)
  * Unrolling to an 128 bytes inner loop.
  * Using interleaving with more registers to break the carry chains.
  */
-static __force_inline unsigned do_csum(const unsigned char *buff, unsigned len)
+static unsigned do_csum(const unsigned char *buff, unsigned len)
 {
        unsigned odd, count;
        unsigned long result = 0;
index 50be90975d04a40e08f9a3c72329fbe9b7ec7cdd..2dbebd308347f21be2ad931ce480a6ade16e72b2 100644 (file)
@@ -40,13 +40,13 @@ EXPORT_SYMBOL(__delay);
 
 inline void __const_udelay(unsigned long xloops)
 {
-       __delay((xloops * HZ * cpu_data[raw_smp_processor_id()].loops_per_jiffy) >> 32);
+       __delay(((xloops * HZ * cpu_data[raw_smp_processor_id()].loops_per_jiffy) >> 32) + 1);
 }
 EXPORT_SYMBOL(__const_udelay);
 
 void __udelay(unsigned long usecs)
 {
-       __const_udelay(usecs * 0x000010c6);  /* 2**32 / 1000000 */
+       __const_udelay(usecs * 0x000010c7);  /* 2**32 / 1000000 (rounded up) */
 }
 EXPORT_SYMBOL(__udelay);
 
index 3751b4788e288748112c05df0121a1186aac5fab..a65fc6f1dcaff5ec3dd876a609a4f56fd3d7abf5 100644 (file)
@@ -23,9 +23,9 @@
 #include <linux/compiler.h>
 #include <linux/module.h>
 #include <linux/kprobes.h>
+#include <linux/uaccess.h>
 
 #include <asm/system.h>
-#include <asm/uaccess.h>
 #include <asm/pgalloc.h>
 #include <asm/smp.h>
 #include <asm/tlbflush.h>
@@ -96,7 +96,7 @@ void bust_spinlocks(int yes)
 static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
                                unsigned long error_code)
 { 
-       unsigned char __user *instr;
+       unsigned char *instr;
        int scan_more = 1;
        int prefetch = 0; 
        unsigned char *max_instr;
@@ -116,7 +116,7 @@ static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
                unsigned char instr_hi;
                unsigned char instr_lo;
 
-               if (__get_user(opcode, (char __user *)instr))
+               if (probe_kernel_address(instr, opcode))
                        break; 
 
                instr_hi = opcode & 0xf0; 
@@ -154,7 +154,7 @@ static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
                case 0x00:
                        /* Prefetch instruction is 0x0F0D or 0x0F18 */
                        scan_more = 0;
-                       if (__get_user(opcode, (char __user *)instr))
+                       if (probe_kernel_address(instr, opcode))
                                break;
                        prefetch = (instr_lo == 0xF) &&
                                (opcode == 0x0D || opcode == 0x18);
@@ -170,7 +170,7 @@ static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
 static int bad_address(void *p) 
 { 
        unsigned long dummy;
-       return __get_user(dummy, (unsigned long __user *)p);
+       return probe_kernel_address((unsigned long *)p, dummy);
 } 
 
 void dump_pagetable(unsigned long address)
index 4c0c00ef3ca769c027591b4d5b6483e9b13b9228..2968b90ef8adfec3d0316a3ef7b8d8e49628284d 100644 (file)
@@ -730,14 +730,15 @@ static __init int x8664_sysctl_init(void)
 __initcall(x8664_sysctl_init);
 #endif
 
-/* A pseudo VMAs to allow ptrace access for the vsyscall page.   This only
+/* A pseudo VMA to allow ptrace access for the vsyscall page.  This only
    covers the 64bit vsyscall page now. 32bit has a real VMA now and does
    not need special handling anymore. */
 
 static struct vm_area_struct gate_vma = {
        .vm_start = VSYSCALL_START,
-       .vm_end = VSYSCALL_END,
-       .vm_page_prot = PAGE_READONLY
+       .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES << PAGE_SHIFT),
+       .vm_page_prot = PAGE_READONLY_EXEC,
+       .vm_flags = VM_READ | VM_EXEC
 };
 
 struct vm_area_struct *get_gate_vma(struct task_struct *tsk)
index 3e231d762aaa8527d112687c711747f98f4bac83..ccb91dd996a957c1dc26f183e095c3a8edbd30f1 100644 (file)
@@ -61,34 +61,40 @@ static struct page *split_large_page(unsigned long address, pgprot_t prot,
        return base;
 } 
 
-
-static void flush_kernel_map(void *address) 
+static void cache_flush_page(void *adr)
 {
-       if (0 && address && cpu_has_clflush) {
-               /* is this worth it? */ 
-               int i;
-               for (i = 0; i < PAGE_SIZE; i += boot_cpu_data.x86_clflush_size) 
-                       asm volatile("clflush (%0)" :: "r" (address + i)); 
-       } else
-               asm volatile("wbinvd":::"memory"); 
-       if (address)
-               __flush_tlb_one(address);
-       else
-               __flush_tlb_all();
+       int i;
+       for (i = 0; i < PAGE_SIZE; i += boot_cpu_data.x86_clflush_size)
+               asm volatile("clflush (%0)" :: "r" (adr + i));
 }
 
+static void flush_kernel_map(void *arg)
+{
+       struct list_head *l = (struct list_head *)arg;
+       struct page *pg;
+
+       /* When clflush is available always use it because it is
+          much cheaper than WBINVD */
+       if (!cpu_has_clflush)
+               asm volatile("wbinvd" ::: "memory");
+       list_for_each_entry(pg, l, lru) {
+               void *adr = page_address(pg);
+               if (cpu_has_clflush)
+                       cache_flush_page(adr);
+               __flush_tlb_one(adr);
+       }
+}
 
-static inline void flush_map(unsigned long address)
+static inline void flush_map(struct list_head *l)
 {      
-       on_each_cpu(flush_kernel_map, (void *)address, 1, 1);
+       on_each_cpu(flush_kernel_map, l, 1, 1);
 }
 
-static struct page *deferred_pages; /* protected by init_mm.mmap_sem */
+static LIST_HEAD(deferred_pages); /* protected by init_mm.mmap_sem */
 
 static inline void save_page(struct page *fpage)
 {
-       fpage->lru.next = (struct list_head *)deferred_pages;
-       deferred_pages = fpage;
+       list_add(&fpage->lru, &deferred_pages);
 }
 
 /* 
@@ -207,18 +213,18 @@ int change_page_attr(struct page *page, int numpages, pgprot_t prot)
 
 void global_flush_tlb(void)
 { 
-       struct page *dpage;
+       struct page *pg, *next;
+       struct list_head l;
 
        down_read(&init_mm.mmap_sem);
-       dpage = xchg(&deferred_pages, NULL);
+       list_replace_init(&deferred_pages, &l);
        up_read(&init_mm.mmap_sem);
 
-       flush_map((dpage && !dpage->lru.next) ? (unsigned long)page_address(dpage) : 0);
-       while (dpage) {
-               struct page *tmp = dpage;
-               dpage = (struct page *)dpage->lru.next;
-               ClearPagePrivate(tmp);
-               __free_page(tmp);
+       flush_map(&l);
+
+       list_for_each_entry_safe(pg, next, &l, lru) {
+               ClearPagePrivate(pg);
+               __free_page(pg);
        } 
 } 
 
index c1e69a1f92a4bf5adbc94e9f5417487502607cf4..9eccfbd1b536a4850132a7ead6a814d828f086f6 100644 (file)
@@ -34,6 +34,14 @@ config GENERIC_HARDIRQS
        bool
        default y
 
+config ARCH_HAS_ILOG2_U32
+       bool
+       default n
+
+config ARCH_HAS_ILOG2_U64
+       bool
+       default n
+
 source "init/Kconfig"
 
 menu "Processor type and features"
index 74e02c04b2dab6eb9567a49f9e589cfe69fb2e9e..d3679dd1d2201785e91194415d01736a16af54bc 100644 (file)
@@ -394,8 +394,7 @@ err:
        if (bt) {
                if (bt->dropped_file)
                        debugfs_remove(bt->dropped_file);
-               if (bt->sequence)
-                       free_percpu(bt->sequence);
+               free_percpu(bt->sequence);
                if (bt->rchan)
                        relay_close(bt->rchan);
                kfree(bt);
index 84e9be073180253baab4cfddb69fbc2a4a14e764..78c6b312bd3030d3c86a9c35e3facc842b73e3eb 100644 (file)
@@ -43,8 +43,8 @@ static int cfq_slice_idle = HZ / 125;
 #define RQ_CIC(rq)             ((struct cfq_io_context*)(rq)->elevator_private)
 #define RQ_CFQQ(rq)            ((rq)->elevator_private2)
 
-static kmem_cache_t *cfq_pool;
-static kmem_cache_t *cfq_ioc_pool;
+static struct kmem_cache *cfq_pool;
+static struct kmem_cache *cfq_ioc_pool;
 
 static DEFINE_PER_CPU(unsigned long, ioc_count);
 static struct completion *ioc_gone;
index 653919d50cd4d06aea68d8e027d15a473e5b4f5a..457fdac4c17d98db97cebd0c6910e23f4f97399f 100644 (file)
@@ -417,6 +417,34 @@ static struct disk_attribute disk_attr_stat = {
        .show   = disk_stats_read
 };
 
+#ifdef CONFIG_FAIL_MAKE_REQUEST
+
+static ssize_t disk_fail_store(struct gendisk * disk,
+                              const char *buf, size_t count)
+{
+       int i;
+
+       if (count > 0 && sscanf(buf, "%d", &i) > 0) {
+               if (i == 0)
+                       disk->flags &= ~GENHD_FL_FAIL;
+               else
+                       disk->flags |= GENHD_FL_FAIL;
+       }
+
+       return count;
+}
+static ssize_t disk_fail_read(struct gendisk * disk, char *page)
+{
+       return sprintf(page, "%d\n", disk->flags & GENHD_FL_FAIL ? 1 : 0);
+}
+static struct disk_attribute disk_attr_fail = {
+       .attr = {.name = "make-it-fail", .mode = S_IRUGO | S_IWUSR },
+       .store  = disk_fail_store,
+       .show   = disk_fail_read
+};
+
+#endif
+
 static struct attribute * default_attrs[] = {
        &disk_attr_uevent.attr,
        &disk_attr_dev.attr,
@@ -424,6 +452,9 @@ static struct attribute * default_attrs[] = {
        &disk_attr_removable.attr,
        &disk_attr_size.attr,
        &disk_attr_stat.attr,
+#ifdef CONFIG_FAIL_MAKE_REQUEST
+       &disk_attr_fail.attr,
+#endif
        NULL,
 };
 
index 58aab630dfc1a55eaf06975d5a48600b5f14e49e..f6962b64660ea67c6092c6303d7d52cd69bffbeb 100644 (file)
@@ -72,7 +72,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
                        bdevp = bdget_disk(disk, part);
                        if (!bdevp)
                                return -ENOMEM;
-                       mutex_lock_nested(&bdevp->bd_mutex, BD_MUTEX_PARTITION);
+                       mutex_lock(&bdevp->bd_mutex);
                        if (bdevp->bd_openers) {
                                mutex_unlock(&bdevp->bd_mutex);
                                bdput(bdevp);
@@ -82,7 +82,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
                        fsync_bdev(bdevp);
                        invalidate_bdev(bdevp, 0);
 
-                       mutex_lock_nested(&bdev->bd_mutex, BD_MUTEX_WHOLE);
+                       mutex_lock(&bdev->bd_mutex);
                        delete_partition(disk, part);
                        mutex_unlock(&bdev->bd_mutex);
                        mutex_unlock(&bdevp->bd_mutex);
@@ -290,7 +290,7 @@ int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd,
    ENOIOCTLCMD for unknown ioctls. */
 long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
 {
-       struct block_device *bdev = file->f_dentry->d_inode->i_bdev;
+       struct block_device *bdev = file->f_path.dentry->d_inode->i_bdev;
        struct gendisk *disk = bdev->bd_disk;
        int ret = -ENOIOCTLCMD;
        if (disk->fops->compat_ioctl) {
index cc6e95f8e5d9b05820251f8ef948f492d4ff6d33..4f83fd92237756e74a959565ca9b6f8b76440165 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/interrupt.h>
 #include <linux/cpu.h>
 #include <linux/blktrace_api.h>
+#include <linux/fault-inject.h>
 
 /*
  * for max sense size
@@ -44,17 +45,17 @@ static struct io_context *current_io_context(gfp_t gfp_flags, int node);
 /*
  * For the allocated request tables
  */
-static kmem_cache_t *request_cachep;
+static struct kmem_cache *request_cachep;
 
 /*
  * For queue allocation
  */
-static kmem_cache_t *requestq_cachep;
+static struct kmem_cache *requestq_cachep;
 
 /*
  * For io context allocations
  */
-static kmem_cache_t *iocontext_cachep;
+static struct kmem_cache *iocontext_cachep;
 
 /*
  * Controlling structure to kblockd
@@ -3056,6 +3057,42 @@ static void handle_bad_sector(struct bio *bio)
        set_bit(BIO_EOF, &bio->bi_flags);
 }
 
+#ifdef CONFIG_FAIL_MAKE_REQUEST
+
+static DECLARE_FAULT_ATTR(fail_make_request);
+
+static int __init setup_fail_make_request(char *str)
+{
+       return setup_fault_attr(&fail_make_request, str);
+}
+__setup("fail_make_request=", setup_fail_make_request);
+
+static int should_fail_request(struct bio *bio)
+{
+       if ((bio->bi_bdev->bd_disk->flags & GENHD_FL_FAIL) ||
+           (bio->bi_bdev->bd_part && bio->bi_bdev->bd_part->make_it_fail))
+               return should_fail(&fail_make_request, bio->bi_size);
+
+       return 0;
+}
+
+static int __init fail_make_request_debugfs(void)
+{
+       return init_fault_attr_dentries(&fail_make_request,
+                                       "fail_make_request");
+}
+
+late_initcall(fail_make_request_debugfs);
+
+#else /* CONFIG_FAIL_MAKE_REQUEST */
+
+static inline int should_fail_request(struct bio *bio)
+{
+       return 0;
+}
+
+#endif /* CONFIG_FAIL_MAKE_REQUEST */
+
 /**
  * generic_make_request: hand a buffer to its device driver for I/O
  * @bio:  The bio describing the location in memory and on the device.
@@ -3141,6 +3178,9 @@ end_io:
                if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags)))
                        goto end_io;
 
+               if (should_fail_request(bio))
+                       goto end_io;
+
                /*
                 * If this device has partitions, remap block n
                 * of partition p to block n+start(p) of the disk.
@@ -3459,8 +3499,6 @@ static void blk_done_softirq(struct softirq_action *h)
        }
 }
 
-#ifdef CONFIG_HOTPLUG_CPU
-
 static int blk_cpu_notify(struct notifier_block *self, unsigned long action,
                          void *hcpu)
 {
@@ -3486,8 +3524,6 @@ static struct notifier_block __devinitdata blk_cpu_notifier = {
        .notifier_call  = blk_cpu_notify,
 };
 
-#endif /* CONFIG_HOTPLUG_CPU */
-
 /**
  * blk_complete_request - end I/O on a request
  * @req:      the request being processed
index cbae8392ce11b848e5573194eb8591a175815822..92ba249f3a5bf6bfc64d4aca0200ad9812bac999 100644 (file)
@@ -39,6 +39,17 @@ config CRYPTO_HMAC
          HMAC: Keyed-Hashing for Message Authentication (RFC2104).
          This is required for IPSec.
 
+config CRYPTO_XCBC
+       tristate "XCBC support"
+       depends on EXPERIMENTAL
+       select CRYPTO_HASH
+       select CRYPTO_MANAGER
+       help
+         XCBC: Keyed-Hashing with encryption algorithm
+               http://www.ietf.org/rfc/rfc3566.txt
+               http://csrc.nist.gov/encryption/modes/proposedmodes/
+                xcbc-mac/xcbc-mac-spec.pdf
+
 config CRYPTO_NULL
        tristate "Null algorithms"
        select CRYPTO_ALGAPI
@@ -128,6 +139,16 @@ config CRYPTO_TGR192
          See also:
          <http://www.cs.technion.ac.il/~biham/Reports/Tiger/>.
 
+config CRYPTO_GF128MUL
+       tristate "GF(2^128) multiplication functions (EXPERIMENTAL)"
+       depends on EXPERIMENTAL
+       help
+         Efficient table driven implementation of multiplications in the
+         field GF(2^128).  This is needed by some cypher modes. This
+         option will be selected automatically if you select such a
+         cipher mode.  Only select this option by hand if you expect to load
+         an external module that requires these functions.
+
 config CRYPTO_ECB
        tristate "ECB support"
        select CRYPTO_BLKCIPHER
@@ -147,6 +168,19 @@ config CRYPTO_CBC
          CBC: Cipher Block Chaining mode
          This block cipher algorithm is required for IPSec.
 
+config CRYPTO_LRW
+       tristate "LRW support (EXPERIMENTAL)"
+       depends on EXPERIMENTAL
+       select CRYPTO_BLKCIPHER
+       select CRYPTO_MANAGER
+       select CRYPTO_GF128MUL
+       help
+         LRW: Liskov Rivest Wagner, a tweakable, non malleable, non movable
+         narrow block cipher mode for dm-crypt.  Use it with cipher
+         specification string aes-lrw-benbi, the key must be 256, 320 or 384.
+         The first 128, 192 or 256 bits in the key are used for AES and the
+         rest is used to tie each cipher block to its logical position.
+
 config CRYPTO_DES
        tristate "DES and Triple DES EDE cipher algorithms"
        select CRYPTO_ALGAPI
index 72366208e291cbbbbbfc89f5c4ddbbb26ec6e5ff..60e3d24f61f56a28c9c2e91eb84a4cac05671366 100644 (file)
@@ -15,6 +15,7 @@ obj-$(CONFIG_CRYPTO_HASH) += crypto_hash.o
 
 obj-$(CONFIG_CRYPTO_MANAGER) += cryptomgr.o
 obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
+obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
 obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o
 obj-$(CONFIG_CRYPTO_MD4) += md4.o
 obj-$(CONFIG_CRYPTO_MD5) += md5.o
@@ -23,8 +24,10 @@ obj-$(CONFIG_CRYPTO_SHA256) += sha256.o
 obj-$(CONFIG_CRYPTO_SHA512) += sha512.o
 obj-$(CONFIG_CRYPTO_WP512) += wp512.o
 obj-$(CONFIG_CRYPTO_TGR192) += tgr192.o
+obj-$(CONFIG_CRYPTO_GF128MUL) += gf128mul.o
 obj-$(CONFIG_CRYPTO_ECB) += ecb.o
 obj-$(CONFIG_CRYPTO_CBC) += cbc.o
+obj-$(CONFIG_CRYPTO_LRW) += lrw.o
 obj-$(CONFIG_CRYPTO_DES) += des.o
 obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish.o
 obj-$(CONFIG_CRYPTO_TWOFISH) += twofish.o
index 4fb7fa45cb0de649194262c5f6061669b3391a80..8c446871cd5b13998294850338bb4ce93930f069 100644 (file)
@@ -466,23 +466,8 @@ void crypto_free_tfm(struct crypto_tfm *tfm)
        kfree(tfm);
 }
 
-int crypto_alg_available(const char *name, u32 flags)
-{
-       int ret = 0;
-       struct crypto_alg *alg = crypto_alg_mod_lookup(name, 0,
-                                                      CRYPTO_ALG_ASYNC);
-       
-       if (!IS_ERR(alg)) {
-               crypto_mod_put(alg);
-               ret = 1;
-       }
-       
-       return ret;
-}
-
 EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
 EXPORT_SYMBOL_GPL(crypto_free_tfm);
-EXPORT_SYMBOL_GPL(crypto_alg_available);
 
 int crypto_has_alg(const char *name, u32 type, u32 mask)
 {
index 0155a94e4b15432b636559124370436fa8edf5af..8f4593268ce0bf5c5ef2e9e47d8ab72789adb842 100644 (file)
 #include "internal.h"
 #include "scatterwalk.h"
 
-void crypto_digest_init(struct crypto_tfm *tfm)
-{
-       struct crypto_hash *hash = crypto_hash_cast(tfm);
-       struct hash_desc desc = { .tfm = hash, .flags = tfm->crt_flags };
-
-       crypto_hash_init(&desc);
-}
-EXPORT_SYMBOL_GPL(crypto_digest_init);
-
-void crypto_digest_update(struct crypto_tfm *tfm,
-                         struct scatterlist *sg, unsigned int nsg)
-{
-       struct crypto_hash *hash = crypto_hash_cast(tfm);
-       struct hash_desc desc = { .tfm = hash, .flags = tfm->crt_flags };
-       unsigned int nbytes = 0;
-       unsigned int i;
-
-       for (i = 0; i < nsg; i++)
-               nbytes += sg[i].length;
-
-       crypto_hash_update(&desc, sg, nbytes);
-}
-EXPORT_SYMBOL_GPL(crypto_digest_update);
-
-void crypto_digest_final(struct crypto_tfm *tfm, u8 *out)
-{
-       struct crypto_hash *hash = crypto_hash_cast(tfm);
-       struct hash_desc desc = { .tfm = hash, .flags = tfm->crt_flags };
-
-       crypto_hash_final(&desc, out);
-}
-EXPORT_SYMBOL_GPL(crypto_digest_final);
-
-void crypto_digest_digest(struct crypto_tfm *tfm,
-                         struct scatterlist *sg, unsigned int nsg, u8 *out)
-{
-       struct crypto_hash *hash = crypto_hash_cast(tfm);
-       struct hash_desc desc = { .tfm = hash, .flags = tfm->crt_flags };
-       unsigned int nbytes = 0;
-       unsigned int i;
-
-       for (i = 0; i < nsg; i++)
-               nbytes += sg[i].length;
-
-       crypto_hash_digest(&desc, sg, nbytes, out);
-}
-EXPORT_SYMBOL_GPL(crypto_digest_digest);
-
 static int init(struct hash_desc *desc)
 {
        struct crypto_tfm *tfm = crypto_hash_tfm(desc->tfm);
diff --git a/crypto/gf128mul.c b/crypto/gf128mul.c
new file mode 100644 (file)
index 0000000..0a2aadf
--- /dev/null
@@ -0,0 +1,466 @@
+/* gf128mul.c - GF(2^128) multiplication functions
+ *
+ * Copyright (c) 2003, Dr Brian Gladman, Worcester, UK.
+ * Copyright (c) 2006, Rik Snel <rsnel@cube.dyndns.org>
+ *
+ * Based on Dr Brian Gladman's (GPL'd) work published at
+ * http://fp.gladman.plus.com/cryptography_technology/index.htm
+ * See the original copyright notice below.
+ *
+ * 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.
+ */
+
+/*
+ ---------------------------------------------------------------------------
+ Copyright (c) 2003, Dr Brian Gladman, Worcester, UK.   All rights reserved.
+
+ LICENSE TERMS
+
+ The free distribution and use of this software in both source and binary
+ form is allowed (with or without changes) provided that:
+
+   1. distributions of this source code include the above copyright
+      notice, this list of conditions and the following disclaimer;
+
+   2. distributions in binary form include the above copyright
+      notice, this list of conditions and the following disclaimer
+      in the documentation and/or other associated materials;
+
+   3. the copyright holder's name is not used to endorse products
+      built using this software without specific written permission.
+
+ ALTERNATIVELY, provided that this notice is retained in full, this product
+ may be distributed under the terms of the GNU General Public License (GPL),
+ in which case the provisions of the GPL apply INSTEAD OF those given above.
+
+ DISCLAIMER
+
+ This software is provided 'as is' with no explicit or implied warranties
+ in respect of its properties, including, but not limited to, correctness
+ and/or fitness for purpose.
+ ---------------------------------------------------------------------------
+ Issue 31/01/2006
+
+ This file provides fast multiplication in GF(128) as required by several
+ cryptographic authentication modes
+*/
+
+#include <crypto/gf128mul.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+
+#define gf128mul_dat(q) { \
+       q(0x00), q(0x01), q(0x02), q(0x03), q(0x04), q(0x05), q(0x06), q(0x07),\
+       q(0x08), q(0x09), q(0x0a), q(0x0b), q(0x0c), q(0x0d), q(0x0e), q(0x0f),\
+       q(0x10), q(0x11), q(0x12), q(0x13), q(0x14), q(0x15), q(0x16), q(0x17),\
+       q(0x18), q(0x19), q(0x1a), q(0x1b), q(0x1c), q(0x1d), q(0x1e), q(0x1f),\
+       q(0x20), q(0x21), q(0x22), q(0x23), q(0x24), q(0x25), q(0x26), q(0x27),\
+       q(0x28), q(0x29), q(0x2a), q(0x2b), q(0x2c), q(0x2d), q(0x2e), q(0x2f),\
+       q(0x30), q(0x31), q(0x32), q(0x33), q(0x34), q(0x35), q(0x36), q(0x37),\
+       q(0x38), q(0x39), q(0x3a), q(0x3b), q(0x3c), q(0x3d), q(0x3e), q(0x3f),\
+       q(0x40), q(0x41), q(0x42), q(0x43), q(0x44), q(0x45), q(0x46), q(0x47),\
+       q(0x48), q(0x49), q(0x4a), q(0x4b), q(0x4c), q(0x4d), q(0x4e), q(0x4f),\
+       q(0x50), q(0x51), q(0x52), q(0x53), q(0x54), q(0x55), q(0x56), q(0x57),\
+       q(0x58), q(0x59), q(0x5a), q(0x5b), q(0x5c), q(0x5d), q(0x5e), q(0x5f),\
+       q(0x60), q(0x61), q(0x62), q(0x63), q(0x64), q(0x65), q(0x66), q(0x67),\
+       q(0x68), q(0x69), q(0x6a), q(0x6b), q(0x6c), q(0x6d), q(0x6e), q(0x6f),\
+       q(0x70), q(0x71), q(0x72), q(0x73), q(0x74), q(0x75), q(0x76), q(0x77),\
+       q(0x78), q(0x79), q(0x7a), q(0x7b), q(0x7c), q(0x7d), q(0x7e), q(0x7f),\
+       q(0x80), q(0x81), q(0x82), q(0x83), q(0x84), q(0x85), q(0x86), q(0x87),\
+       q(0x88), q(0x89), q(0x8a), q(0x8b), q(0x8c), q(0x8d), q(0x8e), q(0x8f),\
+       q(0x90), q(0x91), q(0x92), q(0x93), q(0x94), q(0x95), q(0x96), q(0x97),\
+       q(0x98), q(0x99), q(0x9a), q(0x9b), q(0x9c), q(0x9d), q(0x9e), q(0x9f),\
+       q(0xa0), q(0xa1), q(0xa2), q(0xa3), q(0xa4), q(0xa5), q(0xa6), q(0xa7),\
+       q(0xa8), q(0xa9), q(0xaa), q(0xab), q(0xac), q(0xad), q(0xae), q(0xaf),\
+       q(0xb0), q(0xb1), q(0xb2), q(0xb3), q(0xb4), q(0xb5), q(0xb6), q(0xb7),\
+       q(0xb8), q(0xb9), q(0xba), q(0xbb), q(0xbc), q(0xbd), q(0xbe), q(0xbf),\
+       q(0xc0), q(0xc1), q(0xc2), q(0xc3), q(0xc4), q(0xc5), q(0xc6), q(0xc7),\
+       q(0xc8), q(0xc9), q(0xca), q(0xcb), q(0xcc), q(0xcd), q(0xce), q(0xcf),\
+       q(0xd0), q(0xd1), q(0xd2), q(0xd3), q(0xd4), q(0xd5), q(0xd6), q(0xd7),\
+       q(0xd8), q(0xd9), q(0xda), q(0xdb), q(0xdc), q(0xdd), q(0xde), q(0xdf),\
+       q(0xe0), q(0xe1), q(0xe2), q(0xe3), q(0xe4), q(0xe5), q(0xe6), q(0xe7),\
+       q(0xe8), q(0xe9), q(0xea), q(0xeb), q(0xec), q(0xed), q(0xee), q(0xef),\
+       q(0xf0), q(0xf1), q(0xf2), q(0xf3), q(0xf4), q(0xf5), q(0xf6), q(0xf7),\
+       q(0xf8), q(0xf9), q(0xfa), q(0xfb), q(0xfc), q(0xfd), q(0xfe), q(0xff) \
+}
+
+/*     Given the value i in 0..255 as the byte overflow when a field element
+    in GHASH is multipled by x^8, this function will return the values that
+    are generated in the lo 16-bit word of the field value by applying the
+    modular polynomial. The values lo_byte and hi_byte are returned via the
+    macro xp_fun(lo_byte, hi_byte) so that the values can be assembled into
+    memory as required by a suitable definition of this macro operating on
+    the table above
+*/
+
+#define xx(p, q)       0x##p##q
+
+#define xda_bbe(i) ( \
+       (i & 0x80 ? xx(43, 80) : 0) ^ (i & 0x40 ? xx(21, c0) : 0) ^ \
+       (i & 0x20 ? xx(10, e0) : 0) ^ (i & 0x10 ? xx(08, 70) : 0) ^ \
+       (i & 0x08 ? xx(04, 38) : 0) ^ (i & 0x04 ? xx(02, 1c) : 0) ^ \
+       (i & 0x02 ? xx(01, 0e) : 0) ^ (i & 0x01 ? xx(00, 87) : 0) \
+)
+
+#define xda_lle(i) ( \
+       (i & 0x80 ? xx(e1, 00) : 0) ^ (i & 0x40 ? xx(70, 80) : 0) ^ \
+       (i & 0x20 ? xx(38, 40) : 0) ^ (i & 0x10 ? xx(1c, 20) : 0) ^ \
+       (i & 0x08 ? xx(0e, 10) : 0) ^ (i & 0x04 ? xx(07, 08) : 0) ^ \
+       (i & 0x02 ? xx(03, 84) : 0) ^ (i & 0x01 ? xx(01, c2) : 0) \
+)
+
+static const u16 gf128mul_table_lle[256] = gf128mul_dat(xda_lle);
+static const u16 gf128mul_table_bbe[256] = gf128mul_dat(xda_bbe);
+
+/* These functions multiply a field element by x, by x^4 and by x^8
+ * in the polynomial field representation. It uses 32-bit word operations
+ * to gain speed but compensates for machine endianess and hence works
+ * correctly on both styles of machine.
+ */
+
+static void gf128mul_x_lle(be128 *r, const be128 *x)
+{
+       u64 a = be64_to_cpu(x->a);
+       u64 b = be64_to_cpu(x->b);
+       u64 _tt = gf128mul_table_lle[(b << 7) & 0xff];
+
+       r->b = cpu_to_be64((b >> 1) | (a << 63));
+       r->a = cpu_to_be64((a >> 1) ^ (_tt << 48));
+}
+
+static void gf128mul_x_bbe(be128 *r, const be128 *x)
+{
+       u64 a = be64_to_cpu(x->a);
+       u64 b = be64_to_cpu(x->b);
+       u64 _tt = gf128mul_table_bbe[a >> 63];
+
+       r->a = cpu_to_be64((a << 1) | (b >> 63));
+       r->b = cpu_to_be64((b << 1) ^ _tt);
+}
+
+static void gf128mul_x8_lle(be128 *x)
+{
+       u64 a = be64_to_cpu(x->a);
+       u64 b = be64_to_cpu(x->b);
+       u64 _tt = gf128mul_table_lle[b & 0xff];
+
+       x->b = cpu_to_be64((b >> 8) | (a << 56));
+       x->a = cpu_to_be64((a >> 8) ^ (_tt << 48));
+}
+
+static void gf128mul_x8_bbe(be128 *x)
+{
+       u64 a = be64_to_cpu(x->a);
+       u64 b = be64_to_cpu(x->b);
+       u64 _tt = gf128mul_table_bbe[a >> 56];
+
+       x->a = cpu_to_be64((a << 8) | (b >> 56));
+       x->b = cpu_to_be64((b << 8) ^ _tt);
+}
+
+void gf128mul_lle(be128 *r, const be128 *b)
+{
+       be128 p[8];
+       int i;
+
+       p[0] = *r;
+       for (i = 0; i < 7; ++i)
+               gf128mul_x_lle(&p[i + 1], &p[i]);
+
+       memset(r, 0, sizeof(r));
+       for (i = 0;;) {
+               u8 ch = ((u8 *)b)[15 - i];
+
+               if (ch & 0x80)
+                       be128_xor(r, r, &p[0]);
+               if (ch & 0x40)
+                       be128_xor(r, r, &p[1]);
+               if (ch & 0x20)
+                       be128_xor(r, r, &p[2]);
+               if (ch & 0x10)
+                       be128_xor(r, r, &p[3]);
+               if (ch & 0x08)
+                       be128_xor(r, r, &p[4]);
+               if (ch & 0x04)
+                       be128_xor(r, r, &p[5]);
+               if (ch & 0x02)
+                       be128_xor(r, r, &p[6]);
+               if (ch & 0x01)
+                       be128_xor(r, r, &p[7]);
+
+               if (++i >= 16)
+                       break;
+
+               gf128mul_x8_lle(r);
+       }
+}
+EXPORT_SYMBOL(gf128mul_lle);
+
+void gf128mul_bbe(be128 *r, const be128 *b)
+{
+       be128 p[8];
+       int i;
+
+       p[0] = *r;
+       for (i = 0; i < 7; ++i)
+               gf128mul_x_bbe(&p[i + 1], &p[i]);
+
+       memset(r, 0, sizeof(r));
+       for (i = 0;;) {
+               u8 ch = ((u8 *)b)[i];
+
+               if (ch & 0x80)
+                       be128_xor(r, r, &p[7]);
+               if (ch & 0x40)
+                       be128_xor(r, r, &p[6]);
+               if (ch & 0x20)
+                       be128_xor(r, r, &p[5]);
+               if (ch & 0x10)
+                       be128_xor(r, r, &p[4]);
+               if (ch & 0x08)
+                       be128_xor(r, r, &p[3]);
+               if (ch & 0x04)
+                       be128_xor(r, r, &p[2]);
+               if (ch & 0x02)
+                       be128_xor(r, r, &p[1]);
+               if (ch & 0x01)
+                       be128_xor(r, r, &p[0]);
+
+               if (++i >= 16)
+                       break;
+
+               gf128mul_x8_bbe(r);
+       }
+}
+EXPORT_SYMBOL(gf128mul_bbe);
+
+/*      This version uses 64k bytes of table space.
+    A 16 byte buffer has to be multiplied by a 16 byte key
+    value in GF(128).  If we consider a GF(128) value in
+    the buffer's lowest byte, we can construct a table of
+    the 256 16 byte values that result from the 256 values
+    of this byte.  This requires 4096 bytes. But we also
+    need tables for each of the 16 higher bytes in the
+    buffer as well, which makes 64 kbytes in total.
+*/
+/* additional explanation
+ * t[0][BYTE] contains g*BYTE
+ * t[1][BYTE] contains g*x^8*BYTE
+ *  ..
+ * t[15][BYTE] contains g*x^120*BYTE */
+struct gf128mul_64k *gf128mul_init_64k_lle(const be128 *g)
+{
+       struct gf128mul_64k *t;
+       int i, j, k;
+
+       t = kzalloc(sizeof(*t), GFP_KERNEL);
+       if (!t)
+               goto out;
+
+       for (i = 0; i < 16; i++) {
+               t->t[i] = kzalloc(sizeof(*t->t[i]), GFP_KERNEL);
+               if (!t->t[i]) {
+                       gf128mul_free_64k(t);
+                       t = NULL;
+                       goto out;
+               }
+       }
+
+       t->t[0]->t[128] = *g;
+       for (j = 64; j > 0; j >>= 1)
+               gf128mul_x_lle(&t->t[0]->t[j], &t->t[0]->t[j + j]);
+
+       for (i = 0;;) {
+               for (j = 2; j < 256; j += j)
+                       for (k = 1; k < j; ++k)
+                               be128_xor(&t->t[i]->t[j + k],
+                                         &t->t[i]->t[j], &t->t[i]->t[k]);
+
+               if (++i >= 16)
+                       break;
+
+               for (j = 128; j > 0; j >>= 1) {
+                       t->t[i]->t[j] = t->t[i - 1]->t[j];
+                       gf128mul_x8_lle(&t->t[i]->t[j]);
+               }
+       }
+
+out:
+       return t;
+}
+EXPORT_SYMBOL(gf128mul_init_64k_lle);
+
+struct gf128mul_64k *gf128mul_init_64k_bbe(const be128 *g)
+{
+       struct gf128mul_64k *t;
+       int i, j, k;
+
+       t = kzalloc(sizeof(*t), GFP_KERNEL);
+       if (!t)
+               goto out;
+
+       for (i = 0; i < 16; i++) {
+               t->t[i] = kzalloc(sizeof(*t->t[i]), GFP_KERNEL);
+               if (!t->t[i]) {
+                       gf128mul_free_64k(t);
+                       t = NULL;
+                       goto out;
+               }
+       }
+
+       t->t[0]->t[1] = *g;
+       for (j = 1; j <= 64; j <<= 1)
+               gf128mul_x_bbe(&t->t[0]->t[j + j], &t->t[0]->t[j]);
+
+       for (i = 0;;) {
+               for (j = 2; j < 256; j += j)
+                       for (k = 1; k < j; ++k)
+                               be128_xor(&t->t[i]->t[j + k],
+                                         &t->t[i]->t[j], &t->t[i]->t[k]);
+
+               if (++i >= 16)
+                       break;
+
+               for (j = 128; j > 0; j >>= 1) {
+                       t->t[i]->t[j] = t->t[i - 1]->t[j];
+                       gf128mul_x8_bbe(&t->t[i]->t[j]);
+               }
+       }
+
+out:
+       return t;
+}
+EXPORT_SYMBOL(gf128mul_init_64k_bbe);
+
+void gf128mul_free_64k(struct gf128mul_64k *t)
+{
+       int i;
+
+       for (i = 0; i < 16; i++)
+               kfree(t->t[i]);
+       kfree(t);
+}
+EXPORT_SYMBOL(gf128mul_free_64k);
+
+void gf128mul_64k_lle(be128 *a, struct gf128mul_64k *t)
+{
+       u8 *ap = (u8 *)a;
+       be128 r[1];
+       int i;
+
+       *r = t->t[0]->t[ap[0]];
+       for (i = 1; i < 16; ++i)
+               be128_xor(r, r, &t->t[i]->t[ap[i]]);
+       *a = *r;
+}
+EXPORT_SYMBOL(gf128mul_64k_lle);
+
+void gf128mul_64k_bbe(be128 *a, struct gf128mul_64k *t)
+{
+       u8 *ap = (u8 *)a;
+       be128 r[1];
+       int i;
+
+       *r = t->t[0]->t[ap[15]];
+       for (i = 1; i < 16; ++i)
+               be128_xor(r, r, &t->t[i]->t[ap[15 - i]]);
+       *a = *r;
+}
+EXPORT_SYMBOL(gf128mul_64k_bbe);
+
+/*      This version uses 4k bytes of table space.
+    A 16 byte buffer has to be multiplied by a 16 byte key
+    value in GF(128).  If we consider a GF(128) value in a
+    single byte, we can construct a table of the 256 16 byte
+    values that result from the 256 values of this byte.
+    This requires 4096 bytes. If we take the highest byte in
+    the buffer and use this table to get the result, we then
+    have to multiply by x^120 to get the final value. For the
+    next highest byte the result has to be multiplied by x^112
+    and so on. But we can do this by accumulating the result
+    in an accumulator starting with the result for the top
+    byte.  We repeatedly multiply the accumulator value by
+    x^8 and then add in (i.e. xor) the 16 bytes of the next
+    lower byte in the buffer, stopping when we reach the
+    lowest byte. This requires a 4096 byte table.
+*/
+struct gf128mul_4k *gf128mul_init_4k_lle(const be128 *g)
+{
+       struct gf128mul_4k *t;
+       int j, k;
+
+       t = kzalloc(sizeof(*t), GFP_KERNEL);
+       if (!t)
+               goto out;
+
+       t->t[128] = *g;
+       for (j = 64; j > 0; j >>= 1)
+               gf128mul_x_lle(&t->t[j], &t->t[j+j]);
+
+       for (j = 2; j < 256; j += j)
+               for (k = 1; k < j; ++k)
+                       be128_xor(&t->t[j + k], &t->t[j], &t->t[k]);
+
+out:
+       return t;
+}
+EXPORT_SYMBOL(gf128mul_init_4k_lle);
+
+struct gf128mul_4k *gf128mul_init_4k_bbe(const be128 *g)
+{
+       struct gf128mul_4k *t;
+       int j, k;
+
+       t = kzalloc(sizeof(*t), GFP_KERNEL);
+       if (!t)
+               goto out;
+
+       t->t[1] = *g;
+       for (j = 1; j <= 64; j <<= 1)
+               gf128mul_x_bbe(&t->t[j + j], &t->t[j]);
+
+       for (j = 2; j < 256; j += j)
+               for (k = 1; k < j; ++k)
+                       be128_xor(&t->t[j + k], &t->t[j], &t->t[k]);
+
+out:
+       return t;
+}
+EXPORT_SYMBOL(gf128mul_init_4k_bbe);
+
+void gf128mul_4k_lle(be128 *a, struct gf128mul_4k *t)
+{
+       u8 *ap = (u8 *)a;
+       be128 r[1];
+       int i = 15;
+
+       *r = t->t[ap[15]];
+       while (i--) {
+               gf128mul_x8_lle(r);
+               be128_xor(r, r, &t->t[ap[i]]);
+       }
+       *a = *r;
+}
+EXPORT_SYMBOL(gf128mul_4k_lle);
+
+void gf128mul_4k_bbe(be128 *a, struct gf128mul_4k *t)
+{
+       u8 *ap = (u8 *)a;
+       be128 r[1];
+       int i = 0;
+
+       *r = t->t[ap[0]];
+       while (++i < 16) {
+               gf128mul_x8_bbe(r);
+               be128_xor(r, r, &t->t[ap[i]]);
+       }
+       *a = *r;
+}
+EXPORT_SYMBOL(gf128mul_4k_bbe);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Functions for multiplying elements of GF(2^128)");
diff --git a/crypto/lrw.c b/crypto/lrw.c
new file mode 100644 (file)
index 0000000..5664258
--- /dev/null
@@ -0,0 +1,301 @@
+/* LRW: as defined by Cyril Guyot in
+ *     http://grouper.ieee.org/groups/1619/email/pdf00017.pdf
+ *
+ * Copyright (c) 2006 Rik Snel <rsnel@cube.dyndns.org>
+ *
+ * Based om ecb.c
+ * Copyright (c) 2006 Herbert Xu <herbert@gondor.apana.org.au>
+ *
+ * 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 implementation is checked against the test vectors in the above
+ * document and by a test vector provided by Ken Buchanan at
+ * http://www.mail-archive.com/stds-p1619@listserv.ieee.org/msg00173.html
+ *
+ * The test vectors are included in the testing module tcrypt.[ch] */
+#include <crypto/algapi.h>
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/scatterlist.h>
+#include <linux/slab.h>
+
+#include <crypto/b128ops.h>
+#include <crypto/gf128mul.h>
+
+struct priv {
+       struct crypto_cipher *child;
+       /* optimizes multiplying a random (non incrementing, as at the
+        * start of a new sector) value with key2, we could also have
+        * used 4k optimization tables or no optimization at all. In the
+        * latter case we would have to store key2 here */
+       struct gf128mul_64k *table;
+       /* stores:
+        *  key2*{ 0,0,...0,0,0,0,1 }, key2*{ 0,0,...0,0,0,1,1 },
+        *  key2*{ 0,0,...0,0,1,1,1 }, key2*{ 0,0,...0,1,1,1,1 }
+        *  key2*{ 0,0,...1,1,1,1,1 }, etc
+        * needed for optimized multiplication of incrementing values
+        * with key2 */
+       be128 mulinc[128];
+};
+
+static inline void setbit128_bbe(void *b, int bit)
+{
+       __set_bit(bit ^ 0x78, b);
+}
+
+static int setkey(struct crypto_tfm *parent, const u8 *key,
+                 unsigned int keylen)
+{
+       struct priv *ctx = crypto_tfm_ctx(parent);
+       struct crypto_cipher *child = ctx->child;
+       int err, i;
+       be128 tmp = { 0 };
+       int bsize = crypto_cipher_blocksize(child);
+
+       crypto_cipher_clear_flags(child, CRYPTO_TFM_REQ_MASK);
+       crypto_cipher_set_flags(child, crypto_tfm_get_flags(parent) &
+                                      CRYPTO_TFM_REQ_MASK);
+       if ((err = crypto_cipher_setkey(child, key, keylen - bsize)))
+               return err;
+       crypto_tfm_set_flags(parent, crypto_cipher_get_flags(child) &
+                                    CRYPTO_TFM_RES_MASK);
+
+       if (ctx->table)
+               gf128mul_free_64k(ctx->table);
+
+       /* initialize multiplication table for Key2 */
+       ctx->table = gf128mul_init_64k_bbe((be128 *)(key + keylen - bsize));
+       if (!ctx->table)
+               return -ENOMEM;
+
+       /* initialize optimization table */
+       for (i = 0; i < 128; i++) {
+               setbit128_bbe(&tmp, i);
+               ctx->mulinc[i] = tmp;
+               gf128mul_64k_bbe(&ctx->mulinc[i], ctx->table);
+       }
+
+       return 0;
+}
+
+struct sinfo {
+       be128 t;
+       struct crypto_tfm *tfm;
+       void (*fn)(struct crypto_tfm *, u8 *, const u8 *);
+};
+
+static inline void inc(be128 *iv)
+{
+       if (!(iv->b = cpu_to_be64(be64_to_cpu(iv->b) + 1)))
+               iv->a = cpu_to_be64(be64_to_cpu(iv->a) + 1);
+}
+
+static inline void lrw_round(struct sinfo *s, void *dst, const void *src)
+{
+       be128_xor(dst, &s->t, src);             /* PP <- T xor P */
+       s->fn(s->tfm, dst, dst);                /* CC <- E(Key2,PP) */
+       be128_xor(dst, dst, &s->t);             /* C <- T xor CC */
+}
+
+/* this returns the number of consequative 1 bits starting
+ * from the right, get_index128(00 00 00 00 00 00 ... 00 00 10 FB) = 2 */
+static inline int get_index128(be128 *block)
+{
+       int x;
+       __be32 *p = (__be32 *) block;
+
+       for (p += 3, x = 0; x < 128; p--, x += 32) {
+               u32 val = be32_to_cpup(p);
+
+               if (!~val)
+                       continue;
+
+               return x + ffz(val);
+       }
+
+       return x;
+}
+
+static int crypt(struct blkcipher_desc *d,
+                struct blkcipher_walk *w, struct priv *ctx,
+                void (*fn)(struct crypto_tfm *, u8 *, const u8 *))
+{
+       int err;
+       unsigned int avail;
+       const int bs = crypto_cipher_blocksize(ctx->child);
+       struct sinfo s = {
+               .tfm = crypto_cipher_tfm(ctx->child),
+               .fn = fn
+       };
+       be128 *iv;
+       u8 *wsrc;
+       u8 *wdst;
+
+       err = blkcipher_walk_virt(d, w);
+       if (!(avail = w->nbytes))
+               return err;
+
+       wsrc = w->src.virt.addr;
+       wdst = w->dst.virt.addr;
+
+       /* calculate first value of T */
+       iv = (be128 *)w->iv;
+       s.t = *iv;
+
+       /* T <- I*Key2 */
+       gf128mul_64k_bbe(&s.t, ctx->table);
+
+       goto first;
+
+       for (;;) {
+               do {
+                       /* T <- I*Key2, using the optimization
+                        * discussed in the specification */
+                       be128_xor(&s.t, &s.t, &ctx->mulinc[get_index128(iv)]);
+                       inc(iv);
+
+first:
+                       lrw_round(&s, wdst, wsrc);
+
+                       wsrc += bs;
+                       wdst += bs;
+               } while ((avail -= bs) >= bs);
+
+               err = blkcipher_walk_done(d, w, avail);
+               if (!(avail = w->nbytes))
+                       break;
+
+               wsrc = w->src.virt.addr;
+               wdst = w->dst.virt.addr;
+       }
+
+       return err;
+}
+
+static int encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
+                  struct scatterlist *src, unsigned int nbytes)
+{
+       struct priv *ctx = crypto_blkcipher_ctx(desc->tfm);
+       struct blkcipher_walk w;
+
+       blkcipher_walk_init(&w, dst, src, nbytes);
+       return crypt(desc, &w, ctx,
+                    crypto_cipher_alg(ctx->child)->cia_encrypt);
+}
+
+static int decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
+                  struct scatterlist *src, unsigned int nbytes)
+{
+       struct priv *ctx = crypto_blkcipher_ctx(desc->tfm);
+       struct blkcipher_walk w;
+
+       blkcipher_walk_init(&w, dst, src, nbytes);
+       return crypt(desc, &w, ctx,
+                    crypto_cipher_alg(ctx->child)->cia_decrypt);
+}
+
+static int init_tfm(struct crypto_tfm *tfm)
+{
+       struct crypto_instance *inst = (void *)tfm->__crt_alg;
+       struct crypto_spawn *spawn = crypto_instance_ctx(inst);
+       struct priv *ctx = crypto_tfm_ctx(tfm);
+       u32 *flags = &tfm->crt_flags;
+
+       tfm = crypto_spawn_tfm(spawn);
+       if (IS_ERR(tfm))
+               return PTR_ERR(tfm);
+
+       if (crypto_tfm_alg_blocksize(tfm) != 16) {
+               *flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN;
+               return -EINVAL;
+       }
+
+       ctx->child = crypto_cipher_cast(tfm);
+       return 0;
+}
+
+static void exit_tfm(struct crypto_tfm *tfm)
+{
+       struct priv *ctx = crypto_tfm_ctx(tfm);
+       if (ctx->table)
+               gf128mul_free_64k(ctx->table);
+       crypto_free_cipher(ctx->child);
+}
+
+static struct crypto_instance *alloc(void *param, unsigned int len)
+{
+       struct crypto_instance *inst;
+       struct crypto_alg *alg;
+
+       alg = crypto_get_attr_alg(param, len, CRYPTO_ALG_TYPE_CIPHER,
+                                 CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC);
+       if (IS_ERR(alg))
+               return ERR_PTR(PTR_ERR(alg));
+
+       inst = crypto_alloc_instance("lrw", alg);
+       if (IS_ERR(inst))
+               goto out_put_alg;
+
+       inst->alg.cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER;
+       inst->alg.cra_priority = alg->cra_priority;
+       inst->alg.cra_blocksize = alg->cra_blocksize;
+
+       if (alg->cra_alignmask < 7) inst->alg.cra_alignmask = 7;
+       else inst->alg.cra_alignmask = alg->cra_alignmask;
+       inst->alg.cra_type = &crypto_blkcipher_type;
+
+       if (!(alg->cra_blocksize % 4))
+               inst->alg.cra_alignmask |= 3;
+       inst->alg.cra_blkcipher.ivsize = alg->cra_blocksize;
+       inst->alg.cra_blkcipher.min_keysize =
+               alg->cra_cipher.cia_min_keysize + alg->cra_blocksize;
+       inst->alg.cra_blkcipher.max_keysize =
+               alg->cra_cipher.cia_max_keysize + alg->cra_blocksize;
+
+       inst->alg.cra_ctxsize = sizeof(struct priv);
+
+       inst->alg.cra_init = init_tfm;
+       inst->alg.cra_exit = exit_tfm;
+
+       inst->alg.cra_blkcipher.setkey = setkey;
+       inst->alg.cra_blkcipher.encrypt = encrypt;
+       inst->alg.cra_blkcipher.decrypt = decrypt;
+
+out_put_alg:
+       crypto_mod_put(alg);
+       return inst;
+}
+
+static void free(struct crypto_instance *inst)
+{
+       crypto_drop_spawn(crypto_instance_ctx(inst));
+       kfree(inst);
+}
+
+static struct crypto_template crypto_tmpl = {
+       .name = "lrw",
+       .alloc = alloc,
+       .free = free,
+       .module = THIS_MODULE,
+};
+
+static int __init crypto_module_init(void)
+{
+       return crypto_register_template(&crypto_tmpl);
+}
+
+static void __exit crypto_module_exit(void)
+{
+       crypto_unregister_template(&crypto_tmpl);
+}
+
+module_init(crypto_module_init);
+module_exit(crypto_module_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("LRW block cipher mode");
index 83307420d31c873398006cbd85286ebcf50e2965..d671e8942b1f7d2c774a46a56aada52bf76dca39 100644 (file)
@@ -906,6 +906,10 @@ static void do_test(void)
                            AES_CBC_ENC_TEST_VECTORS);
                test_cipher("cbc(aes)", DECRYPT, aes_cbc_dec_tv_template,
                            AES_CBC_DEC_TEST_VECTORS);
+               test_cipher("lrw(aes)", ENCRYPT, aes_lrw_enc_tv_template,
+                           AES_LRW_ENC_TEST_VECTORS);
+               test_cipher("lrw(aes)", DECRYPT, aes_lrw_dec_tv_template,
+                           AES_LRW_DEC_TEST_VECTORS);
 
                //CAST5
                test_cipher("ecb(cast5)", ENCRYPT, cast5_enc_tv_template,
@@ -977,6 +981,9 @@ static void do_test(void)
                test_hash("hmac(sha256)", hmac_sha256_tv_template,
                          HMAC_SHA256_TEST_VECTORS);
 
+               test_hash("xcbc(aes)", aes_xcbc128_tv_template,
+                         XCBC_AES_TEST_VECTORS);
+
                test_hash("michael_mic", michael_mic_tv_template, MICHAEL_MIC_TEST_VECTORS);
                break;
 
@@ -1052,6 +1059,10 @@ static void do_test(void)
                            AES_CBC_ENC_TEST_VECTORS);
                test_cipher("cbc(aes)", DECRYPT, aes_cbc_dec_tv_template,
                            AES_CBC_DEC_TEST_VECTORS);
+               test_cipher("lrw(aes)", ENCRYPT, aes_lrw_enc_tv_template,
+                           AES_LRW_ENC_TEST_VECTORS);
+               test_cipher("lrw(aes)", DECRYPT, aes_lrw_dec_tv_template,
+                           AES_LRW_DEC_TEST_VECTORS);
                break;
 
        case 11:
@@ -1191,6 +1202,10 @@ static void do_test(void)
                                  aes_speed_template);
                test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
                                  aes_speed_template);
+               test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
+                                 aes_lrw_speed_template);
+               test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
+                                 aes_lrw_speed_template);
                break;
 
        case 201:
index a40c4411729ee2ea9bc8cb192ca99105ee2d978e..48a81362cb851b7e0c9163191d2a61e14ca6d2ab 100644 (file)
@@ -39,15 +39,15 @@ struct hash_testvec {
 struct cipher_testvec {
        char key[MAX_KEYLEN] __attribute__ ((__aligned__(4)));
        char iv[MAX_IVLEN];
-       char input[48];
-       char result[48];
+       char input[512];
+       char result[512];
        unsigned char tap[MAX_TAP];
        int np;
        unsigned char fail;
        unsigned char wk; /* weak key flag */
        unsigned char klen;
-       unsigned char ilen;
-       unsigned char rlen;
+       unsigned short ilen;
+       unsigned short rlen;
 };
 
 struct cipher_speed {
@@ -933,6 +933,74 @@ static struct hash_testvec hmac_sha256_tv_template[] = {
        },
 };
 
+#define XCBC_AES_TEST_VECTORS 6
+
+static struct hash_testvec aes_xcbc128_tv_template[] = {
+       {
+               .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                           0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+               .plaintext = { [0 ... 15] = 0 },
+               .digest = { 0x75, 0xf0, 0x25, 0x1d, 0x52, 0x8a, 0xc0, 0x1c,
+                           0x45, 0x73, 0xdf, 0xd5, 0x84, 0xd7, 0x9f, 0x29 },
+               .psize  = 0,
+               .ksize  = 16,
+       }, {
+               .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                           0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+               .plaintext = { 0x00, 0x01, 0x02 },
+               .digest = { 0x5b, 0x37, 0x65, 0x80, 0xae, 0x2f, 0x19, 0xaf,
+                           0xe7, 0x21, 0x9c, 0xee, 0xf1, 0x72, 0x75, 0x6f },
+               .psize  = 3,
+               .ksize  = 16,
+       } , {
+               .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                           0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+               .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                              0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+               .digest = { 0xd2, 0xa2, 0x46, 0xfa, 0x34, 0x9b, 0x68, 0xa7,
+                           0x99, 0x98, 0xa4, 0x39, 0x4f, 0xf7, 0xa2, 0x63 },
+               .psize  = 16,
+               .ksize  = 16,
+       }, {
+               .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                           0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+               .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                              0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+                              0x10, 0x11, 0x12, 0x13 },
+               .digest = { 0x47, 0xf5, 0x1b, 0x45, 0x64, 0x96, 0x62, 0x15,
+                           0xb8, 0x98, 0x5c, 0x63, 0x05, 0x5e, 0xd3, 0x08 },
+               .tap    = { 10, 10 },
+               .psize  = 20,
+               .np     = 2,
+               .ksize  = 16,
+       }, {
+               .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                           0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+               .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                              0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+                              0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                              0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
+               .digest = { 0xf5, 0x4f, 0x0e, 0xc8, 0xd2, 0xb9, 0xf3, 0xd3,
+                           0x68, 0x07, 0x73, 0x4b, 0xd5, 0x28, 0x3f, 0xd4 },
+               .psize  = 32,
+               .ksize  = 16,
+       }, {
+               .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                           0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+               .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                              0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+                              0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                              0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+                              0x20, 0x21 },
+               .digest = { 0xbe, 0xcb, 0xb3, 0xbc, 0xcd, 0xb5, 0x18, 0xa3,
+                           0x06, 0x77, 0xd5, 0x48, 0x1f, 0xb6, 0xb4, 0xd8 },
+               .tap    = { 17, 17 },
+               .psize  = 34,
+               .np     = 2,
+               .ksize  = 16,
+       }
+};
+
 /*
  * DES test vectors.
  */
@@ -1831,6 +1899,8 @@ static struct cipher_testvec cast6_dec_tv_template[] = {
 #define AES_DEC_TEST_VECTORS 3
 #define AES_CBC_ENC_TEST_VECTORS 2
 #define AES_CBC_DEC_TEST_VECTORS 2
+#define AES_LRW_ENC_TEST_VECTORS 8
+#define AES_LRW_DEC_TEST_VECTORS 8
 
 static struct cipher_testvec aes_enc_tv_template[] = {
        { /* From FIPS-197 */
@@ -1968,6 +2038,509 @@ static struct cipher_testvec aes_cbc_dec_tv_template[] = {
        },
 };
 
+static struct cipher_testvec aes_lrw_enc_tv_template[] = {
+       /* from http://grouper.ieee.org/groups/1619/email/pdf00017.pdf */
+       { /* LRW-32-AES 1 */
+               .key    = { 0x45, 0x62, 0xac, 0x25, 0xf8, 0x28, 0x17, 0x6d,
+                           0x4c, 0x26, 0x84, 0x14, 0xb5, 0x68, 0x01, 0x85,
+                           0x25, 0x8e, 0x2a, 0x05, 0xe7, 0x3e, 0x9d, 0x03,
+                           0xee, 0x5a, 0x83, 0x0c, 0xcc, 0x09, 0x4c, 0x87 },
+               .klen   = 32,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
+               .input  = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+                           0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
+               .ilen   = 16,
+               .result = { 0xf1, 0xb2, 0x73, 0xcd, 0x65, 0xa3, 0xdf, 0x5f,
+                           0xe9, 0x5d, 0x48, 0x92, 0x54, 0x63, 0x4e, 0xb8 },
+               .rlen   = 16,
+       }, { /* LRW-32-AES 2 */
+               .key    = { 0x59, 0x70, 0x47, 0x14, 0xf5, 0x57, 0x47, 0x8c,
+                           0xd7, 0x79, 0xe8, 0x0f, 0x54, 0x88, 0x79, 0x44,
+                           0x0d, 0x48, 0xf0, 0xb7, 0xb1, 0x5a, 0x53, 0xea,
+                           0x1c, 0xaa, 0x6b, 0x29, 0xc2, 0xca, 0xfb, 0xaf
+               },
+               .klen   = 32,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 },
+               .input  = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+                           0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
+               .ilen   = 16,
+               .result = { 0x00, 0xc8, 0x2b, 0xae, 0x95, 0xbb, 0xcd, 0xe5,
+                           0x27, 0x4f, 0x07, 0x69, 0xb2, 0x60, 0xe1, 0x36 },
+               .rlen   = 16,
+       }, { /* LRW-32-AES 3 */
+               .key    = { 0xd8, 0x2a, 0x91, 0x34, 0xb2, 0x6a, 0x56, 0x50,
+                           0x30, 0xfe, 0x69, 0xe2, 0x37, 0x7f, 0x98, 0x47,
+                           0xcd, 0xf9, 0x0b, 0x16, 0x0c, 0x64, 0x8f, 0xb6,
+                           0xb0, 0x0d, 0x0d, 0x1b, 0xae, 0x85, 0x87, 0x1f },
+               .klen   = 32,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                           0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 },
+               .input  = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+                           0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
+               .ilen   = 16,
+               .result = { 0x76, 0x32, 0x21, 0x83, 0xed, 0x8f, 0xf1, 0x82,
+                           0xf9, 0x59, 0x62, 0x03, 0x69, 0x0e, 0x5e, 0x01 },
+               .rlen   = 16,
+       }, { /* LRW-32-AES 4 */
+               .key    = { 0x0f, 0x6a, 0xef, 0xf8, 0xd3, 0xd2, 0xbb, 0x15,
+                           0x25, 0x83, 0xf7, 0x3c, 0x1f, 0x01, 0x28, 0x74,
+                           0xca, 0xc6, 0xbc, 0x35, 0x4d, 0x4a, 0x65, 0x54,
+                           0x90, 0xae, 0x61, 0xcf, 0x7b, 0xae, 0xbd, 0xcc,
+                           0xad, 0xe4, 0x94, 0xc5, 0x4a, 0x29, 0xae, 0x70 },
+               .klen   = 40,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
+               .input  = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+                           0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
+               .ilen   = 16,
+               .result = { 0x9c, 0x0f, 0x15, 0x2f, 0x55, 0xa2, 0xd8, 0xf0,
+                           0xd6, 0x7b, 0x8f, 0x9e, 0x28, 0x22, 0xbc, 0x41 },
+               .rlen   = 16,
+       }, { /* LRW-32-AES 5 */
+               .key    = { 0x8a, 0xd4, 0xee, 0x10, 0x2f, 0xbd, 0x81, 0xff,
+                           0xf8, 0x86, 0xce, 0xac, 0x93, 0xc5, 0xad, 0xc6,
+                           0xa0, 0x19, 0x07, 0xc0, 0x9d, 0xf7, 0xbb, 0xdd,
+                           0x52, 0x13, 0xb2, 0xb7, 0xf0, 0xff, 0x11, 0xd8,
+                           0xd6, 0x08, 0xd0, 0xcd, 0x2e, 0xb1, 0x17, 0x6f },
+               .klen   = 40,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                           0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 },
+               .input  = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+                           0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
+               .ilen   = 16,
+               .result = { 0xd4, 0x27, 0x6a, 0x7f, 0x14, 0x91, 0x3d, 0x65,
+                           0xc8, 0x60, 0x48, 0x02, 0x87, 0xe3, 0x34, 0x06 },
+               .rlen   = 16,
+       }, { /* LRW-32-AES 6 */
+               .key    = { 0xf8, 0xd4, 0x76, 0xff, 0xd6, 0x46, 0xee, 0x6c,
+                           0x23, 0x84, 0xcb, 0x1c, 0x77, 0xd6, 0x19, 0x5d,
+                           0xfe, 0xf1, 0xa9, 0xf3, 0x7b, 0xbc, 0x8d, 0x21,
+                           0xa7, 0x9c, 0x21, 0xf8, 0xcb, 0x90, 0x02, 0x89,
+                           0xa8, 0x45, 0x34, 0x8e, 0xc8, 0xc5, 0xb5, 0xf1,
+                           0x26, 0xf5, 0x0e, 0x76, 0xfe, 0xfd, 0x1b, 0x1e },
+               .klen   = 48,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
+               .input  = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+                           0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
+               .ilen   = 16,
+               .result = { 0xbd, 0x06, 0xb8, 0xe1, 0xdb, 0x98, 0x89, 0x9e,
+                           0xc4, 0x98, 0xe4, 0x91, 0xcf, 0x1c, 0x70, 0x2b },
+               .rlen   = 16,
+       }, { /* LRW-32-AES 7 */
+               .key    = { 0xfb, 0x76, 0x15, 0xb2, 0x3d, 0x80, 0x89, 0x1d,
+                           0xd4, 0x70, 0x98, 0x0b, 0xc7, 0x95, 0x84, 0xc8,
+                           0xb2, 0xfb, 0x64, 0xce, 0x60, 0x97, 0x87, 0x8d,
+                           0x17, 0xfc, 0xe4, 0x5a, 0x49, 0xe8, 0x30, 0xb7,
+                           0x6e, 0x78, 0x17, 0xe7, 0x2d, 0x5e, 0x12, 0xd4,
+                           0x60, 0x64, 0x04, 0x7a, 0xf1, 0x2f, 0x9e, 0x0c },
+               .klen   = 48,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                           0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 },
+               .input  = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+                           0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
+               .ilen   = 16,
+               .result = { 0x5b, 0x90, 0x8e, 0xc1, 0xab, 0xdd, 0x67, 0x5f,
+                           0x3d, 0x69, 0x8a, 0x95, 0x53, 0xc8, 0x9c, 0xe5 },
+               .rlen   = 16,
+       }, {
+/* http://www.mail-archive.com/stds-p1619@listserv.ieee.org/msg00173.html */
+               .key    = { 0xf8, 0xd4, 0x76, 0xff, 0xd6, 0x46, 0xee, 0x6c,
+                           0x23, 0x84, 0xcb, 0x1c, 0x77, 0xd6, 0x19, 0x5d,
+                           0xfe, 0xf1, 0xa9, 0xf3, 0x7b, 0xbc, 0x8d, 0x21,
+                           0xa7, 0x9c, 0x21, 0xf8, 0xcb, 0x90, 0x02, 0x89,
+                           0xa8, 0x45, 0x34, 0x8e, 0xc8, 0xc5, 0xb5, 0xf1,
+                           0x26, 0xf5, 0x0e, 0x76, 0xfe, 0xfd, 0x1b, 0x1e },
+               .klen   = 48,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
+               .input  = { 0x05, 0x11, 0xb7, 0x18, 0xab, 0xc6, 0x2d, 0xac,
+                           0x70, 0x5d, 0xf6, 0x22, 0x94, 0xcd, 0xe5, 0x6c,
+                           0x17, 0x6b, 0xf6, 0x1c, 0xf0, 0xf3, 0x6e, 0xf8,
+                           0x50, 0x38, 0x1f, 0x71, 0x49, 0xb6, 0x57, 0xd6,
+                           0x8f, 0xcb, 0x8d, 0x6b, 0xe3, 0xa6, 0x29, 0x90,
+                           0xfe, 0x2a, 0x62, 0x82, 0xae, 0x6d, 0x8b, 0xf6,
+                           0xad, 0x1e, 0x9e, 0x20, 0x5f, 0x38, 0xbe, 0x04,
+                           0xda, 0x10, 0x8e, 0xed, 0xa2, 0xa4, 0x87, 0xab,
+                           0xda, 0x6b, 0xb4, 0x0c, 0x75, 0xba, 0xd3, 0x7c,
+                           0xc9, 0xac, 0x42, 0x31, 0x95, 0x7c, 0xc9, 0x04,
+                           0xeb, 0xd5, 0x6e, 0x32, 0x69, 0x8a, 0xdb, 0xa6,
+                           0x15, 0xd7, 0x3f, 0x4f, 0x2f, 0x66, 0x69, 0x03,
+                           0x9c, 0x1f, 0x54, 0x0f, 0xde, 0x1f, 0xf3, 0x65,
+                           0x4c, 0x96, 0x12, 0xed, 0x7c, 0x92, 0x03, 0x01,
+                           0x6f, 0xbc, 0x35, 0x93, 0xac, 0xf1, 0x27, 0xf1,
+                           0xb4, 0x96, 0x82, 0x5a, 0x5f, 0xb0, 0xa0, 0x50,
+                           0x89, 0xa4, 0x8e, 0x66, 0x44, 0x85, 0xcc, 0xfd,
+                           0x33, 0x14, 0x70, 0xe3, 0x96, 0xb2, 0xc3, 0xd3,
+                           0xbb, 0x54, 0x5a, 0x1a, 0xf9, 0x74, 0xa2, 0xc5,
+                           0x2d, 0x64, 0x75, 0xdd, 0xb4, 0x54, 0xe6, 0x74,
+                           0x8c, 0xd3, 0x9d, 0x9e, 0x86, 0xab, 0x51, 0x53,
+                           0xb7, 0x93, 0x3e, 0x6f, 0xd0, 0x4e, 0x2c, 0x40,
+                           0xf6, 0xa8, 0x2e, 0x3e, 0x9d, 0xf4, 0x66, 0xa5,
+                           0x76, 0x12, 0x73, 0x44, 0x1a, 0x56, 0xd7, 0x72,
+                           0x88, 0xcd, 0x21, 0x8c, 0x4c, 0x0f, 0xfe, 0xda,
+                           0x95, 0xe0, 0x3a, 0xa6, 0xa5, 0x84, 0x46, 0xcd,
+                           0xd5, 0x3e, 0x9d, 0x3a, 0xe2, 0x67, 0xe6, 0x60,
+                           0x1a, 0xe2, 0x70, 0x85, 0x58, 0xc2, 0x1b, 0x09,
+                           0xe1, 0xd7, 0x2c, 0xca, 0xad, 0xa8, 0x8f, 0xf9,
+                           0xac, 0xb3, 0x0e, 0xdb, 0xca, 0x2e, 0xe2, 0xb8,
+                           0x51, 0x71, 0xd9, 0x3c, 0x6c, 0xf1, 0x56, 0xf8,
+                           0xea, 0x9c, 0xf1, 0xfb, 0x0c, 0xe6, 0xb7, 0x10,
+                           0x1c, 0xf8, 0xa9, 0x7c, 0xe8, 0x53, 0x35, 0xc1,
+                           0x90, 0x3e, 0x76, 0x4a, 0x74, 0xa4, 0x21, 0x2c,
+                           0xf6, 0x2c, 0x4e, 0x0f, 0x94, 0x3a, 0x88, 0x2e,
+                           0x41, 0x09, 0x6a, 0x33, 0x7d, 0xf6, 0xdd, 0x3f,
+                           0x8d, 0x23, 0x31, 0x74, 0x84, 0xeb, 0x88, 0x6e,
+                           0xcc, 0xb9, 0xbc, 0x22, 0x83, 0x19, 0x07, 0x22,
+                           0xa5, 0x2d, 0xdf, 0xa5, 0xf3, 0x80, 0x85, 0x78,
+                           0x84, 0x39, 0x6a, 0x6d, 0x6a, 0x99, 0x4f, 0xa5,
+                           0x15, 0xfe, 0x46, 0xb0, 0xe4, 0x6c, 0xa5, 0x41,
+                           0x3c, 0xce, 0x8f, 0x42, 0x60, 0x71, 0xa7, 0x75,
+                           0x08, 0x40, 0x65, 0x8a, 0x82, 0xbf, 0xf5, 0x43,
+                           0x71, 0x96, 0xa9, 0x4d, 0x44, 0x8a, 0x20, 0xbe,
+                           0xfa, 0x4d, 0xbb, 0xc0, 0x7d, 0x31, 0x96, 0x65,
+                           0xe7, 0x75, 0xe5, 0x3e, 0xfd, 0x92, 0x3b, 0xc9,
+                           0x55, 0xbb, 0x16, 0x7e, 0xf7, 0xc2, 0x8c, 0xa4,
+                           0x40, 0x1d, 0xe5, 0xef, 0x0e, 0xdf, 0xe4, 0x9a,
+                           0x62, 0x73, 0x65, 0xfd, 0x46, 0x63, 0x25, 0x3d,
+                           0x2b, 0xaf, 0xe5, 0x64, 0xfe, 0xa5, 0x5c, 0xcf,
+                           0x24, 0xf3, 0xb4, 0xac, 0x64, 0xba, 0xdf, 0x4b,
+                           0xc6, 0x96, 0x7d, 0x81, 0x2d, 0x8d, 0x97, 0xf7,
+                           0xc5, 0x68, 0x77, 0x84, 0x32, 0x2b, 0xcc, 0x85,
+                           0x74, 0x96, 0xf0, 0x12, 0x77, 0x61, 0xb9, 0xeb,
+                           0x71, 0xaa, 0x82, 0xcb, 0x1c, 0xdb, 0x89, 0xc8,
+                           0xc6, 0xb5, 0xe3, 0x5c, 0x7d, 0x39, 0x07, 0x24,
+                           0xda, 0x39, 0x87, 0x45, 0xc0, 0x2b, 0xbb, 0x01,
+                           0xac, 0xbc, 0x2a, 0x5c, 0x7f, 0xfc, 0xe8, 0xce,
+                           0x6d, 0x9c, 0x6f, 0xed, 0xd3, 0xc1, 0xa1, 0xd6,
+                           0xc5, 0x55, 0xa9, 0x66, 0x2f, 0xe1, 0xc8, 0x32,
+                           0xa6, 0x5d, 0xa4, 0x3a, 0x98, 0x73, 0xe8, 0x45,
+                           0xa4, 0xc7, 0xa8, 0xb4, 0xf6, 0x13, 0x03, 0xf6,
+                           0xe9, 0x2e, 0xc4, 0x29, 0x0f, 0x84, 0xdb, 0xc4,
+                           0x21, 0xc4, 0xc2, 0x75, 0x67, 0x89, 0x37, 0x0a },
+               .ilen   = 512,
+               .result = { 0x1a, 0x1d, 0xa9, 0x30, 0xad, 0xf9, 0x2f, 0x9b,
+                           0xb6, 0x1d, 0xae, 0xef, 0xf0, 0x2f, 0xf8, 0x5a,
+                           0x39, 0x3c, 0xbf, 0x2a, 0xb2, 0x45, 0xb2, 0x23,
+                           0x1b, 0x63, 0x3c, 0xcf, 0xaa, 0xbe, 0xcf, 0x4e,
+                           0xfa, 0xe8, 0x29, 0xc2, 0x20, 0x68, 0x2b, 0x3c,
+                           0x2e, 0x8b, 0xf7, 0x6e, 0x25, 0xbd, 0xe3, 0x3d,
+                           0x66, 0x27, 0xd6, 0xaf, 0xd6, 0x64, 0x3e, 0xe3,
+                           0xe8, 0x58, 0x46, 0x97, 0x39, 0x51, 0x07, 0xde,
+                           0xcb, 0x37, 0xbc, 0xa9, 0xc0, 0x5f, 0x75, 0xc3,
+                           0x0e, 0x84, 0x23, 0x1d, 0x16, 0xd4, 0x1c, 0x59,
+                           0x9c, 0x1a, 0x02, 0x55, 0xab, 0x3a, 0x97, 0x1d,
+                           0xdf, 0xdd, 0xc7, 0x06, 0x51, 0xd7, 0x70, 0xae,
+                           0x23, 0xc6, 0x8c, 0xf5, 0x1e, 0xa0, 0xe5, 0x82,
+                           0xb8, 0xb2, 0xbf, 0x04, 0xa0, 0x32, 0x8e, 0x68,
+                           0xeb, 0xaf, 0x6e, 0x2d, 0x94, 0x22, 0x2f, 0xce,
+                           0x4c, 0xb5, 0x59, 0xe2, 0xa2, 0x2f, 0xa0, 0x98,
+                           0x1a, 0x97, 0xc6, 0xd4, 0xb5, 0x00, 0x59, 0xf2,
+                           0x84, 0x14, 0x72, 0xb1, 0x9a, 0x6e, 0xa3, 0x7f,
+                           0xea, 0x20, 0xe7, 0xcb, 0x65, 0x77, 0x3a, 0xdf,
+                           0xc8, 0x97, 0x67, 0x15, 0xc2, 0x2a, 0x27, 0xcc,
+                           0x18, 0x55, 0xa1, 0x24, 0x0b, 0x24, 0x24, 0xaf,
+                           0x5b, 0xec, 0x68, 0xb8, 0xc8, 0xf5, 0xba, 0x63,
+                           0xff, 0xed, 0x89, 0xce, 0xd5, 0x3d, 0x88, 0xf3,
+                           0x25, 0xef, 0x05, 0x7c, 0x3a, 0xef, 0xeb, 0xd8,
+                           0x7a, 0x32, 0x0d, 0xd1, 0x1e, 0x58, 0x59, 0x99,
+                           0x90, 0x25, 0xb5, 0x26, 0xb0, 0xe3, 0x2b, 0x6c,
+                           0x4c, 0xa9, 0x8b, 0x84, 0x4f, 0x5e, 0x01, 0x50,
+                           0x41, 0x30, 0x58, 0xc5, 0x62, 0x74, 0x52, 0x1d,
+                           0x45, 0x24, 0x6a, 0x42, 0x64, 0x4f, 0x97, 0x1c,
+                           0xa8, 0x66, 0xb5, 0x6d, 0x79, 0xd4, 0x0d, 0x48,
+                           0xc5, 0x5f, 0xf3, 0x90, 0x32, 0xdd, 0xdd, 0xe1,
+                           0xe4, 0xa9, 0x9f, 0xfc, 0xc3, 0x52, 0x5a, 0x46,
+                           0xe4, 0x81, 0x84, 0x95, 0x36, 0x59, 0x7a, 0x6b,
+                           0xaa, 0xb3, 0x60, 0xad, 0xce, 0x9f, 0x9f, 0x28,
+                           0xe0, 0x01, 0x75, 0x22, 0xc4, 0x4e, 0xa9, 0x62,
+                           0x5c, 0x62, 0x0d, 0x00, 0xcb, 0x13, 0xe8, 0x43,
+                           0x72, 0xd4, 0x2d, 0x53, 0x46, 0xb5, 0xd1, 0x16,
+                           0x22, 0x18, 0xdf, 0x34, 0x33, 0xf5, 0xd6, 0x1c,
+                           0xb8, 0x79, 0x78, 0x97, 0x94, 0xff, 0x72, 0x13,
+                           0x4c, 0x27, 0xfc, 0xcb, 0xbf, 0x01, 0x53, 0xa6,
+                           0xb4, 0x50, 0x6e, 0xde, 0xdf, 0xb5, 0x43, 0xa4,
+                           0x59, 0xdf, 0x52, 0xf9, 0x7c, 0xe0, 0x11, 0x6f,
+                           0x2d, 0x14, 0x8e, 0x24, 0x61, 0x2c, 0xe1, 0x17,
+                           0xcc, 0xce, 0x51, 0x0c, 0x19, 0x8a, 0x82, 0x30,
+                           0x94, 0xd5, 0x3d, 0x6a, 0x53, 0x06, 0x5e, 0xbd,
+                           0xb7, 0xeb, 0xfa, 0xfd, 0x27, 0x51, 0xde, 0x85,
+                           0x1e, 0x86, 0x53, 0x11, 0x53, 0x94, 0x00, 0xee,
+                           0x2b, 0x8c, 0x08, 0x2a, 0xbf, 0xdd, 0xae, 0x11,
+                           0xcb, 0x1e, 0xa2, 0x07, 0x9a, 0x80, 0xcf, 0x62,
+                           0x9b, 0x09, 0xdc, 0x95, 0x3c, 0x96, 0x8e, 0xb1,
+                           0x09, 0xbd, 0xe4, 0xeb, 0xdb, 0xca, 0x70, 0x7a,
+                           0x9e, 0xfa, 0x31, 0x18, 0x45, 0x3c, 0x21, 0x33,
+                           0xb0, 0xb3, 0x2b, 0xea, 0xf3, 0x71, 0x2d, 0xe1,
+                           0x03, 0xad, 0x1b, 0x48, 0xd4, 0x67, 0x27, 0xf0,
+                           0x62, 0xe4, 0x3d, 0xfb, 0x9b, 0x08, 0x76, 0xe7,
+                           0xdd, 0x2b, 0x01, 0x39, 0x04, 0x5a, 0x58, 0x7a,
+                           0xf7, 0x11, 0x90, 0xec, 0xbd, 0x51, 0x5c, 0x32,
+                           0x6b, 0xd7, 0x35, 0x39, 0x02, 0x6b, 0xf2, 0xa6,
+                           0xd0, 0x0d, 0x07, 0xe1, 0x06, 0xc4, 0x5b, 0x7d,
+                           0xe4, 0x6a, 0xd7, 0xee, 0x15, 0x1f, 0x83, 0xb4,
+                           0xa3, 0xa7, 0x5e, 0xc3, 0x90, 0xb7, 0xef, 0xd3,
+                           0xb7, 0x4f, 0xf8, 0x92, 0x4c, 0xb7, 0x3c, 0x29,
+                           0xcd, 0x7e, 0x2b, 0x5d, 0x43, 0xea, 0x42, 0xe7,
+                           0x74, 0x3f, 0x7d, 0x58, 0x88, 0x75, 0xde, 0x3e },
+               .rlen   = 512,
+       }
+};
+
+static struct cipher_testvec aes_lrw_dec_tv_template[] = {
+       /* from http://grouper.ieee.org/groups/1619/email/pdf00017.pdf */
+       /* same as enc vectors with input and result reversed */
+       { /* LRW-32-AES 1 */
+               .key    = { 0x45, 0x62, 0xac, 0x25, 0xf8, 0x28, 0x17, 0x6d,
+                           0x4c, 0x26, 0x84, 0x14, 0xb5, 0x68, 0x01, 0x85,
+                           0x25, 0x8e, 0x2a, 0x05, 0xe7, 0x3e, 0x9d, 0x03,
+                           0xee, 0x5a, 0x83, 0x0c, 0xcc, 0x09, 0x4c, 0x87 },
+               .klen   = 32,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
+               .input  = { 0xf1, 0xb2, 0x73, 0xcd, 0x65, 0xa3, 0xdf, 0x5f,
+                           0xe9, 0x5d, 0x48, 0x92, 0x54, 0x63, 0x4e, 0xb8 },
+               .ilen   = 16,
+               .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+                           0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
+               .rlen   = 16,
+       }, { /* LRW-32-AES 2 */
+               .key    = { 0x59, 0x70, 0x47, 0x14, 0xf5, 0x57, 0x47, 0x8c,
+                           0xd7, 0x79, 0xe8, 0x0f, 0x54, 0x88, 0x79, 0x44,
+                           0x0d, 0x48, 0xf0, 0xb7, 0xb1, 0x5a, 0x53, 0xea,
+                           0x1c, 0xaa, 0x6b, 0x29, 0xc2, 0xca, 0xfb, 0xaf
+               },
+               .klen   = 32,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 },
+               .input  = { 0x00, 0xc8, 0x2b, 0xae, 0x95, 0xbb, 0xcd, 0xe5,
+                           0x27, 0x4f, 0x07, 0x69, 0xb2, 0x60, 0xe1, 0x36 },
+               .ilen   = 16,
+               .result  = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+                            0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
+               .rlen   = 16,
+       }, { /* LRW-32-AES 3 */
+               .key    = { 0xd8, 0x2a, 0x91, 0x34, 0xb2, 0x6a, 0x56, 0x50,
+                           0x30, 0xfe, 0x69, 0xe2, 0x37, 0x7f, 0x98, 0x47,
+                           0xcd, 0xf9, 0x0b, 0x16, 0x0c, 0x64, 0x8f, 0xb6,
+                           0xb0, 0x0d, 0x0d, 0x1b, 0xae, 0x85, 0x87, 0x1f },
+               .klen   = 32,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                           0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 },
+               .input  = { 0x76, 0x32, 0x21, 0x83, 0xed, 0x8f, 0xf1, 0x82,
+                           0xf9, 0x59, 0x62, 0x03, 0x69, 0x0e, 0x5e, 0x01 },
+               .ilen   = 16,
+               .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+                           0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
+               .rlen   = 16,
+       }, { /* LRW-32-AES 4 */
+               .key    = { 0x0f, 0x6a, 0xef, 0xf8, 0xd3, 0xd2, 0xbb, 0x15,
+                           0x25, 0x83, 0xf7, 0x3c, 0x1f, 0x01, 0x28, 0x74,
+                           0xca, 0xc6, 0xbc, 0x35, 0x4d, 0x4a, 0x65, 0x54,
+                           0x90, 0xae, 0x61, 0xcf, 0x7b, 0xae, 0xbd, 0xcc,
+                           0xad, 0xe4, 0x94, 0xc5, 0x4a, 0x29, 0xae, 0x70 },
+               .klen   = 40,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
+               .input  = { 0x9c, 0x0f, 0x15, 0x2f, 0x55, 0xa2, 0xd8, 0xf0,
+                           0xd6, 0x7b, 0x8f, 0x9e, 0x28, 0x22, 0xbc, 0x41 },
+               .ilen   = 16,
+               .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+                           0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
+               .rlen   = 16,
+       }, { /* LRW-32-AES 5 */
+               .key    = { 0x8a, 0xd4, 0xee, 0x10, 0x2f, 0xbd, 0x81, 0xff,
+                           0xf8, 0x86, 0xce, 0xac, 0x93, 0xc5, 0xad, 0xc6,
+                           0xa0, 0x19, 0x07, 0xc0, 0x9d, 0xf7, 0xbb, 0xdd,
+                           0x52, 0x13, 0xb2, 0xb7, 0xf0, 0xff, 0x11, 0xd8,
+                           0xd6, 0x08, 0xd0, 0xcd, 0x2e, 0xb1, 0x17, 0x6f },
+               .klen   = 40,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                           0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 },
+               .input  = { 0xd4, 0x27, 0x6a, 0x7f, 0x14, 0x91, 0x3d, 0x65,
+                           0xc8, 0x60, 0x48, 0x02, 0x87, 0xe3, 0x34, 0x06 },
+               .ilen   = 16,
+               .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+                           0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
+               .rlen   = 16,
+       }, { /* LRW-32-AES 6 */
+               .key    = { 0xf8, 0xd4, 0x76, 0xff, 0xd6, 0x46, 0xee, 0x6c,
+                           0x23, 0x84, 0xcb, 0x1c, 0x77, 0xd6, 0x19, 0x5d,
+                           0xfe, 0xf1, 0xa9, 0xf3, 0x7b, 0xbc, 0x8d, 0x21,
+                           0xa7, 0x9c, 0x21, 0xf8, 0xcb, 0x90, 0x02, 0x89,
+                           0xa8, 0x45, 0x34, 0x8e, 0xc8, 0xc5, 0xb5, 0xf1,
+                           0x26, 0xf5, 0x0e, 0x76, 0xfe, 0xfd, 0x1b, 0x1e },
+               .klen   = 48,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
+               .input  = { 0xbd, 0x06, 0xb8, 0xe1, 0xdb, 0x98, 0x89, 0x9e,
+                           0xc4, 0x98, 0xe4, 0x91, 0xcf, 0x1c, 0x70, 0x2b },
+               .ilen   = 16,
+               .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+                           0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
+               .rlen   = 16,
+       }, { /* LRW-32-AES 7 */
+               .key    = { 0xfb, 0x76, 0x15, 0xb2, 0x3d, 0x80, 0x89, 0x1d,
+                           0xd4, 0x70, 0x98, 0x0b, 0xc7, 0x95, 0x84, 0xc8,
+                           0xb2, 0xfb, 0x64, 0xce, 0x60, 0x97, 0x87, 0x8d,
+                           0x17, 0xfc, 0xe4, 0x5a, 0x49, 0xe8, 0x30, 0xb7,
+                           0x6e, 0x78, 0x17, 0xe7, 0x2d, 0x5e, 0x12, 0xd4,
+                           0x60, 0x64, 0x04, 0x7a, 0xf1, 0x2f, 0x9e, 0x0c },
+               .klen   = 48,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                           0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 },
+               .input  = { 0x5b, 0x90, 0x8e, 0xc1, 0xab, 0xdd, 0x67, 0x5f,
+                           0x3d, 0x69, 0x8a, 0x95, 0x53, 0xc8, 0x9c, 0xe5 },
+               .ilen   = 16,
+               .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+                           0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
+               .rlen   = 16,
+       }, {
+/* http://www.mail-archive.com/stds-p1619@listserv.ieee.org/msg00173.html */
+               .key    = { 0xf8, 0xd4, 0x76, 0xff, 0xd6, 0x46, 0xee, 0x6c,
+                           0x23, 0x84, 0xcb, 0x1c, 0x77, 0xd6, 0x19, 0x5d,
+                           0xfe, 0xf1, 0xa9, 0xf3, 0x7b, 0xbc, 0x8d, 0x21,
+                           0xa7, 0x9c, 0x21, 0xf8, 0xcb, 0x90, 0x02, 0x89,
+                           0xa8, 0x45, 0x34, 0x8e, 0xc8, 0xc5, 0xb5, 0xf1,
+                           0x26, 0xf5, 0x0e, 0x76, 0xfe, 0xfd, 0x1b, 0x1e },
+               .klen   = 48,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
+               .input  = { 0x1a, 0x1d, 0xa9, 0x30, 0xad, 0xf9, 0x2f, 0x9b,
+                           0xb6, 0x1d, 0xae, 0xef, 0xf0, 0x2f, 0xf8, 0x5a,
+                           0x39, 0x3c, 0xbf, 0x2a, 0xb2, 0x45, 0xb2, 0x23,
+                           0x1b, 0x63, 0x3c, 0xcf, 0xaa, 0xbe, 0xcf, 0x4e,
+                           0xfa, 0xe8, 0x29, 0xc2, 0x20, 0x68, 0x2b, 0x3c,
+                           0x2e, 0x8b, 0xf7, 0x6e, 0x25, 0xbd, 0xe3, 0x3d,
+                           0x66, 0x27, 0xd6, 0xaf, 0xd6, 0x64, 0x3e, 0xe3,
+                           0xe8, 0x58, 0x46, 0x97, 0x39, 0x51, 0x07, 0xde,
+                           0xcb, 0x37, 0xbc, 0xa9, 0xc0, 0x5f, 0x75, 0xc3,
+                           0x0e, 0x84, 0x23, 0x1d, 0x16, 0xd4, 0x1c, 0x59,
+                           0x9c, 0x1a, 0x02, 0x55, 0xab, 0x3a, 0x97, 0x1d,
+                           0xdf, 0xdd, 0xc7, 0x06, 0x51, 0xd7, 0x70, 0xae,
+                           0x23, 0xc6, 0x8c, 0xf5, 0x1e, 0xa0, 0xe5, 0x82,
+                           0xb8, 0xb2, 0xbf, 0x04, 0xa0, 0x32, 0x8e, 0x68,
+                           0xeb, 0xaf, 0x6e, 0x2d, 0x94, 0x22, 0x2f, 0xce,
+                           0x4c, 0xb5, 0x59, 0xe2, 0xa2, 0x2f, 0xa0, 0x98,
+                           0x1a, 0x97, 0xc6, 0xd4, 0xb5, 0x00, 0x59, 0xf2,
+                           0x84, 0x14, 0x72, 0xb1, 0x9a, 0x6e, 0xa3, 0x7f,
+                           0xea, 0x20, 0xe7, 0xcb, 0x65, 0x77, 0x3a, 0xdf,
+                           0xc8, 0x97, 0x67, 0x15, 0xc2, 0x2a, 0x27, 0xcc,
+                           0x18, 0x55, 0xa1, 0x24, 0x0b, 0x24, 0x24, 0xaf,
+                           0x5b, 0xec, 0x68, 0xb8, 0xc8, 0xf5, 0xba, 0x63,
+                           0xff, 0xed, 0x89, 0xce, 0xd5, 0x3d, 0x88, 0xf3,
+                           0x25, 0xef, 0x05, 0x7c, 0x3a, 0xef, 0xeb, 0xd8,
+                           0x7a, 0x32, 0x0d, 0xd1, 0x1e, 0x58, 0x59, 0x99,
+                           0x90, 0x25, 0xb5, 0x26, 0xb0, 0xe3, 0x2b, 0x6c,
+                           0x4c, 0xa9, 0x8b, 0x84, 0x4f, 0x5e, 0x01, 0x50,
+                           0x41, 0x30, 0x58, 0xc5, 0x62, 0x74, 0x52, 0x1d,
+                           0x45, 0x24, 0x6a, 0x42, 0x64, 0x4f, 0x97, 0x1c,
+                           0xa8, 0x66, 0xb5, 0x6d, 0x79, 0xd4, 0x0d, 0x48,
+                           0xc5, 0x5f, 0xf3, 0x90, 0x32, 0xdd, 0xdd, 0xe1,
+                           0xe4, 0xa9, 0x9f, 0xfc, 0xc3, 0x52, 0x5a, 0x46,
+                           0xe4, 0x81, 0x84, 0x95, 0x36, 0x59, 0x7a, 0x6b,
+                           0xaa, 0xb3, 0x60, 0xad, 0xce, 0x9f, 0x9f, 0x28,
+                           0xe0, 0x01, 0x75, 0x22, 0xc4, 0x4e, 0xa9, 0x62,
+                           0x5c, 0x62, 0x0d, 0x00, 0xcb, 0x13, 0xe8, 0x43,
+                           0x72, 0xd4, 0x2d, 0x53, 0x46, 0xb5, 0xd1, 0x16,
+                           0x22, 0x18, 0xdf, 0x34, 0x33, 0xf5, 0xd6, 0x1c,
+                           0xb8, 0x79, 0x78, 0x97, 0x94, 0xff, 0x72, 0x13,
+                           0x4c, 0x27, 0xfc, 0xcb, 0xbf, 0x01, 0x53, 0xa6,
+                           0xb4, 0x50, 0x6e, 0xde, 0xdf, 0xb5, 0x43, 0xa4,
+                           0x59, 0xdf, 0x52, 0xf9, 0x7c, 0xe0, 0x11, 0x6f,
+                           0x2d, 0x14, 0x8e, 0x24, 0x61, 0x2c, 0xe1, 0x17,
+                           0xcc, 0xce, 0x51, 0x0c, 0x19, 0x8a, 0x82, 0x30,
+                           0x94, 0xd5, 0x3d, 0x6a, 0x53, 0x06, 0x5e, 0xbd,
+                           0xb7, 0xeb, 0xfa, 0xfd, 0x27, 0x51, 0xde, 0x85,
+                           0x1e, 0x86, 0x53, 0x11, 0x53, 0x94, 0x00, 0xee,
+                           0x2b, 0x8c, 0x08, 0x2a, 0xbf, 0xdd, 0xae, 0x11,
+                           0xcb, 0x1e, 0xa2, 0x07, 0x9a, 0x80, 0xcf, 0x62,
+                           0x9b, 0x09, 0xdc, 0x95, 0x3c, 0x96, 0x8e, 0xb1,
+                           0x09, 0xbd, 0xe4, 0xeb, 0xdb, 0xca, 0x70, 0x7a,
+                           0x9e, 0xfa, 0x31, 0x18, 0x45, 0x3c, 0x21, 0x33,
+                           0xb0, 0xb3, 0x2b, 0xea, 0xf3, 0x71, 0x2d, 0xe1,
+                           0x03, 0xad, 0x1b, 0x48, 0xd4, 0x67, 0x27, 0xf0,
+                           0x62, 0xe4, 0x3d, 0xfb, 0x9b, 0x08, 0x76, 0xe7,
+                           0xdd, 0x2b, 0x01, 0x39, 0x04, 0x5a, 0x58, 0x7a,
+                           0xf7, 0x11, 0x90, 0xec, 0xbd, 0x51, 0x5c, 0x32,
+                           0x6b, 0xd7, 0x35, 0x39, 0x02, 0x6b, 0xf2, 0xa6,
+                           0xd0, 0x0d, 0x07, 0xe1, 0x06, 0xc4, 0x5b, 0x7d,
+                           0xe4, 0x6a, 0xd7, 0xee, 0x15, 0x1f, 0x83, 0xb4,
+                           0xa3, 0xa7, 0x5e, 0xc3, 0x90, 0xb7, 0xef, 0xd3,
+                           0xb7, 0x4f, 0xf8, 0x92, 0x4c, 0xb7, 0x3c, 0x29,
+                           0xcd, 0x7e, 0x2b, 0x5d, 0x43, 0xea, 0x42, 0xe7,
+                           0x74, 0x3f, 0x7d, 0x58, 0x88, 0x75, 0xde, 0x3e },
+               .ilen   = 512,
+               .result = { 0x05, 0x11, 0xb7, 0x18, 0xab, 0xc6, 0x2d, 0xac,
+                           0x70, 0x5d, 0xf6, 0x22, 0x94, 0xcd, 0xe5, 0x6c,
+                           0x17, 0x6b, 0xf6, 0x1c, 0xf0, 0xf3, 0x6e, 0xf8,
+                           0x50, 0x38, 0x1f, 0x71, 0x49, 0xb6, 0x57, 0xd6,
+                           0x8f, 0xcb, 0x8d, 0x6b, 0xe3, 0xa6, 0x29, 0x90,
+                           0xfe, 0x2a, 0x62, 0x82, 0xae, 0x6d, 0x8b, 0xf6,
+                           0xad, 0x1e, 0x9e, 0x20, 0x5f, 0x38, 0xbe, 0x04,
+                           0xda, 0x10, 0x8e, 0xed, 0xa2, 0xa4, 0x87, 0xab,
+                           0xda, 0x6b, 0xb4, 0x0c, 0x75, 0xba, 0xd3, 0x7c,
+                           0xc9, 0xac, 0x42, 0x31, 0x95, 0x7c, 0xc9, 0x04,
+                           0xeb, 0xd5, 0x6e, 0x32, 0x69, 0x8a, 0xdb, 0xa6,
+                           0x15, 0xd7, 0x3f, 0x4f, 0x2f, 0x66, 0x69, 0x03,
+                           0x9c, 0x1f, 0x54, 0x0f, 0xde, 0x1f, 0xf3, 0x65,
+                           0x4c, 0x96, 0x12, 0xed, 0x7c, 0x92, 0x03, 0x01,
+                           0x6f, 0xbc, 0x35, 0x93, 0xac, 0xf1, 0x27, 0xf1,
+                           0xb4, 0x96, 0x82, 0x5a, 0x5f, 0xb0, 0xa0, 0x50,
+                           0x89, 0xa4, 0x8e, 0x66, 0x44, 0x85, 0xcc, 0xfd,
+                           0x33, 0x14, 0x70, 0xe3, 0x96, 0xb2, 0xc3, 0xd3,
+                           0xbb, 0x54, 0x5a, 0x1a, 0xf9, 0x74, 0xa2, 0xc5,
+                           0x2d, 0x64, 0x75, 0xdd, 0xb4, 0x54, 0xe6, 0x74,
+                           0x8c, 0xd3, 0x9d, 0x9e, 0x86, 0xab, 0x51, 0x53,
+                           0xb7, 0x93, 0x3e, 0x6f, 0xd0, 0x4e, 0x2c, 0x40,
+                           0xf6, 0xa8, 0x2e, 0x3e, 0x9d, 0xf4, 0x66, 0xa5,
+                           0x76, 0x12, 0x73, 0x44, 0x1a, 0x56, 0xd7, 0x72,
+                           0x88, 0xcd, 0x21, 0x8c, 0x4c, 0x0f, 0xfe, 0xda,
+                           0x95, 0xe0, 0x3a, 0xa6, 0xa5, 0x84, 0x46, 0xcd,
+                           0xd5, 0x3e, 0x9d, 0x3a, 0xe2, 0x67, 0xe6, 0x60,
+                           0x1a, 0xe2, 0x70, 0x85, 0x58, 0xc2, 0x1b, 0x09,
+                           0xe1, 0xd7, 0x2c, 0xca, 0xad, 0xa8, 0x8f, 0xf9,
+                           0xac, 0xb3, 0x0e, 0xdb, 0xca, 0x2e, 0xe2, 0xb8,
+                           0x51, 0x71, 0xd9, 0x3c, 0x6c, 0xf1, 0x56, 0xf8,
+                           0xea, 0x9c, 0xf1, 0xfb, 0x0c, 0xe6, 0xb7, 0x10,
+                           0x1c, 0xf8, 0xa9, 0x7c, 0xe8, 0x53, 0x35, 0xc1,
+                           0x90, 0x3e, 0x76, 0x4a, 0x74, 0xa4, 0x21, 0x2c,
+                           0xf6, 0x2c, 0x4e, 0x0f, 0x94, 0x3a, 0x88, 0x2e,
+                           0x41, 0x09, 0x6a, 0x33, 0x7d, 0xf6, 0xdd, 0x3f,
+                           0x8d, 0x23, 0x31, 0x74, 0x84, 0xeb, 0x88, 0x6e,
+                           0xcc, 0xb9, 0xbc, 0x22, 0x83, 0x19, 0x07, 0x22,
+                           0xa5, 0x2d, 0xdf, 0xa5, 0xf3, 0x80, 0x85, 0x78,
+                           0x84, 0x39, 0x6a, 0x6d, 0x6a, 0x99, 0x4f, 0xa5,
+                           0x15, 0xfe, 0x46, 0xb0, 0xe4, 0x6c, 0xa5, 0x41,
+                           0x3c, 0xce, 0x8f, 0x42, 0x60, 0x71, 0xa7, 0x75,
+                           0x08, 0x40, 0x65, 0x8a, 0x82, 0xbf, 0xf5, 0x43,
+                           0x71, 0x96, 0xa9, 0x4d, 0x44, 0x8a, 0x20, 0xbe,
+                           0xfa, 0x4d, 0xbb, 0xc0, 0x7d, 0x31, 0x96, 0x65,
+                           0xe7, 0x75, 0xe5, 0x3e, 0xfd, 0x92, 0x3b, 0xc9,
+                           0x55, 0xbb, 0x16, 0x7e, 0xf7, 0xc2, 0x8c, 0xa4,
+                           0x40, 0x1d, 0xe5, 0xef, 0x0e, 0xdf, 0xe4, 0x9a,
+                           0x62, 0x73, 0x65, 0xfd, 0x46, 0x63, 0x25, 0x3d,
+                           0x2b, 0xaf, 0xe5, 0x64, 0xfe, 0xa5, 0x5c, 0xcf,
+                           0x24, 0xf3, 0xb4, 0xac, 0x64, 0xba, 0xdf, 0x4b,
+                           0xc6, 0x96, 0x7d, 0x81, 0x2d, 0x8d, 0x97, 0xf7,
+                           0xc5, 0x68, 0x77, 0x84, 0x32, 0x2b, 0xcc, 0x85,
+                           0x74, 0x96, 0xf0, 0x12, 0x77, 0x61, 0xb9, 0xeb,
+                           0x71, 0xaa, 0x82, 0xcb, 0x1c, 0xdb, 0x89, 0xc8,
+                           0xc6, 0xb5, 0xe3, 0x5c, 0x7d, 0x39, 0x07, 0x24,
+                           0xda, 0x39, 0x87, 0x45, 0xc0, 0x2b, 0xbb, 0x01,
+                           0xac, 0xbc, 0x2a, 0x5c, 0x7f, 0xfc, 0xe8, 0xce,
+                           0x6d, 0x9c, 0x6f, 0xed, 0xd3, 0xc1, 0xa1, 0xd6,
+                           0xc5, 0x55, 0xa9, 0x66, 0x2f, 0xe1, 0xc8, 0x32,
+                           0xa6, 0x5d, 0xa4, 0x3a, 0x98, 0x73, 0xe8, 0x45,
+                           0xa4, 0xc7, 0xa8, 0xb4, 0xf6, 0x13, 0x03, 0xf6,
+                           0xe9, 0x2e, 0xc4, 0x29, 0x0f, 0x84, 0xdb, 0xc4,
+                           0x21, 0xc4, 0xc2, 0x75, 0x67, 0x89, 0x37, 0x0a },
+               .rlen   = 512,
+       }
+};
+
 /* Cast5 test vectors from RFC 2144 */
 #define CAST5_ENC_TEST_VECTORS 3
 #define CAST5_DEC_TEST_VECTORS 3
@@ -3084,6 +3657,27 @@ static struct cipher_speed aes_speed_template[] = {
        {  .klen = 0, .blen = 0, }
 };
 
+static struct cipher_speed aes_lrw_speed_template[] = {
+       { .klen = 32, .blen = 16, },
+       { .klen = 32, .blen = 64, },
+       { .klen = 32, .blen = 256, },
+       { .klen = 32, .blen = 1024, },
+       { .klen = 32, .blen = 8192, },
+       { .klen = 40, .blen = 16, },
+       { .klen = 40, .blen = 64, },
+       { .klen = 40, .blen = 256, },
+       { .klen = 40, .blen = 1024, },
+       { .klen = 40, .blen = 8192, },
+       { .klen = 48, .blen = 16, },
+       { .klen = 48, .blen = 64, },
+       { .klen = 48, .blen = 256, },
+       { .klen = 48, .blen = 1024, },
+       { .klen = 48, .blen = 8192, },
+
+       /* End marker */
+       {  .klen = 0, .blen = 0, }
+};
+
 static struct cipher_speed des3_ede_speed_template[] = {
        { .klen = 24, .blen = 16, },
        { .klen = 24, .blen = 64, },
diff --git a/crypto/xcbc.c b/crypto/xcbc.c
new file mode 100644 (file)
index 0000000..9347eb6
--- /dev/null
@@ -0,0 +1,348 @@
+/*
+ * Copyright (C)2006 USAGI/WIDE Project
+ *
+ * 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
+ *
+ * Author:
+ *     Kazunori Miyazawa <miyazawa@linux-ipv6.org>
+ */
+
+#include <linux/crypto.h>
+#include <linux/err.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/rtnetlink.h>
+#include <linux/slab.h>
+#include <linux/scatterlist.h>
+#include "internal.h"
+
+static u_int32_t ks[12] = {0x01010101, 0x01010101, 0x01010101, 0x01010101,
+                          0x02020202, 0x02020202, 0x02020202, 0x02020202,
+                          0x03030303, 0x03030303, 0x03030303, 0x03030303};
+/*
+ * +------------------------
+ * | <parent tfm>
+ * +------------------------
+ * | crypto_xcbc_ctx
+ * +------------------------
+ * | odds (block size)
+ * +------------------------
+ * | prev (block size)
+ * +------------------------
+ * | key (block size)
+ * +------------------------
+ * | consts (block size * 3)
+ * +------------------------
+ */
+struct crypto_xcbc_ctx {
+       struct crypto_tfm *child;
+       u8 *odds;
+       u8 *prev;
+       u8 *key;
+       u8 *consts;
+       void (*xor)(u8 *a, const u8 *b, unsigned int bs);
+       unsigned int keylen;
+       unsigned int len;
+};
+
+static void xor_128(u8 *a, const u8 *b, unsigned int bs)
+{
+       ((u32 *)a)[0] ^= ((u32 *)b)[0];
+       ((u32 *)a)[1] ^= ((u32 *)b)[1];
+       ((u32 *)a)[2] ^= ((u32 *)b)[2];
+       ((u32 *)a)[3] ^= ((u32 *)b)[3];
+}
+
+static int _crypto_xcbc_digest_setkey(struct crypto_hash *parent,
+                                     struct crypto_xcbc_ctx *ctx)
+{
+       int bs = crypto_hash_blocksize(parent);
+       int err = 0;
+       u8 key1[bs];
+
+       if ((err = crypto_cipher_setkey(ctx->child, ctx->key, ctx->keylen)))
+           return err;
+
+       ctx->child->__crt_alg->cra_cipher.cia_encrypt(ctx->child, key1,
+                       ctx->consts);
+
+       return crypto_cipher_setkey(ctx->child, key1, bs);
+}
+
+static int crypto_xcbc_digest_setkey(struct crypto_hash *parent,
+                                    const u8 *inkey, unsigned int keylen)
+{
+       struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(parent);
+
+       if (keylen != crypto_tfm_alg_blocksize(ctx->child))
+               return -EINVAL;
+
+       ctx->keylen = keylen;
+       memcpy(ctx->key, inkey, keylen);
+       ctx->consts = (u8*)ks;
+
+       return _crypto_xcbc_digest_setkey(parent, ctx);
+}
+
+static int crypto_xcbc_digest_init(struct hash_desc *pdesc)
+{
+       struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(pdesc->tfm);
+       int bs = crypto_hash_blocksize(pdesc->tfm);
+
+       ctx->len = 0;
+       memset(ctx->odds, 0, bs);
+       memset(ctx->prev, 0, bs);
+
+       return 0;
+}
+
+static int crypto_xcbc_digest_update(struct hash_desc *pdesc,
+                                    struct scatterlist *sg,
+                                    unsigned int nbytes)
+{
+       struct crypto_hash *parent = pdesc->tfm;
+       struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(parent);
+       struct crypto_tfm *tfm = ctx->child;
+       int bs = crypto_hash_blocksize(parent);
+       unsigned int i = 0;
+
+       do {
+
+               struct page *pg = sg[i].page;
+               unsigned int offset = sg[i].offset;
+               unsigned int slen = sg[i].length;
+
+               while (slen > 0) {
+                       unsigned int len = min(slen, ((unsigned int)(PAGE_SIZE)) - offset);
+                       char *p = crypto_kmap(pg, 0) + offset;
+
+                       /* checking the data can fill the block */
+                       if ((ctx->len + len) <= bs) {
+                               memcpy(ctx->odds + ctx->len, p, len);
+                               ctx->len += len;
+                               slen -= len;
+
+                               /* checking the rest of the page */
+                               if (len + offset >= PAGE_SIZE) {
+                                       offset = 0;
+                                       pg++;
+                               } else
+                                       offset += len;
+
+                               crypto_kunmap(p, 0);
+                               crypto_yield(tfm->crt_flags);
+                               continue;
+                       }
+
+                       /* filling odds with new data and encrypting it */
+                       memcpy(ctx->odds + ctx->len, p, bs - ctx->len);
+                       len -= bs - ctx->len;
+                       p += bs - ctx->len;
+
+                       ctx->xor(ctx->prev, ctx->odds, bs);
+                       tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, ctx->prev, ctx->prev);
+
+                       /* clearing the length */
+                       ctx->len = 0;
+
+                       /* encrypting the rest of data */
+                       while (len > bs) {
+                               ctx->xor(ctx->prev, p, bs);
+                               tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, ctx->prev, ctx->prev);
+                               p += bs;
+                               len -= bs;
+                       }
+
+                       /* keeping the surplus of blocksize */
+                       if (len) {
+                               memcpy(ctx->odds, p, len);
+                               ctx->len = len;
+                       }
+                       crypto_kunmap(p, 0);
+                       crypto_yield(tfm->crt_flags);
+                       slen -= min(slen, ((unsigned int)(PAGE_SIZE)) - offset);
+                       offset = 0;
+                       pg++;
+               }
+               nbytes-=sg[i].length;
+               i++;
+       } while (nbytes>0);
+
+       return 0;
+}
+
+static int crypto_xcbc_digest_final(struct hash_desc *pdesc, u8 *out)
+{
+       struct crypto_hash *parent = pdesc->tfm;
+       struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(parent);
+       struct crypto_tfm *tfm = ctx->child;
+       int bs = crypto_hash_blocksize(parent);
+       int err = 0;
+
+       if (ctx->len == bs) {
+               u8 key2[bs];
+
+               if ((err = crypto_cipher_setkey(tfm, ctx->key, ctx->keylen)) != 0)
+                       return err;
+
+               tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, key2, (const u8*)(ctx->consts+bs));
+
+               ctx->xor(ctx->prev, ctx->odds, bs);
+               ctx->xor(ctx->prev, key2, bs);
+               _crypto_xcbc_digest_setkey(parent, ctx);
+
+               tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, out, ctx->prev);
+       } else {
+               u8 key3[bs];
+               unsigned int rlen;
+               u8 *p = ctx->odds + ctx->len;
+               *p = 0x80;
+               p++;
+
+               rlen = bs - ctx->len -1;
+               if (rlen)
+                       memset(p, 0, rlen);
+
+               if ((err = crypto_cipher_setkey(tfm, ctx->key, ctx->keylen)) != 0)
+                       return err;
+
+               tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, key3, (const u8*)(ctx->consts+bs*2));
+
+               ctx->xor(ctx->prev, ctx->odds, bs);
+               ctx->xor(ctx->prev, key3, bs);
+
+               _crypto_xcbc_digest_setkey(parent, ctx);
+
+               tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, out, ctx->prev);
+       }
+
+       return 0;
+}
+
+static int crypto_xcbc_digest(struct hash_desc *pdesc,
+                 struct scatterlist *sg, unsigned int nbytes, u8 *out)
+{
+       crypto_xcbc_digest_init(pdesc);
+       crypto_xcbc_digest_update(pdesc, sg, nbytes);
+       return crypto_xcbc_digest_final(pdesc, out);
+}
+
+static int xcbc_init_tfm(struct crypto_tfm *tfm)
+{
+       struct crypto_instance *inst = (void *)tfm->__crt_alg;
+       struct crypto_spawn *spawn = crypto_instance_ctx(inst);
+       struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(__crypto_hash_cast(tfm));
+       int bs = crypto_hash_blocksize(__crypto_hash_cast(tfm));
+
+       tfm = crypto_spawn_tfm(spawn);
+       if (IS_ERR(tfm))
+               return PTR_ERR(tfm);
+
+       switch(bs) {
+       case 16:
+               ctx->xor = xor_128;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       ctx->child = crypto_cipher_cast(tfm);
+       ctx->odds = (u8*)(ctx+1);
+       ctx->prev = ctx->odds + bs;
+       ctx->key = ctx->prev + bs;
+
+       return 0;
+};
+
+static void xcbc_exit_tfm(struct crypto_tfm *tfm)
+{
+       struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(__crypto_hash_cast(tfm));
+       crypto_free_cipher(ctx->child);
+}
+
+static struct crypto_instance *xcbc_alloc(void *param, unsigned int len)
+{
+       struct crypto_instance *inst;
+       struct crypto_alg *alg;
+       alg = crypto_get_attr_alg(param, len, CRYPTO_ALG_TYPE_CIPHER,
+                                 CRYPTO_ALG_TYPE_HASH_MASK | CRYPTO_ALG_ASYNC);
+       if (IS_ERR(alg))
+               return ERR_PTR(PTR_ERR(alg));
+
+       switch(alg->cra_blocksize) {
+       case 16:
+               break;
+       default:
+               return ERR_PTR(PTR_ERR(alg));
+       }
+
+       inst = crypto_alloc_instance("xcbc", alg);
+       if (IS_ERR(inst))
+               goto out_put_alg;
+
+       inst->alg.cra_flags = CRYPTO_ALG_TYPE_HASH;
+       inst->alg.cra_priority = alg->cra_priority;
+       inst->alg.cra_blocksize = alg->cra_blocksize;
+       inst->alg.cra_alignmask = alg->cra_alignmask;
+       inst->alg.cra_type = &crypto_hash_type;
+
+       inst->alg.cra_hash.digestsize =
+               (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) ==
+               CRYPTO_ALG_TYPE_HASH ? alg->cra_hash.digestsize :
+                                      alg->cra_blocksize;
+       inst->alg.cra_ctxsize = sizeof(struct crypto_xcbc_ctx) +
+                               ALIGN(inst->alg.cra_blocksize * 3, sizeof(void *));
+       inst->alg.cra_init = xcbc_init_tfm;
+       inst->alg.cra_exit = xcbc_exit_tfm;
+
+       inst->alg.cra_hash.init = crypto_xcbc_digest_init;
+       inst->alg.cra_hash.update = crypto_xcbc_digest_update;
+       inst->alg.cra_hash.final = crypto_xcbc_digest_final;
+       inst->alg.cra_hash.digest = crypto_xcbc_digest;
+       inst->alg.cra_hash.setkey = crypto_xcbc_digest_setkey;
+
+out_put_alg:
+       crypto_mod_put(alg);
+       return inst;
+}
+
+static void xcbc_free(struct crypto_instance *inst)
+{
+       crypto_drop_spawn(crypto_instance_ctx(inst));
+       kfree(inst);
+}
+
+static struct crypto_template crypto_xcbc_tmpl = {
+       .name = "xcbc",
+       .alloc = xcbc_alloc,
+       .free = xcbc_free,
+       .module = THIS_MODULE,
+};
+
+static int __init crypto_xcbc_module_init(void)
+{
+       return crypto_register_template(&crypto_xcbc_tmpl);
+}
+
+static void __exit crypto_xcbc_module_exit(void)
+{
+       crypto_unregister_template(&crypto_xcbc_tmpl);
+}
+
+module_init(crypto_xcbc_module_init);
+module_exit(crypto_xcbc_module_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("XCBC keyed hash algorithm");
index f39463418904f0777e105911edfec32b0331dc7a..4929e923b5c6fa15632cd45afd4e4df62b294ef6 100644 (file)
@@ -64,6 +64,8 @@ source "drivers/video/Kconfig"
 
 source "sound/Kconfig"
 
+source "drivers/hid/Kconfig"
+
 source "drivers/usb/Kconfig"
 
 source "drivers/mmc/Kconfig"
index 67711770b1d9c53d95746db422f6b711c8857a2c..50f76da598c95f67d86d7097c57fa2b03ee08909 100644 (file)
@@ -77,4 +77,5 @@ obj-$(CONFIG_CRYPTO)          += crypto/
 obj-$(CONFIG_SUPERH)           += sh/
 obj-$(CONFIG_GENERIC_TIME)     += clocksource/
 obj-$(CONFIG_DMA_ENGINE)       += dma/
+obj-$(CONFIG_HID)              += hid/
 obj-$(CONFIG_PPC_PS3)          += ps3/
index 9e3e2a69c03a6dedd375b32666e94b0989ed1566..fd5475071accea2d48ff5ec7f15270d61409a27b 100644 (file)
@@ -80,12 +80,38 @@ static int amba_resume(struct device *dev)
        return ret;
 }
 
+#define amba_attr_func(name,fmt,arg...)                                        \
+static ssize_t name##_show(struct device *_dev,                                \
+                          struct device_attribute *attr, char *buf)    \
+{                                                                      \
+       struct amba_device *dev = to_amba_device(_dev);                 \
+       return sprintf(buf, fmt, arg);                                  \
+}
+
+#define amba_attr(name,fmt,arg...)     \
+amba_attr_func(name,fmt,arg)           \
+static DEVICE_ATTR(name, S_IRUGO, name##_show, NULL)
+
+amba_attr_func(id, "%08x\n", dev->periphid);
+amba_attr(irq0, "%u\n", dev->irq[0]);
+amba_attr(irq1, "%u\n", dev->irq[1]);
+amba_attr_func(resource, "\t%016llx\t%016llx\t%016lx\n",
+        (unsigned long long)dev->res.start, (unsigned long long)dev->res.end,
+        dev->res.flags);
+
+static struct device_attribute amba_dev_attrs[] = {
+       __ATTR_RO(id),
+       __ATTR_RO(resource),
+       __ATTR_NULL,
+};
+
 /*
  * Primecells are part of the Advanced Microcontroller Bus Architecture,
  * so we call the bus "amba".
  */
 static struct bus_type amba_bustype = {
        .name           = "amba",
+       .dev_attrs      = amba_dev_attrs,
        .match          = amba_match,
        .uevent         = amba_uevent,
        .suspend        = amba_suspend,
@@ -169,21 +195,6 @@ static void amba_device_release(struct device *dev)
        kfree(d);
 }
 
-#define amba_attr(name,fmt,arg...)                             \
-static ssize_t show_##name(struct device *_dev, struct device_attribute *attr, char *buf)      \
-{                                                              \
-       struct amba_device *dev = to_amba_device(_dev);         \
-       return sprintf(buf, fmt, arg);                          \
-}                                                              \
-static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
-
-amba_attr(id, "%08x\n", dev->periphid);
-amba_attr(irq0, "%u\n", dev->irq[0]);
-amba_attr(irq1, "%u\n", dev->irq[1]);
-amba_attr(resource, "\t%016llx\t%016llx\t%016lx\n",
-        (unsigned long long)dev->res.start, (unsigned long long)dev->res.end,
-        dev->res.flags);
-
 /**
  *     amba_device_register - register an AMBA device
  *     @dev: AMBA device to register
@@ -208,40 +219,46 @@ int amba_device_register(struct amba_device *dev, struct resource *parent)
                dev_warn(&dev->dev, "coherent dma mask is unset\n");
 
        ret = request_resource(parent, &dev->res);
-       if (ret == 0) {
-               tmp = ioremap(dev->res.start, SZ_4K);
-               if (!tmp) {
-                       ret = -ENOMEM;
-                       goto out;
-               }
-
-               for (pid = 0, i = 0; i < 4; i++)
-                       pid |= (readl(tmp + 0xfe0 + 4 * i) & 255) << (i * 8);
-               for (cid = 0, i = 0; i < 4; i++)
-                       cid |= (readl(tmp + 0xff0 + 4 * i) & 255) << (i * 8);
-
-               iounmap(tmp);
-
-               if (cid == 0xb105f00d)
-                       dev->periphid = pid;
-
-               if (dev->periphid)
-                       ret = device_register(&dev->dev);
-               else
-                       ret = -ENODEV;
-
-               if (ret == 0) {
-                       device_create_file(&dev->dev, &dev_attr_id);
-                       if (dev->irq[0] != NO_IRQ)
-                               device_create_file(&dev->dev, &dev_attr_irq0);
-                       if (dev->irq[1] != NO_IRQ)
-                               device_create_file(&dev->dev, &dev_attr_irq1);
-                       device_create_file(&dev->dev, &dev_attr_resource);
-               } else {
- out:
-                       release_resource(&dev->res);
-               }
+       if (ret)
+               goto err_out;
+
+       tmp = ioremap(dev->res.start, SZ_4K);
+       if (!tmp) {
+               ret = -ENOMEM;
+               goto err_release;
        }
+
+       for (pid = 0, i = 0; i < 4; i++)
+               pid |= (readl(tmp + 0xfe0 + 4 * i) & 255) << (i * 8);
+       for (cid = 0, i = 0; i < 4; i++)
+               cid |= (readl(tmp + 0xff0 + 4 * i) & 255) << (i * 8);
+
+       iounmap(tmp);
+
+       if (cid == 0xb105f00d)
+               dev->periphid = pid;
+
+       if (!dev->periphid) {
+               ret = -ENODEV;
+               goto err_release;
+       }
+
+       ret = device_register(&dev->dev);
+       if (ret)
+               goto err_release;
+
+       if (dev->irq[0] != NO_IRQ)
+               ret = device_create_file(&dev->dev, &dev_attr_irq0);
+       if (ret == 0 && dev->irq[1] != NO_IRQ)
+               ret = device_create_file(&dev->dev, &dev_attr_irq1);
+       if (ret == 0)
+               return ret;
+
+       device_unregister(&dev->dev);
+
+ err_release:
+       release_resource(&dev->res);
+ err_out:
        return ret;
 }
 
index 8816e30fb7a42d978e0cf6eba687f25090368b65..011c0a8a2dcc6cbef5de1dda26899ebf83cb5345 100644 (file)
@@ -2303,7 +2303,7 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed,
         * DMA cycle timing is slower/equal than the fastest PIO timing.
         */
 
-       if (speed > XFER_PIO_4) {
+       if (speed > XFER_PIO_6) {
                ata_timing_compute(adev, adev->pio_mode, &p, T, UT);
                ata_timing_merge(&p, t, t, ATA_TIMING_ALL);
        }
@@ -4960,6 +4960,7 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
        if (ap->flags & ATA_FLAG_PIO_POLLING) {
                switch (qc->tf.protocol) {
                case ATA_PROT_PIO:
+               case ATA_PROT_NODATA:
                case ATA_PROT_ATAPI:
                case ATA_PROT_ATAPI_NODATA:
                        qc->tf.flags |= ATA_TFLAG_POLLING;
index a2778cf016bc2e8866423775416a48621a17433c..f055874a6ec5d303a11960fe88605c8975e7923c 100644 (file)
@@ -66,15 +66,17 @@ enum {
        board_2037x             = 0,    /* FastTrak S150 TX2plus */
        board_20319             = 1,    /* FastTrak S150 TX4 */
        board_20619             = 2,    /* FastTrak TX4000 */
-       board_20771             = 3,    /* FastTrak TX2300 */
-       board_2057x             = 4,    /* SATAII150 Tx2plus */
-       board_40518             = 5,    /* SATAII150 Tx4 */
+       board_2057x             = 3,    /* SATAII150 Tx2plus */
+       board_40518             = 4,    /* SATAII150 Tx4 */
 
        PDC_HAS_PATA            = (1 << 1), /* PDC20375/20575 has PATA */
 
+       /* PDC_CTLSTAT bit definitions */
+       PDC_DMA_ENABLE          = (1 << 7),
+       PDC_IRQ_DISABLE         = (1 << 10),
        PDC_RESET               = (1 << 11), /* HDMA reset */
 
-       PDC_COMMON_FLAGS        = ATA_FLAG_NO_LEGACY | ATA_FLAG_SRST |
+       PDC_COMMON_FLAGS        = ATA_FLAG_NO_LEGACY |
                                  ATA_FLAG_MMIO | ATA_FLAG_NO_ATAPI |
                                  ATA_FLAG_PIO_POLLING,
 
@@ -90,7 +92,6 @@ struct pdc_port_priv {
 
 struct pdc_host_priv {
        unsigned long           flags;
-       int                     hotplug_offset;
 };
 
 static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg);
@@ -101,13 +102,16 @@ static void pdc_eng_timeout(struct ata_port *ap);
 static int pdc_port_start(struct ata_port *ap);
 static void pdc_port_stop(struct ata_port *ap);
 static void pdc_pata_phy_reset(struct ata_port *ap);
-static void pdc_sata_phy_reset(struct ata_port *ap);
 static void pdc_qc_prep(struct ata_queued_cmd *qc);
 static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
 static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
 static void pdc_irq_clear(struct ata_port *ap);
 static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc);
 static void pdc_host_stop(struct ata_host *host);
+static void pdc_freeze(struct ata_port *ap);
+static void pdc_thaw(struct ata_port *ap);
+static void pdc_error_handler(struct ata_port *ap);
+static void pdc_post_internal_cmd(struct ata_queued_cmd *qc);
 
 
 static struct scsi_host_template pdc_ata_sht = {
@@ -136,11 +140,12 @@ static const struct ata_port_operations pdc_sata_ops = {
        .exec_command           = pdc_exec_command_mmio,
        .dev_select             = ata_std_dev_select,
 
-       .phy_reset              = pdc_sata_phy_reset,
-
        .qc_prep                = pdc_qc_prep,
        .qc_issue               = pdc_qc_issue_prot,
-       .eng_timeout            = pdc_eng_timeout,
+       .freeze                 = pdc_freeze,
+       .thaw                   = pdc_thaw,
+       .error_handler          = pdc_error_handler,
+       .post_internal_cmd      = pdc_post_internal_cmd,
        .data_xfer              = ata_mmio_data_xfer,
        .irq_handler            = pdc_interrupt,
        .irq_clear              = pdc_irq_clear,
@@ -198,23 +203,13 @@ static const struct ata_port_info pdc_port_info[] = {
        /* board_20619 */
        {
                .sht            = &pdc_ata_sht,
-               .flags          = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS,
+               .flags          = PDC_COMMON_FLAGS | ATA_FLAG_SRST | ATA_FLAG_SLAVE_POSS,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
                .udma_mask      = 0x7f, /* udma0-6 ; FIXME */
                .port_ops       = &pdc_pata_ops,
        },
 
-       /* board_20771 */
-       {
-               .sht            = &pdc_ata_sht,
-               .flags          = PDC_COMMON_FLAGS | ATA_FLAG_SATA,
-               .pio_mask       = 0x1f, /* pio0-4 */
-               .mwdma_mask     = 0x07, /* mwdma0-2 */
-               .udma_mask      = 0x7f, /* udma0-6 ; FIXME */
-               .port_ops       = &pdc_sata_ops,
-       },
-
        /* board_2057x */
        {
                .sht            = &pdc_ata_sht,
@@ -244,6 +239,7 @@ static const struct pci_device_id pdc_ata_pci_tbl[] = {
        { PCI_VDEVICE(PROMISE, 0x3570), board_2057x },
        { PCI_VDEVICE(PROMISE, 0x3571), board_2057x },
        { PCI_VDEVICE(PROMISE, 0x3574), board_2057x },
+       { PCI_VDEVICE(PROMISE, 0x3577), board_2057x },
        { PCI_VDEVICE(PROMISE, 0x3d73), board_2057x },
        { PCI_VDEVICE(PROMISE, 0x3d75), board_2057x },
 
@@ -256,15 +252,6 @@ static const struct pci_device_id pdc_ata_pci_tbl[] = {
 
        { PCI_VDEVICE(PROMISE, 0x6629), board_20619 },
 
-/* TODO: remove all associated board_20771 code, as it completely
- * duplicates board_2037x code, unless reason for separation can be
- * divined.
- */
-#if 0
-       { PCI_VDEVICE(PROMISE, 0x3570), board_20771 },
-#endif
-       { PCI_VDEVICE(PROMISE, 0x3577), board_20771 },
-
        { }     /* terminate list */
 };
 
@@ -366,12 +353,6 @@ static void pdc_reset_port(struct ata_port *ap)
        readl(mmio);    /* flush */
 }
 
-static void pdc_sata_phy_reset(struct ata_port *ap)
-{
-       pdc_reset_port(ap);
-       sata_phy_reset(ap);
-}
-
 static void pdc_pata_cbl_detect(struct ata_port *ap)
 {
        u8 tmp;
@@ -439,6 +420,61 @@ static void pdc_qc_prep(struct ata_queued_cmd *qc)
        }
 }
 
+static void pdc_freeze(struct ata_port *ap)
+{
+       void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr;
+       u32 tmp;
+
+       tmp = readl(mmio + PDC_CTLSTAT);
+       tmp |= PDC_IRQ_DISABLE;
+       tmp &= ~PDC_DMA_ENABLE;
+       writel(tmp, mmio + PDC_CTLSTAT);
+       readl(mmio + PDC_CTLSTAT); /* flush */
+}
+
+static void pdc_thaw(struct ata_port *ap)
+{
+       void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr;
+       u32 tmp;
+
+       /* clear IRQ */
+       readl(mmio + PDC_INT_SEQMASK);
+
+       /* turn IRQ back on */
+       tmp = readl(mmio + PDC_CTLSTAT);
+       tmp &= ~PDC_IRQ_DISABLE;
+       writel(tmp, mmio + PDC_CTLSTAT);
+       readl(mmio + PDC_CTLSTAT); /* flush */
+}
+
+static void pdc_error_handler(struct ata_port *ap)
+{
+       ata_reset_fn_t hardreset;
+
+       if (!(ap->pflags & ATA_PFLAG_FROZEN))
+               pdc_reset_port(ap);
+
+       hardreset = NULL;
+       if (sata_scr_valid(ap))
+               hardreset = sata_std_hardreset;
+
+       /* perform recovery */
+       ata_do_eh(ap, ata_std_prereset, ata_std_softreset, hardreset,
+                 ata_std_postreset);
+}
+
+static void pdc_post_internal_cmd(struct ata_queued_cmd *qc)
+{
+       struct ata_port *ap = qc->ap;
+
+       if (qc->flags & ATA_QCFLAG_FAILED)
+               qc->err_mask |= AC_ERR_OTHER;
+
+       /* make DMA engine forget about the failed command */
+       if (qc->err_mask)
+               pdc_reset_port(ap);
+}
+
 static void pdc_eng_timeout(struct ata_port *ap)
 {
        struct ata_host *host = ap->host;
@@ -645,9 +681,14 @@ static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe)
 {
        void __iomem *mmio = pe->mmio_base;
        struct pdc_host_priv *hp = pe->private_data;
-       int hotplug_offset = hp->hotplug_offset;
+       int hotplug_offset;
        u32 tmp;
 
+       if (hp->flags & PDC_FLAG_GEN_II)
+               hotplug_offset = PDC2_SATA_PLUG_CSR;
+       else
+               hotplug_offset = PDC_SATA_PLUG_CSR;
+
        /*
         * Except for the hotplug stuff, this is voodoo from the
         * Promise driver.  Label this entire section
@@ -742,8 +783,6 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
                goto err_out_free_ent;
        }
 
-       /* Set default hotplug offset */
-       hp->hotplug_offset = PDC_SATA_PLUG_CSR;
        probe_ent->private_data = hp;
 
        probe_ent->sht          = pdc_port_info[board_idx].sht;
@@ -767,8 +806,6 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
        switch (board_idx) {
        case board_40518:
                hp->flags |= PDC_FLAG_GEN_II;
-               /* Override hotplug offset for SATAII150 */
-               hp->hotplug_offset = PDC2_SATA_PLUG_CSR;
                /* Fall through */
        case board_20319:
                        probe_ent->n_ports = 4;
@@ -780,10 +817,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
                probe_ent->port[3].scr_addr = base + 0x700;
                break;
        case board_2057x:
-       case board_20771:
                hp->flags |= PDC_FLAG_GEN_II;
-               /* Override hotplug offset for SATAII150 */
-               hp->hotplug_offset = PDC2_SATA_PLUG_CSR;
                /* Fall through */
        case board_2037x:
                probe_ent->n_ports = 2;
index cfa5af883e1357a687df2168d6a706b20f8cbb8f..2ddd76fdbc432bdc0661276d0baf8984d4ae57b2 100644 (file)
@@ -242,6 +242,7 @@ config ATM_IDT77252_USE_SUNI
 config ATM_AMBASSADOR
        tristate "Madge Ambassador (Collage PCI 155 Server)"
        depends on PCI && ATM
+       select BITREVERSE
        help
          This is a driver for ATMizer based ATM card produced by Madge
          Networks Ltd. Say Y (or M to compile as a module named ambassador)
index b5077ce8cb4007b901716c89208e6b94f5012bd5..1b16f8166b094ae474b94f6da5401fe3a9179c19 100644 (file)
@@ -41,7 +41,7 @@ ifeq ($(CONFIG_ATM_FORE200E_PCA),y)
   # guess the target endianess to choose the right PCA-200E firmware image
   ifeq ($(CONFIG_ATM_FORE200E_PCA_DEFAULT_FW),y)
     byteorder.h                        := include$(if $(patsubst $(srctree),,$(objtree)),2)/asm/byteorder.h
-    CONFIG_ATM_FORE200E_PCA_FW := $(obj)/pca200e$(if $(shell $(CC) -E -dM $(byteorder.h) | grep ' __LITTLE_ENDIAN '),.bin,_ecd.bin2)
+    CONFIG_ATM_FORE200E_PCA_FW := $(obj)/pca200e$(if $(shell $(CC) $(CPPFLAGS) -E -dM $(byteorder.h) | grep ' __LITTLE_ENDIAN '),.bin,_ecd.bin2)
   endif
 endif
 
index afa7d750a59372c8087ae9dd8cf2fb4d5dc8c015..3c372e08f77d8d5164cfbbed40833c9ed89c2926 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/poison.h>
+#include <linux/bitrev.h>
 
 #include <asm/atomic.h>
 #include <asm/io.h>
@@ -2068,18 +2069,6 @@ static void __devinit amb_ucode_version (amb_dev * dev) {
   PRINTK (KERN_INFO, "microcode version is %u.%u", major, minor);
 }
   
-// swap bits within byte to get Ethernet ordering
-static u8 bit_swap (u8 byte)
-{
-    const u8 swap[] = {
-      0x0, 0x8, 0x4, 0xc,
-      0x2, 0xa, 0x6, 0xe,
-      0x1, 0x9, 0x5, 0xd,
-      0x3, 0xb, 0x7, 0xf
-    };
-    return ((swap[byte & 0xf]<<4) | swap[byte>>4]);
-}
-
 // get end station address
 static void __devinit amb_esi (amb_dev * dev, u8 * esi) {
   u32 lower4;
@@ -2101,9 +2090,9 @@ static void __devinit amb_esi (amb_dev * dev, u8 * esi) {
     PRINTDB (DBG_INIT, "ESI:");
     for (i = 0; i < ESI_LEN; ++i) {
       if (i < 4)
-         esi[i] = bit_swap (lower4>>(8*i));
+         esi[i] = bitrev8(lower4>>(8*i));
       else
-         esi[i] = bit_swap (upper2>>(8*(i-4)));
+         esi[i] = bitrev8(upper2>>(8*(i-4)));
       PRINTDM (DBG_INIT, " %02x", esi[i]);
     }
     
index c7314a79da0fffcedeb9e40ecef63ec14c994b9e..7d9b4e52f0bf4c985f1766fe2f88c35c78ea6c32 100644 (file)
@@ -820,7 +820,7 @@ he_init_group(struct he_dev *he_dev, int group)
                void *cpuaddr;
 
 #ifdef USE_RBPS_POOL 
-               cpuaddr = pci_pool_alloc(he_dev->rbps_pool, SLAB_KERNEL|SLAB_DMA, &dma_handle);
+               cpuaddr = pci_pool_alloc(he_dev->rbps_pool, GFP_KERNEL|GFP_DMA, &dma_handle);
                if (cpuaddr == NULL)
                        return -ENOMEM;
 #else
@@ -884,7 +884,7 @@ he_init_group(struct he_dev *he_dev, int group)
                void *cpuaddr;
 
 #ifdef USE_RBPL_POOL
-               cpuaddr = pci_pool_alloc(he_dev->rbpl_pool, SLAB_KERNEL|SLAB_DMA, &dma_handle);
+               cpuaddr = pci_pool_alloc(he_dev->rbpl_pool, GFP_KERNEL|GFP_DMA, &dma_handle);
                if (cpuaddr == NULL)
                        return -ENOMEM;
 #else
@@ -1724,7 +1724,7 @@ __alloc_tpd(struct he_dev *he_dev)
        struct he_tpd *tpd;
        dma_addr_t dma_handle; 
 
-       tpd = pci_pool_alloc(he_dev->tpd_pool, SLAB_ATOMIC|SLAB_DMA, &dma_handle);              
+       tpd = pci_pool_alloc(he_dev->tpd_pool, GFP_ATOMIC|GFP_DMA, &dma_handle);
        if (tpd == NULL)
                return NULL;
                        
index e4b530ef757de101329753e37cc1db524dce45c2..67b79a7592a9d94c92d0e737d82638fdc5e7f74d 100644 (file)
@@ -386,6 +386,7 @@ void device_initialize(struct device *dev)
        INIT_LIST_HEAD(&dev->node);
        init_MUTEX(&dev->sem);
        device_init_wakeup(dev, 0);
+       set_dev_node(dev, -1);
 }
 
 #ifdef CONFIG_SYSFS_DEPRECATED
index 1f745f12f94e5edb70f05d5ba6d8e0ac999ac549..7fd095efaebd75d3d6e1446b7bfdee12c64e31df 100644 (file)
@@ -104,8 +104,8 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
 
 /*
  * register_cpu - Setup a driverfs device for a CPU.
- * @cpu - Callers can set the cpu->no_control field to 1, to indicate not to
- *               generate a control file in sysfs for this CPU.
+ * @cpu - cpu->hotpluggable field set to 1 will generate a control file in
+ *       sysfs for this CPU.
  * @num - CPU number to use when creating the device.
  *
  * Initialize and register the CPU device.
@@ -119,7 +119,7 @@ int __devinit register_cpu(struct cpu *cpu, int num)
 
        error = sysdev_register(&cpu->sysdev);
 
-       if (!error && !cpu->no_control)
+       if (!error && cpu->hotpluggable)
                register_cpu_control(cpu);
        if (!error)
                cpu_sys_devices[num] = &cpu->sysdev;
index b2efbd4cf710d9d0ce79474c2280d04c6bbd7c42..dbe0735f8c9e6bab0446ea0278cd749e3ea98630 100644 (file)
@@ -126,7 +126,7 @@ dma_pool_create (const char *name, struct device *dev,
        } else if (allocation < size)
                return NULL;
 
-       if (!(retval = kmalloc (sizeof *retval, SLAB_KERNEL)))
+       if (!(retval = kmalloc (sizeof *retval, GFP_KERNEL)))
                return retval;
 
        strlcpy (retval->name, name, sizeof retval->name);
@@ -297,7 +297,7 @@ restart:
                        }
                }
        }
-       if (!(page = pool_alloc_page (pool, SLAB_ATOMIC))) {
+       if (!(page = pool_alloc_page (pool, GFP_ATOMIC))) {
                if (mem_flags & __GFP_WAIT) {
                        DECLARE_WAITQUEUE (wait, current);
 
index c6b7d9c4b65115054f3f9cd3591c7dbf2c75142d..74b96795d2f58606ae5d048618405c6e73b53db9 100644 (file)
@@ -290,9 +290,8 @@ static CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL);
 
 static int block_size_init(void)
 {
-       sysfs_create_file(&memory_sysdev_class.kset.kobj,
-               &class_attr_block_size_bytes.attr);
-       return 0;
+       return sysfs_create_file(&memory_sysdev_class.kset.kobj,
+                               &class_attr_block_size_bytes.attr);
 }
 
 /*
@@ -323,12 +322,14 @@ static CLASS_ATTR(probe, 0700, NULL, memory_probe_store);
 
 static int memory_probe_init(void)
 {
-       sysfs_create_file(&memory_sysdev_class.kset.kobj,
-               &class_attr_probe.attr);
-       return 0;
+       return sysfs_create_file(&memory_sysdev_class.kset.kobj,
+                               &class_attr_probe.attr);
 }
 #else
-#define memory_probe_init(...) do {} while (0)
+static inline int memory_probe_init(void)
+{
+       return 0;
+}
 #endif
 
 /*
@@ -431,9 +432,12 @@ int __init memory_dev_init(void)
 {
        unsigned int i;
        int ret;
+       int err;
 
        memory_sysdev_class.kset.uevent_ops = &memory_uevent_ops;
        ret = sysdev_class_register(&memory_sysdev_class);
+       if (ret)
+               goto out;
 
        /*
         * Create entries for memory sections that were found
@@ -442,11 +446,19 @@ int __init memory_dev_init(void)
        for (i = 0; i < NR_MEM_SECTIONS; i++) {
                if (!valid_section_nr(i))
                        continue;
-               add_memory_block(0, __nr_to_section(i), MEM_ONLINE, 0);
+               err = add_memory_block(0, __nr_to_section(i), MEM_ONLINE, 0);
+               if (!ret)
+                       ret = err;
        }
 
-       memory_probe_init();
-       block_size_init();
-
+       err = memory_probe_init();
+       if (!ret)
+               ret = err;
+       err = block_size_init();
+       if (!ret)
+               ret = err;
+out:
+       if (ret)
+               printk(KERN_ERR "%s() failed: %d\n", __FUNCTION__, ret);
        return ret;
 }
index 3d12b85b09623a9498627fa2889fbccf2156f27d..067a9e8bc377f2cdfe670112bb493714f0faaeaf 100644 (file)
@@ -108,7 +108,6 @@ static int __cpuinit topology_add_dev(unsigned int cpu)
        return rc;
 }
 
-#ifdef CONFIG_HOTPLUG_CPU
 static void __cpuinit topology_remove_dev(unsigned int cpu)
 {
        struct sys_device *sys_dev = get_cpu_sysdev(cpu);
@@ -136,7 +135,6 @@ static int __cpuinit topology_cpu_callback(struct notifier_block *nfb,
        }
        return rc ? NOTIFY_BAD : NOTIFY_OK;
 }
-#endif
 
 static int __cpuinit topology_sysfs_init(void)
 {
index 742d0740310140a59e7a03ca4ab6883ee82be8e2..8d81a3a64c078bb4d2523ac51c2ef6ad6c10e7dc 100644 (file)
@@ -324,13 +324,13 @@ static boolean DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
       Command->Next = Controller->FreeCommands;
       Controller->FreeCommands = Command;
       Controller->Commands[CommandIdentifier-1] = Command;
-      ScatterGatherCPU = pci_pool_alloc(ScatterGatherPool, SLAB_ATOMIC,
+      ScatterGatherCPU = pci_pool_alloc(ScatterGatherPool, GFP_ATOMIC,
                                                        &ScatterGatherDMA);
       if (ScatterGatherCPU == NULL)
          return DAC960_Failure(Controller, "AUXILIARY STRUCTURE CREATION");
 
       if (RequestSensePool != NULL) {
-         RequestSenseCPU = pci_pool_alloc(RequestSensePool, SLAB_ATOMIC,
+         RequestSenseCPU = pci_pool_alloc(RequestSensePool, GFP_ATOMIC,
                                                &RequestSenseDMA);
          if (RequestSenseCPU == NULL) {
                 pci_pool_free(ScatterGatherPool, ScatterGatherCPU,
index 17dc22282e148d89f8a526de5a52deb32cd73828..ce9cfcb6071c5a7aa135ae92cdb56a2a0ab2da0e 100644 (file)
@@ -168,7 +168,8 @@ config BLK_CPQ_CISS_DA
 
 config CISS_SCSI_TAPE
        bool "SCSI tape drive support for Smart Array 5xxx"
-       depends on BLK_CPQ_CISS_DA && SCSI && PROC_FS
+       depends on BLK_CPQ_CISS_DA && PROC_FS
+       depends on SCSI=y || SCSI=BLK_CPQ_CISS_DA
        help
          When enabled (Y), this option allows SCSI tape drives and SCSI medium
          changers (tape robots) to be accessed via a Compaq 5xxx array 
@@ -305,6 +306,7 @@ config BLK_DEV_LOOP
 config BLK_DEV_CRYPTOLOOP
        tristate "Cryptoloop Support"
        select CRYPTO
+       select CRYPTO_CBC
        depends on BLK_DEV_LOOP
        ---help---
          Say Y here if you want to be able to use the ciphers that are 
@@ -429,14 +431,18 @@ config CDROM_PKTCDVD
        tristate "Packet writing on CD/DVD media"
        depends on !UML
        help
-         If you have a CDROM drive that supports packet writing, say Y to
-         include preliminary support. It should work with any MMC/Mt Fuji
-         compliant ATAPI or SCSI drive, which is just about any newer CD
-         writer.
+         If you have a CDROM/DVD drive that supports packet writing, say
+         Y to include support. It should work with any MMC/Mt Fuji
+         compliant ATAPI or SCSI drive, which is just about any newer
+         DVD/CD writer.
 
-         Currently only writing to CD-RW, DVD-RW and DVD+RW discs is possible.
+         Currently only writing to CD-RW, DVD-RW, DVD+RW and DVDRAM discs
+         is possible.
          DVD-RW disks must be in restricted overwrite mode.
 
+         See the file <file:Documentation/cdrom/packet-writing.txt>
+         for further information on the use of this driver.
+
          To compile this driver as a module, choose M here: the
          module will be called pktcdvd.
 
index 8e41c87b026e79282ac48c9c37d42a565ff916d1..e04be94d195c5ecca5a8faf9cb0ca6fc24d9b09c 100644 (file)
@@ -363,7 +363,7 @@ static ssize_t slm_read( struct file *file, char *buf, size_t count,
                                                 loff_t *ppos )
 
 {
-       struct inode *node = file->f_dentry->d_inode;
+       struct inode *node = file->f_path.dentry->d_inode;
        unsigned long page;
        int length;
        int end;
@@ -618,7 +618,7 @@ static ssize_t slm_write( struct file *file, const char *buf, size_t count,
                                                  loff_t *ppos )
 
 {
-       struct inode *node = file->f_dentry->d_inode;
+       struct inode *node = file->f_path.dentry->d_inode;
        int             device = iminor(node);
        int             n, filled, w, h;
 
index aa25f8b09fe3092fc93093a29c8757c6229f6563..478489c568a4c9f9de45cc05aba97f294d80bff8 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/netdevice.h>
 #include "aoe.h"
 
-static kmem_cache_t *buf_pool_cache;
+static struct kmem_cache *buf_pool_cache;
 
 static ssize_t aoedisk_show_state(struct gendisk * disk, char *page)
 {
index 4105c3bf34764da399d29e638294ead0e07a3973..ee159edb6b88b92bc373d830eb285aa799558111 100644 (file)
 #include <linux/completion.h>
 
 #define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin))
-#define DRIVER_NAME "HP CISS Driver (v 3.6.10)"
-#define DRIVER_VERSION CCISS_DRIVER_VERSION(3,6,10)
+#define DRIVER_NAME "HP CISS Driver (v 3.6.14)"
+#define DRIVER_VERSION CCISS_DRIVER_VERSION(3,6,14)
 
 /* Embedded module documentation macros - see modules.h */
 MODULE_AUTHOR("Hewlett-Packard Company");
-MODULE_DESCRIPTION("Driver for HP Controller SA5xxx SA6xxx version 3.6.10");
+MODULE_DESCRIPTION("Driver for HP Controller SA5xxx SA6xxx version 3.6.14");
 MODULE_SUPPORTED_DEVICE("HP SA5i SA5i+ SA532 SA5300 SA5312 SA641 SA642 SA6400"
                        " SA6i P600 P800 P400 P400i E200 E200i E500");
+MODULE_VERSION("3.6.14");
 MODULE_LICENSE("GPL");
 
 #include "cciss_cmd.h"
@@ -81,7 +82,9 @@ static const struct pci_device_id cciss_pci_device_id[] = {
        {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSD,     0x103C, 0x3213},
        {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSD,     0x103C, 0x3214},
        {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSD,     0x103C, 0x3215},
-       {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSC,     0x103C, 0x3233},
+       {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSC,     0x103C, 0x3237},
+       {PCI_VENDOR_ID_HP,     PCI_ANY_ID,      PCI_ANY_ID, PCI_ANY_ID,
+               PCI_CLASS_STORAGE_RAID << 8, 0xffff << 8, 0},
        {0,}
 };
 
@@ -90,27 +93,29 @@ MODULE_DEVICE_TABLE(pci, cciss_pci_device_id);
 /*  board_id = Subsystem Device ID & Vendor ID
  *  product = Marketing Name for the board
  *  access = Address of the struct of function pointers
+ *  nr_cmds = Number of commands supported by controller
  */
 static struct board_type products[] = {
-       {0x40700E11, "Smart Array 5300", &SA5_access},
-       {0x40800E11, "Smart Array 5i", &SA5B_access},
-       {0x40820E11, "Smart Array 532", &SA5B_access},
-       {0x40830E11, "Smart Array 5312", &SA5B_access},
-       {0x409A0E11, "Smart Array 641", &SA5_access},
-       {0x409B0E11, "Smart Array 642", &SA5_access},
-       {0x409C0E11, "Smart Array 6400", &SA5_access},
-       {0x409D0E11, "Smart Array 6400 EM", &SA5_access},
-       {0x40910E11, "Smart Array 6i", &SA5_access},
-       {0x3225103C, "Smart Array P600", &SA5_access},
-       {0x3223103C, "Smart Array P800", &SA5_access},
-       {0x3234103C, "Smart Array P400", &SA5_access},
-       {0x3235103C, "Smart Array P400i", &SA5_access},
-       {0x3211103C, "Smart Array E200i", &SA5_access},
-       {0x3212103C, "Smart Array E200", &SA5_access},
-       {0x3213103C, "Smart Array E200i", &SA5_access},
-       {0x3214103C, "Smart Array E200i", &SA5_access},
-       {0x3215103C, "Smart Array E200i", &SA5_access},
-       {0x3233103C, "Smart Array E500", &SA5_access},
+       {0x40700E11, "Smart Array 5300", &SA5_access, 512},
+       {0x40800E11, "Smart Array 5i", &SA5B_access, 512},
+       {0x40820E11, "Smart Array 532", &SA5B_access, 512},
+       {0x40830E11, "Smart Array 5312", &SA5B_access, 512},
+       {0x409A0E11, "Smart Array 641", &SA5_access, 512},
+       {0x409B0E11, "Smart Array 642", &SA5_access, 512},
+       {0x409C0E11, "Smart Array 6400", &SA5_access, 512},
+       {0x409D0E11, "Smart Array 6400 EM", &SA5_access, 512},
+       {0x40910E11, "Smart Array 6i", &SA5_access, 512},
+       {0x3225103C, "Smart Array P600", &SA5_access, 512},
+       {0x3223103C, "Smart Array P800", &SA5_access, 512},
+       {0x3234103C, "Smart Array P400", &SA5_access, 512},
+       {0x3235103C, "Smart Array P400i", &SA5_access, 512},
+       {0x3211103C, "Smart Array E200i", &SA5_access, 120},
+       {0x3212103C, "Smart Array E200", &SA5_access, 120},
+       {0x3213103C, "Smart Array E200i", &SA5_access, 120},
+       {0x3214103C, "Smart Array E200i", &SA5_access, 120},
+       {0x3215103C, "Smart Array E200i", &SA5_access, 120},
+       {0x3237103C, "Smart Array E500", &SA5_access, 512},
+       {0xFFFF103C, "Unknown Smart Array", &SA5_access, 120},
 };
 
 /* How long to wait (in milliseconds) for board to go into simple mode */
@@ -121,7 +126,6 @@ static struct board_type products[] = {
 #define MAX_CMD_RETRIES 3
 
 #define READ_AHEAD      1024
-#define NR_CMDS                 384    /* #commands that can be outstanding */
 #define MAX_CTLR       32
 
 /* Originally cciss driver only supports 8 major numbers */
@@ -137,7 +141,6 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
                       unsigned int cmd, unsigned long arg);
 static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo);
 
-static int revalidate_allvol(ctlr_info_t *host);
 static int cciss_revalidate(struct gendisk *disk);
 static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk);
 static int deregister_disk(struct gendisk *disk, drive_info_struct *drv,
@@ -265,6 +268,7 @@ static int cciss_proc_get_info(char *buffer, char **start, off_t offset,
                       "Firmware Version: %c%c%c%c\n"
                       "IRQ: %d\n"
                       "Logical drives: %d\n"
+                      "Max sectors: %d\n"
                       "Current Q depth: %d\n"
                       "Current # commands on controller: %d\n"
                       "Max Q depth since init: %d\n"
@@ -275,7 +279,9 @@ static int cciss_proc_get_info(char *buffer, char **start, off_t offset,
                       (unsigned long)h->board_id,
                       h->firm_ver[0], h->firm_ver[1], h->firm_ver[2],
                       h->firm_ver[3], (unsigned int)h->intr[SIMPLE_MODE_INT],
-                      h->num_luns, h->Qdepth, h->commands_outstanding,
+                      h->num_luns,
+                      h->cciss_max_sectors,
+                      h->Qdepth, h->commands_outstanding,
                       h->maxQsinceinit, h->max_outstanding, h->maxSG);
 
        pos += size;
@@ -400,8 +406,8 @@ static CommandList_struct *cmd_alloc(ctlr_info_t *h, int get_from_pool)
        } else {                /* get it out of the controllers pool */
 
                do {
-                       i = find_first_zero_bit(h->cmd_pool_bits, NR_CMDS);
-                       if (i == NR_CMDS)
+                       i = find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds);
+                       if (i == h->nr_cmds)
                                return NULL;
                } while (test_and_set_bit
                         (i & (BITS_PER_LONG - 1),
@@ -487,7 +493,7 @@ static int cciss_open(struct inode *inode, struct file *filep)
         * but I'm already using way to many device nodes to claim another one
         * for "raw controller".
         */
-       if (drv->nr_blocks == 0) {
+       if (drv->heads == 0) {
                if (iminor(inode) != 0) {       /* not node 0? */
                        /* if not node 0 make sure it is a partition = 0 */
                        if (iminor(inode) & 0x0f) {
@@ -529,7 +535,7 @@ static int do_ioctl(struct file *f, unsigned cmd, unsigned long arg)
 {
        int ret;
        lock_kernel();
-       ret = cciss_ioctl(f->f_dentry->d_inode, f, cmd, arg);
+       ret = cciss_ioctl(f->f_path.dentry->d_inode, f, cmd, arg);
        unlock_kernel();
        return ret;
 }
@@ -850,9 +856,7 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
                }
 
        case CCISS_REVALIDVOLS:
-               if (bdev != bdev->bd_contains || drv != host->drv)
-                       return -ENXIO;
-               return revalidate_allvol(host);
+               return rebuild_lun_table(host, NULL);
 
        case CCISS_GETLUNINFO:{
                        LogvolInfo_struct luninfo;
@@ -1152,75 +1156,6 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
        }
 }
 
-/*
- * revalidate_allvol is for online array config utilities.  After a
- * utility reconfigures the drives in the array, it can use this function
- * (through an ioctl) to make the driver zap any previous disk structs for
- * that controller and get new ones.
- *
- * Right now I'm using the getgeometry() function to do this, but this
- * function should probably be finer grained and allow you to revalidate one
- * particular logical volume (instead of all of them on a particular
- * controller).
- */
-static int revalidate_allvol(ctlr_info_t *host)
-{
-       int ctlr = host->ctlr, i;
-       unsigned long flags;
-
-       spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
-       if (host->usage_count > 1) {
-               spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
-               printk(KERN_WARNING "cciss: Device busy for volume"
-                      " revalidation (usage=%d)\n", host->usage_count);
-               return -EBUSY;
-       }
-       host->usage_count++;
-       spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
-
-       for (i = 0; i < NWD; i++) {
-               struct gendisk *disk = host->gendisk[i];
-               if (disk) {
-                       request_queue_t *q = disk->queue;
-
-                       if (disk->flags & GENHD_FL_UP)
-                               del_gendisk(disk);
-                       if (q)
-                               blk_cleanup_queue(q);
-               }
-       }
-
-       /*
-        * Set the partition and block size structures for all volumes
-        * on this controller to zero.  We will reread all of this data
-        */
-       memset(host->drv, 0, sizeof(drive_info_struct)
-              * CISS_MAX_LUN);
-       /*
-        * Tell the array controller not to give us any interrupts while
-        * we check the new geometry.  Then turn interrupts back on when
-        * we're done.
-        */
-       host->access.set_intr_mask(host, CCISS_INTR_OFF);
-       cciss_getgeometry(ctlr);
-       host->access.set_intr_mask(host, CCISS_INTR_ON);
-
-       /* Loop through each real device */
-       for (i = 0; i < NWD; i++) {
-               struct gendisk *disk = host->gendisk[i];
-               drive_info_struct *drv = &(host->drv[i]);
-               /* we must register the controller even if no disks exist */
-               /* this is for the online array utilities */
-               if (!drv->heads && i)
-                       continue;
-               blk_queue_hardsect_size(drv->queue, drv->block_size);
-               set_capacity(disk, drv->nr_blocks);
-               add_disk(disk);
-       }
-       host->usage_count--;
-       return 0;
-}
-
 static inline void complete_buffers(struct bio *bio, int status)
 {
        while (bio) {
@@ -1243,7 +1178,7 @@ static void cciss_check_queues(ctlr_info_t *h)
         * in case the interrupt we serviced was from an ioctl and did not
         * free any new commands.
         */
-       if ((find_first_zero_bit(h->cmd_pool_bits, NR_CMDS)) == NR_CMDS)
+       if ((find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds)) == h->nr_cmds)
                return;
 
        /* We have room on the queue for more commands.  Now we need to queue
@@ -1262,7 +1197,7 @@ static void cciss_check_queues(ctlr_info_t *h)
                /* check to see if we have maxed out the number of commands
                 * that can be placed on the queue.
                 */
-               if ((find_first_zero_bit(h->cmd_pool_bits, NR_CMDS)) == NR_CMDS) {
+               if ((find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds)) == h->nr_cmds) {
                        if (curr_queue == start_queue) {
                                h->next_to_run =
                                    (start_queue + 1) % (h->highest_lun + 1);
@@ -1380,6 +1315,11 @@ static void cciss_update_drive_info(int ctlr, int drv_index)
        /* if it's the controller it's already added */
        if (drv_index) {
                disk->queue = blk_init_queue(do_cciss_request, &h->lock);
+               sprintf(disk->disk_name, "cciss/c%dd%d", ctlr, drv_index);
+               disk->major = h->major;
+               disk->first_minor = drv_index << NWD_SHIFT;
+               disk->fops = &cciss_fops;
+               disk->private_data = &h->drv[drv_index];
 
                /* Set up queue information */
                disk->queue->backing_dev_info.ra_pages = READ_AHEAD;
@@ -1391,7 +1331,7 @@ static void cciss_update_drive_info(int ctlr, int drv_index)
                /* This is a limit in the driver and could be eliminated. */
                blk_queue_max_phys_segments(disk->queue, MAXSGENTRIES);
 
-               blk_queue_max_sectors(disk->queue, 512);
+               blk_queue_max_sectors(disk->queue, h->cciss_max_sectors);
 
                blk_queue_softirq_done(disk->queue, cciss_softirq_done);
 
@@ -1458,11 +1398,6 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk)
 
        /* Set busy_configuring flag for this operation */
        spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags);
-       if (h->num_luns >= CISS_MAX_LUN) {
-               spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
-               return -EINVAL;
-       }
-
        if (h->busy_configuring) {
                spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
                return -EBUSY;
@@ -1495,17 +1430,8 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk)
                                              0, 0, TYPE_CMD);
 
                if (return_code == IO_OK) {
-                       listlength |=
-                           (0xff & (unsigned int)(ld_buff->LUNListLength[0]))
-                           << 24;
-                       listlength |=
-                           (0xff & (unsigned int)(ld_buff->LUNListLength[1]))
-                           << 16;
-                       listlength |=
-                           (0xff & (unsigned int)(ld_buff->LUNListLength[2]))
-                           << 8;
-                       listlength |=
-                           0xff & (unsigned int)(ld_buff->LUNListLength[3]);
+                       listlength =
+                               be32_to_cpu(*(__u32 *) ld_buff->LUNListLength);
                } else {        /* reading number of logical volumes failed */
                        printk(KERN_WARNING "cciss: report logical volume"
                               " command failed\n");
@@ -1556,6 +1482,14 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk)
                                if (drv_index == -1)
                                        goto freeret;
 
+                               /*Check if the gendisk needs to be allocated */
+                               if (!h->gendisk[drv_index]){
+                                       h->gendisk[drv_index] = alloc_disk(1 << NWD_SHIFT);
+                                       if (!h->gendisk[drv_index]){
+                                               printk(KERN_ERR "cciss: could not allocate new disk %d\n", drv_index);
+                                               goto mem_msg;
+                                       }
+                               }
                        }
                        h->drv[drv_index].LunID = lunid;
                        cciss_update_drive_info(ctlr, drv_index);
@@ -1593,6 +1527,7 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk)
 static int deregister_disk(struct gendisk *disk, drive_info_struct *drv,
                           int clear_all)
 {
+       int i;
        ctlr_info_t *h = get_host(disk);
 
        if (!capable(CAP_SYS_RAWIO))
@@ -1616,9 +1551,35 @@ static int deregister_disk(struct gendisk *disk, drive_info_struct *drv,
                                del_gendisk(disk);
                        if (q) {
                                blk_cleanup_queue(q);
+                               /* Set drv->queue to NULL so that we do not try
+                                * to call blk_start_queue on this queue in the
+                                * interrupt handler
+                                */
                                drv->queue = NULL;
                        }
+                       /* If clear_all is set then we are deleting the logical
+                        * drive, not just refreshing its info.  For drives
+                        * other than disk 0 we will call put_disk.  We do not
+                        * do this for disk 0 as we need it to be able to
+                        * configure the controller.
+                       */
+                       if (clear_all){
+                               /* This isn't pretty, but we need to find the
+                                * disk in our array and NULL our the pointer.
+                                * This is so that we will call alloc_disk if
+                                * this index is used again later.
+                               */
+                               for (i=0; i < CISS_MAX_LUN; i++){
+                                       if(h->gendisk[i] == disk){
+                                               h->gendisk[i] = NULL;
+                                               break;
+                                       }
+                               }
+                               put_disk(disk);
+                       }
                }
+       } else {
+               set_capacity(disk, 0);
        }
 
        --h->num_luns;
@@ -2136,7 +2097,7 @@ static int add_sendcmd_reject(__u8 cmd, int ctlr, unsigned long complete)
 
        /* We've sent down an abort or reset, but something else
           has completed */
-       if (srl->ncompletions >= (NR_CMDS + 2)) {
+       if (srl->ncompletions >= (hba[ctlr]->nr_cmds + 2)) {
                /* Uh oh.  No room to save it for later... */
                printk(KERN_WARNING "cciss%d: Sendcmd: Invalid command addr, "
                       "reject list overflow, command lost!\n", ctlr);
@@ -2673,7 +2634,7 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id)
                        a1 = a;
                        if ((a & 0x04)) {
                                a2 = (a >> 3);
-                               if (a2 >= NR_CMDS) {
+                               if (a2 >= h->nr_cmds) {
                                        printk(KERN_WARNING
                                               "cciss: controller cciss%d failed, stopping.\n",
                                               h->ctlr);
@@ -2827,23 +2788,21 @@ static void __devinit cciss_interrupt_mode(ctlr_info_t *c,
                if (err > 0) {
                        printk(KERN_WARNING "cciss: only %d MSI-X vectors "
                               "available\n", err);
+                       goto default_int_mode;
                } else {
                        printk(KERN_WARNING "cciss: MSI-X init failed %d\n",
                               err);
+                       goto default_int_mode;
                }
        }
        if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) {
                if (!pci_enable_msi(pdev)) {
-                       c->intr[SIMPLE_MODE_INT] = pdev->irq;
                        c->msi_vector = 1;
-                       return;
                } else {
                        printk(KERN_WARNING "cciss: MSI init failed\n");
-                       c->intr[SIMPLE_MODE_INT] = pdev->irq;
-                       return;
                }
        }
-      default_int_mode:
+default_int_mode:
 #endif                         /* CONFIG_PCI_MSI */
        /* if we get here we're going to use the default interrupt mode */
        c->intr[SIMPLE_MODE_INT] = pdev->irq;
@@ -2956,16 +2915,10 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
                if (board_id == products[i].board_id) {
                        c->product_name = products[i].product_name;
                        c->access = *(products[i].access);
+                       c->nr_cmds = products[i].nr_cmds;
                        break;
                }
        }
-       if (i == ARRAY_SIZE(products)) {
-               printk(KERN_WARNING "cciss: Sorry, I don't know how"
-                      " to access the Smart Array controller %08lx\n",
-                      (unsigned long)board_id);
-               err = -ENODEV;
-               goto err_out_free_res;
-       }
        if ((readb(&c->cfgtable->Signature[0]) != 'C') ||
            (readb(&c->cfgtable->Signature[1]) != 'I') ||
            (readb(&c->cfgtable->Signature[2]) != 'S') ||
@@ -2974,6 +2927,27 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
                err = -ENODEV;
                goto err_out_free_res;
        }
+       /* We didn't find the controller in our list. We know the
+        * signature is valid. If it's an HP device let's try to
+        * bind to the device and fire it up. Otherwise we bail.
+        */
+       if (i == ARRAY_SIZE(products)) {
+               if (subsystem_vendor_id == PCI_VENDOR_ID_HP) {
+                       c->product_name = products[i-1].product_name;
+                       c->access = *(products[i-1].access);
+                       c->nr_cmds = products[i-1].nr_cmds;
+                       printk(KERN_WARNING "cciss: This is an unknown "
+                               "Smart Array controller.\n"
+                               "cciss: Please update to the latest driver "
+                               "available from www.hp.com.\n");
+               } else {
+                       printk(KERN_WARNING "cciss: Sorry, I don't know how"
+                               " to access the Smart Array controller %08lx\n"
+                                       , (unsigned long)board_id);
+                       err = -ENODEV;
+                       goto err_out_free_res;
+               }
+       }
 #ifdef CONFIG_X86
        {
                /* Need to enable prefetch in the SCSI core for 6400 in x86 */
@@ -2984,6 +2958,17 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
        }
 #endif
 
+       /* Disabling DMA prefetch for the P600
+        * An ASIC bug may result in a prefetch beyond
+        * physical memory.
+        */
+       if(board_id == 0x3225103C) {
+               __u32 dma_prefetch;
+               dma_prefetch = readl(c->vaddr + I2O_DMA1_CFG);
+               dma_prefetch |= 0x8000;
+               writel(dma_prefetch, c->vaddr + I2O_DMA1_CFG);
+       }
+
 #ifdef CCISS_DEBUG
        printk("Trying to put board into Simple mode\n");
 #endif                         /* CCISS_DEBUG */
@@ -3158,13 +3143,7 @@ geo_inq:
 /* Returns -1 if no free entries are left.  */
 static int alloc_cciss_hba(void)
 {
-       struct gendisk *disk[NWD];
-       int i, n;
-       for (n = 0; n < NWD; n++) {
-               disk[n] = alloc_disk(1 << NWD_SHIFT);
-               if (!disk[n])
-                       goto out;
-       }
+       int i;
 
        for (i = 0; i < MAX_CTLR; i++) {
                if (!hba[i]) {
@@ -3172,20 +3151,18 @@ static int alloc_cciss_hba(void)
                        p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL);
                        if (!p)
                                goto Enomem;
-                       for (n = 0; n < NWD; n++)
-                               p->gendisk[n] = disk[n];
+                       p->gendisk[0] = alloc_disk(1 << NWD_SHIFT);
+                       if (!p->gendisk[0])
+                               goto Enomem;
                        hba[i] = p;
                        return i;
                }
        }
        printk(KERN_WARNING "cciss: This driver supports a maximum"
               " of %d controllers.\n", MAX_CTLR);
-       goto out;
-      Enomem:
+       return -1;
+Enomem:
        printk(KERN_ERR "cciss: out of memory.\n");
-      out:
-       while (n--)
-               put_disk(disk[n]);
        return -1;
 }
 
@@ -3195,7 +3172,7 @@ static void free_hba(int i)
        int n;
 
        hba[i] = NULL;
-       for (n = 0; n < NWD; n++)
+       for (n = 0; n < CISS_MAX_LUN; n++)
                put_disk(p->gendisk[n]);
        kfree(p);
 }
@@ -3208,9 +3185,8 @@ static void free_hba(int i)
 static int __devinit cciss_init_one(struct pci_dev *pdev,
                                    const struct pci_device_id *ent)
 {
-       request_queue_t *q;
        int i;
-       int j;
+       int j = 0;
        int rc;
        int dac;
 
@@ -3269,15 +3245,15 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
               hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not");
 
        hba[i]->cmd_pool_bits =
-           kmalloc(((NR_CMDS + BITS_PER_LONG -
+           kmalloc(((hba[i]->nr_cmds + BITS_PER_LONG -
                      1) / BITS_PER_LONG) * sizeof(unsigned long), GFP_KERNEL);
        hba[i]->cmd_pool = (CommandList_struct *)
            pci_alloc_consistent(hba[i]->pdev,
-                   NR_CMDS * sizeof(CommandList_struct),
+                   hba[i]->nr_cmds * sizeof(CommandList_struct),
                    &(hba[i]->cmd_pool_dhandle));
        hba[i]->errinfo_pool = (ErrorInfo_struct *)
            pci_alloc_consistent(hba[i]->pdev,
-                   NR_CMDS * sizeof(ErrorInfo_struct),
+                   hba[i]->nr_cmds * sizeof(ErrorInfo_struct),
                    &(hba[i]->errinfo_pool_dhandle));
        if ((hba[i]->cmd_pool_bits == NULL)
            || (hba[i]->cmd_pool == NULL)
@@ -3288,7 +3264,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
 #ifdef CONFIG_CISS_SCSI_TAPE
        hba[i]->scsi_rejects.complete =
            kmalloc(sizeof(hba[i]->scsi_rejects.complete[0]) *
-                   (NR_CMDS + 5), GFP_KERNEL);
+                   (hba[i]->nr_cmds + 5), GFP_KERNEL);
        if (hba[i]->scsi_rejects.complete == NULL) {
                printk(KERN_ERR "cciss: out of memory");
                goto clean4;
@@ -3302,7 +3278,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
        /* command and error info recs zeroed out before
           they are used */
        memset(hba[i]->cmd_pool_bits, 0,
-              ((NR_CMDS + BITS_PER_LONG -
+              ((hba[i]->nr_cmds + BITS_PER_LONG -
                 1) / BITS_PER_LONG) * sizeof(unsigned long));
 
 #ifdef CCISS_DEBUG
@@ -3317,18 +3293,34 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
        hba[i]->access.set_intr_mask(hba[i], CCISS_INTR_ON);
 
        cciss_procinit(i);
+
+       hba[i]->cciss_max_sectors = 2048;
+
        hba[i]->busy_initializing = 0;
 
-       for (j = 0; j < NWD; j++) {     /* mfm */
+       do {
                drive_info_struct *drv = &(hba[i]->drv[j]);
                struct gendisk *disk = hba[i]->gendisk[j];
+               request_queue_t *q;
+
+               /* Check if the disk was allocated already */
+               if (!disk){
+                       hba[i]->gendisk[j] = alloc_disk(1 << NWD_SHIFT);
+                       disk = hba[i]->gendisk[j];
+               }
+
+               /* Check that the disk was able to be allocated */
+               if (!disk) {
+                       printk(KERN_ERR "cciss: unable to allocate memory for disk %d\n", j);
+                       goto clean4;
+               }
 
                q = blk_init_queue(do_cciss_request, &hba[i]->lock);
                if (!q) {
                        printk(KERN_ERR
                               "cciss:  unable to allocate queue for disk %d\n",
                               j);
-                       break;
+                       goto clean4;
                }
                drv->queue = q;
 
@@ -3341,7 +3333,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
                /* This is a limit in the driver and could be eliminated. */
                blk_queue_max_phys_segments(q, MAXSGENTRIES);
 
-               blk_queue_max_sectors(q, 512);
+               blk_queue_max_sectors(q, hba[i]->cciss_max_sectors);
 
                blk_queue_softirq_done(q, cciss_softirq_done);
 
@@ -3360,7 +3352,8 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
                blk_queue_hardsect_size(q, drv->block_size);
                set_capacity(disk, drv->nr_blocks);
                add_disk(disk);
-       }
+               j++;
+       } while (j <= hba[i]->highest_lun);
 
        return 1;
 
@@ -3371,11 +3364,11 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
        kfree(hba[i]->cmd_pool_bits);
        if (hba[i]->cmd_pool)
                pci_free_consistent(hba[i]->pdev,
-                                   NR_CMDS * sizeof(CommandList_struct),
+                                   hba[i]->nr_cmds * sizeof(CommandList_struct),
                                    hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle);
        if (hba[i]->errinfo_pool)
                pci_free_consistent(hba[i]->pdev,
-                                   NR_CMDS * sizeof(ErrorInfo_struct),
+                                   hba[i]->nr_cmds * sizeof(ErrorInfo_struct),
                                    hba[i]->errinfo_pool,
                                    hba[i]->errinfo_pool_dhandle);
        free_irq(hba[i]->intr[SIMPLE_MODE_INT], hba[i]);
@@ -3383,6 +3376,15 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
        unregister_blkdev(hba[i]->major, hba[i]->devname);
       clean1:
        hba[i]->busy_initializing = 0;
+       /* cleanup any queues that may have been initialized */
+       for (j=0; j <= hba[i]->highest_lun; j++){
+               drive_info_struct *drv = &(hba[i]->drv[j]);
+               if (drv->queue)
+                       blk_cleanup_queue(drv->queue);
+       }
+       pci_release_regions(pdev);
+       pci_disable_device(pdev);
+       pci_set_drvdata(pdev, NULL);
        free_hba(i);
        return -1;
 }
@@ -3430,7 +3432,7 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev)
        remove_proc_entry(hba[i]->devname, proc_cciss);
 
        /* remove it from the disk list */
-       for (j = 0; j < NWD; j++) {
+       for (j = 0; j < CISS_MAX_LUN; j++) {
                struct gendisk *disk = hba[i]->gendisk[j];
                if (disk) {
                        request_queue_t *q = disk->queue;
@@ -3442,9 +3444,9 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev)
                }
        }
 
-       pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(CommandList_struct),
+       pci_free_consistent(hba[i]->pdev, hba[i]->nr_cmds * sizeof(CommandList_struct),
                            hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle);
-       pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(ErrorInfo_struct),
+       pci_free_consistent(hba[i]->pdev, hba[i]->nr_cmds * sizeof(ErrorInfo_struct),
                            hba[i]->errinfo_pool, hba[i]->errinfo_pool_dhandle);
        kfree(hba[i]->cmd_pool_bits);
 #ifdef CONFIG_CISS_SCSI_TAPE
index 562235c1445a123b9a5f36293b6f28bf887c2ff0..b70988dd33eccec8f068f87b0c738e6e3875293f 100644 (file)
@@ -6,7 +6,6 @@
 #include "cciss_cmd.h"
 
 
-#define NWD            16
 #define NWD_SHIFT      4
 #define MAX_PART       (1 << NWD_SHIFT)
 
@@ -60,6 +59,7 @@ struct ctlr_info
        __u32   board_id;
        void __iomem *vaddr;
        unsigned long paddr;
+       int     nr_cmds; /* Number of commands allowed on this controller */
        CfgTable_struct __iomem *cfgtable;
        int     interrupts_enabled;
        int     major;
@@ -76,6 +76,7 @@ struct ctlr_info
        unsigned int intr[4];
        unsigned int msix_vector;
        unsigned int msi_vector;
+       int     cciss_max_sectors;
        BYTE    cciss_read;
        BYTE    cciss_write;
        BYTE    cciss_read_capacity;
@@ -110,7 +111,7 @@ struct ctlr_info
        int                     next_to_run;
 
        // Disk structures we need to pass back
-       struct gendisk   *gendisk[NWD];
+       struct gendisk   *gendisk[CISS_MAX_LUN];
 #ifdef CONFIG_CISS_SCSI_TAPE
        void *scsi_ctlr; /* ptr to structure containing scsi related stuff */
        /* list of block side commands the scsi error handling sucked up */
@@ -282,6 +283,7 @@ struct board_type {
        __u32   board_id;
        char    *product_name;
        struct access_method *access;
+       int nr_cmds; /* Max cmds this kind of ctlr can handle. */
 };
 
 #define CCISS_LOCK(i)  (&hba[i]->lock)
index 4af7c4c0c7afb4610863d36142ed1e9ad19d994f..43bf5593b59bf6ed1da79abbbba46a0fea499d44 100644 (file)
@@ -55,6 +55,7 @@
 #define I2O_INT_MASK            0x34
 #define I2O_IBPOST_Q            0x40
 #define I2O_OBPOST_Q            0x44
+#define I2O_DMA1_CFG           0x214
 
 //Configuration Table
 #define CFGTBL_ChangeReq        0x00000001l
@@ -88,7 +89,7 @@ typedef union _u64bit
 //###########################################################################
 //STRUCTURES
 //###########################################################################
-#define CISS_MAX_LUN   16      
+#define CISS_MAX_LUN   1024
 #define CISS_MAX_PHYS_LUN      1024
 // SCSI-3 Cmmands 
 
index beab6d2643cb0fb27419bed3aa16b87034d2de0f..6b5b642074079d544614af1e83485ad1f91398fc 100644 (file)
@@ -1000,7 +1000,7 @@ loop_get_status(struct loop_device *lo, struct loop_info64 *info)
 
        if (lo->lo_state != Lo_bound)
                return -ENXIO;
-       error = vfs_getattr(file->f_vfsmnt, file->f_dentry, &stat);
+       error = vfs_getattr(file->f_path.mnt, file->f_path.dentry, &stat);
        if (error)
                return error;
        memset(info, 0, sizeof(*info));
@@ -1287,7 +1287,7 @@ loop_get_status_compat(struct loop_device *lo,
 
 static long lo_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
        int err;
 
index 9d1035e8d9d8c713148aa589abbf2c738022c197..090796bef78f16374f8c94f2bf70e23e602deabd 100644 (file)
@@ -355,14 +355,30 @@ harderror:
        return NULL;
 }
 
+static ssize_t pid_show(struct gendisk *disk, char *page)
+{
+       return sprintf(page, "%ld\n",
+               (long) ((struct nbd_device *)disk->private_data)->pid);
+}
+
+static struct disk_attribute pid_attr = {
+       .attr = { .name = "pid", .mode = S_IRUGO },
+       .show = pid_show,
+};
+
 static void nbd_do_it(struct nbd_device *lo)
 {
        struct request *req;
 
        BUG_ON(lo->magic != LO_MAGIC);
 
+       lo->pid = current->pid;
+       sysfs_create_file(&lo->disk->kobj, &pid_attr.attr);
+
        while ((req = nbd_read_stat(lo)) != NULL)
                nbd_end_request(req);
+
+       sysfs_remove_file(&lo->disk->kobj, &pid_attr.attr);
        return;
 }
 
@@ -521,7 +537,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
                error = -EINVAL;
                file = fget(arg);
                if (file) {
-                       inode = file->f_dentry->d_inode;
+                       inode = file->f_path.dentry->d_inode;
                        if (S_ISSOCK(inode->i_mode)) {
                                lo->file = file;
                                lo->sock = SOCKET_I(inode);
index c4d696d43dc140d29c9d2b0f50970d1cbfbde9dd..2695465568ad9dde48b7563f0bfdc97404966a13 100644 (file)
@@ -149,12 +149,12 @@ static struct pi_protocol aten = {
 
 static int __init aten_init(void)
 {
-       return pi_register(&aten)-1;
+       return paride_register(&aten);
 }
 
 static void __exit aten_exit(void)
 {
-       pi_unregister( &aten );
+       paride_unregister( &aten );
 }
 
 MODULE_LICENSE("GPL");
index d462ff6b139d8b1f37a416b5ef917117772a6e5e..4f27e7392e38adc6663188805afed0e4e488b515 100644 (file)
@@ -464,12 +464,12 @@ static struct pi_protocol bpck = {
 
 static int __init bpck_init(void)
 {
-       return pi_register(&bpck)-1;
+       return paride_register(&bpck);
 }
 
 static void __exit bpck_exit(void)
 {
-       pi_unregister(&bpck);
+       paride_unregister(&bpck);
 }
 
 MODULE_LICENSE("GPL");
index 41a237c5957db19226bb35b31ec896ad9f8d0724..ad124525ac23f2d8edd34d80708b9518c177f306 100644 (file)
@@ -31,10 +31,7 @@ static int verbose; /* set this to 1 to see debugging messages and whatnot */
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <asm/io.h>
-
-#if defined(CONFIG_PARPORT_MODULE)||defined(CONFIG_PARPORT)
 #include <linux/parport.h>
-#endif
 
 #include "ppc6lnx.c"
 #include "paride.h"
@@ -139,11 +136,6 @@ static int bpck6_test_port ( PIA *pi )   /* check for 8-bit port */
        PPCSTRUCT(pi)->ppc_id=pi->unit;
        PPCSTRUCT(pi)->lpt_addr=pi->port;
 
-#ifdef CONFIG_PARPORT_PC_MODULE
-#define CONFIG_PARPORT_PC
-#endif
-
-#ifdef CONFIG_PARPORT_PC
        /* look at the parport device to see if what modes we can use */
        if(((struct pardevice *)(pi->pardev))->port->modes & 
                (PARPORT_MODE_EPP)
@@ -161,11 +153,6 @@ static int bpck6_test_port ( PIA *pi )   /* check for 8-bit port */
        {
                return 1;
        }
-#else
-       /* there is no way of knowing what kind of port we have
-          default to the highest mode possible */
-       return 5;
-#endif
 }
 
 static int bpck6_probe_unit ( PIA *pi )
@@ -265,12 +252,12 @@ static int __init bpck6_init(void)
        printk(KERN_INFO "bpck6: Copyright 2001 by Micro Solutions, Inc., DeKalb IL. USA\n");
        if(verbose)
                printk(KERN_DEBUG "bpck6: verbose debug enabled.\n");
-       return pi_register(&bpck6) - 1;  
+       return paride_register(&bpck6);
 }
 
 static void __exit bpck6_exit(void)
 {
-       pi_unregister(&bpck6);
+       paride_unregister(&bpck6);
 }
 
 MODULE_LICENSE("GPL");
index 43d61359d8ecc4febea357115e9cbb809e43804e..9bcd354953234d5303adcdf37139ba07bbf8e1a3 100644 (file)
@@ -205,12 +205,12 @@ static struct pi_protocol comm = {
 
 static int __init comm_init(void)
 {
-       return pi_register(&comm)-1;
+       return paride_register(&comm);
 }
 
 static void __exit comm_exit(void)
 {
-       pi_unregister(&comm);
+       paride_unregister(&comm);
 }
 
 MODULE_LICENSE("GPL");
index 04d53bf58e8c20ad47b61019eef55263d0acf76d..accc5c777cbba7efa0aca7ea09ba0cfa08df0b48 100644 (file)
@@ -220,12 +220,12 @@ static struct pi_protocol dstr = {
 
 static int __init dstr_init(void)
 {
-       return pi_register(&dstr)-1;
+       return paride_register(&dstr);
 }
 
 static void __exit dstr_exit(void)
 {
-       pi_unregister(&dstr);
+       paride_unregister(&dstr);
 }
 
 MODULE_LICENSE("GPL");
index 55d1c0a1fb90df6327b34a2e554340ae0770a5af..1bcdff77322effc30fc679596a01762f9d2672a0 100644 (file)
@@ -327,12 +327,12 @@ static int __init epat_init(void)
 #ifdef CONFIG_PARIDE_EPATC8
        epatc8 = 1;
 #endif
-       return pi_register(&epat)-1;
+       return paride_register(&epat);
 }
 
 static void __exit epat_exit(void)
 {
-       pi_unregister(&epat);
+       paride_unregister(&epat);
 }
 
 MODULE_LICENSE("GPL");
index 0f2e0c292d8245c680b41a6d4128c691b06c594b..fb0e782d055e455dd1863d6be83ef90423eb0a4a 100644 (file)
@@ -303,12 +303,12 @@ static struct pi_protocol epia = {
 
 static int __init epia_init(void)
 {
-       return pi_register(&epia)-1;
+       return paride_register(&epia);
 }
 
 static void __exit epia_exit(void)
 {
-       pi_unregister(&epia);
+       paride_unregister(&epia);
 }
 
 MODULE_LICENSE("GPL");
index e0f0691d8bc2e1150417b7b7a9f522030afe3f90..381283753ae4811ae514f716f00e46e236b2bf64 100644 (file)
@@ -138,12 +138,12 @@ static struct pi_protocol fit2 = {
 
 static int __init fit2_init(void)
 {
-       return pi_register(&fit2)-1;
+       return paride_register(&fit2);
 }
 
 static void __exit fit2_exit(void)
 {
-       pi_unregister(&fit2);
+       paride_unregister(&fit2);
 }
 
 MODULE_LICENSE("GPL");
index 15400e7bc66682dec344a2c575b79b13a9be3033..275d269458ebdfc6f87f19f6573992059e18828b 100644 (file)
@@ -198,12 +198,12 @@ static struct pi_protocol fit3 = {
 
 static int __init fit3_init(void)
 {
-       return pi_register(&fit3)-1;
+       return paride_register(&fit3);
 }
 
 static void __exit fit3_exit(void)
 {
-       pi_unregister(&fit3);
+       paride_unregister(&fit3);
 }
 
 MODULE_LICENSE("GPL");
index 5ea2904d2815aed0099bbd97bfada763fa7c6af3..4f2ba244689b40583f03f476252b592493f751e9 100644 (file)
@@ -263,12 +263,12 @@ static struct pi_protocol friq = {
 
 static int __init friq_init(void)
 {
-       return pi_register(&friq)-1;
+       return paride_register(&friq);
 }
 
 static void __exit friq_exit(void)
 {
-       pi_unregister(&friq);
+       paride_unregister(&friq);
 }
 
 MODULE_LICENSE("GPL");
index 56b3824b1538f122990af22a82f5718728b72e00..c3cde364603a593d6270342e0b5dde661c99b948 100644 (file)
@@ -300,12 +300,12 @@ static struct pi_protocol frpw = {
 
 static int __init frpw_init(void)
 {
-       return pi_register(&frpw)-1;
+       return paride_register(&frpw);
 }
 
 static void __exit frpw_exit(void)
 {
-       pi_unregister(&frpw);
+       paride_unregister(&frpw);
 }
 
 MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/jumbo b/drivers/block/paride/jumbo
deleted file mode 100644 (file)
index e793b9c..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/sh
-#
-# This script can be used to build "jumbo" modules that contain the
-# base PARIDE support, one protocol module and one high-level driver.
-#
-echo -n "High level driver [pcd] : "
-read X
-HLD=${X:-pcd}
-#
-echo -n "Protocol module [bpck] : "
-read X
-PROTO=${X:-bpck}
-#
-echo -n "Use MODVERSIONS [y] ? "
-read X
-UMODV=${X:-y}
-#
-echo -n "For SMP kernel [n] ? "
-read X
-USMP=${X:-n}
-#
-echo -n "Support PARPORT [n] ? "
-read X
-UPARP=${X:-n}
-#
-echo
-#
-case $USMP in
-       y* | Y* ) FSMP="-DCONFIG_SMP"
-                 ;;
-       *)        FSMP=""
-                 ;;
-esac
-#
-MODI="-include ../../../include/linux/modversions.h"
-#
-case $UMODV in
-       y* | Y* ) FMODV="-DMODVERSIONS $MODI"
-                 ;;
-       *)        FMODV=""
-                 ;;
-esac
-#
-case $UPARP in
-       y* | Y* ) FPARP="-DCONFIG_PARPORT"
-                 ;;
-       *)        FPARP=""
-                 ;;
-esac
-#
-TARG=$HLD-$PROTO.o
-FPROTO=-DCONFIG_PARIDE_`echo "$PROTO" | tr [a-z] [A-Z]`
-FK="-D__KERNEL__ -I ../../../include"
-FLCH=-D_LINUX_CONFIG_H
-#
-echo cc $FK $FSMP $FLCH $FPARP $FPROTO $FMODV -Wall -O2 -o Jb.o -c paride.c
-cc $FK $FSMP $FLCH $FPARP $FPROTO $FMODV -Wall -O2 -o Jb.o -c paride.c
-#
-echo cc $FK $FSMP $FMODV -Wall -O2 -o Jp.o -c $PROTO.c
-cc $FK $FSMP $FMODV -Wall -O2 -o Jp.o -c $PROTO.c
-#
-echo cc $FK $FSMP $FMODV -DMODULE -DPARIDE_JUMBO -Wall -O2 -o Jd.o -c $HLD.c
-cc $FK $FSMP $FMODV -DMODULE -DPARIDE_JUMBO -Wall -O2 -o Jd.o -c $HLD.c
-#
-echo ld -r -o $TARG Jp.o Jb.o Jd.o
-ld -r -o $TARG Jp.o Jb.o Jd.o
-#
-#
-rm Jp.o Jb.o Jd.o
-#
index d983bcea76fe6d8978d17ae04d16bcd7069a2e4e..35999c415ee339784df83acbd13abb4bb111ec48 100644 (file)
@@ -283,13 +283,21 @@ static struct pi_protocol k971 = {
 
 static int __init kbic_init(void)
 {
-       return (pi_register(&k951)||pi_register(&k971))-1;
+       int rv;
+
+       rv = paride_register(&k951);
+       if (rv < 0)
+               return rv;
+       rv = paride_register(&k971);
+       if (rv < 0)
+               paride_unregister(&k951);
+       return rv;
 }
 
 static void __exit kbic_exit(void)
 {
-       pi_unregister(&k951);
-       pi_unregister(&k971);
+       paride_unregister(&k951);
+       paride_unregister(&k971);
 }
 
 MODULE_LICENSE("GPL");
index 6c7edbfba9a03f1699bbb60a86bd2399e9d34a79..117ab0e8ccf0afc9156f500d795487fbfd1f4894 100644 (file)
@@ -115,12 +115,12 @@ static struct pi_protocol ktti = {
 
 static int __init ktti_init(void)
 {
-       return pi_register(&ktti)-1;
+       return paride_register(&ktti);
 }
 
 static void __exit ktti_exit(void)
 {
-       pi_unregister(&ktti);
+       paride_unregister(&ktti);
 }
 
 MODULE_LICENSE("GPL");
index 9f8e01096809aaf069971adb7ca9a003caa97b1e..0173697a1a4d5d9d474f14553e3d350ec0195b7e 100644 (file)
@@ -140,12 +140,12 @@ static struct pi_protocol on20 = {
 
 static int __init on20_init(void)
 {
-       return pi_register(&on20)-1;
+       return paride_register(&on20);
 }
 
 static void __exit on20_exit(void)
 {
-       pi_unregister(&on20);
+       paride_unregister(&on20);
 }
 
 MODULE_LICENSE("GPL");
index 0f833caa210136376b4cf7ff716545cc40bbf1e8..95ba256921f20c128a4a676c4ad405bfc1cdc1aa 100644 (file)
@@ -306,12 +306,12 @@ static struct pi_protocol on26 = {
 
 static int __init on26_init(void)
 {
-       return pi_register(&on26)-1;
+       return paride_register(&on26);
 }
 
 static void __exit on26_exit(void)
 {
-       pi_unregister(&on26);
+       paride_unregister(&on26);
 }
 
 MODULE_LICENSE("GPL");
index 4b258f7836f32f0b99b2f0607e3986a7bdebcbd1..48c50f11f63b9290f943ed026b947d031716d36e 100644 (file)
 #include <linux/spinlock.h>
 #include <linux/wait.h>
 #include <linux/sched.h>       /* TASK_* */
-
-#ifdef CONFIG_PARPORT_MODULE
-#define CONFIG_PARPORT
-#endif
-
-#ifdef CONFIG_PARPORT
 #include <linux/parport.h>
-#endif
 
 #include "paride.h"
 
@@ -76,8 +69,6 @@ void pi_read_block(PIA * pi, char *buf, int count)
 
 EXPORT_SYMBOL(pi_read_block);
 
-#ifdef CONFIG_PARPORT
-
 static void pi_wake_up(void *p)
 {
        PIA *pi = (PIA *) p;
@@ -100,11 +91,8 @@ static void pi_wake_up(void *p)
                cont();
 }
 
-#endif
-
 int pi_schedule_claimed(PIA * pi, void (*cont) (void))
 {
-#ifdef CONFIG_PARPORT
        unsigned long flags;
 
        spin_lock_irqsave(&pi_spinlock, flags);
@@ -115,7 +103,6 @@ int pi_schedule_claimed(PIA * pi, void (*cont) (void))
        }
        pi->claimed = 1;
        spin_unlock_irqrestore(&pi_spinlock, flags);
-#endif
        return 1;
 }
 EXPORT_SYMBOL(pi_schedule_claimed);
@@ -133,20 +120,16 @@ static void pi_claim(PIA * pi)
        if (pi->claimed)
                return;
        pi->claimed = 1;
-#ifdef CONFIG_PARPORT
        if (pi->pardev)
                wait_event(pi->parq,
                           !parport_claim((struct pardevice *) pi->pardev));
-#endif
 }
 
 static void pi_unclaim(PIA * pi)
 {
        pi->claimed = 0;
-#ifdef CONFIG_PARPORT
        if (pi->pardev)
                parport_release((struct pardevice *) (pi->pardev));
-#endif
 }
 
 void pi_connect(PIA * pi)
@@ -167,21 +150,15 @@ EXPORT_SYMBOL(pi_disconnect);
 
 static void pi_unregister_parport(PIA * pi)
 {
-#ifdef CONFIG_PARPORT
        if (pi->pardev) {
                parport_unregister_device((struct pardevice *) (pi->pardev));
                pi->pardev = NULL;
        }
-#endif
 }
 
 void pi_release(PIA * pi)
 {
        pi_unregister_parport(pi);
-#ifndef CONFIG_PARPORT
-       if (pi->reserved)
-               release_region(pi->port, pi->reserved);
-#endif                         /* !CONFIG_PARPORT */
        if (pi->proto->release_proto)
                pi->proto->release_proto(pi);
        module_put(pi->proto->owner);
@@ -229,7 +206,7 @@ static int pi_test_proto(PIA * pi, char *scratch, int verbose)
        return res;
 }
 
-int pi_register(PIP * pr)
+int paride_register(PIP * pr)
 {
        int k;
 
@@ -237,24 +214,24 @@ int pi_register(PIP * pr)
                if (protocols[k] && !strcmp(pr->name, protocols[k]->name)) {
                        printk("paride: %s protocol already registered\n",
                               pr->name);
-                       return 0;
+                       return -1;
                }
        k = 0;
        while ((k < MAX_PROTOS) && (protocols[k]))
                k++;
        if (k == MAX_PROTOS) {
                printk("paride: protocol table full\n");
-               return 0;
+               return -1;
        }
        protocols[k] = pr;
        pr->index = k;
        printk("paride: %s registered as protocol %d\n", pr->name, k);
-       return 1;
+       return 0;
 }
 
-EXPORT_SYMBOL(pi_register);
+EXPORT_SYMBOL(paride_register);
 
-void pi_unregister(PIP * pr)
+void paride_unregister(PIP * pr)
 {
        if (!pr)
                return;
@@ -265,12 +242,10 @@ void pi_unregister(PIP * pr)
        protocols[pr->index] = NULL;
 }
 
-EXPORT_SYMBOL(pi_unregister);
+EXPORT_SYMBOL(paride_unregister);
 
 static int pi_register_parport(PIA * pi, int verbose)
 {
-#ifdef CONFIG_PARPORT
-
        struct parport *port;
 
        port = parport_find_base(pi->port);
@@ -290,7 +265,6 @@ static int pi_register_parport(PIA * pi, int verbose)
                printk("%s: 0x%x is %s\n", pi->device, pi->port, port->name);
 
        pi->parname = (char *) port->name;
-#endif
 
        return 1;
 }
@@ -447,13 +421,6 @@ int pi_init(PIA * pi, int autoprobe, int port, int mode,
                        printk("%s: Adapter not found\n", device);
                return 0;
        }
-#ifndef CONFIG_PARPORT
-       if (!request_region(pi->port, pi->reserved, pi->device)) {
-               printk(KERN_WARNING "paride: Unable to request region 0x%x\n",
-                      pi->port);
-               return 0;
-       }
-#endif                         /* !CONFIG_PARPORT */
 
        if (pi->parname)
                printk("%s: Sharing %s at 0x%x\n", pi->device,
index c6d98ef09e480640d1deaa3138b1430872e4d765..2bddbf45518bbb7596a71bf83743eff9a12c9b60 100644 (file)
@@ -163,8 +163,8 @@ struct pi_protocol {
 
 typedef struct pi_protocol PIP;
 
-extern int pi_register( PIP * );
-extern void pi_unregister ( PIP * );
+extern int paride_register( PIP * );
+extern void paride_unregister ( PIP * );
 
 #endif /* __DRIVERS_PARIDE_H__ */
 /* end of paride.h */
index ac5ba462710b2f0af37b37032804aa238bbdf2b8..c852eed91e4b6d82cdea3950271abc17e7f4762d 100644 (file)
@@ -912,12 +912,12 @@ static int __init pcd_init(void)
        int unit;
 
        if (disable)
-               return -1;
+               return -EINVAL;
 
        pcd_init_units();
 
        if (pcd_detect())
-               return -1;
+               return -ENODEV;
 
        /* get the atapi capabilities page */
        pcd_probe_capabilities();
@@ -925,7 +925,7 @@ static int __init pcd_init(void)
        if (register_blkdev(major, name)) {
                for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++)
                        put_disk(cd->disk);
-               return -1;
+               return -EBUSY;
        }
 
        pcd_queue = blk_init_queue(do_pcd_request, &pcd_lock);
@@ -933,7 +933,7 @@ static int __init pcd_init(void)
                unregister_blkdev(major, name);
                for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++)
                        put_disk(cd->disk);
-               return -1;
+               return -ENOMEM;
        }
 
        for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) {
index 1a9dee19efcf11cfc61d02dc383a4cb04ff222d9..7cdaa19512605d7cc28356d41132426ca0953630 100644 (file)
@@ -933,25 +933,25 @@ static int __init pf_init(void)
        int unit;
 
        if (disable)
-               return -1;
+               return -EINVAL;
 
        pf_init_units();
 
        if (pf_detect())
-               return -1;
+               return -ENODEV;
        pf_busy = 0;
 
        if (register_blkdev(major, name)) {
                for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++)
                        put_disk(pf->disk);
-               return -1;
+               return -EBUSY;
        }
        pf_queue = blk_init_queue(do_pf_request, &pf_spin_lock);
        if (!pf_queue) {
                unregister_blkdev(major, name);
                for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++)
                        put_disk(pf->disk);
-               return -1;
+               return -ENOMEM;
        }
 
        blk_queue_max_phys_segments(pf_queue, cluster);
index 13f998aa1cd3ffc19ccf402fd901b91e8b0dbf2d..9970aedbb5d9a05f049b33d7cce2b7079a5436a4 100644 (file)
@@ -646,14 +646,14 @@ static int __init pg_init(void)
        int err;
 
        if (disable){
-               err = -1;
+               err = -EINVAL;
                goto out;
        }
 
        pg_init_units();
 
        if (pg_detect()) {
-               err = -1;
+               err = -ENODEV;
                goto out;
        }
 
index 35fb2663672146d0cdbd1ed15ea36da68d1bb223..c902b25e48697d938179d7002ea7522fab5aad93 100644 (file)
@@ -946,12 +946,12 @@ static int __init pt_init(void)
        int err;
 
        if (disable) {
-               err = -1;
+               err = -EINVAL;
                goto out;
        }
 
        if (pt_detect()) {
-               err = -1;
+               err = -ENODEV;
                goto out;
        }
 
index f2904f67af4711484fc0ca99c74d8dc462103d76..7c95c762950fde3efa8253e134662f2db9fc739b 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2000 Jens Axboe <axboe@suse.de>
  * Copyright (C) 2001-2004 Peter Osterlund <petero2@telia.com>
+ * Copyright (C) 2006 Thomas Maier <balagi@justmail.de>
  *
  * May be copied or modified under the terms of the GNU General Public
  * License.  See linux/COPYING for more information.
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/miscdevice.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 #include <linux/mutex.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_ioctl.h>
 #include <scsi/scsi.h>
+#include <linux/debugfs.h>
+#include <linux/device.h>
 
 #include <asm/uaccess.h>
 
 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
 static struct proc_dir_entry *pkt_proc;
 static int pktdev_major;
+static int write_congestion_on  = PKT_WRITE_CONGESTION_ON;
+static int write_congestion_off = PKT_WRITE_CONGESTION_OFF;
 static struct mutex ctl_mutex; /* Serialize open/close/setup/teardown */
 static mempool_t *psd_pool;
 
+static struct class    *class_pktcdvd = NULL;    /* /sys/class/pktcdvd */
+static struct dentry   *pkt_debugfs_root = NULL; /* /debug/pktcdvd */
+
+/* forward declaration */
+static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev);
+static int pkt_remove_dev(dev_t pkt_dev);
+static int pkt_seq_show(struct seq_file *m, void *p);
+
+
+
+/*
+ * create and register a pktcdvd kernel object.
+ */
+static struct pktcdvd_kobj* pkt_kobj_create(struct pktcdvd_device *pd,
+                                       const char* name,
+                                       struct kobject* parent,
+                                       struct kobj_type* ktype)
+{
+       struct pktcdvd_kobj *p;
+       p = kzalloc(sizeof(*p), GFP_KERNEL);
+       if (!p)
+               return NULL;
+       kobject_set_name(&p->kobj, "%s", name);
+       p->kobj.parent = parent;
+       p->kobj.ktype = ktype;
+       p->pd = pd;
+       if (kobject_register(&p->kobj) != 0)
+               return NULL;
+       return p;
+}
+/*
+ * remove a pktcdvd kernel object.
+ */
+static void pkt_kobj_remove(struct pktcdvd_kobj *p)
+{
+       if (p)
+               kobject_unregister(&p->kobj);
+}
+/*
+ * default release function for pktcdvd kernel objects.
+ */
+static void pkt_kobj_release(struct kobject *kobj)
+{
+       kfree(to_pktcdvdkobj(kobj));
+}
+
+
+/**********************************************************
+ *
+ * sysfs interface for pktcdvd
+ * by (C) 2006  Thomas Maier <balagi@justmail.de>
+ *
+ **********************************************************/
+
+#define DEF_ATTR(_obj,_name,_mode) \
+       static struct attribute _obj = { \
+               .name = _name, .owner = THIS_MODULE, .mode = _mode }
+
+/**********************************************************
+  /sys/class/pktcdvd/pktcdvd[0-7]/
+                     stat/reset
+                     stat/packets_started
+                     stat/packets_finished
+                     stat/kb_written
+                     stat/kb_read
+                     stat/kb_read_gather
+                     write_queue/size
+                     write_queue/congestion_off
+                     write_queue/congestion_on
+ **********************************************************/
+
+DEF_ATTR(kobj_pkt_attr_st1, "reset", 0200);
+DEF_ATTR(kobj_pkt_attr_st2, "packets_started", 0444);
+DEF_ATTR(kobj_pkt_attr_st3, "packets_finished", 0444);
+DEF_ATTR(kobj_pkt_attr_st4, "kb_written", 0444);
+DEF_ATTR(kobj_pkt_attr_st5, "kb_read", 0444);
+DEF_ATTR(kobj_pkt_attr_st6, "kb_read_gather", 0444);
+
+static struct attribute *kobj_pkt_attrs_stat[] = {
+       &kobj_pkt_attr_st1,
+       &kobj_pkt_attr_st2,
+       &kobj_pkt_attr_st3,
+       &kobj_pkt_attr_st4,
+       &kobj_pkt_attr_st5,
+       &kobj_pkt_attr_st6,
+       NULL
+};
+
+DEF_ATTR(kobj_pkt_attr_wq1, "size", 0444);
+DEF_ATTR(kobj_pkt_attr_wq2, "congestion_off", 0644);
+DEF_ATTR(kobj_pkt_attr_wq3, "congestion_on",  0644);
+
+static struct attribute *kobj_pkt_attrs_wqueue[] = {
+       &kobj_pkt_attr_wq1,
+       &kobj_pkt_attr_wq2,
+       &kobj_pkt_attr_wq3,
+       NULL
+};
+
+/* declares a char buffer[64] _dbuf, copies data from
+ * _b with length _l into it and ensures that _dbuf ends
+ * with a \0 character.
+ */
+#define DECLARE_BUF_AS_STRING(_dbuf, _b, _l) \
+       char _dbuf[64]; int dlen = (_l) < 0 ? 0 : (_l); \
+       if (dlen >= sizeof(_dbuf)) dlen = sizeof(_dbuf)-1; \
+       memcpy(_dbuf, _b, dlen); _dbuf[dlen] = 0
+
+static ssize_t kobj_pkt_show(struct kobject *kobj,
+                       struct attribute *attr, char *data)
+{
+       struct pktcdvd_device *pd = to_pktcdvdkobj(kobj)->pd;
+       int n = 0;
+       int v;
+       if (strcmp(attr->name, "packets_started") == 0) {
+               n = sprintf(data, "%lu\n", pd->stats.pkt_started);
+
+       } else if (strcmp(attr->name, "packets_finished") == 0) {
+               n = sprintf(data, "%lu\n", pd->stats.pkt_ended);
+
+       } else if (strcmp(attr->name, "kb_written") == 0) {
+               n = sprintf(data, "%lu\n", pd->stats.secs_w >> 1);
+
+       } else if (strcmp(attr->name, "kb_read") == 0) {
+               n = sprintf(data, "%lu\n", pd->stats.secs_r >> 1);
+
+       } else if (strcmp(attr->name, "kb_read_gather") == 0) {
+               n = sprintf(data, "%lu\n", pd->stats.secs_rg >> 1);
+
+       } else if (strcmp(attr->name, "size") == 0) {
+               spin_lock(&pd->lock);
+               v = pd->bio_queue_size;
+               spin_unlock(&pd->lock);
+               n = sprintf(data, "%d\n", v);
+
+       } else if (strcmp(attr->name, "congestion_off") == 0) {
+               spin_lock(&pd->lock);
+               v = pd->write_congestion_off;
+               spin_unlock(&pd->lock);
+               n = sprintf(data, "%d\n", v);
+
+       } else if (strcmp(attr->name, "congestion_on") == 0) {
+               spin_lock(&pd->lock);
+               v = pd->write_congestion_on;
+               spin_unlock(&pd->lock);
+               n = sprintf(data, "%d\n", v);
+       }
+       return n;
+}
+
+static void init_write_congestion_marks(int* lo, int* hi)
+{
+       if (*hi > 0) {
+               *hi = max(*hi, 500);
+               *hi = min(*hi, 1000000);
+               if (*lo <= 0)
+                       *lo = *hi - 100;
+               else {
+                       *lo = min(*lo, *hi - 100);
+                       *lo = max(*lo, 100);
+               }
+       } else {
+               *hi = -1;
+               *lo = -1;
+       }
+}
+
+static ssize_t kobj_pkt_store(struct kobject *kobj,
+                       struct attribute *attr,
+                       const char *data, size_t len)
+{
+       struct pktcdvd_device *pd = to_pktcdvdkobj(kobj)->pd;
+       int val;
+       DECLARE_BUF_AS_STRING(dbuf, data, len); /* ensure sscanf scans a string */
+
+       if (strcmp(attr->name, "reset") == 0 && dlen > 0) {
+               pd->stats.pkt_started = 0;
+               pd->stats.pkt_ended = 0;
+               pd->stats.secs_w = 0;
+               pd->stats.secs_rg = 0;
+               pd->stats.secs_r = 0;
+
+       } else if (strcmp(attr->name, "congestion_off") == 0
+                  && sscanf(dbuf, "%d", &val) == 1) {
+               spin_lock(&pd->lock);
+               pd->write_congestion_off = val;
+               init_write_congestion_marks(&pd->write_congestion_off,
+                                       &pd->write_congestion_on);
+               spin_unlock(&pd->lock);
+
+       } else if (strcmp(attr->name, "congestion_on") == 0
+                  && sscanf(dbuf, "%d", &val) == 1) {
+               spin_lock(&pd->lock);
+               pd->write_congestion_on = val;
+               init_write_congestion_marks(&pd->write_congestion_off,
+                                       &pd->write_congestion_on);
+               spin_unlock(&pd->lock);
+       }
+       return len;
+}
+
+static struct sysfs_ops kobj_pkt_ops = {
+       .show = kobj_pkt_show,
+       .store = kobj_pkt_store
+};
+static struct kobj_type kobj_pkt_type_stat = {
+       .release = pkt_kobj_release,
+       .sysfs_ops = &kobj_pkt_ops,
+       .default_attrs = kobj_pkt_attrs_stat
+};
+static struct kobj_type kobj_pkt_type_wqueue = {
+       .release = pkt_kobj_release,
+       .sysfs_ops = &kobj_pkt_ops,
+       .default_attrs = kobj_pkt_attrs_wqueue
+};
+
+static void pkt_sysfs_dev_new(struct pktcdvd_device *pd)
+{
+       if (class_pktcdvd) {
+               pd->clsdev = class_device_create(class_pktcdvd,
+                                       NULL, pd->pkt_dev,
+                                       NULL, "%s", pd->name);
+               if (IS_ERR(pd->clsdev))
+                       pd->clsdev = NULL;
+       }
+       if (pd->clsdev) {
+               pd->kobj_stat = pkt_kobj_create(pd, "stat",
+                                       &pd->clsdev->kobj,
+                                       &kobj_pkt_type_stat);
+               pd->kobj_wqueue = pkt_kobj_create(pd, "write_queue",
+                                       &pd->clsdev->kobj,
+                                       &kobj_pkt_type_wqueue);
+       }
+}
+
+static void pkt_sysfs_dev_remove(struct pktcdvd_device *pd)
+{
+       pkt_kobj_remove(pd->kobj_stat);
+       pkt_kobj_remove(pd->kobj_wqueue);
+       if (class_pktcdvd)
+               class_device_destroy(class_pktcdvd, pd->pkt_dev);
+}
+
+
+/********************************************************************
+  /sys/class/pktcdvd/
+                     add            map block device
+                     remove         unmap packet dev
+                     device_map     show mappings
+ *******************************************************************/
+
+static void class_pktcdvd_release(struct class *cls)
+{
+       kfree(cls);
+}
+static ssize_t class_pktcdvd_show_map(struct class *c, char *data)
+{
+       int n = 0;
+       int idx;
+       mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
+       for (idx = 0; idx < MAX_WRITERS; idx++) {
+               struct pktcdvd_device *pd = pkt_devs[idx];
+               if (!pd)
+                       continue;
+               n += sprintf(data+n, "%s %u:%u %u:%u\n",
+                       pd->name,
+                       MAJOR(pd->pkt_dev), MINOR(pd->pkt_dev),
+                       MAJOR(pd->bdev->bd_dev),
+                       MINOR(pd->bdev->bd_dev));
+       }
+       mutex_unlock(&ctl_mutex);
+       return n;
+}
+
+static ssize_t class_pktcdvd_store_add(struct class *c, const char *buf,
+                                       size_t count)
+{
+       unsigned int major, minor;
+       DECLARE_BUF_AS_STRING(dbuf, buf, count);
+       if (sscanf(dbuf, "%u:%u", &major, &minor) == 2) {
+               pkt_setup_dev(MKDEV(major, minor), NULL);
+               return count;
+       }
+       return -EINVAL;
+}
+
+static ssize_t class_pktcdvd_store_remove(struct class *c, const char *buf,
+                                       size_t count)
+{
+       unsigned int major, minor;
+       DECLARE_BUF_AS_STRING(dbuf, buf, count);
+       if (sscanf(dbuf, "%u:%u", &major, &minor) == 2) {
+               pkt_remove_dev(MKDEV(major, minor));
+               return count;
+       }
+       return -EINVAL;
+}
+
+static struct class_attribute class_pktcdvd_attrs[] = {
+ __ATTR(add,            0200, NULL, class_pktcdvd_store_add),
+ __ATTR(remove,         0200, NULL, class_pktcdvd_store_remove),
+ __ATTR(device_map,     0444, class_pktcdvd_show_map, NULL),
+ __ATTR_NULL
+};
+
+
+static int pkt_sysfs_init(void)
+{
+       int ret = 0;
+
+       /*
+        * create control files in sysfs
+        * /sys/class/pktcdvd/...
+        */
+       class_pktcdvd = kzalloc(sizeof(*class_pktcdvd), GFP_KERNEL);
+       if (!class_pktcdvd)
+               return -ENOMEM;
+       class_pktcdvd->name = DRIVER_NAME;
+       class_pktcdvd->owner = THIS_MODULE;
+       class_pktcdvd->class_release = class_pktcdvd_release;
+       class_pktcdvd->class_attrs = class_pktcdvd_attrs;
+       ret = class_register(class_pktcdvd);
+       if (ret) {
+               kfree(class_pktcdvd);
+               class_pktcdvd = NULL;
+               printk(DRIVER_NAME": failed to create class pktcdvd\n");
+               return ret;
+       }
+       return 0;
+}
+
+static void pkt_sysfs_cleanup(void)
+{
+       if (class_pktcdvd)
+               class_destroy(class_pktcdvd);
+       class_pktcdvd = NULL;
+}
+
+/********************************************************************
+  entries in debugfs
+
+  /debugfs/pktcdvd[0-7]/
+                       info
+
+ *******************************************************************/
+
+static int pkt_debugfs_seq_show(struct seq_file *m, void *p)
+{
+       return pkt_seq_show(m, p);
+}
+
+static int pkt_debugfs_fops_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, pkt_debugfs_seq_show, inode->i_private);
+}
+
+static struct file_operations debug_fops = {
+       .open           = pkt_debugfs_fops_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .owner          = THIS_MODULE,
+};
+
+static void pkt_debugfs_dev_new(struct pktcdvd_device *pd)
+{
+       if (!pkt_debugfs_root)
+               return;
+       pd->dfs_f_info = NULL;
+       pd->dfs_d_root = debugfs_create_dir(pd->name, pkt_debugfs_root);
+       if (IS_ERR(pd->dfs_d_root)) {
+               pd->dfs_d_root = NULL;
+               return;
+       }
+       pd->dfs_f_info = debugfs_create_file("info", S_IRUGO,
+                               pd->dfs_d_root, pd, &debug_fops);
+       if (IS_ERR(pd->dfs_f_info)) {
+               pd->dfs_f_info = NULL;
+               return;
+       }
+}
+
+static void pkt_debugfs_dev_remove(struct pktcdvd_device *pd)
+{
+       if (!pkt_debugfs_root)
+               return;
+       if (pd->dfs_f_info)
+               debugfs_remove(pd->dfs_f_info);
+       pd->dfs_f_info = NULL;
+       if (pd->dfs_d_root)
+               debugfs_remove(pd->dfs_d_root);
+       pd->dfs_d_root = NULL;
+}
+
+static void pkt_debugfs_init(void)
+{
+       pkt_debugfs_root = debugfs_create_dir(DRIVER_NAME, NULL);
+       if (IS_ERR(pkt_debugfs_root)) {
+               pkt_debugfs_root = NULL;
+               return;
+       }
+}
+
+static void pkt_debugfs_cleanup(void)
+{
+       if (!pkt_debugfs_root)
+               return;
+       debugfs_remove(pkt_debugfs_root);
+       pkt_debugfs_root = NULL;
+}
+
+/* ----------------------------------------------------------*/
+
 
 static void pkt_bio_finished(struct pktcdvd_device *pd)
 {
@@ -893,6 +1311,7 @@ static int pkt_handle_queue(struct pktcdvd_device *pd)
        sector_t zone = 0; /* Suppress gcc warning */
        struct pkt_rb_node *node, *first_node;
        struct rb_node *n;
+       int wakeup;
 
        VPRINTK("handle_queue\n");
 
@@ -965,7 +1384,13 @@ try_next_bio:
                pkt->write_size += bio->bi_size / CD_FRAMESIZE;
                spin_unlock(&pkt->lock);
        }
+       /* check write congestion marks, and if bio_queue_size is
+          below, wake up any waiters */
+       wakeup = (pd->write_congestion_on > 0
+                       && pd->bio_queue_size <= pd->write_congestion_off);
        spin_unlock(&pd->lock);
+       if (wakeup)
+               blk_clear_queue_congested(pd->disk->queue, WRITE);
 
        pkt->sleep_time = max(PACKET_WAIT_TIME, 1);
        pkt_set_state(pkt, PACKET_WAITING_STATE);
@@ -2178,6 +2603,23 @@ static int pkt_make_request(request_queue_t *q, struct bio *bio)
        }
        spin_unlock(&pd->cdrw.active_list_lock);
 
+       /*
+        * Test if there is enough room left in the bio work queue
+        * (queue size >= congestion on mark).
+        * If not, wait till the work queue size is below the congestion off mark.
+        */
+       spin_lock(&pd->lock);
+       if (pd->write_congestion_on > 0
+           && pd->bio_queue_size >= pd->write_congestion_on) {
+               blk_set_queue_congested(q, WRITE);
+               do {
+                       spin_unlock(&pd->lock);
+                       congestion_wait(WRITE, HZ);
+                       spin_lock(&pd->lock);
+               } while(pd->bio_queue_size > pd->write_congestion_off);
+       }
+       spin_unlock(&pd->lock);
+
        /*
         * No matching packet found. Store the bio in the work queue.
         */
@@ -2297,6 +2739,9 @@ static int pkt_seq_show(struct seq_file *m, void *p)
        seq_printf(m, "\tstate:\t\t\ti:%d ow:%d rw:%d ww:%d rec:%d fin:%d\n",
                   states[0], states[1], states[2], states[3], states[4], states[5]);
 
+       seq_printf(m, "\twrite congestion marks:\toff=%d on=%d\n",
+                       pd->write_congestion_off,
+                       pd->write_congestion_on);
        return 0;
 }
 
@@ -2436,36 +2881,33 @@ static struct block_device_operations pktcdvd_ops = {
 /*
  * Set up mapping from pktcdvd device to CD-ROM device.
  */
-static int pkt_setup_dev(struct pkt_ctrl_command *ctrl_cmd)
+static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
 {
        int idx;
        int ret = -ENOMEM;
        struct pktcdvd_device *pd;
        struct gendisk *disk;
-       dev_t dev = new_decode_dev(ctrl_cmd->dev);
+
+       mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
 
        for (idx = 0; idx < MAX_WRITERS; idx++)
                if (!pkt_devs[idx])
                        break;
        if (idx == MAX_WRITERS) {
                printk(DRIVER_NAME": max %d writers supported\n", MAX_WRITERS);
-               return -EBUSY;
+               ret = -EBUSY;
+               goto out_mutex;
        }
 
        pd = kzalloc(sizeof(struct pktcdvd_device), GFP_KERNEL);
        if (!pd)
-               return ret;
+               goto out_mutex;
 
        pd->rb_pool = mempool_create_kmalloc_pool(PKT_RB_POOL_SIZE,
                                                  sizeof(struct pkt_rb_node));
        if (!pd->rb_pool)
                goto out_mem;
 
-       disk = alloc_disk(1);
-       if (!disk)
-               goto out_mem;
-       pd->disk = disk;
-
        INIT_LIST_HEAD(&pd->cdrw.pkt_free_list);
        INIT_LIST_HEAD(&pd->cdrw.pkt_active_list);
        spin_lock_init(&pd->cdrw.active_list_lock);
@@ -2476,11 +2918,18 @@ static int pkt_setup_dev(struct pkt_ctrl_command *ctrl_cmd)
        init_waitqueue_head(&pd->wqueue);
        pd->bio_queue = RB_ROOT;
 
+       pd->write_congestion_on  = write_congestion_on;
+       pd->write_congestion_off = write_congestion_off;
+
+       disk = alloc_disk(1);
+       if (!disk)
+               goto out_mem;
+       pd->disk = disk;
        disk->major = pktdev_major;
        disk->first_minor = idx;
        disk->fops = &pktcdvd_ops;
        disk->flags = GENHD_FL_REMOVABLE;
-       sprintf(disk->disk_name, DRIVER_NAME"%d", idx);
+       strcpy(disk->disk_name, pd->name);
        disk->private_data = pd;
        disk->queue = blk_alloc_queue(GFP_KERNEL);
        if (!disk->queue)
@@ -2492,8 +2941,15 @@ static int pkt_setup_dev(struct pkt_ctrl_command *ctrl_cmd)
                goto out_new_dev;
 
        add_disk(disk);
+
+       pkt_sysfs_dev_new(pd);
+       pkt_debugfs_dev_new(pd);
+
        pkt_devs[idx] = pd;
-       ctrl_cmd->pkt_dev = new_encode_dev(pd->pkt_dev);
+       if (pkt_dev)
+               *pkt_dev = pd->pkt_dev;
+
+       mutex_unlock(&ctl_mutex);
        return 0;
 
 out_new_dev:
@@ -2504,17 +2960,22 @@ out_mem:
        if (pd->rb_pool)
                mempool_destroy(pd->rb_pool);
        kfree(pd);
+out_mutex:
+       mutex_unlock(&ctl_mutex);
+       printk(DRIVER_NAME": setup of pktcdvd device failed\n");
        return ret;
 }
 
 /*
  * Tear down mapping from pktcdvd device to CD-ROM device.
  */
-static int pkt_remove_dev(struct pkt_ctrl_command *ctrl_cmd)
+static int pkt_remove_dev(dev_t pkt_dev)
 {
        struct pktcdvd_device *pd;
        int idx;
-       dev_t pkt_dev = new_decode_dev(ctrl_cmd->pkt_dev);
+       int ret = 0;
+
+       mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
 
        for (idx = 0; idx < MAX_WRITERS; idx++) {
                pd = pkt_devs[idx];
@@ -2523,15 +2984,22 @@ static int pkt_remove_dev(struct pkt_ctrl_command *ctrl_cmd)
        }
        if (idx == MAX_WRITERS) {
                DPRINTK(DRIVER_NAME": dev not setup\n");
-               return -ENXIO;
+               ret = -ENXIO;
+               goto out;
        }
 
-       if (pd->refcnt > 0)
-               return -EBUSY;
-
+       if (pd->refcnt > 0) {
+               ret = -EBUSY;
+               goto out;
+       }
        if (!IS_ERR(pd->cdrw.thread))
                kthread_stop(pd->cdrw.thread);
 
+       pkt_devs[idx] = NULL;
+
+       pkt_debugfs_dev_remove(pd);
+       pkt_sysfs_dev_remove(pd);
+
        blkdev_put(pd->bdev);
 
        remove_proc_entry(pd->name, pkt_proc);
@@ -2541,18 +3009,24 @@ static int pkt_remove_dev(struct pkt_ctrl_command *ctrl_cmd)
        blk_cleanup_queue(pd->disk->queue);
        put_disk(pd->disk);
 
-       pkt_devs[idx] = NULL;
        mempool_destroy(pd->rb_pool);
        kfree(pd);
 
        /* This is safe: open() is still holding a reference. */
        module_put(THIS_MODULE);
-       return 0;
+
+out:
+       mutex_unlock(&ctl_mutex);
+       return ret;
 }
 
 static void pkt_get_status(struct pkt_ctrl_command *ctrl_cmd)
 {
-       struct pktcdvd_device *pd = pkt_find_dev_from_minor(ctrl_cmd->dev_index);
+       struct pktcdvd_device *pd;
+
+       mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
+
+       pd = pkt_find_dev_from_minor(ctrl_cmd->dev_index);
        if (pd) {
                ctrl_cmd->dev = new_encode_dev(pd->bdev->bd_dev);
                ctrl_cmd->pkt_dev = new_encode_dev(pd->pkt_dev);
@@ -2561,6 +3035,8 @@ static void pkt_get_status(struct pkt_ctrl_command *ctrl_cmd)
                ctrl_cmd->pkt_dev = 0;
        }
        ctrl_cmd->num_devices = MAX_WRITERS;
+
+       mutex_unlock(&ctl_mutex);
 }
 
 static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
@@ -2568,6 +3044,7 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm
        void __user *argp = (void __user *)arg;
        struct pkt_ctrl_command ctrl_cmd;
        int ret = 0;
+       dev_t pkt_dev = 0;
 
        if (cmd != PACKET_CTRL_CMD)
                return -ENOTTY;
@@ -2579,21 +3056,16 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm
        case PKT_CTRL_CMD_SETUP:
                if (!capable(CAP_SYS_ADMIN))
                        return -EPERM;
-               mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
-               ret = pkt_setup_dev(&ctrl_cmd);
-               mutex_unlock(&ctl_mutex);
+               ret = pkt_setup_dev(new_decode_dev(ctrl_cmd.dev), &pkt_dev);
+               ctrl_cmd.pkt_dev = new_encode_dev(pkt_dev);
                break;
        case PKT_CTRL_CMD_TEARDOWN:
                if (!capable(CAP_SYS_ADMIN))
                        return -EPERM;
-               mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
-               ret = pkt_remove_dev(&ctrl_cmd);
-               mutex_unlock(&ctl_mutex);
+               ret = pkt_remove_dev(new_decode_dev(ctrl_cmd.pkt_dev));
                break;
        case PKT_CTRL_CMD_STATUS:
-               mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
                pkt_get_status(&ctrl_cmd);
-               mutex_unlock(&ctl_mutex);
                break;
        default:
                return -ENOTTY;
@@ -2620,6 +3092,8 @@ static int __init pkt_init(void)
 {
        int ret;
 
+       mutex_init(&ctl_mutex);
+
        psd_pool = mempool_create_kmalloc_pool(PSD_POOL_SIZE,
                                        sizeof(struct packet_stacked_data));
        if (!psd_pool)
@@ -2633,18 +3107,25 @@ static int __init pkt_init(void)
        if (!pktdev_major)
                pktdev_major = ret;
 
+       ret = pkt_sysfs_init();
+       if (ret)
+               goto out;
+
+       pkt_debugfs_init();
+
        ret = misc_register(&pkt_misc);
        if (ret) {
                printk(DRIVER_NAME": Unable to register misc device\n");
-               goto out;
+               goto out_misc;
        }
 
-       mutex_init(&ctl_mutex);
-
        pkt_proc = proc_mkdir(DRIVER_NAME, proc_root_driver);
 
        return 0;
 
+out_misc:
+       pkt_debugfs_cleanup();
+       pkt_sysfs_cleanup();
 out:
        unregister_blkdev(pktdev_major, DRIVER_NAME);
 out2:
@@ -2656,6 +3137,10 @@ static void __exit pkt_exit(void)
 {
        remove_proc_entry(DRIVER_NAME, proc_root_driver);
        misc_deregister(&pkt_misc);
+
+       pkt_debugfs_cleanup();
+       pkt_sysfs_cleanup();
+
        unregister_blkdev(pktdev_major, DRIVER_NAME);
        mempool_destroy(psd_pool);
 }
index d0cface535fb33e851aeab4548c2bcd6097340dd..5e2c31882003e785f630597d0ba8451d0e195e3a 100644 (file)
@@ -330,7 +330,7 @@ static struct sk_buff *bcsp_dequeue(struct hci_uart *hu)
           reliable packet if the number of packets sent but not yet ack'ed
           is < than the winsize */
 
-       spin_lock_irqsave(&bcsp->unack.lock, flags);
+       spin_lock_irqsave_nested(&bcsp->unack.lock, flags, SINGLE_DEPTH_NESTING);
 
        if (bcsp->unack.qlen < BCSP_TXWINSIZE && (skb = skb_dequeue(&bcsp->rel)) != NULL) {
                struct sk_buff *nskb = bcsp_prepare_pkt(bcsp, skb->data, skb->len, bt_cb(skb)->pkt_type);
@@ -696,7 +696,7 @@ static void bcsp_timed_event(unsigned long arg)
 
        BT_DBG("hu %p retransmitting %u pkts", hu, bcsp->unack.qlen);
 
-       spin_lock_irqsave(&bcsp->unack.lock, flags);
+       spin_lock_irqsave_nested(&bcsp->unack.lock, flags, SINGLE_DEPTH_NESTING);
 
        while ((skb = __skb_dequeue_tail(&bcsp->unack)) != NULL) {
                bcsp->msgq_txseq = (bcsp->msgq_txseq - 1) & 0x07;
index 25032d7edc55e19a3f63a8e3dfd92a70ddca767c..3541690a77d443932de3b2123ba677d491f729bb 100644 (file)
@@ -101,7 +101,7 @@ static void debug(int debug_this, const char* fmt, ...)
                return;
 
        va_start(args, fmt);
-       vsprintf(s, fmt, args);
+       vsnprintf(s, sizeof(s), fmt, args);
        printk(KERN_DEBUG "optcd: %s\n", s);
        va_end(args);
 }
index ba50e5a712f23fe2fe68511274fb7f3cc1d8dbec..a1283b1ef9890cdadae175ed9049900d26dfacca 100644 (file)
@@ -770,11 +770,10 @@ static void msg(int level, const char *fmt, ...)
        
        msgnum++;
        if (msgnum>99) msgnum=0;
-       sprintf(buf, MSG_LEVEL "%s-%d [%02d]:  ", major_name, current_drive - D_S, msgnum);
        va_start(args, fmt);
-       vsprintf(&buf[18], fmt, args);
+       vsnprintf(buf, sizeof(buf), fmt, args);
        va_end(args);
-       printk(buf);
+       printk(MSG_LEVEL "%s-%d [%02d]:  %s", major_name, current_drive - D_S, msgnum, buf);
 #if KLOGD_PAUSE
        sbp_sleep(KLOGD_PAUSE); /* else messages get lost */
 #endif /* KLOGD_PAUSE */ 
index 24f922f127830ea75880c8e65a5dfe3418599942..b10f4d8fdc7fb99fa6bbf0c07fc0ee4bf5347f36 100644 (file)
@@ -201,6 +201,21 @@ config MOXA_SMARTIO
          The module will be called mxser. If you want to do that, say M
          here.
 
+config MOXA_SMARTIO_NEW
+       tristate "Moxa SmartIO support v. 2.0 (EXPERIMENTAL)"
+       depends on SERIAL_NONSTANDARD
+       help
+         Say Y here if you have a Moxa SmartIO multiport serial card and/or
+         want to help develop a new version of this driver.
+
+         This is upgraded (1.9.1) driver from original Moxa drivers with
+         changes finally resulting in PCI probing.
+
+         Use at your own risk.
+
+         This driver can also be built as a module. The module will be called
+         mxser_new. If you want to do that, say M here.
+
 config ISI
        tristate "Multi-Tech multiport card support (EXPERIMENTAL)"
        depends on SERIAL_NONSTANDARD
index b1fcdab909471e49b6489eeb048bca1b371ac070..fc110637ced6ad4b4f6ae8b70bc3365d69110540 100644 (file)
@@ -31,6 +31,7 @@ obj-$(CONFIG_MOXA_INTELLIO)   += moxa.o
 obj-$(CONFIG_A2232)            += ser_a2232.o generic_serial.o
 obj-$(CONFIG_ATARI_DSP56K)     += dsp56k.o
 obj-$(CONFIG_MOXA_SMARTIO)     += mxser.o
+obj-$(CONFIG_MOXA_SMARTIO_NEW) += mxser_new.o
 obj-$(CONFIG_COMPUTONE)                += ip2/
 obj-$(CONFIG_RISCOM8)          += riscom8.o
 obj-$(CONFIG_ISI)              += isicom.o
index 00b17ae39736cbbb4132f85d91c0b1c80f415bd1..2f2c4efff8a31d3c5e53f80d017f8ecd88435984 100644 (file)
@@ -459,7 +459,7 @@ static const struct aper_size_info_32 nforce3_sizes[5] =
 
 /* Handle shadow device of the Nvidia NForce3 */
 /* CHECK-ME original 2.4 version set up some IORRs. Check if that is needed. */
-static int __devinit nforce3_agp_init(struct pci_dev *pdev)
+static int nforce3_agp_init(struct pci_dev *pdev)
 {
        u32 tmp, apbase, apbar, aplimit;
        struct pci_dev *dev1;
index 66086fa2d59a2c38188f854ecc8a55bb5081eac3..feb4ac802a0d1e44f8fef6d24a7e7638a0d3b563 100644 (file)
@@ -104,7 +104,7 @@ static struct async_struct *IRQ_ports;
 
 static unsigned char current_ctl_bits;
 
-static void change_speed(struct async_struct *info, struct termios *old);
+static void change_speed(struct async_struct *info, struct ktermios *old);
 static void rs_wait_until_sent(struct tty_struct *tty, int timeout);
 
 
@@ -694,7 +694,7 @@ static void shutdown(struct async_struct * info)
  * the specified baud rate for a serial port.
  */
 static void change_speed(struct async_struct *info,
-                        struct termios *old_termios)
+                        struct ktermios *old_termios)
 {
        int     quot = 0, baud_base, baud;
        unsigned cflag, cval = 0;
@@ -1365,7 +1365,7 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
        return 0;
 }
 
-static void rs_set_termios(struct tty_struct *tty, struct termios *old_termios)
+static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
        struct async_struct *info = (struct async_struct *)tty->driver_data;
        unsigned long flags;
index 8ce3f34cfc2226ac213f1eeec63b84908c4313e8..c02d9e99e0501737ce909c30ab5292b28b72ef9d 100644 (file)
@@ -82,7 +82,7 @@ static inline u32 cs5535_lowhigh_base(int reg)
 static ssize_t cs5535_gpio_write(struct file *file, const char __user *data,
                                 size_t len, loff_t *ppos)
 {
-       u32     m = iminor(file->f_dentry->d_inode);
+       u32     m = iminor(file->f_path.dentry->d_inode);
        int     i, j;
        u32     base = gpio_base + cs5535_lowhigh_base(m);
        u32     m0, m1;
@@ -117,7 +117,7 @@ static ssize_t cs5535_gpio_write(struct file *file, const char __user *data,
 static ssize_t cs5535_gpio_read(struct file *file, char __user *buf,
                                size_t len, loff_t *ppos)
 {
-       u32     m = iminor(file->f_dentry->d_inode);
+       u32     m = iminor(file->f_path.dentry->d_inode);
        u32     base = gpio_base + cs5535_lowhigh_base(m);
        int     rd_bit = 1 << (m & 0x0f);
        int     i;
index acb2de5e3a985db72fa6c94c05017ca162a9d7b1..3ffa0807754c34313f9288299552f97df2c8468f 100644 (file)
@@ -1,8 +1,6 @@
 #undef BLOCKMOVE
 #define        Z_WAKE
 #undef Z_EXT_CHARS_IN_BUFFER
-static char rcsid[] =
-"$Revision: 2.3.2.20 $$Date: 2004/02/25 18:14:16 $";
 
 /*
  *  linux/drivers/char/cyclades.c
@@ -593,18 +591,20 @@ static char rcsid[] =
  *
  */
 
+#define CY_VERSION     "2.4"
+
 /* If you need to install more boards than NR_CARDS, change the constant
    in the definition below. No other change is necessary to support up to
    eight boards. Beyond that you'll have to extend cy_isa_addresses. */
 
-#define NR_CARDS        4
+#define NR_CARDS       4
 
 /*
    If the total number of ports is larger than NR_PORTS, change this
    constant in the definition below. No other change is necessary to
    support more boards/ports. */
 
-#define NR_PORTS        256
+#define NR_PORTS       256
 
 #define ZE_V1_NPORTS   64
 #define ZO_V1  0
@@ -625,9 +625,9 @@ static char rcsid[] =
 #undef CY_PCI_DEBUG
 
 #if 0
-#define PAUSE __asm__("nop");
+#define PAUSE __asm__("nop")
 #else
-#define PAUSE ;
+#define PAUSE do {} while (0)
 #endif
 
 /*
@@ -663,7 +663,7 @@ static char rcsid[] =
                do {                                            \
                spin_lock_irqsave(&cy_card[info->card].card_lock, flags); \
                } while (0)
-               
+
 #define        CY_UNLOCK(info,flags)                                   \
                do {                                            \
                spin_unlock_irqrestore(&cy_card[info->card].card_lock, flags); \
@@ -676,14 +676,14 @@ static char rcsid[] =
 #include <linux/stat.h>
 #include <linux/proc_fs.h>
 
-static void cy_throttle (struct tty_struct *tty);
-static void cy_send_xchar (struct tty_struct *tty, char ch);
+static void cy_throttle(struct tty_struct *tty);
+static void cy_send_xchar(struct tty_struct *tty, char ch);
 
 #define IS_CYC_Z(card) ((card).num_chips == -1)
 
 #define Z_FPGA_CHECK(card) \
-    ((cy_readl(&((struct RUNTIME_9060 __iomem *) \
-                ((card).ctl_addr))->init_ctrl) & (1<<17)) != 0)
+       ((cy_readl(&((struct RUNTIME_9060 __iomem *) \
+               ((card).ctl_addr))->init_ctrl) & (1<<17)) != 0)
 
 #define ISZLOADED(card)        (((ZO_V1==cy_readl(&((struct RUNTIME_9060 __iomem *) \
                        ((card).ctl_addr))->mail_box_0)) || \
@@ -698,8 +698,6 @@ static void cy_send_xchar (struct tty_struct *tty, char ch);
 
 #define STD_COM_FLAGS (0)
 
-#define        JIFFIES_DIFF(n, j)      ((j) - (n))
-
 static struct tty_driver *cy_serial_driver;
 
 #ifdef CONFIG_ISA
@@ -713,27 +711,28 @@ static struct tty_driver *cy_serial_driver;
 */
 
 static unsigned int cy_isa_addresses[] = {
-        0xD0000,
-        0xD2000,
-        0xD4000,
-        0xD6000,
-        0xD8000,
-        0xDA000,
-        0xDC000,
-        0xDE000,
-        0,0,0,0,0,0,0,0
+       0xD0000,
+       0xD2000,
+       0xD4000,
+       0xD6000,
+       0xD8000,
+       0xDA000,
+       0xDC000,
+       0xDE000,
+       0, 0, 0, 0, 0, 0, 0, 0
 };
+
 #define NR_ISA_ADDRS ARRAY_SIZE(cy_isa_addresses)
 
 #ifdef MODULE
 static long maddr[NR_CARDS] = { 0, };
-static int irq[NR_CARDS]  = { 0, };
+static int irq[NR_CARDS] = { 0, };
 
 module_param_array(maddr, long, NULL, 0);
 module_param_array(irq, int, NULL, 0);
 #endif
 
-#endif /* CONFIG_ISA */
+#endif                         /* CONFIG_ISA */
 
 /* This is the per-card data structure containing address, irq, number of
    channels, etc. This driver supports a maximum of NR_CARDS cards.
@@ -745,7 +744,7 @@ static struct cyclades_card cy_card[NR_CARDS];
 */
 static struct cyclades_port cy_port[NR_PORTS];
 
-static int cy_next_channel; /* next minor available */
+static int cy_next_channel;    /* next minor available */
 
 /*
  * This is used to look up the divisor speeds and the timeouts
@@ -757,36 +756,42 @@ static int cy_next_channel; /* next minor available */
  *     20
  */
 static int baud_table[] = {
-       0,    50,    75,   110,   134,   150,   200,   300,   600,  1200,
-    1800,  2400,  4800,  9600, 19200, 38400, 57600, 76800,115200,150000,
-  230400,     0};
-
-static char baud_co_25[] = {  /* 25 MHz clock option table */
-    /* value =>    00    01   02    03    04 */
-    /* divide by    8    32   128   512  2048 */
-    0x00,  0x04,  0x04,  0x04,  0x04,  0x04,  0x03,  0x03,  0x03,  0x02,
-    0x02,  0x02,  0x01,  0x01,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00};
-
-static char baud_bpr_25[] = {  /* 25 MHz baud rate period table */
-    0x00,  0xf5,  0xa3,  0x6f,  0x5c,  0x51,  0xf5,  0xa3,  0x51,  0xa3,
-    0x6d,  0x51,  0xa3,  0x51,  0xa3,  0x51,  0x36,  0x29,  0x1b,  0x15};
-
-static char baud_co_60[] = {  /* 60 MHz clock option table (CD1400 J) */
-    /* value =>    00    01   02    03    04 */
-    /* divide by    8    32   128   512  2048 */
-    0x00,  0x00,  0x00,  0x04,  0x04,  0x04,  0x04,  0x04,  0x03,  0x03,
-    0x03,  0x02,  0x02,  0x01,  0x01,  0x00,  0x00,  0x00,  0x00,  0x00,
-    0x00};
-
-static char baud_bpr_60[] = {  /* 60 MHz baud rate period table (CD1400 J) */
-    0x00,  0x82,  0x21,  0xff,  0xdb,  0xc3,  0x92,  0x62,  0xc3,  0x62,
-    0x41,  0xc3,  0x62,  0xc3,  0x62,  0xc3,  0x82,  0x62,  0x41,  0x32,
-    0x21};
-
-static char baud_cor3[] = {  /* receive threshold */
-    0x0a,  0x0a,  0x0a,  0x0a,  0x0a,  0x0a,  0x0a,  0x0a,  0x0a,  0x0a,
-    0x0a,  0x0a,  0x0a,  0x09,  0x09,  0x08,  0x08,  0x08,  0x08,  0x07,
-    0x07};
+       0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
+       1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 115200, 150000,
+       230400, 0
+};
+
+static char baud_co_25[] = {   /* 25 MHz clock option table */
+       /* value =>    00    01   02    03    04 */
+       /* divide by    8    32   128   512  2048 */
+       0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02,
+       0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static char baud_bpr_25[] = {  /* 25 MHz baud rate period table */
+       0x00, 0xf5, 0xa3, 0x6f, 0x5c, 0x51, 0xf5, 0xa3, 0x51, 0xa3,
+       0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x36, 0x29, 0x1b, 0x15
+};
+
+static char baud_co_60[] = {   /* 60 MHz clock option table (CD1400 J) */
+       /* value =>    00    01   02    03    04 */
+       /* divide by    8    32   128   512  2048 */
+       0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03,
+       0x03, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00
+};
+
+static char baud_bpr_60[] = {  /* 60 MHz baud rate period table (CD1400 J) */
+       0x00, 0x82, 0x21, 0xff, 0xdb, 0xc3, 0x92, 0x62, 0xc3, 0x62,
+       0x41, 0xc3, 0x62, 0xc3, 0x62, 0xc3, 0x82, 0x62, 0x41, 0x32,
+       0x21
+};
+
+static char baud_cor3[] = {    /* receive threshold */
+       0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
+       0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07,
+       0x07
+};
 
 /*
  * The Cyclades driver implements HW flow control as any serial driver.
@@ -799,42 +804,42 @@ static char baud_cor3[] = {  /* receive threshold */
  * cables.
  */
 
-static char rflow_thr[] = {  /* rflow threshold */
-    0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
-    0x00,  0x00,  0x00,  0x0a,  0x0a,  0x0a,  0x0a,  0x0a,  0x0a,  0x0a,
-    0x0a};
+static char rflow_thr[] = {    /* rflow threshold */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
+       0x0a
+};
 
 /*  The Cyclom-Ye has placed the sequential chips in non-sequential
  *  address order.  This look-up table overcomes that problem.
  */
-static int cy_chip_offset [] =
-    { 0x0000,
-      0x0400,
-      0x0800,
-      0x0C00,
-      0x0200,
-      0x0600,
-      0x0A00,
-      0x0E00
-    };
+static int cy_chip_offset[] = { 0x0000,
+       0x0400,
+       0x0800,
+       0x0C00,
+       0x0200,
+       0x0600,
+       0x0A00,
+       0x0E00
+};
 
 /* PCI related definitions */
 
-static unsigned short  cy_pci_nboard;
-static unsigned short  cy_isa_nboard;
-static unsigned short  cy_nboard;
+static unsigned short cy_pci_nboard;
+static unsigned short cy_isa_nboard;
+static unsigned short cy_nboard;
 #ifdef CONFIG_PCI
-static unsigned short  cy_pci_dev_id[] = {
-                           PCI_DEVICE_ID_CYCLOM_Y_Lo,  /* PCI < 1Mb */
-                           PCI_DEVICE_ID_CYCLOM_Y_Hi,  /* PCI > 1Mb */
-                           PCI_DEVICE_ID_CYCLOM_4Y_Lo, /* 4Y PCI < 1Mb */
-                           PCI_DEVICE_ID_CYCLOM_4Y_Hi, /* 4Y PCI > 1Mb */
-                           PCI_DEVICE_ID_CYCLOM_8Y_Lo, /* 8Y PCI < 1Mb */
-                           PCI_DEVICE_ID_CYCLOM_8Y_Hi, /* 8Y PCI > 1Mb */
-                           PCI_DEVICE_ID_CYCLOM_Z_Lo,  /* Z PCI < 1Mb */
-                           PCI_DEVICE_ID_CYCLOM_Z_Hi,  /* Z PCI > 1Mb */
-                           0                           /* end of table */
-                       };
+static unsigned short cy_pci_dev_id[] = {
+       PCI_DEVICE_ID_CYCLOM_Y_Lo,      /* PCI < 1Mb */
+       PCI_DEVICE_ID_CYCLOM_Y_Hi,      /* PCI > 1Mb */
+       PCI_DEVICE_ID_CYCLOM_4Y_Lo,     /* 4Y PCI < 1Mb */
+       PCI_DEVICE_ID_CYCLOM_4Y_Hi,     /* 4Y PCI > 1Mb */
+       PCI_DEVICE_ID_CYCLOM_8Y_Lo,     /* 8Y PCI < 1Mb */
+       PCI_DEVICE_ID_CYCLOM_8Y_Hi,     /* 8Y PCI > 1Mb */
+       PCI_DEVICE_ID_CYCLOM_Z_Lo,      /* Z PCI < 1Mb */
+       PCI_DEVICE_ID_CYCLOM_Z_Hi,      /* Z PCI > 1Mb */
+       0                       /* end of table */
+};
 #endif
 
 static void cy_start(struct tty_struct *);
@@ -842,9 +847,9 @@ static void set_line_char(struct cyclades_port *);
 static int cyz_issue_cmd(struct cyclades_card *, uclong, ucchar, uclong);
 #ifdef CONFIG_ISA
 static unsigned detect_isa_irq(void __iomem *);
-#endif /* CONFIG_ISA */
+#endif                         /* CONFIG_ISA */
 
-static int cyclades_get_proc_info(char *, char **, off_t , int , int *, void *);
+static int cyclades_get_proc_info(char *, char **, off_t, int, int *, void *);
 
 #ifndef CONFIG_CYZ_INTR
 static void cyz_poll(unsigned long);
@@ -855,41 +860,36 @@ static long cyz_polling_cycle = CZ_DEF_POLL;
 static int cyz_timeron = 0;
 static DEFINE_TIMER(cyz_timerlist, cyz_poll, 0, 0);
 
-#else /* CONFIG_CYZ_INTR */
+#else                          /* CONFIG_CYZ_INTR */
 static void cyz_rx_restart(unsigned long);
 static struct timer_list cyz_rx_full_timer[NR_PORTS];
-#endif /* CONFIG_CYZ_INTR */
+#endif                         /* CONFIG_CYZ_INTR */
 
-static inline int
-serial_paranoia_check(struct cyclades_port *info,
-                        char *name, const char *routine)
+static inline int serial_paranoia_check(struct cyclades_port *info,
+               char *name, const char *routine)
 {
 #ifdef SERIAL_PARANOIA_CHECK
-    static const char *badmagic =
-        "cyc Warning: bad magic number for serial struct (%s) in %s\n";
-    static const char *badinfo =
-        "cyc Warning: null cyclades_port for (%s) in %s\n";
-    static const char *badrange =
-        "cyc Warning: cyclades_port out of range for (%s) in %s\n";
-
-    if (!info) {
-        printk(badinfo, name, routine);
-        return 1;
-    }
-
-    if( (long)info < (long)(&cy_port[0])
-    || (long)(&cy_port[NR_PORTS]) < (long)info ){
-        printk(badrange, name, routine);
-        return 1;
-    }
-
-    if (info->magic != CYCLADES_MAGIC) {
-        printk(badmagic, name, routine);
-        return 1;
-    }
+       if (!info) {
+               printk("cyc Warning: null cyclades_port for (%s) in %s\n",
+                               name, routine);
+               return 1;
+       }
+
+       if ((long)info < (long)(&cy_port[0]) ||
+                       (long)(&cy_port[NR_PORTS]) < (long)info) {
+               printk("cyc Warning: cyclades_port out of range for (%s) in "
+                               "%s\n", name, routine);
+               return 1;
+       }
+
+       if (info->magic != CYCLADES_MAGIC) {
+               printk("cyc Warning: bad magic number for serial struct (%s) "
+                               "in %s\n", name, routine);
+               return 1;
+       }
 #endif
-        return 0;
-} /* serial_paranoia_check */
+       return 0;
+}                              /* serial_paranoia_check */
 
 /*
  * This routine is used by the interrupt handler to schedule
@@ -897,13 +897,11 @@ serial_paranoia_check(struct cyclades_port *info,
  * (also known as the "bottom half").  This can be called any
  * number of times for any channel without harm.
  */
-static inline void
-cy_sched_event(struct cyclades_port *info, int event)
+static inline void cy_sched_event(struct cyclades_port *info, int event)
 {
-    info->event |= 1 << event; /* remember what kind of event and who */
-    schedule_work(&info->tqueue);
-} /* cy_sched_event */
-
+       info->event |= 1 << event; /* remember what kind of event and who */
+       schedule_work(&info->tqueue);
+}                              /* cy_sched_event */
 
 /*
  * This routine is used to handle the "bottom half" processing for the
@@ -930,41 +928,36 @@ do_softint(struct work_struct *work)
 {
        struct cyclades_port *info =
                container_of(work, struct cyclades_port, tqueue);
-  struct tty_struct    *tty;
-
-    tty = info->tty;
-    if (!tty)
-        return;
-
-    if (test_and_clear_bit(Cy_EVENT_HANGUP, &info->event)) {
-        tty_hangup(info->tty);
-        wake_up_interruptible(&info->open_wait);
-        info->flags &= ~ASYNC_NORMAL_ACTIVE;
-    }
-    if (test_and_clear_bit(Cy_EVENT_OPEN_WAKEUP, &info->event)) {
-        wake_up_interruptible(&info->open_wait);
-    }
+       struct tty_struct    *tty;
+
+       tty = info->tty;
+       if (!tty)
+               return;
+
+       if (test_and_clear_bit(Cy_EVENT_HANGUP, &info->event)) {
+               tty_hangup(info->tty);
+               wake_up_interruptible(&info->open_wait);
+                       info->flags &= ~ASYNC_NORMAL_ACTIVE;
+       }
+       if (test_and_clear_bit(Cy_EVENT_OPEN_WAKEUP, &info->event))
+               wake_up_interruptible(&info->open_wait);
 #ifdef CONFIG_CYZ_INTR
-    if (test_and_clear_bit(Cy_EVENT_Z_RX_FULL, &info->event)) {
-       if (cyz_rx_full_timer[info->line].function == NULL) {
-           cyz_rx_full_timer[info->line].expires = jiffies + 1;
-           cyz_rx_full_timer[info->line].function = cyz_rx_restart;
-           cyz_rx_full_timer[info->line].data = (unsigned long)info;
-           add_timer(&cyz_rx_full_timer[info->line]);
+       if (test_and_clear_bit(Cy_EVENT_Z_RX_FULL, &info->event)) {
+               if (cyz_rx_full_timer[info->line].function == NULL) {
+                       cyz_rx_full_timer[info->line].expires = jiffies + 1;
+                       cyz_rx_full_timer[info->line].function = cyz_rx_restart;
+                       cyz_rx_full_timer[info->line].data =
+                                               (unsigned long)info;
+                       add_timer(&cyz_rx_full_timer[info->line]);
+               }
        }
-    }
 #endif
-    if (test_and_clear_bit(Cy_EVENT_DELTA_WAKEUP, &info->event)) {
-       wake_up_interruptible(&info->delta_msr_wait);
-    }
-    if (test_and_clear_bit(Cy_EVENT_WRITE_WAKEUP, &info->event)) {
-        tty_wakeup(tty);
-        wake_up_interruptible(&tty->write_wait);
-    }
+       if (test_and_clear_bit(Cy_EVENT_DELTA_WAKEUP, &info->event))
+               wake_up_interruptible(&info->delta_msr_wait);
+       tty_wakeup(tty);
 #ifdef Z_WAKE
-    if (test_and_clear_bit(Cy_EVENT_SHUTDOWN_WAKEUP, &info->event)) {
-        wake_up_interruptible(&info->shutdown_wait);
-    }
+       if (test_and_clear_bit(Cy_EVENT_SHUTDOWN_WAKEUP, &info->event))
+               wake_up_interruptible(&info->shutdown_wait);
 #endif
 } /* do_softint */
 
@@ -979,341 +972,339 @@ do_softint(struct work_struct *work)
 
    This function is only called from inside spinlock-protected code.
  */
-static int
-cyy_issue_cmd(void __iomem *base_addr, u_char cmd, int index)
+static int cyy_issue_cmd(void __iomem * base_addr, u_char cmd, int index)
 {
-  volatile int  i;
+       volatile int i;
 
-    /* Check to see that the previous command has completed */
-    for(i = 0 ; i < 100 ; i++){
-       if (cy_readb(base_addr+(CyCCR<<index)) == 0){
-           break;
+       /* Check to see that the previous command has completed */
+       for (i = 0; i < 100; i++) {
+               if (cy_readb(base_addr + (CyCCR << index)) == 0) {
+                       break;
+               }
+               udelay(10L);
        }
-       udelay(10L);
-    }
-    /* if the CCR never cleared, the previous command
-       didn't finish within the "reasonable time" */
-    if (i == 100)      return (-1);
+       /* if the CCR never cleared, the previous command
+          didn't finish within the "reasonable time" */
+       if (i == 100)
+               return -1;
 
-    /* Issue the new command */
-    cy_writeb(base_addr+(CyCCR<<index), cmd);
+       /* Issue the new command */
+       cy_writeb(base_addr + (CyCCR << index), cmd);
 
-    return(0);
-} /* cyy_issue_cmd */
+       return 0;
+}                              /* cyy_issue_cmd */
 
 #ifdef CONFIG_ISA
 /* ISA interrupt detection code */
-static unsigned 
-detect_isa_irq(void __iomem *address)
+static unsigned detect_isa_irq(void __iomem * address)
 {
-  int irq;
-  unsigned long irqs, flags;
-  int save_xir, save_car;
-  int index = 0; /* IRQ probing is only for ISA */
-
-    /* forget possible initially masked and pending IRQ */
-    irq = probe_irq_off(probe_irq_on());
-
-    /* Clear interrupts on the board first */
-    cy_writeb(address + (Cy_ClrIntr<<index), 0);
-                             /* Cy_ClrIntr is 0x1800 */
-
-    irqs = probe_irq_on();
-    /* Wait ... */
-    udelay(5000L);
-
-    /* Enable the Tx interrupts on the CD1400 */
-    local_irq_save(flags);
-       cy_writeb(address + (CyCAR<<index), 0);
-       cyy_issue_cmd(address, CyCHAN_CTL|CyENB_XMTR, index);
-
-       cy_writeb(address + (CyCAR<<index), 0);
-       cy_writeb(address + (CySRER<<index), 
-               cy_readb(address + (CySRER<<index)) | CyTxRdy);
-    local_irq_restore(flags);
-
-    /* Wait ... */
-    udelay(5000L);
-
-    /* Check which interrupt is in use */
-    irq = probe_irq_off(irqs);
-
-    /* Clean up */
-    save_xir = (u_char) cy_readb(address + (CyTIR<<index));
-    save_car = cy_readb(address + (CyCAR<<index));
-    cy_writeb(address + (CyCAR<<index), (save_xir & 0x3));
-    cy_writeb(address + (CySRER<<index),
-       cy_readb(address + (CySRER<<index)) & ~CyTxRdy);
-    cy_writeb(address + (CyTIR<<index), (save_xir & 0x3f));
-    cy_writeb(address + (CyCAR<<index), (save_car));
-    cy_writeb(address + (Cy_ClrIntr<<index), 0);
-                             /* Cy_ClrIntr is 0x1800 */
-
-    return (irq > 0)? irq : 0;
+       int irq;
+       unsigned long irqs, flags;
+       int save_xir, save_car;
+       int index = 0;          /* IRQ probing is only for ISA */
+
+       /* forget possible initially masked and pending IRQ */
+       irq = probe_irq_off(probe_irq_on());
+
+       /* Clear interrupts on the board first */
+       cy_writeb(address + (Cy_ClrIntr << index), 0);
+       /* Cy_ClrIntr is 0x1800 */
+
+       irqs = probe_irq_on();
+       /* Wait ... */
+       udelay(5000L);
+
+       /* Enable the Tx interrupts on the CD1400 */
+       local_irq_save(flags);
+       cy_writeb(address + (CyCAR << index), 0);
+       cyy_issue_cmd(address, CyCHAN_CTL | CyENB_XMTR, index);
+
+       cy_writeb(address + (CyCAR << index), 0);
+       cy_writeb(address + (CySRER << index),
+                 cy_readb(address + (CySRER << index)) | CyTxRdy);
+       local_irq_restore(flags);
+
+       /* Wait ... */
+       udelay(5000L);
+
+       /* Check which interrupt is in use */
+       irq = probe_irq_off(irqs);
+
+       /* Clean up */
+       save_xir = (u_char) cy_readb(address + (CyTIR << index));
+       save_car = cy_readb(address + (CyCAR << index));
+       cy_writeb(address + (CyCAR << index), (save_xir & 0x3));
+       cy_writeb(address + (CySRER << index),
+                 cy_readb(address + (CySRER << index)) & ~CyTxRdy);
+       cy_writeb(address + (CyTIR << index), (save_xir & 0x3f));
+       cy_writeb(address + (CyCAR << index), (save_car));
+       cy_writeb(address + (Cy_ClrIntr << index), 0);
+       /* Cy_ClrIntr is 0x1800 */
+
+       return (irq > 0) ? irq : 0;
 }
-#endif /* CONFIG_ISA */
+#endif                         /* CONFIG_ISA */
 
-/* The real interrupt service routine is called
-   whenever the card wants its hand held--chars
-   received, out buffer empty, modem change, etc.
- */
-static irqreturn_t
-cyy_interrupt(int irq, void *dev_id)
+static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
+                       void __iomem * base_addr, int status, int index)
 {
-  struct tty_struct *tty;
-  int status;
-  struct cyclades_card *cinfo;
-  struct cyclades_port *info;
-  void __iomem *base_addr, *card_base_addr;
-  int chip;
-  int save_xir, channel, save_car;
-  char data;
-  volatile int char_count;
-  int outch;
-  int i,j,index;
-  int too_many;
-  int had_work;
-  int mdm_change;
-  int mdm_status;
-  int len;
-    if((cinfo = (struct cyclades_card *)dev_id) == 0){
-#ifdef CY_DEBUG_INTERRUPTS
-       printk("cyy_interrupt: spurious interrupt %d\n\r", irq);
-#endif
-        return IRQ_NONE; /* spurious interrupt */
-    }
-
-    card_base_addr = cinfo->base_addr;
-    index = cinfo->bus_index;
-
-
-    /* This loop checks all chips in the card.  Make a note whenever
-       _any_ chip had some work to do, as this is considered an
-       indication that there will be more to do.  Only when no chip
-       has any work does this outermost loop exit.
-     */
-    do{
-        had_work = 0;
-        for ( chip = 0 ; chip < cinfo->num_chips ; chip ++) {
-            base_addr = cinfo->base_addr + (cy_chip_offset[chip]<<index);
-            too_many = 0;
-            while ( (status = cy_readb(base_addr+(CySVRR<<index))) != 0x00) {
-                had_work++;
-                /* The purpose of the following test is to ensure that
-                   no chip can monopolize the driver.  This forces the
-                   chips to be checked in a round-robin fashion (after
-                   draining each of a bunch (1000) of characters).
-                 */
-                if(1000<too_many++){
-                    break;
-                }
-                if (status & CySRReceive) { /* reception interrupt */
+       struct cyclades_port *info;
+       struct tty_struct *tty;
+       volatile int char_count;
+       int i, j, len, mdm_change, mdm_status, outch;
+       int save_xir, channel, save_car;
+       char data;
+
+       if (status & CySRReceive) {     /* reception interrupt */
 #ifdef CY_DEBUG_INTERRUPTS
-                   printk("cyy_interrupt: rcvd intr, chip %d\n\r", chip);
+               printk("cyy_interrupt: rcvd intr, chip %d\n\r", chip);
 #endif
-                    /* determine the channel & change to that context */
-                   spin_lock(&cinfo->card_lock);
-                    save_xir = (u_char) cy_readb(base_addr+(CyRIR<<index));
-                    channel = (u_short ) (save_xir & CyIRChannel);
-                    i = channel + chip * 4 + cinfo->first_line;
-                    info = &cy_port[i];
-                    info->last_active = jiffies;
-                    save_car = cy_readb(base_addr+(CyCAR<<index));
-                    cy_writeb(base_addr+(CyCAR<<index), save_xir);
-
-                    /* if there is nowhere to put the data, discard it */
-                    if(info->tty == 0){
-                        j = (cy_readb(base_addr+(CyRIVR<<index)) & CyIVRMask);
-                        if ( j == CyIVRRxEx ) { /* exception */
-                            data = cy_readb(base_addr+(CyRDSR<<index));
-                        } else { /* normal character reception */
-                            char_count = cy_readb(base_addr+(CyRDCR<<index));
-                            while(char_count--){
-                                data = cy_readb(base_addr+(CyRDSR<<index));
-                            }
-                        }
-                    }else{ /* there is an open port for this data */
-                        tty = info->tty;
-                        j = (cy_readb(base_addr+(CyRIVR<<index)) & CyIVRMask);
-                        if ( j == CyIVRRxEx ) { /* exception */
-                            data = cy_readb(base_addr+(CyRDSR<<index));
-
-                           /* For statistics only */
-                           if (data & CyBREAK)
-                               info->icount.brk++;
-                           else if(data & CyFRAME)
-                               info->icount.frame++;
-                           else if(data & CyPARITY)
-                               info->icount.parity++;
-                           else if(data & CyOVERRUN)
-                               info->icount.overrun++;
-
-                            if(data & info->ignore_status_mask){
-                               info->icount.rx++;
-                                continue;
-                            }
-                            if (tty_buffer_request_room(tty, 1)) {
-                                if (data & info->read_status_mask){
-                                    if(data & CyBREAK){
-                                        tty_insert_flip_char(tty, cy_readb(base_addr+(CyRDSR<<index)), TTY_BREAK);
-                                       info->icount.rx++;
-                                        if (info->flags & ASYNC_SAK){
-                                            do_SAK(tty);
-                                        }
-                                    }else if(data & CyFRAME){
-                                        tty_insert_flip_char(tty, cy_readb(base_addr+(CyRDSR<<index)), TTY_FRAME);
-                                       info->icount.rx++;
-                                       info->idle_stats.frame_errs++;
-                                    }else if(data & CyPARITY){
-                                       /* Pieces of seven... */
-                                        tty_insert_flip_char(tty, cy_readb(base_addr+(CyRDSR<<index)), TTY_PARITY);
-                                       info->icount.rx++;
-                                       info->idle_stats.parity_errs++;
-                                    }else if(data & CyOVERRUN){
-                                        tty_insert_flip_char(tty, 0, TTY_OVERRUN);
+               /* determine the channel & change to that context */
+               spin_lock(&cinfo->card_lock);
+               save_xir = (u_char) cy_readb(base_addr + (CyRIR << index));
+               channel = (u_short) (save_xir & CyIRChannel);
+               i = channel + chip * 4 + cinfo->first_line;
+               info = &cy_port[i];
+               info->last_active = jiffies;
+               save_car = cy_readb(base_addr + (CyCAR << index));
+               cy_writeb(base_addr + (CyCAR << index), save_xir);
+
+               /* if there is nowhere to put the data, discard it */
+               if (info->tty == 0) {
+                       j = (cy_readb(base_addr + (CyRIVR << index)) &
+                               CyIVRMask);
+                       if (j == CyIVRRxEx) {   /* exception */
+                               data = cy_readb(base_addr + (CyRDSR << index));
+                       } else {        /* normal character reception */
+                               char_count = cy_readb(base_addr +
+                                               (CyRDCR << index));
+                               while (char_count--) {
+                                       data = cy_readb(base_addr +
+                                               (CyRDSR << index));
+                               }
+                       }
+               } else {        /* there is an open port for this data */
+                       tty = info->tty;
+                       j = (cy_readb(base_addr + (CyRIVR << index)) &
+                                       CyIVRMask);
+                       if (j == CyIVRRxEx) {   /* exception */
+                               data = cy_readb(base_addr + (CyRDSR << index));
+
+                               /* For statistics only */
+                               if (data & CyBREAK)
+                                       info->icount.brk++;
+                               else if (data & CyFRAME)
+                                       info->icount.frame++;
+                               else if (data & CyPARITY)
+                                       info->icount.parity++;
+                               else if (data & CyOVERRUN)
+                                       info->icount.overrun++;
+
+                               if (data & info->ignore_status_mask) {
                                        info->icount.rx++;
-                                        /* If the flip buffer itself is
-                                           overflowing, we still lose
-                                           the next incoming character.
-                                         */
-                                        tty_insert_flip_char(tty, cy_readb(base_addr+(CyRDSR<<index)), TTY_FRAME);
-                                       info->icount.rx++;
+                                       return;
+                               }
+                               if (tty_buffer_request_room(tty, 1)) {
+                                       if (data & info->read_status_mask) {
+                                               if (data & CyBREAK) {
+                                                       tty_insert_flip_char(
+                                                               tty,
+                                                               cy_readb(
+                                                               base_addr +
+                                                               (CyRDSR <<
+                                                                       index)),
+                                                               TTY_BREAK);
+                                                       info->icount.rx++;
+                                                       if (info->flags &
+                                                           ASYNC_SAK) {
+                                                               do_SAK(tty);
+                                                       }
+                                               } else if (data & CyFRAME) {
+                                                       tty_insert_flip_char(
+                                                               tty,
+                                                               cy_readb(
+                                                               base_addr +
+                                                               (CyRDSR <<
+                                                                       index)),
+                                                               TTY_FRAME);
+                                                       info->icount.rx++;
+                                                       info->idle_stats.
+                                                               frame_errs++;
+                                               } else if (data & CyPARITY) {
+                                                       /* Pieces of seven... */
+                                                       tty_insert_flip_char(
+                                                               tty,
+                                                               cy_readb(
+                                                               base_addr +
+                                                               (CyRDSR <<
+                                                                       index)),
+                                                               TTY_PARITY);
+                                                       info->icount.rx++;
+                                                       info->idle_stats.
+                                                               parity_errs++;
+                                               } else if (data & CyOVERRUN) {
+                                                       tty_insert_flip_char(
+                                                               tty, 0,
+                                                               TTY_OVERRUN);
+                                                       info->icount.rx++;
+                                               /* If the flip buffer itself is
+                                                  overflowing, we still lose
+                                                  the next incoming character.
+                                                */
+                                                       tty_insert_flip_char(
+                                                               tty,
+                                                               cy_readb(
+                                                               base_addr +
+                                                               (CyRDSR <<
+                                                                       index)),
+                                                               TTY_FRAME);
+                                                       info->icount.rx++;
+                                                       info->idle_stats.
+                                                               overruns++;
+                                       /* These two conditions may imply */
+                                       /* a normal read should be done. */
+                                       /* }else if(data & CyTIMEOUT){ */
+                                       /* }else if(data & CySPECHAR){ */
+                                               } else {
+                                                       tty_insert_flip_char(
+                                                               tty, 0,
+                                                               TTY_NORMAL);
+                                                       info->icount.rx++;
+                                               }
+                                       } else {
+                                               tty_insert_flip_char(tty, 0,
+                                                               TTY_NORMAL);
+                                               info->icount.rx++;
+                                       }
+                               } else {
+                                       /* there was a software buffer
+                                          overrun and nothing could be
+                                          done about it!!! */
+                                       info->icount.buf_overrun++;
                                        info->idle_stats.overruns++;
-                                    /* These two conditions may imply */
-                                    /* a normal read should be done. */
-                                    /* }else if(data & CyTIMEOUT){ */
-                                    /* }else if(data & CySPECHAR){ */
-                                    }else {
-                                       tty_insert_flip_char(tty, 0, TTY_NORMAL);
-                                       info->icount.rx++;
-                                    }
-                                }else{
-                                   tty_insert_flip_char(tty, 0, TTY_NORMAL);
-                                   info->icount.rx++;
-                                }
-                            }else{
-                                /* there was a software buffer
-                                  overrun and nothing could be
-                                  done about it!!! */
-                               info->icount.buf_overrun++;
-                               info->idle_stats.overruns++;
-                            }
-                        } else { /* normal character reception */
-                            /* load # chars available from the chip */
-                            char_count = cy_readb(base_addr+(CyRDCR<<index));
+                               }
+                       } else {        /* normal character reception */
+                               /* load # chars available from the chip */
+                               char_count = cy_readb(base_addr +
+                                               (CyRDCR << index));
 
 #ifdef CY_ENABLE_MONITORING
-                            ++info->mon.int_count;
-                            info->mon.char_count += char_count;
-                            if (char_count > info->mon.char_max)
-                               info->mon.char_max = char_count;
-                            info->mon.char_last = char_count;
+                               ++info->mon.int_count;
+                               info->mon.char_count += char_count;
+                               if (char_count > info->mon.char_max)
+                                       info->mon.char_max = char_count;
+                               info->mon.char_last = char_count;
 #endif
-                           len = tty_buffer_request_room(tty, char_count);
-                            while(len--){
-                                data = cy_readb(base_addr+(CyRDSR<<index));
-                               tty_insert_flip_char(tty, data, TTY_NORMAL);
-                               info->idle_stats.recv_bytes++;
-                               info->icount.rx++;
+                               len = tty_buffer_request_room(tty, char_count);
+                               while (len--) {
+                                       data = cy_readb(base_addr +
+                                                       (CyRDSR << index));
+                                       tty_insert_flip_char(tty, data,
+                                                       TTY_NORMAL);
+                                       info->idle_stats.recv_bytes++;
+                                       info->icount.rx++;
 #ifdef CY_16Y_HACK
-                                udelay(10L);
+                                       udelay(10L);
 #endif
-                            }
-                             info->idle_stats.recv_idle = jiffies;
-                        }
+                               }
+                               info->idle_stats.recv_idle = jiffies;
+                       }
                        tty_schedule_flip(tty);
-                    }
-                    /* end of service */
-                    cy_writeb(base_addr+(CyRIR<<index), (save_xir & 0x3f));
-                    cy_writeb(base_addr+(CyCAR<<index), (save_car));
-                   spin_unlock(&cinfo->card_lock);
-                }
-
-
-                if (status & CySRTransmit) { /* transmission interrupt */
-                    /* Since we only get here when the transmit buffer
-                       is empty, we know we can always stuff a dozen
-                       characters. */
+               }
+               /* end of service */
+               cy_writeb(base_addr + (CyRIR << index), (save_xir & 0x3f));
+               cy_writeb(base_addr + (CyCAR << index), (save_car));
+               spin_unlock(&cinfo->card_lock);
+       }
+
+       if (status & CySRTransmit) {    /* transmission interrupt */
+               /* Since we only get here when the transmit buffer
+                  is empty, we know we can always stuff a dozen
+                  characters. */
 #ifdef CY_DEBUG_INTERRUPTS
-                   printk("cyy_interrupt: xmit intr, chip %d\n\r", chip);
+               printk("cyy_interrupt: xmit intr, chip %d\n\r", chip);
 #endif
 
-                    /* determine the channel & change to that context */
-                   spin_lock(&cinfo->card_lock);
-                    save_xir = (u_char) cy_readb(base_addr+(CyTIR<<index));
-                    channel = (u_short ) (save_xir & CyIRChannel);
-                    i = channel + chip * 4 + cinfo->first_line;
-                    save_car = cy_readb(base_addr+(CyCAR<<index));
-                    cy_writeb(base_addr+(CyCAR<<index), save_xir);
-
-                    /* validate the port# (as configured and open) */
-                    if( (i < 0) || (NR_PORTS <= i) ){
-                        cy_writeb(base_addr+(CySRER<<index),
-                             cy_readb(base_addr+(CySRER<<index)) & ~CyTxRdy);
-                        goto txend;
-                    }
-                    info = &cy_port[i];
-                    info->last_active = jiffies;
-                    if(info->tty == 0){
-                        cy_writeb(base_addr+(CySRER<<index),
-                             cy_readb(base_addr+(CySRER<<index)) & ~CyTxRdy);
-                        goto txdone;
-                    }
-
-                    /* load the on-chip space for outbound data */
-                    char_count = info->xmit_fifo_size;
-
-                    if(info->x_char) { /* send special char */
-                        outch = info->x_char;
-                        cy_writeb(base_addr+(CyTDR<<index), outch);
-                        char_count--;
+               /* determine the channel & change to that context */
+               spin_lock(&cinfo->card_lock);
+               save_xir = (u_char) cy_readb(base_addr + (CyTIR << index));
+               channel = (u_short) (save_xir & CyIRChannel);
+               i = channel + chip * 4 + cinfo->first_line;
+               save_car = cy_readb(base_addr + (CyCAR << index));
+               cy_writeb(base_addr + (CyCAR << index), save_xir);
+
+               /* validate the port# (as configured and open) */
+               if ((i < 0) || (NR_PORTS <= i)) {
+                       cy_writeb(base_addr + (CySRER << index),
+                                 cy_readb(base_addr + (CySRER << index)) &
+                                 ~CyTxRdy);
+                       goto txend;
+               }
+               info = &cy_port[i];
+               info->last_active = jiffies;
+               if (info->tty == 0) {
+                       cy_writeb(base_addr + (CySRER << index),
+                                 cy_readb(base_addr + (CySRER << index)) &
+                                 ~CyTxRdy);
+                       goto txdone;
+               }
+
+               /* load the on-chip space for outbound data */
+               char_count = info->xmit_fifo_size;
+
+               if (info->x_char) {     /* send special char */
+                       outch = info->x_char;
+                       cy_writeb(base_addr + (CyTDR << index), outch);
+                       char_count--;
                        info->icount.tx++;
-                        info->x_char = 0;
-                    }
+                       info->x_char = 0;
+               }
 
-                    if (info->breakon || info->breakoff) {
+               if (info->breakon || info->breakoff) {
                        if (info->breakon) {
-                           cy_writeb(base_addr + (CyTDR<<index), 0); 
-                           cy_writeb(base_addr + (CyTDR<<index), 0x81);
-                           info->breakon = 0;
-                            char_count -= 2;
+                               cy_writeb(base_addr + (CyTDR << index), 0);
+                               cy_writeb(base_addr + (CyTDR << index), 0x81);
+                               info->breakon = 0;
+                               char_count -= 2;
                        }
                        if (info->breakoff) {
-                           cy_writeb(base_addr + (CyTDR<<index), 0); 
-                           cy_writeb(base_addr + (CyTDR<<index), 0x83);
-                           info->breakoff = 0;
-                            char_count -= 2;
+                               cy_writeb(base_addr + (CyTDR << index), 0);
+                               cy_writeb(base_addr + (CyTDR << index), 0x83);
+                               info->breakoff = 0;
+                               char_count -= 2;
                        }
-                    }
-
-                    while (char_count-- > 0){
-                       if (!info->xmit_cnt){
-                           if (cy_readb(base_addr+(CySRER<<index))&CyTxMpty) {
-                               cy_writeb(base_addr+(CySRER<<index),
-                                         cy_readb(base_addr+(CySRER<<index)) &
-                                         ~CyTxMpty);
-                           } else {
-                               cy_writeb(base_addr+(CySRER<<index),
-                                         ((cy_readb(base_addr+(CySRER<<index))
-                                           & ~CyTxRdy)
-                                          | CyTxMpty));
-                           }
-                           goto txdone;
+               }
+
+               while (char_count-- > 0) {
+                       if (!info->xmit_cnt) {
+                               if (cy_readb(base_addr + (CySRER << index)) &
+                                               CyTxMpty) {
+                                       cy_writeb(base_addr + (CySRER << index),
+                                               cy_readb(base_addr +
+                                                       (CySRER << index)) &
+                                               ~CyTxMpty);
+                               } else {
+                                       cy_writeb(base_addr + (CySRER << index),
+                                               (cy_readb(base_addr +
+                                                       (CySRER << index)) &
+                                               ~CyTxRdy) | CyTxMpty);
+                               }
+                               goto txdone;
                        }
-                       if (info->xmit_buf == 0){
-                            cy_writeb(base_addr+(CySRER<<index),
-                               cy_readb(base_addr+(CySRER<<index)) & 
+                       if (info->xmit_buf == 0) {
+                               cy_writeb(base_addr + (CySRER << index),
+                                       cy_readb(base_addr + (CySRER << index))&
                                        ~CyTxRdy);
-                            goto txdone;
+                               goto txdone;
                        }
-                       if (info->tty->stopped || info->tty->hw_stopped){
-                            cy_writeb(base_addr+(CySRER<<index),
-                               cy_readb(base_addr+(CySRER<<index)) & 
+                       if (info->tty->stopped || info->tty->hw_stopped) {
+                               cy_writeb(base_addr + (CySRER << index),
+                                       cy_readb(base_addr + (CySRER << index))&
                                        ~CyTxRdy);
-                            goto txdone;
+                               goto txdone;
                        }
-                        /* Because the Embedded Transmit Commands have
-                           been enabled, we must check to see if the
+                       /* Because the Embedded Transmit Commands have
+                          been enabled, we must check to see if the
                           escape character, NULL, is being sent.  If it
                           is, we must ensure that there is room for it
                           to be doubled in the output stream.  Therefore
@@ -1322,125 +1313,182 @@ cyy_interrupt(int irq, void *dev_id)
                           after the check for a NULL output character.
                           This is necessary because there may not be
                           room for the two chars needed to send a NULL.)
-                         */
-                        outch = info->xmit_buf[info->xmit_tail];
-                        if( outch ){
-                            info->xmit_cnt--;
-                            info->xmit_tail = (info->xmit_tail + 1)
-                                                      & (SERIAL_XMIT_SIZE - 1);
-                            cy_writeb(base_addr+(CyTDR<<index), outch);
-                           info->icount.tx++;
-                        }else{
-                            if(char_count > 1){
-                                info->xmit_cnt--;
-                                info->xmit_tail = (info->xmit_tail + 1)
-                                                     & (SERIAL_XMIT_SIZE - 1);
-                                cy_writeb(base_addr+(CyTDR<<index), 
-                                         outch);
-                                cy_writeb(base_addr+(CyTDR<<index), 0);
+                        */
+                       outch = info->xmit_buf[info->xmit_tail];
+                       if (outch) {
+                               info->xmit_cnt--;
+                               info->xmit_tail = (info->xmit_tail + 1) &
+                                               (SERIAL_XMIT_SIZE - 1);
+                               cy_writeb(base_addr + (CyTDR << index), outch);
                                info->icount.tx++;
-                                char_count--;
-                            }else{
-                            }
-                        }
-                    }
-
-        txdone:
-                    if (info->xmit_cnt < WAKEUP_CHARS) {
-                        cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
-                    }
-        txend:
-                    /* end of service */
-                    cy_writeb(base_addr+(CyTIR<<index), 
-                             (save_xir & 0x3f));
-                    cy_writeb(base_addr+(CyCAR<<index), (save_car));
-                   spin_unlock(&cinfo->card_lock);
-                }
-
-                if (status & CySRModem) {        /* modem interrupt */
-
-                    /* determine the channel & change to that context */
-                   spin_lock(&cinfo->card_lock);
-                    save_xir = (u_char) cy_readb(base_addr+(CyMIR<<index));
-                    channel = (u_short ) (save_xir & CyIRChannel);
-                    info = &cy_port[channel + chip * 4
-                                          + cinfo->first_line];
-                    info->last_active = jiffies;
-                    save_car = cy_readb(base_addr+(CyCAR<<index));
-                    cy_writeb(base_addr+(CyCAR<<index), save_xir);
-
-                    mdm_change = cy_readb(base_addr+(CyMISR<<index));
-                    mdm_status = cy_readb(base_addr+(CyMSVR1<<index));
-
-                    if(info->tty == 0){/* no place for data, ignore it*/
-                        ;
-                    }else{
+                       } else {
+                               if (char_count > 1) {
+                                       info->xmit_cnt--;
+                                       info->xmit_tail = (info->xmit_tail + 1)&
+                                               (SERIAL_XMIT_SIZE - 1);
+                                       cy_writeb(base_addr + (CyTDR << index),
+                                               outch);
+                                       cy_writeb(base_addr + (CyTDR << index),
+                                               0);
+                                       info->icount.tx++;
+                                       char_count--;
+                               } else {
+                               }
+                       }
+               }
+
+txdone:
+               if (info->xmit_cnt < WAKEUP_CHARS) {
+                       cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
+               }
+txend:
+               /* end of service */
+               cy_writeb(base_addr + (CyTIR << index), (save_xir & 0x3f));
+               cy_writeb(base_addr + (CyCAR << index), (save_car));
+               spin_unlock(&cinfo->card_lock);
+       }
+
+       if (status & CySRModem) {       /* modem interrupt */
+
+               /* determine the channel & change to that context */
+               spin_lock(&cinfo->card_lock);
+               save_xir = (u_char) cy_readb(base_addr + (CyMIR << index));
+               channel = (u_short) (save_xir & CyIRChannel);
+               info = &cy_port[channel + chip * 4 + cinfo->first_line];
+               info->last_active = jiffies;
+               save_car = cy_readb(base_addr + (CyCAR << index));
+               cy_writeb(base_addr + (CyCAR << index), save_xir);
+
+               mdm_change = cy_readb(base_addr + (CyMISR << index));
+               mdm_status = cy_readb(base_addr + (CyMSVR1 << index));
+
+               if (info->tty == 0) {   /* no place for data, ignore it */
+                       ;
+               } else {
                        if (mdm_change & CyANY_DELTA) {
-                           /* For statistics only */
-                           if (mdm_change & CyDCD)     info->icount.dcd++;
-                           if (mdm_change & CyCTS)     info->icount.cts++;
-                           if (mdm_change & CyDSR)     info->icount.dsr++;
-                           if (mdm_change & CyRI)      info->icount.rng++;
+                               /* For statistics only */
+                               if (mdm_change & CyDCD)
+                                       info->icount.dcd++;
+                               if (mdm_change & CyCTS)
+                                       info->icount.cts++;
+                               if (mdm_change & CyDSR)
+                                       info->icount.dsr++;
+                               if (mdm_change & CyRI)
+                                       info->icount.rng++;
+
+                               cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP);
+                       }
+
+                       if ((mdm_change & CyDCD) &&
+                                       (info->flags & ASYNC_CHECK_CD)) {
+                               if (mdm_status & CyDCD) {
+                                       cy_sched_event(info,
+                                                       Cy_EVENT_OPEN_WAKEUP);
+                               } else {
+                                       cy_sched_event(info, Cy_EVENT_HANGUP);
+                               }
+                       }
+                       if ((mdm_change & CyCTS) &&
+                                       (info->flags & ASYNC_CTS_FLOW)) {
+                               if (info->tty->hw_stopped) {
+                                       if (mdm_status & CyCTS) {
+                                               /* cy_start isn't used
+                                                  because... !!! */
+                                               info->tty->hw_stopped = 0;
+                                               cy_writeb(base_addr +
+                                                       (CySRER << index),
+                                                       cy_readb(base_addr +
+                                                               (CySRER <<
+                                                                       index))|
+                                                       CyTxRdy);
+                                               cy_sched_event(info,
+                                                       Cy_EVENT_WRITE_WAKEUP);
+                                       }
+                               } else {
+                                       if (!(mdm_status & CyCTS)) {
+                                               /* cy_stop isn't used
+                                                  because ... !!! */
+                                               info->tty->hw_stopped = 1;
+                                               cy_writeb(base_addr +
+                                                       (CySRER << index),
+                                                       cy_readb(base_addr +
+                                                               (CySRER <<
+                                                               index)) &
+                                                       ~CyTxRdy);
+                                       }
+                               }
+                       }
+                       if (mdm_change & CyDSR) {
+                       }
+                       if (mdm_change & CyRI) {
+                       }
+               }
+               /* end of service */
+               cy_writeb(base_addr + (CyMIR << index), (save_xir & 0x3f));
+               cy_writeb(base_addr + (CyCAR << index), save_car);
+               spin_unlock(&cinfo->card_lock);
+       }
+}
 
-                           cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP);
+/* The real interrupt service routine is called
+   whenever the card wants its hand held--chars
+   received, out buffer empty, modem change, etc.
+ */
+static irqreturn_t cyy_interrupt(int irq, void *dev_id)
+{
+       int status;
+       struct cyclades_card *cinfo;
+       void __iomem *base_addr, *card_base_addr;
+       int chip;
+       int index;
+       int too_many;
+       int had_work;
+
+       if ((cinfo = (struct cyclades_card *)dev_id) == 0) {
+#ifdef CY_DEBUG_INTERRUPTS
+               printk("cyy_interrupt: spurious interrupt %d\n\r", irq);
+#endif
+               return IRQ_NONE;        /* spurious interrupt */
+       }
+
+       card_base_addr = cinfo->base_addr;
+       index = cinfo->bus_index;
+
+       /* This loop checks all chips in the card.  Make a note whenever
+          _any_ chip had some work to do, as this is considered an
+          indication that there will be more to do.  Only when no chip
+          has any work does this outermost loop exit.
+        */
+       do {
+               had_work = 0;
+               for (chip = 0; chip < cinfo->num_chips; chip++) {
+                       base_addr = cinfo->base_addr +
+                                       (cy_chip_offset[chip] << index);
+                       too_many = 0;
+                       while ((status = cy_readb(base_addr +
+                                               (CySVRR << index))) != 0x00) {
+                               had_work++;
+                       /* The purpose of the following test is to ensure that
+                          no chip can monopolize the driver.  This forces the
+                          chips to be checked in a round-robin fashion (after
+                          draining each of a bunch (1000) of characters).
+                        */
+                               if (1000 < too_many++) {
+                                       break;
+                               }
+                               cyy_intr_chip(cinfo, chip, base_addr, status,
+                                               index);
                        }
+               }
+       } while (had_work);
 
-                        if((mdm_change & CyDCD)
-                        && (info->flags & ASYNC_CHECK_CD)){
-                            if(mdm_status & CyDCD){
-                                cy_sched_event(info,
-                                   Cy_EVENT_OPEN_WAKEUP);
-                            }else{
-                                cy_sched_event(info,
-                                   Cy_EVENT_HANGUP);
-                            }
-                        }
-                        if((mdm_change & CyCTS)
-                        && (info->flags & ASYNC_CTS_FLOW)){
-                            if(info->tty->hw_stopped){
-                                if(mdm_status & CyCTS){
-                                    /* cy_start isn't used
-                                        because... !!! */
-                                    info->tty->hw_stopped = 0;
-                                  cy_writeb(base_addr+(CySRER<<index),
-                                       cy_readb(base_addr+(CySRER<<index)) | 
-                                       CyTxRdy);
-                                    cy_sched_event(info,
-                                       Cy_EVENT_WRITE_WAKEUP);
-                                }
-                            }else{
-                                if(!(mdm_status & CyCTS)){
-                                    /* cy_stop isn't used
-                                        because ... !!! */
-                                    info->tty->hw_stopped = 1;
-                                  cy_writeb(base_addr+(CySRER<<index),
-                                       cy_readb(base_addr+(CySRER<<index)) & 
-                                       ~CyTxRdy);
-                                }
-                            }
-                        }
-                        if(mdm_change & CyDSR){
-                        }
-                        if(mdm_change & CyRI){
-                        }
-                    }
-                    /* end of service */
-                    cy_writeb(base_addr+(CyMIR<<index), 
-                             (save_xir & 0x3f));
-                    cy_writeb(base_addr+(CyCAR<<index), save_car);
-                   spin_unlock(&cinfo->card_lock);
-                }
-            }          /* end while status != 0 */
-        }            /* end loop for chips... */
-    } while(had_work);
-
-   /* clear interrupts */
-   spin_lock(&cinfo->card_lock);
-   cy_writeb(card_base_addr + (Cy_ClrIntr<<index), 0);
-                                /* Cy_ClrIntr is 0x1800 */
-   spin_unlock(&cinfo->card_lock);
-   return IRQ_HANDLED;
-} /* cyy_interrupt */
+       /* clear interrupts */
+       spin_lock(&cinfo->card_lock);
+       cy_writeb(card_base_addr + (Cy_ClrIntr << index), 0);
+       /* Cy_ClrIntr is 0x1800 */
+       spin_unlock(&cinfo->card_lock);
+       return IRQ_HANDLED;
+}                              /* cyy_interrupt */
 
 /***********************************************************/
 /********* End of block of Cyclom-Y specific code **********/
@@ -1448,643 +1496,655 @@ cyy_interrupt(int irq, void *dev_id)
 /***********************************************************/
 
 static int
-cyz_fetch_msg( struct cyclades_card *cinfo,
-           uclong *channel, ucchar *cmd, uclong *param)
+cyz_fetch_msg(struct cyclades_card *cinfo,
+               uclong * channel, ucchar * cmd, uclong * param)
 {
-  struct FIRM_ID __iomem *firm_id;
-  struct ZFW_CTRL __iomem *zfw_ctrl;
-  struct BOARD_CTRL __iomem *board_ctrl;
-  unsigned long loc_doorbell;
-
-    firm_id = cinfo->base_addr + ID_ADDRESS;
-    if (!ISZLOADED(*cinfo)){
-       return (-1);
-    }
-    zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
-    board_ctrl = &zfw_ctrl->board_ctrl;
-
-    loc_doorbell = cy_readl(&((struct RUNTIME_9060 __iomem *)
-                     (cinfo->ctl_addr))->loc_doorbell);
-    if (loc_doorbell){
-       *cmd = (char)(0xff & loc_doorbell);
-       *channel = cy_readl(&board_ctrl->fwcmd_channel);
-       *param = (uclong)cy_readl(&board_ctrl->fwcmd_param);
-       cy_writel(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->loc_doorbell, 
-                 0xffffffff);
-       return 1;
-    }
-    return 0;
-} /* cyz_fetch_msg */
+       struct FIRM_ID __iomem *firm_id;
+       struct ZFW_CTRL __iomem *zfw_ctrl;
+       struct BOARD_CTRL __iomem *board_ctrl;
+       unsigned long loc_doorbell;
+
+       firm_id = cinfo->base_addr + ID_ADDRESS;
+       if (!ISZLOADED(*cinfo)) {
+               return -1;
+       }
+       zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) &
+                       0xfffff);
+       board_ctrl = &zfw_ctrl->board_ctrl;
+
+       loc_doorbell = cy_readl(&((struct RUNTIME_9060 __iomem *)
+                                 (cinfo->ctl_addr))->loc_doorbell);
+       if (loc_doorbell) {
+               *cmd = (char)(0xff & loc_doorbell);
+               *channel = cy_readl(&board_ctrl->fwcmd_channel);
+               *param = (uclong) cy_readl(&board_ctrl->fwcmd_param);
+               cy_writel(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->
+                         loc_doorbell, 0xffffffff);
+               return 1;
+       }
+       return 0;
+}                              /* cyz_fetch_msg */
 
 static int
-cyz_issue_cmd( struct cyclades_card *cinfo,
-           uclong channel, ucchar cmd, uclong param)
+cyz_issue_cmd(struct cyclades_card *cinfo,
+               uclong channel, ucchar cmd, uclong param)
 {
-  struct FIRM_ID __iomem *firm_id;
-  struct ZFW_CTRL __iomem *zfw_ctrl;
-  struct BOARD_CTRL __iomem *board_ctrl;
-  unsigned long __iomem *pci_doorbell;
-  int index;
-
-    firm_id = cinfo->base_addr + ID_ADDRESS;
-    if (!ISZLOADED(*cinfo)){
-       return (-1);
-    }
-    zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
-    board_ctrl = &zfw_ctrl->board_ctrl;
-
-    index = 0;
-    pci_doorbell = &((struct RUNTIME_9060 __iomem *) (cinfo->ctl_addr))->pci_doorbell;
-    while( (cy_readl(pci_doorbell) & 0xff) != 0){
-        if (index++ == 1000){
-           return((int)(cy_readl(pci_doorbell) & 0xff));
-        }
-       udelay(50L);
-    }
-    cy_writel(&board_ctrl->hcmd_channel, channel);
-    cy_writel(&board_ctrl->hcmd_param , param);
-    cy_writel(pci_doorbell, (long)cmd);
-
-    return(0);
-} /* cyz_issue_cmd */
+       struct FIRM_ID __iomem *firm_id;
+       struct ZFW_CTRL __iomem *zfw_ctrl;
+       struct BOARD_CTRL __iomem *board_ctrl;
+       unsigned long __iomem *pci_doorbell;
+       int index;
+
+       firm_id = cinfo->base_addr + ID_ADDRESS;
+       if (!ISZLOADED(*cinfo)) {
+               return -1;
+       }
+       zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) &
+                       0xfffff);
+       board_ctrl = &zfw_ctrl->board_ctrl;
+
+       index = 0;
+       pci_doorbell =
+           &((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->pci_doorbell;
+       while ((cy_readl(pci_doorbell) & 0xff) != 0) {
+               if (index++ == 1000) {
+                       return (int)(cy_readl(pci_doorbell) & 0xff);
+               }
+               udelay(50L);
+       }
+       cy_writel(&board_ctrl->hcmd_channel, channel);
+       cy_writel(&board_ctrl->hcmd_param, param);
+       cy_writel(pci_doorbell, (long)cmd);
+
+       return 0;
+}                              /* cyz_issue_cmd */
 
 static void
 cyz_handle_rx(struct cyclades_port *info,
-             volatile struct CH_CTRL __iomem *ch_ctrl,
-             volatile struct BUF_CTRL __iomem *buf_ctrl)
+               volatile struct CH_CTRL __iomem * ch_ctrl,
+               volatile struct BUF_CTRL __iomem * buf_ctrl)
 {
-  struct cyclades_card *cinfo = &cy_card[info->card];
-  struct tty_struct *tty = info->tty;
-  volatile int char_count;
-  int len;
+       struct cyclades_card *cinfo = &cy_card[info->card];
+       struct tty_struct *tty = info->tty;
+       volatile int char_count;
+       int len;
 #ifdef BLOCKMOVE
-  int small_count;
+       int small_count;
 #else
-  char data;
+       char data;
 #endif
-  volatile uclong rx_put, rx_get, new_rx_get, rx_bufsize, rx_bufaddr;
+       volatile uclong rx_put, rx_get, new_rx_get, rx_bufsize, rx_bufaddr;
 
-    rx_get = new_rx_get = cy_readl(&buf_ctrl->rx_get);
-    rx_put = cy_readl(&buf_ctrl->rx_put);
-    rx_bufsize = cy_readl(&buf_ctrl->rx_bufsize);
-    rx_bufaddr = cy_readl(&buf_ctrl->rx_bufaddr);
-    if (rx_put >= rx_get)
-       char_count = rx_put - rx_get;
-    else
-       char_count = rx_put - rx_get + rx_bufsize;
+       rx_get = new_rx_get = cy_readl(&buf_ctrl->rx_get);
+       rx_put = cy_readl(&buf_ctrl->rx_put);
+       rx_bufsize = cy_readl(&buf_ctrl->rx_bufsize);
+       rx_bufaddr = cy_readl(&buf_ctrl->rx_bufaddr);
+       if (rx_put >= rx_get)
+               char_count = rx_put - rx_get;
+       else
+               char_count = rx_put - rx_get + rx_bufsize;
 
-    if ( char_count ) {
-       info->last_active = jiffies;
-       info->jiffies[1] = jiffies;
+       if (char_count) {
+               info->last_active = jiffies;
+               info->jiffies[1] = jiffies;
 
 #ifdef CY_ENABLE_MONITORING
-       info->mon.int_count++;
-       info->mon.char_count += char_count;
-       if (char_count > info->mon.char_max)
-           info->mon.char_max = char_count;
-       info->mon.char_last = char_count;
+               info->mon.int_count++;
+               info->mon.char_count += char_count;
+               if (char_count > info->mon.char_max)
+                       info->mon.char_max = char_count;
+               info->mon.char_last = char_count;
 #endif
-       if(tty == 0){
-           /* flush received characters */
-           new_rx_get = (new_rx_get + char_count) & (rx_bufsize - 1);
-           info->rflush_count++;
-       }else{
+               if (tty == 0) {
+                       /* flush received characters */
+                       new_rx_get = (new_rx_get + char_count) &
+                                       (rx_bufsize - 1);
+                       info->rflush_count++;
+               } else {
 #ifdef BLOCKMOVE
-           /* we'd like to use memcpy(t, f, n) and memset(s, c, count)
-              for performance, but because of buffer boundaries, there
-              may be several steps to the operation */
-           while(0 < (small_count = 
-                      min_t(unsigned int, (rx_bufsize - new_rx_get),
-                      min_t(unsigned int, (TTY_FLIPBUF_SIZE - tty->flip.count), char_count))
-                )) {
-               memcpy_fromio(tty->flip.char_buf_ptr,
-                             (char *)(cinfo->base_addr
-                                      + rx_bufaddr + new_rx_get),
-                             small_count);
-
-               tty->flip.char_buf_ptr += small_count;
-               memset(tty->flip.flag_buf_ptr, TTY_NORMAL, small_count);
-               tty->flip.flag_buf_ptr += small_count;
-               new_rx_get = (new_rx_get + small_count) & (rx_bufsize - 1);
-               char_count -= small_count;
-               info->icount.rx += small_count;
-               info->idle_stats.recv_bytes += small_count;
-               tty->flip.count += small_count;
-           }
+               /* we'd like to use memcpy(t, f, n) and memset(s, c, count)
+                  for performance, but because of buffer boundaries, there
+                  may be several steps to the operation */
+                       while (0 < (small_count = min_t(unsigned int,
+                                       rx_bufsize - new_rx_get,
+                                       min_t(unsigned int, TTY_FLIPBUF_SIZE -
+                                               tty->flip.count, char_count)))){
+                               memcpy_fromio(tty->flip.char_buf_ptr,
+                                       (char *)(cinfo->base_addr + rx_bufaddr +
+                                               new_rx_get),
+                                       small_count);
+
+                               tty->flip.char_buf_ptr += small_count;
+                               memset(tty->flip.flag_buf_ptr, TTY_NORMAL,
+                                       small_count);
+                               tty->flip.flag_buf_ptr += small_count;
+                               new_rx_get = (new_rx_get + small_count) &
+                                               (rx_bufsize - 1);
+                               char_count -= small_count;
+                               info->icount.rx += small_count;
+                               info->idle_stats.recv_bytes += small_count;
+                               tty->flip.count += small_count;
+                       }
 #else
-           len = tty_buffer_request_room(tty, char_count);
-           while(len--){
-               data = cy_readb(cinfo->base_addr + rx_bufaddr + new_rx_get);
-               new_rx_get = (new_rx_get + 1) & (rx_bufsize - 1);
-               tty_insert_flip_char(tty, data, TTY_NORMAL);
-               info->idle_stats.recv_bytes++;
-               info->icount.rx++;
-           }
+                       len = tty_buffer_request_room(tty, char_count);
+                       while (len--) {
+                               data = cy_readb(cinfo->base_addr + rx_bufaddr +
+                                               new_rx_get);
+                               new_rx_get = (new_rx_get + 1)& (rx_bufsize - 1);
+                               tty_insert_flip_char(tty, data, TTY_NORMAL);
+                               info->idle_stats.recv_bytes++;
+                               info->icount.rx++;
+                       }
 #endif
 #ifdef CONFIG_CYZ_INTR
-           /* Recalculate the number of chars in the RX buffer and issue
-              a cmd in case it's higher than the RX high water mark */
-           rx_put = cy_readl(&buf_ctrl->rx_put);
-           if (rx_put >= rx_get)
-               char_count = rx_put - rx_get;
-           else
-               char_count = rx_put - rx_get + rx_bufsize;
-           if(char_count >= cy_readl(&buf_ctrl->rx_threshold)) {
-               cy_sched_event(info, Cy_EVENT_Z_RX_FULL);
-           }
+               /* Recalculate the number of chars in the RX buffer and issue
+                  a cmd in case it's higher than the RX high water mark */
+                       rx_put = cy_readl(&buf_ctrl->rx_put);
+                       if (rx_put >= rx_get)
+                               char_count = rx_put - rx_get;
+                       else
+                               char_count = rx_put - rx_get + rx_bufsize;
+                       if (char_count >= (int)cy_readl(&buf_ctrl->
+                                       rx_threshold)) {
+                               cy_sched_event(info, Cy_EVENT_Z_RX_FULL);
+                       }
 #endif
-           info->idle_stats.recv_idle = jiffies;
-           tty_schedule_flip(tty);
+                       info->idle_stats.recv_idle = jiffies;
+                       tty_schedule_flip(tty);
+               }
+               /* Update rx_get */
+               cy_writel(&buf_ctrl->rx_get, new_rx_get);
        }
-       /* Update rx_get */
-       cy_writel(&buf_ctrl->rx_get, new_rx_get);
-    }
 }
 
 static void
 cyz_handle_tx(struct cyclades_port *info,
-             volatile struct CH_CTRL __iomem *ch_ctrl,
-             volatile struct BUF_CTRL __iomem *buf_ctrl)
+               volatile struct CH_CTRL __iomem * ch_ctrl,
+               volatile struct BUF_CTRL __iomem * buf_ctrl)
 {
-  struct cyclades_card *cinfo = &cy_card[info->card];
-  struct tty_struct *tty = info->tty;
-  char data;
-  volatile int char_count;
+       struct cyclades_card *cinfo = &cy_card[info->card];
+       struct tty_struct *tty = info->tty;
+       char data;
+       volatile int char_count;
 #ifdef BLOCKMOVE
-  int small_count;
+       int small_count;
 #endif
-  volatile uclong tx_put, tx_get, tx_bufsize, tx_bufaddr;
+       volatile uclong tx_put, tx_get, tx_bufsize, tx_bufaddr;
 
-    if (info->xmit_cnt <= 0)   /* Nothing to transmit */
-       return;
+       if (info->xmit_cnt <= 0)        /* Nothing to transmit */
+               return;
 
-    tx_get = cy_readl(&buf_ctrl->tx_get);
-    tx_put = cy_readl(&buf_ctrl->tx_put);
-    tx_bufsize = cy_readl(&buf_ctrl->tx_bufsize);
-    tx_bufaddr = cy_readl(&buf_ctrl->tx_bufaddr);
-    if (tx_put >= tx_get)
-       char_count = tx_get - tx_put - 1 + tx_bufsize;
-    else
-       char_count = tx_get - tx_put - 1;
+       tx_get = cy_readl(&buf_ctrl->tx_get);
+       tx_put = cy_readl(&buf_ctrl->tx_put);
+       tx_bufsize = cy_readl(&buf_ctrl->tx_bufsize);
+       tx_bufaddr = cy_readl(&buf_ctrl->tx_bufaddr);
+       if (tx_put >= tx_get)
+               char_count = tx_get - tx_put - 1 + tx_bufsize;
+       else
+               char_count = tx_get - tx_put - 1;
 
-    if ( char_count ) {
+       if (char_count) {
 
-       if( tty == 0 ){
-           goto ztxdone;
-       }
+               if (tty == 0) {
+                       goto ztxdone;
+               }
 
-       if(info->x_char) { /* send special char */
-           data = info->x_char;
+               if (info->x_char) {     /* send special char */
+                       data = info->x_char;
 
-           cy_writeb((cinfo->base_addr + tx_bufaddr + tx_put), data);
-           tx_put = (tx_put + 1) & (tx_bufsize - 1);
-           info->x_char = 0;
-           char_count--;
-           info->icount.tx++;
-           info->last_active = jiffies;
-           info->jiffies[2] = jiffies;
-       }
+                       cy_writeb(cinfo->base_addr + tx_bufaddr + tx_put, data);
+                       tx_put = (tx_put + 1) & (tx_bufsize - 1);
+                       info->x_char = 0;
+                       char_count--;
+                       info->icount.tx++;
+                       info->last_active = jiffies;
+                       info->jiffies[2] = jiffies;
+               }
 #ifdef BLOCKMOVE
-       while(0 < (small_count = 
-                  min_t(unsigned int, (tx_bufsize - tx_put),
-                      min_t(unsigned int, (SERIAL_XMIT_SIZE - info->xmit_tail),
-                          min_t(unsigned int, info->xmit_cnt, char_count))))) {
-
-           memcpy_toio((char *)(cinfo->base_addr + tx_bufaddr + tx_put),
-                       &info->xmit_buf[info->xmit_tail],
-                       small_count);
-
-           tx_put = (tx_put + small_count) & (tx_bufsize - 1);
-           char_count -= small_count;
-           info->icount.tx += small_count;
-           info->xmit_cnt -= small_count;
-           info->xmit_tail = 
-               (info->xmit_tail + small_count) & (SERIAL_XMIT_SIZE - 1);
-           info->last_active = jiffies;
-           info->jiffies[2] = jiffies;
-       }
+               while (0 < (small_count = min_t(unsigned int,
+                               tx_bufsize - tx_put, min_t(unsigned int,
+                                       (SERIAL_XMIT_SIZE - info->xmit_tail),
+                                       min_t(unsigned int, info->xmit_cnt,
+                                               char_count))))) {
+
+                       memcpy_toio((char *)(cinfo->base_addr + tx_bufaddr +
+                                       tx_put),
+                                       &info->xmit_buf[info->xmit_tail],
+                                       small_count);
+
+                       tx_put = (tx_put + small_count) & (tx_bufsize - 1);
+                       char_count -= small_count;
+                       info->icount.tx += small_count;
+                       info->xmit_cnt -= small_count;
+                       info->xmit_tail = (info->xmit_tail + small_count) &
+                                       (SERIAL_XMIT_SIZE - 1);
+                       info->last_active = jiffies;
+                       info->jiffies[2] = jiffies;
+               }
 #else
-       while (info->xmit_cnt && char_count){
-           data = info->xmit_buf[info->xmit_tail];
-           info->xmit_cnt--;
-           info->xmit_tail = (info->xmit_tail + 1) & (SERIAL_XMIT_SIZE - 1);
-
-           cy_writeb(cinfo->base_addr + tx_bufaddr + tx_put, data);
-           tx_put = (tx_put + 1) & (tx_bufsize - 1);
-           char_count--;
-           info->icount.tx++;
-           info->last_active = jiffies;
-           info->jiffies[2] = jiffies;
-       }
+               while (info->xmit_cnt && char_count) {
+                       data = info->xmit_buf[info->xmit_tail];
+                       info->xmit_cnt--;
+                       info->xmit_tail = (info->xmit_tail + 1) &
+                                       (SERIAL_XMIT_SIZE - 1);
+
+                       cy_writeb(cinfo->base_addr + tx_bufaddr + tx_put, data);
+                       tx_put = (tx_put + 1) & (tx_bufsize - 1);
+                       char_count--;
+                       info->icount.tx++;
+                       info->last_active = jiffies;
+                       info->jiffies[2] = jiffies;
+               }
 #endif
-    ztxdone:
-       if (info->xmit_cnt < WAKEUP_CHARS) {
-           cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
+ztxdone:
+               if (info->xmit_cnt < WAKEUP_CHARS) {
+                       cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
+               }
+               /* Update tx_put */
+               cy_writel(&buf_ctrl->tx_put, tx_put);
        }
-       /* Update tx_put */
-       cy_writel(&buf_ctrl->tx_put, tx_put);
-    }
 }
 
-static void
-cyz_handle_cmd(struct cyclades_card *cinfo)
+static void cyz_handle_cmd(struct cyclades_card *cinfo)
 {
-  struct tty_struct *tty;
-  struct cyclades_port *info;
-  static volatile struct FIRM_ID __iomem *firm_id;
-  static volatile struct ZFW_CTRL __iomem *zfw_ctrl;
-  static volatile struct BOARD_CTRL __iomem *board_ctrl;
-  static volatile struct CH_CTRL __iomem *ch_ctrl;
-  static volatile struct BUF_CTRL __iomem *buf_ctrl;
-  uclong channel;
-  ucchar cmd;
-  uclong param;
-  uclong hw_ver, fw_ver;
-  int special_count;
-  int delta_count;
-
-    firm_id = cinfo->base_addr + ID_ADDRESS;
-    zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
-    board_ctrl = &zfw_ctrl->board_ctrl;
-    fw_ver = cy_readl(&board_ctrl->fw_version);
-    hw_ver = cy_readl(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->mail_box_0);
-
-
-    while(cyz_fetch_msg(cinfo, &channel, &cmd, &param) == 1) {
-       special_count = 0;
-       delta_count = 0;
-       info = &cy_port[channel + cinfo->first_line];
-       if((tty = info->tty) == 0) {
-           continue;
-       }
-       ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
-       buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]);
-
-       switch(cmd) {
-           case C_CM_PR_ERROR:
-               tty_insert_flip_char(tty, 0, TTY_PARITY);
-               info->icount.rx++;
-               special_count++;
-               break;
-           case C_CM_FR_ERROR:
-               tty_insert_flip_char(tty, 0, TTY_FRAME);
-               info->icount.rx++;
-               special_count++;
-               break;
-           case C_CM_RXBRK:
-               tty_insert_flip_char(tty, 0, TTY_BREAK);
-               info->icount.rx++;
-               special_count++;
-               break;
-           case C_CM_MDCD:
-               info->icount.dcd++;
-               delta_count++;
-               if (info->flags & ASYNC_CHECK_CD){
-                   if ((fw_ver > 241 ? 
-                         ((u_long)param) : 
-                         cy_readl(&ch_ctrl->rs_status)) & C_RS_DCD) {
-                       cy_sched_event(info, Cy_EVENT_OPEN_WAKEUP);
-                   }else{
-                       cy_sched_event(info, Cy_EVENT_HANGUP);
-                   }
+       struct tty_struct *tty;
+       struct cyclades_port *info;
+       static volatile struct FIRM_ID __iomem *firm_id;
+       static volatile struct ZFW_CTRL __iomem *zfw_ctrl;
+       static volatile struct BOARD_CTRL __iomem *board_ctrl;
+       static volatile struct CH_CTRL __iomem *ch_ctrl;
+       static volatile struct BUF_CTRL __iomem *buf_ctrl;
+       uclong channel;
+       ucchar cmd;
+       uclong param;
+       uclong hw_ver, fw_ver;
+       int special_count;
+       int delta_count;
+
+       firm_id = cinfo->base_addr + ID_ADDRESS;
+       zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) &
+                       0xfffff);
+       board_ctrl = &zfw_ctrl->board_ctrl;
+       fw_ver = cy_readl(&board_ctrl->fw_version);
+       hw_ver = cy_readl(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->
+                       mail_box_0);
+
+       while (cyz_fetch_msg(cinfo, &channel, &cmd, &param) == 1) {
+               special_count = 0;
+               delta_count = 0;
+               info = &cy_port[channel + cinfo->first_line];
+               if ((tty = info->tty) == 0) {
+                       continue;
                }
-               break;
-           case C_CM_MCTS:
-               info->icount.cts++;
-               delta_count++;
-               break;
-           case C_CM_MRI:
-               info->icount.rng++;
-               delta_count++;
-               break;
-           case C_CM_MDSR:
-               info->icount.dsr++;
-               delta_count++;
-               break;
+               ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
+               buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]);
+
+               switch (cmd) {
+               case C_CM_PR_ERROR:
+                       tty_insert_flip_char(tty, 0, TTY_PARITY);
+                       info->icount.rx++;
+                       special_count++;
+                       break;
+               case C_CM_FR_ERROR:
+                       tty_insert_flip_char(tty, 0, TTY_FRAME);
+                       info->icount.rx++;
+                       special_count++;
+                       break;
+               case C_CM_RXBRK:
+                       tty_insert_flip_char(tty, 0, TTY_BREAK);
+                       info->icount.rx++;
+                       special_count++;
+                       break;
+               case C_CM_MDCD:
+                       info->icount.dcd++;
+                       delta_count++;
+                       if (info->flags & ASYNC_CHECK_CD) {
+                               if ((fw_ver > 241 ? ((u_long) param) :
+                                               cy_readl(&ch_ctrl->rs_status)) &
+                                               C_RS_DCD) {
+                                       cy_sched_event(info,
+                                                       Cy_EVENT_OPEN_WAKEUP);
+                               } else {
+                                       cy_sched_event(info, Cy_EVENT_HANGUP);
+                               }
+                       }
+                       break;
+               case C_CM_MCTS:
+                       info->icount.cts++;
+                       delta_count++;
+                       break;
+               case C_CM_MRI:
+                       info->icount.rng++;
+                       delta_count++;
+                       break;
+               case C_CM_MDSR:
+                       info->icount.dsr++;
+                       delta_count++;
+                       break;
 #ifdef Z_WAKE
-           case C_CM_IOCTLW:
-               cy_sched_event(info, Cy_EVENT_SHUTDOWN_WAKEUP);
-               break;
+               case C_CM_IOCTLW:
+                       cy_sched_event(info, Cy_EVENT_SHUTDOWN_WAKEUP);
+                       break;
 #endif
 #ifdef CONFIG_CYZ_INTR
-           case C_CM_RXHIWM:
-           case C_CM_RXNNDT:
-           case C_CM_INTBACK2:
-               /* Reception Interrupt */
+               case C_CM_RXHIWM:
+               case C_CM_RXNNDT:
+               case C_CM_INTBACK2:
+                       /* Reception Interrupt */
 #ifdef CY_DEBUG_INTERRUPTS
-               printk("cyz_interrupt: rcvd intr, card %d, port %ld\n\r", 
-                       info->card, channel);
+                       printk("cyz_interrupt: rcvd intr, card %d, "
+                                       "port %ld\n\r", info->card, channel);
 #endif
-               cyz_handle_rx(info, ch_ctrl, buf_ctrl);
-               break;
-           case C_CM_TXBEMPTY:
-           case C_CM_TXLOWWM:
-           case C_CM_INTBACK:
-               /* Transmission Interrupt */
+                       cyz_handle_rx(info, ch_ctrl, buf_ctrl);
+                       break;
+               case C_CM_TXBEMPTY:
+               case C_CM_TXLOWWM:
+               case C_CM_INTBACK:
+                       /* Transmission Interrupt */
 #ifdef CY_DEBUG_INTERRUPTS
-               printk("cyz_interrupt: xmit intr, card %d, port %ld\n\r", 
-                       info->card, channel);
+                       printk("cyz_interrupt: xmit intr, card %d, "
+                                       "port %ld\n\r", info->card, channel);
 #endif
-               cyz_handle_tx(info, ch_ctrl, buf_ctrl);
-               break;
-#endif /* CONFIG_CYZ_INTR */
-           case C_CM_FATAL:
-               /* should do something with this !!! */
-               break;
-           default:
-               break;
+                       cyz_handle_tx(info, ch_ctrl, buf_ctrl);
+                       break;
+#endif                         /* CONFIG_CYZ_INTR */
+               case C_CM_FATAL:
+                       /* should do something with this !!! */
+                       break;
+               default:
+                       break;
+               }
+               if (delta_count)
+                       cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP);
+               if (special_count)
+                       tty_schedule_flip(tty);
        }
-       if(delta_count)
-           cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP);
-       if(special_count)
-           tty_schedule_flip(tty);
-    }
 }
 
 #ifdef CONFIG_CYZ_INTR
-static irqreturn_t
-cyz_interrupt(int irq, void *dev_id)
+static irqreturn_t cyz_interrupt(int irq, void *dev_id)
 {
-  struct cyclades_card *cinfo;
+       struct cyclades_card *cinfo;
 
-    if((cinfo = (struct cyclades_card *)dev_id) == 0){
+       if ((cinfo = (struct cyclades_card *)dev_id) == 0) {
 #ifdef CY_DEBUG_INTERRUPTS
-       printk("cyz_interrupt: spurious interrupt %d\n\r", irq);
+               printk("cyz_interrupt: spurious interrupt %d\n\r", irq);
 #endif
-        return IRQ_NONE; /* spurious interrupt */
-    }
+               return IRQ_NONE;        /* spurious interrupt */
+       }
 
-    if (!ISZLOADED(*cinfo)) {
+       if (!ISZLOADED(*cinfo)) {
 #ifdef CY_DEBUG_INTERRUPTS
-       printk("cyz_interrupt: board not yet loaded (IRQ%d).\n\r", irq);
+               printk("cyz_interrupt: board not yet loaded (IRQ%d).\n\r", irq);
 #endif
-       return IRQ_NONE;
-    }
+               return IRQ_NONE;
+       }
 
-    /* Handle the interrupts */
-    cyz_handle_cmd(cinfo);
+       /* Handle the interrupts */
+       cyz_handle_cmd(cinfo);
 
-    return IRQ_HANDLED;
-} /* cyz_interrupt */
+       return IRQ_HANDLED;
+}                              /* cyz_interrupt */
 
-static void
-cyz_rx_restart(unsigned long arg)
+static void cyz_rx_restart(unsigned long arg)
 {
-    struct cyclades_port *info = (struct cyclades_port *)arg;
-    int retval;
-    int card = info->card;
-    uclong channel = (info->line) - (cy_card[card].first_line);
-    unsigned long flags;
-
-    CY_LOCK(info, flags);
-    retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_INTBACK2, 0L);
-    if (retval != 0){
-       printk("cyc:cyz_rx_restart retval on ttyC%d was %x\n", 
-              info->line, retval);
-    }
-    cyz_rx_full_timer[info->line].function = NULL;
-    CY_UNLOCK(info, flags);
+       struct cyclades_port *info = (struct cyclades_port *)arg;
+       int retval;
+       int card = info->card;
+       uclong channel = (info->line) - (cy_card[card].first_line);
+       unsigned long flags;
+
+       CY_LOCK(info, flags);
+       retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_INTBACK2, 0L);
+       if (retval != 0) {
+               printk("cyc:cyz_rx_restart retval on ttyC%d was %x\n",
+                       info->line, retval);
+       }
+       cyz_rx_full_timer[info->line].function = NULL;
+       CY_UNLOCK(info, flags);
 }
 
-#else /* CONFIG_CYZ_INTR */
+#else                          /* CONFIG_CYZ_INTR */
 
-static void
-cyz_poll(unsigned long arg)
+static void cyz_poll(unsigned long arg)
 {
-  struct cyclades_card *cinfo;
-  struct cyclades_port *info;
-  struct tty_struct *tty;
-  static volatile struct FIRM_ID *firm_id;
-  static volatile struct ZFW_CTRL *zfw_ctrl;
-  static volatile struct BOARD_CTRL *board_ctrl;
-  static volatile struct CH_CTRL *ch_ctrl;
-  static volatile struct BUF_CTRL *buf_ctrl;
-  int card, port;
-
-    cyz_timerlist.expires = jiffies + (HZ);
-    for (card = 0 ; card < NR_CARDS ; card++){
-       cinfo = &cy_card[card];
-
-       if (!IS_CYC_Z(*cinfo)) continue;
-       if (!ISZLOADED(*cinfo)) continue;
+       struct cyclades_card *cinfo;
+       struct cyclades_port *info;
+       struct tty_struct *tty;
+       static volatile struct FIRM_ID *firm_id;
+       static volatile struct ZFW_CTRL *zfw_ctrl;
+       static volatile struct BOARD_CTRL *board_ctrl;
+       static volatile struct CH_CTRL *ch_ctrl;
+       static volatile struct BUF_CTRL *buf_ctrl;
+       int card, port;
 
-       firm_id = cinfo->base_addr + ID_ADDRESS;
-       zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
-       board_ctrl = &(zfw_ctrl->board_ctrl);
+       cyz_timerlist.expires = jiffies + (HZ);
+       for (card = 0; card < NR_CARDS; card++) {
+               cinfo = &cy_card[card];
+
+               if (!IS_CYC_Z(*cinfo))
+                       continue;
+               if (!ISZLOADED(*cinfo))
+                       continue;
+
+               firm_id = cinfo->base_addr + ID_ADDRESS;
+               zfw_ctrl = cinfo->base_addr +
+                               (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
+               board_ctrl = &(zfw_ctrl->board_ctrl);
 
        /* Skip first polling cycle to avoid racing conditions with the FW */
-       if (!cinfo->intr_enabled) {
-           cinfo->nports = (int) cy_readl(&board_ctrl->n_channel);
-           cinfo->intr_enabled = 1;
-           continue;
-       }
+               if (!cinfo->intr_enabled) {
+                       cinfo->nports = (int)cy_readl(&board_ctrl->n_channel);
+                       cinfo->intr_enabled = 1;
+                       continue;
+               }
 
-       cyz_handle_cmd(cinfo);
+               cyz_handle_cmd(cinfo);
 
-       for (port = 0 ; port < cinfo->nports ; port++) {
-           info = &cy_port[ port + cinfo->first_line ];
-            tty = info->tty;
-           ch_ctrl = &(zfw_ctrl->ch_ctrl[port]);
-           buf_ctrl = &(zfw_ctrl->buf_ctrl[port]);
+               for (port = 0; port < cinfo->nports; port++) {
+                       info = &cy_port[port + cinfo->first_line];
+                       tty = info->tty;
+                       ch_ctrl = &(zfw_ctrl->ch_ctrl[port]);
+                       buf_ctrl = &(zfw_ctrl->buf_ctrl[port]);
 
-           if (!info->throttle)
-               cyz_handle_rx(info, ch_ctrl, buf_ctrl);
-           cyz_handle_tx(info, ch_ctrl, buf_ctrl);
+                       if (!info->throttle)
+                               cyz_handle_rx(info, ch_ctrl, buf_ctrl);
+                       cyz_handle_tx(info, ch_ctrl, buf_ctrl);
+               }
+               /* poll every 'cyz_polling_cycle' period */
+               cyz_timerlist.expires = jiffies + cyz_polling_cycle;
        }
-       /* poll every 'cyz_polling_cycle' period */
-       cyz_timerlist.expires = jiffies + cyz_polling_cycle;
-    }
-    add_timer(&cyz_timerlist);
-
-    return;
-} /* cyz_poll */
+       add_timer(&cyz_timerlist);
+}                              /* cyz_poll */
 
-#endif /* CONFIG_CYZ_INTR */
+#endif                         /* CONFIG_CYZ_INTR */
 
 /********** End of block of Cyclades-Z specific code *********/
 /***********************************************************/
 
-
 /* This is called whenever a port becomes active;
    interrupts are enabled and DTR & RTS are turned on.
  */
-static int
-startup(struct cyclades_port * info)
+static int startup(struct cyclades_port *info)
 {
-  unsigned long flags;
-  int retval = 0;
-  void __iomem *base_addr;
-  int card,chip,channel,index;
-  unsigned long page;
+       unsigned long flags;
+       int retval = 0;
+       void __iomem *base_addr;
+       int card, chip, channel, index;
+       unsigned long page;
 
-    card = info->card;
-    channel = (info->line) - (cy_card[card].first_line);
+       card = info->card;
+       channel = (info->line) - (cy_card[card].first_line);
 
-    page = get_zeroed_page(GFP_KERNEL);
-    if (!page)
-       return -ENOMEM;
+       page = get_zeroed_page(GFP_KERNEL);
+       if (!page)
+               return -ENOMEM;
 
-    CY_LOCK(info, flags);
+       CY_LOCK(info, flags);
 
-    if (info->flags & ASYNC_INITIALIZED){
-       free_page(page);
-       goto errout;
-    }
+       if (info->flags & ASYNC_INITIALIZED) {
+               free_page(page);
+               goto errout;
+       }
 
-    if (!info->type){
-        if (info->tty){
-            set_bit(TTY_IO_ERROR, &info->tty->flags);
-        }
-       free_page(page);
-       goto errout;
-    }
+       if (!info->type) {
+               if (info->tty) {
+                       set_bit(TTY_IO_ERROR, &info->tty->flags);
+               }
+               free_page(page);
+               goto errout;
+       }
 
-    if (info->xmit_buf)
-       free_page(page);
-    else
-       info->xmit_buf = (unsigned char *) page;
+       if (info->xmit_buf)
+               free_page(page);
+       else
+               info->xmit_buf = (unsigned char *)page;
 
-    CY_UNLOCK(info, flags);
+       CY_UNLOCK(info, flags);
 
-    set_line_char(info);
+       set_line_char(info);
 
-    if (!IS_CYC_Z(cy_card[card])) {
-       chip = channel>>2;
-       channel &= 0x03;
-       index = cy_card[card].bus_index;
-       base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index);
+       if (!IS_CYC_Z(cy_card[card])) {
+               chip = channel >> 2;
+               channel &= 0x03;
+               index = cy_card[card].bus_index;
+               base_addr = cy_card[card].base_addr +
+                               (cy_chip_offset[chip] << index);
 
 #ifdef CY_DEBUG_OPEN
-       printk("cyc startup card %d, chip %d, channel %d, base_addr %lx\n",
-            card, chip, channel, (long)base_addr);/**/
+               printk("cyc startup card %d, chip %d, channel %d, "
+                               "base_addr %lx\n",
+                               card, chip, channel, (long)base_addr);
+               /**/
 #endif
+               CY_LOCK(info, flags);
 
-       CY_LOCK(info, flags);
-
-       cy_writeb(base_addr+(CyCAR<<index), (u_char)channel);
+               cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
 
-       cy_writeb(base_addr+(CyRTPR<<index), (info->default_timeout
-                ? info->default_timeout : 0x02)); /* 10ms rx timeout */
+               cy_writeb(base_addr + (CyRTPR << index),
+                       (info->default_timeout ? info->default_timeout : 0x02));
+               /* 10ms rx timeout */
 
-       cyy_issue_cmd(base_addr,CyCHAN_CTL|CyENB_RCVR|CyENB_XMTR,index);
+               cyy_issue_cmd(base_addr, CyCHAN_CTL | CyENB_RCVR | CyENB_XMTR,
+                               index);
 
-       cy_writeb(base_addr+(CyCAR<<index), (u_char)channel);
-       cy_writeb(base_addr+(CyMSVR1<<index), CyRTS);
-       cy_writeb(base_addr+(CyMSVR2<<index), CyDTR);
+               cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
+               cy_writeb(base_addr + (CyMSVR1 << index), CyRTS);
+               cy_writeb(base_addr + (CyMSVR2 << index), CyDTR);
 
 #ifdef CY_DEBUG_DTR
-       printk("cyc:startup raising DTR\n");
-       printk("     status: 0x%x, 0x%x\n",
-               cy_readb(base_addr+(CyMSVR1<<index)), 
-                cy_readb(base_addr+(CyMSVR2<<index)));
+               printk("cyc:startup raising DTR\n");
+               printk("     status: 0x%x, 0x%x\n",
+                       cy_readb(base_addr + (CyMSVR1 << index)),
+                       cy_readb(base_addr + (CyMSVR2 << index)));
 #endif
 
-       cy_writeb(base_addr+(CySRER<<index),
-               cy_readb(base_addr+(CySRER<<index)) | CyRxData);
-       info->flags |= ASYNC_INITIALIZED;
+               cy_writeb(base_addr + (CySRER << index),
+                       cy_readb(base_addr + (CySRER << index)) | CyRxData);
+               info->flags |= ASYNC_INITIALIZED;
 
-       if (info->tty){
-           clear_bit(TTY_IO_ERROR, &info->tty->flags);
-       }
-       info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
-       info->breakon = info->breakoff = 0;
-       memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats));
-       info->idle_stats.in_use    =
-       info->idle_stats.recv_idle =
-       info->idle_stats.xmit_idle = jiffies;
+               if (info->tty) {
+                       clear_bit(TTY_IO_ERROR, &info->tty->flags);
+               }
+               info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
+               info->breakon = info->breakoff = 0;
+               memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats));
+               info->idle_stats.in_use =
+               info->idle_stats.recv_idle =
+               info->idle_stats.xmit_idle = jiffies;
 
-       CY_UNLOCK(info, flags);
+               CY_UNLOCK(info, flags);
 
-    } else {
-      struct FIRM_ID __iomem *firm_id;
-      struct ZFW_CTRL __iomem *zfw_ctrl;
-      struct BOARD_CTRL __iomem *board_ctrl;
-      struct CH_CTRL __iomem *ch_ctrl;
-      int retval;
+       } else {
+               struct FIRM_ID __iomem *firm_id;
+               struct ZFW_CTRL __iomem *zfw_ctrl;
+               struct BOARD_CTRL __iomem *board_ctrl;
+               struct CH_CTRL __iomem *ch_ctrl;
+               int retval;
 
-       base_addr = cy_card[card].base_addr;
+               base_addr = cy_card[card].base_addr;
 
-        firm_id = base_addr + ID_ADDRESS;
-        if (!ISZLOADED(cy_card[card])){
-           return -ENODEV;
-       }
+               firm_id = base_addr + ID_ADDRESS;
+               if (!ISZLOADED(cy_card[card])) {
+                       return -ENODEV;
+               }
 
-       zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
-       board_ctrl = &zfw_ctrl->board_ctrl;
-       ch_ctrl = zfw_ctrl->ch_ctrl;
+               zfw_ctrl = cy_card[card].base_addr +
+                               (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
+               board_ctrl = &zfw_ctrl->board_ctrl;
+               ch_ctrl = zfw_ctrl->ch_ctrl;
 
 #ifdef CY_DEBUG_OPEN
-       printk("cyc startup Z card %d, channel %d, base_addr %lx\n",
-            card, channel, (long)base_addr);/**/
+               printk("cyc startup Z card %d, channel %d, base_addr %lx\n",
+                       card, channel, (long)base_addr);
+               /**/
 #endif
+               CY_LOCK(info, flags);
 
-       CY_LOCK(info, flags);
-
-       cy_writel(&ch_ctrl[channel].op_mode, C_CH_ENABLE);
+               cy_writel(&ch_ctrl[channel].op_mode, C_CH_ENABLE);
 #ifdef Z_WAKE
 #ifdef CONFIG_CYZ_INTR
-       cy_writel(&ch_ctrl[channel].intr_enable, 
-                 C_IN_TXBEMPTY|C_IN_TXLOWWM|C_IN_RXHIWM|C_IN_RXNNDT|
-                 C_IN_IOCTLW|
-                 C_IN_MDCD);
+               cy_writel(&ch_ctrl[channel].intr_enable,
+                         C_IN_TXBEMPTY | C_IN_TXLOWWM | C_IN_RXHIWM |
+                         C_IN_RXNNDT | C_IN_IOCTLW | C_IN_MDCD);
 #else
-       cy_writel(&ch_ctrl[channel].intr_enable, 
-                 C_IN_IOCTLW|
-                 C_IN_MDCD);
-#endif /* CONFIG_CYZ_INTR */
+               cy_writel(&ch_ctrl[channel].intr_enable,
+                         C_IN_IOCTLW | C_IN_MDCD);
+#endif                         /* CONFIG_CYZ_INTR */
 #else
 #ifdef CONFIG_CYZ_INTR
-       cy_writel(&ch_ctrl[channel].intr_enable, 
-                 C_IN_TXBEMPTY|C_IN_TXLOWWM|C_IN_RXHIWM|C_IN_RXNNDT|
-                 C_IN_MDCD);
+               cy_writel(&ch_ctrl[channel].intr_enable,
+                         C_IN_TXBEMPTY | C_IN_TXLOWWM | C_IN_RXHIWM |
+                         C_IN_RXNNDT | C_IN_MDCD);
 #else
-       cy_writel(&ch_ctrl[channel].intr_enable, 
-                 C_IN_MDCD);
-#endif /* CONFIG_CYZ_INTR */
-#endif /* Z_WAKE */
-
-       retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_IOCTL, 0L);
-       if (retval != 0){
-           printk("cyc:startup(1) retval on ttyC%d was %x\n",
-                  info->line, retval);
-       }
+               cy_writel(&ch_ctrl[channel].intr_enable, C_IN_MDCD);
+#endif                         /* CONFIG_CYZ_INTR */
+#endif                         /* Z_WAKE */
+
+               retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_IOCTL, 0L);
+               if (retval != 0) {
+                       printk("cyc:startup(1) retval on ttyC%d was %x\n",
+                               info->line, retval);
+               }
 
-       /* Flush RX buffers before raising DTR and RTS */
-       retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_FLUSH_RX, 0L);
-       if (retval != 0){
-           printk("cyc:startup(2) retval on ttyC%d was %x\n",
-                  info->line, retval);
-       }
+               /* Flush RX buffers before raising DTR and RTS */
+               retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_FLUSH_RX,
+                               0L);
+               if (retval != 0) {
+                       printk("cyc:startup(2) retval on ttyC%d was %x\n",
+                               info->line, retval);
+               }
 
-       /* set timeout !!! */
-       /* set RTS and DTR !!! */
-       cy_writel(&ch_ctrl[channel].rs_control,
-             cy_readl(&ch_ctrl[channel].rs_control) | C_RS_RTS | C_RS_DTR) ;
-       retval = cyz_issue_cmd(&cy_card[info->card],
-           channel, C_CM_IOCTLM, 0L);
-       if (retval != 0){
-           printk("cyc:startup(3) retval on ttyC%d was %x\n",
-                  info->line, retval);
-       }
+               /* set timeout !!! */
+               /* set RTS and DTR !!! */
+               cy_writel(&ch_ctrl[channel].rs_control,
+                       cy_readl(&ch_ctrl[channel].rs_control) | C_RS_RTS |
+                       C_RS_DTR);
+               retval = cyz_issue_cmd(&cy_card[info->card], channel,
+                               C_CM_IOCTLM, 0L);
+               if (retval != 0) {
+                       printk("cyc:startup(3) retval on ttyC%d was %x\n",
+                               info->line, retval);
+               }
 #ifdef CY_DEBUG_DTR
-           printk("cyc:startup raising Z DTR\n");
+               printk("cyc:startup raising Z DTR\n");
 #endif
 
-       /* enable send, recv, modem !!! */
+               /* enable send, recv, modem !!! */
 
-       info->flags |= ASYNC_INITIALIZED;
-       if (info->tty){
-           clear_bit(TTY_IO_ERROR, &info->tty->flags);
-       }
-       info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
-       info->breakon = info->breakoff = 0;
-       memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats));
-       info->idle_stats.in_use    =
-       info->idle_stats.recv_idle =
-       info->idle_stats.xmit_idle = jiffies;
+               info->flags |= ASYNC_INITIALIZED;
+               if (info->tty) {
+                       clear_bit(TTY_IO_ERROR, &info->tty->flags);
+               }
+               info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
+               info->breakon = info->breakoff = 0;
+               memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats));
+               info->idle_stats.in_use =
+               info->idle_stats.recv_idle =
+               info->idle_stats.xmit_idle = jiffies;
 
-       CY_UNLOCK(info, flags);
-    }
+               CY_UNLOCK(info, flags);
+       }
 
 #ifdef CY_DEBUG_OPEN
        printk(" cyc startup done\n");
@@ -2094,165 +2154,165 @@ startup(struct cyclades_port * info)
 errout:
        CY_UNLOCK(info, flags);
        return retval;
-} /* startup */
-
+}                              /* startup */
 
-static void
-start_xmit( struct cyclades_port *info )
+static void start_xmit(struct cyclades_port *info)
 {
-  unsigned long flags;
-  void __iomem *base_addr;
-  int card,chip,channel,index;
-
-    card = info->card;
-    channel = (info->line) - (cy_card[card].first_line);
-    if (!IS_CYC_Z(cy_card[card])) {
-       chip = channel>>2;
-       channel &= 0x03;
-       index = cy_card[card].bus_index;
-       base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index);
+       unsigned long flags;
+       void __iomem *base_addr;
+       int card, chip, channel, index;
 
-       CY_LOCK(info, flags);
-           cy_writeb(base_addr+(CyCAR<<index), channel);
-           cy_writeb(base_addr+(CySRER<<index), 
-               cy_readb(base_addr+(CySRER<<index)) | CyTxRdy);
-       CY_UNLOCK(info, flags);
-    } else {
-#ifdef CONFIG_CYZ_INTR
-      int retval;
+       card = info->card;
+       channel = (info->line) - (cy_card[card].first_line);
+       if (!IS_CYC_Z(cy_card[card])) {
+               chip = channel >> 2;
+               channel &= 0x03;
+               index = cy_card[card].bus_index;
+               base_addr = cy_card[card].base_addr +
+                               (cy_chip_offset[chip] << index);
 
-       CY_LOCK(info, flags);
-           retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_INTBACK, 0L);
-           if (retval != 0){
-               printk("cyc:start_xmit retval on ttyC%d was %x\n",
-                      info->line, retval);
-           }
-       CY_UNLOCK(info, flags);
-#else /* CONFIG_CYZ_INTR */
-       /* Don't have to do anything at this time */
-#endif /* CONFIG_CYZ_INTR */
-    }
-} /* start_xmit */
+               CY_LOCK(info, flags);
+               cy_writeb(base_addr + (CyCAR << index), channel);
+               cy_writeb(base_addr + (CySRER << index),
+                       cy_readb(base_addr + (CySRER << index)) | CyTxRdy);
+               CY_UNLOCK(info, flags);
+       } else {
+#ifdef CONFIG_CYZ_INTR
+               int retval;
+
+               CY_LOCK(info, flags);
+               retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_INTBACK,
+                               0L);
+               if (retval != 0) {
+                       printk("cyc:start_xmit retval on ttyC%d was %x\n",
+                               info->line, retval);
+               }
+               CY_UNLOCK(info, flags);
+#else                          /* CONFIG_CYZ_INTR */
+               /* Don't have to do anything at this time */
+#endif                         /* CONFIG_CYZ_INTR */
+       }
+}                              /* start_xmit */
 
 /*
  * This routine shuts down a serial port; interrupts are disabled,
  * and DTR is dropped if the hangup on close termio flag is on.
  */
-static void
-shutdown(struct cyclades_port * info)
+static void shutdown(struct cyclades_port *info)
 {
-  unsigned long flags;
-  void __iomem *base_addr;
-  int card,chip,channel,index;
-
-    if (!(info->flags & ASYNC_INITIALIZED)){
-        return;
-    }
-
-    card = info->card;
-    channel = info->line - cy_card[card].first_line;
-    if (!IS_CYC_Z(cy_card[card])) {
-       chip = channel>>2;
-       channel &= 0x03;
-       index = cy_card[card].bus_index;
-       base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index);
+       unsigned long flags;
+       void __iomem *base_addr;
+       int card, chip, channel, index;
+
+       if (!(info->flags & ASYNC_INITIALIZED)) {
+               return;
+       }
+
+       card = info->card;
+       channel = info->line - cy_card[card].first_line;
+       if (!IS_CYC_Z(cy_card[card])) {
+               chip = channel >> 2;
+               channel &= 0x03;
+               index = cy_card[card].bus_index;
+               base_addr = cy_card[card].base_addr +
+                               (cy_chip_offset[chip] << index);
 
 #ifdef CY_DEBUG_OPEN
-    printk("cyc shutdown Y card %d, chip %d, channel %d, base_addr %lx\n",
-               card, chip, channel, (long)base_addr);
+               printk("cyc shutdown Y card %d, chip %d, channel %d, "
+                               "base_addr %lx\n",
+                               card, chip, channel, (long)base_addr);
 #endif
 
-       CY_LOCK(info, flags);
+               CY_LOCK(info, flags);
+
+               /* Clear delta_msr_wait queue to avoid mem leaks. */
+               wake_up_interruptible(&info->delta_msr_wait);
 
-           /* Clear delta_msr_wait queue to avoid mem leaks. */
-           wake_up_interruptible(&info->delta_msr_wait);
-
-           if (info->xmit_buf){
-               unsigned char * temp;
-               temp = info->xmit_buf;
-               info->xmit_buf = NULL;
-               free_page((unsigned long) temp);
-           }
-           cy_writeb(base_addr+(CyCAR<<index), (u_char)channel);
-           if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
-               cy_writeb(base_addr+(CyMSVR1<<index), ~CyRTS);
-               cy_writeb(base_addr+(CyMSVR2<<index), ~CyDTR);
+               if (info->xmit_buf) {
+                       unsigned char *temp;
+                       temp = info->xmit_buf;
+                       info->xmit_buf = NULL;
+                       free_page((unsigned long)temp);
+               }
+               cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
+               if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
+                       cy_writeb(base_addr + (CyMSVR1 << index), ~CyRTS);
+                       cy_writeb(base_addr + (CyMSVR2 << index), ~CyDTR);
 #ifdef CY_DEBUG_DTR
-               printk("cyc shutdown dropping DTR\n");
-               printk("     status: 0x%x, 0x%x\n",
-                   cy_readb(base_addr+(CyMSVR1<<index)), 
-                    cy_readb(base_addr+(CyMSVR2<<index)));
+                       printk("cyc shutdown dropping DTR\n");
+                       printk("     status: 0x%x, 0x%x\n",
+                               cy_readb(base_addr + (CyMSVR1 << index)),
+                               cy_readb(base_addr + (CyMSVR2 << index)));
 #endif
-           }
-           cyy_issue_cmd(base_addr,CyCHAN_CTL|CyDIS_RCVR,index);
-            /* it may be appropriate to clear _XMIT at
-              some later date (after testing)!!! */
-
-           if (info->tty){
-               set_bit(TTY_IO_ERROR, &info->tty->flags);
-           }
-           info->flags &= ~ASYNC_INITIALIZED;
-       CY_UNLOCK(info, flags);
-    } else {
-      struct FIRM_ID __iomem *firm_id;
-      struct ZFW_CTRL __iomem *zfw_ctrl;
-      struct BOARD_CTRL __iomem *board_ctrl;
-      struct CH_CTRL __iomem *ch_ctrl;
-      int retval;
-
-       base_addr = cy_card[card].base_addr;
+               }
+               cyy_issue_cmd(base_addr, CyCHAN_CTL | CyDIS_RCVR, index);
+               /* it may be appropriate to clear _XMIT at
+                  some later date (after testing)!!! */
+
+               if (info->tty) {
+                       set_bit(TTY_IO_ERROR, &info->tty->flags);
+               }
+               info->flags &= ~ASYNC_INITIALIZED;
+               CY_UNLOCK(info, flags);
+       } else {
+               struct FIRM_ID __iomem *firm_id;
+               struct ZFW_CTRL __iomem *zfw_ctrl;
+               struct BOARD_CTRL __iomem *board_ctrl;
+               struct CH_CTRL __iomem *ch_ctrl;
+               int retval;
+
+               base_addr = cy_card[card].base_addr;
 #ifdef CY_DEBUG_OPEN
-    printk("cyc shutdown Z card %d, channel %d, base_addr %lx\n",
-               card, channel, (long)base_addr);
+               printk("cyc shutdown Z card %d, channel %d, base_addr %lx\n",
+                       card, channel, (long)base_addr);
 #endif
 
-        firm_id = base_addr + ID_ADDRESS;
-        if (!ISZLOADED(cy_card[card])) {
-           return;
-       }
+               firm_id = base_addr + ID_ADDRESS;
+               if (!ISZLOADED(cy_card[card])) {
+                       return;
+               }
 
-       zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
-       board_ctrl = &zfw_ctrl->board_ctrl;
-       ch_ctrl = zfw_ctrl->ch_ctrl;
+               zfw_ctrl = cy_card[card].base_addr +
+                               (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
+               board_ctrl = &zfw_ctrl->board_ctrl;
+               ch_ctrl = zfw_ctrl->ch_ctrl;
 
-       CY_LOCK(info, flags);
+               CY_LOCK(info, flags);
 
-           if (info->xmit_buf){
-               unsigned char * temp;
-               temp = info->xmit_buf;
-               info->xmit_buf = NULL;
-               free_page((unsigned long) temp);
-           }
-           
-           if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
-               cy_writel(&ch_ctrl[channel].rs_control,
-                   (uclong)(cy_readl(&ch_ctrl[channel].rs_control) & 
-                   ~(C_RS_RTS | C_RS_DTR)));
-               retval = cyz_issue_cmd(&cy_card[info->card],
-                       channel, C_CM_IOCTLM, 0L);
-               if (retval != 0){
-                   printk("cyc:shutdown retval on ttyC%d was %x\n",
-                          info->line, retval);
+               if (info->xmit_buf) {
+                       unsigned char *temp;
+                       temp = info->xmit_buf;
+                       info->xmit_buf = NULL;
+                       free_page((unsigned long)temp);
                }
+
+               if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
+                       cy_writel(&ch_ctrl[channel].rs_control,
+                               (uclong)(cy_readl(&ch_ctrl[channel].rs_control)&
+                                       ~(C_RS_RTS | C_RS_DTR)));
+                       retval = cyz_issue_cmd(&cy_card[info->card], channel,
+                                       C_CM_IOCTLM, 0L);
+                       if (retval != 0) {
+                               printk("cyc:shutdown retval on ttyC%d was %x\n",
+                                       info->line, retval);
+                       }
 #ifdef CY_DEBUG_DTR
-               printk("cyc:shutdown dropping Z DTR\n");
+                       printk("cyc:shutdown dropping Z DTR\n");
 #endif
-           }
-           
-           if (info->tty){
-               set_bit(TTY_IO_ERROR, &info->tty->flags);
-           }
-           info->flags &= ~ASYNC_INITIALIZED;
+               }
 
-       CY_UNLOCK(info, flags);
-    }
+               if (info->tty) {
+                       set_bit(TTY_IO_ERROR, &info->tty->flags);
+               }
+               info->flags &= ~ASYNC_INITIALIZED;
+
+               CY_UNLOCK(info, flags);
+       }
 
 #ifdef CY_DEBUG_OPEN
-    printk(" cyc shutdown done\n");
+       printk(" cyc shutdown done\n");
 #endif
-    return;
-} /* shutdown */
-
+}                              /* shutdown */
 
 /*
  * ------------------------------------------------------------
@@ -2261,527 +2321,546 @@ shutdown(struct cyclades_port * info)
  */
 
 static int
-block_til_ready(struct tty_struct *tty, struct file * filp,
-                           struct cyclades_port *info)
+block_til_ready(struct tty_struct *tty, struct file *filp,
+               struct cyclades_port *info)
 {
-  DECLARE_WAITQUEUE(wait, current);
-  struct cyclades_card *cinfo;
-  unsigned long flags;
-  int chip, channel,index;
-  int retval;
-  void __iomem *base_addr;
-
-    cinfo = &cy_card[info->card];
-    channel = info->line - cinfo->first_line;
-
-    /*
-     * If the device is in the middle of being closed, then block
-     * until it's done, and then try again.
-     */
-    if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) {
-       if (info->flags & ASYNC_CLOSING) {
-            interruptible_sleep_on(&info->close_wait);
+       DECLARE_WAITQUEUE(wait, current);
+       struct cyclades_card *cinfo;
+       unsigned long flags;
+       int chip, channel, index;
+       int retval;
+       void __iomem *base_addr;
+
+       cinfo = &cy_card[info->card];
+       channel = info->line - cinfo->first_line;
+
+       /*
+        * If the device is in the middle of being closed, then block
+        * until it's done, and then try again.
+        */
+       if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) {
+               if (info->flags & ASYNC_CLOSING) {
+                       interruptible_sleep_on(&info->close_wait);
+               }
+               return (info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS;
        }
-        return ((info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS);
-    }
-
-    /*
-     * If non-blocking mode is set, then make the check up front
-     * and then exit.
-     */
-    if ((filp->f_flags & O_NONBLOCK) ||
-       (tty->flags & (1 << TTY_IO_ERROR))) {
-        info->flags |= ASYNC_NORMAL_ACTIVE;
-        return 0;
-    }
-
-    /*
-     * Block waiting for the carrier detect and the line to become
-     * free (i.e., not in use by the callout).  While we are in
-     * this loop, info->count is dropped by one, so that
-     * cy_close() knows when to free things.  We restore it upon
-     * exit, either normal or abnormal.
-     */
-    retval = 0;
-    add_wait_queue(&info->open_wait, &wait);
+
+       /*
+        * If non-blocking mode is set, then make the check up front
+        * and then exit.
+        */
+       if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) {
+               info->flags |= ASYNC_NORMAL_ACTIVE;
+               return 0;
+       }
+
+       /*
+        * Block waiting for the carrier detect and the line to become
+        * free (i.e., not in use by the callout).  While we are in
+        * this loop, info->count is dropped by one, so that
+        * cy_close() knows when to free things.  We restore it upon
+        * exit, either normal or abnormal.
+        */
+       retval = 0;
+       add_wait_queue(&info->open_wait, &wait);
 #ifdef CY_DEBUG_OPEN
-    printk("cyc block_til_ready before block: ttyC%d, count = %d\n",
-           info->line, info->count);/**/
+       printk("cyc block_til_ready before block: ttyC%d, count = %d\n",
+               info->line, info->count);
+       /**/
 #endif
-    CY_LOCK(info, flags);
-    if (!tty_hung_up_p(filp))
-       info->count--;
-    CY_UNLOCK(info, flags);
+       CY_LOCK(info, flags);
+       if (!tty_hung_up_p(filp))
+               info->count--;
+       CY_UNLOCK(info, flags);
 #ifdef CY_DEBUG_COUNT
-    printk("cyc block_til_ready: (%d): decrementing count to %d\n",
-        current->pid, info->count);
+       printk("cyc block_til_ready: (%d): decrementing count to %d\n",
+               current->pid, info->count);
 #endif
-    info->blocked_open++;
-
-    if (!IS_CYC_Z(*cinfo)) {
-       chip = channel>>2;
-       channel &= 0x03;
-       index = cinfo->bus_index;
-       base_addr = cinfo->base_addr + (cy_chip_offset[chip]<<index);
-
-       while (1) {
-           CY_LOCK(info, flags);
-               if ((tty->termios->c_cflag & CBAUD)){
-                   cy_writeb(base_addr+(CyCAR<<index), (u_char)channel);
-                   cy_writeb(base_addr+(CyMSVR1<<index), CyRTS);
-                   cy_writeb(base_addr+(CyMSVR2<<index), CyDTR);
+       info->blocked_open++;
+
+       if (!IS_CYC_Z(*cinfo)) {
+               chip = channel >> 2;
+               channel &= 0x03;
+               index = cinfo->bus_index;
+               base_addr = cinfo->base_addr + (cy_chip_offset[chip] << index);
+
+               while (1) {
+                       CY_LOCK(info, flags);
+                       if ((tty->termios->c_cflag & CBAUD)) {
+                               cy_writeb(base_addr + (CyCAR << index),
+                                         (u_char) channel);
+                               cy_writeb(base_addr + (CyMSVR1 << index),
+                                         CyRTS);
+                               cy_writeb(base_addr + (CyMSVR2 << index),
+                                         CyDTR);
 #ifdef CY_DEBUG_DTR
-                   printk("cyc:block_til_ready raising DTR\n");
-                   printk("     status: 0x%x, 0x%x\n",
-                       cy_readb(base_addr+(CyMSVR1<<index)), 
-                        cy_readb(base_addr+(CyMSVR2<<index)));
+                               printk("cyc:block_til_ready raising DTR\n");
+                               printk("     status: 0x%x, 0x%x\n",
+                                       cy_readb(base_addr +
+                                               (CyMSVR1 << index)),
+                                       cy_readb(base_addr +
+                                               (CyMSVR2 << index)));
 #endif
-               }
-           CY_UNLOCK(info, flags);
+                       }
+                       CY_UNLOCK(info, flags);
 
-           set_current_state(TASK_INTERRUPTIBLE);
-           if (tty_hung_up_p(filp)
-           || !(info->flags & ASYNC_INITIALIZED) ){
-               retval = ((info->flags & ASYNC_HUP_NOTIFY) ? 
-                   -EAGAIN : -ERESTARTSYS);
-               break;
-           }
+                       set_current_state(TASK_INTERRUPTIBLE);
+                       if (tty_hung_up_p(filp) ||
+                                       !(info->flags & ASYNC_INITIALIZED)) {
+                               retval = ((info->flags & ASYNC_HUP_NOTIFY) ?
+                                         -EAGAIN : -ERESTARTSYS);
+                               break;
+                       }
 
-           CY_LOCK(info, flags);
-               cy_writeb(base_addr+(CyCAR<<index), (u_char)channel);
-               if (!(info->flags & ASYNC_CLOSING)
-               && (C_CLOCAL(tty)
-                   || (cy_readb(base_addr+(CyMSVR1<<index)) & CyDCD))) {
+                       CY_LOCK(info, flags);
+                       cy_writeb(base_addr + (CyCAR << index),
+                                 (u_char) channel);
+                       if (!(info->flags & ASYNC_CLOSING) && (C_CLOCAL(tty) ||
+                                       (cy_readb(base_addr +
+                                               (CyMSVR1 << index)) & CyDCD))) {
+                               CY_UNLOCK(info, flags);
+                               break;
+                       }
                        CY_UNLOCK(info, flags);
-                       break;
-               }
-           CY_UNLOCK(info, flags);
 
-           if (signal_pending(current)) {
-               retval = -ERESTARTSYS;
-               break;
-           }
+                       if (signal_pending(current)) {
+                               retval = -ERESTARTSYS;
+                               break;
+                       }
 #ifdef CY_DEBUG_OPEN
-           printk("cyc block_til_ready blocking: ttyC%d, count = %d\n",
-                  info->line, info->count);/**/
+                       printk("cyc block_til_ready blocking: ttyC%d, "
+                                       "count = %d\n",
+                                       info->line, info->count);
+                       /**/
 #endif
-           schedule();
-       }
-    } else {
-      struct FIRM_ID __iomem *firm_id;
-      struct ZFW_CTRL __iomem *zfw_ctrl;
-      struct BOARD_CTRL __iomem *board_ctrl;
-      struct CH_CTRL __iomem *ch_ctrl;
-      int retval;
-
-       base_addr = cinfo->base_addr;
-       firm_id = base_addr + ID_ADDRESS;
-        if (!ISZLOADED(*cinfo)){
-            current->state = TASK_RUNNING;
-           remove_wait_queue(&info->open_wait, &wait);
-           return -EINVAL;
-       }
-
-       zfw_ctrl = base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
-       board_ctrl = &zfw_ctrl->board_ctrl;
-       ch_ctrl = zfw_ctrl->ch_ctrl;
-
-       while (1) {
-           if ((tty->termios->c_cflag & CBAUD)){
-               cy_writel(&ch_ctrl[channel].rs_control,
-                       cy_readl(&ch_ctrl[channel].rs_control) |
-                       (C_RS_RTS | C_RS_DTR));
-               retval = cyz_issue_cmd(&cy_card[info->card],
-                                      channel, C_CM_IOCTLM, 0L);
-               if (retval != 0){
-                   printk("cyc:block_til_ready retval on ttyC%d was %x\n",
-                          info->line, retval);
+                       schedule();
+               }
+       } else {
+               struct FIRM_ID __iomem *firm_id;
+               struct ZFW_CTRL __iomem *zfw_ctrl;
+               struct BOARD_CTRL __iomem *board_ctrl;
+               struct CH_CTRL __iomem *ch_ctrl;
+               int retval;
+
+               base_addr = cinfo->base_addr;
+               firm_id = base_addr + ID_ADDRESS;
+               if (!ISZLOADED(*cinfo)) {
+                       current->state = TASK_RUNNING;
+                       remove_wait_queue(&info->open_wait, &wait);
+                       return -EINVAL;
                }
+
+               zfw_ctrl = base_addr + (cy_readl(&firm_id->zfwctrl_addr) &
+                               0xfffff);
+               board_ctrl = &zfw_ctrl->board_ctrl;
+               ch_ctrl = zfw_ctrl->ch_ctrl;
+
+               while (1) {
+                       if ((tty->termios->c_cflag & CBAUD)) {
+                               cy_writel(&ch_ctrl[channel].rs_control,
+                                         cy_readl(&ch_ctrl[channel].
+                                                  rs_control) | (C_RS_RTS |
+                                                                 C_RS_DTR));
+                               retval = cyz_issue_cmd(&cy_card[info->card],
+                                               channel, C_CM_IOCTLM, 0L);
+                               if (retval != 0) {
+                                       printk("cyc:block_til_ready retval on "
+                                               "ttyC%d was %x\n",
+                                               info->line, retval);
+                               }
 #ifdef CY_DEBUG_DTR
-               printk("cyc:block_til_ready raising Z DTR\n");
+                               printk("cyc:block_til_ready raising Z DTR\n");
 #endif
-           }
+                       }
 
-           set_current_state(TASK_INTERRUPTIBLE);
-           if (tty_hung_up_p(filp)
-           || !(info->flags & ASYNC_INITIALIZED) ){
-               retval = ((info->flags & ASYNC_HUP_NOTIFY) ?
-                   -EAGAIN : -ERESTARTSYS);
-               break;
-           }
-           if (!(info->flags & ASYNC_CLOSING)
-           && (C_CLOCAL(tty)
-             || (cy_readl(&ch_ctrl[channel].rs_status) & C_RS_DCD))) {
-               break;
-           }
-           if (signal_pending(current)) {
-               retval = -ERESTARTSYS;
-               break;
-           }
+                       set_current_state(TASK_INTERRUPTIBLE);
+                       if (tty_hung_up_p(filp) ||
+                                       !(info->flags & ASYNC_INITIALIZED)) {
+                               retval = ((info->flags & ASYNC_HUP_NOTIFY) ?
+                                         -EAGAIN : -ERESTARTSYS);
+                               break;
+                       }
+                       if (!(info->flags & ASYNC_CLOSING) && (C_CLOCAL(tty) ||
+                                       (cy_readl(&ch_ctrl[channel].rs_status) &
+                                               C_RS_DCD))) {
+                               break;
+                       }
+                       if (signal_pending(current)) {
+                               retval = -ERESTARTSYS;
+                               break;
+                       }
 #ifdef CY_DEBUG_OPEN
-           printk("cyc block_til_ready blocking: ttyC%d, count = %d\n",
-                  info->line, info->count);/**/
+                       printk("cyc block_til_ready blocking: ttyC%d, "
+                                       "count = %d\n",
+                                       info->line, info->count);
+                       /**/
 #endif
-           schedule();
+                       schedule();
+               }
        }
-    }
-    current->state = TASK_RUNNING;
-    remove_wait_queue(&info->open_wait, &wait);
-    if (!tty_hung_up_p(filp)){
-       info->count++;
+       current->state = TASK_RUNNING;
+       remove_wait_queue(&info->open_wait, &wait);
+       if (!tty_hung_up_p(filp)) {
+               info->count++;
 #ifdef CY_DEBUG_COUNT
-       printk("cyc:block_til_ready (%d): incrementing count to %d\n",
-           current->pid, info->count);
+               printk("cyc:block_til_ready (%d): incrementing count to %d\n",
+                       current->pid, info->count);
 #endif
-    }
-    info->blocked_open--;
+       }
+       info->blocked_open--;
 #ifdef CY_DEBUG_OPEN
-    printk("cyc:block_til_ready after blocking: ttyC%d, count = %d\n",
-          info->line, info->count);/**/
+       printk("cyc:block_til_ready after blocking: ttyC%d, count = %d\n",
+               info->line, info->count);
+       /**/
 #endif
-    if (retval)
-       return retval;
-    info->flags |= ASYNC_NORMAL_ACTIVE;
-    return 0;
-} /* block_til_ready */
-
+       if (retval)
+               return retval;
+       info->flags |= ASYNC_NORMAL_ACTIVE;
+       return 0;
+}                              /* block_til_ready */
 
 /*
  * This routine is called whenever a serial port is opened.  It
  * performs the serial-specific initialization for the tty structure.
  */
-static int
-cy_open(struct tty_struct *tty, struct file * filp)
+static int cy_open(struct tty_struct *tty, struct file *filp)
 {
-  struct cyclades_port  *info;
-  int retval, line;
-
-    line = tty->index;
-    if ((line < 0) || (NR_PORTS <= line)){
-        return -ENODEV;
-    }
-    info = &cy_port[line];
-    if (info->line < 0){
-        return -ENODEV;
-    }
-    
-    /* If the card's firmware hasn't been loaded,
-       treat it as absent from the system.  This
-       will make the user pay attention.
-    */
-    if (IS_CYC_Z(cy_card[info->card])) {
-       struct cyclades_card *cinfo = &cy_card[info->card];
-       struct FIRM_ID __iomem *firm_id = cinfo->base_addr + ID_ADDRESS;
-
-        if (!ISZLOADED(*cinfo)) {
-           if (((ZE_V1 ==cy_readl(&((struct RUNTIME_9060 __iomem *)
-               (cinfo->ctl_addr))->mail_box_0)) &&
-               Z_FPGA_CHECK (*cinfo)) &&
-               (ZFIRM_HLT == cy_readl (&firm_id->signature)))
-           {
-               printk ("cyc:Cyclades-Z Error: you need an external power supply for this number of ports.\n\rFirmware halted.\r\n");
-           } else {
-               printk("cyc:Cyclades-Z firmware not yet loaded\n");
-           }
-           return -ENODEV;
-       }
-#ifdef CONFIG_CYZ_INTR
-       else {
-           /* In case this Z board is operating in interrupt mode, its 
-              interrupts should be enabled as soon as the first open happens 
-              to one of its ports. */
-            if (!cinfo->intr_enabled) {
-               struct ZFW_CTRL __iomem *zfw_ctrl;
-               struct BOARD_CTRL __iomem *board_ctrl;
-
-               zfw_ctrl = cinfo->base_addr + (cy_readl (&firm_id->zfwctrl_addr) & 0xfffff);
+       struct cyclades_port *info;
+       int retval, line;
 
-               board_ctrl = &zfw_ctrl->board_ctrl;
+       line = tty->index;
+       if ((line < 0) || (NR_PORTS <= line)) {
+               return -ENODEV;
+       }
+       info = &cy_port[line];
+       if (info->line < 0) {
+               return -ENODEV;
+       }
 
-               /* Enable interrupts on the PLX chip */
-               cy_writew(cinfo->ctl_addr+0x68,
-                       cy_readw(cinfo->ctl_addr+0x68)|0x0900);
-               /* Enable interrupts on the FW */
-               retval = cyz_issue_cmd(cinfo,
-                                       0, C_CM_IRQ_ENBL, 0L);
-               if (retval != 0){
-                   printk("cyc:IRQ enable retval was %x\n", retval);
+       /* If the card's firmware hasn't been loaded,
+          treat it as absent from the system.  This
+          will make the user pay attention.
+        */
+       if (IS_CYC_Z(cy_card[info->card])) {
+               struct cyclades_card *cinfo = &cy_card[info->card];
+               struct FIRM_ID __iomem *firm_id = cinfo->base_addr + ID_ADDRESS;
+
+               if (!ISZLOADED(*cinfo)) {
+                       if (((ZE_V1 == cy_readl(
+                                       &((struct RUNTIME_9060 __iomem *)
+                                        (cinfo->ctl_addr))->mail_box_0)) &&
+                                       Z_FPGA_CHECK(*cinfo)) &&
+                                       (ZFIRM_HLT == cy_readl(
+                                               &firm_id->signature))) {
+                               printk("cyc:Cyclades-Z Error: you need an "
+                                       "external power supply for this number "
+                                       "of ports.\n\rFirmware halted.\r\n");
+                       } else {
+                               printk("cyc:Cyclades-Z firmware not yet "
+                                       "loaded\n");
+                       }
+                       return -ENODEV;
                }
-               cinfo->nports = (int) cy_readl (&board_ctrl->n_channel);
-               cinfo->intr_enabled = 1;
-           }
+#ifdef CONFIG_CYZ_INTR
+               else {
+               /* In case this Z board is operating in interrupt mode, its
+                  interrupts should be enabled as soon as the first open
+                  happens to one of its ports. */
+                       if (!cinfo->intr_enabled) {
+                               struct ZFW_CTRL __iomem *zfw_ctrl;
+                               struct BOARD_CTRL __iomem *board_ctrl;
+
+                               zfw_ctrl = cinfo->base_addr +
+                                       (cy_readl(&firm_id->zfwctrl_addr) &
+                                               0xfffff);
+
+                               board_ctrl = &zfw_ctrl->board_ctrl;
+
+                               /* Enable interrupts on the PLX chip */
+                               cy_writew(cinfo->ctl_addr + 0x68,
+                                         cy_readw(cinfo->ctl_addr +
+                                                  0x68) | 0x0900);
+                               /* Enable interrupts on the FW */
+                               retval = cyz_issue_cmd(cinfo, 0,
+                                               C_CM_IRQ_ENBL, 0L);
+                               if (retval != 0) {
+                                       printk("cyc:IRQ enable retval was %x\n",
+                                               retval);
+                               }
+                               cinfo->nports =
+                                       (int)cy_readl(&board_ctrl->n_channel);
+                               cinfo->intr_enabled = 1;
+                       }
+               }
+#endif                         /* CONFIG_CYZ_INTR */
+               /* Make sure this Z port really exists in hardware */
+               if (info->line > (cinfo->first_line + cinfo->nports - 1))
+                       return -ENODEV;
        }
-#endif /* CONFIG_CYZ_INTR */
-       /* Make sure this Z port really exists in hardware */
-       if (info->line > (cinfo->first_line + cinfo->nports - 1))
-               return -ENODEV;
-    }
 #ifdef CY_DEBUG_OTHER
-    printk("cyc:cy_open ttyC%d\n", info->line); /* */
+       printk("cyc:cy_open ttyC%d\n", info->line);     /* */
 #endif
-    tty->driver_data = info;
-    info->tty = tty;
-    if (serial_paranoia_check(info, tty->name, "cy_open")){
-        return -ENODEV;
-    }
+       tty->driver_data = info;
+       info->tty = tty;
+       if (serial_paranoia_check(info, tty->name, "cy_open")) {
+               return -ENODEV;
+       }
 #ifdef CY_DEBUG_OPEN
-    printk("cyc:cy_open ttyC%d, count = %d\n",
-        info->line, info->count);/**/
+       printk("cyc:cy_open ttyC%d, count = %d\n", info->line, info->count);
+       /**/
 #endif
-    info->count++;
+       info->count++;
 #ifdef CY_DEBUG_COUNT
-    printk("cyc:cy_open (%d): incrementing count to %d\n",
-        current->pid, info->count);
+       printk("cyc:cy_open (%d): incrementing count to %d\n",
+               current->pid, info->count);
 #endif
 
-    /*
-     * If the port is the middle of closing, bail out now
-     */
-    if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) {
-       if (info->flags & ASYNC_CLOSING)
-           interruptible_sleep_on(&info->close_wait);
-       return ((info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS);
-    }
-
-    /*
-     * Start up serial port
-     */
-    retval = startup(info);
-    if (retval){
-        return retval;
-    }
-
-    retval = block_til_ready(tty, filp, info);
-    if (retval) {
-#ifdef CY_DEBUG_OPEN
-        printk("cyc:cy_open returning after block_til_ready with %d\n",
-               retval);
-#endif
-        return retval;
-    }
+       /*
+        * If the port is the middle of closing, bail out now
+        */
+       if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) {
+               if (info->flags & ASYNC_CLOSING)
+                       interruptible_sleep_on(&info->close_wait);
+               return (info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS;
+       }
 
-    info->throttle = 0;
+       /*
+        * Start up serial port
+        */
+       retval = startup(info);
+       if (retval) {
+               return retval;
+       }
 
+       retval = block_til_ready(tty, filp, info);
+       if (retval) {
 #ifdef CY_DEBUG_OPEN
-    printk(" cyc:cy_open done\n");/**/
+               printk("cyc:cy_open returning after block_til_ready with %d\n",
+                       retval);
 #endif
+               return retval;
+       }
 
-    return 0;
-} /* cy_open */
+       info->throttle = 0;
 
+#ifdef CY_DEBUG_OPEN
+       printk(" cyc:cy_open done\n");
+       /**/
+#endif
+       return 0;
+}                              /* cy_open */
 
 /*
  * cy_wait_until_sent() --- wait until the transmitter is empty
  */
-static void 
-cy_wait_until_sent(struct tty_struct *tty, int timeout)
+static void cy_wait_until_sent(struct tty_struct *tty, int timeout)
 {
-  struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
-  void __iomem *base_addr;
-  int card,chip,channel,index;
-  unsigned long orig_jiffies;
-  int char_time;
-       
-    if (serial_paranoia_check(info, tty->name, "cy_wait_until_sent"))
-       return;
-
-    if (info->xmit_fifo_size == 0)
-       return; /* Just in case.... */
-
-
-    orig_jiffies = jiffies;
-    /*
-     * Set the check interval to be 1/5 of the estimated time to
-     * send a single character, and make it at least 1.  The check
-     * interval should also be less than the timeout.
-     * 
-     * Note: we have to use pretty tight timings here to satisfy
-     * the NIST-PCTS.
-     */
-    char_time = (info->timeout - HZ/50) / info->xmit_fifo_size;
-    char_time = char_time / 5;
-    if (char_time <= 0)
-       char_time = 1;
-    if (timeout < 0)
-       timeout = 0;
-    if (timeout)
-       char_time = min(char_time, timeout);
-    /*
-     * If the transmitter hasn't cleared in twice the approximate
-     * amount of time to send the entire FIFO, it probably won't
-     * ever clear.  This assumes the UART isn't doing flow
-     * control, which is currently the case.  Hence, if it ever
-     * takes longer than info->timeout, this is probably due to a
-     * UART bug of some kind.  So, we clamp the timeout parameter at
-     * 2*info->timeout.
-     */
-    if (!timeout || timeout > 2*info->timeout)
-       timeout = 2*info->timeout;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       void __iomem *base_addr;
+       int card, chip, channel, index;
+       unsigned long orig_jiffies;
+       int char_time;
+
+       if (serial_paranoia_check(info, tty->name, "cy_wait_until_sent"))
+               return;
+
+       if (info->xmit_fifo_size == 0)
+               return;         /* Just in case.... */
+
+       orig_jiffies = jiffies;
+       /*
+        * Set the check interval to be 1/5 of the estimated time to
+        * send a single character, and make it at least 1.  The check
+        * interval should also be less than the timeout.
+        *
+        * Note: we have to use pretty tight timings here to satisfy
+        * the NIST-PCTS.
+        */
+       char_time = (info->timeout - HZ / 50) / info->xmit_fifo_size;
+       char_time = char_time / 5;
+       if (char_time <= 0)
+               char_time = 1;
+       if (timeout < 0)
+               timeout = 0;
+       if (timeout)
+               char_time = min(char_time, timeout);
+       /*
+        * If the transmitter hasn't cleared in twice the approximate
+        * amount of time to send the entire FIFO, it probably won't
+        * ever clear.  This assumes the UART isn't doing flow
+        * control, which is currently the case.  Hence, if it ever
+        * takes longer than info->timeout, this is probably due to a
+        * UART bug of some kind.  So, we clamp the timeout parameter at
+        * 2*info->timeout.
+        */
+       if (!timeout || timeout > 2 * info->timeout)
+               timeout = 2 * info->timeout;
 #ifdef CY_DEBUG_WAIT_UNTIL_SENT
-    printk("In cy_wait_until_sent(%d) check=%lu...", timeout, char_time);
-    printk("jiff=%lu...", jiffies);
+       printk("In cy_wait_until_sent(%d) check=%lu...", timeout, char_time);
+       printk("jiff=%lu...", jiffies);
 #endif
-    card = info->card;
-    channel = (info->line) - (cy_card[card].first_line);
-    if (!IS_CYC_Z(cy_card[card])) {
-       chip = channel>>2;
-       channel &= 0x03;
-       index = cy_card[card].bus_index;
-       base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index);
-       while (cy_readb(base_addr+(CySRER<<index)) & CyTxRdy) {
+       card = info->card;
+       channel = (info->line) - (cy_card[card].first_line);
+       if (!IS_CYC_Z(cy_card[card])) {
+               chip = channel >> 2;
+               channel &= 0x03;
+               index = cy_card[card].bus_index;
+               base_addr =
+                   cy_card[card].base_addr + (cy_chip_offset[chip] << index);
+               while (cy_readb(base_addr + (CySRER << index)) & CyTxRdy) {
 #ifdef CY_DEBUG_WAIT_UNTIL_SENT
-           printk("Not clean (jiff=%lu)...", jiffies);
+                       printk("Not clean (jiff=%lu)...", jiffies);
 #endif
-           if (msleep_interruptible(jiffies_to_msecs(char_time)))
-               break;
-           if (timeout && time_after(jiffies, orig_jiffies + timeout))
-               break;
+                       if (msleep_interruptible(jiffies_to_msecs(char_time)))
+                               break;
+                       if (timeout && time_after(jiffies, orig_jiffies +
+                                       timeout))
+                               break;
+               }
+       } else {
+               /* Nothing to do! */
        }
-    } else {
-       // Nothing to do!
-    }
-    /* Run one more char cycle */
-    msleep_interruptible(jiffies_to_msecs(char_time * 5));
+       /* Run one more char cycle */
+       msleep_interruptible(jiffies_to_msecs(char_time * 5));
 #ifdef CY_DEBUG_WAIT_UNTIL_SENT
-    printk("Clean (jiff=%lu)...done\n", jiffies);
+       printk("Clean (jiff=%lu)...done\n", jiffies);
 #endif
 }
 
 /*
  * This routine is called when a particular tty device is closed.
  */
-static void
-cy_close(struct tty_struct *tty, struct file *filp)
+static void cy_close(struct tty_struct *tty, struct file *filp)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  unsigned long flags;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       unsigned long flags;
 
 #ifdef CY_DEBUG_OTHER
-    printk("cyc:cy_close ttyC%d\n", info->line);
+       printk("cyc:cy_close ttyC%d\n", info->line);
 #endif
 
-    if (!info || serial_paranoia_check(info, tty->name, "cy_close")){
-        return;
-    }
+       if (!info || serial_paranoia_check(info, tty->name, "cy_close")) {
+               return;
+       }
 
-    CY_LOCK(info, flags);
-    /* If the TTY is being hung up, nothing to do */
-    if (tty_hung_up_p(filp)) {
-       CY_UNLOCK(info, flags);
-        return;
-    }
-        
+       CY_LOCK(info, flags);
+       /* If the TTY is being hung up, nothing to do */
+       if (tty_hung_up_p(filp)) {
+               CY_UNLOCK(info, flags);
+               return;
+       }
 #ifdef CY_DEBUG_OPEN
-    printk("cyc:cy_close ttyC%d, count = %d\n", info->line, info->count);
+       printk("cyc:cy_close ttyC%d, count = %d\n", info->line, info->count);
 #endif
-    if ((tty->count == 1) && (info->count != 1)) {
-        /*
-         * Uh, oh.  tty->count is 1, which means that the tty
-         * structure will be freed.  Info->count should always
-         * be one in these conditions.  If it's greater than
-         * one, we've got real problems, since it means the
-         * serial port won't be shutdown.
-         */
-        printk("cyc:cy_close: bad serial port count; tty->count is 1, "
-           "info->count is %d\n", info->count);
-        info->count = 1;
-    }
+       if ((tty->count == 1) && (info->count != 1)) {
+               /*
+                * Uh, oh.  tty->count is 1, which means that the tty
+                * structure will be freed.  Info->count should always
+                * be one in these conditions.  If it's greater than
+                * one, we've got real problems, since it means the
+                * serial port won't be shutdown.
+                */
+               printk("cyc:cy_close: bad serial port count; tty->count is 1, "
+                       "info->count is %d\n", info->count);
+               info->count = 1;
+       }
 #ifdef CY_DEBUG_COUNT
-    printk("cyc:cy_close at (%d): decrementing count to %d\n",
-        current->pid, info->count - 1);
+       printk("cyc:cy_close at (%d): decrementing count to %d\n",
+               current->pid, info->count - 1);
 #endif
-    if (--info->count < 0) {
+       if (--info->count < 0) {
 #ifdef CY_DEBUG_COUNT
-    printk("cyc:cyc_close setting count to 0\n");
+               printk("cyc:cyc_close setting count to 0\n");
 #endif
-        info->count = 0;
-    }
-    if (info->count) {
-       CY_UNLOCK(info, flags);
-        return;
-    }
-    info->flags |= ASYNC_CLOSING;
-
-    /*
-    * Now we wait for the transmit buffer to clear; and we notify
-    * the line discipline to only process XON/XOFF characters.
-    */
-    tty->closing = 1;
-    CY_UNLOCK(info, flags);
-    if (info->closing_wait != CY_CLOSING_WAIT_NONE) {
-       tty_wait_until_sent(tty, info->closing_wait);
-    }
-    CY_LOCK(info, flags);
-
-    if (!IS_CYC_Z(cy_card[info->card])) {
-       int channel = info->line - cy_card[info->card].first_line;
-       int index = cy_card[info->card].bus_index;
-       void __iomem *base_addr = cy_card[info->card].base_addr + (cy_chip_offset[channel>>2] << index);
-       /* Stop accepting input */
-       channel &= 0x03;
-       cy_writeb(base_addr+(CyCAR<<index), (u_char)channel);
-       cy_writeb(base_addr+(CySRER<<index),
-                       cy_readb(base_addr+(CySRER<<index)) & ~CyRxData);
-       if (info->flags & ASYNC_INITIALIZED) {
-           /* Waiting for on-board buffers to be empty before closing 
-              the port */
-           CY_UNLOCK(info, flags);
-           cy_wait_until_sent(tty, info->timeout);
-           CY_LOCK(info, flags);
+               info->count = 0;
        }
-    } else {
-#ifdef Z_WAKE
-       /* Waiting for on-board buffers to be empty before closing the port */
-       void __iomem *base_addr = cy_card[info->card].base_addr;
-       struct FIRM_ID __iomem *firm_id = base_addr + ID_ADDRESS;
-       struct ZFW_CTRL __iomem *zfw_ctrl = base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
-       struct CH_CTRL __iomem *ch_ctrl = zfw_ctrl->ch_ctrl;
-       int channel = info->line - cy_card[info->card].first_line;
-       int retval;
+       if (info->count) {
+               CY_UNLOCK(info, flags);
+               return;
+       }
+       info->flags |= ASYNC_CLOSING;
 
-       if (cy_readl(&ch_ctrl[channel].flow_status) != C_FS_TXIDLE) {
-           retval = cyz_issue_cmd(&cy_card[info->card], channel, 
-                                  C_CM_IOCTLW, 0L);
-           if (retval != 0){
-               printk("cyc:cy_close retval on ttyC%d was %x\n",
-                      info->line, retval);
-           }
-           CY_UNLOCK(info, flags);
-           interruptible_sleep_on(&info->shutdown_wait);
-           CY_LOCK(info, flags);
+       /*
+        * Now we wait for the transmit buffer to clear; and we notify
+        * the line discipline to only process XON/XOFF characters.
+        */
+       tty->closing = 1;
+       CY_UNLOCK(info, flags);
+       if (info->closing_wait != CY_CLOSING_WAIT_NONE) {
+               tty_wait_until_sent(tty, info->closing_wait);
        }
+       CY_LOCK(info, flags);
+
+       if (!IS_CYC_Z(cy_card[info->card])) {
+               int channel = info->line - cy_card[info->card].first_line;
+               int index = cy_card[info->card].bus_index;
+               void __iomem *base_addr = cy_card[info->card].base_addr +
+                       (cy_chip_offset[channel >> 2] << index);
+               /* Stop accepting input */
+               channel &= 0x03;
+               cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
+               cy_writeb(base_addr + (CySRER << index),
+                         cy_readb(base_addr + (CySRER << index)) & ~CyRxData);
+               if (info->flags & ASYNC_INITIALIZED) {
+                       /* Waiting for on-board buffers to be empty before closing
+                          the port */
+                       CY_UNLOCK(info, flags);
+                       cy_wait_until_sent(tty, info->timeout);
+                       CY_LOCK(info, flags);
+               }
+       } else {
+#ifdef Z_WAKE
+               /* Waiting for on-board buffers to be empty before closing the port */
+               void __iomem *base_addr = cy_card[info->card].base_addr;
+               struct FIRM_ID __iomem *firm_id = base_addr + ID_ADDRESS;
+               struct ZFW_CTRL __iomem *zfw_ctrl =
+                   base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
+               struct CH_CTRL __iomem *ch_ctrl = zfw_ctrl->ch_ctrl;
+               int channel = info->line - cy_card[info->card].first_line;
+               int retval;
+
+               if (cy_readl(&ch_ctrl[channel].flow_status) != C_FS_TXIDLE) {
+                       retval = cyz_issue_cmd(&cy_card[info->card], channel,
+                                               C_CM_IOCTLW, 0L);
+                       if (retval != 0) {
+                               printk("cyc:cy_close retval on ttyC%d was %x\n",
+                                       info->line, retval);
+                       }
+                       CY_UNLOCK(info, flags);
+                       interruptible_sleep_on(&info->shutdown_wait);
+                       CY_LOCK(info, flags);
+               }
 #endif
-    }
-
-    CY_UNLOCK(info, flags);
-    shutdown(info);
-    if (tty->driver->flush_buffer)
-        tty->driver->flush_buffer(tty);
-    tty_ldisc_flush(tty);        
-    CY_LOCK(info, flags);
-
-    tty->closing = 0;
-    info->event = 0;
-    info->tty = NULL;
-    if (info->blocked_open) {
+       }
+
        CY_UNLOCK(info, flags);
-        if (info->close_delay) {
-            msleep_interruptible(jiffies_to_msecs(info->close_delay));
-        }
-        wake_up_interruptible(&info->open_wait);
+       shutdown(info);
+       if (tty->driver->flush_buffer)
+               tty->driver->flush_buffer(tty);
+       tty_ldisc_flush(tty);
        CY_LOCK(info, flags);
-    }
-    info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
-    wake_up_interruptible(&info->close_wait);
+
+       tty->closing = 0;
+       info->event = 0;
+       info->tty = NULL;
+       if (info->blocked_open) {
+               CY_UNLOCK(info, flags);
+               if (info->close_delay) {
+                       msleep_interruptible(jiffies_to_msecs
+                                               (info->close_delay));
+               }
+               wake_up_interruptible(&info->open_wait);
+               CY_LOCK(info, flags);
+       }
+       info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
+       wake_up_interruptible(&info->close_wait);
 
 #ifdef CY_DEBUG_OTHER
-    printk(" cyc:cy_close done\n");
+       printk(" cyc:cy_close done\n");
 #endif
 
-    CY_UNLOCK(info, flags);
-    return;
-} /* cy_close */
-
+       CY_UNLOCK(info, flags);
+}                              /* cy_close */
 
 /* This routine gets called when tty_write has put something into
  * the write_queue.  The characters may come from user space or
@@ -2796,50 +2875,49 @@ cy_close(struct tty_struct *tty, struct file *filp)
  * If the port is already active, there is no need to kick it.
  *
  */
-static int
-cy_write(struct tty_struct * tty, const unsigned char *buf, int count)
+static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  unsigned long flags;
-  int c, ret = 0;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       unsigned long flags;
+       int c, ret = 0;
 
 #ifdef CY_DEBUG_IO
-    printk("cyc:cy_write ttyC%d\n", info->line); /* */
+       printk("cyc:cy_write ttyC%d\n", info->line);    /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_write")){
-        return 0;
-    }
-        
-    if (!info->xmit_buf)
-       return 0;
+       if (serial_paranoia_check(info, tty->name, "cy_write")) {
+               return 0;
+       }
+
+       if (!info->xmit_buf)
+               return 0;
+
+       CY_LOCK(info, flags);
+       while (1) {
+               c = min(count, min((int)(SERIAL_XMIT_SIZE - info->xmit_cnt - 1),
+                                  (int)(SERIAL_XMIT_SIZE - info->xmit_head)));
+
+               if (c <= 0)
+                       break;
+
+               memcpy(info->xmit_buf + info->xmit_head, buf, c);
+               info->xmit_head = (info->xmit_head + c) &
+                       (SERIAL_XMIT_SIZE - 1);
+               info->xmit_cnt += c;
+               buf += c;
+               count -= c;
+               ret += c;
+       }
+       CY_UNLOCK(info, flags);
 
-    CY_LOCK(info, flags);
-    while (1) {
-       c = min(count, min((int)(SERIAL_XMIT_SIZE - info->xmit_cnt - 1),
-                       (int)(SERIAL_XMIT_SIZE - info->xmit_head)));
-               
-       if (c <= 0)
-           break;
-
-       memcpy(info->xmit_buf + info->xmit_head, buf, c);
-       info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
-       info->xmit_cnt += c;
-       buf += c;
-       count -= c;
-       ret += c;
-    }
-    CY_UNLOCK(info, flags);
-
-    info->idle_stats.xmit_bytes += ret;
-    info->idle_stats.xmit_idle   = jiffies;
-
-    if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) {
-        start_xmit(info);
-    }
-    return ret;
-} /* cy_write */
+       info->idle_stats.xmit_bytes += ret;
+       info->idle_stats.xmit_idle = jiffies;
 
+       if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) {
+               start_xmit(info);
+       }
+       return ret;
+}                              /* cy_write */
 
 /*
  * This routine is called by the kernel to write a single
@@ -2848,60 +2926,56 @@ cy_write(struct tty_struct * tty, const unsigned char *buf, int count)
  * done stuffing characters into the driver.  If there is no room
  * in the queue, the character is ignored.
  */
-static void
-cy_put_char(struct tty_struct *tty, unsigned char ch)
+static void cy_put_char(struct tty_struct *tty, unsigned char ch)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  unsigned long flags;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       unsigned long flags;
 
 #ifdef CY_DEBUG_IO
-    printk("cyc:cy_put_char ttyC%d\n", info->line);
+       printk("cyc:cy_put_char ttyC%d\n", info->line);
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_put_char"))
-        return;
+       if (serial_paranoia_check(info, tty->name, "cy_put_char"))
+               return;
 
-    if (!info->xmit_buf)
-        return;
+       if (!info->xmit_buf)
+               return;
 
-    CY_LOCK(info, flags);
-        if (info->xmit_cnt >= SERIAL_XMIT_SIZE - 1) {
-           CY_UNLOCK(info, flags);
-            return;
-        }
+       CY_LOCK(info, flags);
+       if (info->xmit_cnt >= (int)(SERIAL_XMIT_SIZE - 1)) {
+               CY_UNLOCK(info, flags);
+               return;
+       }
 
-        info->xmit_buf[info->xmit_head++] = ch;
-        info->xmit_head &= SERIAL_XMIT_SIZE - 1;
-        info->xmit_cnt++;
+       info->xmit_buf[info->xmit_head++] = ch;
+       info->xmit_head &= SERIAL_XMIT_SIZE - 1;
+       info->xmit_cnt++;
        info->idle_stats.xmit_bytes++;
        info->idle_stats.xmit_idle = jiffies;
-    CY_UNLOCK(info, flags);
-} /* cy_put_char */
-
+       CY_UNLOCK(info, flags);
+}                              /* cy_put_char */
 
 /*
  * This routine is called by the kernel after it has written a
  * series of characters to the tty device using put_char().  
  */
-static void
-cy_flush_chars(struct tty_struct *tty)
+static void cy_flush_chars(struct tty_struct *tty)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-                                
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+
 #ifdef CY_DEBUG_IO
-    printk("cyc:cy_flush_chars ttyC%d\n", info->line); /* */
+       printk("cyc:cy_flush_chars ttyC%d\n", info->line);      /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_flush_chars"))
-        return;
-
-    if (info->xmit_cnt <= 0 || tty->stopped
-    || tty->hw_stopped || !info->xmit_buf)
-        return;
+       if (serial_paranoia_check(info, tty->name, "cy_flush_chars"))
+               return;
 
-    start_xmit(info);
-} /* cy_flush_chars */
+       if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
+                       !info->xmit_buf)
+               return;
 
+       start_xmit(info);
+}                              /* cy_flush_chars */
 
 /*
  * This routine returns the numbers of characters the tty driver
@@ -2909,75 +2983,70 @@ cy_flush_chars(struct tty_struct *tty)
  * to change as output buffers get emptied, or if the output flow
  * control is activated.
  */
-static int
-cy_write_room(struct tty_struct *tty)
+static int cy_write_room(struct tty_struct *tty)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  int   ret;
-                                
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       int ret;
+
 #ifdef CY_DEBUG_IO
-    printk("cyc:cy_write_room ttyC%d\n", info->line); /* */
+       printk("cyc:cy_write_room ttyC%d\n", info->line);       /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_write_room"))
-        return 0;
-    ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
-    if (ret < 0)
-        ret = 0;
-    return ret;
-} /* 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)
+               ret = 0;
+       return ret;
+}                              /* cy_write_room */
 
-
-static int
-cy_chars_in_buffer(struct tty_struct *tty)
+static int cy_chars_in_buffer(struct tty_struct *tty)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  int card, channel;
-                                
-    if (serial_paranoia_check(info, tty->name, "cy_chars_in_buffer"))
-        return 0;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       int card, channel;
 
-    card = info->card;
-    channel = (info->line) - (cy_card[card].first_line);
+       if (serial_paranoia_check(info, tty->name, "cy_chars_in_buffer"))
+               return 0;
+
+       card = info->card;
+       channel = (info->line) - (cy_card[card].first_line);
 
 #ifdef Z_EXT_CHARS_IN_BUFFER
-    if (!IS_CYC_Z(cy_card[card])) {
-#endif /* Z_EXT_CHARS_IN_BUFFER */
+       if (!IS_CYC_Z(cy_card[card])) {
+#endif                         /* Z_EXT_CHARS_IN_BUFFER */
 #ifdef CY_DEBUG_IO
-       printk("cyc:cy_chars_in_buffer ttyC%d %d\n",
-               info->line, info->xmit_cnt); /* */
+               printk("cyc:cy_chars_in_buffer ttyC%d %d\n", info->line, info->xmit_cnt);       /* */
 #endif
-       return info->xmit_cnt;
+               return info->xmit_cnt;
 #ifdef Z_EXT_CHARS_IN_BUFFER
-    } else {
-       static volatile struct FIRM_ID *firm_id;
-       static volatile struct ZFW_CTRL *zfw_ctrl;
-       static volatile struct CH_CTRL *ch_ctrl;
-       static volatile struct BUF_CTRL *buf_ctrl;
-       int char_count;
-       volatile uclong tx_put, tx_get, tx_bufsize;
-
-       firm_id = cy_card[card].base_addr + ID_ADDRESS;
-       zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
-       ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
-       buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]);
-
-       tx_get = cy_readl(&buf_ctrl->tx_get);
-       tx_put = cy_readl(&buf_ctrl->tx_put);
-       tx_bufsize = cy_readl(&buf_ctrl->tx_bufsize);
-       if (tx_put >= tx_get)
-           char_count = tx_put - tx_get;
-       else
-           char_count = tx_put - tx_get + tx_bufsize;
+       } else {
+               static volatile struct FIRM_ID *firm_id;
+               static volatile struct ZFW_CTRL *zfw_ctrl;
+               static volatile struct CH_CTRL *ch_ctrl;
+               static volatile struct BUF_CTRL *buf_ctrl;
+               int char_count;
+               volatile uclong tx_put, tx_get, tx_bufsize;
+
+               firm_id = cy_card[card].base_addr + ID_ADDRESS;
+               zfw_ctrl = cy_card[card].base_addr +
+                       (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
+               ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
+               buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]);
+
+               tx_get = cy_readl(&buf_ctrl->tx_get);
+               tx_put = cy_readl(&buf_ctrl->tx_put);
+               tx_bufsize = cy_readl(&buf_ctrl->tx_bufsize);
+               if (tx_put >= tx_get)
+                       char_count = tx_put - tx_get;
+               else
+                       char_count = tx_put - tx_get + tx_bufsize;
 #ifdef CY_DEBUG_IO
-       printk("cyc:cy_chars_in_buffer ttyC%d %d\n",
-               info->line, info->xmit_cnt + char_count); /* */
+               printk("cyc:cy_chars_in_buffer ttyC%d %d\n", info->line, info->xmit_cnt + char_count);  /* */
 #endif
-       return (info->xmit_cnt + char_count);
-    }
-#endif /* Z_EXT_CHARS_IN_BUFFER */
-} /* cy_chars_in_buffer */
-
+               return info->xmit_cnt + char_count;
+       }
+#endif                         /* Z_EXT_CHARS_IN_BUFFER */
+}                              /* cy_chars_in_buffer */
 
 /*
  * ------------------------------------------------------------
@@ -2985,178 +3054,179 @@ cy_chars_in_buffer(struct tty_struct *tty)
  * ------------------------------------------------------------
  */
 
-static void
-cyy_baud_calc(struct cyclades_port *info, uclong baud)
+static void cyy_baud_calc(struct cyclades_port *info, uclong baud)
 {
-    int co, co_val, bpr;
-    uclong cy_clock = ((info->chip_rev >= CD1400_REV_J) ? 60000000 : 25000000);
-
-    if (baud == 0) {
-       info->tbpr = info->tco = info->rbpr = info->rco = 0;
-       return;
-    }
-
-    /* determine which prescaler to use */
-    for (co = 4, co_val = 2048; co; co--, co_val >>= 2) {
-       if (cy_clock / co_val / baud > 63)
-           break;
-    }
-
-    bpr = (cy_clock / co_val * 2 / baud + 1) / 2;
-    if (bpr > 255)
-       bpr = 255;
-
-    info->tbpr = info->rbpr = bpr;
-    info->tco = info->rco = co;
+       int co, co_val, bpr;
+       uclong cy_clock = ((info->chip_rev >= CD1400_REV_J) ? 60000000 :
+                       25000000);
+
+       if (baud == 0) {
+               info->tbpr = info->tco = info->rbpr = info->rco = 0;
+               return;
+       }
+
+       /* determine which prescaler to use */
+       for (co = 4, co_val = 2048; co; co--, co_val >>= 2) {
+               if (cy_clock / co_val / baud > 63)
+                       break;
+       }
+
+       bpr = (cy_clock / co_val * 2 / baud + 1) / 2;
+       if (bpr > 255)
+               bpr = 255;
+
+       info->tbpr = info->rbpr = bpr;
+       info->tco = info->rco = co;
 }
 
 /*
  * This routine finds or computes the various line characteristics.
  * It used to be called config_setup
  */
-static void
-set_line_char(struct cyclades_port * info)
+static void set_line_char(struct cyclades_port *info)
 {
-  unsigned long flags;
-  void __iomem *base_addr;
-  int card,chip,channel,index;
-  unsigned cflag, iflag;
-  unsigned short chip_number;
-  int baud, baud_rate = 0;
-  int   i;
-
-
-    if (!info->tty || !info->tty->termios){
-        return;
-    }
-    if (info->line == -1){
-        return;
-    }
-    cflag = info->tty->termios->c_cflag;
-    iflag = info->tty->termios->c_iflag;
-
-    /*
-     * Set up the tty->alt_speed kludge
-     */
-    if (info->tty) {
-       if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
-           info->tty->alt_speed = 57600;
-       if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
-           info->tty->alt_speed = 115200;
-       if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
-           info->tty->alt_speed = 230400;
-       if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
-           info->tty->alt_speed = 460800;
-    }
-
-    card = info->card;
-    channel = (info->line) - (cy_card[card].first_line);
-    chip_number = channel / 4;
-
-    if (!IS_CYC_Z(cy_card[card])) {
-
-       index = cy_card[card].bus_index;
-
-       /* baud rate */
-       baud = tty_get_baud_rate(info->tty);
-       if ((baud == 38400) &&
-           ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) {
-           if (info->custom_divisor)
-               baud_rate = info->baud / info->custom_divisor;
-           else
-               baud_rate = info->baud;
-       } else if (baud > CD1400_MAX_SPEED) {
-           baud = CD1400_MAX_SPEED;
+       unsigned long flags;
+       void __iomem *base_addr;
+       int card, chip, channel, index;
+       unsigned cflag, iflag;
+       unsigned short chip_number;
+       int baud, baud_rate = 0;
+       int i;
+
+       if (!info->tty || !info->tty->termios) {
+               return;
        }
-       /* find the baud index */
-       for (i = 0; i < 20; i++) {
-           if (baud == baud_table[i]) {
-               break;
-           }
+       if (info->line == -1) {
+               return;
        }
-       if (i == 20) {
-           i = 19; /* CD1400_MAX_SPEED */
-       } 
+       cflag = info->tty->termios->c_cflag;
+       iflag = info->tty->termios->c_iflag;
 
-       if ((baud == 38400) &&
-           ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) {
-           cyy_baud_calc(info, baud_rate);
-       } else {
-           if(info->chip_rev >= CD1400_REV_J) {
-               /* It is a CD1400 rev. J or later */
-               info->tbpr = baud_bpr_60[i]; /* Tx BPR */
-               info->tco = baud_co_60[i]; /* Tx CO */
-               info->rbpr = baud_bpr_60[i]; /* Rx BPR */
-               info->rco = baud_co_60[i]; /* Rx CO */
-           } else {
-               info->tbpr = baud_bpr_25[i]; /* Tx BPR */
-               info->tco = baud_co_25[i]; /* Tx CO */
-               info->rbpr = baud_bpr_25[i]; /* Rx BPR */
-               info->rco = baud_co_25[i]; /* Rx CO */
-           }
-       }
-       if (baud_table[i] == 134) {
-           /* get it right for 134.5 baud */
-           info->timeout = (info->xmit_fifo_size*HZ*30/269) + 2;
-       } else if ((baud == 38400) &&
-                  ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) {
-           info->timeout = (info->xmit_fifo_size*HZ*15/baud_rate) + 2;
-       } else if (baud_table[i]) {
-           info->timeout = (info->xmit_fifo_size*HZ*15/baud_table[i]) + 2;
-           /* this needs to be propagated into the card info */
-       } else {
-           info->timeout = 0;
-       }
-       /* By tradition (is it a standard?) a baud rate of zero
-          implies the line should be/has been closed.  A bit
-          later in this routine such a test is performed. */
-
-       /* byte size and parity */
-       info->cor5 = 0;
-       info->cor4 = 0;
-       info->cor3 = (info->default_threshold
-                     ? info->default_threshold
-                     : baud_cor3[i]); /* receive threshold */
-       info->cor2 = CyETC;
-       switch(cflag & CSIZE){
-       case CS5:
-           info->cor1 = Cy_5_BITS;
-           break;
-       case CS6:
-           info->cor1 = Cy_6_BITS;
-           break;
-       case CS7:
-           info->cor1 = Cy_7_BITS;
-           break;
-       case CS8:
-           info->cor1 = Cy_8_BITS;
-           break;
-       }
-       if(cflag & CSTOPB){
-           info->cor1 |= Cy_2_STOP;
-       }
-       if (cflag & PARENB){
-           if (cflag & PARODD){
-               info->cor1 |= CyPARITY_O;
-           }else{
-               info->cor1 |= CyPARITY_E;
-           }
-       }else{
-           info->cor1 |= CyPARITY_NONE;
-       }
-           
-       /* CTS flow control flag */
-       if (cflag & CRTSCTS){
-           info->flags |= ASYNC_CTS_FLOW;
-           info->cor2 |= CyCtsAE;
-       }else{
-           info->flags &= ~ASYNC_CTS_FLOW;
-           info->cor2 &= ~CyCtsAE;
+       /*
+        * Set up the tty->alt_speed kludge
+        */
+       if (info->tty) {
+               if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+                       info->tty->alt_speed = 57600;
+               if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+                       info->tty->alt_speed = 115200;
+               if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+                       info->tty->alt_speed = 230400;
+               if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+                       info->tty->alt_speed = 460800;
        }
-       if (cflag & CLOCAL)
-           info->flags &= ~ASYNC_CHECK_CD;
-       else
-           info->flags |= ASYNC_CHECK_CD;
+
+       card = info->card;
+       channel = (info->line) - (cy_card[card].first_line);
+       chip_number = channel / 4;
+
+       if (!IS_CYC_Z(cy_card[card])) {
+
+               index = cy_card[card].bus_index;
+
+               /* baud rate */
+               baud = tty_get_baud_rate(info->tty);
+               if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
+                               ASYNC_SPD_CUST) {
+                       if (info->custom_divisor)
+                               baud_rate = info->baud / info->custom_divisor;
+                       else
+                               baud_rate = info->baud;
+               } else if (baud > CD1400_MAX_SPEED) {
+                       baud = CD1400_MAX_SPEED;
+               }
+               /* find the baud index */
+               for (i = 0; i < 20; i++) {
+                       if (baud == baud_table[i]) {
+                               break;
+                       }
+               }
+               if (i == 20) {
+                       i = 19; /* CD1400_MAX_SPEED */
+               }
+
+               if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
+                               ASYNC_SPD_CUST) {
+                       cyy_baud_calc(info, baud_rate);
+               } else {
+                       if (info->chip_rev >= CD1400_REV_J) {
+                               /* It is a CD1400 rev. J or later */
+                               info->tbpr = baud_bpr_60[i];    /* Tx BPR */
+                               info->tco = baud_co_60[i];      /* Tx CO */
+                               info->rbpr = baud_bpr_60[i];    /* Rx BPR */
+                               info->rco = baud_co_60[i];      /* Rx CO */
+                       } else {
+                               info->tbpr = baud_bpr_25[i];    /* Tx BPR */
+                               info->tco = baud_co_25[i];      /* Tx CO */
+                               info->rbpr = baud_bpr_25[i];    /* Rx BPR */
+                               info->rco = baud_co_25[i];      /* Rx CO */
+                       }
+               }
+               if (baud_table[i] == 134) {
+                       /* get it right for 134.5 baud */
+                       info->timeout = (info->xmit_fifo_size * HZ * 30 / 269) +
+                                       2;
+               } else if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
+                               ASYNC_SPD_CUST) {
+                       info->timeout = (info->xmit_fifo_size * HZ * 15 /
+                                       baud_rate) + 2;
+               } else if (baud_table[i]) {
+                       info->timeout = (info->xmit_fifo_size * HZ * 15 /
+                                       baud_table[i]) + 2;
+                       /* this needs to be propagated into the card info */
+               } else {
+                       info->timeout = 0;
+               }
+               /* By tradition (is it a standard?) a baud rate of zero
+                  implies the line should be/has been closed.  A bit
+                  later in this routine such a test is performed. */
+
+               /* byte size and parity */
+               info->cor5 = 0;
+               info->cor4 = 0;
+               /* receive threshold */
+               info->cor3 = (info->default_threshold ?
+                               info->default_threshold : baud_cor3[i]);
+               info->cor2 = CyETC;
+               switch (cflag & CSIZE) {
+               case CS5:
+                       info->cor1 = Cy_5_BITS;
+                       break;
+               case CS6:
+                       info->cor1 = Cy_6_BITS;
+                       break;
+               case CS7:
+                       info->cor1 = Cy_7_BITS;
+                       break;
+               case CS8:
+                       info->cor1 = Cy_8_BITS;
+                       break;
+               }
+               if (cflag & CSTOPB) {
+                       info->cor1 |= Cy_2_STOP;
+               }
+               if (cflag & PARENB) {
+                       if (cflag & PARODD) {
+                               info->cor1 |= CyPARITY_O;
+                       } else {
+                               info->cor1 |= CyPARITY_E;
+                       }
+               } else {
+                       info->cor1 |= CyPARITY_NONE;
+               }
+
+               /* CTS flow control flag */
+               if (cflag & CRTSCTS) {
+                       info->flags |= ASYNC_CTS_FLOW;
+                       info->cor2 |= CyCtsAE;
+               } else {
+                       info->flags &= ~ASYNC_CTS_FLOW;
+                       info->cor2 &= ~CyCtsAE;
+               }
+               if (cflag & CLOCAL)
+                       info->flags &= ~ASYNC_CHECK_CD;
+               else
+                       info->flags |= ASYNC_CHECK_CD;
 
         /***********************************************
            The hardware option, CyRtsAO, presents RTS when
@@ -3168,300 +3238,319 @@ set_line_char(struct cyclades_port * info)
            cable.  Contact Marcio Saito for details.
         ***********************************************/
 
-       chip = channel>>2;
-       channel &= 0x03;
-       base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index);
+               chip = channel >> 2;
+               channel &= 0x03;
+               base_addr = cy_card[card].base_addr +
+                       (cy_chip_offset[chip] << index);
 
-       CY_LOCK(info, flags);
-           cy_writeb(base_addr+(CyCAR<<index), (u_char)channel);
-
-          /* tx and rx baud rate */
-
-           cy_writeb(base_addr+(CyTCOR<<index), info->tco);
-           cy_writeb(base_addr+(CyTBPR<<index), info->tbpr);
-           cy_writeb(base_addr+(CyRCOR<<index), info->rco);
-           cy_writeb(base_addr+(CyRBPR<<index), info->rbpr);
-
-           /* set line characteristics  according configuration */
-
-           cy_writeb(base_addr+(CySCHR1<<index), 
-                     START_CHAR(info->tty));
-           cy_writeb(base_addr+(CySCHR2<<index), 
-                     STOP_CHAR(info->tty));
-           cy_writeb(base_addr+(CyCOR1<<index), info->cor1);
-           cy_writeb(base_addr+(CyCOR2<<index), info->cor2);
-           cy_writeb(base_addr+(CyCOR3<<index), info->cor3);
-           cy_writeb(base_addr+(CyCOR4<<index), info->cor4);
-           cy_writeb(base_addr+(CyCOR5<<index), info->cor5);
-
-           cyy_issue_cmd(base_addr,
-                    CyCOR_CHANGE|CyCOR1ch|CyCOR2ch|CyCOR3ch,index);
-
-           cy_writeb(base_addr+(CyCAR<<index), 
-                     (u_char)channel); /* !!! Is this needed? */
-           cy_writeb(base_addr+(CyRTPR<<index), (info->default_timeout
-                                                ? info->default_timeout
-                                                : 0x02)); /* 10ms rx timeout */
-
-           if (C_CLOCAL(info->tty)) {
-               /* without modem intr */
-               cy_writeb(base_addr+(CySRER<<index),
-                   cy_readb(base_addr+(CySRER<<index)) | CyMdmCh); 
-                                       /* act on 1->0 modem transitions */
-                if ((cflag & CRTSCTS) && info->rflow) {
-                        cy_writeb(base_addr+(CyMCOR1<<index), 
-                                  (CyCTS|rflow_thr[i]));
-                } else {
-                        cy_writeb(base_addr+(CyMCOR1<<index), CyCTS);
-                }
-                                       /* act on 0->1 modem transitions */
-               cy_writeb(base_addr+(CyMCOR2<<index), CyCTS);
-           } else {
-               /* without modem intr */
-               cy_writeb(base_addr+(CySRER<<index),
-                   cy_readb(base_addr+(CySRER<<index)) | CyMdmCh); 
-                                       /* act on 1->0 modem transitions */
-                if ((cflag & CRTSCTS) && info->rflow) {
-                       cy_writeb(base_addr+(CyMCOR1<<index), 
-                                 (CyDSR|CyCTS|CyRI|CyDCD|rflow_thr[i]));
-                } else {
-                       cy_writeb(base_addr+(CyMCOR1<<index), 
-                                  CyDSR|CyCTS|CyRI|CyDCD);
-                }
-                                       /* act on 0->1 modem transitions */
-               cy_writeb(base_addr+(CyMCOR2<<index), 
-                         CyDSR|CyCTS|CyRI|CyDCD);
-           }
-
-           if(i == 0){ /* baud rate is zero, turn off line */
-               if (info->rtsdtr_inv) {
-                       cy_writeb(base_addr+(CyMSVR1<<index), ~CyRTS);
+               CY_LOCK(info, flags);
+               cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
+
+               /* tx and rx baud rate */
+
+               cy_writeb(base_addr + (CyTCOR << index), info->tco);
+               cy_writeb(base_addr + (CyTBPR << index), info->tbpr);
+               cy_writeb(base_addr + (CyRCOR << index), info->rco);
+               cy_writeb(base_addr + (CyRBPR << index), info->rbpr);
+
+               /* set line characteristics  according configuration */
+
+               cy_writeb(base_addr + (CySCHR1 << index),
+                         START_CHAR(info->tty));
+               cy_writeb(base_addr + (CySCHR2 << index), STOP_CHAR(info->tty));
+               cy_writeb(base_addr + (CyCOR1 << index), info->cor1);
+               cy_writeb(base_addr + (CyCOR2 << index), info->cor2);
+               cy_writeb(base_addr + (CyCOR3 << index), info->cor3);
+               cy_writeb(base_addr + (CyCOR4 << index), info->cor4);
+               cy_writeb(base_addr + (CyCOR5 << index), info->cor5);
+
+               cyy_issue_cmd(base_addr, CyCOR_CHANGE | CyCOR1ch | CyCOR2ch |
+                               CyCOR3ch, index);
+
+               cy_writeb(base_addr + (CyCAR << index), (u_char) channel);      /* !!! Is this needed? */
+               cy_writeb(base_addr + (CyRTPR << index),
+                       (info->default_timeout ? info->default_timeout : 0x02));
+               /* 10ms rx timeout */
+
+               if (C_CLOCAL(info->tty)) {
+                       /* without modem intr */
+                       cy_writeb(base_addr + (CySRER << index),
+                                 cy_readb(base_addr +
+                                          (CySRER << index)) | CyMdmCh);
+                       /* act on 1->0 modem transitions */
+                       if ((cflag & CRTSCTS) && info->rflow) {
+                               cy_writeb(base_addr + (CyMCOR1 << index),
+                                         (CyCTS | rflow_thr[i]));
+                       } else {
+                               cy_writeb(base_addr + (CyMCOR1 << index),
+                                         CyCTS);
+                       }
+                       /* act on 0->1 modem transitions */
+                       cy_writeb(base_addr + (CyMCOR2 << index), CyCTS);
                } else {
-                        cy_writeb(base_addr+(CyMSVR2<<index), ~CyDTR);
+                       /* without modem intr */
+                       cy_writeb(base_addr + (CySRER << index),
+                                 cy_readb(base_addr +
+                                          (CySRER << index)) | CyMdmCh);
+                       /* act on 1->0 modem transitions */
+                       if ((cflag & CRTSCTS) && info->rflow) {
+                               cy_writeb(base_addr + (CyMCOR1 << index),
+                                         (CyDSR | CyCTS | CyRI | CyDCD |
+                                          rflow_thr[i]));
+                       } else {
+                               cy_writeb(base_addr + (CyMCOR1 << index),
+                                         CyDSR | CyCTS | CyRI | CyDCD);
+                       }
+                       /* act on 0->1 modem transitions */
+                       cy_writeb(base_addr + (CyMCOR2 << index),
+                                 CyDSR | CyCTS | CyRI | CyDCD);
                }
+
+               if (i == 0) {   /* baud rate is zero, turn off line */
+                       if (info->rtsdtr_inv) {
+                               cy_writeb(base_addr + (CyMSVR1 << index),
+                                         ~CyRTS);
+                       } else {
+                               cy_writeb(base_addr + (CyMSVR2 << index),
+                                         ~CyDTR);
+                       }
 #ifdef CY_DEBUG_DTR
-               printk("cyc:set_line_char dropping DTR\n");
-               printk("     status: 0x%x, 0x%x\n", 
-                   cy_readb(base_addr+(CyMSVR1<<index)),
-                   cy_readb(base_addr+(CyMSVR2<<index)));
+                       printk("cyc:set_line_char dropping DTR\n");
+                       printk("     status: 0x%x, 0x%x\n",
+                               cy_readb(base_addr + (CyMSVR1 << index)),
+                               cy_readb(base_addr + (CyMSVR2 << index)));
 #endif
-           }else{
-                if (info->rtsdtr_inv) {
-                       cy_writeb(base_addr+(CyMSVR1<<index), CyRTS);
-                } else {
-                       cy_writeb(base_addr+(CyMSVR2<<index), CyDTR);
-                }
+               } else {
+                       if (info->rtsdtr_inv) {
+                               cy_writeb(base_addr + (CyMSVR1 << index),
+                                         CyRTS);
+                       } else {
+                               cy_writeb(base_addr + (CyMSVR2 << index),
+                                         CyDTR);
+                       }
 #ifdef CY_DEBUG_DTR
-               printk("cyc:set_line_char raising DTR\n");
-               printk("     status: 0x%x, 0x%x\n",
-                   cy_readb(base_addr+(CyMSVR1<<index)),
-                   cy_readb(base_addr+(CyMSVR2<<index)));
+                       printk("cyc:set_line_char raising DTR\n");
+                       printk("     status: 0x%x, 0x%x\n",
+                               cy_readb(base_addr + (CyMSVR1 << index)),
+                               cy_readb(base_addr + (CyMSVR2 << index)));
 #endif
-           }
-
-           if (info->tty){
-               clear_bit(TTY_IO_ERROR, &info->tty->flags);
-           }
-       CY_UNLOCK(info, flags);
+               }
 
-    } else {
-      struct FIRM_ID __iomem *firm_id;
-      struct ZFW_CTRL __iomem *zfw_ctrl;
-      struct BOARD_CTRL __iomem *board_ctrl;
-      struct CH_CTRL __iomem *ch_ctrl;
-      struct BUF_CTRL __iomem *buf_ctrl;
-      uclong sw_flow;
-      int retval;
-
-        firm_id = cy_card[card].base_addr + ID_ADDRESS;
-        if (!ISZLOADED(cy_card[card])) {
-           return;
-       }
+               if (info->tty) {
+                       clear_bit(TTY_IO_ERROR, &info->tty->flags);
+               }
+               CY_UNLOCK(info, flags);
 
-       zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
-       board_ctrl = &zfw_ctrl->board_ctrl;
-       ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
-       buf_ctrl = &zfw_ctrl->buf_ctrl[channel];
-
-       /* baud rate */
-       baud = tty_get_baud_rate(info->tty);
-       if ((baud == 38400) &&
-           ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) {
-           if (info->custom_divisor)
-               baud_rate = info->baud / info->custom_divisor;
-           else
-               baud_rate = info->baud;
-       } else if (baud > CYZ_MAX_SPEED) {
-           baud = CYZ_MAX_SPEED;
-       }
-       cy_writel(&ch_ctrl->comm_baud , baud);
-
-       if (baud == 134) {
-           /* get it right for 134.5 baud */
-           info->timeout = (info->xmit_fifo_size*HZ*30/269) + 2;
-       } else if ((baud == 38400) &&
-                  ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) {
-           info->timeout = (info->xmit_fifo_size*HZ*15/baud_rate) + 2;
-       } else if (baud) {
-           info->timeout = (info->xmit_fifo_size*HZ*15/baud) + 2;
-           /* this needs to be propagated into the card info */
        } else {
-           info->timeout = 0;
-       }
+               struct FIRM_ID __iomem *firm_id;
+               struct ZFW_CTRL __iomem *zfw_ctrl;
+               struct BOARD_CTRL __iomem *board_ctrl;
+               struct CH_CTRL __iomem *ch_ctrl;
+               struct BUF_CTRL __iomem *buf_ctrl;
+               uclong sw_flow;
+               int retval;
+
+               firm_id = cy_card[card].base_addr + ID_ADDRESS;
+               if (!ISZLOADED(cy_card[card])) {
+                       return;
+               }
 
-       /* byte size and parity */
-       switch(cflag & CSIZE){
-       case CS5: cy_writel(&ch_ctrl->comm_data_l , C_DL_CS5); break;
-       case CS6: cy_writel(&ch_ctrl->comm_data_l , C_DL_CS6); break;
-       case CS7: cy_writel(&ch_ctrl->comm_data_l , C_DL_CS7); break;
-       case CS8: cy_writel(&ch_ctrl->comm_data_l , C_DL_CS8); break;
-       }
-       if(cflag & CSTOPB){
-           cy_writel(&ch_ctrl->comm_data_l,
-               cy_readl(&ch_ctrl->comm_data_l) | C_DL_2STOP);
-       }else{
-           cy_writel(&ch_ctrl->comm_data_l,
-               cy_readl(&ch_ctrl->comm_data_l) | C_DL_1STOP);
-       }
-       if (cflag & PARENB){
-           if (cflag & PARODD){
-               cy_writel(&ch_ctrl->comm_parity , C_PR_ODD);
-           }else{
-               cy_writel(&ch_ctrl->comm_parity , C_PR_EVEN);
-           }
-       }else{
-           cy_writel(&ch_ctrl->comm_parity , C_PR_NONE);
-       }
+               zfw_ctrl = cy_card[card].base_addr +
+                       (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
+               board_ctrl = &zfw_ctrl->board_ctrl;
+               ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
+               buf_ctrl = &zfw_ctrl->buf_ctrl[channel];
+
+               /* baud rate */
+               baud = tty_get_baud_rate(info->tty);
+               if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
+                               ASYNC_SPD_CUST) {
+                       if (info->custom_divisor)
+                               baud_rate = info->baud / info->custom_divisor;
+                       else
+                               baud_rate = info->baud;
+               } else if (baud > CYZ_MAX_SPEED) {
+                       baud = CYZ_MAX_SPEED;
+               }
+               cy_writel(&ch_ctrl->comm_baud, baud);
+
+               if (baud == 134) {
+                       /* get it right for 134.5 baud */
+                       info->timeout = (info->xmit_fifo_size * HZ * 30 / 269) +
+                                       2;
+               } else if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
+                               ASYNC_SPD_CUST) {
+                       info->timeout = (info->xmit_fifo_size * HZ * 15 /
+                                       baud_rate) + 2;
+               } else if (baud) {
+                       info->timeout = (info->xmit_fifo_size * HZ * 15 /
+                                       baud) + 2;
+                       /* this needs to be propagated into the card info */
+               } else {
+                       info->timeout = 0;
+               }
 
-       /* CTS flow control flag */
-       if (cflag & CRTSCTS){
-           cy_writel(&ch_ctrl->hw_flow,
-               cy_readl(&ch_ctrl->hw_flow) | C_RS_CTS | C_RS_RTS);
-       }else{
-           cy_writel(&ch_ctrl->hw_flow,
-               cy_readl(&ch_ctrl->hw_flow) & ~(C_RS_CTS | C_RS_RTS));
-       }
-       /* As the HW flow control is done in firmware, the driver doesn't
-          need to care about it */
-       info->flags &= ~ASYNC_CTS_FLOW;
-
-       /* XON/XOFF/XANY flow control flags */
-       sw_flow = 0;
-       if (iflag & IXON){
-           sw_flow |= C_FL_OXX;
-           if (iflag & IXANY)
-               sw_flow |= C_FL_OIXANY;
-       }
-       cy_writel(&ch_ctrl->sw_flow, sw_flow);
+               /* byte size and parity */
+               switch (cflag & CSIZE) {
+               case CS5:
+                       cy_writel(&ch_ctrl->comm_data_l, C_DL_CS5);
+                       break;
+               case CS6:
+                       cy_writel(&ch_ctrl->comm_data_l, C_DL_CS6);
+                       break;
+               case CS7:
+                       cy_writel(&ch_ctrl->comm_data_l, C_DL_CS7);
+                       break;
+               case CS8:
+                       cy_writel(&ch_ctrl->comm_data_l, C_DL_CS8);
+                       break;
+               }
+               if (cflag & CSTOPB) {
+                       cy_writel(&ch_ctrl->comm_data_l,
+                                 cy_readl(&ch_ctrl->comm_data_l) | C_DL_2STOP);
+               } else {
+                       cy_writel(&ch_ctrl->comm_data_l,
+                                 cy_readl(&ch_ctrl->comm_data_l) | C_DL_1STOP);
+               }
+               if (cflag & PARENB) {
+                       if (cflag & PARODD) {
+                               cy_writel(&ch_ctrl->comm_parity, C_PR_ODD);
+                       } else {
+                               cy_writel(&ch_ctrl->comm_parity, C_PR_EVEN);
+                       }
+               } else {
+                       cy_writel(&ch_ctrl->comm_parity, C_PR_NONE);
+               }
 
-       retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_IOCTL, 0L);
-       if (retval != 0){
-           printk("cyc:set_line_char retval on ttyC%d was %x\n",
-                  info->line, retval);
-       }
+               /* CTS flow control flag */
+               if (cflag & CRTSCTS) {
+                       cy_writel(&ch_ctrl->hw_flow,
+                                 cy_readl(&ch_ctrl->
+                                          hw_flow) | C_RS_CTS | C_RS_RTS);
+               } else {
+                       cy_writel(&ch_ctrl->hw_flow,
+                                 cy_readl(&ch_ctrl->
+                                          hw_flow) & ~(C_RS_CTS | C_RS_RTS));
+               }
+               /* As the HW flow control is done in firmware, the driver
+                  doesn't need to care about it */
+               info->flags &= ~ASYNC_CTS_FLOW;
+
+               /* XON/XOFF/XANY flow control flags */
+               sw_flow = 0;
+               if (iflag & IXON) {
+                       sw_flow |= C_FL_OXX;
+                       if (iflag & IXANY)
+                               sw_flow |= C_FL_OIXANY;
+               }
+               cy_writel(&ch_ctrl->sw_flow, sw_flow);
 
-       /* CD sensitivity */
-       if (cflag & CLOCAL){
-           info->flags &= ~ASYNC_CHECK_CD;
-       }else{
-           info->flags |= ASYNC_CHECK_CD;
-       }
+               retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_IOCTL, 0L);
+               if (retval != 0) {
+                       printk("cyc:set_line_char retval on ttyC%d was %x\n",
+                               info->line, retval);
+               }
+
+               /* CD sensitivity */
+               if (cflag & CLOCAL) {
+                       info->flags &= ~ASYNC_CHECK_CD;
+               } else {
+                       info->flags |= ASYNC_CHECK_CD;
+               }
 
-       if(baud == 0){ /* baud rate is zero, turn off line */
-           cy_writel(&ch_ctrl->rs_control,
-               cy_readl(&ch_ctrl->rs_control) & ~C_RS_DTR);
+               if (baud == 0) {        /* baud rate is zero, turn off line */
+                       cy_writel(&ch_ctrl->rs_control,
+                                 cy_readl(&ch_ctrl->rs_control) & ~C_RS_DTR);
 #ifdef CY_DEBUG_DTR
-           printk("cyc:set_line_char dropping Z DTR\n");
+                       printk("cyc:set_line_char dropping Z DTR\n");
 #endif
-       }else{
-           cy_writel(&ch_ctrl->rs_control,
-               cy_readl(&ch_ctrl->rs_control) | C_RS_DTR);
+               } else {
+                       cy_writel(&ch_ctrl->rs_control,
+                                 cy_readl(&ch_ctrl->rs_control) | C_RS_DTR);
 #ifdef CY_DEBUG_DTR
-           printk("cyc:set_line_char raising Z DTR\n");
+                       printk("cyc:set_line_char raising Z DTR\n");
 #endif
-       }
+               }
 
-       retval = cyz_issue_cmd( &cy_card[card], channel, C_CM_IOCTLM, 0L);
-       if (retval != 0){
-           printk("cyc:set_line_char(2) retval on ttyC%d was %x\n",
-                  info->line, retval);
-       }
+               retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_IOCTLM,0L);
+               if (retval != 0) {
+                       printk("cyc:set_line_char(2) retval on ttyC%d was %x\n",
+                               info->line, retval);
+               }
 
-       if (info->tty){
-           clear_bit(TTY_IO_ERROR, &info->tty->flags);
+               if (info->tty) {
+                       clear_bit(TTY_IO_ERROR, &info->tty->flags);
+               }
        }
-    }
-} /* set_line_char */
-
+}                              /* set_line_char */
 
 static int
-get_serial_info(struct cyclades_port * info,
-                           struct serial_struct __user * retinfo)
+get_serial_info(struct cyclades_port *info,
+               struct serial_struct __user * retinfo)
 {
-  struct serial_struct tmp;
-  struct cyclades_card *cinfo = &cy_card[info->card];
-
-    if (!retinfo)
-            return -EFAULT;
-    memset(&tmp, 0, sizeof(tmp));
-    tmp.type = info->type;
-    tmp.line = info->line;
-    tmp.port = info->card * 0x100 + info->line - cinfo->first_line;
-    tmp.irq = cinfo->irq;
-    tmp.flags = info->flags;
-    tmp.close_delay = info->close_delay;
-    tmp.baud_base = info->baud;
-    tmp.custom_divisor = info->custom_divisor;
-    tmp.hub6 = 0;               /*!!!*/
-    return copy_to_user(retinfo,&tmp,sizeof(*retinfo))?-EFAULT:0;
-} /* get_serial_info */
+       struct serial_struct tmp;
+       struct cyclades_card *cinfo = &cy_card[info->card];
 
+       if (!retinfo)
+               return -EFAULT;
+       memset(&tmp, 0, sizeof(tmp));
+       tmp.type = info->type;
+       tmp.line = info->line;
+       tmp.port = info->card * 0x100 + info->line - cinfo->first_line;
+       tmp.irq = cinfo->irq;
+       tmp.flags = info->flags;
+       tmp.close_delay = info->close_delay;
+       tmp.baud_base = info->baud;
+       tmp.custom_divisor = info->custom_divisor;
+       tmp.hub6 = 0;           /*!!! */
+       return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
+}                              /* get_serial_info */
 
 static int
-set_serial_info(struct cyclades_port * info,
-                           struct serial_struct __user * new_info)
+set_serial_info(struct cyclades_port *info,
+               struct serial_struct __user * new_info)
 {
-  struct serial_struct new_serial;
-  struct cyclades_port old_info;
-
-    if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
-       return -EFAULT;
-    old_info = *info;
-
-    if (!capable(CAP_SYS_ADMIN)) {
-            if ((new_serial.close_delay != info->close_delay) ||
-               (new_serial.baud_base != info->baud) ||
-               ((new_serial.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK) !=
-                (info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK)))
-                    return -EPERM;
-            info->flags = ((info->flags & ~ASYNC_USR_MASK) |
-                           (new_serial.flags & ASYNC_USR_MASK));
-            info->baud = new_serial.baud_base;
-           info->custom_divisor = new_serial.custom_divisor;
-            goto check_and_exit;
-    }
-
-
-    /*
-     * OK, past this point, all the error checking has been done.
-     * At this point, we start making changes.....
-     */
-
-    info->baud = new_serial.baud_base;
-    info->custom_divisor = new_serial.custom_divisor;
-    info->flags = ((info->flags & ~ASYNC_FLAGS) |
-                    (new_serial.flags & ASYNC_FLAGS));
-    info->close_delay = new_serial.close_delay * HZ/100;
-    info->closing_wait = new_serial.closing_wait * HZ/100;
+       struct serial_struct new_serial;
+       struct cyclades_port old_info;
+
+       if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
+               return -EFAULT;
+       old_info = *info;
+
+       if (!capable(CAP_SYS_ADMIN)) {
+               if (new_serial.close_delay != info->close_delay ||
+                               new_serial.baud_base != info->baud ||
+                               (new_serial.flags & ASYNC_FLAGS &
+                                       ~ASYNC_USR_MASK) !=
+                               (info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK))
+                       return -EPERM;
+               info->flags = (info->flags & ~ASYNC_USR_MASK) |
+                               (new_serial.flags & ASYNC_USR_MASK);
+               info->baud = new_serial.baud_base;
+               info->custom_divisor = new_serial.custom_divisor;
+               goto check_and_exit;
+       }
+
+       /*
+        * OK, past this point, all the error checking has been done.
+        * At this point, we start making changes.....
+        */
+
+       info->baud = new_serial.baud_base;
+       info->custom_divisor = new_serial.custom_divisor;
+       info->flags = (info->flags & ~ASYNC_FLAGS) |
+                       (new_serial.flags & ASYNC_FLAGS);
+       info->close_delay = new_serial.close_delay * HZ / 100;
+       info->closing_wait = new_serial.closing_wait * HZ / 100;
 
 check_and_exit:
-    if (info->flags & ASYNC_INITIALIZED){
-        set_line_char(info);
-        return 0;
-    }else{
-        return startup(info);
-    }
-} /* set_serial_info */
+       if (info->flags & ASYNC_INITIALIZED) {
+               set_line_char(info);
+               return 0;
+       } else {
+               return startup(info);
+       }
+}                              /* set_serial_info */
 
 /*
  * get_lsr_info - get line status register info
@@ -3473,441 +3562,452 @@ check_and_exit:
  *         transmit holding register is empty.  This functionality
  *         allows an RS485 driver to be written in user space.
  */
-static int get_lsr_info(struct cyclades_port *info, unsigned int __user *value)
+static int get_lsr_info(struct cyclades_port *info, unsigned int __user * value)
 {
-    int card, chip, channel, index;
-    unsigned char status;
-    unsigned int result;
-    unsigned long flags;
-    void __iomem *base_addr;
-
-    card = info->card;
-    channel = (info->line) - (cy_card[card].first_line);
-    if (!IS_CYC_Z(cy_card[card])) {
-       chip = channel>>2;
-       channel &= 0x03;
-       index = cy_card[card].bus_index;
-       base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index);
+       int card, chip, channel, index;
+       unsigned char status;
+       unsigned int result;
+       unsigned long flags;
+       void __iomem *base_addr;
 
-       CY_LOCK(info, flags);
-       status = cy_readb(base_addr+(CySRER<<index)) & (CyTxRdy|CyTxMpty);
-       CY_UNLOCK(info, flags);
-       result = (status ? 0 : TIOCSER_TEMT);
-    } else {
-       /* Not supported yet */
-       return -EINVAL;
-    }
-    return put_user(result, (unsigned long __user *) value);
+       card = info->card;
+       channel = (info->line) - (cy_card[card].first_line);
+       if (!IS_CYC_Z(cy_card[card])) {
+               chip = channel >> 2;
+               channel &= 0x03;
+               index = cy_card[card].bus_index;
+               base_addr =
+                   cy_card[card].base_addr + (cy_chip_offset[chip] << index);
+
+               CY_LOCK(info, flags);
+               status = cy_readb(base_addr + (CySRER << index)) &
+                               (CyTxRdy | CyTxMpty);
+               CY_UNLOCK(info, flags);
+               result = (status ? 0 : TIOCSER_TEMT);
+       } else {
+               /* Not supported yet */
+               return -EINVAL;
+       }
+       return put_user(result, (unsigned long __user *)value);
 }
 
-static int
-cy_tiocmget(struct tty_struct *tty, struct file *file)
+static int cy_tiocmget(struct tty_struct *tty, struct file *file)
 {
-  struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
-  int card,chip,channel,index;
-  void __iomem *base_addr;
-  unsigned long flags;
-  unsigned char status;
-  unsigned long lstatus;
-  unsigned int result;
-  struct FIRM_ID __iomem *firm_id;
-  struct ZFW_CTRL __iomem *zfw_ctrl;
-  struct BOARD_CTRL __iomem *board_ctrl;
-  struct CH_CTRL __iomem *ch_ctrl;
-
-    if (serial_paranoia_check(info, tty->name, __FUNCTION__))
-       return -ENODEV;
-
-    card = info->card;
-    channel = (info->line) - (cy_card[card].first_line);
-    if (!IS_CYC_Z(cy_card[card])) {
-       chip = channel>>2;
-       channel &= 0x03;
-       index = cy_card[card].bus_index;
-       base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index);
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       int card, chip, channel, index;
+       void __iomem *base_addr;
+       unsigned long flags;
+       unsigned char status;
+       unsigned long lstatus;
+       unsigned int result;
+       struct FIRM_ID __iomem *firm_id;
+       struct ZFW_CTRL __iomem *zfw_ctrl;
+       struct BOARD_CTRL __iomem *board_ctrl;
+       struct CH_CTRL __iomem *ch_ctrl;
+
+       if (serial_paranoia_check(info, tty->name, __FUNCTION__))
+               return -ENODEV;
 
-       CY_LOCK(info, flags);
-           cy_writeb(base_addr+(CyCAR<<index), (u_char)channel);
-           status = cy_readb(base_addr+(CyMSVR1<<index));
-           status |= cy_readb(base_addr+(CyMSVR2<<index));
-       CY_UNLOCK(info, flags);
+       card = info->card;
+       channel = (info->line) - (cy_card[card].first_line);
+       if (!IS_CYC_Z(cy_card[card])) {
+               chip = channel >> 2;
+               channel &= 0x03;
+               index = cy_card[card].bus_index;
+               base_addr =
+                   cy_card[card].base_addr + (cy_chip_offset[chip] << index);
 
-        if (info->rtsdtr_inv) {
-           result =  ((status  & CyRTS) ? TIOCM_DTR : 0)
-                   | ((status  & CyDTR) ? TIOCM_RTS : 0);
+               CY_LOCK(info, flags);
+               cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
+               status = cy_readb(base_addr + (CyMSVR1 << index));
+               status |= cy_readb(base_addr + (CyMSVR2 << index));
+               CY_UNLOCK(info, flags);
+
+               if (info->rtsdtr_inv) {
+                       result = ((status & CyRTS) ? TIOCM_DTR : 0) |
+                               ((status & CyDTR) ? TIOCM_RTS : 0);
+               } else {
+                       result = ((status & CyRTS) ? TIOCM_RTS : 0) |
+                               ((status & CyDTR) ? TIOCM_DTR : 0);
+               }
+               result |= ((status & CyDCD) ? TIOCM_CAR : 0) |
+                       ((status & CyRI) ? TIOCM_RNG : 0) |
+                       ((status & CyDSR) ? TIOCM_DSR : 0) |
+                       ((status & CyCTS) ? TIOCM_CTS : 0);
        } else {
-           result =  ((status  & CyRTS) ? TIOCM_RTS : 0)
-                   | ((status  & CyDTR) ? TIOCM_DTR : 0);
-       }
-       result |=  ((status  & CyDCD) ? TIOCM_CAR : 0)
-                | ((status  & CyRI) ? TIOCM_RNG : 0)
-                | ((status  & CyDSR) ? TIOCM_DSR : 0)
-                | ((status  & CyCTS) ? TIOCM_CTS : 0);
-    } else {
-       base_addr = cy_card[card].base_addr;
-
-        if (cy_card[card].num_chips != -1){
-           return -EINVAL;
-       }
+               base_addr = cy_card[card].base_addr;
 
-       firm_id = cy_card[card].base_addr + ID_ADDRESS;
-        if (ISZLOADED(cy_card[card])) {
-           zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
-           board_ctrl = &zfw_ctrl->board_ctrl;
-           ch_ctrl = zfw_ctrl->ch_ctrl;
-           lstatus = cy_readl(&ch_ctrl[channel].rs_status);
-           result =  ((lstatus  & C_RS_RTS) ? TIOCM_RTS : 0)
-                   | ((lstatus  & C_RS_DTR) ? TIOCM_DTR : 0)
-                   | ((lstatus  & C_RS_DCD) ? TIOCM_CAR : 0)
-                   | ((lstatus  & C_RS_RI) ? TIOCM_RNG : 0)
-                   | ((lstatus  & C_RS_DSR) ? TIOCM_DSR : 0)
-                   | ((lstatus  & C_RS_CTS) ? TIOCM_CTS : 0);
-       }else{
-           result = 0;
-           return -ENODEV;
-       }
+               if (cy_card[card].num_chips != -1) {
+                       return -EINVAL;
+               }
 
-    }
-    return result;
-} /* cy_tiomget */
+               firm_id = cy_card[card].base_addr + ID_ADDRESS;
+               if (ISZLOADED(cy_card[card])) {
+                       zfw_ctrl = cy_card[card].base_addr +
+                               (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
+                       board_ctrl = &zfw_ctrl->board_ctrl;
+                       ch_ctrl = zfw_ctrl->ch_ctrl;
+                       lstatus = cy_readl(&ch_ctrl[channel].rs_status);
+                       result = ((lstatus & C_RS_RTS) ? TIOCM_RTS : 0) |
+                               ((lstatus & C_RS_DTR) ? TIOCM_DTR : 0) |
+                               ((lstatus & C_RS_DCD) ? TIOCM_CAR : 0) |
+                               ((lstatus & C_RS_RI) ? TIOCM_RNG : 0) |
+                               ((lstatus & C_RS_DSR) ? TIOCM_DSR : 0) |
+                               ((lstatus & C_RS_CTS) ? TIOCM_CTS : 0);
+               } else {
+                       result = 0;
+                       return -ENODEV;
+               }
 
+       }
+       return result;
+}                              /* cy_tiomget */
 
 static int
 cy_tiocmset(struct tty_struct *tty, struct file *file,
-            unsigned int set, unsigned int clear)
+               unsigned int set, unsigned int clear)
 {
-  struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
-  int card,chip,channel,index;
-  void __iomem *base_addr;
-  unsigned long flags;
-  struct FIRM_ID __iomem *firm_id;
-  struct ZFW_CTRL __iomem *zfw_ctrl;
-  struct BOARD_CTRL __iomem *board_ctrl;
-  struct CH_CTRL __iomem *ch_ctrl;
-  int retval;
-
-    if (serial_paranoia_check(info, tty->name, __FUNCTION__))
-       return -ENODEV;
-
-    card = info->card;
-    channel = (info->line) - (cy_card[card].first_line);
-    if (!IS_CYC_Z(cy_card[card])) {
-       chip = channel>>2;
-       channel &= 0x03;
-       index = cy_card[card].bus_index;
-       base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index);
-
-       if (set & TIOCM_RTS){
-               CY_LOCK(info, flags);
-               cy_writeb(base_addr+(CyCAR<<index), (u_char)channel);
-                if (info->rtsdtr_inv) {
-                       cy_writeb(base_addr+(CyMSVR2<<index), CyDTR);
-                } else {
-                       cy_writeb(base_addr+(CyMSVR1<<index), CyRTS);
-                }
-               CY_UNLOCK(info, flags);
-       }
-       if (clear & TIOCM_RTS) {
-               CY_LOCK(info, flags);
-               cy_writeb(base_addr+(CyCAR<<index), (u_char)channel);
-                if (info->rtsdtr_inv) {
-                       cy_writeb(base_addr+(CyMSVR2<<index), ~CyDTR);
-                } else {
-                       cy_writeb(base_addr+(CyMSVR1<<index), ~CyRTS);
-                }
-               CY_UNLOCK(info, flags);
-       }
-       if (set & TIOCM_DTR){
-               CY_LOCK(info, flags);
-               cy_writeb(base_addr+(CyCAR<<index), (u_char)channel);
-                if (info->rtsdtr_inv) {
-                       cy_writeb(base_addr+(CyMSVR1<<index), CyRTS);
-                } else {
-                       cy_writeb(base_addr+(CyMSVR2<<index), CyDTR);
-                }
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       int card, chip, channel, index;
+       void __iomem *base_addr;
+       unsigned long flags;
+       struct FIRM_ID __iomem *firm_id;
+       struct ZFW_CTRL __iomem *zfw_ctrl;
+       struct BOARD_CTRL __iomem *board_ctrl;
+       struct CH_CTRL __iomem *ch_ctrl;
+       int retval;
+
+       if (serial_paranoia_check(info, tty->name, __FUNCTION__))
+               return -ENODEV;
+
+       card = info->card;
+       channel = (info->line) - (cy_card[card].first_line);
+       if (!IS_CYC_Z(cy_card[card])) {
+               chip = channel >> 2;
+               channel &= 0x03;
+               index = cy_card[card].bus_index;
+               base_addr =
+                   cy_card[card].base_addr + (cy_chip_offset[chip] << index);
+
+               if (set & TIOCM_RTS) {
+                       CY_LOCK(info, flags);
+                       cy_writeb(base_addr + (CyCAR << index),
+                                 (u_char) channel);
+                       if (info->rtsdtr_inv) {
+                               cy_writeb(base_addr + (CyMSVR2 << index),
+                                         CyDTR);
+                       } else {
+                               cy_writeb(base_addr + (CyMSVR1 << index),
+                                         CyRTS);
+                       }
+                       CY_UNLOCK(info, flags);
+               }
+               if (clear & TIOCM_RTS) {
+                       CY_LOCK(info, flags);
+                       cy_writeb(base_addr + (CyCAR << index),
+                                 (u_char) channel);
+                       if (info->rtsdtr_inv) {
+                               cy_writeb(base_addr + (CyMSVR2 << index),
+                                         ~CyDTR);
+                       } else {
+                               cy_writeb(base_addr + (CyMSVR1 << index),
+                                         ~CyRTS);
+                       }
+                       CY_UNLOCK(info, flags);
+               }
+               if (set & TIOCM_DTR) {
+                       CY_LOCK(info, flags);
+                       cy_writeb(base_addr + (CyCAR << index),
+                                 (u_char) channel);
+                       if (info->rtsdtr_inv) {
+                               cy_writeb(base_addr + (CyMSVR1 << index),
+                                         CyRTS);
+                       } else {
+                               cy_writeb(base_addr + (CyMSVR2 << index),
+                                         CyDTR);
+                       }
 #ifdef CY_DEBUG_DTR
-               printk("cyc:set_modem_info raising DTR\n");
-               printk("     status: 0x%x, 0x%x\n",
-                   cy_readb(base_addr+(CyMSVR1<<index)), 
-                    cy_readb(base_addr+(CyMSVR2<<index)));
+                       printk("cyc:set_modem_info raising DTR\n");
+                       printk("     status: 0x%x, 0x%x\n",
+                               cy_readb(base_addr + (CyMSVR1 << index)),
+                               cy_readb(base_addr + (CyMSVR2 << index)));
 #endif
-               CY_UNLOCK(info, flags);
-       }
-       if (clear & TIOCM_DTR) {
-               CY_LOCK(info, flags);
-               cy_writeb(base_addr+(CyCAR<<index), (u_char)channel);
-                if (info->rtsdtr_inv) {
-                       cy_writeb(base_addr+(CyMSVR1<<index), ~CyRTS);
-                } else {
-                       cy_writeb(base_addr+(CyMSVR2<<index), ~CyDTR);
-                }
+                       CY_UNLOCK(info, flags);
+               }
+               if (clear & TIOCM_DTR) {
+                       CY_LOCK(info, flags);
+                       cy_writeb(base_addr + (CyCAR << index),
+                                 (u_char) channel);
+                       if (info->rtsdtr_inv) {
+                               cy_writeb(base_addr + (CyMSVR1 << index),
+                                         ~CyRTS);
+                       } else {
+                               cy_writeb(base_addr + (CyMSVR2 << index),
+                                         ~CyDTR);
+                       }
 
 #ifdef CY_DEBUG_DTR
-               printk("cyc:set_modem_info dropping DTR\n");
-               printk("     status: 0x%x, 0x%x\n",
-                   cy_readb(base_addr+(CyMSVR1<<index)), 
-                    cy_readb(base_addr+(CyMSVR2<<index)));
+                       printk("cyc:set_modem_info dropping DTR\n");
+                       printk("     status: 0x%x, 0x%x\n",
+                               cy_readb(base_addr + (CyMSVR1 << index)),
+                               cy_readb(base_addr + (CyMSVR2 << index)));
 #endif
-               CY_UNLOCK(info, flags);
-       }
-    } else {
-       base_addr = cy_card[card].base_addr;
-
-       firm_id = cy_card[card].base_addr + ID_ADDRESS;
-        if (ISZLOADED(cy_card[card])) {
-           zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
-           board_ctrl = &zfw_ctrl->board_ctrl;
-           ch_ctrl = zfw_ctrl->ch_ctrl;
-
-           if (set & TIOCM_RTS){
-                   CY_LOCK(info, flags);
-                   cy_writel(&ch_ctrl[channel].rs_control,
-                       cy_readl(&ch_ctrl[channel].rs_control) | C_RS_RTS);
-                   CY_UNLOCK(info, flags);
-           }
-           if (clear & TIOCM_RTS) {
-                   CY_LOCK(info, flags);
-                   cy_writel(&ch_ctrl[channel].rs_control,
-                       cy_readl(&ch_ctrl[channel].rs_control) & ~C_RS_RTS);
-                   CY_UNLOCK(info, flags);
-           }
-           if (set & TIOCM_DTR){
-                   CY_LOCK(info, flags);
-                   cy_writel(&ch_ctrl[channel].rs_control,
-                       cy_readl(&ch_ctrl[channel].rs_control) | C_RS_DTR);
+                       CY_UNLOCK(info, flags);
+               }
+       } else {
+               base_addr = cy_card[card].base_addr;
+
+               firm_id = cy_card[card].base_addr + ID_ADDRESS;
+               if (ISZLOADED(cy_card[card])) {
+                       zfw_ctrl = cy_card[card].base_addr +
+                               (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
+                       board_ctrl = &zfw_ctrl->board_ctrl;
+                       ch_ctrl = zfw_ctrl->ch_ctrl;
+
+                       if (set & TIOCM_RTS) {
+                               CY_LOCK(info, flags);
+                               cy_writel(&ch_ctrl[channel].rs_control,
+                                         cy_readl(&ch_ctrl[channel].
+                                                  rs_control) | C_RS_RTS);
+                               CY_UNLOCK(info, flags);
+                       }
+                       if (clear & TIOCM_RTS) {
+                               CY_LOCK(info, flags);
+                               cy_writel(&ch_ctrl[channel].rs_control,
+                                         cy_readl(&ch_ctrl[channel].
+                                                  rs_control) & ~C_RS_RTS);
+                               CY_UNLOCK(info, flags);
+                       }
+                       if (set & TIOCM_DTR) {
+                               CY_LOCK(info, flags);
+                               cy_writel(&ch_ctrl[channel].rs_control,
+                                         cy_readl(&ch_ctrl[channel].
+                                                  rs_control) | C_RS_DTR);
 #ifdef CY_DEBUG_DTR
-                   printk("cyc:set_modem_info raising Z DTR\n");
+                               printk("cyc:set_modem_info raising Z DTR\n");
 #endif
-                   CY_UNLOCK(info, flags);
-           }
-           if (clear & TIOCM_DTR) {
-                   CY_LOCK(info, flags);
-                   cy_writel(&ch_ctrl[channel].rs_control,
-                       cy_readl(&ch_ctrl[channel].rs_control) & ~C_RS_DTR);
+                               CY_UNLOCK(info, flags);
+                       }
+                       if (clear & TIOCM_DTR) {
+                               CY_LOCK(info, flags);
+                               cy_writel(&ch_ctrl[channel].rs_control,
+                                         cy_readl(&ch_ctrl[channel].
+                                                  rs_control) & ~C_RS_DTR);
 #ifdef CY_DEBUG_DTR
-                   printk("cyc:set_modem_info clearing Z DTR\n");
+                               printk("cyc:set_modem_info clearing Z DTR\n");
 #endif
-                   CY_UNLOCK(info, flags);
-           }
-       }else{
-           return -ENODEV;
-       }
-       CY_LOCK(info, flags);
-        retval = cyz_issue_cmd(&cy_card[info->card],
-                                   channel, C_CM_IOCTLM,0L);
-       if (retval != 0){
-           printk("cyc:set_modem_info retval on ttyC%d was %x\n",
-                  info->line, retval);
+                               CY_UNLOCK(info, flags);
+                       }
+               } else {
+                       return -ENODEV;
+               }
+               CY_LOCK(info, flags);
+               retval = cyz_issue_cmd(&cy_card[info->card],
+                                       channel, C_CM_IOCTLM, 0L);
+               if (retval != 0) {
+                       printk("cyc:set_modem_info retval on ttyC%d was %x\n",
+                               info->line, retval);
+               }
+               CY_UNLOCK(info, flags);
        }
-       CY_UNLOCK(info, flags);
-    }
-    return 0;
-} /* cy_tiocmset */
+       return 0;
+}                              /* cy_tiocmset */
 
 /*
  * cy_break() --- routine which turns the break handling on or off
  */
-static void
-cy_break(struct tty_struct *tty, int break_state)
+static void cy_break(struct tty_struct *tty, int break_state)
 {
-    struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
-    unsigned long flags;
-
-    if (serial_paranoia_check(info, tty->name, "cy_break"))
-       return;
-
-    CY_LOCK(info, flags);
-    if (!IS_CYC_Z(cy_card[info->card])) {
-        /* Let the transmit ISR take care of this (since it
-          requires stuffing characters into the output stream).
-        */
-       if (break_state == -1) {
-           if (!info->breakon) {
-               info->breakon = 1;
-               if (!info->xmit_cnt) {
-                   CY_UNLOCK(info, flags);
-                   start_xmit(info);
-                   CY_LOCK(info, flags);
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       unsigned long flags;
+
+       if (serial_paranoia_check(info, tty->name, "cy_break"))
+               return;
+
+       CY_LOCK(info, flags);
+       if (!IS_CYC_Z(cy_card[info->card])) {
+               /* Let the transmit ISR take care of this (since it
+                  requires stuffing characters into the output stream).
+                */
+               if (break_state == -1) {
+                       if (!info->breakon) {
+                               info->breakon = 1;
+                               if (!info->xmit_cnt) {
+                                       CY_UNLOCK(info, flags);
+                                       start_xmit(info);
+                                       CY_LOCK(info, flags);
+                               }
+                       }
+               } else {
+                       if (!info->breakoff) {
+                               info->breakoff = 1;
+                               if (!info->xmit_cnt) {
+                                       CY_UNLOCK(info, flags);
+                                       start_xmit(info);
+                                       CY_LOCK(info, flags);
+                               }
+                       }
                }
-           }
        } else {
-           if (!info->breakoff) {
-               info->breakoff = 1;
-               if (!info->xmit_cnt) {
-                   CY_UNLOCK(info, flags);
-                   start_xmit(info);
-                   CY_LOCK(info, flags);
+               int retval;
+
+               if (break_state == -1) {
+                       retval = cyz_issue_cmd(&cy_card[info->card],
+                               info->line - cy_card[info->card].first_line,
+                               C_CM_SET_BREAK, 0L);
+                       if (retval != 0) {
+                               printk("cyc:cy_break (set) retval on ttyC%d "
+                                       "was %x\n", info->line, retval);
+                       }
+               } else {
+                       retval = cyz_issue_cmd(&cy_card[info->card],
+                               info->line - cy_card[info->card].first_line,
+                               C_CM_CLR_BREAK, 0L);
+                       if (retval != 0) {
+                               printk("cyc:cy_break (clr) retval on ttyC%d "
+                                       "was %x\n", info->line, retval);
+                       }
                }
-           }
        }
-    } else {
-       int retval;
-
-       if (break_state == -1) {
-           retval = cyz_issue_cmd(&cy_card[info->card],
-               (info->line) - (cy_card[info->card].first_line),
-               C_CM_SET_BREAK, 0L);
-           if (retval != 0) {
-               printk("cyc:cy_break (set) retval on ttyC%d was %x\n",
-                      info->line, retval);
-           }
-       } else {
-           retval = cyz_issue_cmd(&cy_card[info->card],
-               (info->line) - (cy_card[info->card].first_line),
-               C_CM_CLR_BREAK, 0L);
-           if (retval != 0) {
-               printk("cyc:cy_break (clr) retval on ttyC%d was %x\n",
-                      info->line, retval);
-           }
-       }
-    }
-    CY_UNLOCK(info, flags);
-} /* cy_break */
+       CY_UNLOCK(info, flags);
+}                              /* cy_break */
 
 static int
-get_mon_info(struct cyclades_port * info, struct cyclades_monitor __user * mon)
+get_mon_info(struct cyclades_port *info, struct cyclades_monitor __user * mon)
 {
 
-    if(copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor)))
-       return -EFAULT;
-    info->mon.int_count  = 0;
-    info->mon.char_count = 0;
-    info->mon.char_max   = 0;
-    info->mon.char_last  = 0;
-    return 0;
-}/* get_mon_info */
-
+       if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor)))
+               return -EFAULT;
+       info->mon.int_count = 0;
+       info->mon.char_count = 0;
+       info->mon.char_max = 0;
+       info->mon.char_last = 0;
+       return 0;
+}                              /* get_mon_info */
 
-static int
-set_threshold(struct cyclades_port * info, unsigned long value)
+static int set_threshold(struct cyclades_port *info, unsigned long value)
 {
-  void __iomem *base_addr;
-  int card,channel,chip,index;
-  unsigned long flags;
-   
-    card = info->card;
-    channel = info->line - cy_card[card].first_line;
-    if (!IS_CYC_Z(cy_card[card])) {
-       chip = channel>>2;
-       channel &= 0x03;
-       index = cy_card[card].bus_index;
-       base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index);
-
-       info->cor3 &= ~CyREC_FIFO;
-       info->cor3 |= value & CyREC_FIFO;
+       void __iomem *base_addr;
+       int card, channel, chip, index;
+       unsigned long flags;
 
-       CY_LOCK(info, flags);
-           cy_writeb(base_addr+(CyCOR3<<index), info->cor3);
-           cyy_issue_cmd(base_addr,CyCOR_CHANGE|CyCOR3ch,index);
-       CY_UNLOCK(info, flags);
-    } else {
-       // Nothing to do!
-    }
-    return 0;
-}/* set_threshold */
+       card = info->card;
+       channel = info->line - cy_card[card].first_line;
+       if (!IS_CYC_Z(cy_card[card])) {
+               chip = channel >> 2;
+               channel &= 0x03;
+               index = cy_card[card].bus_index;
+               base_addr =
+                   cy_card[card].base_addr + (cy_chip_offset[chip] << index);
 
+               info->cor3 &= ~CyREC_FIFO;
+               info->cor3 |= value & CyREC_FIFO;
 
-static int
-get_threshold(struct cyclades_port * info, unsigned long __user *value)
-{
-  void __iomem *base_addr;
-  int card,channel,chip,index;
-  unsigned long tmp;
-   
-    card = info->card;
-    channel = info->line - cy_card[card].first_line;
-    if (!IS_CYC_Z(cy_card[card])) {
-       chip = channel>>2;
-       channel &= 0x03;
-       index = cy_card[card].bus_index;
-       base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index);
-
-       tmp = cy_readb(base_addr+(CyCOR3<<index)) & CyREC_FIFO;
-       return put_user(tmp,value);
-    } else {
-       // Nothing to do!
+               CY_LOCK(info, flags);
+               cy_writeb(base_addr + (CyCOR3 << index), info->cor3);
+               cyy_issue_cmd(base_addr, CyCOR_CHANGE | CyCOR3ch, index);
+               CY_UNLOCK(info, flags);
+       } else {
+               /* Nothing to do! */
+       }
        return 0;
-    }
-}/* get_threshold */
-
+}                              /* set_threshold */
 
 static int
-set_default_threshold(struct cyclades_port * info, unsigned long value)
+get_threshold(struct cyclades_port *info, unsigned long __user * value)
 {
-    info->default_threshold = value & 0x0f;
-    return 0;
-}/* set_default_threshold */
+       void __iomem *base_addr;
+       int card, channel, chip, index;
+       unsigned long tmp;
 
+       card = info->card;
+       channel = info->line - cy_card[card].first_line;
+       if (!IS_CYC_Z(cy_card[card])) {
+               chip = channel >> 2;
+               channel &= 0x03;
+               index = cy_card[card].bus_index;
+               base_addr =
+                   cy_card[card].base_addr + (cy_chip_offset[chip] << index);
+
+               tmp = cy_readb(base_addr + (CyCOR3 << index)) & CyREC_FIFO;
+               return put_user(tmp, value);
+       } else {
+               /* Nothing to do! */
+               return 0;
+       }
+}                              /* get_threshold */
 
 static int
-get_default_threshold(struct cyclades_port * info, unsigned long __user *value)
+set_default_threshold(struct cyclades_port *info, unsigned long value)
 {
-    return put_user(info->default_threshold,value);
-}/* get_default_threshold */
-
+       info->default_threshold = value & 0x0f;
+       return 0;
+}                              /* set_default_threshold */
 
 static int
-set_timeout(struct cyclades_port * info, unsigned long value)
+get_default_threshold(struct cyclades_port *info, unsigned long __user * value)
 {
-  void __iomem *base_addr;
-  int card,channel,chip,index;
-  unsigned long flags;
-   
-    card = info->card;
-    channel = info->line - cy_card[card].first_line;
-    if (!IS_CYC_Z(cy_card[card])) {
-       chip = channel>>2;
-       channel &= 0x03;
-       index = cy_card[card].bus_index;
-       base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index);
+       return put_user(info->default_threshold, value);
+}                              /* get_default_threshold */
 
-       CY_LOCK(info, flags);
-           cy_writeb(base_addr+(CyRTPR<<index), value & 0xff);
-       CY_UNLOCK(info, flags);
-    } else {
-       // Nothing to do!
-    }
-    return 0;
-}/* set_timeout */
+static int set_timeout(struct cyclades_port *info, unsigned long value)
+{
+       void __iomem *base_addr;
+       int card, channel, chip, index;
+       unsigned long flags;
 
+       card = info->card;
+       channel = info->line - cy_card[card].first_line;
+       if (!IS_CYC_Z(cy_card[card])) {
+               chip = channel >> 2;
+               channel &= 0x03;
+               index = cy_card[card].bus_index;
+               base_addr =
+                   cy_card[card].base_addr + (cy_chip_offset[chip] << index);
 
-static int
-get_timeout(struct cyclades_port * info, unsigned long __user *value)
-{
-  void __iomem *base_addr;
-  int card,channel,chip,index;
-  unsigned long tmp;
-   
-    card = info->card;
-    channel = info->line - cy_card[card].first_line;
-    if (!IS_CYC_Z(cy_card[card])) {
-       chip = channel>>2;
-       channel &= 0x03;
-       index = cy_card[card].bus_index;
-       base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index);
-
-       tmp = cy_readb(base_addr+(CyRTPR<<index));
-       return put_user(tmp,value);
-    } else {
-       // Nothing to do!
+               CY_LOCK(info, flags);
+               cy_writeb(base_addr + (CyRTPR << index), value & 0xff);
+               CY_UNLOCK(info, flags);
+       } else {
+               /* Nothing to do! */
+       }
        return 0;
-    }
-}/* get_timeout */
+}                              /* set_timeout */
 
-
-static int
-set_default_timeout(struct cyclades_port * info, unsigned long value)
+static int get_timeout(struct cyclades_port *info, unsigned long __user * value)
 {
-    info->default_timeout = value & 0xff;
-    return 0;
-}/* set_default_timeout */
+       void __iomem *base_addr;
+       int card, channel, chip, index;
+       unsigned long tmp;
+
+       card = info->card;
+       channel = info->line - cy_card[card].first_line;
+       if (!IS_CYC_Z(cy_card[card])) {
+               chip = channel >> 2;
+               channel &= 0x03;
+               index = cy_card[card].bus_index;
+               base_addr =
+                   cy_card[card].base_addr + (cy_chip_offset[chip] << index);
+
+               tmp = cy_readb(base_addr + (CyRTPR << index));
+               return put_user(tmp, value);
+       } else {
+               /* Nothing to do! */
+               return 0;
+       }
+}                              /* get_timeout */
 
+static int set_default_timeout(struct cyclades_port *info, unsigned long value)
+{
+       info->default_timeout = value & 0xff;
+       return 0;
+}                              /* set_default_timeout */
 
 static int
-get_default_timeout(struct cyclades_port * info, unsigned long __user *value)
+get_default_timeout(struct cyclades_port *info, unsigned long __user * value)
 {
-    return put_user(info->default_timeout,value);
-}/* get_default_timeout */
+       return put_user(info->default_timeout, value);
+}                              /* get_default_timeout */
 
 /*
  * This routine allows the tty driver to implement device-
@@ -3915,184 +4015,193 @@ get_default_timeout(struct cyclades_port * info, unsigned long __user *value)
  * not recognized by the driver, it should return ENOIOCTLCMD.
  */
 static int
-cy_ioctl(struct tty_struct *tty, struct file * file,
-            unsigned int cmd, unsigned long arg)
+cy_ioctl(struct tty_struct *tty, struct file *file,
+        unsigned int cmd, unsigned long arg)
 {
-  struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
-  struct cyclades_icount cprev, cnow;          /* kernel counter temps */
-  struct serial_icounter_struct __user *p_cuser;       /* user space */
-  int ret_val = 0;
-  unsigned long flags;
-  void __user *argp = (void __user *)arg;
-
-    if (serial_paranoia_check(info, tty->name, "cy_ioctl"))
-       return -ENODEV;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_icount cprev, cnow;     /* kernel counter temps */
+       struct serial_icounter_struct __user *p_cuser;  /* user space */
+       int ret_val = 0;
+       unsigned long flags;
+       void __user *argp = (void __user *)arg;
+
+       if (serial_paranoia_check(info, tty->name, "cy_ioctl"))
+               return -ENODEV;
 
 #ifdef CY_DEBUG_OTHER
-    printk("cyc:cy_ioctl ttyC%d, cmd = %x arg = %lx\n",
-        info->line, cmd, arg); /* */
+       printk("cyc:cy_ioctl ttyC%d, cmd = %x arg = %lx\n", info->line, cmd, arg);      /* */
 #endif
 
-    switch (cmd) {
-        case CYGETMON:
-            ret_val = get_mon_info(info, argp);
-            break;
-        case CYGETTHRESH:
-            ret_val = get_threshold(info, argp);
-            break;
-        case CYSETTHRESH:
-            ret_val = set_threshold(info, arg);
-            break;
-        case CYGETDEFTHRESH:
-            ret_val = get_default_threshold(info, argp);
-            break;
-        case CYSETDEFTHRESH:
-            ret_val = set_default_threshold(info, arg);
-            break;
-        case CYGETTIMEOUT:
-            ret_val = get_timeout(info, argp);
-            break;
-        case CYSETTIMEOUT:
-            ret_val = set_timeout(info, arg);
-            break;
-        case CYGETDEFTIMEOUT:
-            ret_val = get_default_timeout(info, argp);
-            break;
-        case CYSETDEFTIMEOUT:
-            ret_val = set_default_timeout(info, arg);
-            break;
+       switch (cmd) {
+       case CYGETMON:
+               ret_val = get_mon_info(info, argp);
+               break;
+       case CYGETTHRESH:
+               ret_val = get_threshold(info, argp);
+               break;
+       case CYSETTHRESH:
+               ret_val = set_threshold(info, arg);
+               break;
+       case CYGETDEFTHRESH:
+               ret_val = get_default_threshold(info, argp);
+               break;
+       case CYSETDEFTHRESH:
+               ret_val = set_default_threshold(info, arg);
+               break;
+       case CYGETTIMEOUT:
+               ret_val = get_timeout(info, argp);
+               break;
+       case CYSETTIMEOUT:
+               ret_val = set_timeout(info, arg);
+               break;
+       case CYGETDEFTIMEOUT:
+               ret_val = get_default_timeout(info, argp);
+               break;
+       case CYSETDEFTIMEOUT:
+               ret_val = set_default_timeout(info, arg);
+               break;
        case CYSETRFLOW:
-           info->rflow = (int)arg;
-           ret_val = 0;
-           break;
+               info->rflow = (int)arg;
+               ret_val = 0;
+               break;
        case CYGETRFLOW:
-           ret_val = info->rflow;
-           break;
+               ret_val = info->rflow;
+               break;
        case CYSETRTSDTR_INV:
-           info->rtsdtr_inv = (int)arg;
-           ret_val = 0;
-           break;
+               info->rtsdtr_inv = (int)arg;
+               ret_val = 0;
+               break;
        case CYGETRTSDTR_INV:
-           ret_val = info->rtsdtr_inv;
-           break;
+               ret_val = info->rtsdtr_inv;
+               break;
        case CYGETCARDINFO:
-            if (copy_to_user(argp, &cy_card[info->card], 
-                       sizeof (struct cyclades_card))) {
-               ret_val = -EFAULT;
+               if (copy_to_user(argp, &cy_card[info->card],
+                                sizeof(struct cyclades_card))) {
+                       ret_val = -EFAULT;
+                       break;
+               }
+               ret_val = 0;
                break;
-           }
-           ret_val = 0;
-            break;
        case CYGETCD1400VER:
-           ret_val = info->chip_rev;
-           break;
+               ret_val = info->chip_rev;
+               break;
 #ifndef CONFIG_CYZ_INTR
        case CYZSETPOLLCYCLE:
-            cyz_polling_cycle = (arg * HZ) / 1000;
-           ret_val = 0;
-           break;
+               cyz_polling_cycle = (arg * HZ) / 1000;
+               ret_val = 0;
+               break;
        case CYZGETPOLLCYCLE:
-            ret_val = (cyz_polling_cycle * 1000) / HZ;
-           break;
-#endif /* CONFIG_CYZ_INTR */
+               ret_val = (cyz_polling_cycle * 1000) / HZ;
+               break;
+#endif                         /* CONFIG_CYZ_INTR */
        case CYSETWAIT:
-           info->closing_wait = (unsigned short)arg * HZ/100;
-           ret_val = 0;
-           break;
+               info->closing_wait = (unsigned short)arg *HZ / 100;
+               ret_val = 0;
+               break;
        case CYGETWAIT:
-           ret_val = info->closing_wait / (HZ/100);
-           break;
-        case TIOCGSERIAL:
-            ret_val = get_serial_info(info, argp);
-            break;
-        case TIOCSSERIAL:
-            ret_val = set_serial_info(info, argp);
-            break;
-       case TIOCSERGETLSR: /* Get line status register */
-           ret_val = get_lsr_info(info, argp);
-           break;
-       /*
-        * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change 
-        * - mask passed in arg for lines of interest
-        *   (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
-        * Caller should use TIOCGICOUNT to see which one it was
-        */
+               ret_val = info->closing_wait / (HZ / 100);
+               break;
+       case TIOCGSERIAL:
+               ret_val = get_serial_info(info, argp);
+               break;
+       case TIOCSSERIAL:
+               ret_val = set_serial_info(info, argp);
+               break;
+       case TIOCSERGETLSR:     /* Get line status register */
+               ret_val = get_lsr_info(info, argp);
+               break;
+               /*
+                * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
+                * - mask passed in arg for lines of interest
+                *   (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
+                * Caller should use TIOCGICOUNT to see which one it was
+                */
        case TIOCMIWAIT:
-           CY_LOCK(info, flags);
-           /* note the counters on entry */
-           cprev = info->icount;
-           CY_UNLOCK(info, flags);
-           while (1) {
-               interruptible_sleep_on(&info->delta_msr_wait);
-               /* see if a signal did it */
-               if (signal_pending(current)) {
-                   return -ERESTARTSYS;
-               }
-
                CY_LOCK(info, flags);
-               cnow = info->icount; /* atomic copy */
+               /* note the counters on entry */
+               cprev = info->icount;
                CY_UNLOCK(info, flags);
+               while (1) {
+                       interruptible_sleep_on(&info->delta_msr_wait);
+                       /* see if a signal did it */
+                       if (signal_pending(current)) {
+                               return -ERESTARTSYS;
+                       }
 
-               if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && 
-                   cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) {
-                   return -EIO; /* no change => error */
-               }
-               if ( ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || 
-                    ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || 
-                    ((arg & TIOCM_CD)  && (cnow.dcd != cprev.dcd)) || 
-                    ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) {
-                   return 0;
-               }
-               cprev = cnow;
-           }
-           /* NOTREACHED */
+                       CY_LOCK(info, flags);
+                       cnow = info->icount;    /* atomic copy */
+                       CY_UNLOCK(info, flags);
 
-       /*
-        * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
-        * Return: write counters to the user passed counter struct
-        * NB: both 1->0 and 0->1 transitions are counted except for
-        *     RI where only 0->1 is counted.
-        */
+                       if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
+                           cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) {
+                               return -EIO;    /* no change => error */
+                       }
+                       if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
+                           ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
+                           ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
+                           ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) {
+                               return 0;
+                       }
+                       cprev = cnow;
+               }
+               /* NOTREACHED */
+
+               /*
+                * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
+                * Return: write counters to the user passed counter struct
+                * NB: both 1->0 and 0->1 transitions are counted except for
+                *     RI where only 0->1 is counted.
+                */
        case TIOCGICOUNT:
-           CY_LOCK(info, flags);
-           cnow = info->icount;
-           CY_UNLOCK(info, flags);
-           p_cuser = argp;
-           ret_val = put_user(cnow.cts, &p_cuser->cts);
-           if (ret_val) return ret_val;
-           ret_val = put_user(cnow.dsr, &p_cuser->dsr);
-           if (ret_val) return ret_val;
-           ret_val = put_user(cnow.rng, &p_cuser->rng);
-           if (ret_val) return ret_val;
-           ret_val = put_user(cnow.dcd, &p_cuser->dcd);
-           if (ret_val) return ret_val;
-           ret_val = put_user(cnow.rx, &p_cuser->rx);
-           if (ret_val) return ret_val;
-           ret_val = put_user(cnow.tx, &p_cuser->tx);
-           if (ret_val) return ret_val;
-           ret_val = put_user(cnow.frame, &p_cuser->frame);
-           if (ret_val) return ret_val;
-           ret_val = put_user(cnow.overrun, &p_cuser->overrun);
-           if (ret_val) return ret_val;
-           ret_val = put_user(cnow.parity, &p_cuser->parity);
-           if (ret_val) return ret_val;
-           ret_val = put_user(cnow.brk, &p_cuser->brk);
-           if (ret_val) return ret_val;
-           ret_val = put_user(cnow.buf_overrun, &p_cuser->buf_overrun);
-           if (ret_val) return ret_val;
-           ret_val = 0;
-           break;
-        default:
-            ret_val = -ENOIOCTLCMD;
-    }
+               CY_LOCK(info, flags);
+               cnow = info->icount;
+               CY_UNLOCK(info, flags);
+               p_cuser = argp;
+               ret_val = put_user(cnow.cts, &p_cuser->cts);
+               if (ret_val)
+                       return ret_val;
+               ret_val = put_user(cnow.dsr, &p_cuser->dsr);
+               if (ret_val)
+                       return ret_val;
+               ret_val = put_user(cnow.rng, &p_cuser->rng);
+               if (ret_val)
+                       return ret_val;
+               ret_val = put_user(cnow.dcd, &p_cuser->dcd);
+               if (ret_val)
+                       return ret_val;
+               ret_val = put_user(cnow.rx, &p_cuser->rx);
+               if (ret_val)
+                       return ret_val;
+               ret_val = put_user(cnow.tx, &p_cuser->tx);
+               if (ret_val)
+                       return ret_val;
+               ret_val = put_user(cnow.frame, &p_cuser->frame);
+               if (ret_val)
+                       return ret_val;
+               ret_val = put_user(cnow.overrun, &p_cuser->overrun);
+               if (ret_val)
+                       return ret_val;
+               ret_val = put_user(cnow.parity, &p_cuser->parity);
+               if (ret_val)
+                       return ret_val;
+               ret_val = put_user(cnow.brk, &p_cuser->brk);
+               if (ret_val)
+                       return ret_val;
+               ret_val = put_user(cnow.buf_overrun, &p_cuser->buf_overrun);
+               if (ret_val)
+                       return ret_val;
+               ret_val = 0;
+               break;
+       default:
+               ret_val = -ENOIOCTLCMD;
+       }
 
 #ifdef CY_DEBUG_OTHER
-    printk(" cyc:cy_ioctl done\n");
+       printk(" cyc:cy_ioctl done\n");
 #endif
 
-    return ret_val;
-} /* cy_ioctl */
-
+       return ret_val;
+}                              /* cy_ioctl */
 
 /*
  * This routine allows the tty driver to be notified when
@@ -4100,66 +4209,64 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
  * well-designed tty driver should be prepared to accept the case
  * where old == NULL, and try to do something rational.
  */
-static void
-cy_set_termios(struct tty_struct *tty, struct termios * old_termios)
+static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
 
 #ifdef CY_DEBUG_OTHER
-    printk("cyc:cy_set_termios ttyC%d\n", info->line);
+       printk("cyc:cy_set_termios ttyC%d\n", info->line);
 #endif
 
-    if ((tty->termios->c_cflag == old_termios->c_cflag) &&
-       ((tty->termios->c_iflag & (IXON|IXANY)) == 
-        (old_termios->c_iflag & (IXON|IXANY))))
-        return;
-    set_line_char(info);
-
-    if ((old_termios->c_cflag & CRTSCTS) &&
-        !(tty->termios->c_cflag & CRTSCTS)) {
-            tty->hw_stopped = 0;
-            cy_start(tty);
-    }
+       if (tty->termios->c_cflag == old_termios->c_cflag &&
+                       (tty->termios->c_iflag & (IXON | IXANY)) ==
+                       (old_termios->c_iflag & (IXON | IXANY)))
+               return;
+       set_line_char(info);
+
+       if ((old_termios->c_cflag & CRTSCTS) &&
+                       !(tty->termios->c_cflag & CRTSCTS)) {
+               tty->hw_stopped = 0;
+               cy_start(tty);
+       }
 #if 0
-    /*
-     * No need to wake up processes in open wait, since they
-     * sample the CLOCAL flag once, and don't recheck it.
-     * XXX  It's not clear whether the current behavior is correct
-     * or not.  Hence, this may change.....
-     */
-    if (!(old_termios->c_cflag & CLOCAL) &&
-        (tty->termios->c_cflag & CLOCAL))
-            wake_up_interruptible(&info->open_wait);
+       /*
+        * No need to wake up processes in open wait, since they
+        * sample the CLOCAL flag once, and don't recheck it.
+        * XXX  It's not clear whether the current behavior is correct
+        * or not.  Hence, this may change.....
+        */
+       if (!(old_termios->c_cflag & CLOCAL) &&
+           (tty->termios->c_cflag & CLOCAL))
+               wake_up_interruptible(&info->open_wait);
 #endif
-
-    return;
-} /* cy_set_termios */
+}                              /* cy_set_termios */
 
 /* This function is used to send a high-priority XON/XOFF character to
    the device.
 */
-static void
-cy_send_xchar (struct tty_struct *tty, char ch)
+static void cy_send_xchar(struct tty_struct *tty, char ch)
 {
-       struct cyclades_port *info = (struct cyclades_port *) tty->driver_data;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
        int card, channel;
 
-       if (serial_paranoia_check (info, tty->name, "cy_send_xchar"))
+       if (serial_paranoia_check(info, tty->name, "cy_send_xchar"))
                return;
 
-       info->x_char = ch;
+       info->x_char = ch;
 
        if (ch)
-               cy_start (tty);
+               cy_start(tty);
 
        card = info->card;
        channel = info->line - cy_card[card].first_line;
 
-       if (IS_CYC_Z (cy_card[card])) {
-               if (ch == STOP_CHAR (tty))
-                       cyz_issue_cmd (&cy_card[card], channel, C_CM_SENDXOFF, 0L);
-               else if (ch == START_CHAR (tty))
-                       cyz_issue_cmd (&cy_card[card], channel, C_CM_SENDXON, 0L);
+       if (IS_CYC_Z(cy_card[card])) {
+               if (ch == STOP_CHAR(tty))
+                       cyz_issue_cmd(&cy_card[card], channel, C_CM_SENDXOFF,
+                                       0L);
+               else if (ch == START_CHAR(tty))
+                       cyz_issue_cmd(&cy_card[card], channel, C_CM_SENDXON,
+                                       0L);
        }
 }
 
@@ -4167,260 +4274,248 @@ cy_send_xchar (struct tty_struct *tty, char ch)
    that incoming characters should be throttled because the input
    buffers are close to full.
  */
-static void
-cy_throttle(struct tty_struct * tty)
+static void cy_throttle(struct tty_struct *tty)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  unsigned long flags;
-  void __iomem *base_addr;
-  int card,chip,channel,index;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       unsigned long flags;
+       void __iomem *base_addr;
+       int card, chip, channel, index;
 
 #ifdef CY_DEBUG_THROTTLE
-  char buf[64];
+       char buf[64];
 
-    printk("cyc:throttle %s: %d....ttyC%d\n", 
-          tty_name(tty, buf),
-           tty->ldisc.chars_in_buffer(tty), info->line);
+       printk("cyc:throttle %s: %d....ttyC%d\n", tty_name(tty, buf),
+                       tty->ldisc.chars_in_buffer(tty), info->line);
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_throttle")){
-            return;
-    }
-
-    card = info->card;
-
-    if (I_IXOFF(tty)) {
-        if (!IS_CYC_Z (cy_card[card]))
-            cy_send_xchar (tty, STOP_CHAR (tty));
-        else
-            info->throttle = 1;
-    }
-
-    if (tty->termios->c_cflag & CRTSCTS) {
-        channel = info->line - cy_card[card].first_line;
-        if (!IS_CYC_Z(cy_card[card])) {
-            chip = channel>>2;
-            channel &= 0x03;
-            index = cy_card[card].bus_index;
-            base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index);
-
-            CY_LOCK(info, flags);
-            cy_writeb(base_addr+(CyCAR<<index), (u_char)channel);
-            if (info->rtsdtr_inv) {
-                cy_writeb(base_addr+(CyMSVR2<<index), ~CyDTR);
-             } else {
-                cy_writeb(base_addr+(CyMSVR1<<index), ~CyRTS);
-            }
-           CY_UNLOCK(info, flags);
-       } else {
-           info->throttle = 1;
-        }
-    }
+       if (serial_paranoia_check(info, tty->name, "cy_throttle")) {
+               return;
+       }
+
+       card = info->card;
 
-    return;
-} /* cy_throttle */
+       if (I_IXOFF(tty)) {
+               if (!IS_CYC_Z(cy_card[card]))
+                       cy_send_xchar(tty, STOP_CHAR(tty));
+               else
+                       info->throttle = 1;
+       }
 
+       if (tty->termios->c_cflag & CRTSCTS) {
+               channel = info->line - cy_card[card].first_line;
+               if (!IS_CYC_Z(cy_card[card])) {
+                       chip = channel >> 2;
+                       channel &= 0x03;
+                       index = cy_card[card].bus_index;
+                       base_addr = cy_card[card].base_addr +
+                               (cy_chip_offset[chip] << index);
+
+                       CY_LOCK(info, flags);
+                       cy_writeb(base_addr + (CyCAR << index),
+                                 (u_char) channel);
+                       if (info->rtsdtr_inv) {
+                               cy_writeb(base_addr + (CyMSVR2 << index),
+                                         ~CyDTR);
+                       } else {
+                               cy_writeb(base_addr + (CyMSVR1 << index),
+                                         ~CyRTS);
+                       }
+                       CY_UNLOCK(info, flags);
+               } else {
+                       info->throttle = 1;
+               }
+       }
+}                              /* cy_throttle */
 
 /*
  * This routine notifies the tty driver that it should signal
  * that characters can now be sent to the tty without fear of
  * overrunning the input buffers of the line disciplines.
  */
-static void
-cy_unthrottle(struct tty_struct * tty)
+static void cy_unthrottle(struct tty_struct *tty)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  unsigned long flags;
-  void __iomem *base_addr;
-  int card,chip,channel,index;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       unsigned long flags;
+       void __iomem *base_addr;
+       int card, chip, channel, index;
 
 #ifdef CY_DEBUG_THROTTLE
-  char buf[64];
-        
-    printk("cyc:unthrottle %s: %d....ttyC%d\n", 
-          tty_name(tty, buf),
-           tty->ldisc.chars_in_buffer(tty), info->line);
-#endif
+       char buf[64];
 
-    if (serial_paranoia_check(info, tty->name, "cy_unthrottle")){
-            return;
-    }
+       printk("cyc:unthrottle %s: %d....ttyC%d\n", tty_name(tty, buf),
+               tty->ldisc.chars_in_buffer(tty), info->line);
+#endif
 
-    if (I_IXOFF(tty)) {
-       if (info->x_char)
-           info->x_char = 0;
-       else
-           cy_send_xchar (tty, START_CHAR (tty));
-    }
-
-    if (tty->termios->c_cflag & CRTSCTS) {
-        card = info->card;
-        channel = info->line - cy_card[card].first_line;
-        if (!IS_CYC_Z(cy_card[card])) {
-           chip = channel>>2;
-           channel &= 0x03;
-           index = cy_card[card].bus_index;
-           base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index);
-
-           CY_LOCK(info, flags);
-           cy_writeb(base_addr+(CyCAR<<index), (u_char)channel);
-           if (info->rtsdtr_inv) {
-                   cy_writeb(base_addr+(CyMSVR2<<index), CyDTR);
-           } else {
-                   cy_writeb(base_addr+(CyMSVR1<<index), CyRTS);
-           }
-           CY_UNLOCK(info, flags);
-        } else {
-           info->throttle = 0;
+       if (serial_paranoia_check(info, tty->name, "cy_unthrottle")) {
+               return;
        }
-    }
 
-    return;
-} /* cy_unthrottle */
+       if (I_IXOFF(tty)) {
+               if (info->x_char)
+                       info->x_char = 0;
+               else
+                       cy_send_xchar(tty, START_CHAR(tty));
+       }
 
+       if (tty->termios->c_cflag & CRTSCTS) {
+               card = info->card;
+               channel = info->line - cy_card[card].first_line;
+               if (!IS_CYC_Z(cy_card[card])) {
+                       chip = channel >> 2;
+                       channel &= 0x03;
+                       index = cy_card[card].bus_index;
+                       base_addr = cy_card[card].base_addr +
+                               (cy_chip_offset[chip] << index);
+
+                       CY_LOCK(info, flags);
+                       cy_writeb(base_addr + (CyCAR << index),
+                                 (u_char) channel);
+                       if (info->rtsdtr_inv) {
+                               cy_writeb(base_addr + (CyMSVR2 << index),
+                                         CyDTR);
+                       } else {
+                               cy_writeb(base_addr + (CyMSVR1 << index),
+                                         CyRTS);
+                       }
+                       CY_UNLOCK(info, flags);
+               } else {
+                       info->throttle = 0;
+               }
+       }
+}                              /* cy_unthrottle */
 
 /* cy_start and cy_stop provide software output flow control as a
    function of XON/XOFF, software CTS, and other such stuff.
 */
-static void
-cy_stop(struct tty_struct *tty)
+static void cy_stop(struct tty_struct *tty)
 {
-  struct cyclades_card *cinfo;
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  void __iomem *base_addr;
-  int chip,channel,index;
-  unsigned long flags;
+       struct cyclades_card *cinfo;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       void __iomem *base_addr;
+       int chip, channel, index;
+       unsigned long flags;
 
 #ifdef CY_DEBUG_OTHER
-    printk("cyc:cy_stop ttyC%d\n", info->line); /* */
+       printk("cyc:cy_stop ttyC%d\n", info->line);     /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_stop"))
-        return;
-        
-    cinfo = &cy_card[info->card];
-    channel = info->line - cinfo->first_line;
-    if (!IS_CYC_Z(*cinfo)) {
-        index = cinfo->bus_index;
-        chip = channel>>2;
-        channel &= 0x03;
-        base_addr = cy_card[info->card].base_addr + (cy_chip_offset[chip]<<index);
-
-       CY_LOCK(info, flags);
-            cy_writeb(base_addr+(CyCAR<<index),
-              (u_char)(channel & 0x0003)); /* index channel */
-            cy_writeb(base_addr+(CySRER<<index), 
-               cy_readb(base_addr+(CySRER<<index)) & ~CyTxRdy);
-       CY_UNLOCK(info, flags);
-    } else {
-       // Nothing to do!
-    }
+       if (serial_paranoia_check(info, tty->name, "cy_stop"))
+               return;
 
-    return;
-} /* cy_stop */
+       cinfo = &cy_card[info->card];
+       channel = info->line - cinfo->first_line;
+       if (!IS_CYC_Z(*cinfo)) {
+               index = cinfo->bus_index;
+               chip = channel >> 2;
+               channel &= 0x03;
+               base_addr = cy_card[info->card].base_addr +
+                       (cy_chip_offset[chip] << index);
 
+               CY_LOCK(info, flags);
+               cy_writeb(base_addr + (CyCAR << index),
+                       (u_char)(channel & 0x0003)); /* index channel */
+               cy_writeb(base_addr + (CySRER << index),
+                         cy_readb(base_addr + (CySRER << index)) & ~CyTxRdy);
+               CY_UNLOCK(info, flags);
+       } else {
+               /* Nothing to do! */
+       }
+}                              /* cy_stop */
 
-static void
-cy_start(struct tty_struct *tty)
+static void cy_start(struct tty_struct *tty)
 {
-  struct cyclades_card *cinfo;
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  void __iomem *base_addr;
-  int chip,channel,index;
-  unsigned long flags;
+       struct cyclades_card *cinfo;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       void __iomem *base_addr;
+       int chip, channel, index;
+       unsigned long flags;
 
 #ifdef CY_DEBUG_OTHER
-    printk("cyc:cy_start ttyC%d\n", info->line); /* */
+       printk("cyc:cy_start ttyC%d\n", info->line);    /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_start"))
-        return;
-        
-    cinfo = &cy_card[info->card];
-    channel = info->line - cinfo->first_line;
-    index = cinfo->bus_index;
-    if (!IS_CYC_Z(*cinfo)) {
-        chip = channel>>2;
-        channel &= 0x03;
-        base_addr = cy_card[info->card].base_addr + (cy_chip_offset[chip]<<index);
-
-       CY_LOCK(info, flags);
-            cy_writeb(base_addr+(CyCAR<<index),
-              (u_char)(channel & 0x0003)); /* index channel */
-            cy_writeb(base_addr+(CySRER<<index), 
-               cy_readb(base_addr+(CySRER<<index)) | CyTxRdy);
-       CY_UNLOCK(info, flags);
-    } else {
-       // Nothing to do!
-    }
+       if (serial_paranoia_check(info, tty->name, "cy_start"))
+               return;
 
-    return;
-} /* cy_start */
+       cinfo = &cy_card[info->card];
+       channel = info->line - cinfo->first_line;
+       index = cinfo->bus_index;
+       if (!IS_CYC_Z(*cinfo)) {
+               chip = channel >> 2;
+               channel &= 0x03;
+               base_addr = cy_card[info->card].base_addr +
+                       (cy_chip_offset[chip] << index);
 
+               CY_LOCK(info, flags);
+               cy_writeb(base_addr + (CyCAR << index), (u_char) (channel & 0x0003));   /* index channel */
+               cy_writeb(base_addr + (CySRER << index),
+                         cy_readb(base_addr + (CySRER << index)) | CyTxRdy);
+               CY_UNLOCK(info, flags);
+       } else {
+               /* Nothing to do! */
+       }
+}                              /* cy_start */
 
-static void
-cy_flush_buffer(struct tty_struct *tty)
+static void cy_flush_buffer(struct tty_struct *tty)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  int card, channel, retval;
-  unsigned long flags;
-                                
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       int card, channel, retval;
+       unsigned long flags;
+
 #ifdef CY_DEBUG_IO
-    printk("cyc:cy_flush_buffer ttyC%d\n", info->line); /* */
+       printk("cyc:cy_flush_buffer ttyC%d\n", info->line);     /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_flush_buffer"))
-        return;
-
-    card = info->card;
-    channel = (info->line) - (cy_card[card].first_line);
+       if (serial_paranoia_check(info, tty->name, "cy_flush_buffer"))
+               return;
 
-    CY_LOCK(info, flags);
-    info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
-    CY_UNLOCK(info, flags);
+       card = info->card;
+       channel = (info->line) - (cy_card[card].first_line);
 
-    if (IS_CYC_Z(cy_card[card])) { /* If it is a Z card, flush the on-board 
-                                     buffers as well */
        CY_LOCK(info, flags);
-       retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_FLUSH_TX, 0L);
-       if (retval != 0) {
-           printk("cyc: flush_buffer retval on ttyC%d was %x\n",
-                  info->line, retval);
-       }
+       info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
        CY_UNLOCK(info, flags);
-    }
-    tty_wakeup(tty);
-    wake_up_interruptible(&tty->write_wait);
-} /* cy_flush_buffer */
 
+       if (IS_CYC_Z(cy_card[card])) {  /* If it is a Z card, flush the on-board
+                                          buffers as well */
+               CY_LOCK(info, flags);
+               retval =
+                   cyz_issue_cmd(&cy_card[card], channel, C_CM_FLUSH_TX, 0L);
+               if (retval != 0) {
+                       printk("cyc: flush_buffer retval on ttyC%d was %x\n",
+                               info->line, retval);
+               }
+               CY_UNLOCK(info, flags);
+       }
+       tty_wakeup(tty);
+       wake_up_interruptible(&tty->write_wait);
+}                              /* cy_flush_buffer */
 
 /*
  * cy_hangup() --- called by tty_hangup() when a hangup is signaled.
  */
-static void
-cy_hangup(struct tty_struct *tty)
+static void cy_hangup(struct tty_struct *tty)
 {
-  struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
-        
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+
 #ifdef CY_DEBUG_OTHER
-    printk("cyc:cy_hangup ttyC%d\n", info->line); /* */
+       printk("cyc:cy_hangup ttyC%d\n", info->line);   /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_hangup"))
-        return;
+       if (serial_paranoia_check(info, tty->name, "cy_hangup"))
+               return;
 
-    cy_flush_buffer(tty);
-    shutdown(info);
-    info->event = 0;
-    info->count = 0;
+       cy_flush_buffer(tty);
+       shutdown(info);
+       info->event = 0;
+       info->count = 0;
 #ifdef CY_DEBUG_COUNT
-    printk("cyc:cy_hangup (%d): setting count to 0\n", current->pid);
+       printk("cyc:cy_hangup (%d): setting count to 0\n", current->pid);
 #endif
-    info->tty = NULL;
-    info->flags &= ~ASYNC_NORMAL_ACTIVE;
-    wake_up_interruptible(&info->open_wait);
-} /* cy_hangup */
-
+       info->tty = NULL;
+       info->flags &= ~ASYNC_NORMAL_ACTIVE;
+       wake_up_interruptible(&info->open_wait);
+}                              /* cy_hangup */
 
 /*
  * ---------------------------------------------------------------------
@@ -4433,82 +4528,84 @@ cy_hangup(struct tty_struct *tty)
 /* initialize chips on Cyclom-Y card -- return number of valid
    chips (which is number of ports/4) */
 static unsigned short __init
-cyy_init_card(void __iomem *true_base_addr,int index)
+cyy_init_card(void __iomem * true_base_addr, int index)
 {
-  unsigned int chip_number;
-  void __iomem *base_addr;
-
-    cy_writeb(true_base_addr+(Cy_HwReset<<index), 0); 
-                                               /* Cy_HwReset is 0x1400 */
-    cy_writeb(true_base_addr+(Cy_ClrIntr<<index), 0); 
-                                               /* Cy_ClrIntr is 0x1800 */
-    udelay(500L);
-
-    for(chip_number=0; chip_number<CyMAX_CHIPS_PER_CARD; chip_number++){
-        base_addr = true_base_addr + (cy_chip_offset[chip_number]<<index);
-        mdelay(1);
-        if(cy_readb(base_addr+(CyCCR<<index)) != 0x00){
-            /*************
-            printk(" chip #%d at %#6lx is never idle (CCR != 0)\n",
-               chip_number, (unsigned long)base_addr);
-            *************/
-            return chip_number;
-        }
-
-        cy_writeb(base_addr+(CyGFRCR<<index), 0);
-        udelay(10L);
-
-        /* The Cyclom-16Y does not decode address bit 9 and therefore
-           cannot distinguish between references to chip 0 and a non-
-           existent chip 4.  If the preceding clearing of the supposed
-           chip 4 GFRCR register appears at chip 0, there is no chip 4
-           and this must be a Cyclom-16Y, not a Cyclom-32Ye.
-        */
-        if (chip_number == 4
-        && cy_readb(true_base_addr
-           + (cy_chip_offset[0]<<index)
-           + (CyGFRCR<<index)) == 0){
-            return chip_number;
-        }
-
-        cy_writeb(base_addr+(CyCCR<<index), CyCHIP_RESET);
-        mdelay(1);
-
-        if(cy_readb(base_addr+(CyGFRCR<<index)) == 0x00){
-            /*
-            printk(" chip #%d at %#6lx is not responding ",
-               chip_number, (unsigned long)base_addr);
-            printk("(GFRCR stayed 0)\n",
-            */
-            return chip_number;
-        }
-        if((0xf0 & (cy_readb(base_addr+(CyGFRCR<<index)))) != 0x40){
-            /*
-            printk(" chip #%d at %#6lx is not valid (GFRCR == %#2x)\n",
-               chip_number, (unsigned long)base_addr,
-              base_addr[CyGFRCR<<index]);
-            */
-            return chip_number;
-        }
-        cy_writeb(base_addr+(CyGCR<<index), CyCH0_SERIAL);
-        if (cy_readb(base_addr+(CyGFRCR<<index)) >= CD1400_REV_J){
-           /* It is a CD1400 rev. J or later */
-           /* Impossible to reach 5ms with this chip. 
-              Changed to 2ms instead (f = 500 Hz). */
-           cy_writeb(base_addr+(CyPPR<<index), CyCLOCK_60_2MS);
-       } else {
-           /* f = 200 Hz */
-           cy_writeb(base_addr+(CyPPR<<index), CyCLOCK_25_5MS);
-       }
+       unsigned int chip_number;
+       void __iomem *base_addr;
+
+       cy_writeb(true_base_addr + (Cy_HwReset << index), 0);
+       /* Cy_HwReset is 0x1400 */
+       cy_writeb(true_base_addr + (Cy_ClrIntr << index), 0);
+       /* Cy_ClrIntr is 0x1800 */
+       udelay(500L);
+
+       for (chip_number = 0; chip_number < CyMAX_CHIPS_PER_CARD; chip_number++) {
+               base_addr =
+                   true_base_addr + (cy_chip_offset[chip_number] << index);
+               mdelay(1);
+               if (cy_readb(base_addr + (CyCCR << index)) != 0x00) {
+                       /*************
+                       printk(" chip #%d at %#6lx is never idle (CCR != 0)\n",
+                       chip_number, (unsigned long)base_addr);
+                       *************/
+                       return chip_number;
+               }
+
+               cy_writeb(base_addr + (CyGFRCR << index), 0);
+               udelay(10L);
+
+               /* The Cyclom-16Y does not decode address bit 9 and therefore
+                  cannot distinguish between references to chip 0 and a non-
+                  existent chip 4.  If the preceding clearing of the supposed
+                  chip 4 GFRCR register appears at chip 0, there is no chip 4
+                  and this must be a Cyclom-16Y, not a Cyclom-32Ye.
+                */
+               if (chip_number == 4 && cy_readb(true_base_addr +
+                               (cy_chip_offset[0] << index) +
+                               (CyGFRCR << index)) == 0) {
+                       return chip_number;
+               }
+
+               cy_writeb(base_addr + (CyCCR << index), CyCHIP_RESET);
+               mdelay(1);
+
+               if (cy_readb(base_addr + (CyGFRCR << index)) == 0x00) {
+                       /*
+                          printk(" chip #%d at %#6lx is not responding ",
+                          chip_number, (unsigned long)base_addr);
+                          printk("(GFRCR stayed 0)\n",
+                        */
+                       return chip_number;
+               }
+               if ((0xf0 & (cy_readb(base_addr + (CyGFRCR << index)))) !=
+                               0x40) {
+                       /*
+                       printk(" chip #%d at %#6lx is not valid (GFRCR == "
+                                       "%#2x)\n",
+                                       chip_number, (unsigned long)base_addr,
+                                       base_addr[CyGFRCR<<index]);
+                        */
+                       return chip_number;
+               }
+               cy_writeb(base_addr + (CyGCR << index), CyCH0_SERIAL);
+               if (cy_readb(base_addr + (CyGFRCR << index)) >= CD1400_REV_J) {
+                       /* It is a CD1400 rev. J or later */
+                       /* Impossible to reach 5ms with this chip.
+                          Changed to 2ms instead (f = 500 Hz). */
+                       cy_writeb(base_addr + (CyPPR << index), CyCLOCK_60_2MS);
+               } else {
+                       /* f = 200 Hz */
+                       cy_writeb(base_addr + (CyPPR << index), CyCLOCK_25_5MS);
+               }
 
-    /*
-        printk(" chip #%d at %#6lx is rev 0x%2x\n",
-               chip_number, (unsigned long)base_addr,
-              cy_readb(base_addr+(CyGFRCR<<index)));
-    */
-    }
-    return chip_number;
-} /* cyy_init_card */
+               /*
+                  printk(" chip #%d at %#6lx is rev 0x%2x\n",
+                  chip_number, (unsigned long)base_addr,
+                  cy_readb(base_addr+(CyGFRCR<<index)));
+                */
+       }
+       return chip_number;
+}                              /* cyy_init_card */
 
 /*
  * ---------------------------------------------------------------------
@@ -4516,126 +4613,124 @@ cyy_init_card(void __iomem *true_base_addr,int index)
  * sets global variables and return the number of ISA boards found.
  * ---------------------------------------------------------------------
  */
-static int __init
-cy_detect_isa(void)
+static int __init cy_detect_isa(void)
 {
 #ifdef CONFIG_ISA
-  unsigned short       cy_isa_irq,nboard;
-  void __iomem         *cy_isa_address;
-  unsigned short       i,j,cy_isa_nchan;
+       unsigned short cy_isa_irq, nboard;
+       void __iomem *cy_isa_address;
+       unsigned short i, j, cy_isa_nchan;
 #ifdef MODULE
-  int isparam = 0;
+       int isparam = 0;
 #endif
 
-        nboard = 0;
+       nboard = 0;
 
 #ifdef MODULE
        /* Check for module parameters */
-       for(i = 0 ; i < NR_CARDS; i++) {
-           if (maddr[i] || i) {
-               isparam = 1;
-               cy_isa_addresses[i] = maddr[i];
-           }
-           if (!maddr[i])
-               break;
+       for (i = 0; i < NR_CARDS; i++) {
+               if (maddr[i] || i) {
+                       isparam = 1;
+                       cy_isa_addresses[i] = maddr[i];
+               }
+               if (!maddr[i])
+                       break;
        }
 #endif
 
-        /* scan the address table probing for Cyclom-Y/ISA boards */
-        for (i = 0 ; i < NR_ISA_ADDRS ; i++) {
-               unsigned int isa_address = cy_isa_addresses[i];
-                if (isa_address  == 0x0000) {
-                        return(nboard);
-                }
+       /* scan the address table probing for Cyclom-Y/ISA boards */
+       for (i = 0; i < NR_ISA_ADDRS; i++) {
+               unsigned int isa_address = cy_isa_addresses[i];
+               if (isa_address == 0x0000) {
+                       return nboard;
+               }
 
-                /* probe for CD1400... */
+               /* probe for CD1400... */
                cy_isa_address = ioremap(isa_address, CyISA_Ywin);
-                cy_isa_nchan = CyPORTS_PER_CHIP * 
-                     cyy_init_card(cy_isa_address,0);
-                if (cy_isa_nchan == 0) {
-                        continue;
-                }
-
+               cy_isa_nchan = CyPORTS_PER_CHIP *
+                       cyy_init_card(cy_isa_address, 0);
+               if (cy_isa_nchan == 0) {
+                       continue;
+               }
 #ifdef MODULE
                if (isparam && irq[i])
-                   cy_isa_irq = irq[i];
+                       cy_isa_irq = irq[i];
                else
 #endif
-                /* find out the board's irq by probing */
-                cy_isa_irq = detect_isa_irq(cy_isa_address);
-                if (cy_isa_irq == 0) {
-                        printk("Cyclom-Y/ISA found at 0x%lx ",
-                                (unsigned long) cy_isa_address);
-                        printk("but the IRQ could not be detected.\n");
-                        continue;
-                }
-
-                if((cy_next_channel+cy_isa_nchan) > NR_PORTS) {
-                        printk("Cyclom-Y/ISA found at 0x%lx ",
-                                (unsigned long) cy_isa_address);
-                        printk("but no more channels are available.\n");
-                        printk("Change NR_PORTS in cyclades.c and recompile kernel.\n");
-                        return(nboard);
-                }
-                /* fill the next cy_card structure available */
-                for (j = 0 ; j < NR_CARDS ; j++) {
-                        if (cy_card[j].base_addr == 0)  break;
-                }
-                if (j == NR_CARDS) {    /* no more cy_cards available */
-                        printk("Cyclom-Y/ISA found at 0x%lx ",
-                                (unsigned long) cy_isa_address);
-                        printk("but no more cards can be used .\n");
-                        printk("Change NR_CARDS in cyclades.c and recompile kernel.\n");
-                        return(nboard);
-                }
-
-                /* allocate IRQ */
-                if(request_irq(cy_isa_irq, cyy_interrupt,
-                                  IRQF_DISABLED, "Cyclom-Y", &cy_card[j]))
-                {
-                        printk("Cyclom-Y/ISA found at 0x%lx ",
-                                (unsigned long) cy_isa_address);
-                        printk("but could not allocate IRQ#%d.\n",
-                                cy_isa_irq);
-                        return(nboard);
-                }
-
-                /* set cy_card */
-                cy_card[j].base_addr = cy_isa_address;
-                cy_card[j].ctl_addr = NULL;
-                cy_card[j].irq = (int) cy_isa_irq;
-                cy_card[j].bus_index = 0;
-                cy_card[j].first_line = cy_next_channel;
-                cy_card[j].num_chips = cy_isa_nchan/4;
-                nboard++;
-                        
-                /* print message */
-                printk("Cyclom-Y/ISA #%d: 0x%lx-0x%lx, IRQ%d, ",
-                    j+1, (unsigned long) cy_isa_address,
-                    (unsigned long)(cy_isa_address + (CyISA_Ywin - 1)),
-                   cy_isa_irq);
-                printk("%d channels starting from port %d.\n",
-                        cy_isa_nchan, cy_next_channel);
-                cy_next_channel += cy_isa_nchan;
-        }
-        return(nboard);
+                       /* find out the board's irq by probing */
+                       cy_isa_irq = detect_isa_irq(cy_isa_address);
+               if (cy_isa_irq == 0) {
+                       printk("Cyclom-Y/ISA found at 0x%lx ",
+                               (unsigned long)cy_isa_address);
+                       printk("but the IRQ could not be detected.\n");
+                       continue;
+               }
+
+               if ((cy_next_channel + cy_isa_nchan) > NR_PORTS) {
+                       printk("Cyclom-Y/ISA found at 0x%lx ",
+                               (unsigned long)cy_isa_address);
+                       printk("but no more channels are available.\n");
+                       printk("Change NR_PORTS in cyclades.c and recompile "
+                                       "kernel.\n");
+                       return nboard;
+               }
+               /* fill the next cy_card structure available */
+               for (j = 0; j < NR_CARDS; j++) {
+                       if (cy_card[j].base_addr == 0)
+                               break;
+               }
+               if (j == NR_CARDS) {    /* no more cy_cards available */
+                       printk("Cyclom-Y/ISA found at 0x%lx ",
+                               (unsigned long)cy_isa_address);
+                       printk("but no more cards can be used .\n");
+                       printk("Change NR_CARDS in cyclades.c and recompile "
+                                       "kernel.\n");
+                       return nboard;
+               }
+
+               /* allocate IRQ */
+               if (request_irq(cy_isa_irq, cyy_interrupt,
+                               IRQF_DISABLED, "Cyclom-Y", &cy_card[j])) {
+                       printk("Cyclom-Y/ISA found at 0x%lx ",
+                               (unsigned long)cy_isa_address);
+                       printk("but could not allocate IRQ#%d.\n", cy_isa_irq);
+                       return nboard;
+               }
+
+               /* set cy_card */
+               cy_card[j].base_addr = cy_isa_address;
+               cy_card[j].ctl_addr = NULL;
+               cy_card[j].irq = (int)cy_isa_irq;
+               cy_card[j].bus_index = 0;
+               cy_card[j].first_line = cy_next_channel;
+               cy_card[j].num_chips = cy_isa_nchan / 4;
+               nboard++;
+
+               /* print message */
+               printk("Cyclom-Y/ISA #%d: 0x%lx-0x%lx, IRQ%d, ",
+                       j + 1, (unsigned long)cy_isa_address,
+                       (unsigned long)(cy_isa_address + (CyISA_Ywin - 1)),
+                       cy_isa_irq);
+               printk("%d channels starting from port %d.\n",
+                       cy_isa_nchan, cy_next_channel);
+               cy_next_channel += cy_isa_nchan;
+       }
+       return nboard;
 #else
-        return(0);
-#endif /* CONFIG_ISA */
-} /* cy_detect_isa */
+       return 0;
+#endif                         /* CONFIG_ISA */
+}                              /* cy_detect_isa */
 
-static void 
-plx_init(void __iomem *addr, uclong initctl)
+static void plx_init(void __iomem * addr, uclong initctl)
 {
-    /* Reset PLX */
-    cy_writel(addr + initctl, cy_readl(addr + initctl) | 0x40000000);
-    udelay(100L);
-    cy_writel(addr + initctl, cy_readl(addr + initctl) & ~0x40000000);
-
-    /* Reload Config. Registers from EEPROM */
-    cy_writel(addr + initctl, cy_readl(addr + initctl) | 0x20000000);
-    udelay(100L);
-    cy_writel(addr + initctl, cy_readl(addr + initctl) & ~0x20000000);
+       /* Reset PLX */
+       cy_writel(addr + initctl, cy_readl(addr + initctl) | 0x40000000);
+       udelay(100L);
+       cy_writel(addr + initctl, cy_readl(addr + initctl) & ~0x40000000);
+
+       /* Reload Config. Registers from EEPROM */
+       cy_writel(addr + initctl, cy_readl(addr + initctl) | 0x20000000);
+       udelay(100L);
+       cy_writel(addr + initctl, cy_readl(addr + initctl) & ~0x20000000);
 }
 
 /*
@@ -4644,43 +4739,42 @@ plx_init(void __iomem *addr, uclong initctl)
  * sets global variables and return the number of PCI boards found.
  * ---------------------------------------------------------------------
  */
-static int __init
-cy_detect_pci(void)
+static int __init cy_detect_pci(void)
 {
 #ifdef CONFIG_PCI
 
-  struct pci_dev       *pdev = NULL;
-  unsigned char                cyy_rev_id;
-  unsigned char                cy_pci_irq = 0;
-  uclong               cy_pci_phys0, cy_pci_phys2;
-  void __iomem         *cy_pci_addr0, *cy_pci_addr2;
-  unsigned short       i,j,cy_pci_nchan, plx_ver;
-  unsigned short       device_id,dev_index = 0;
-  uclong               mailbox;
-  uclong               ZeIndex = 0;
-  void __iomem         *Ze_addr0[NR_CARDS], *Ze_addr2[NR_CARDS];
-  uclong               Ze_phys0[NR_CARDS], Ze_phys2[NR_CARDS];
-  unsigned char                Ze_irq[NR_CARDS];
-  struct pci_dev       *Ze_pdev[NR_CARDS];
-
-        for (i = 0; i < NR_CARDS; i++) {
-                /* look for a Cyclades card by vendor and device id */
-                while((device_id = cy_pci_dev_id[dev_index]) != 0) {
-                        if((pdev = pci_get_device(PCI_VENDOR_ID_CYCLADES,
-                                        device_id, pdev)) == NULL) {
-                                dev_index++;    /* try next device id */
-                        } else {
-                                break;          /* found a board */
-                        }
-                }
+       struct pci_dev *pdev = NULL;
+       unsigned char cyy_rev_id;
+       unsigned char cy_pci_irq = 0;
+       uclong cy_pci_phys0, cy_pci_phys2;
+       void __iomem *cy_pci_addr0, *cy_pci_addr2;
+       unsigned short i, j, cy_pci_nchan, plx_ver;
+       unsigned short device_id, dev_index = 0;
+       uclong mailbox;
+       uclong ZeIndex = 0;
+       void __iomem *Ze_addr0[NR_CARDS], *Ze_addr2[NR_CARDS];
+       uclong Ze_phys0[NR_CARDS], Ze_phys2[NR_CARDS];
+       unsigned char Ze_irq[NR_CARDS];
+       struct pci_dev *Ze_pdev[NR_CARDS];
+
+       for (i = 0; i < NR_CARDS; i++) {
+               /* look for a Cyclades card by vendor and device id */
+               while ((device_id = cy_pci_dev_id[dev_index]) != 0) {
+                       if ((pdev = pci_get_device(PCI_VENDOR_ID_CYCLADES,
+                                                  device_id, pdev)) == NULL) {
+                               dev_index++;    /* try next device id */
+                       } else {
+                               break;  /* found a board */
+                       }
+               }
 
                if (device_id == 0)
-                   break;
+                       break;
 
                if (pci_enable_device(pdev))
-                   continue;
+                       continue;
 
-                /* read PCI configuration area */
+               /* read PCI configuration area */
                cy_pci_irq = pdev->irq;
                cy_pci_phys0 = pci_resource_start(pdev, 0);
                cy_pci_phys2 = pci_resource_start(pdev, 2);
@@ -4688,482 +4782,497 @@ cy_detect_pci(void)
 
                device_id &= ~PCI_DEVICE_ID_MASK;
 
-    if ((device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo)
-          || (device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi)){
+               if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo ||
+                               device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi) {
 #ifdef CY_PCI_DEBUG
-            printk("Cyclom-Y/PCI (bus=0x0%x, pci_id=0x%x, ",
-               pdev->bus->number, pdev->devfn);
-            printk("rev_id=%d) IRQ%d\n",
-               cyy_rev_id, (int)cy_pci_irq);
-            printk("Cyclom-Y/PCI:found  winaddr=0x%lx ctladdr=0x%lx\n",
-               (ulong)cy_pci_phys2, (ulong)cy_pci_phys0);
+                       printk("Cyclom-Y/PCI (bus=0x0%x, pci_id=0x%x, ",
+                               pdev->bus->number, pdev->devfn);
+                       printk("rev_id=%d) IRQ%d\n",
+                               cyy_rev_id, (int)cy_pci_irq);
+                       printk("Cyclom-Y/PCI:found  winaddr=0x%lx "
+                               "ctladdr=0x%lx\n",
+                               (ulong)cy_pci_phys2, (ulong)cy_pci_phys0);
 #endif
 
-               if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) {
-                   printk("  Warning: PCI I/O bit incorrectly set. "
-                          "Ignoring it...\n");
-                   pdev->resource[2].flags &= ~IORESOURCE_IO;
-               }
-
-               /* Although we don't use this I/O region, we should
-                  request it from the kernel anyway, to avoid problems
-                  with other drivers accessing it. */
-               if (pci_request_regions(pdev, "Cyclom-Y") != 0) {
-                       printk(KERN_ERR "cyclades: failed to reserve PCI resources\n");
-                       continue;
-               }
+                       if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) {
+                               printk("  Warning: PCI I/O bit incorrectly "
+                                       "set. Ignoring it...\n");
+                               pdev->resource[2].flags &= ~IORESOURCE_IO;
+                       }
 
+                       /* Although we don't use this I/O region, we should
+                          request it from the kernel anyway, to avoid problems
+                          with other drivers accessing it. */
+                       if (pci_request_regions(pdev, "Cyclom-Y") != 0) {
+                               printk(KERN_ERR "cyclades: failed to reserve "
+                                               "PCI resources\n");
+                               continue;
+                       }
 #if defined(__alpha__)
-                if (device_id  == PCI_DEVICE_ID_CYCLOM_Y_Lo) { /* below 1M? */
-                   printk("Cyclom-Y/PCI (bus=0x0%x, pci_id=0x%x, ",
-                       pdev->bus->number, pdev->devfn);
-                   printk("rev_id=%d) IRQ%d\n",
-                       cyy_rev_id, (int)cy_pci_irq);
-                    printk("Cyclom-Y/PCI:found  winaddr=0x%lx ctladdr=0x%lx\n",
-                       (ulong)cy_pci_phys2, (ulong)cy_pci_phys0);
-                   printk("Cyclom-Y/PCI not supported for low addresses in "
-                           "Alpha systems.\n");
-                   i--;
-                   continue;
-                }
+                       if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo) {   /* below 1M? */
+                               printk("Cyclom-Y/PCI (bus=0x0%x, pci_id=0x%x, ",
+                                       pdev->bus->number, pdev->devfn);
+                               printk("rev_id=%d) IRQ%d\n",
+                                       cyy_rev_id, (int)cy_pci_irq);
+                               printk("Cyclom-Y/PCI:found  winaddr=0x%lx "
+                                       "ctladdr=0x%lx\n",
+                                       (ulong)cy_pci_phys2,
+                                       (ulong)cy_pci_phys0);
+                               printk("Cyclom-Y/PCI not supported for low "
+                                       "addresses in Alpha systems.\n");
+                               i--;
+                               continue;
+                       }
 #endif
-               cy_pci_addr0 = ioremap(cy_pci_phys0, CyPCI_Yctl);
-               cy_pci_addr2 = ioremap(cy_pci_phys2, CyPCI_Ywin);
+                       cy_pci_addr0 = ioremap(cy_pci_phys0, CyPCI_Yctl);
+                       cy_pci_addr2 = ioremap(cy_pci_phys2, CyPCI_Ywin);
 
 #ifdef CY_PCI_DEBUG
-            printk("Cyclom-Y/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n",
-               (u_long)cy_pci_addr2, (u_long)cy_pci_addr0);
+                       printk("Cyclom-Y/PCI: relocate winaddr=0x%lx "
+                               "ctladdr=0x%lx\n",
+                               (u_long)cy_pci_addr2, (u_long)cy_pci_addr0);
 #endif
-                cy_pci_nchan = (unsigned short)(CyPORTS_PER_CHIP * 
-                       cyy_init_card(cy_pci_addr2, 1));
-                if(cy_pci_nchan == 0) {
-                        printk("Cyclom-Y PCI host card with ");
-                        printk("no Serial-Modules at 0x%lx.\n",
-                           (ulong) cy_pci_phys2);
-                        i--;
-                        continue;
-                }
-                if((cy_next_channel+cy_pci_nchan) > NR_PORTS) {
-                        printk("Cyclom-Y/PCI found at 0x%lx ",
-                           (ulong) cy_pci_phys2);
-                        printk("but no channels are available.\n");
-                        printk("Change NR_PORTS in cyclades.c and recompile kernel.\n");
-                        return(i);
-                }
-                /* fill the next cy_card structure available */
-                for (j = 0 ; j < NR_CARDS ; j++) {
-                        if (cy_card[j].base_addr == 0)  break;
-                }
-                if (j == NR_CARDS) {    /* no more cy_cards available */
-                        printk("Cyclom-Y/PCI found at 0x%lx ",
-                           (ulong) cy_pci_phys2);
-                        printk("but no more cards can be used.\n");
-                        printk("Change NR_CARDS in cyclades.c and recompile kernel.\n");
-                        return(i);
-                }
-
-                /* allocate IRQ */
-                if(request_irq(cy_pci_irq, cyy_interrupt,
-                       IRQF_SHARED, "Cyclom-Y", &cy_card[j]))
-                {
-                        printk("Cyclom-Y/PCI found at 0x%lx ",
-                           (ulong) cy_pci_phys2);
-                        printk("but could not allocate IRQ%d.\n",
-                           cy_pci_irq);
-                        return(i);
-                }
-
-                /* set cy_card */
-                cy_card[j].base_phys = (ulong)cy_pci_phys2;
-                cy_card[j].ctl_phys = (ulong)cy_pci_phys0;
-                cy_card[j].base_addr = cy_pci_addr2;
-                cy_card[j].ctl_addr = cy_pci_addr0;
-                cy_card[j].irq = (int) cy_pci_irq;
-                cy_card[j].bus_index = 1;
-                cy_card[j].first_line = cy_next_channel;
-                cy_card[j].num_chips = cy_pci_nchan/4;
-               cy_card[j].pdev = pdev;
-       
-                /* enable interrupts in the PCI interface */
-               plx_ver = cy_readb(cy_pci_addr2 + CyPLX_VER) & 0x0f;
-               switch (plx_ver) {
-                   case PLX_9050:
-
-                   cy_writeb(cy_pci_addr0+0x4c, 0x43);
-                   break;
-
-                   case PLX_9060:
-                   case PLX_9080:
-                   default: /* Old boards, use PLX_9060 */
-
-                   plx_init(cy_pci_addr0, 0x6c);
-                   /* For some yet unknown reason, once the PLX9060 reloads
-                      the EEPROM, the IRQ is lost and, thus, we have to
-                      re-write it to the PCI config. registers.
-                      This will remain here until we find a permanent fix. */
-                   pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, cy_pci_irq);
-
-                   cy_writew(cy_pci_addr0+0x68, 
-                       cy_readw(cy_pci_addr0+0x68)|0x0900);
-                   break;
-               }
+                       cy_pci_nchan = (unsigned short)(CyPORTS_PER_CHIP *
+                                       cyy_init_card(cy_pci_addr2, 1));
+                       if (cy_pci_nchan == 0) {
+                               printk("Cyclom-Y PCI host card with ");
+                               printk("no Serial-Modules at 0x%lx.\n",
+                                       (ulong) cy_pci_phys2);
+                               i--;
+                               continue;
+                       }
+                       if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) {
+                               printk("Cyclom-Y/PCI found at 0x%lx ",
+                                       (ulong) cy_pci_phys2);
+                               printk("but no channels are available.\n");
+                               printk("Change NR_PORTS in cyclades.c and "
+                                               "recompile kernel.\n");
+                               return i;
+                       }
+                       /* fill the next cy_card structure available */
+                       for (j = 0; j < NR_CARDS; j++) {
+                               if (cy_card[j].base_addr == 0)
+                                       break;
+                       }
+                       if (j == NR_CARDS) {    /* no more cy_cards available */
+                               printk("Cyclom-Y/PCI found at 0x%lx ",
+                                       (ulong) cy_pci_phys2);
+                               printk("but no more cards can be used.\n");
+                               printk("Change NR_CARDS in cyclades.c and "
+                                               "recompile kernel.\n");
+                               return i;
+                       }
 
-                /* print message */
-                printk("Cyclom-Y/PCI #%d: 0x%lx-0x%lx, IRQ%d, ",
-                      j+1, 
-                      (ulong)cy_pci_phys2, 
-                      (ulong)(cy_pci_phys2 + CyPCI_Ywin - 1),
-                      (int)cy_pci_irq);
-                printk("%d channels starting from port %d.\n",
-                   cy_pci_nchan, cy_next_channel);
-
-                cy_next_channel += cy_pci_nchan;
-    }else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Lo){
-           /* print message */
-               printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ",
-                   pdev->bus->number, pdev->devfn);
-               printk("rev_id=%d) IRQ%d\n",
-                   cyy_rev_id, (int)cy_pci_irq);
-               printk("Cyclades-Z/PCI: found winaddr=0x%lx ctladdr=0x%lx\n",
-                   (ulong)cy_pci_phys2, (ulong)cy_pci_phys0);
-           printk("Cyclades-Z/PCI not supported for low addresses\n");
-           break;
-    }else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Hi){
+                       /* allocate IRQ */
+                       if (request_irq(cy_pci_irq, cyy_interrupt,
+                                       IRQF_SHARED, "Cyclom-Y", &cy_card[j])) {
+                               printk("Cyclom-Y/PCI found at 0x%lx ",
+                                       (ulong) cy_pci_phys2);
+                               printk("but could not allocate IRQ%d.\n",
+                                       cy_pci_irq);
+                               return i;
+                       }
+
+                       /* set cy_card */
+                       cy_card[j].base_phys = (ulong) cy_pci_phys2;
+                       cy_card[j].ctl_phys = (ulong) cy_pci_phys0;
+                       cy_card[j].base_addr = cy_pci_addr2;
+                       cy_card[j].ctl_addr = cy_pci_addr0;
+                       cy_card[j].irq = (int)cy_pci_irq;
+                       cy_card[j].bus_index = 1;
+                       cy_card[j].first_line = cy_next_channel;
+                       cy_card[j].num_chips = cy_pci_nchan / 4;
+                       cy_card[j].pdev = pdev;
+
+                       /* enable interrupts in the PCI interface */
+                       plx_ver = cy_readb(cy_pci_addr2 + CyPLX_VER) & 0x0f;
+                       switch (plx_ver) {
+                       case PLX_9050:
+
+                               cy_writeb(cy_pci_addr0 + 0x4c, 0x43);
+                               break;
+
+                       case PLX_9060:
+                       case PLX_9080:
+                       default:        /* Old boards, use PLX_9060 */
+
+                               plx_init(cy_pci_addr0, 0x6c);
+                       /* For some yet unknown reason, once the PLX9060 reloads
+                          the EEPROM, the IRQ is lost and, thus, we have to
+                          re-write it to the PCI config. registers.
+                          This will remain here until we find a permanent
+                          fix. */
+                               pci_write_config_byte(pdev, PCI_INTERRUPT_LINE,
+                                               cy_pci_irq);
+
+                               cy_writew(cy_pci_addr0 + 0x68,
+                                         cy_readw(cy_pci_addr0 +
+                                                  0x68) | 0x0900);
+                               break;
+                       }
+
+                       /* print message */
+                       printk("Cyclom-Y/PCI #%d: 0x%lx-0x%lx, IRQ%d, ",
+                               j + 1, (ulong)cy_pci_phys2,
+                               (ulong) (cy_pci_phys2 + CyPCI_Ywin - 1),
+                               (int)cy_pci_irq);
+                       printk("%d channels starting from port %d.\n",
+                               cy_pci_nchan, cy_next_channel);
+
+                       cy_next_channel += cy_pci_nchan;
+               } else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Lo) {
+                       /* print message */
+                       printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ",
+                               pdev->bus->number, pdev->devfn);
+                       printk("rev_id=%d) IRQ%d\n",
+                               cyy_rev_id, (int)cy_pci_irq);
+                       printk("Cyclades-Z/PCI: found winaddr=0x%lx "
+                               "ctladdr=0x%lx\n",
+                               (ulong)cy_pci_phys2, (ulong)cy_pci_phys0);
+                       printk("Cyclades-Z/PCI not supported for low "
+                               "addresses\n");
+                       break;
+               } else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Hi) {
 #ifdef CY_PCI_DEBUG
-            printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ",
-               pdev->bus->number, pdev->devfn);
-            printk("rev_id=%d) IRQ%d\n",
-               cyy_rev_id, (int)cy_pci_irq);
-            printk("Cyclades-Z/PCI: found winaddr=0x%lx ctladdr=0x%lx\n",
-                (ulong)cy_pci_phys2, (ulong)cy_pci_phys0);
+                       printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ",
+                               pdev->bus->number, pdev->devfn);
+                       printk("rev_id=%d) IRQ%d\n",
+                               cyy_rev_id, (int)cy_pci_irq);
+                       printk("Cyclades-Z/PCI: found winaddr=0x%lx "
+                               "ctladdr=0x%lx\n",
+                               (ulong) cy_pci_phys2, (ulong) cy_pci_phys0);
 #endif
-               cy_pci_addr0 = ioremap(cy_pci_phys0, CyPCI_Zctl);
-
-               /* Disable interrupts on the PLX before resetting it */
-               cy_writew(cy_pci_addr0+0x68,
-                       cy_readw(cy_pci_addr0+0x68) & ~0x0900);
-
-               plx_init(cy_pci_addr0, 0x6c);
-               /* For some yet unknown reason, once the PLX9060 reloads
-                  the EEPROM, the IRQ is lost and, thus, we have to
-                  re-write it to the PCI config. registers.
-                  This will remain here until we find a permanent fix. */
-               pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, cy_pci_irq);
-
-               mailbox = (uclong)cy_readl(&((struct RUNTIME_9060 __iomem *) 
-                          cy_pci_addr0)->mail_box_0);
-
-               if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) {
-                   printk("  Warning: PCI I/O bit incorrectly set. "
-                          "Ignoring it...\n");
-                   pdev->resource[2].flags &= ~IORESOURCE_IO;
-               }
+                       cy_pci_addr0 = ioremap(cy_pci_phys0, CyPCI_Zctl);
+
+                       /* Disable interrupts on the PLX before resetting it */
+                       cy_writew(cy_pci_addr0 + 0x68,
+                               cy_readw(cy_pci_addr0 + 0x68) & ~0x0900);
+
+                       plx_init(cy_pci_addr0, 0x6c);
+                       /* For some yet unknown reason, once the PLX9060 reloads
+                          the EEPROM, the IRQ is lost and, thus, we have to
+                          re-write it to the PCI config. registers.
+                          This will remain here until we find a permanent
+                          fix. */
+                       pci_write_config_byte(pdev, PCI_INTERRUPT_LINE,
+                                               cy_pci_irq);
+
+                       mailbox =
+                           (uclong)cy_readl(&((struct RUNTIME_9060 __iomem *)
+                                               cy_pci_addr0)->mail_box_0);
+
+                       if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) {
+                               printk("  Warning: PCI I/O bit incorrectly "
+                                       "set. Ignoring it...\n");
+                               pdev->resource[2].flags &= ~IORESOURCE_IO;
+                       }
 
-               /* Although we don't use this I/O region, we should
-                  request it from the kernel anyway, to avoid problems
-                  with other drivers accessing it. */
-               if (pci_request_regions(pdev, "Cyclades-Z") != 0) {
-                       printk(KERN_ERR "cyclades: failed to reserve PCI resources\n");
-                       continue;
-               }
-       
-               if (mailbox == ZE_V1) {
-                   cy_pci_addr2 = ioremap(cy_pci_phys2, CyPCI_Ze_win);
-                   if (ZeIndex == NR_CARDS) {
-                       printk("Cyclades-Ze/PCI found at 0x%lx ",
-                               (ulong)cy_pci_phys2);
-                       printk("but no more cards can be used.\n");
-                        printk("Change NR_CARDS in cyclades.c and recompile kernel.\n");
-                   } else {
-                       Ze_phys0[ZeIndex] = cy_pci_phys0;
-                       Ze_phys2[ZeIndex] = cy_pci_phys2;
-                       Ze_addr0[ZeIndex] = cy_pci_addr0;
-                       Ze_addr2[ZeIndex] = cy_pci_addr2;
-                       Ze_irq[ZeIndex] = cy_pci_irq;
-                       Ze_pdev[ZeIndex] = pdev;
-                       ZeIndex++;
-                   }
-                   i--;
-                   continue;
-               } else {
-                   cy_pci_addr2 = ioremap(cy_pci_phys2, CyPCI_Zwin);
-               }
+                       /* Although we don't use this I/O region, we should
+                          request it from the kernel anyway, to avoid problems
+                          with other drivers accessing it. */
+                       if (pci_request_regions(pdev, "Cyclades-Z") != 0) {
+                               printk(KERN_ERR "cyclades: failed to reserve "
+                                       "PCI resources\n");
+                               continue;
+                       }
+
+                       if (mailbox == ZE_V1) {
+                               cy_pci_addr2 = ioremap(cy_pci_phys2,
+                                               CyPCI_Ze_win);
+                               if (ZeIndex == NR_CARDS) {
+                                       printk("Cyclades-Ze/PCI found at "
+                                               "0x%lx but no more cards can "
+                                               "be used.\nChange NR_CARDS in "
+                                               "cyclades.c and recompile "
+                                               "kernel.\n",
+                                               (ulong)cy_pci_phys2);
+                               } else {
+                                       Ze_phys0[ZeIndex] = cy_pci_phys0;
+                                       Ze_phys2[ZeIndex] = cy_pci_phys2;
+                                       Ze_addr0[ZeIndex] = cy_pci_addr0;
+                                       Ze_addr2[ZeIndex] = cy_pci_addr2;
+                                       Ze_irq[ZeIndex] = cy_pci_irq;
+                                       Ze_pdev[ZeIndex] = pdev;
+                                       ZeIndex++;
+                               }
+                               i--;
+                               continue;
+                       } else {
+                               cy_pci_addr2 = ioremap(cy_pci_phys2,CyPCI_Zwin);
+                       }
 
 #ifdef CY_PCI_DEBUG
-            printk("Cyclades-Z/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n",
-                (ulong)cy_pci_addr2, (ulong)cy_pci_addr0);
-           if (mailbox == ZO_V1) {
-               cy_writel(&((struct RUNTIME_9060 *)
-                         (cy_pci_addr0))->loc_addr_base, WIN_CREG);
-               PAUSE
-               printk("Cyclades-8Zo/PCI: FPGA id %lx, ver %lx\n",
-                      (ulong)(0xff & cy_readl(&((struct CUSTOM_REG *)
-                       (cy_pci_addr2))->fpga_id)),
-                      (ulong)(0xff & cy_readl(&((struct CUSTOM_REG *)
-                       (cy_pci_addr2))->fpga_version)));
-               cy_writel(&((struct RUNTIME_9060 *)
-                         (cy_pci_addr0))->loc_addr_base, WIN_RAM);
-           } else {
-               printk("Cyclades-Z/PCI: New Cyclades-Z board.  FPGA not loaded\n");
-           }
+                       printk("Cyclades-Z/PCI: relocate winaddr=0x%lx "
+                               "ctladdr=0x%lx\n",
+                               (ulong) cy_pci_addr2, (ulong) cy_pci_addr0);
+                       if (mailbox == ZO_V1) {
+                               cy_writel(&((struct RUNTIME_9060 *)
+                                       (cy_pci_addr0))->loc_addr_base,
+                                       WIN_CREG);
+                               PAUSE;
+                               printk("Cyclades-8Zo/PCI: FPGA id %lx, ver "
+                                       "%lx\n", (ulong) (0xff &
+                                       cy_readl(&((struct CUSTOM_REG *)
+                                               (cy_pci_addr2))->fpga_id)),
+                                       (ulong)(0xff &
+                                       cy_readl(&((struct CUSTOM_REG *)
+                                               (cy_pci_addr2))->
+                                                       fpga_version)));
+                               cy_writel(&((struct RUNTIME_9060 *)
+                                       (cy_pci_addr0))->loc_addr_base,
+                                       WIN_RAM);
+                       } else {
+                               printk("Cyclades-Z/PCI: New Cyclades-Z board.  "
+                                               "FPGA not loaded\n");
+                       }
 #endif
-           /* The following clears the firmware id word.  This ensures
-              that the driver will not attempt to talk to the board
-              until it has been properly initialized.
-            */
-               PAUSE
-               if ((mailbox == ZO_V1) || (mailbox == ZO_V2))
-                   cy_writel(cy_pci_addr2 + ID_ADDRESS, 0L);
-
-                /* This must be a Cyclades-8Zo/PCI.  The extendable
-                   version will have a different device_id and will
-                   be allocated its maximum number of ports. */
-                cy_pci_nchan = 8;
-
-                if((cy_next_channel+cy_pci_nchan) > NR_PORTS) {
-                        printk("Cyclades-8Zo/PCI found at 0x%lx ",
-                           (ulong)cy_pci_phys2);
-                        printk("but no channels are available.\n");
-                        printk("Change NR_PORTS in cyclades.c and recompile kernel.\n");
-                        return(i);
-                }
-
-                /* fill the next cy_card structure available */
-                for (j = 0 ; j < NR_CARDS ; j++) {
-                        if (cy_card[j].base_addr == 0)  break;
-                }
-                if (j == NR_CARDS) {    /* no more cy_cards available */
-                   printk("Cyclades-8Zo/PCI found at 0x%lx ",
-                       (ulong)cy_pci_phys2);
-                   printk("but no more cards can be used.\n");
-                    printk("Change NR_CARDS in cyclades.c and recompile kernel.\n");
-                   return(i);
-                }
+                       /* The following clears the firmware id word.  This
+                          ensures that the driver will not attempt to talk to
+                          the board until it has been properly initialized.
+                        */
+                       PAUSE;
+                       if ((mailbox == ZO_V1) || (mailbox == ZO_V2))
+                               cy_writel(cy_pci_addr2 + ID_ADDRESS, 0L);
+
+                       /* This must be a Cyclades-8Zo/PCI.  The extendable
+                          version will have a different device_id and will
+                          be allocated its maximum number of ports. */
+                       cy_pci_nchan = 8;
+
+                       if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) {
+                               printk("Cyclades-8Zo/PCI found at 0x%lx but"
+                                       "no channels are available.\nChange "
+                                       "NR_PORTS in cyclades.c and recompile "
+                                       "kernel.\n", (ulong)cy_pci_phys2);
+                               return i;
+                       }
 
+                       /* fill the next cy_card structure available */
+                       for (j = 0; j < NR_CARDS; j++) {
+                               if (cy_card[j].base_addr == 0)
+                                       break;
+                       }
+                       if (j == NR_CARDS) {    /* no more cy_cards available */
+                               printk("Cyclades-8Zo/PCI found at 0x%lx but"
+                                       "no more cards can be used.\nChange "
+                                       "NR_CARDS in cyclades.c and recompile "
+                                       "kernel.\n", (ulong)cy_pci_phys2);
+                               return i;
+                       }
+#ifdef CONFIG_CYZ_INTR
+                       /* allocate IRQ only if board has an IRQ */
+                       if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) {
+                               if (request_irq(cy_pci_irq, cyz_interrupt,
+                                               IRQF_SHARED, "Cyclades-Z",
+                                               &cy_card[j])) {
+                                       printk("Cyclom-8Zo/PCI found at 0x%lx "
+                                               "but could not allocate "
+                                               "IRQ%d.\n", (ulong)cy_pci_phys2,
+                                               cy_pci_irq);
+                                       return i;
+                               }
+                       }
+#endif                         /* CONFIG_CYZ_INTR */
+
+                       /* set cy_card */
+                       cy_card[j].base_phys = cy_pci_phys2;
+                       cy_card[j].ctl_phys = cy_pci_phys0;
+                       cy_card[j].base_addr = cy_pci_addr2;
+                       cy_card[j].ctl_addr = cy_pci_addr0;
+                       cy_card[j].irq = (int)cy_pci_irq;
+                       cy_card[j].bus_index = 1;
+                       cy_card[j].first_line = cy_next_channel;
+                       cy_card[j].num_chips = -1;
+                       cy_card[j].pdev = pdev;
+
+                       /* print message */
 #ifdef CONFIG_CYZ_INTR
-                /* allocate IRQ only if board has an IRQ */
-               if( (cy_pci_irq != 0) && (cy_pci_irq != 255) ) {
-                   if(request_irq(cy_pci_irq, cyz_interrupt,
-                       IRQF_SHARED, "Cyclades-Z", &cy_card[j]))
-                   {
-                        printk("Cyclom-8Zo/PCI found at 0x%lx ",
-                           (ulong) cy_pci_phys2);
-                        printk("but could not allocate IRQ%d.\n",
-                           cy_pci_irq);
-                       return(i);
-                   }
+                       /* don't report IRQ if board is no IRQ */
+                       if ((cy_pci_irq != 0) && (cy_pci_irq != 255))
+                               printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, "
+                                       "IRQ%d, ", j + 1, (ulong)cy_pci_phys2,
+                                       (ulong) (cy_pci_phys2 + CyPCI_Zwin - 1),
+                                       (int)cy_pci_irq);
+                       else
+#endif                         /* CONFIG_CYZ_INTR */
+                               printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, ",
+                                       j + 1, (ulong)cy_pci_phys2,
+                                       (ulong)(cy_pci_phys2 + CyPCI_Zwin - 1));
+
+                       printk("%d channels starting from port %d.\n",
+                                       cy_pci_nchan, cy_next_channel);
+                       cy_next_channel += cy_pci_nchan;
                }
-#endif /* CONFIG_CYZ_INTR */
-
-
-                /* set cy_card */
-                cy_card[j].base_phys = cy_pci_phys2;
-                cy_card[j].ctl_phys = cy_pci_phys0;
-                cy_card[j].base_addr = cy_pci_addr2;
-                cy_card[j].ctl_addr = cy_pci_addr0;
-                cy_card[j].irq = (int) cy_pci_irq;
-                cy_card[j].bus_index = 1;
-                cy_card[j].first_line = cy_next_channel;
-                cy_card[j].num_chips = -1;
-               cy_card[j].pdev = pdev;
+       }
 
-                /* print message */
-#ifdef CONFIG_CYZ_INTR
-               /* don't report IRQ if board is no IRQ */
-               if( (cy_pci_irq != 0) && (cy_pci_irq != 255) )
-                   printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, IRQ%d, ",
-                       j+1,(ulong)cy_pci_phys2,
-                       (ulong)(cy_pci_phys2 + CyPCI_Zwin - 1),
-                       (int)cy_pci_irq);
-               else
-#endif /* CONFIG_CYZ_INTR */
-                   printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, ",
-                       j+1,(ulong)cy_pci_phys2,
-                       (ulong)(cy_pci_phys2 + CyPCI_Zwin - 1));
-
-                printk("%d channels starting from port %d.\n",
-                   cy_pci_nchan,cy_next_channel);
-                cy_next_channel += cy_pci_nchan;
-           }
-        }
-
-        for (; ZeIndex != 0 && i < NR_CARDS; i++) {
-           cy_pci_phys0 = Ze_phys0[0];
-           cy_pci_phys2 = Ze_phys2[0];
-           cy_pci_addr0 = Ze_addr0[0];
-           cy_pci_addr2 = Ze_addr2[0];
-           cy_pci_irq = Ze_irq[0];
-           pdev = Ze_pdev[0];
-           for (j = 0 ; j < ZeIndex-1 ; j++) {
-               Ze_phys0[j] = Ze_phys0[j+1];
-               Ze_phys2[j] = Ze_phys2[j+1];
-               Ze_addr0[j] = Ze_addr0[j+1];
-               Ze_addr2[j] = Ze_addr2[j+1];
-               Ze_irq[j] = Ze_irq[j+1];
-               Ze_pdev[j] = Ze_pdev[j+1];
-           }
-           ZeIndex--;
-               mailbox = (uclong)cy_readl(&((struct RUNTIME_9060 __iomem *) 
-                                          cy_pci_addr0)->mail_box_0);
+       for (; ZeIndex != 0 && i < NR_CARDS; i++) {
+               cy_pci_phys0 = Ze_phys0[0];
+               cy_pci_phys2 = Ze_phys2[0];
+               cy_pci_addr0 = Ze_addr0[0];
+               cy_pci_addr2 = Ze_addr2[0];
+               cy_pci_irq = Ze_irq[0];
+               pdev = Ze_pdev[0];
+               for (j = 0; j < ZeIndex - 1; j++) {
+                       Ze_phys0[j] = Ze_phys0[j + 1];
+                       Ze_phys2[j] = Ze_phys2[j + 1];
+                       Ze_addr0[j] = Ze_addr0[j + 1];
+                       Ze_addr2[j] = Ze_addr2[j + 1];
+                       Ze_irq[j] = Ze_irq[j + 1];
+                       Ze_pdev[j] = Ze_pdev[j + 1];
+               }
+               ZeIndex--;
+               mailbox = (uclong)cy_readl(&((struct RUNTIME_9060 __iomem *)
+                                               cy_pci_addr0)->mail_box_0);
 #ifdef CY_PCI_DEBUG
-            printk("Cyclades-Z/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n",
-                (ulong)cy_pci_addr2, (ulong)cy_pci_addr0);
-           printk("Cyclades-Z/PCI: New Cyclades-Z board.  FPGA not loaded\n");
+               printk("Cyclades-Z/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n",
+                       (ulong)cy_pci_addr2, (ulong)cy_pci_addr0);
+               printk("Cyclades-Z/PCI: New Cyclades-Z board.  FPGA not "
+                               "loaded\n");
 #endif
-               PAUSE
-                /* This must be the new Cyclades-Ze/PCI. */
-                cy_pci_nchan = ZE_V1_NPORTS;
-
-                if((cy_next_channel+cy_pci_nchan) > NR_PORTS) {
-                        printk("Cyclades-Ze/PCI found at 0x%lx ",
-                           (ulong)cy_pci_phys2);
-                        printk("but no channels are available.\n");
-                        printk("Change NR_PORTS in cyclades.c and recompile kernel.\n");
-                        return(i);
-                }
-
-                /* fill the next cy_card structure available */
-                for (j = 0 ; j < NR_CARDS ; j++) {
-                        if (cy_card[j].base_addr == 0)  break;
-                }
-                if (j == NR_CARDS) {    /* no more cy_cards available */
-                   printk("Cyclades-Ze/PCI found at 0x%lx ",
-                       (ulong)cy_pci_phys2);
-                   printk("but no more cards can be used.\n");
-                    printk("Change NR_CARDS in cyclades.c and recompile kernel.\n");
-                   return(i);
-                }
+               PAUSE;
+               /* This must be the new Cyclades-Ze/PCI. */
+               cy_pci_nchan = ZE_V1_NPORTS;
+
+               if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) {
+                       printk("Cyclades-Ze/PCI found at 0x%lx but no channels "
+                               "are available.\nChange NR_PORTS in cyclades.c "
+                               "and recompile kernel.\n",
+                               (ulong) cy_pci_phys2);
+                       return i;
+               }
 
+               /* fill the next cy_card structure available */
+               for (j = 0; j < NR_CARDS; j++) {
+                       if (cy_card[j].base_addr == 0)
+                               break;
+               }
+               if (j == NR_CARDS) {    /* no more cy_cards available */
+                       printk("Cyclades-Ze/PCI found at 0x%lx but no more "
+                               "cards can be used.\nChange NR_CARDS in "
+                               "cyclades.c and recompile kernel.\n",
+                               (ulong) cy_pci_phys2);
+                       return i;
+               }
 #ifdef CONFIG_CYZ_INTR
-                /* allocate IRQ only if board has an IRQ */
-               if( (cy_pci_irq != 0) && (cy_pci_irq != 255) ) {
-                   if(request_irq(cy_pci_irq, cyz_interrupt,
-                       IRQF_SHARED, "Cyclades-Z", &cy_card[j]))
-                   {
-                        printk("Cyclom-Ze/PCI found at 0x%lx ",
-                           (ulong) cy_pci_phys2);
-                        printk("but could not allocate IRQ%d.\n",
-                           cy_pci_irq);
-                       return(i);
-                   }
+               /* allocate IRQ only if board has an IRQ */
+               if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) {
+                       if (request_irq(cy_pci_irq, cyz_interrupt,
+                                       IRQF_SHARED, "Cyclades-Z",
+                                       &cy_card[j])) {
+                               printk("Cyclom-Ze/PCI found at 0x%lx ",
+                                       (ulong) cy_pci_phys2);
+                               printk("but could not allocate IRQ%d.\n",
+                                       cy_pci_irq);
+                               return i;
+                       }
                }
-#endif /* CONFIG_CYZ_INTR */
-
-                /* set cy_card */
-                cy_card[j].base_phys = cy_pci_phys2;
-                cy_card[j].ctl_phys = cy_pci_phys0;
-                cy_card[j].base_addr = cy_pci_addr2;
-                cy_card[j].ctl_addr = cy_pci_addr0;
-                cy_card[j].irq = (int) cy_pci_irq;
-                cy_card[j].bus_index = 1;
-                cy_card[j].first_line = cy_next_channel;
-                cy_card[j].num_chips = -1;
+#endif                         /* CONFIG_CYZ_INTR */
+
+               /* set cy_card */
+               cy_card[j].base_phys = cy_pci_phys2;
+               cy_card[j].ctl_phys = cy_pci_phys0;
+               cy_card[j].base_addr = cy_pci_addr2;
+               cy_card[j].ctl_addr = cy_pci_addr0;
+               cy_card[j].irq = (int)cy_pci_irq;
+               cy_card[j].bus_index = 1;
+               cy_card[j].first_line = cy_next_channel;
+               cy_card[j].num_chips = -1;
                cy_card[j].pdev = pdev;
 
-                /* print message */
+               /* print message */
 #ifdef CONFIG_CYZ_INTR
                /* don't report IRQ if board is no IRQ */
-               if( (cy_pci_irq != 0) && (cy_pci_irq != 255) )
-                   printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, IRQ%d, ",
-                       j+1,(ulong)cy_pci_phys2,
-                       (ulong)(cy_pci_phys2 + CyPCI_Ze_win - 1),
-                       (int)cy_pci_irq);
+               if ((cy_pci_irq != 0) && (cy_pci_irq != 255))
+                       printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, IRQ%d, ",
+                               j + 1, (ulong) cy_pci_phys2,
+                               (ulong) (cy_pci_phys2 + CyPCI_Ze_win - 1),
+                               (int)cy_pci_irq);
                else
-#endif /* CONFIG_CYZ_INTR */
-                   printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, ",
-                       j+1,(ulong)cy_pci_phys2,
-                       (ulong)(cy_pci_phys2 + CyPCI_Ze_win - 1));
-
-                printk("%d channels starting from port %d.\n",
-                   cy_pci_nchan,cy_next_channel);
-                cy_next_channel += cy_pci_nchan;
-        }
+#endif                         /* CONFIG_CYZ_INTR */
+                       printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, ",
+                               j + 1, (ulong) cy_pci_phys2,
+                               (ulong) (cy_pci_phys2 + CyPCI_Ze_win - 1));
+
+               printk("%d channels starting from port %d.\n",
+                       cy_pci_nchan, cy_next_channel);
+               cy_next_channel += cy_pci_nchan;
+       }
        if (ZeIndex != 0) {
-           printk("Cyclades-Ze/PCI found at 0x%x ",
-               (unsigned int) Ze_phys2[0]);
-           printk("but no more cards can be used.\n");
-            printk("Change NR_CARDS in cyclades.c and recompile kernel.\n");
+               printk("Cyclades-Ze/PCI found at 0x%x but no more cards can be "
+                       "used.\nChange NR_CARDS in cyclades.c and recompile "
+                       "kernel.\n", (unsigned int)Ze_phys2[0]);
        }
-        return(i);
+       return i;
 #else
-        return(0);
-#endif /* ifdef CONFIG_PCI */
-} /* cy_detect_pci */
-
+       return 0;
+#endif                         /* ifdef CONFIG_PCI */
+}                              /* cy_detect_pci */
 
 /*
  * This routine prints out the appropriate serial driver version number
  * and identifies which options were configured into this driver.
  */
-static inline void
-show_version(void)
+static inline void show_version(void)
 {
-  char *rcsvers, *rcsdate, *tmp;
-    rcsvers = strchr(rcsid, ' '); rcsvers++;
-    tmp = strchr(rcsvers, ' '); *tmp++ = '\0';
-    rcsdate = strchr(tmp, ' '); rcsdate++;
-    tmp = strrchr(rcsdate, ' '); *tmp = '\0';
-    printk("Cyclades driver %s %s\n",
-        rcsvers, rcsdate);
-    printk("        built %s %s\n",
-       __DATE__, __TIME__);
-} /* show_version */
-
-static int 
+       printk("Cyclades driver " CY_VERSION "\n");
+       printk("        built %s %s\n", __DATE__, __TIME__);
+}                              /* show_version */
+
+static int
 cyclades_get_proc_info(char *buf, char **start, off_t offset, int length,
-                      int *eof, void *data)
+               int *eof, void *data)
 {
-    struct cyclades_port  *info;
-    int i;
-    int len=0;
-    off_t begin=0;
-    off_t pos=0;
-    int size;
-    __u32 cur_jifs = jiffies;
-
-    size = sprintf(buf, "Dev TimeOpen   BytesOut  IdleOut    BytesIn   IdleIn  Overruns  Ldisc\n");
-
-    pos += size;
-    len += size;
-
-    /* Output one line for each known port */
-    for (i = 0; i < NR_PORTS && cy_port[i].line >= 0; i++) {
-       info = &cy_port[i];
-
-       if (info->count)
-           size = sprintf(buf+len,
-                       "%3d %8lu %10lu %8lu %10lu %8lu %9lu %6ld\n",
-                       info->line,
-                       JIFFIES_DIFF(info->idle_stats.in_use, cur_jifs) / HZ,
-                       info->idle_stats.xmit_bytes,
-                       JIFFIES_DIFF(info->idle_stats.xmit_idle, cur_jifs) / HZ,
-                       info->idle_stats.recv_bytes,
-                       JIFFIES_DIFF(info->idle_stats.recv_idle, cur_jifs) / HZ,
-                       info->idle_stats.overruns,
-                       (long) info->tty->ldisc.num);
-       else
-           size = sprintf(buf+len,
-                       "%3d %8lu %10lu %8lu %10lu %8lu %9lu %6ld\n",
-                       info->line, 0L, 0L, 0L, 0L, 0L, 0L, 0L);
+       struct cyclades_port *info;
+       int i;
+       int len = 0;
+       off_t begin = 0;
+       off_t pos = 0;
+       int size;
+       __u32 cur_jifs = jiffies;
+
+       size = sprintf(buf, "Dev TimeOpen   BytesOut  IdleOut    BytesIn   "
+                       "IdleIn  Overruns  Ldisc\n");
+
+       pos += size;
        len += size;
-       pos = begin + len;
 
-       if (pos < offset) {
-           len   = 0;
-           begin = pos;
+       /* Output one line for each known port */
+       for (i = 0; i < NR_PORTS && cy_port[i].line >= 0; i++) {
+               info = &cy_port[i];
+
+               if (info->count)
+                       size = sprintf(buf + len, "%3d %8lu %10lu %8lu %10lu "
+                               "%8lu %9lu %6ld\n", info->line,
+                               (cur_jifs - info->idle_stats.in_use) / HZ,
+                               info->idle_stats.xmit_bytes,
+                               (cur_jifs - info->idle_stats.xmit_idle) / HZ,
+                               info->idle_stats.recv_bytes,
+                               (cur_jifs - info->idle_stats.recv_idle) / HZ,
+                               info->idle_stats.overruns,
+                               (long)info->tty->ldisc.num);
+               else
+                       size = sprintf(buf + len, "%3d %8lu %10lu %8lu %10lu "
+                               "%8lu %9lu %6ld\n",
+                               info->line, 0L, 0L, 0L, 0L, 0L, 0L, 0L);
+               len += size;
+               pos = begin + len;
+
+               if (pos < offset) {
+                       len = 0;
+                       begin = pos;
+               }
+               if (pos > offset + length)
+                       goto done;
        }
-       if (pos > offset + length)
-           goto done;
-    }
-    *eof = 1;
+       *eof = 1;
 done:
-    *start = buf + (offset - begin);   /* Start of wanted data */
-    len -= (offset - begin);           /* Start slop */
-    if (len > length)
-       len = length;                   /* Ending slop */
-    if (len < 0)
-       len = 0;
-    return len;
+       *start = buf + (offset - begin);        /* Start of wanted data */
+       len -= (offset - begin);        /* Start slop */
+       if (len > length)
+               len = length;   /* Ending slop */
+       if (len < 0)
+               len = 0;
+       return len;
 }
 
 /* The serial driver boot-time initialization code!
@@ -5185,290 +5294,288 @@ done:
  */
 
 static const struct tty_operations cy_ops = {
-    .open = cy_open,
-    .close = cy_close,
-    .write = cy_write,
-    .put_char = cy_put_char,
-    .flush_chars = cy_flush_chars,
-    .write_room = cy_write_room,
-    .chars_in_buffer = cy_chars_in_buffer,
-    .flush_buffer = cy_flush_buffer,
-    .ioctl = cy_ioctl,
-    .throttle = cy_throttle,
-    .unthrottle = cy_unthrottle,
-    .set_termios = cy_set_termios,
-    .stop = cy_stop,
-    .start = cy_start,
-    .hangup = cy_hangup,
-    .break_ctl = cy_break,
-    .wait_until_sent = cy_wait_until_sent,
-    .read_proc = cyclades_get_proc_info,
-    .tiocmget = cy_tiocmget,
-    .tiocmset = cy_tiocmset,
+       .open = cy_open,
+       .close = cy_close,
+       .write = cy_write,
+       .put_char = cy_put_char,
+       .flush_chars = cy_flush_chars,
+       .write_room = cy_write_room,
+       .chars_in_buffer = cy_chars_in_buffer,
+       .flush_buffer = cy_flush_buffer,
+       .ioctl = cy_ioctl,
+       .throttle = cy_throttle,
+       .unthrottle = cy_unthrottle,
+       .set_termios = cy_set_termios,
+       .stop = cy_stop,
+       .start = cy_start,
+       .hangup = cy_hangup,
+       .break_ctl = cy_break,
+       .wait_until_sent = cy_wait_until_sent,
+       .read_proc = cyclades_get_proc_info,
+       .tiocmget = cy_tiocmget,
+       .tiocmset = cy_tiocmset,
 };
 
-static int __init
-cy_init(void)
+static int __init cy_init(void)
 {
-  struct cyclades_port  *info;
-  struct cyclades_card *cinfo;
-  int number_z_boards = 0;
-  int board,port,i,index;
-  unsigned long mailbox;
-  unsigned short chip_number;
-  int nports;
-
-    cy_serial_driver = alloc_tty_driver(NR_PORTS);
-    if (!cy_serial_driver)
-       return -ENOMEM;
-    show_version();
-
-    /* Initialize the tty_driver structure */
-    
-    cy_serial_driver->owner = THIS_MODULE;
-    cy_serial_driver->driver_name = "cyclades";
-    cy_serial_driver->name = "ttyC";
-    cy_serial_driver->major = CYCLADES_MAJOR;
-    cy_serial_driver->minor_start = 0;
-    cy_serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
-    cy_serial_driver->subtype = SERIAL_TYPE_NORMAL;
-    cy_serial_driver->init_termios = tty_std_termios;
-    cy_serial_driver->init_termios.c_cflag =
-            B9600 | CS8 | CREAD | HUPCL | CLOCAL;
-    cy_serial_driver->flags = TTY_DRIVER_REAL_RAW;
-    tty_set_operations(cy_serial_driver, &cy_ops);
-
-    if (tty_register_driver(cy_serial_driver))
-            panic("Couldn't register Cyclades serial driver\n");
-
-    for (i = 0; i < NR_CARDS; i++) {
-            /* base_addr=0 indicates board not found */
-            cy_card[i].base_addr = NULL;
-    }
-
-    /* the code below is responsible to find the boards. Each different
-       type of board has its own detection routine. If a board is found,
-       the next cy_card structure available is set by the detection
-       routine. These functions are responsible for checking the
-       availability of cy_card and cy_port data structures and updating
-       the cy_next_channel. */
-
-    /* look for isa boards */
-    cy_isa_nboard = cy_detect_isa();
-
-    /* look for pci boards */
-    cy_pci_nboard = cy_detect_pci();
-
-    cy_nboard = cy_isa_nboard + cy_pci_nboard;
-
-    /* invalidate remaining cy_card structures */
-    for (i = 0 ; i < NR_CARDS ; i++) {
-        if (cy_card[i].base_addr == 0) {
-                cy_card[i].first_line = -1;
-                cy_card[i].ctl_addr = NULL;
-                cy_card[i].irq = 0;
-                cy_card[i].bus_index = 0;
-                cy_card[i].first_line = 0;
-                cy_card[i].num_chips = 0;
-        }
-    }
-    /* invalidate remaining cy_port structures */
-    for (i = cy_next_channel ; i < NR_PORTS ; i++) {
-        cy_port[i].line = -1;
-        cy_port[i].magic = -1;
-    }
-
-    /* initialize per-port data structures for each valid board found */
-    for (board = 0 ; board < cy_nboard ; board++) {
-            cinfo = &cy_card[board];
-            if (cinfo->num_chips == -1) { /* Cyclades-Z */
-               number_z_boards++;
-               mailbox = cy_readl(&((struct RUNTIME_9060 __iomem *)
-                            cy_card[board].ctl_addr)->mail_box_0);
-               nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8;
-               cinfo->intr_enabled = 0;
-               cinfo->nports = 0; /* Will be correctly set later, after 
-                                     Z FW is loaded */
-               spin_lock_init(&cinfo->card_lock);
-                for (port = cinfo->first_line ;
-                     port < cinfo->first_line + nports;
-                     port++)
-                {
-                    info = &cy_port[port];
-                    info->magic = CYCLADES_MAGIC;
-                    info->type = PORT_STARTECH;
-                    info->card = board;
-                    info->line = port;
-                   info->chip_rev = 0;
-                    info->flags = STD_COM_FLAGS;
-                    info->tty = NULL;
-                   if (mailbox == ZO_V1)
-                       info->xmit_fifo_size = CYZ_FIFO_SIZE;
-                   else
-                       info->xmit_fifo_size = 4 * CYZ_FIFO_SIZE;
-                    info->cor1 = 0;
-                    info->cor2 = 0;
-                    info->cor3 = 0;
-                    info->cor4 = 0;
-                    info->cor5 = 0;
-                    info->tbpr = 0;
-                    info->tco = 0;
-                    info->rbpr = 0;
-                    info->rco = 0;
-                   info->custom_divisor = 0;
-                    info->close_delay = 5*HZ/10;
-                   info->closing_wait = CLOSING_WAIT_DELAY;
-                   info->icount.cts = info->icount.dsr = 
-                       info->icount.rng = info->icount.dcd = 0;
-                   info->icount.rx = info->icount.tx = 0;
-                   info->icount.frame = info->icount.parity = 0;
-                   info->icount.overrun = info->icount.brk = 0;
-                    info->x_char = 0;
-                    info->event = 0;
-                    info->count = 0;
-                    info->blocked_open = 0;
-                    info->default_threshold = 0;
-                    info->default_timeout = 0;
-                   INIT_WORK(&info->tqueue, do_softint);
-                   init_waitqueue_head(&info->open_wait);
-                   init_waitqueue_head(&info->close_wait);
-                   init_waitqueue_head(&info->shutdown_wait);
-                   init_waitqueue_head(&info->delta_msr_wait);
-                    /* info->session */
-                    /* info->pgrp */
-                    info->read_status_mask = 0;
-                    /* info->timeout */
-                   /* Bentson's vars */
-                    info->jiffies[0] = 0;
-                    info->jiffies[1] = 0;
-                    info->jiffies[2] = 0;
-                    info->rflush_count = 0;
+       struct cyclades_port *info;
+       struct cyclades_card *cinfo;
+       int number_z_boards = 0;
+       int board, port, i, index;
+       unsigned long mailbox;
+       unsigned short chip_number;
+       int nports;
+
+       cy_serial_driver = alloc_tty_driver(NR_PORTS);
+       if (!cy_serial_driver)
+               return -ENOMEM;
+       show_version();
+
+       /* Initialize the tty_driver structure */
+
+       cy_serial_driver->owner = THIS_MODULE;
+       cy_serial_driver->driver_name = "cyclades";
+       cy_serial_driver->name = "ttyC";
+       cy_serial_driver->major = CYCLADES_MAJOR;
+       cy_serial_driver->minor_start = 0;
+       cy_serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
+       cy_serial_driver->subtype = SERIAL_TYPE_NORMAL;
+       cy_serial_driver->init_termios = tty_std_termios;
+       cy_serial_driver->init_termios.c_cflag =
+           B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+       cy_serial_driver->flags = TTY_DRIVER_REAL_RAW;
+       tty_set_operations(cy_serial_driver, &cy_ops);
+
+       if (tty_register_driver(cy_serial_driver))
+               panic("Couldn't register Cyclades serial driver\n");
+
+       for (i = 0; i < NR_CARDS; i++) {
+               /* base_addr=0 indicates board not found */
+               cy_card[i].base_addr = NULL;
+       }
+
+       /* the code below is responsible to find the boards. Each different
+          type of board has its own detection routine. If a board is found,
+          the next cy_card structure available is set by the detection
+          routine. These functions are responsible for checking the
+          availability of cy_card and cy_port data structures and updating
+          the cy_next_channel. */
+
+       /* look for isa boards */
+       cy_isa_nboard = cy_detect_isa();
+
+       /* look for pci boards */
+       cy_pci_nboard = cy_detect_pci();
+
+       cy_nboard = cy_isa_nboard + cy_pci_nboard;
+
+       /* invalidate remaining cy_card structures */
+       for (i = 0; i < NR_CARDS; i++) {
+               if (cy_card[i].base_addr == 0) {
+                       cy_card[i].first_line = -1;
+                       cy_card[i].ctl_addr = NULL;
+                       cy_card[i].irq = 0;
+                       cy_card[i].bus_index = 0;
+                       cy_card[i].first_line = 0;
+                       cy_card[i].num_chips = 0;
+               }
+       }
+       /* invalidate remaining cy_port structures */
+       for (i = cy_next_channel; i < NR_PORTS; i++) {
+               cy_port[i].line = -1;
+               cy_port[i].magic = -1;
+       }
+
+       /* initialize per-port data structures for each valid board found */
+       for (board = 0; board < cy_nboard; board++) {
+               cinfo = &cy_card[board];
+               if (cinfo->num_chips == -1) {   /* Cyclades-Z */
+                       number_z_boards++;
+                       mailbox = cy_readl(&((struct RUNTIME_9060 __iomem *)
+                                            cy_card[board].ctl_addr)->
+                                          mail_box_0);
+                       nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8;
+                       cinfo->intr_enabled = 0;
+                       cinfo->nports = 0;      /* Will be correctly set later, after 
+                                                  Z FW is loaded */
+                       spin_lock_init(&cinfo->card_lock);
+                       for (port = cinfo->first_line;
+                            port < cinfo->first_line + nports; port++) {
+                               info = &cy_port[port];
+                               info->magic = CYCLADES_MAGIC;
+                               info->type = PORT_STARTECH;
+                               info->card = board;
+                               info->line = port;
+                               info->chip_rev = 0;
+                               info->flags = STD_COM_FLAGS;
+                               info->tty = NULL;
+                               if (mailbox == ZO_V1)
+                                       info->xmit_fifo_size = CYZ_FIFO_SIZE;
+                               else
+                                       info->xmit_fifo_size =
+                                           4 * CYZ_FIFO_SIZE;
+                               info->cor1 = 0;
+                               info->cor2 = 0;
+                               info->cor3 = 0;
+                               info->cor4 = 0;
+                               info->cor5 = 0;
+                               info->tbpr = 0;
+                               info->tco = 0;
+                               info->rbpr = 0;
+                               info->rco = 0;
+                               info->custom_divisor = 0;
+                               info->close_delay = 5 * HZ / 10;
+                               info->closing_wait = CLOSING_WAIT_DELAY;
+                               info->icount.cts = info->icount.dsr =
+                                   info->icount.rng = info->icount.dcd = 0;
+                               info->icount.rx = info->icount.tx = 0;
+                               info->icount.frame = info->icount.parity = 0;
+                               info->icount.overrun = info->icount.brk = 0;
+                               info->x_char = 0;
+                               info->event = 0;
+                               info->count = 0;
+                               info->blocked_open = 0;
+                               info->default_threshold = 0;
+                               info->default_timeout = 0;
+                               INIT_WORK(&info->tqueue, do_softint);
+                               init_waitqueue_head(&info->open_wait);
+                               init_waitqueue_head(&info->close_wait);
+                               init_waitqueue_head(&info->shutdown_wait);
+                               init_waitqueue_head(&info->delta_msr_wait);
+                               /* info->session */
+                               /* info->pgrp */
+                               info->read_status_mask = 0;
+                               /* info->timeout */
+                               /* Bentson's vars */
+                               info->jiffies[0] = 0;
+                               info->jiffies[1] = 0;
+                               info->jiffies[2] = 0;
+                               info->rflush_count = 0;
 #ifdef CONFIG_CYZ_INTR
-                   init_timer(&cyz_rx_full_timer[port]);
-                   cyz_rx_full_timer[port].function = NULL;
+                               init_timer(&cyz_rx_full_timer[port]);
+                               cyz_rx_full_timer[port].function = NULL;
 #endif
-                }
-                continue;
-            }else{ /* Cyclom-Y of some kind*/
-                index = cinfo->bus_index;
-               spin_lock_init(&cinfo->card_lock);
-               cinfo->nports = CyPORTS_PER_CHIP * cinfo->num_chips;
-                for (port = cinfo->first_line ;
-                     port < cinfo->first_line + cinfo->nports ;
-                     port++)
-                {
-                    info = &cy_port[port];
-                    info->magic = CYCLADES_MAGIC;
-                    info->type = PORT_CIRRUS;
-                    info->card = board;
-                    info->line = port;
-                    info->flags = STD_COM_FLAGS;
-                    info->tty = NULL;
-                    info->xmit_fifo_size = CyMAX_CHAR_FIFO;
-                    info->cor1 = CyPARITY_NONE|Cy_1_STOP|Cy_8_BITS;
-                    info->cor2 = CyETC;
-                    info->cor3 = 0x08; /* _very_ small rcv threshold */
-                    info->cor4 = 0;
-                    info->cor5 = 0;
-                   info->custom_divisor = 0;
-                    info->close_delay = 5*HZ/10;
-                   info->closing_wait = CLOSING_WAIT_DELAY;
-                   info->icount.cts = info->icount.dsr = 
-                       info->icount.rng = info->icount.dcd = 0;
-                   info->icount.rx = info->icount.tx = 0;
-                   info->icount.frame = info->icount.parity = 0;
-                   info->icount.overrun = info->icount.brk = 0;
-                   chip_number = (port - cinfo->first_line) / 4;
-                   if ((info->chip_rev =
-                        cy_readb(cinfo->base_addr +
-                                 (cy_chip_offset[chip_number]<<index) +
-                                 (CyGFRCR<<index))) >= CD1400_REV_J) {
-                        /* It is a CD1400 rev. J or later */
-                        info->tbpr = baud_bpr_60[13]; /* Tx BPR */
-                        info->tco = baud_co_60[13]; /* Tx CO */
-                        info->rbpr = baud_bpr_60[13]; /* Rx BPR */
-                        info->rco = baud_co_60[13]; /* Rx CO */
-                        info->rflow = 0;
-                        info->rtsdtr_inv = 1;
-                    } else {
-                        info->tbpr = baud_bpr_25[13]; /* Tx BPR */
-                        info->tco = baud_co_25[13]; /* Tx CO */
-                        info->rbpr = baud_bpr_25[13]; /* Rx BPR */
-                        info->rco = baud_co_25[13]; /* Rx CO */
-                        info->rflow = 0;
-                        info->rtsdtr_inv = 0;
-                    }
-                    info->x_char = 0;
-                    info->event = 0;
-                    info->count = 0;
-                    info->blocked_open = 0;
-                    info->default_threshold = 0;
-                    info->default_timeout = 0;
-                   INIT_WORK(&info->tqueue, do_softint);
-                   init_waitqueue_head(&info->open_wait);
-                   init_waitqueue_head(&info->close_wait);
-                   init_waitqueue_head(&info->shutdown_wait);
-                   init_waitqueue_head(&info->delta_msr_wait);
-                    /* info->session */
-                    /* info->pgrp */
-                    info->read_status_mask =
-                                 CyTIMEOUT| CySPECHAR| CyBREAK
-                                  | CyPARITY| CyFRAME| CyOVERRUN;
-                    /* info->timeout */
-                }
-            }
-    }
+                       }
+                       continue;
+               } else {        /* Cyclom-Y of some kind */
+                       index = cinfo->bus_index;
+                       spin_lock_init(&cinfo->card_lock);
+                       cinfo->nports = CyPORTS_PER_CHIP * cinfo->num_chips;
+                       for (port = cinfo->first_line;
+                            port < cinfo->first_line + cinfo->nports; port++) {
+                               info = &cy_port[port];
+                               info->magic = CYCLADES_MAGIC;
+                               info->type = PORT_CIRRUS;
+                               info->card = board;
+                               info->line = port;
+                               info->flags = STD_COM_FLAGS;
+                               info->tty = NULL;
+                               info->xmit_fifo_size = CyMAX_CHAR_FIFO;
+                               info->cor1 =
+                                   CyPARITY_NONE | Cy_1_STOP | Cy_8_BITS;
+                               info->cor2 = CyETC;
+                               info->cor3 = 0x08;      /* _very_ small rcv threshold */
+                               info->cor4 = 0;
+                               info->cor5 = 0;
+                               info->custom_divisor = 0;
+                               info->close_delay = 5 * HZ / 10;
+                               info->closing_wait = CLOSING_WAIT_DELAY;
+                               info->icount.cts = info->icount.dsr =
+                                   info->icount.rng = info->icount.dcd = 0;
+                               info->icount.rx = info->icount.tx = 0;
+                               info->icount.frame = info->icount.parity = 0;
+                               info->icount.overrun = info->icount.brk = 0;
+                               chip_number = (port - cinfo->first_line) / 4;
+                               if ((info->chip_rev =
+                                    cy_readb(cinfo->base_addr +
+                                             (cy_chip_offset[chip_number] <<
+                                              index) + (CyGFRCR << index))) >=
+                                   CD1400_REV_J) {
+                                       /* It is a CD1400 rev. J or later */
+                                       info->tbpr = baud_bpr_60[13];   /* Tx BPR */
+                                       info->tco = baud_co_60[13];     /* Tx CO */
+                                       info->rbpr = baud_bpr_60[13];   /* Rx BPR */
+                                       info->rco = baud_co_60[13];     /* Rx CO */
+                                       info->rflow = 0;
+                                       info->rtsdtr_inv = 1;
+                               } else {
+                                       info->tbpr = baud_bpr_25[13];   /* Tx BPR */
+                                       info->tco = baud_co_25[13];     /* Tx CO */
+                                       info->rbpr = baud_bpr_25[13];   /* Rx BPR */
+                                       info->rco = baud_co_25[13];     /* Rx CO */
+                                       info->rflow = 0;
+                                       info->rtsdtr_inv = 0;
+                               }
+                               info->x_char = 0;
+                               info->event = 0;
+                               info->count = 0;
+                               info->blocked_open = 0;
+                               info->default_threshold = 0;
+                               info->default_timeout = 0;
+                               INIT_WORK(&info->tqueue, do_softint);
+                               init_waitqueue_head(&info->open_wait);
+                               init_waitqueue_head(&info->close_wait);
+                               init_waitqueue_head(&info->shutdown_wait);
+                               init_waitqueue_head(&info->delta_msr_wait);
+                               /* info->session */
+                               /* info->pgrp */
+                               info->read_status_mask =
+                                   CyTIMEOUT | CySPECHAR | CyBREAK
+                                   | CyPARITY | CyFRAME | CyOVERRUN;
+                               /* info->timeout */
+                       }
+               }
+       }
 
 #ifndef CONFIG_CYZ_INTR
-    if (number_z_boards && !cyz_timeron){
-       cyz_timeron++;
-       cyz_timerlist.expires = jiffies + 1;
-       add_timer(&cyz_timerlist);
+       if (number_z_boards && !cyz_timeron) {
+               cyz_timeron++;
+               cyz_timerlist.expires = jiffies + 1;
+               add_timer(&cyz_timerlist);
 #ifdef CY_PCI_DEBUG
-       printk("Cyclades-Z polling initialized\n");
+               printk("Cyclades-Z polling initialized\n");
 #endif
-    }
-#endif /* CONFIG_CYZ_INTR */
+       }
+#endif                         /* CONFIG_CYZ_INTR */
+
+       return 0;
 
-    return 0;
-    
-} /* cy_init */
+}                              /* cy_init */
 
-static void __exit
-cy_cleanup_module(void)
+static void __exit cy_cleanup_module(void)
 {
-    int i, e1;
+       int i, e1;
 
 #ifndef CONFIG_CYZ_INTR
-    if (cyz_timeron){
-       cyz_timeron = 0;
-       del_timer(&cyz_timerlist);
-    }
+       if (cyz_timeron){
+               cyz_timeron = 0;
+               del_timer(&cyz_timerlist);
+       }
 #endif /* CONFIG_CYZ_INTR */
 
-    if ((e1 = tty_unregister_driver(cy_serial_driver)))
-            printk("cyc: failed to unregister Cyclades serial driver(%d)\n",
-               e1);
+       if ((e1 = tty_unregister_driver(cy_serial_driver)))
+               printk("cyc: failed to unregister Cyclades serial driver(%d)\n",
+                       e1);
 
-    put_tty_driver(cy_serial_driver);
+       put_tty_driver(cy_serial_driver);
 
-    for (i = 0; i < NR_CARDS; i++) {
-        if (cy_card[i].base_addr) {
-           iounmap(cy_card[i].base_addr);
-           if (cy_card[i].ctl_addr)
-               iounmap(cy_card[i].ctl_addr);
-           if (cy_card[i].irq
+       for (i = 0; i < NR_CARDS; i++) {
+               if (cy_card[i].base_addr) {
+                       iounmap(cy_card[i].base_addr);
+                       if (cy_card[i].ctl_addr)
+                               iounmap(cy_card[i].ctl_addr);
+                       if (cy_card[i].irq
 #ifndef CONFIG_CYZ_INTR
-               && cy_card[i].num_chips != -1 /* not a Z card */
+                               && cy_card[i].num_chips != -1 /* not a Z card */
 #endif /* CONFIG_CYZ_INTR */
-           )
-               free_irq(cy_card[i].irq, &cy_card[i]);
+                               )
+                               free_irq(cy_card[i].irq, &cy_card[i]);
 #ifdef CONFIG_PCI
-               if (cy_card[i].pdev)
-                       pci_release_regions(cy_card[i].pdev);
+                       if (cy_card[i].pdev)
+                               pci_release_regions(cy_card[i].pdev);
 #endif
-        }
-    }
+               }
+       }
 } /* cy_cleanup_module */
 
 module_init(cy_init);
index 85f404e25c7364d2a176b2ba2d75aa9d735da57e..8ea2bea2b1830feadbeb24f1f8d6d80e943a3ad6 100644 (file)
 extern int zs_init(void);
 #endif
 
-#ifdef CONFIG_DZ
-extern int dz_init(void);
-#endif
-
 #ifdef CONFIG_SERIAL_CONSOLE
 
 #ifdef CONFIG_ZS
 extern void zs_serial_console_init(void);
 #endif
 
-#ifdef CONFIG_DZ
-extern void dz_serial_console_init(void);
-#endif
-
 #endif
 
 /* rs_init - starts up the serial interface -
@@ -46,23 +38,11 @@ extern void dz_serial_console_init(void);
 
 int __init rs_init(void)
 {
-
-#if defined(CONFIG_ZS) && defined(CONFIG_DZ)
+#ifdef CONFIG_ZS
     if (IOASIC)
        return zs_init();
-    else
-       return dz_init();
-#else
-
-#ifdef CONFIG_ZS
-    return zs_init();
-#endif
-
-#ifdef CONFIG_DZ
-    return dz_init();
-#endif
-
 #endif
+    return -ENXIO;
 }
 
 __initcall(rs_init);
@@ -76,21 +56,9 @@ __initcall(rs_init);
  */
 static int __init decserial_console_init(void)
 {
-#if defined(CONFIG_ZS) && defined(CONFIG_DZ)
+#ifdef CONFIG_ZS
     if (IOASIC)
        zs_serial_console_init();
-    else
-       dz_serial_console_init();
-#else
-
-#ifdef CONFIG_ZS
-    zs_serial_console_init();
-#endif
-
-#ifdef CONFIG_DZ
-    dz_serial_console_init();
-#endif
-
 #endif
     return 0;
 }
index d4f874520082844776eff9f912cb70323f25003f..fafeb34f89d5beba40afe752c6e2c92d85cf78df 100644 (file)
@@ -102,7 +102,7 @@ static int compat_drm_version(struct file *file, unsigned int cmd,
                          &version->desc))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_dentry->d_inode, file,
+       err = drm_ioctl(file->f_path.dentry->d_inode, file,
                        DRM_IOCTL_VERSION, (unsigned long)version);
        if (err)
                return err;
@@ -143,7 +143,7 @@ static int compat_drm_getunique(struct file *file, unsigned int cmd,
                          &u->unique))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_dentry->d_inode, file,
+       err = drm_ioctl(file->f_path.dentry->d_inode, file,
                        DRM_IOCTL_GET_UNIQUE, (unsigned long)u);
        if (err)
                return err;
@@ -172,7 +172,7 @@ static int compat_drm_setunique(struct file *file, unsigned int cmd,
                          &u->unique))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_SET_UNIQUE, (unsigned long)u);
 }
 
@@ -203,7 +203,7 @@ static int compat_drm_getmap(struct file *file, unsigned int cmd,
        if (__put_user(idx, &map->offset))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_dentry->d_inode, file,
+       err = drm_ioctl(file->f_path.dentry->d_inode, file,
                        DRM_IOCTL_GET_MAP, (unsigned long)map);
        if (err)
                return err;
@@ -244,7 +244,7 @@ static int compat_drm_addmap(struct file *file, unsigned int cmd,
            || __put_user(m32.flags, &map->flags))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_dentry->d_inode, file,
+       err = drm_ioctl(file->f_path.dentry->d_inode, file,
                        DRM_IOCTL_ADD_MAP, (unsigned long)map);
        if (err)
                return err;
@@ -282,7 +282,7 @@ static int compat_drm_rmmap(struct file *file, unsigned int cmd,
        if (__put_user((void *)(unsigned long)handle, &map->handle))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_RM_MAP, (unsigned long)map);
 }
 
@@ -312,7 +312,7 @@ static int compat_drm_getclient(struct file *file, unsigned int cmd,
        if (__put_user(idx, &client->idx))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_dentry->d_inode, file,
+       err = drm_ioctl(file->f_path.dentry->d_inode, file,
                        DRM_IOCTL_GET_CLIENT, (unsigned long)client);
        if (err)
                return err;
@@ -349,7 +349,7 @@ static int compat_drm_getstats(struct file *file, unsigned int cmd,
        if (!access_ok(VERIFY_WRITE, stats, sizeof(*stats)))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_dentry->d_inode, file,
+       err = drm_ioctl(file->f_path.dentry->d_inode, file,
                        DRM_IOCTL_GET_STATS, (unsigned long)stats);
        if (err)
                return err;
@@ -393,7 +393,7 @@ static int compat_drm_addbufs(struct file *file, unsigned int cmd,
            || __put_user(agp_start, &buf->agp_start))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_dentry->d_inode, file,
+       err = drm_ioctl(file->f_path.dentry->d_inode, file,
                        DRM_IOCTL_ADD_BUFS, (unsigned long)buf);
        if (err)
                return err;
@@ -425,7 +425,7 @@ static int compat_drm_markbufs(struct file *file, unsigned int cmd,
            || __put_user(b32.high_mark, &buf->high_mark))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_MARK_BUFS, (unsigned long)buf);
 }
 
@@ -467,7 +467,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
            || __put_user(list, &request->list))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_dentry->d_inode, file,
+       err = drm_ioctl(file->f_path.dentry->d_inode, file,
                        DRM_IOCTL_INFO_BUFS, (unsigned long)request);
        if (err)
                return err;
@@ -529,7 +529,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
            || __put_user(list, &request->list))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_dentry->d_inode, file,
+       err = drm_ioctl(file->f_path.dentry->d_inode, file,
                        DRM_IOCTL_MAP_BUFS, (unsigned long)request);
        if (err)
                return err;
@@ -576,7 +576,7 @@ static int compat_drm_freebufs(struct file *file, unsigned int cmd,
                          &request->list))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_FREE_BUFS, (unsigned long)request);
 }
 
@@ -603,7 +603,7 @@ static int compat_drm_setsareactx(struct file *file, unsigned int cmd,
                          &request->handle))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_SET_SAREA_CTX, (unsigned long)request);
 }
 
@@ -626,7 +626,7 @@ static int compat_drm_getsareactx(struct file *file, unsigned int cmd,
        if (__put_user(ctx_id, &request->ctx_id))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_dentry->d_inode, file,
+       err = drm_ioctl(file->f_path.dentry->d_inode, file,
                        DRM_IOCTL_GET_SAREA_CTX, (unsigned long)request);
        if (err)
                return err;
@@ -662,7 +662,7 @@ static int compat_drm_resctx(struct file *file, unsigned int cmd,
                          &res->contexts))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_dentry->d_inode, file,
+       err = drm_ioctl(file->f_path.dentry->d_inode, file,
                        DRM_IOCTL_RES_CTX, (unsigned long)res);
        if (err)
                return err;
@@ -716,7 +716,7 @@ static int compat_drm_dma(struct file *file, unsigned int cmd,
                          &d->request_sizes))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_dentry->d_inode, file,
+       err = drm_ioctl(file->f_path.dentry->d_inode, file,
                        DRM_IOCTL_DMA, (unsigned long)d);
        if (err)
                return err;
@@ -749,7 +749,7 @@ static int compat_drm_agp_enable(struct file *file, unsigned int cmd,
        if (put_user(m32.mode, &mode->mode))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_AGP_ENABLE, (unsigned long)mode);
 }
 
@@ -779,7 +779,7 @@ static int compat_drm_agp_info(struct file *file, unsigned int cmd,
        if (!access_ok(VERIFY_WRITE, info, sizeof(*info)))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_dentry->d_inode, file,
+       err = drm_ioctl(file->f_path.dentry->d_inode, file,
                        DRM_IOCTL_AGP_INFO, (unsigned long)info);
        if (err)
                return err;
@@ -825,7 +825,7 @@ static int compat_drm_agp_alloc(struct file *file, unsigned int cmd,
            || __put_user(req32.type, &request->type))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_dentry->d_inode, file,
+       err = drm_ioctl(file->f_path.dentry->d_inode, file,
                        DRM_IOCTL_AGP_ALLOC, (unsigned long)request);
        if (err)
                return err;
@@ -833,7 +833,7 @@ static int compat_drm_agp_alloc(struct file *file, unsigned int cmd,
        if (__get_user(req32.handle, &request->handle)
            || __get_user(req32.physical, &request->physical)
            || copy_to_user(argp, &req32, sizeof(req32))) {
-               drm_ioctl(file->f_dentry->d_inode, file,
+               drm_ioctl(file->f_path.dentry->d_inode, file,
                          DRM_IOCTL_AGP_FREE, (unsigned long)request);
                return -EFAULT;
        }
@@ -854,7 +854,7 @@ static int compat_drm_agp_free(struct file *file, unsigned int cmd,
            || __put_user(handle, &request->handle))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_AGP_FREE, (unsigned long)request);
 }
 
@@ -879,7 +879,7 @@ static int compat_drm_agp_bind(struct file *file, unsigned int cmd,
            || __put_user(req32.offset, &request->offset))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_AGP_BIND, (unsigned long)request);
 }
 
@@ -896,7 +896,7 @@ static int compat_drm_agp_unbind(struct file *file, unsigned int cmd,
            || __put_user(handle, &request->handle))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_AGP_UNBIND, (unsigned long)request);
 }
 #endif                         /* __OS_HAS_AGP */
@@ -921,7 +921,7 @@ static int compat_drm_sg_alloc(struct file *file, unsigned int cmd,
            || __put_user(x, &request->size))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_dentry->d_inode, file,
+       err = drm_ioctl(file->f_path.dentry->d_inode, file,
                        DRM_IOCTL_SG_ALLOC, (unsigned long)request);
        if (err)
                return err;
@@ -948,7 +948,7 @@ static int compat_drm_sg_free(struct file *file, unsigned int cmd,
            || __put_user(x << PAGE_SHIFT, &request->handle))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_SG_FREE, (unsigned long)request);
 }
 
@@ -988,7 +988,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
            || __put_user(req32.request.signal, &request->request.signal))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_dentry->d_inode, file,
+       err = drm_ioctl(file->f_path.dentry->d_inode, file,
                        DRM_IOCTL_WAIT_VBLANK, (unsigned long)request);
        if (err)
                return err;
@@ -1060,7 +1060,7 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        if (fn != NULL)
                ret = (*fn) (filp, cmd, arg);
        else
-               ret = drm_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
+               ret = drm_ioctl(filp->f_path.dentry->d_inode, filp, cmd, arg);
        unlock_kernel();
 
        return ret;
index 74686e9a2d342d84cc5110ef08a5f1c245606bf5..b9cfc077f6bc845633328aef6965b292fe83871f 100644 (file)
@@ -147,14 +147,14 @@ static __inline__ struct page *drm_do_vm_shm_nopage(struct vm_area_struct *vma,
        if (address > vma->vm_end)
                return NOPAGE_SIGBUS;   /* Disallow mremap */
        if (!map)
-               return NOPAGE_OOM;      /* Nothing allocated */
+               return NOPAGE_SIGBUS;   /* Nothing allocated */
 
        offset = address - vma->vm_start;
        i = (unsigned long)map->handle + offset;
        page = (map->type == _DRM_CONSISTENT) ?
                virt_to_page((void *)i) : vmalloc_to_page((void *)i);
        if (!page)
-               return NOPAGE_OOM;
+               return NOPAGE_SIGBUS;
        get_page(page);
 
        DRM_DEBUG("shm_nopage 0x%lx\n", address);
@@ -272,7 +272,7 @@ static __inline__ struct page *drm_do_vm_dma_nopage(struct vm_area_struct *vma,
        if (address > vma->vm_end)
                return NOPAGE_SIGBUS;   /* Disallow mremap */
        if (!dma->pagelist)
-               return NOPAGE_OOM;      /* Nothing allocated */
+               return NOPAGE_SIGBUS;   /* Nothing allocated */
 
        offset = address - vma->vm_start;       /* vm_[pg]off[set] should be 0 */
        page_nr = offset >> PAGE_SHIFT;
@@ -310,7 +310,7 @@ static __inline__ struct page *drm_do_vm_sg_nopage(struct vm_area_struct *vma,
        if (address > vma->vm_end)
                return NOPAGE_SIGBUS;   /* Disallow mremap */
        if (!entry->pagelist)
-               return NOPAGE_OOM;      /* Nothing allocated */
+               return NOPAGE_SIGBUS;   /* Nothing allocated */
 
        offset = address - vma->vm_start;
        map_offset = map->offset - (unsigned long)dev->sg->virtual;
index 296248cdc767e50cc2cdd1c0f40a6deedf4b299e..1fe68a251b75fe3107115a970a919c1e3e447328 100644 (file)
@@ -66,7 +66,7 @@ static int compat_i915_batchbuffer(struct file *file, unsigned int cmd,
                          &batchbuffer->cliprects))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_I915_BATCHBUFFER,
                         (unsigned long)batchbuffer);
 }
@@ -102,7 +102,7 @@ static int compat_i915_cmdbuffer(struct file *file, unsigned int cmd,
                          &cmdbuffer->cliprects))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_I915_CMDBUFFER, (unsigned long)cmdbuffer);
 }
 
@@ -125,7 +125,7 @@ static int compat_i915_irq_emit(struct file *file, unsigned int cmd,
                          &request->irq_seq))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_I915_IRQ_EMIT, (unsigned long)request);
 }
 typedef struct drm_i915_getparam32 {
@@ -149,7 +149,7 @@ static int compat_i915_getparam(struct file *file, unsigned int cmd,
                          &request->value))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_I915_GETPARAM, (unsigned long)request);
 }
 
@@ -178,7 +178,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
                          &request->region_offset))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_I915_ALLOC, (unsigned long)request);
 }
 
@@ -215,7 +215,7 @@ long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        if (fn != NULL)
                ret = (*fn) (filp, cmd, arg);
        else
-               ret = drm_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
+               ret = drm_ioctl(filp->f_path.dentry->d_inode, filp, cmd, arg);
        unlock_kernel();
 
        return ret;
index 54a18eb2fc04abb75f7d2f19b6903cb06c3d1ddf..30d00478ddee9055aad48054659223afeaef573f 100644 (file)
@@ -100,7 +100,7 @@ static int compat_mga_init(struct file *file, unsigned int cmd,
        if (err)
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_MGA_INIT, (unsigned long)init);
 }
 
@@ -125,7 +125,7 @@ static int compat_mga_getparam(struct file *file, unsigned int cmd,
                          &getparam->value))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_MGA_GETPARAM, (unsigned long)getparam);
 }
 
@@ -166,7 +166,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
            || __put_user(dma_bootstrap32.agp_size, &dma_bootstrap->agp_size))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_dentry->d_inode, file,
+       err = drm_ioctl(file->f_path.dentry->d_inode, file,
                        DRM_IOCTL_MGA_DMA_BOOTSTRAP,
                        (unsigned long)dma_bootstrap);
        if (err)
@@ -224,7 +224,7 @@ long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        if (fn != NULL)
                ret = (*fn) (filp, cmd, arg);
        else
-               ret = drm_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
+               ret = drm_ioctl(filp->f_path.dentry->d_inode, filp, cmd, arg);
        unlock_kernel();
 
        return ret;
index 9dd6d4116e4761d9041887cd14d10c27d3016870..d3cb676eee84493e0af7d9df4c445f18dd1766f3 100644 (file)
@@ -95,7 +95,7 @@ static int compat_r128_init(struct file *file, unsigned int cmd,
                          &init->agp_textures_offset))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_R128_INIT, (unsigned long)init);
 }
 
@@ -129,7 +129,7 @@ static int compat_r128_depth(struct file *file, unsigned int cmd,
                          &depth->mask))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_R128_DEPTH, (unsigned long)depth);
 
 }
@@ -153,7 +153,7 @@ static int compat_r128_stipple(struct file *file, unsigned int cmd,
                          &stipple->mask))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_R128_STIPPLE, (unsigned long)stipple);
 }
 
@@ -178,7 +178,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
                          &getparam->value))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
 }
 
@@ -214,7 +214,7 @@ long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        if (fn != NULL)
                ret = (*fn) (filp, cmd, arg);
        else
-               ret = drm_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
+               ret = drm_ioctl(filp->f_path.dentry->d_inode, filp, cmd, arg);
        unlock_kernel();
 
        return ret;
index 0ccfd3618ff1c66a16d6ac261f9f3f2b3bcf1235..1f1f9cc055a437db9873005acb885eed2b7c9b87 100644 (file)
@@ -92,7 +92,7 @@ static int compat_radeon_cp_init(struct file *file, unsigned int cmd,
                          &init->gart_textures_offset))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_RADEON_CP_INIT, (unsigned long)init);
 }
 
@@ -125,7 +125,7 @@ static int compat_radeon_cp_clear(struct file *file, unsigned int cmd,
                          &clr->depth_boxes))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_RADEON_CLEAR, (unsigned long)clr);
 }
 
@@ -149,7 +149,7 @@ static int compat_radeon_cp_stipple(struct file *file, unsigned int cmd,
                          &request->mask))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_RADEON_STIPPLE, (unsigned long)request);
 }
 
@@ -204,7 +204,7 @@ static int compat_radeon_cp_texture(struct file *file, unsigned int cmd,
                          &image->data))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_RADEON_TEXTURE, (unsigned long)request);
 }
 
@@ -238,7 +238,7 @@ static int compat_radeon_cp_vertex2(struct file *file, unsigned int cmd,
                          &request->prim))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_RADEON_VERTEX2, (unsigned long)request);
 }
 
@@ -268,7 +268,7 @@ static int compat_radeon_cp_cmdbuf(struct file *file, unsigned int cmd,
                          &request->boxes))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_RADEON_CMDBUF, (unsigned long)request);
 }
 
@@ -293,7 +293,7 @@ static int compat_radeon_cp_getparam(struct file *file, unsigned int cmd,
                          &request->value))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_RADEON_GETPARAM, (unsigned long)request);
 }
 
@@ -322,7 +322,7 @@ static int compat_radeon_mem_alloc(struct file *file, unsigned int cmd,
                          &request->region_offset))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_RADEON_ALLOC, (unsigned long)request);
 }
 
@@ -345,7 +345,7 @@ static int compat_radeon_irq_emit(struct file *file, unsigned int cmd,
                          &request->irq_seq))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
+       return drm_ioctl(file->f_path.dentry->d_inode, file,
                         DRM_IOCTL_RADEON_IRQ_EMIT, (unsigned long)request);
 }
 
@@ -386,7 +386,7 @@ long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        if (fn != NULL)
                ret = (*fn) (filp, cmd, arg);
        else
-               ret = drm_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
+               ret = drm_ioctl(filp->f_path.dentry->d_inode, filp, cmd, arg);
        unlock_kernel();
 
        return ret;
index 9b1bf60ffbe7f536deabd2e252479e0a9370808b..06f2dbf17710770e5829d464e81cfb48d5e8367c 100644 (file)
@@ -201,7 +201,7 @@ static int dsp56k_upload(u_char __user *bin, int len)
 static ssize_t dsp56k_read(struct file *file, char __user *buf, size_t count,
                           loff_t *ppos)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int dev = iminor(inode) & 0x0f;
 
        switch(dev)
@@ -264,7 +264,7 @@ static ssize_t dsp56k_read(struct file *file, char __user *buf, size_t count,
 static ssize_t dsp56k_write(struct file *file, const char __user *buf, size_t count,
                            loff_t *ppos)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int dev = iminor(inode) & 0x0f;
 
        switch(dev)
@@ -420,7 +420,7 @@ static int dsp56k_ioctl(struct inode *inode, struct file *file,
 #if 0
 static unsigned int dsp56k_poll(struct file *file, poll_table *wait)
 {
-       int dev = iminor(file->f_dentry->d_inode) & 0x0f;
+       int dev = iminor(file->f_path.dentry->d_inode) & 0x0f;
 
        switch(dev)
        {
index 5e82c3bad2e31214fcc76053caf1c4995e08950a..d4005e94fe5f36b90b56e3f7f299c3c82c3fef21 100644 (file)
@@ -122,7 +122,7 @@ static void dtlk_timer_tick(unsigned long data);
 static ssize_t dtlk_read(struct file *file, char __user *buf,
                         size_t count, loff_t * ppos)
 {
-       unsigned int minor = iminor(file->f_dentry->d_inode);
+       unsigned int minor = iminor(file->f_path.dentry->d_inode);
        char ch;
        int i = 0, retries;
 
@@ -174,7 +174,7 @@ static ssize_t dtlk_write(struct file *file, const char __user *buf,
        }
 #endif
 
-       if (iminor(file->f_dentry->d_inode) != DTLK_MINOR)
+       if (iminor(file->f_path.dentry->d_inode) != DTLK_MINOR)
                return -EINVAL;
 
        while (1) {
index 7c71eb779802a9f9ed1a8dde50b3943b86c25b96..a0f822c9d74def65e14f97fb319d782b305ef19d 100644 (file)
@@ -199,7 +199,7 @@ static int pc_ioctl(struct tty_struct *, struct file *,
                     unsigned int, unsigned long);
 static int info_ioctl(struct tty_struct *, struct file *,
                     unsigned int, unsigned long);
-static void pc_set_termios(struct tty_struct *, struct termios *);
+static void pc_set_termios(struct tty_struct *, struct ktermios *);
 static void do_softint(struct work_struct *work);
 static void pc_stop(struct tty_struct *);
 static void pc_start(struct tty_struct *);
@@ -1236,6 +1236,8 @@ static int __init pc_init(void)
        pc_driver->init_termios.c_oflag = 0;
        pc_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
        pc_driver->init_termios.c_lflag = 0;
+       pc_driver->init_termios.c_ispeed = 9600;
+       pc_driver->init_termios.c_ospeed = 9600;
        pc_driver->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(pc_driver, &pc_ops);
 
@@ -1250,6 +1252,8 @@ static int __init pc_init(void)
        pc_info->init_termios.c_oflag = 0;
        pc_info->init_termios.c_lflag = 0;
        pc_info->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL;
+       pc_info->init_termios.c_ispeed = 9600;
+       pc_info->init_termios.c_ospeed = 9600;
        pc_info->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(pc_info, &info_ops);
 
@@ -1999,7 +2003,7 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch)
 { /* Begin epcaparam */
 
        unsigned int cmdHead;
-       struct termios *ts;
+       struct ktermios *ts;
        struct board_chan __iomem *bc;
        unsigned mval, hflow, cflag, iflag;
 
@@ -2114,7 +2118,7 @@ static void receive_data(struct channel *ch)
 { /* Begin receive_data */
 
        unchar *rptr;
-       struct termios *ts = NULL;
+       struct ktermios *ts = NULL;
        struct tty_struct *tty;
        struct board_chan __iomem *bc;
        int dataToRead, wrapgap, bytesAvailable;
@@ -2362,12 +2366,14 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
        switch (cmd) 
        { /* Begin switch cmd */
 
+#if 0  /* Handled by calling layer properly */
                case TCGETS:
-                       if (copy_to_user(argp, tty->termios, sizeof(struct termios)))
+                       if (copy_to_user(argp, tty->termios, sizeof(struct ktermios)))
                                return -EFAULT;
                        return 0;
                case TCGETA:
                        return get_termio(tty, argp);
+#endif
                case TCSBRK:    /* SVID version: non-zero arg --> no break */
                        retval = tty_check_change(tty);
                        if (retval)
@@ -2536,7 +2542,7 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
 
 /* --------------------- Begin pc_set_termios  ----------------------- */
 
-static void pc_set_termios(struct tty_struct *tty, struct termios *old_termios)
+static void pc_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 { /* Begin pc_set_termios */
 
        struct channel *ch;
index 93b5519625130362874ed36d48fc2f0fafe630f4..d1bfbaa2aa0284f62a2d400ed8e74d34221106eb 100644 (file)
@@ -1915,7 +1915,7 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
        return 0;
 }
 
-static void rs_set_termios(struct tty_struct *tty, struct termios *old_termios)
+static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
        struct esp_struct *info = (struct esp_struct *)tty->driver_data;
        unsigned long flags;
index 87127e49c0dbf8a07aeae5fd6cee1f5be3d0a397..e769811e74172d36bff0d845a9fab7327299b158 100644 (file)
@@ -718,11 +718,11 @@ static unsigned int     gs_baudrates[] = {
 
 
 void gs_set_termios (struct tty_struct * tty, 
-                     struct termios * old_termios)
+                     struct ktermios * old_termios)
 {
        struct gs_port *port;
        int baudrate, tmp, rv;
-       struct termios *tiosp;
+       struct ktermios *tiosp;
 
        func_enter();
 
index 9902ffad3b12ddb26e8d064f3ea0b5f3d1a9bb66..cc2cd46bedc6ac6dac8dd7d256a3605c784128cf 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/sched.h>
 #include <linux/spinlock.h>
 #include <linux/delay.h>
+#include <linux/freezer.h>
 
 #include <asm/uaccess.h>
 
index 8728255c9463743046da3b69fde2b198d3fd1329..207f7343ba60df8b5aa2b998cc6184bc1f37cf0f 100644 (file)
@@ -192,11 +192,13 @@ MODULE_VERSION(HVCS_DRIVER_VERSION);
  * that will cause echoing or we'll go into recursive loop echoing chars back
  * and forth with the console drivers.
  */
-static struct termios hvcs_tty_termios = {
+static struct ktermios hvcs_tty_termios = {
        .c_iflag = IGNBRK | IGNPAR,
        .c_oflag = OPOST,
        .c_cflag = B38400 | CS8 | CREAD | HUPCL,
-       .c_cc = INIT_C_CC
+       .c_cc = INIT_C_CC,
+       .c_ispeed = 38400,
+       .c_ospeed = 38400
 };
 
 /*
@@ -337,11 +339,6 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp);
 static void hvcs_close(struct tty_struct *tty, struct file *filp);
 static void hvcs_hangup(struct tty_struct * tty);
 
-static void hvcs_create_device_attrs(struct hvcs_struct *hvcsd);
-static void hvcs_remove_device_attrs(struct vio_dev *vdev);
-static void hvcs_create_driver_attrs(void);
-static void hvcs_remove_driver_attrs(void);
-
 static int __devinit hvcs_probe(struct vio_dev *dev,
                const struct vio_device_id *id);
 static int __devexit hvcs_remove(struct vio_dev *dev);
@@ -353,6 +350,172 @@ static void __exit hvcs_module_exit(void);
 #define HVCS_TRY_WRITE 0x00000004
 #define HVCS_READ_MASK (HVCS_SCHED_READ | HVCS_QUICK_READ)
 
+static inline struct hvcs_struct *from_vio_dev(struct vio_dev *viod)
+{
+       return viod->dev.driver_data;
+}
+/* The sysfs interface for the driver and devices */
+
+static ssize_t hvcs_partner_vtys_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct vio_dev *viod = to_vio_dev(dev);
+       struct hvcs_struct *hvcsd = from_vio_dev(viod);
+       unsigned long flags;
+       int retval;
+
+       spin_lock_irqsave(&hvcsd->lock, flags);
+       retval = sprintf(buf, "%X\n", hvcsd->p_unit_address);
+       spin_unlock_irqrestore(&hvcsd->lock, flags);
+       return retval;
+}
+static DEVICE_ATTR(partner_vtys, S_IRUGO, hvcs_partner_vtys_show, NULL);
+
+static ssize_t hvcs_partner_clcs_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct vio_dev *viod = to_vio_dev(dev);
+       struct hvcs_struct *hvcsd = from_vio_dev(viod);
+       unsigned long flags;
+       int retval;
+
+       spin_lock_irqsave(&hvcsd->lock, flags);
+       retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
+       spin_unlock_irqrestore(&hvcsd->lock, flags);
+       return retval;
+}
+static DEVICE_ATTR(partner_clcs, S_IRUGO, hvcs_partner_clcs_show, NULL);
+
+static ssize_t hvcs_current_vty_store(struct device *dev, struct device_attribute *attr, const char * buf,
+               size_t count)
+{
+       /*
+        * Don't need this feature at the present time because firmware doesn't
+        * yet support multiple partners.
+        */
+       printk(KERN_INFO "HVCS: Denied current_vty change: -EPERM.\n");
+       return -EPERM;
+}
+
+static ssize_t hvcs_current_vty_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct vio_dev *viod = to_vio_dev(dev);
+       struct hvcs_struct *hvcsd = from_vio_dev(viod);
+       unsigned long flags;
+       int retval;
+
+       spin_lock_irqsave(&hvcsd->lock, flags);
+       retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
+       spin_unlock_irqrestore(&hvcsd->lock, flags);
+       return retval;
+}
+
+static DEVICE_ATTR(current_vty,
+       S_IRUGO | S_IWUSR, hvcs_current_vty_show, hvcs_current_vty_store);
+
+static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribute *attr, const char *buf,
+               size_t count)
+{
+       struct vio_dev *viod = to_vio_dev(dev);
+       struct hvcs_struct *hvcsd = from_vio_dev(viod);
+       unsigned long flags;
+
+       /* writing a '0' to this sysfs entry will result in the disconnect. */
+       if (simple_strtol(buf, NULL, 0) != 0)
+               return -EINVAL;
+
+       spin_lock_irqsave(&hvcsd->lock, flags);
+
+       if (hvcsd->open_count > 0) {
+               spin_unlock_irqrestore(&hvcsd->lock, flags);
+               printk(KERN_INFO "HVCS: vterm state unchanged.  "
+                               "The hvcs device node is still in use.\n");
+               return -EPERM;
+       }
+
+       if (hvcsd->connected == 0) {
+               spin_unlock_irqrestore(&hvcsd->lock, flags);
+               printk(KERN_INFO "HVCS: vterm state unchanged. The"
+                               " vty-server is not connected to a vty.\n");
+               return -EPERM;
+       }
+
+       hvcs_partner_free(hvcsd);
+       printk(KERN_INFO "HVCS: Closed vty-server@%X and"
+                       " partner vty@%X:%d connection.\n",
+                       hvcsd->vdev->unit_address,
+                       hvcsd->p_unit_address,
+                       (uint32_t)hvcsd->p_partition_ID);
+
+       spin_unlock_irqrestore(&hvcsd->lock, flags);
+       return count;
+}
+
+static ssize_t hvcs_vterm_state_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct vio_dev *viod = to_vio_dev(dev);
+       struct hvcs_struct *hvcsd = from_vio_dev(viod);
+       unsigned long flags;
+       int retval;
+
+       spin_lock_irqsave(&hvcsd->lock, flags);
+       retval = sprintf(buf, "%d\n", hvcsd->connected);
+       spin_unlock_irqrestore(&hvcsd->lock, flags);
+       return retval;
+}
+static DEVICE_ATTR(vterm_state, S_IRUGO | S_IWUSR,
+               hvcs_vterm_state_show, hvcs_vterm_state_store);
+
+static ssize_t hvcs_index_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct vio_dev *viod = to_vio_dev(dev);
+       struct hvcs_struct *hvcsd = from_vio_dev(viod);
+       unsigned long flags;
+       int retval;
+
+       spin_lock_irqsave(&hvcsd->lock, flags);
+       retval = sprintf(buf, "%d\n", hvcsd->index);
+       spin_unlock_irqrestore(&hvcsd->lock, flags);
+       return retval;
+}
+
+static DEVICE_ATTR(index, S_IRUGO, hvcs_index_show, NULL);
+
+static struct attribute *hvcs_attrs[] = {
+       &dev_attr_partner_vtys.attr,
+       &dev_attr_partner_clcs.attr,
+       &dev_attr_current_vty.attr,
+       &dev_attr_vterm_state.attr,
+       &dev_attr_index.attr,
+       NULL,
+};
+
+static struct attribute_group hvcs_attr_group = {
+       .attrs = hvcs_attrs,
+};
+
+static ssize_t hvcs_rescan_show(struct device_driver *ddp, char *buf)
+{
+       /* A 1 means it is updating, a 0 means it is done updating */
+       return snprintf(buf, PAGE_SIZE, "%d\n", hvcs_rescan_status);
+}
+
+static ssize_t hvcs_rescan_store(struct device_driver *ddp, const char * buf,
+               size_t count)
+{
+       if ((simple_strtol(buf, NULL, 0) != 1)
+               && (hvcs_rescan_status != 0))
+               return -EINVAL;
+
+       hvcs_rescan_status = 1;
+       printk(KERN_INFO "HVCS: rescanning partner info for all"
+               " vty-servers.\n");
+       hvcs_rescan_devices_list();
+       hvcs_rescan_status = 0;
+       return count;
+}
+
+static DRIVER_ATTR(rescan,
+       S_IRUGO | S_IWUSR, hvcs_rescan_show, hvcs_rescan_store);
+
 static void hvcs_kick(void)
 {
        hvcs_kicked = 1;
@@ -575,7 +738,7 @@ static void destroy_hvcs_struct(struct kobject *kobj)
        spin_unlock_irqrestore(&hvcsd->lock, flags);
        spin_unlock(&hvcs_structs_lock);
 
-       hvcs_remove_device_attrs(vdev);
+       sysfs_remove_group(&vdev->dev.kobj, &hvcs_attr_group);
 
        kfree(hvcsd);
 }
@@ -608,6 +771,7 @@ static int __devinit hvcs_probe(
 {
        struct hvcs_struct *hvcsd;
        int index;
+       int retval;
 
        if (!dev || !id) {
                printk(KERN_ERR "HVCS: probed with invalid parameter.\n");
@@ -658,14 +822,16 @@ static int __devinit hvcs_probe(
         * the hvcs_struct has been added to the devices list then the user app
         * will get -ENODEV.
         */
-
        spin_lock(&hvcs_structs_lock);
-
        list_add_tail(&(hvcsd->next), &hvcs_structs);
-
        spin_unlock(&hvcs_structs_lock);
 
-       hvcs_create_device_attrs(hvcsd);
+       retval = sysfs_create_group(&dev->dev.kobj, &hvcs_attr_group);
+       if (retval) {
+               printk(KERN_ERR "HVCS: Can't create sysfs attrs for vty-server@%X\n",
+                      hvcsd->vdev->unit_address);
+               return retval;
+       }
 
        printk(KERN_INFO "HVCS: vty-server@%X added to the vio bus.\n", dev->unit_address);
 
@@ -1354,8 +1520,10 @@ static int __init hvcs_module_init(void)
        if (!hvcs_tty_driver)
                return -ENOMEM;
 
-       if (hvcs_alloc_index_list(num_ttys_to_alloc))
-               return -ENOMEM;
+       if (hvcs_alloc_index_list(num_ttys_to_alloc)) {
+               rc = -ENOMEM;
+               goto index_fail;
+       }
 
        hvcs_tty_driver->owner = THIS_MODULE;
 
@@ -1385,41 +1553,57 @@ static int __init hvcs_module_init(void)
         * dynamically assigned major and minor numbers for our devices.
         */
        if (tty_register_driver(hvcs_tty_driver)) {
-               printk(KERN_ERR "HVCS: registration "
-                       " as a tty driver failed.\n");
-               hvcs_free_index_list();
-               put_tty_driver(hvcs_tty_driver);
-               return -EIO;
+               printk(KERN_ERR "HVCS: registration as a tty driver failed.\n");
+               rc = -EIO;
+               goto register_fail;
        }
 
        hvcs_pi_buff = kmalloc(PAGE_SIZE, GFP_KERNEL);
        if (!hvcs_pi_buff) {
-               tty_unregister_driver(hvcs_tty_driver);
-               hvcs_free_index_list();
-               put_tty_driver(hvcs_tty_driver);
-               return -ENOMEM;
+               rc = -ENOMEM;
+               goto buff_alloc_fail;
        }
 
        hvcs_task = kthread_run(khvcsd, NULL, "khvcsd");
        if (IS_ERR(hvcs_task)) {
                printk(KERN_ERR "HVCS: khvcsd creation failed.  Driver not loaded.\n");
-               kfree(hvcs_pi_buff);
-               tty_unregister_driver(hvcs_tty_driver);
-               hvcs_free_index_list();
-               put_tty_driver(hvcs_tty_driver);
-               return -EIO;
+               rc = -EIO;
+               goto kthread_fail;
        }
 
        rc = vio_register_driver(&hvcs_vio_driver);
+       if (rc) {
+               printk(KERN_ERR "HVCS: can't register vio driver\n");
+               goto vio_fail;
+       }
 
        /*
         * This needs to be done AFTER the vio_register_driver() call or else
         * the kobjects won't be initialized properly.
         */
-       hvcs_create_driver_attrs();
+       rc = driver_create_file(&(hvcs_vio_driver.driver), &driver_attr_rescan);
+       if (rc) {
+               printk(KERN_ERR "HVCS: sysfs attr create failed\n");
+               goto attr_fail;
+       }
 
        printk(KERN_INFO "HVCS: driver module inserted.\n");
 
+       return 0;
+
+attr_fail:
+       vio_unregister_driver(&hvcs_vio_driver);
+vio_fail:
+       kthread_stop(hvcs_task);
+kthread_fail:
+       kfree(hvcs_pi_buff);
+buff_alloc_fail:
+       tty_unregister_driver(hvcs_tty_driver);
+register_fail:
+       hvcs_free_index_list();
+index_fail:
+       put_tty_driver(hvcs_tty_driver);
+       hvcs_tty_driver = NULL;
        return rc;
 }
 
@@ -1441,7 +1625,7 @@ static void __exit hvcs_module_exit(void)
        hvcs_pi_buff = NULL;
        spin_unlock(&hvcs_pi_lock);
 
-       hvcs_remove_driver_attrs();
+       driver_remove_file(&hvcs_vio_driver.driver, &driver_attr_rescan);
 
        vio_unregister_driver(&hvcs_vio_driver);
 
@@ -1456,191 +1640,3 @@ static void __exit hvcs_module_exit(void)
 
 module_init(hvcs_module_init);
 module_exit(hvcs_module_exit);
-
-static inline struct hvcs_struct *from_vio_dev(struct vio_dev *viod)
-{
-       return viod->dev.driver_data;
-}
-/* The sysfs interface for the driver and devices */
-
-static ssize_t hvcs_partner_vtys_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct vio_dev *viod = to_vio_dev(dev);
-       struct hvcs_struct *hvcsd = from_vio_dev(viod);
-       unsigned long flags;
-       int retval;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-       retval = sprintf(buf, "%X\n", hvcsd->p_unit_address);
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       return retval;
-}
-static DEVICE_ATTR(partner_vtys, S_IRUGO, hvcs_partner_vtys_show, NULL);
-
-static ssize_t hvcs_partner_clcs_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct vio_dev *viod = to_vio_dev(dev);
-       struct hvcs_struct *hvcsd = from_vio_dev(viod);
-       unsigned long flags;
-       int retval;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-       retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       return retval;
-}
-static DEVICE_ATTR(partner_clcs, S_IRUGO, hvcs_partner_clcs_show, NULL);
-
-static ssize_t hvcs_current_vty_store(struct device *dev, struct device_attribute *attr, const char * buf,
-               size_t count)
-{
-       /*
-        * Don't need this feature at the present time because firmware doesn't
-        * yet support multiple partners.
-        */
-       printk(KERN_INFO "HVCS: Denied current_vty change: -EPERM.\n");
-       return -EPERM;
-}
-
-static ssize_t hvcs_current_vty_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct vio_dev *viod = to_vio_dev(dev);
-       struct hvcs_struct *hvcsd = from_vio_dev(viod);
-       unsigned long flags;
-       int retval;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-       retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       return retval;
-}
-
-static DEVICE_ATTR(current_vty,
-       S_IRUGO | S_IWUSR, hvcs_current_vty_show, hvcs_current_vty_store);
-
-static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribute *attr, const char *buf,
-               size_t count)
-{
-       struct vio_dev *viod = to_vio_dev(dev);
-       struct hvcs_struct *hvcsd = from_vio_dev(viod);
-       unsigned long flags;
-
-       /* writing a '0' to this sysfs entry will result in the disconnect. */
-       if (simple_strtol(buf, NULL, 0) != 0)
-               return -EINVAL;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-
-       if (hvcsd->open_count > 0) {
-               spin_unlock_irqrestore(&hvcsd->lock, flags);
-               printk(KERN_INFO "HVCS: vterm state unchanged.  "
-                               "The hvcs device node is still in use.\n");
-               return -EPERM;
-       }
-
-       if (hvcsd->connected == 0) {
-               spin_unlock_irqrestore(&hvcsd->lock, flags);
-               printk(KERN_INFO "HVCS: vterm state unchanged. The"
-                               " vty-server is not connected to a vty.\n");
-               return -EPERM;
-       }
-
-       hvcs_partner_free(hvcsd);
-       printk(KERN_INFO "HVCS: Closed vty-server@%X and"
-                       " partner vty@%X:%d connection.\n",
-                       hvcsd->vdev->unit_address,
-                       hvcsd->p_unit_address,
-                       (uint32_t)hvcsd->p_partition_ID);
-
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       return count;
-}
-
-static ssize_t hvcs_vterm_state_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct vio_dev *viod = to_vio_dev(dev);
-       struct hvcs_struct *hvcsd = from_vio_dev(viod);
-       unsigned long flags;
-       int retval;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-       retval = sprintf(buf, "%d\n", hvcsd->connected);
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       return retval;
-}
-static DEVICE_ATTR(vterm_state, S_IRUGO | S_IWUSR,
-               hvcs_vterm_state_show, hvcs_vterm_state_store);
-
-static ssize_t hvcs_index_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct vio_dev *viod = to_vio_dev(dev);
-       struct hvcs_struct *hvcsd = from_vio_dev(viod);
-       unsigned long flags;
-       int retval;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-       retval = sprintf(buf, "%d\n", hvcsd->index);
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       return retval;
-}
-
-static DEVICE_ATTR(index, S_IRUGO, hvcs_index_show, NULL);
-
-static struct attribute *hvcs_attrs[] = {
-       &dev_attr_partner_vtys.attr,
-       &dev_attr_partner_clcs.attr,
-       &dev_attr_current_vty.attr,
-       &dev_attr_vterm_state.attr,
-       &dev_attr_index.attr,
-       NULL,
-};
-
-static struct attribute_group hvcs_attr_group = {
-       .attrs = hvcs_attrs,
-};
-
-static void hvcs_create_device_attrs(struct hvcs_struct *hvcsd)
-{
-       struct vio_dev *vdev = hvcsd->vdev;
-       sysfs_create_group(&vdev->dev.kobj, &hvcs_attr_group);
-}
-
-static void hvcs_remove_device_attrs(struct vio_dev *vdev)
-{
-       sysfs_remove_group(&vdev->dev.kobj, &hvcs_attr_group);
-}
-
-static ssize_t hvcs_rescan_show(struct device_driver *ddp, char *buf)
-{
-       /* A 1 means it is updating, a 0 means it is done updating */
-       return snprintf(buf, PAGE_SIZE, "%d\n", hvcs_rescan_status);
-}
-
-static ssize_t hvcs_rescan_store(struct device_driver *ddp, const char * buf,
-               size_t count)
-{
-       if ((simple_strtol(buf, NULL, 0) != 1)
-               && (hvcs_rescan_status != 0))
-               return -EINVAL;
-
-       hvcs_rescan_status = 1;
-       printk(KERN_INFO "HVCS: rescanning partner info for all"
-               " vty-servers.\n");
-       hvcs_rescan_devices_list();
-       hvcs_rescan_status = 0;
-       return count;
-}
-static DRIVER_ATTR(rescan,
-       S_IRUGO | S_IWUSR, hvcs_rescan_show, hvcs_rescan_store);
-
-static void hvcs_create_driver_attrs(void)
-{
-       struct device_driver *driverfs = &(hvcs_vio_driver.driver);
-       driver_create_file(driverfs, &driver_attr_rescan);
-}
-
-static void hvcs_remove_driver_attrs(void)
-{
-       struct device_driver *driverfs = &(hvcs_vio_driver.driver);
-       driver_remove_file(driverfs, &driver_attr_rescan);
-}
index 82a41d5b4ed0b595d8056b114673a8fd36fcd6f6..d7806834fc171ad07f08c90f0e5b20a30c000987 100644 (file)
@@ -1161,6 +1161,8 @@ static int __init hvsi_init(void)
        hvsi_driver->type = TTY_DRIVER_TYPE_SYSTEM;
        hvsi_driver->init_termios = tty_std_termios;
        hvsi_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL;
+       hvsi_driver->init_termios.c_ispeed = 9600;
+       hvsi_driver->init_termios.c_ospeed = 9600;
        hvsi_driver->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(hvsi_driver, &hvsi_ops);
 
index 9f7635f7517827123f3427408ab9123d60799105..5f3acd8e64b86d9e6ac8e685b61329322aada8c6 100644 (file)
@@ -3,17 +3,20 @@
 #
 
 config HW_RANDOM
-       bool "Hardware Random Number Generator Core support"
-       default y
+       tristate "Hardware Random Number Generator Core support"
+       default m
        ---help---
          Hardware Random Number Generator Core infrastructure.
 
+         To compile this driver as a module, choose M here: the
+         module will be called rng-core.
+
          If unsure, say Y.
 
 config HW_RANDOM_INTEL
        tristate "Intel HW Random Number Generator support"
        depends on HW_RANDOM && (X86 || IA64) && PCI
-       default y
+       default HW_RANDOM
        ---help---
          This driver provides kernel-side support for the Random Number
          Generator hardware found on Intel i8xx-based motherboards.
@@ -26,7 +29,7 @@ config HW_RANDOM_INTEL
 config HW_RANDOM_AMD
        tristate "AMD HW Random Number Generator support"
        depends on HW_RANDOM && X86 && PCI
-       default y
+       default HW_RANDOM
        ---help---
          This driver provides kernel-side support for the Random Number
          Generator hardware found on AMD 76x-based motherboards.
@@ -39,7 +42,7 @@ config HW_RANDOM_AMD
 config HW_RANDOM_GEODE
        tristate "AMD Geode HW Random Number Generator support"
        depends on HW_RANDOM && X86 && PCI
-       default y
+       default HW_RANDOM
        ---help---
          This driver provides kernel-side support for the Random Number
          Generator hardware found on the AMD Geode LX.
@@ -52,7 +55,7 @@ config HW_RANDOM_GEODE
 config HW_RANDOM_VIA
        tristate "VIA HW Random Number Generator support"
        depends on HW_RANDOM && X86_32
-       default y
+       default HW_RANDOM
        ---help---
          This driver provides kernel-side support for the Random Number
          Generator hardware found on VIA based motherboards.
@@ -65,7 +68,7 @@ config HW_RANDOM_VIA
 config HW_RANDOM_IXP4XX
        tristate "Intel IXP4xx NPU HW Random Number Generator support"
        depends on HW_RANDOM && ARCH_IXP4XX
-       default y
+       default HW_RANDOM
        ---help---
          This driver provides kernel-side support for the Random
          Number Generator hardware found on the Intel IXP4xx NPU.
@@ -78,7 +81,7 @@ config HW_RANDOM_IXP4XX
 config HW_RANDOM_OMAP
        tristate "OMAP Random Number Generator support"
        depends on HW_RANDOM && (ARCH_OMAP16XX || ARCH_OMAP24XX)
-       default y
+       default HW_RANDOM
        ---help---
          This driver provides kernel-side support for the Random Number
          Generator hardware found on OMAP16xx and OMAP24xx multimedia
index e263ae96f94052dfd2ef718ea566117b73e5778a..c41fa19454e3910dfce0a1bbe4d7d33eddca77fe 100644 (file)
@@ -2,7 +2,8 @@
 # Makefile for HW Random Number Generator (RNG) device drivers.
 #
 
-obj-$(CONFIG_HW_RANDOM) += core.o
+obj-$(CONFIG_HW_RANDOM) += rng-core.o
+rng-core-y := core.o
 obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o
 obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o
 obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o
index baa4e721b758d84b5b5d59c7dc943cb33b1fe2d5..29277ec6b8ed837056c888806fbc994dcf49f2e7 100644 (file)
@@ -367,11 +367,6 @@ static UCHAR cc02[];
 #define CSE_NULL  3  // Replace with a null
 #define CSE_MARK  4  // Replace with a 3-character sequence (as Unix)
 
-#define  CMD_SET_REPLACEMENT(arg,ch)   \
-                       (((cmdSyntaxPtr)(ct36a))->cmd[1] = (arg), \
-                       (((cmdSyntaxPtr)(ct36a))->cmd[2] = (ch),  \
-                       (cmdSyntaxPtr)(ct36a))
-
 #define CSE_REPLACE  0x8       // Replace the errored character with the
                                                        // replacement character defined here
 
index c213fdbdb2b0e53ce521e7f55714802d75399f28..78045767ec33691d7b8b89770c00f5f39b935f48 100644 (file)
@@ -1016,7 +1016,6 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count)
        unsigned short channel;
        unsigned short stuffIndex;
        unsigned long flags;
-       int rc = 0;
 
        int bailout = 10;
 
index cda2459c1d602293a5f80dc8bbb4c7430b46929e..7c70310a49b5b48a771a86f188f8489521c07123 100644 (file)
@@ -177,7 +177,7 @@ static int  ip2_write_room(PTTY);
 static int  ip2_chars_in_buf(PTTY);
 static void ip2_flush_buffer(PTTY);
 static int  ip2_ioctl(PTTY, struct file *, UINT, ULONG);
-static void ip2_set_termios(PTTY, struct termios *);
+static void ip2_set_termios(PTTY, struct ktermios *);
 static void ip2_set_line_discipline(PTTY);
 static void ip2_throttle(PTTY);
 static void ip2_unthrottle(PTTY);
@@ -198,7 +198,7 @@ static void do_status(struct work_struct *);
 
 static void ip2_wait_until_sent(PTTY,int);
 
-static void set_params (i2ChanStrPtr, struct termios *);
+static void set_params (i2ChanStrPtr, struct ktermios *);
 static int get_serial_info(i2ChanStrPtr, struct serial_struct __user *);
 static int set_serial_info(i2ChanStrPtr, struct serial_struct __user *);
 
@@ -2398,7 +2398,7 @@ set_serial_info( i2ChanStrPtr pCh, struct serial_struct __user *new_info )
 /*                                                                            */
 /******************************************************************************/
 static void
-ip2_set_termios( PTTY tty, struct termios *old_termios )
+ip2_set_termios( PTTY tty, struct ktermios *old_termios )
 {
        i2ChanStrPtr pCh = (i2ChanStrPtr)tty->driver_data;
 
@@ -2440,11 +2440,11 @@ ip2_set_line_discipline ( PTTY tty )
 /* change.                                                                    */
 /******************************************************************************/
 static void
-set_params( i2ChanStrPtr pCh, struct termios *o_tios )
+set_params( i2ChanStrPtr pCh, struct ktermios *o_tios )
 {
        tcflag_t cflag, iflag, lflag;
        char stop_char, start_char;
-       struct termios dummy;
+       struct ktermios dummy;
 
        lflag = pCh->pTTY->termios->c_lflag;
        cflag = pCh->pTTY->termios->c_cflag;
@@ -2700,7 +2700,7 @@ static
 ssize_t
 ip2_ipl_read(struct file *pFile, char __user *pData, size_t count, loff_t *off )
 {
-       unsigned int minor = iminor(pFile->f_dentry->d_inode);
+       unsigned int minor = iminor(pFile->f_path.dentry->d_inode);
        int rc = 0;
 
 #ifdef IP2DEBUG_IPL
index 0030cd8e2e956cb436ae781c854ba41df23058a9..6c59baa887a8c7d1fc1352034303b07ba85eec05 100644 (file)
 #include <linux/ipmi_msgdefs.h>                /* for completion codes */
 #include "ipmi_si_sm.h"
 
-static int bt_debug = 0x00;    /* Production value 0, see following flags */
+#define BT_DEBUG_OFF   0       /* Used in production */
+#define BT_DEBUG_ENABLE        1       /* Generic messages */
+#define BT_DEBUG_MSG   2       /* Prints all request/response buffers */
+#define BT_DEBUG_STATES        4       /* Verbose look at state changes */
+
+static int bt_debug = BT_DEBUG_OFF;
 
-#define        BT_DEBUG_ENABLE 1
-#define BT_DEBUG_MSG   2
-#define BT_DEBUG_STATES        4
 module_param(bt_debug, int, 0644);
 MODULE_PARM_DESC(bt_debug, "debug bitmask, 1=enable, 2=messages, 4=states");
 
@@ -47,38 +49,54 @@ MODULE_PARM_DESC(bt_debug, "debug bitmask, 1=enable, 2=messages, 4=states");
    Since the Open IPMI architecture is single-message oriented at this
    stage, the queue depth of BT is of no concern. */
 
-#define BT_NORMAL_TIMEOUT      5000000 /* seconds in microseconds */
-#define BT_RETRY_LIMIT         2
-#define BT_RESET_DELAY         6000000 /* 6 seconds after warm reset */
+#define BT_NORMAL_TIMEOUT      5       /* seconds */
+#define BT_NORMAL_RETRY_LIMIT  2
+#define BT_RESET_DELAY         6       /* seconds after warm reset */
+
+/* States are written in chronological order and usually cover
+   multiple rows of the state table discussion in the IPMI spec. */
 
 enum bt_states {
-       BT_STATE_IDLE,
+       BT_STATE_IDLE = 0,      /* Order is critical in this list */
        BT_STATE_XACTION_START,
        BT_STATE_WRITE_BYTES,
-       BT_STATE_WRITE_END,
        BT_STATE_WRITE_CONSUME,
-       BT_STATE_B2H_WAIT,
-       BT_STATE_READ_END,
-       BT_STATE_RESET1,                /* These must come last */
+       BT_STATE_READ_WAIT,
+       BT_STATE_CLEAR_B2H,
+       BT_STATE_READ_BYTES,
+       BT_STATE_RESET1,        /* These must come last */
        BT_STATE_RESET2,
        BT_STATE_RESET3,
        BT_STATE_RESTART,
-       BT_STATE_HOSED
+       BT_STATE_PRINTME,
+       BT_STATE_CAPABILITIES_BEGIN,
+       BT_STATE_CAPABILITIES_END,
+       BT_STATE_LONG_BUSY      /* BT doesn't get hosed :-) */
 };
 
+/* Macros seen at the end of state "case" blocks.  They help with legibility
+   and debugging. */
+
+#define BT_STATE_CHANGE(X,Y) { bt->state = X; return Y; }
+
+#define BT_SI_SM_RETURN(Y)   { last_printed = BT_STATE_PRINTME; return Y; }
+
 struct si_sm_data {
        enum bt_states  state;
-       enum bt_states  last_state;     /* assist printing and resets */
        unsigned char   seq;            /* BT sequence number */
        struct si_sm_io *io;
-        unsigned char  write_data[IPMI_MAX_MSG_LENGTH];
-        int            write_count;
-        unsigned char  read_data[IPMI_MAX_MSG_LENGTH];
-        int            read_count;
-        int            truncated;
-        long           timeout;
-        unsigned int   error_retries;  /* end of "common" fields */
+       unsigned char   write_data[IPMI_MAX_MSG_LENGTH];
+       int             write_count;
+       unsigned char   read_data[IPMI_MAX_MSG_LENGTH];
+       int             read_count;
+       int             truncated;
+       long            timeout;        /* microseconds countdown */
+       int             error_retries;  /* end of "common" fields */
        int             nonzero_status; /* hung BMCs stay all 0 */
+       enum bt_states  complete;       /* to divert the state machine */
+       int             BT_CAP_outreqs;
+       long            BT_CAP_req2rsp;
+       int             BT_CAP_retries; /* Recommended retries */
 };
 
 #define BT_CLR_WR_PTR  0x01    /* See IPMI 1.5 table 11.6.4 */
@@ -111,86 +129,118 @@ struct si_sm_data {
 static char *state2txt(unsigned char state)
 {
        switch (state) {
-               case BT_STATE_IDLE:             return("IDLE");
-               case BT_STATE_XACTION_START:    return("XACTION");
-               case BT_STATE_WRITE_BYTES:      return("WR_BYTES");
-               case BT_STATE_WRITE_END:        return("WR_END");
-               case BT_STATE_WRITE_CONSUME:    return("WR_CONSUME");
-               case BT_STATE_B2H_WAIT:         return("B2H_WAIT");
-               case BT_STATE_READ_END:         return("RD_END");
-               case BT_STATE_RESET1:           return("RESET1");
-               case BT_STATE_RESET2:           return("RESET2");
-               case BT_STATE_RESET3:           return("RESET3");
-               case BT_STATE_RESTART:          return("RESTART");
-               case BT_STATE_HOSED:            return("HOSED");
+       case BT_STATE_IDLE:             return("IDLE");
+       case BT_STATE_XACTION_START:    return("XACTION");
+       case BT_STATE_WRITE_BYTES:      return("WR_BYTES");
+       case BT_STATE_WRITE_CONSUME:    return("WR_CONSUME");
+       case BT_STATE_READ_WAIT:        return("RD_WAIT");
+       case BT_STATE_CLEAR_B2H:        return("CLEAR_B2H");
+       case BT_STATE_READ_BYTES:       return("RD_BYTES");
+       case BT_STATE_RESET1:           return("RESET1");
+       case BT_STATE_RESET2:           return("RESET2");
+       case BT_STATE_RESET3:           return("RESET3");
+       case BT_STATE_RESTART:          return("RESTART");
+       case BT_STATE_LONG_BUSY:        return("LONG_BUSY");
+       case BT_STATE_CAPABILITIES_BEGIN: return("CAP_BEGIN");
+       case BT_STATE_CAPABILITIES_END: return("CAP_END");
        }
        return("BAD STATE");
 }
 #define STATE2TXT state2txt(bt->state)
 
-static char *status2txt(unsigned char status, char *buf)
+static char *status2txt(unsigned char status)
 {
+       /*
+        * This cannot be called by two threads at the same time and
+        * the buffer is always consumed immediately, so the static is
+        * safe to use.
+        */
+       static char buf[40];
+
        strcpy(buf, "[ ");
-       if (status & BT_B_BUSY) strcat(buf, "B_BUSY ");
-       if (status & BT_H_BUSY) strcat(buf, "H_BUSY ");
-       if (status & BT_OEM0) strcat(buf, "OEM0 ");
-       if (status & BT_SMS_ATN) strcat(buf, "SMS ");
-       if (status & BT_B2H_ATN) strcat(buf, "B2H ");
-       if (status & BT_H2B_ATN) strcat(buf, "H2B ");
+       if (status & BT_B_BUSY)
+               strcat(buf, "B_BUSY ");
+       if (status & BT_H_BUSY)
+               strcat(buf, "H_BUSY ");
+       if (status & BT_OEM0)
+               strcat(buf, "OEM0 ");
+       if (status & BT_SMS_ATN)
+               strcat(buf, "SMS ");
+       if (status & BT_B2H_ATN)
+               strcat(buf, "B2H ");
+       if (status & BT_H2B_ATN)
+               strcat(buf, "H2B ");
        strcat(buf, "]");
        return buf;
 }
-#define STATUS2TXT(buf) status2txt(status, buf)
+#define STATUS2TXT status2txt(status)
+
+/* called externally at insmod time, and internally on cleanup */
 
-/* This will be called from within this module on a hosed condition */
-#define FIRST_SEQ      0
 static unsigned int bt_init_data(struct si_sm_data *bt, struct si_sm_io *io)
 {
-       bt->state = BT_STATE_IDLE;
-       bt->last_state = BT_STATE_IDLE;
-       bt->seq = FIRST_SEQ;
-       bt->io = io;
-       bt->write_count = 0;
-       bt->read_count = 0;
-       bt->error_retries = 0;
-       bt->nonzero_status = 0;
-       bt->truncated = 0;
-       bt->timeout = BT_NORMAL_TIMEOUT;
+       memset(bt, 0, sizeof(struct si_sm_data));
+       if (bt->io != io) {             /* external: one-time only things */
+               bt->io = io;
+               bt->seq = 0;
+       }
+       bt->state = BT_STATE_IDLE;      /* start here */
+       bt->complete = BT_STATE_IDLE;   /* end here */
+       bt->BT_CAP_req2rsp = BT_NORMAL_TIMEOUT * 1000000;
+       bt->BT_CAP_retries = BT_NORMAL_RETRY_LIMIT;
+       /* BT_CAP_outreqs == zero is a flag to read BT Capabilities */
        return 3; /* We claim 3 bytes of space; ought to check SPMI table */
 }
 
+/* Jam a completion code (probably an error) into a response */
+
+static void force_result(struct si_sm_data *bt, unsigned char completion_code)
+{
+       bt->read_data[0] = 4;                           /* # following bytes */
+       bt->read_data[1] = bt->write_data[1] | 4;       /* Odd NetFn/LUN */
+       bt->read_data[2] = bt->write_data[2];           /* seq (ignored) */
+       bt->read_data[3] = bt->write_data[3];           /* Command */
+       bt->read_data[4] = completion_code;
+       bt->read_count = 5;
+}
+
+/* The upper state machine starts here */
+
 static int bt_start_transaction(struct si_sm_data *bt,
                                unsigned char *data,
                                unsigned int size)
 {
        unsigned int i;
 
-       if ((size < 2) || (size > (IPMI_MAX_MSG_LENGTH - 2)))
-              return -1;
+       if (size < 2)
+               return IPMI_REQ_LEN_INVALID_ERR;
+       if (size > IPMI_MAX_MSG_LENGTH)
+               return IPMI_REQ_LEN_EXCEEDED_ERR;
 
-       if ((bt->state != BT_STATE_IDLE) && (bt->state != BT_STATE_HOSED))
-               return -2;
+       if (bt->state == BT_STATE_LONG_BUSY)
+               return IPMI_NODE_BUSY_ERR;
+
+       if (bt->state != BT_STATE_IDLE)
+               return IPMI_NOT_IN_MY_STATE_ERR;
 
        if (bt_debug & BT_DEBUG_MSG) {
-               printk(KERN_WARNING "+++++++++++++++++++++++++++++++++++++\n");
-               printk(KERN_WARNING "BT: write seq=0x%02X:", bt->seq);
+               printk(KERN_WARNING "BT: +++++++++++++++++ New command\n");
+               printk(KERN_WARNING "BT: NetFn/LUN CMD [%d data]:", size - 2);
                for (i = 0; i < size; i ++)
-                      printk (" %02x", data[i]);
+                       printk (" %02x", data[i]);
                printk("\n");
        }
        bt->write_data[0] = size + 1;   /* all data plus seq byte */
        bt->write_data[1] = *data;      /* NetFn/LUN */
-       bt->write_data[2] = bt->seq;
+       bt->write_data[2] = bt->seq++;
        memcpy(bt->write_data + 3, data + 1, size - 1);
        bt->write_count = size + 2;
-
        bt->error_retries = 0;
        bt->nonzero_status = 0;
-       bt->read_count = 0;
        bt->truncated = 0;
        bt->state = BT_STATE_XACTION_START;
-       bt->last_state = BT_STATE_IDLE;
-       bt->timeout = BT_NORMAL_TIMEOUT;
+       bt->timeout = bt->BT_CAP_req2rsp;
+       force_result(bt, IPMI_ERR_UNSPECIFIED);
        return 0;
 }
 
@@ -198,38 +248,30 @@ static int bt_start_transaction(struct si_sm_data *bt,
    it calls this.  Strip out the length and seq bytes. */
 
 static int bt_get_result(struct si_sm_data *bt,
-                          unsigned char *data,
-                          unsigned int length)
+                        unsigned char *data,
+                        unsigned int length)
 {
        int i, msg_len;
 
        msg_len = bt->read_count - 2;           /* account for length & seq */
-       /* Always NetFn, Cmd, cCode */
        if (msg_len < 3 || msg_len > IPMI_MAX_MSG_LENGTH) {
-               printk(KERN_DEBUG "BT results: bad msg_len = %d\n", msg_len);
-               data[0] = bt->write_data[1] | 0x4;      /* Kludge a response */
-               data[1] = bt->write_data[3];
-               data[2] = IPMI_ERR_UNSPECIFIED;
+               force_result(bt, IPMI_ERR_UNSPECIFIED);
                msg_len = 3;
-       } else {
-               data[0] = bt->read_data[1];
-               data[1] = bt->read_data[3];
-               if (length < msg_len)
-                      bt->truncated = 1;
-               if (bt->truncated) {    /* can be set in read_all_bytes() */
-                       data[2] = IPMI_ERR_MSG_TRUNCATED;
-                       msg_len = 3;
-               } else
-                      memcpy(data + 2, bt->read_data + 4, msg_len - 2);
+       }
+       data[0] = bt->read_data[1];
+       data[1] = bt->read_data[3];
+       if (length < msg_len || bt->truncated) {
+               data[2] = IPMI_ERR_MSG_TRUNCATED;
+               msg_len = 3;
+       } else
+               memcpy(data + 2, bt->read_data + 4, msg_len - 2);
 
-               if (bt_debug & BT_DEBUG_MSG) {
-                       printk (KERN_WARNING "BT: res (raw)");
-                       for (i = 0; i < msg_len; i++)
-                              printk(" %02x", data[i]);
-                       printk ("\n");
-               }
+       if (bt_debug & BT_DEBUG_MSG) {
+               printk (KERN_WARNING "BT: result %d bytes:", msg_len);
+               for (i = 0; i < msg_len; i++)
+                       printk(" %02x", data[i]);
+               printk ("\n");
        }
-       bt->read_count = 0;     /* paranoia */
        return msg_len;
 }
 
@@ -238,22 +280,40 @@ static int bt_get_result(struct si_sm_data *bt,
 
 static void reset_flags(struct si_sm_data *bt)
 {
+       if (bt_debug)
+               printk(KERN_WARNING "IPMI BT: flag reset %s\n",
+                                       status2txt(BT_STATUS));
        if (BT_STATUS & BT_H_BUSY)
-              BT_CONTROL(BT_H_BUSY);
-       if (BT_STATUS & BT_B_BUSY)
-              BT_CONTROL(BT_B_BUSY);
-       BT_CONTROL(BT_CLR_WR_PTR);
-       BT_CONTROL(BT_SMS_ATN);
-
-       if (BT_STATUS & BT_B2H_ATN) {
-               int i;
-               BT_CONTROL(BT_H_BUSY);
-               BT_CONTROL(BT_B2H_ATN);
-               BT_CONTROL(BT_CLR_RD_PTR);
-               for (i = 0; i < IPMI_MAX_MSG_LENGTH + 2; i++)
-                      BMC2HOST;
-               BT_CONTROL(BT_H_BUSY);
-       }
+               BT_CONTROL(BT_H_BUSY);  /* force clear */
+       BT_CONTROL(BT_CLR_WR_PTR);      /* always reset */
+       BT_CONTROL(BT_SMS_ATN);         /* always clear */
+       BT_INTMASK_W(BT_BMC_HWRST);
+}
+
+/* Get rid of an unwanted/stale response.  This should only be needed for
+   BMCs that support multiple outstanding requests. */
+
+static void drain_BMC2HOST(struct si_sm_data *bt)
+{
+       int i, size;
+
+       if (!(BT_STATUS & BT_B2H_ATN))  /* Not signalling a response */
+               return;
+
+       BT_CONTROL(BT_H_BUSY);          /* now set */
+       BT_CONTROL(BT_B2H_ATN);         /* always clear */
+       BT_STATUS;                      /* pause */
+       BT_CONTROL(BT_B2H_ATN);         /* some BMCs are stubborn */
+       BT_CONTROL(BT_CLR_RD_PTR);      /* always reset */
+       if (bt_debug)
+               printk(KERN_WARNING "IPMI BT: stale response %s; ",
+                       status2txt(BT_STATUS));
+       size = BMC2HOST;
+       for (i = 0; i < size ; i++)
+               BMC2HOST;
+       BT_CONTROL(BT_H_BUSY);          /* now clear */
+       if (bt_debug)
+               printk("drained %d bytes\n", size + 1);
 }
 
 static inline void write_all_bytes(struct si_sm_data *bt)
@@ -261,201 +321,256 @@ static inline void write_all_bytes(struct si_sm_data *bt)
        int i;
 
        if (bt_debug & BT_DEBUG_MSG) {
-               printk(KERN_WARNING "BT: write %d bytes seq=0x%02X",
+               printk(KERN_WARNING "BT: write %d bytes seq=0x%02X",
                        bt->write_count, bt->seq);
                for (i = 0; i < bt->write_count; i++)
                        printk (" %02x", bt->write_data[i]);
                printk ("\n");
        }
        for (i = 0; i < bt->write_count; i++)
-              HOST2BMC(bt->write_data[i]);
+               HOST2BMC(bt->write_data[i]);
 }
 
 static inline int read_all_bytes(struct si_sm_data *bt)
 {
        unsigned char i;
 
+       /* length is "framing info", minimum = 4: NetFn, Seq, Cmd, cCode.
+          Keep layout of first four bytes aligned with write_data[] */
+
        bt->read_data[0] = BMC2HOST;
        bt->read_count = bt->read_data[0];
-       if (bt_debug & BT_DEBUG_MSG)
-               printk(KERN_WARNING "BT: read %d bytes:", bt->read_count);
 
-       /* minimum: length, NetFn, Seq, Cmd, cCode == 5 total, or 4 more
-          following the length byte. */
        if (bt->read_count < 4 || bt->read_count >= IPMI_MAX_MSG_LENGTH) {
                if (bt_debug & BT_DEBUG_MSG)
-                       printk("bad length %d\n", bt->read_count);
+                       printk(KERN_WARNING "BT: bad raw rsp len=%d\n",
+                               bt->read_count);
                bt->truncated = 1;
                return 1;       /* let next XACTION START clean it up */
        }
        for (i = 1; i <= bt->read_count; i++)
-              bt->read_data[i] = BMC2HOST;
-       bt->read_count++;       /* account for the length byte */
+               bt->read_data[i] = BMC2HOST;
+       bt->read_count++;       /* Account internally for length byte */
 
        if (bt_debug & BT_DEBUG_MSG) {
-               for (i = 0; i < bt->read_count; i++)
+               int max = bt->read_count;
+
+               printk(KERN_WARNING "BT: got %d bytes seq=0x%02X",
+                       max, bt->read_data[2]);
+               if (max > 16)
+                       max = 16;
+               for (i = 0; i < max; i++)
                        printk (" %02x", bt->read_data[i]);
-               printk ("\n");
+               printk ("%s\n", bt->read_count == max ? "" : " ...");
        }
-       if (bt->seq != bt->write_data[2])       /* idiot check */
-               printk(KERN_DEBUG "BT: internal error: sequence mismatch\n");
 
-       /* per the spec, the (NetFn, Seq, Cmd) tuples should match */
-       if ((bt->read_data[3] == bt->write_data[3]) &&          /* Cmd */
-               (bt->read_data[2] == bt->write_data[2]) &&      /* Sequence */
-               ((bt->read_data[1] & 0xF8) == (bt->write_data[1] & 0xF8)))
+       /* per the spec, the (NetFn[1], Seq[2], Cmd[3]) tuples must match */
+       if ((bt->read_data[3] == bt->write_data[3]) &&
+           (bt->read_data[2] == bt->write_data[2]) &&
+           ((bt->read_data[1] & 0xF8) == (bt->write_data[1] & 0xF8)))
                        return 1;
 
        if (bt_debug & BT_DEBUG_MSG)
-              printk(KERN_WARNING "BT: bad packet: "
+               printk(KERN_WARNING "IPMI BT: bad packet: "
                "want 0x(%02X, %02X, %02X) got (%02X, %02X, %02X)\n",
-               bt->write_data[1], bt->write_data[2], bt->write_data[3],
+               bt->write_data[1] | 0x04, bt->write_data[2], bt->write_data[3],
                bt->read_data[1],  bt->read_data[2],  bt->read_data[3]);
        return 0;
 }
 
-/* Modifies bt->state appropriately, need to get into the bt_event() switch */
+/* Restart if retries are left, or return an error completion code */
 
-static void error_recovery(struct si_sm_data *bt, char *reason)
+static enum si_sm_result error_recovery(struct si_sm_data *bt,
+                                       unsigned char status,
+                                       unsigned char cCode)
 {
-       unsigned char status;
-       char buf[40]; /* For getting status */
+       char *reason;
 
-       bt->timeout = BT_NORMAL_TIMEOUT; /* various places want to retry */
+       bt->timeout = bt->BT_CAP_req2rsp;
 
-       status = BT_STATUS;
-       printk(KERN_DEBUG "BT: %s in %s %s\n", reason, STATE2TXT,
-              STATUS2TXT(buf));
+       switch (cCode) {
+       case IPMI_TIMEOUT_ERR:
+               reason = "timeout";
+               break;
+       default:
+               reason = "internal error";
+               break;
+       }
+
+       printk(KERN_WARNING "IPMI BT: %s in %s %s ",    /* open-ended line */
+               reason, STATE2TXT, STATUS2TXT);
 
+       /* Per the IPMI spec, retries are based on the sequence number
+          known only to this module, so manage a restart here. */
        (bt->error_retries)++;
-       if (bt->error_retries > BT_RETRY_LIMIT) {
-               printk(KERN_DEBUG "retry limit (%d) exceeded\n", BT_RETRY_LIMIT);
-               bt->state = BT_STATE_HOSED;
-               if (!bt->nonzero_status)
-                       printk(KERN_ERR "IPMI: BT stuck, try power cycle\n");
-               else if (bt->error_retries <= BT_RETRY_LIMIT + 1) {
-                       printk(KERN_DEBUG "IPMI: BT reset (takes 5 secs)\n");
-                       bt->state = BT_STATE_RESET1;
-               }
-       return;
+       if (bt->error_retries < bt->BT_CAP_retries) {
+               printk("%d retries left\n",
+                       bt->BT_CAP_retries - bt->error_retries);
+               bt->state = BT_STATE_RESTART;
+               return SI_SM_CALL_WITHOUT_DELAY;
        }
 
-       /* Sometimes the BMC queues get in an "off-by-one" state...*/
-       if ((bt->state == BT_STATE_B2H_WAIT) && (status & BT_B2H_ATN)) {
-               printk(KERN_DEBUG "retry B2H_WAIT\n");
-               return;
+       printk("failed %d retries, sending error response\n",
+               bt->BT_CAP_retries);
+       if (!bt->nonzero_status)
+               printk(KERN_ERR "IPMI BT: stuck, try power cycle\n");
+
+       /* this is most likely during insmod */
+       else if (bt->seq <= (unsigned char)(bt->BT_CAP_retries & 0xFF)) {
+               printk(KERN_WARNING "IPMI: BT reset (takes 5 secs)\n");
+               bt->state = BT_STATE_RESET1;
+               return SI_SM_CALL_WITHOUT_DELAY;
        }
 
-       printk(KERN_DEBUG "restart command\n");
-       bt->state = BT_STATE_RESTART;
+       /* Concoct a useful error message, set up the next state, and
+          be done with this sequence. */
+
+       bt->state = BT_STATE_IDLE;
+       switch (cCode) {
+       case IPMI_TIMEOUT_ERR:
+               if (status & BT_B_BUSY) {
+                       cCode = IPMI_NODE_BUSY_ERR;
+                       bt->state = BT_STATE_LONG_BUSY;
+               }
+               break;
+       default:
+               break;
+       }
+       force_result(bt, cCode);
+       return SI_SM_TRANSACTION_COMPLETE;
 }
 
-/* Check the status and (possibly) advance the BT state machine.  The
-   default return is SI_SM_CALL_WITH_DELAY. */
+/* Check status and (usually) take action and change this state machine. */
 
 static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
 {
-       unsigned char status;
-       char buf[40]; /* For getting status */
+       unsigned char status, BT_CAP[8];
+       static enum bt_states last_printed = BT_STATE_PRINTME;
        int i;
 
        status = BT_STATUS;
        bt->nonzero_status |= status;
-
-       if ((bt_debug & BT_DEBUG_STATES) && (bt->state != bt->last_state))
+       if ((bt_debug & BT_DEBUG_STATES) && (bt->state != last_printed)) {
                printk(KERN_WARNING "BT: %s %s TO=%ld - %ld \n",
                        STATE2TXT,
-                       STATUS2TXT(buf),
+                       STATUS2TXT,
                        bt->timeout,
                        time);
-       bt->last_state = bt->state;
+               last_printed = bt->state;
+       }
 
-       if (bt->state == BT_STATE_HOSED)
-              return SI_SM_HOSED;
+       /* Commands that time out may still (eventually) provide a response.
+          This stale response will get in the way of a new response so remove
+          it if possible (hopefully during IDLE).  Even if it comes up later
+          it will be rejected by its (now-forgotten) seq number. */
+
+       if ((bt->state < BT_STATE_WRITE_BYTES) && (status & BT_B2H_ATN)) {
+               drain_BMC2HOST(bt);
+               BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
+       }
 
-       if (bt->state != BT_STATE_IDLE) {       /* do timeout test */
+       if ((bt->state != BT_STATE_IDLE) &&
+           (bt->state <  BT_STATE_PRINTME)) {          /* check timeout */
                bt->timeout -= time;
-               if ((bt->timeout < 0) && (bt->state < BT_STATE_RESET1)) {
-                       error_recovery(bt, "timed out");
-                       return SI_SM_CALL_WITHOUT_DELAY;
-               }
+               if ((bt->timeout < 0) && (bt->state < BT_STATE_RESET1))
+                       return error_recovery(bt,
+                                             status,
+                                             IPMI_TIMEOUT_ERR);
        }
 
        switch (bt->state) {
 
-       case BT_STATE_IDLE:     /* check for asynchronous messages */
+       /* Idle state first checks for asynchronous messages from another
+          channel, then does some opportunistic housekeeping. */
+
+       case BT_STATE_IDLE:
                if (status & BT_SMS_ATN) {
                        BT_CONTROL(BT_SMS_ATN); /* clear it */
                        return SI_SM_ATTN;
                }
-               return SI_SM_IDLE;
 
-       case BT_STATE_XACTION_START:
-               if (status & BT_H_BUSY) {
+               if (status & BT_H_BUSY)         /* clear a leftover H_BUSY */
                        BT_CONTROL(BT_H_BUSY);
-                       break;
-               }
-               if (status & BT_B2H_ATN)
-                      break;
-               bt->state = BT_STATE_WRITE_BYTES;
-               return SI_SM_CALL_WITHOUT_DELAY;        /* for logging */
 
-       case BT_STATE_WRITE_BYTES:
+               /* Read BT capabilities if it hasn't been done yet */
+               if (!bt->BT_CAP_outreqs)
+                       BT_STATE_CHANGE(BT_STATE_CAPABILITIES_BEGIN,
+                                       SI_SM_CALL_WITHOUT_DELAY);
+               bt->timeout = bt->BT_CAP_req2rsp;
+               BT_SI_SM_RETURN(SI_SM_IDLE);
+
+       case BT_STATE_XACTION_START:
                if (status & (BT_B_BUSY | BT_H2B_ATN))
-                      break;
+                       BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
+               if (BT_STATUS & BT_H_BUSY)
+                       BT_CONTROL(BT_H_BUSY);  /* force clear */
+               BT_STATE_CHANGE(BT_STATE_WRITE_BYTES,
+                               SI_SM_CALL_WITHOUT_DELAY);
+
+       case BT_STATE_WRITE_BYTES:
+               if (status & BT_H_BUSY)
+                       BT_CONTROL(BT_H_BUSY);  /* clear */
                BT_CONTROL(BT_CLR_WR_PTR);
                write_all_bytes(bt);
-               BT_CONTROL(BT_H2B_ATN); /* clears too fast to catch? */
-               bt->state = BT_STATE_WRITE_CONSUME;
-               return SI_SM_CALL_WITHOUT_DELAY; /* it MIGHT sail through */
-
-       case BT_STATE_WRITE_CONSUME: /* BMCs usually blow right thru here */
-               if (status & (BT_H2B_ATN | BT_B_BUSY))
-                      break;
-               bt->state = BT_STATE_B2H_WAIT;
-               /* fall through with status */
-
-       /* Stay in BT_STATE_B2H_WAIT until a packet matches.  However, spinning
-          hard here, constantly reading status, seems to hold off the
-          generation of B2H_ATN so ALWAYS return CALL_WITH_DELAY. */
-
-       case BT_STATE_B2H_WAIT:
-               if (!(status & BT_B2H_ATN))
-                      break;
-
-               /* Assume ordered, uncached writes: no need to wait */
-               if (!(status & BT_H_BUSY))
-                      BT_CONTROL(BT_H_BUSY); /* set */
-               BT_CONTROL(BT_B2H_ATN);         /* clear it, ACK to the BMC */
-               BT_CONTROL(BT_CLR_RD_PTR);      /* reset the queue */
-               i = read_all_bytes(bt);
-               BT_CONTROL(BT_H_BUSY);          /* clear */
-               if (!i)                         /* Try this state again */
-                      break;
-               bt->state = BT_STATE_READ_END;
-               return SI_SM_CALL_WITHOUT_DELAY;        /* for logging */
-
-       case BT_STATE_READ_END:
-
-               /* I could wait on BT_H_BUSY to go clear for a truly clean
-                  exit.  However, this is already done in XACTION_START
-                  and the (possible) extra loop/status/possible wait affects
-                  performance.  So, as long as it works, just ignore H_BUSY */
-
-#ifdef MAKE_THIS_TRUE_IF_NECESSARY
+               BT_CONTROL(BT_H2B_ATN); /* can clear too fast to catch */
+               BT_STATE_CHANGE(BT_STATE_WRITE_CONSUME,
+                               SI_SM_CALL_WITHOUT_DELAY);
 
-               if (status & BT_H_BUSY)
-                      break;
-#endif
-               bt->seq++;
-               bt->state = BT_STATE_IDLE;
-               return SI_SM_TRANSACTION_COMPLETE;
+       case BT_STATE_WRITE_CONSUME:
+               if (status & (BT_B_BUSY | BT_H2B_ATN))
+                       BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
+               BT_STATE_CHANGE(BT_STATE_READ_WAIT,
+                               SI_SM_CALL_WITHOUT_DELAY);
+
+       /* Spinning hard can suppress B2H_ATN and force a timeout */
+
+       case BT_STATE_READ_WAIT:
+               if (!(status & BT_B2H_ATN))
+                       BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
+               BT_CONTROL(BT_H_BUSY);          /* set */
+
+               /* Uncached, ordered writes should just proceeed serially but
+                  some BMCs don't clear B2H_ATN with one hit.  Fast-path a
+                  workaround without too much penalty to the general case. */
+
+               BT_CONTROL(BT_B2H_ATN);         /* clear it to ACK the BMC */
+               BT_STATE_CHANGE(BT_STATE_CLEAR_B2H,
+                               SI_SM_CALL_WITHOUT_DELAY);
+
+       case BT_STATE_CLEAR_B2H:
+               if (status & BT_B2H_ATN) {      /* keep hitting it */
+                       BT_CONTROL(BT_B2H_ATN);
+                       BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
+               }
+               BT_STATE_CHANGE(BT_STATE_READ_BYTES,
+                               SI_SM_CALL_WITHOUT_DELAY);
+
+       case BT_STATE_READ_BYTES:
+               if (!(status & BT_H_BUSY))      /* check in case of retry */
+                       BT_CONTROL(BT_H_BUSY);
+               BT_CONTROL(BT_CLR_RD_PTR);      /* start of BMC2HOST buffer */
+               i = read_all_bytes(bt);         /* true == packet seq match */
+               BT_CONTROL(BT_H_BUSY);          /* NOW clear */
+               if (!i)                         /* Not my message */
+                       BT_STATE_CHANGE(BT_STATE_READ_WAIT,
+                                       SI_SM_CALL_WITHOUT_DELAY);
+               bt->state = bt->complete;
+               return bt->state == BT_STATE_IDLE ?     /* where to next? */
+                       SI_SM_TRANSACTION_COMPLETE :    /* normal */
+                       SI_SM_CALL_WITHOUT_DELAY;       /* Startup magic */
+
+       case BT_STATE_LONG_BUSY:        /* For example: after FW update */
+               if (!(status & BT_B_BUSY)) {
+                       reset_flags(bt);        /* next state is now IDLE */
+                       bt_init_data(bt, bt->io);
+               }
+               return SI_SM_CALL_WITH_DELAY;   /* No repeat printing */
 
        case BT_STATE_RESET1:
-               reset_flags(bt);
-               bt->timeout = BT_RESET_DELAY;
-               bt->state = BT_STATE_RESET2;
-               break;
+               reset_flags(bt);
+               drain_BMC2HOST(bt);
+               BT_STATE_CHANGE(BT_STATE_RESET2,
+                               SI_SM_CALL_WITH_DELAY);
 
        case BT_STATE_RESET2:           /* Send a soft reset */
                BT_CONTROL(BT_CLR_WR_PTR);
@@ -464,29 +579,59 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
                HOST2BMC(42);           /* Sequence number */
                HOST2BMC(3);            /* Cmd == Soft reset */
                BT_CONTROL(BT_H2B_ATN);
-               bt->state = BT_STATE_RESET3;
-               break;
+               bt->timeout = BT_RESET_DELAY * 1000000;
+               BT_STATE_CHANGE(BT_STATE_RESET3,
+                               SI_SM_CALL_WITH_DELAY);
 
-       case BT_STATE_RESET3:
+       case BT_STATE_RESET3:           /* Hold off everything for a bit */
                if (bt->timeout > 0)
-                      return SI_SM_CALL_WITH_DELAY;
-               bt->state = BT_STATE_RESTART;   /* printk in debug modes */
-               break;
+                       return SI_SM_CALL_WITH_DELAY;
+               drain_BMC2HOST(bt);
+               BT_STATE_CHANGE(BT_STATE_RESTART,
+                               SI_SM_CALL_WITH_DELAY);
 
-       case BT_STATE_RESTART:          /* don't reset retries! */
-               reset_flags(bt);
-               bt->write_data[2] = ++bt->seq;
+       case BT_STATE_RESTART:          /* don't reset retries or seq! */
                bt->read_count = 0;
                bt->nonzero_status = 0;
-               bt->timeout = BT_NORMAL_TIMEOUT;
-               bt->state = BT_STATE_XACTION_START;
-               break;
-
-       default:        /* HOSED is supposed to be caught much earlier */
-               error_recovery(bt, "internal logic error");
-               break;
-       }
-       return SI_SM_CALL_WITH_DELAY;
+               bt->timeout = bt->BT_CAP_req2rsp;
+               BT_STATE_CHANGE(BT_STATE_XACTION_START,
+                               SI_SM_CALL_WITH_DELAY);
+
+       /* Get BT Capabilities, using timing of upper level state machine.
+          Set outreqs to prevent infinite loop on timeout. */
+       case BT_STATE_CAPABILITIES_BEGIN:
+               bt->BT_CAP_outreqs = 1;
+               {
+                       unsigned char GetBT_CAP[] = { 0x18, 0x36 };
+                       bt->state = BT_STATE_IDLE;
+                       bt_start_transaction(bt, GetBT_CAP, sizeof(GetBT_CAP));
+               }
+               bt->complete = BT_STATE_CAPABILITIES_END;
+               BT_STATE_CHANGE(BT_STATE_XACTION_START,
+                               SI_SM_CALL_WITH_DELAY);
+
+       case BT_STATE_CAPABILITIES_END:
+               i = bt_get_result(bt, BT_CAP, sizeof(BT_CAP));
+               bt_init_data(bt, bt->io);
+               if ((i == 8) && !BT_CAP[2]) {
+                       bt->BT_CAP_outreqs = BT_CAP[3];
+                       bt->BT_CAP_req2rsp = BT_CAP[6] * 1000000;
+                       bt->BT_CAP_retries = BT_CAP[7];
+               } else
+                       printk(KERN_WARNING "IPMI BT: using default values\n");
+               if (!bt->BT_CAP_outreqs)
+                       bt->BT_CAP_outreqs = 1;
+               printk(KERN_WARNING "IPMI BT: req2rsp=%ld secs retries=%d\n",
+                       bt->BT_CAP_req2rsp / 1000000L, bt->BT_CAP_retries);
+               bt->timeout = bt->BT_CAP_req2rsp;
+               return SI_SM_CALL_WITHOUT_DELAY;
+
+       default:        /* should never occur */
+               return error_recovery(bt,
+                                     status,
+                                     IPMI_ERR_UNSPECIFIED);
+       }
+       return SI_SM_CALL_WITH_DELAY;
 }
 
 static int bt_detect(struct si_sm_data *bt)
@@ -497,7 +642,7 @@ static int bt_detect(struct si_sm_data *bt)
           test that first.  The calling routine uses negative logic. */
 
        if ((BT_STATUS == 0xFF) && (BT_INTMASK_R == 0xFF))
-              return 1;
+               return 1;
        reset_flags(bt);
        return 0;
 }
@@ -513,11 +658,11 @@ static int bt_size(void)
 
 struct si_sm_handlers bt_smi_handlers =
 {
-       .init_data         = bt_init_data,
-       .start_transaction = bt_start_transaction,
-       .get_result        = bt_get_result,
-       .event             = bt_event,
-       .detect            = bt_detect,
-       .cleanup           = bt_cleanup,
-       .size              = bt_size,
+       .init_data              = bt_init_data,
+       .start_transaction      = bt_start_transaction,
+       .get_result             = bt_get_result,
+       .event                  = bt_event,
+       .detect                 = bt_detect,
+       .cleanup                = bt_cleanup,
+       .size                   = bt_size,
 };
index 81fcf0ce21d1c91cf95f478a960a20d2459a6772..e257835a9a73364fcc66ee5ed86f9cf7392d8b07 100644 (file)
@@ -596,6 +596,31 @@ static int ipmi_ioctl(struct inode  *inode,
                rv = 0;
                break;
        }
+
+       case IPMICTL_GET_MAINTENANCE_MODE_CMD:
+       {
+               int mode;
+
+               mode = ipmi_get_maintenance_mode(priv->user);
+               if (copy_to_user(arg, &mode, sizeof(mode))) {
+                       rv = -EFAULT;
+                       break;
+               }
+               rv = 0;
+               break;
+       }
+
+       case IPMICTL_SET_MAINTENANCE_MODE_CMD:
+       {
+               int mode;
+
+               if (copy_from_user(&mode, arg, sizeof(mode))) {
+                       rv = -EFAULT;
+                       break;
+               }
+               rv = ipmi_set_maintenance_mode(priv->user, mode);
+               break;
+       }
        }
   
        return rv;
@@ -773,7 +798,7 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd,
                if (copy_to_user(precv64, &recv64, sizeof(recv64)))
                        return -EFAULT;
 
-               rc = ipmi_ioctl(filep->f_dentry->d_inode, filep,
+               rc = ipmi_ioctl(filep->f_path.dentry->d_inode, filep,
                                ((cmd == COMPAT_IPMICTL_RECEIVE_MSG)
                                 ? IPMICTL_RECEIVE_MSG
                                 : IPMICTL_RECEIVE_MSG_TRUNC),
@@ -790,7 +815,7 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd,
                return rc;
        }
        default:
-               return ipmi_ioctl(filep->f_dentry->d_inode, filep, cmd, arg);
+               return ipmi_ioctl(filep->f_path.dentry->d_inode, filep, cmd, arg);
        }
 }
 #endif
index 2062675f9e998d1e8f3420f6a1b7af747624f283..c1b8228cb7b685c619d437fac98f01ef68169437 100644 (file)
@@ -93,8 +93,8 @@ enum kcs_states {
                                   state machine. */
 };
 
-#define MAX_KCS_READ_SIZE 80
-#define MAX_KCS_WRITE_SIZE 80
+#define MAX_KCS_READ_SIZE IPMI_MAX_MSG_LENGTH
+#define MAX_KCS_WRITE_SIZE IPMI_MAX_MSG_LENGTH
 
 /* Timeouts in microseconds. */
 #define IBF_RETRY_TIMEOUT 1000000
@@ -261,12 +261,14 @@ static int start_kcs_transaction(struct si_sm_data *kcs, unsigned char *data,
 {
        unsigned int i;
 
-       if ((size < 2) || (size > MAX_KCS_WRITE_SIZE)) {
-               return -1;
-       }
-       if ((kcs->state != KCS_IDLE) && (kcs->state != KCS_HOSED)) {
-               return -2;
-       }
+       if (size < 2)
+               return IPMI_REQ_LEN_INVALID_ERR;
+       if (size > MAX_KCS_WRITE_SIZE)
+               return IPMI_REQ_LEN_EXCEEDED_ERR;
+
+       if ((kcs->state != KCS_IDLE) && (kcs->state != KCS_HOSED))
+               return IPMI_NOT_IN_MY_STATE_ERR;
+
        if (kcs_debug & KCS_DEBUG_MSG) {
                printk(KERN_DEBUG "start_kcs_transaction -");
                for (i = 0; i < size; i ++) {
index c47add8e47df3009aaf25d6dffe4ded0b64f0773..5703ee28e1cc0b97adb7488db3b843b2715290ca 100644 (file)
@@ -48,7 +48,7 @@
 
 #define PFX "IPMI message handler: "
 
-#define IPMI_DRIVER_VERSION "39.0"
+#define IPMI_DRIVER_VERSION "39.1"
 
 static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void);
 static int ipmi_init_msghandler(void);
@@ -59,6 +59,9 @@ static int initialized = 0;
 static struct proc_dir_entry *proc_ipmi_root = NULL;
 #endif /* CONFIG_PROC_FS */
 
+/* Remain in auto-maintenance mode for this amount of time (in ms). */
+#define IPMI_MAINTENANCE_MODE_TIMEOUT 30000
+
 #define MAX_EVENTS_IN_QUEUE    25
 
 /* Don't let a message sit in a queue forever, always time it with at lest
@@ -193,17 +196,28 @@ struct ipmi_smi
 
        struct kref refcount;
 
+       /* Used for a list of interfaces. */
+       struct list_head link;
+
        /* The list of upper layers that are using me.  seq_lock
         * protects this. */
        struct list_head users;
 
+       /* Information to supply to users. */
+       unsigned char ipmi_version_major;
+       unsigned char ipmi_version_minor;
+
        /* Used for wake ups at startup. */
        wait_queue_head_t waitq;
 
        struct bmc_device *bmc;
        char *my_dev_name;
+       char *sysfs_name;
 
-       /* This is the lower-layer's sender routine. */
+       /* This is the lower-layer's sender routine.  Note that you
+        * must either be holding the ipmi_interfaces_mutex or be in
+        * an umpreemptible region to use this.  You must fetch the
+        * value into a local variable and make sure it is not NULL. */
        struct ipmi_smi_handlers *handlers;
        void                     *send_info;
 
@@ -242,6 +256,7 @@ struct ipmi_smi
        spinlock_t       events_lock; /* For dealing with event stuff. */
        struct list_head waiting_events;
        unsigned int     waiting_events_count; /* How many events in queue? */
+       int              delivering_events;
 
        /* The event receiver for my BMC, only really used at panic
           shutdown as a place to store this. */
@@ -250,6 +265,12 @@ struct ipmi_smi
        unsigned char local_sel_device;
        unsigned char local_event_generator;
 
+       /* For handling of maintenance mode. */
+       int maintenance_mode;
+       int maintenance_mode_enable;
+       int auto_maintenance_timeout;
+       spinlock_t maintenance_mode_lock; /* Used in a timer... */
+
        /* A cheap hack, if this is non-null and a message to an
           interface comes in with a NULL user, call this routine with
           it.  Note that the message will still be freed by the
@@ -338,13 +359,6 @@ struct ipmi_smi
 };
 #define to_si_intf_from_dev(device) container_of(device, struct ipmi_smi, dev)
 
-/* Used to mark an interface entry that cannot be used but is not a
- * free entry, either, primarily used at creation and deletion time so
- * a slot doesn't get reused too quickly. */
-#define IPMI_INVALID_INTERFACE_ENTRY ((ipmi_smi_t) ((long) 1))
-#define IPMI_INVALID_INTERFACE(i) (((i) == NULL) \
-                                  || (i == IPMI_INVALID_INTERFACE_ENTRY))
-
 /**
  * The driver model view of the IPMI messaging driver.
  */
@@ -354,16 +368,13 @@ static struct device_driver ipmidriver = {
 };
 static DEFINE_MUTEX(ipmidriver_mutex);
 
-#define MAX_IPMI_INTERFACES 4
-static ipmi_smi_t ipmi_interfaces[MAX_IPMI_INTERFACES];
-
-/* Directly protects the ipmi_interfaces data structure. */
-static DEFINE_SPINLOCK(interfaces_lock);
+static struct list_head ipmi_interfaces = LIST_HEAD_INIT(ipmi_interfaces);
+static DEFINE_MUTEX(ipmi_interfaces_mutex);
 
 /* List of watchers that want to know when smi's are added and
    deleted. */
 static struct list_head smi_watchers = LIST_HEAD_INIT(smi_watchers);
-static DECLARE_RWSEM(smi_watchers_sem);
+static DEFINE_MUTEX(smi_watchers_mutex);
 
 
 static void free_recv_msg_list(struct list_head *q)
@@ -423,48 +434,84 @@ static void intf_free(struct kref *ref)
        kfree(intf);
 }
 
+struct watcher_entry {
+       int              intf_num;
+       ipmi_smi_t       intf;
+       struct list_head link;
+};
+
 int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher)
 {
-       int           i;
-       unsigned long flags;
+       ipmi_smi_t intf;
+       struct list_head to_deliver = LIST_HEAD_INIT(to_deliver);
+       struct watcher_entry *e, *e2;
+
+       mutex_lock(&smi_watchers_mutex);
+
+       mutex_lock(&ipmi_interfaces_mutex);
 
-       down_write(&smi_watchers_sem);
-       list_add(&(watcher->link), &smi_watchers);
-       up_write(&smi_watchers_sem);
-       spin_lock_irqsave(&interfaces_lock, flags);
-       for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
-               ipmi_smi_t intf = ipmi_interfaces[i];
-               if (IPMI_INVALID_INTERFACE(intf))
+       /* Build a list of things to deliver. */
+       list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
+               if (intf->intf_num == -1)
                        continue;
-               spin_unlock_irqrestore(&interfaces_lock, flags);
-               watcher->new_smi(i, intf->si_dev);
-               spin_lock_irqsave(&interfaces_lock, flags);
+               e = kmalloc(sizeof(*e), GFP_KERNEL);
+               if (!e)
+                       goto out_err;
+               kref_get(&intf->refcount);
+               e->intf = intf;
+               e->intf_num = intf->intf_num;
+               list_add_tail(&e->link, &to_deliver);
        }
-       spin_unlock_irqrestore(&interfaces_lock, flags);
+
+       /* We will succeed, so add it to the list. */
+       list_add(&watcher->link, &smi_watchers);
+
+       mutex_unlock(&ipmi_interfaces_mutex);
+
+       list_for_each_entry_safe(e, e2, &to_deliver, link) {
+               list_del(&e->link);
+               watcher->new_smi(e->intf_num, e->intf->si_dev);
+               kref_put(&e->intf->refcount, intf_free);
+               kfree(e);
+       }
+
+       mutex_unlock(&smi_watchers_mutex);
+
        return 0;
+
+ out_err:
+       mutex_unlock(&ipmi_interfaces_mutex);
+       mutex_unlock(&smi_watchers_mutex);
+       list_for_each_entry_safe(e, e2, &to_deliver, link) {
+               list_del(&e->link);
+               kref_put(&e->intf->refcount, intf_free);
+               kfree(e);
+       }
+       return -ENOMEM;
 }
 
 int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher)
 {
-       down_write(&smi_watchers_sem);
+       mutex_lock(&smi_watchers_mutex);
        list_del(&(watcher->link));
-       up_write(&smi_watchers_sem);
+       mutex_unlock(&smi_watchers_mutex);
        return 0;
 }
 
+/*
+ * Must be called with smi_watchers_mutex held.
+ */
 static void
 call_smi_watchers(int i, struct device *dev)
 {
        struct ipmi_smi_watcher *w;
 
-       down_read(&smi_watchers_sem);
        list_for_each_entry(w, &smi_watchers, link) {
                if (try_module_get(w->owner)) {
                        w->new_smi(i, dev);
                        module_put(w->owner);
                }
        }
-       up_read(&smi_watchers_sem);
 }
 
 static int
@@ -590,6 +637,17 @@ static void deliver_response(struct ipmi_recv_msg *msg)
        }
 }
 
+static void
+deliver_err_response(struct ipmi_recv_msg *msg, int err)
+{
+       msg->recv_type = IPMI_RESPONSE_RECV_TYPE;
+       msg->msg_data[0] = err;
+       msg->msg.netfn |= 1; /* Convert to a response. */
+       msg->msg.data_len = 1;
+       msg->msg.data = msg->msg_data;
+       deliver_response(msg);
+}
+
 /* Find the next sequence number not being used and add the given
    message with the given timeout to the sequence table.  This must be
    called with the interface's seq_lock held. */
@@ -727,14 +785,8 @@ static int intf_err_seq(ipmi_smi_t   intf,
        }
        spin_unlock_irqrestore(&(intf->seq_lock), flags);
 
-       if (msg) {
-               msg->recv_type = IPMI_RESPONSE_RECV_TYPE;
-               msg->msg_data[0] = err;
-               msg->msg.netfn |= 1; /* Convert to a response. */
-               msg->msg.data_len = 1;
-               msg->msg.data = msg->msg_data;
-               deliver_response(msg);
-       }
+       if (msg)
+               deliver_err_response(msg, err);
 
        return rv;
 }
@@ -776,17 +828,18 @@ int ipmi_create_user(unsigned int          if_num,
        if (!new_user)
                return -ENOMEM;
 
-       spin_lock_irqsave(&interfaces_lock, flags);
-       intf = ipmi_interfaces[if_num];
-       if ((if_num >= MAX_IPMI_INTERFACES) || IPMI_INVALID_INTERFACE(intf)) {
-               spin_unlock_irqrestore(&interfaces_lock, flags);
-               rv = -EINVAL;
-               goto out_kfree;
+       mutex_lock(&ipmi_interfaces_mutex);
+       list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
+               if (intf->intf_num == if_num)
+                       goto found;
        }
+       /* Not found, return an error */
+       rv = -EINVAL;
+       goto out_kfree;
 
+ found:
        /* Note that each existing user holds a refcount to the interface. */
        kref_get(&intf->refcount);
-       spin_unlock_irqrestore(&interfaces_lock, flags);
 
        kref_init(&new_user->refcount);
        new_user->handler = handler;
@@ -807,6 +860,10 @@ int ipmi_create_user(unsigned int          if_num,
                }
        }
 
+       /* Hold the lock so intf->handlers is guaranteed to be good
+        * until now */
+       mutex_unlock(&ipmi_interfaces_mutex);
+
        new_user->valid = 1;
        spin_lock_irqsave(&intf->seq_lock, flags);
        list_add_rcu(&new_user->link, &intf->users);
@@ -817,6 +874,7 @@ int ipmi_create_user(unsigned int          if_num,
 out_kref:
        kref_put(&intf->refcount, intf_free);
 out_kfree:
+       mutex_unlock(&ipmi_interfaces_mutex);
        kfree(new_user);
        return rv;
 }
@@ -846,6 +904,7 @@ int ipmi_destroy_user(ipmi_user_t user)
                    && (intf->seq_table[i].recv_msg->user == user))
                {
                        intf->seq_table[i].inuse = 0;
+                       ipmi_free_recv_msg(intf->seq_table[i].recv_msg);
                }
        }
        spin_unlock_irqrestore(&intf->seq_lock, flags);
@@ -872,9 +931,13 @@ int ipmi_destroy_user(ipmi_user_t user)
                kfree(rcvr);
        }
 
-       module_put(intf->handlers->owner);
-       if (intf->handlers->dec_usecount)
-               intf->handlers->dec_usecount(intf->send_info);
+       mutex_lock(&ipmi_interfaces_mutex);
+       if (intf->handlers) {
+               module_put(intf->handlers->owner);
+               if (intf->handlers->dec_usecount)
+                       intf->handlers->dec_usecount(intf->send_info);
+       }
+       mutex_unlock(&ipmi_interfaces_mutex);
 
        kref_put(&intf->refcount, intf_free);
 
@@ -887,8 +950,8 @@ void ipmi_get_version(ipmi_user_t   user,
                      unsigned char *major,
                      unsigned char *minor)
 {
-       *major = ipmi_version_major(&user->intf->bmc->id);
-       *minor = ipmi_version_minor(&user->intf->bmc->id);
+       *major = user->intf->ipmi_version_major;
+       *minor = user->intf->ipmi_version_minor;
 }
 
 int ipmi_set_my_address(ipmi_user_t   user,
@@ -931,6 +994,65 @@ int ipmi_get_my_LUN(ipmi_user_t   user,
        return 0;
 }
 
+int ipmi_get_maintenance_mode(ipmi_user_t user)
+{
+       int           mode;
+       unsigned long flags;
+
+       spin_lock_irqsave(&user->intf->maintenance_mode_lock, flags);
+       mode = user->intf->maintenance_mode;
+       spin_unlock_irqrestore(&user->intf->maintenance_mode_lock, flags);
+
+       return mode;
+}
+EXPORT_SYMBOL(ipmi_get_maintenance_mode);
+
+static void maintenance_mode_update(ipmi_smi_t intf)
+{
+       if (intf->handlers->set_maintenance_mode)
+               intf->handlers->set_maintenance_mode(
+                       intf->send_info, intf->maintenance_mode_enable);
+}
+
+int ipmi_set_maintenance_mode(ipmi_user_t user, int mode)
+{
+       int           rv = 0;
+       unsigned long flags;
+       ipmi_smi_t    intf = user->intf;
+
+       spin_lock_irqsave(&intf->maintenance_mode_lock, flags);
+       if (intf->maintenance_mode != mode) {
+               switch (mode) {
+               case IPMI_MAINTENANCE_MODE_AUTO:
+                       intf->maintenance_mode = mode;
+                       intf->maintenance_mode_enable
+                               = (intf->auto_maintenance_timeout > 0);
+                       break;
+
+               case IPMI_MAINTENANCE_MODE_OFF:
+                       intf->maintenance_mode = mode;
+                       intf->maintenance_mode_enable = 0;
+                       break;
+
+               case IPMI_MAINTENANCE_MODE_ON:
+                       intf->maintenance_mode = mode;
+                       intf->maintenance_mode_enable = 1;
+                       break;
+
+               default:
+                       rv = -EINVAL;
+                       goto out_unlock;
+               }
+
+               maintenance_mode_update(intf);
+       }
+ out_unlock:
+       spin_unlock_irqrestore(&intf->maintenance_mode_lock, flags);
+
+       return rv;
+}
+EXPORT_SYMBOL(ipmi_set_maintenance_mode);
+
 int ipmi_set_gets_events(ipmi_user_t user, int val)
 {
        unsigned long        flags;
@@ -943,20 +1065,33 @@ int ipmi_set_gets_events(ipmi_user_t user, int val)
        spin_lock_irqsave(&intf->events_lock, flags);
        user->gets_events = val;
 
-       if (val) {
-               /* Deliver any queued events. */
+       if (intf->delivering_events)
+               /*
+                * Another thread is delivering events for this, so
+                * let it handle any new events.
+                */
+               goto out;
+
+       /* Deliver any queued events. */
+       while (user->gets_events && !list_empty(&intf->waiting_events)) {
                list_for_each_entry_safe(msg, msg2, &intf->waiting_events, link)
                        list_move_tail(&msg->link, &msgs);
                intf->waiting_events_count = 0;
-       }
 
-       /* Hold the events lock while doing this to preserve order. */
-       list_for_each_entry_safe(msg, msg2, &msgs, link) {
-               msg->user = user;
-               kref_get(&user->refcount);
-               deliver_response(msg);
+               intf->delivering_events = 1;
+               spin_unlock_irqrestore(&intf->events_lock, flags);
+
+               list_for_each_entry_safe(msg, msg2, &msgs, link) {
+                       msg->user = user;
+                       kref_get(&user->refcount);
+                       deliver_response(msg);
+               }
+
+               spin_lock_irqsave(&intf->events_lock, flags);
+               intf->delivering_events = 0;
        }
 
+ out:
        spin_unlock_irqrestore(&intf->events_lock, flags);
 
        return 0;
@@ -1067,7 +1202,8 @@ int ipmi_unregister_for_cmd(ipmi_user_t   user,
 void ipmi_user_set_run_to_completion(ipmi_user_t user, int val)
 {
        ipmi_smi_t intf = user->intf;
-       intf->handlers->set_run_to_completion(intf->send_info, val);
+       if (intf->handlers)
+               intf->handlers->set_run_to_completion(intf->send_info, val);
 }
 
 static unsigned char
@@ -1178,10 +1314,11 @@ static int i_ipmi_request(ipmi_user_t          user,
                          int                  retries,
                          unsigned int         retry_time_ms)
 {
-       int                  rv = 0;
-       struct ipmi_smi_msg  *smi_msg;
-       struct ipmi_recv_msg *recv_msg;
-       unsigned long        flags;
+       int                      rv = 0;
+       struct ipmi_smi_msg      *smi_msg;
+       struct ipmi_recv_msg     *recv_msg;
+       unsigned long            flags;
+       struct ipmi_smi_handlers *handlers;
 
 
        if (supplied_recv) {
@@ -1204,6 +1341,13 @@ static int i_ipmi_request(ipmi_user_t          user,
                }
        }
 
+       rcu_read_lock();
+       handlers = intf->handlers;
+       if (!handlers) {
+               rv = -ENODEV;
+               goto out_err;
+       }
+
        recv_msg->user = user;
        if (user)
                kref_get(&user->refcount);
@@ -1246,6 +1390,24 @@ static int i_ipmi_request(ipmi_user_t          user,
                        goto out_err;
                }
 
+               if (((msg->netfn == IPMI_NETFN_APP_REQUEST)
+                     && ((msg->cmd == IPMI_COLD_RESET_CMD)
+                         || (msg->cmd == IPMI_WARM_RESET_CMD)))
+                    || (msg->netfn == IPMI_NETFN_FIRMWARE_REQUEST))
+               {
+                       spin_lock_irqsave(&intf->maintenance_mode_lock, flags);
+                       intf->auto_maintenance_timeout
+                               = IPMI_MAINTENANCE_MODE_TIMEOUT;
+                       if (!intf->maintenance_mode
+                           && !intf->maintenance_mode_enable)
+                       {
+                               intf->maintenance_mode_enable = 1;
+                               maintenance_mode_update(intf);
+                       }
+                       spin_unlock_irqrestore(&intf->maintenance_mode_lock,
+                                              flags);
+               }
+
                if ((msg->data_len + 2) > IPMI_MAX_MSG_LENGTH) {
                        spin_lock_irqsave(&intf->counter_lock, flags);
                        intf->sent_invalid_commands++;
@@ -1520,11 +1682,14 @@ static int i_ipmi_request(ipmi_user_t          user,
                printk("\n");
        }
 #endif
-       intf->handlers->sender(intf->send_info, smi_msg, priority);
+
+       handlers->sender(intf->send_info, smi_msg, priority);
+       rcu_read_unlock();
 
        return 0;
 
  out_err:
+       rcu_read_unlock();
        ipmi_free_smi_msg(smi_msg);
        ipmi_free_recv_msg(recv_msg);
        return rv;
@@ -1604,6 +1769,7 @@ int ipmi_request_supply_msgs(ipmi_user_t          user,
                              -1, 0);
 }
 
+#ifdef CONFIG_PROC_FS
 static int ipmb_file_read_proc(char *page, char **start, off_t off,
                               int count, int *eof, void *data)
 {
@@ -1692,6 +1858,7 @@ static int stat_file_read_proc(char *page, char **start, off_t off,
 
        return (out - ((char *) page));
 }
+#endif /* CONFIG_PROC_FS */
 
 int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
                            read_proc_t *read_proc, write_proc_t *write_proc,
@@ -1817,13 +1984,12 @@ static int __find_bmc_prod_dev_id(struct device *dev, void *data)
        struct bmc_device *bmc = dev_get_drvdata(dev);
 
        return (bmc->id.product_id == id->product_id
-               && bmc->id.product_id == id->product_id
                && bmc->id.device_id == id->device_id);
 }
 
 static struct bmc_device *ipmi_find_bmc_prod_dev_id(
        struct device_driver *drv,
-       unsigned char product_id, unsigned char device_id)
+       unsigned int product_id, unsigned char device_id)
 {
        struct prod_dev_id id = {
                .product_id = product_id,
@@ -1940,6 +2106,9 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr,
 
 static void remove_files(struct bmc_device *bmc)
 {
+       if (!bmc->dev)
+               return;
+
        device_remove_file(&bmc->dev->dev,
                           &bmc->device_id_attr);
        device_remove_file(&bmc->dev->dev,
@@ -1973,7 +2142,8 @@ cleanup_bmc_device(struct kref *ref)
        bmc = container_of(ref, struct bmc_device, refcount);
 
        remove_files(bmc);
-       platform_device_unregister(bmc->dev);
+       if (bmc->dev)
+               platform_device_unregister(bmc->dev);
        kfree(bmc);
 }
 
@@ -1981,7 +2151,11 @@ static void ipmi_bmc_unregister(ipmi_smi_t intf)
 {
        struct bmc_device *bmc = intf->bmc;
 
-       sysfs_remove_link(&intf->si_dev->kobj, "bmc");
+       if (intf->sysfs_name) {
+               sysfs_remove_link(&intf->si_dev->kobj, intf->sysfs_name);
+               kfree(intf->sysfs_name);
+               intf->sysfs_name = NULL;
+       }
        if (intf->my_dev_name) {
                sysfs_remove_link(&bmc->dev->dev.kobj, intf->my_dev_name);
                kfree(intf->my_dev_name);
@@ -1990,6 +2164,7 @@ static void ipmi_bmc_unregister(ipmi_smi_t intf)
 
        mutex_lock(&ipmidriver_mutex);
        kref_put(&bmc->refcount, cleanup_bmc_device);
+       intf->bmc = NULL;
        mutex_unlock(&ipmidriver_mutex);
 }
 
@@ -1997,6 +2172,56 @@ static int create_files(struct bmc_device *bmc)
 {
        int err;
 
+       bmc->device_id_attr.attr.name = "device_id";
+       bmc->device_id_attr.attr.owner = THIS_MODULE;
+       bmc->device_id_attr.attr.mode = S_IRUGO;
+       bmc->device_id_attr.show = device_id_show;
+
+       bmc->provides_dev_sdrs_attr.attr.name = "provides_device_sdrs";
+       bmc->provides_dev_sdrs_attr.attr.owner = THIS_MODULE;
+       bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO;
+       bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show;
+
+       bmc->revision_attr.attr.name = "revision";
+       bmc->revision_attr.attr.owner = THIS_MODULE;
+       bmc->revision_attr.attr.mode = S_IRUGO;
+       bmc->revision_attr.show = revision_show;
+
+       bmc->firmware_rev_attr.attr.name = "firmware_revision";
+       bmc->firmware_rev_attr.attr.owner = THIS_MODULE;
+       bmc->firmware_rev_attr.attr.mode = S_IRUGO;
+       bmc->firmware_rev_attr.show = firmware_rev_show;
+
+       bmc->version_attr.attr.name = "ipmi_version";
+       bmc->version_attr.attr.owner = THIS_MODULE;
+       bmc->version_attr.attr.mode = S_IRUGO;
+       bmc->version_attr.show = ipmi_version_show;
+
+       bmc->add_dev_support_attr.attr.name = "additional_device_support";
+       bmc->add_dev_support_attr.attr.owner = THIS_MODULE;
+       bmc->add_dev_support_attr.attr.mode = S_IRUGO;
+       bmc->add_dev_support_attr.show = add_dev_support_show;
+
+       bmc->manufacturer_id_attr.attr.name = "manufacturer_id";
+       bmc->manufacturer_id_attr.attr.owner = THIS_MODULE;
+       bmc->manufacturer_id_attr.attr.mode = S_IRUGO;
+       bmc->manufacturer_id_attr.show = manufacturer_id_show;
+
+       bmc->product_id_attr.attr.name = "product_id";
+       bmc->product_id_attr.attr.owner = THIS_MODULE;
+       bmc->product_id_attr.attr.mode = S_IRUGO;
+       bmc->product_id_attr.show = product_id_show;
+
+       bmc->guid_attr.attr.name = "guid";
+       bmc->guid_attr.attr.owner = THIS_MODULE;
+       bmc->guid_attr.attr.mode = S_IRUGO;
+       bmc->guid_attr.show = guid_show;
+
+       bmc->aux_firmware_rev_attr.attr.name = "aux_firmware_revision";
+       bmc->aux_firmware_rev_attr.attr.owner = THIS_MODULE;
+       bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO;
+       bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show;
+
        err = device_create_file(&bmc->dev->dev,
                           &bmc->device_id_attr);
        if (err) goto out;
@@ -2066,7 +2291,8 @@ out:
        return err;
 }
 
-static int ipmi_bmc_register(ipmi_smi_t intf)
+static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum,
+                            const char *sysfs_name)
 {
        int               rv;
        struct bmc_device *bmc = intf->bmc;
@@ -2106,9 +2332,39 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
                       bmc->id.product_id,
                       bmc->id.device_id);
        } else {
-               bmc->dev = platform_device_alloc("ipmi_bmc",
-                                                bmc->id.device_id);
+               char name[14];
+               unsigned char orig_dev_id = bmc->id.device_id;
+               int warn_printed = 0;
+
+               snprintf(name, sizeof(name),
+                        "ipmi_bmc.%4.4x", bmc->id.product_id);
+
+               while (ipmi_find_bmc_prod_dev_id(&ipmidriver,
+                                                bmc->id.product_id,
+                                                bmc->id.device_id))
+               {
+                       if (!warn_printed) {
+                               printk(KERN_WARNING PFX
+                                      "This machine has two different BMCs"
+                                      " with the same product id and device"
+                                      " id.  This is an error in the"
+                                      " firmware, but incrementing the"
+                                      " device id to work around the problem."
+                                      " Prod ID = 0x%x, Dev ID = 0x%x\n",
+                                      bmc->id.product_id, bmc->id.device_id);
+                               warn_printed = 1;
+                       }
+                       bmc->id.device_id++; /* Wraps at 255 */
+                       if (bmc->id.device_id == orig_dev_id) {
+                               printk(KERN_ERR PFX
+                                      "Out of device ids!\n");
+                               break;
+                       }
+               }
+
+               bmc->dev = platform_device_alloc(name, bmc->id.device_id);
                if (!bmc->dev) {
+                       mutex_unlock(&ipmidriver_mutex);
                        printk(KERN_ERR
                               "ipmi_msghandler:"
                               " Unable to allocate platform device\n");
@@ -2121,6 +2377,8 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
                rv = platform_device_add(bmc->dev);
                mutex_unlock(&ipmidriver_mutex);
                if (rv) {
+                       platform_device_put(bmc->dev);
+                       bmc->dev = NULL;
                        printk(KERN_ERR
                               "ipmi_msghandler:"
                               " Unable to register bmc device: %d\n",
@@ -2130,57 +2388,6 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
                        return rv;
                }
 
-               bmc->device_id_attr.attr.name = "device_id";
-               bmc->device_id_attr.attr.owner = THIS_MODULE;
-               bmc->device_id_attr.attr.mode = S_IRUGO;
-               bmc->device_id_attr.show = device_id_show;
-
-               bmc->provides_dev_sdrs_attr.attr.name = "provides_device_sdrs";
-               bmc->provides_dev_sdrs_attr.attr.owner = THIS_MODULE;
-               bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO;
-               bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show;
-
-               bmc->revision_attr.attr.name = "revision";
-               bmc->revision_attr.attr.owner = THIS_MODULE;
-               bmc->revision_attr.attr.mode = S_IRUGO;
-               bmc->revision_attr.show = revision_show;
-
-               bmc->firmware_rev_attr.attr.name = "firmware_revision";
-               bmc->firmware_rev_attr.attr.owner = THIS_MODULE;
-               bmc->firmware_rev_attr.attr.mode = S_IRUGO;
-               bmc->firmware_rev_attr.show = firmware_rev_show;
-
-               bmc->version_attr.attr.name = "ipmi_version";
-               bmc->version_attr.attr.owner = THIS_MODULE;
-               bmc->version_attr.attr.mode = S_IRUGO;
-               bmc->version_attr.show = ipmi_version_show;
-
-               bmc->add_dev_support_attr.attr.name
-                       = "additional_device_support";
-               bmc->add_dev_support_attr.attr.owner = THIS_MODULE;
-               bmc->add_dev_support_attr.attr.mode = S_IRUGO;
-               bmc->add_dev_support_attr.show = add_dev_support_show;
-
-               bmc->manufacturer_id_attr.attr.name = "manufacturer_id";
-               bmc->manufacturer_id_attr.attr.owner = THIS_MODULE;
-               bmc->manufacturer_id_attr.attr.mode = S_IRUGO;
-               bmc->manufacturer_id_attr.show = manufacturer_id_show;
-
-               bmc->product_id_attr.attr.name = "product_id";
-               bmc->product_id_attr.attr.owner = THIS_MODULE;
-               bmc->product_id_attr.attr.mode = S_IRUGO;
-               bmc->product_id_attr.show = product_id_show;
-
-               bmc->guid_attr.attr.name = "guid";
-               bmc->guid_attr.attr.owner = THIS_MODULE;
-               bmc->guid_attr.attr.mode = S_IRUGO;
-               bmc->guid_attr.show = guid_show;
-
-               bmc->aux_firmware_rev_attr.attr.name = "aux_firmware_revision";
-               bmc->aux_firmware_rev_attr.attr.owner = THIS_MODULE;
-               bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO;
-               bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show;
-
                rv = create_files(bmc);
                if (rv) {
                        mutex_lock(&ipmidriver_mutex);
@@ -2202,29 +2409,44 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
         * create symlink from system interface device to bmc device
         * and back.
         */
+       intf->sysfs_name = kstrdup(sysfs_name, GFP_KERNEL);
+       if (!intf->sysfs_name) {
+               rv = -ENOMEM;
+               printk(KERN_ERR
+                      "ipmi_msghandler: allocate link to BMC: %d\n",
+                      rv);
+               goto out_err;
+       }
+
        rv = sysfs_create_link(&intf->si_dev->kobj,
-                              &bmc->dev->dev.kobj, "bmc");
+                              &bmc->dev->dev.kobj, intf->sysfs_name);
        if (rv) {
+               kfree(intf->sysfs_name);
+               intf->sysfs_name = NULL;
                printk(KERN_ERR
                       "ipmi_msghandler: Unable to create bmc symlink: %d\n",
                       rv);
                goto out_err;
        }
 
-       size = snprintf(dummy, 0, "ipmi%d", intf->intf_num);
+       size = snprintf(dummy, 0, "ipmi%d", ifnum);
        intf->my_dev_name = kmalloc(size+1, GFP_KERNEL);
        if (!intf->my_dev_name) {
+               kfree(intf->sysfs_name);
+               intf->sysfs_name = NULL;
                rv = -ENOMEM;
                printk(KERN_ERR
                       "ipmi_msghandler: allocate link from BMC: %d\n",
                       rv);
                goto out_err;
        }
-       snprintf(intf->my_dev_name, size+1, "ipmi%d", intf->intf_num);
+       snprintf(intf->my_dev_name, size+1, "ipmi%d", ifnum);
 
        rv = sysfs_create_link(&bmc->dev->dev.kobj, &intf->si_dev->kobj,
                               intf->my_dev_name);
        if (rv) {
+               kfree(intf->sysfs_name);
+               intf->sysfs_name = NULL;
                kfree(intf->my_dev_name);
                intf->my_dev_name = NULL;
                printk(KERN_ERR
@@ -2409,17 +2631,14 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
                      void                     *send_info,
                      struct ipmi_device_id    *device_id,
                      struct device            *si_dev,
+                     const char               *sysfs_name,
                      unsigned char            slave_addr)
 {
        int              i, j;
        int              rv;
        ipmi_smi_t       intf;
-       unsigned long    flags;
-       int              version_major;
-       int              version_minor;
-
-       version_major = ipmi_version_major(device_id);
-       version_minor = ipmi_version_minor(device_id);
+       ipmi_smi_t       tintf;
+       struct list_head *link;
 
        /* Make sure the driver is actually initialized, this handles
           problems with initialization order. */
@@ -2437,12 +2656,16 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
        if (!intf)
                return -ENOMEM;
        memset(intf, 0, sizeof(*intf));
+
+       intf->ipmi_version_major = ipmi_version_major(device_id);
+       intf->ipmi_version_minor = ipmi_version_minor(device_id);
+
        intf->bmc = kzalloc(sizeof(*intf->bmc), GFP_KERNEL);
        if (!intf->bmc) {
                kfree(intf);
                return -ENOMEM;
        }
-       intf->intf_num = -1;
+       intf->intf_num = -1; /* Mark it invalid for now. */
        kref_init(&intf->refcount);
        intf->bmc->id = *device_id;
        intf->si_dev = si_dev;
@@ -2470,26 +2693,30 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
        INIT_LIST_HEAD(&intf->waiting_events);
        intf->waiting_events_count = 0;
        mutex_init(&intf->cmd_rcvrs_mutex);
+       spin_lock_init(&intf->maintenance_mode_lock);
        INIT_LIST_HEAD(&intf->cmd_rcvrs);
        init_waitqueue_head(&intf->waitq);
 
        spin_lock_init(&intf->counter_lock);
        intf->proc_dir = NULL;
 
-       rv = -ENOMEM;
-       spin_lock_irqsave(&interfaces_lock, flags);
-       for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
-               if (ipmi_interfaces[i] == NULL) {
-                       intf->intf_num = i;
-                       /* Reserve the entry till we are done. */
-                       ipmi_interfaces[i] = IPMI_INVALID_INTERFACE_ENTRY;
-                       rv = 0;
+       mutex_lock(&smi_watchers_mutex);
+       mutex_lock(&ipmi_interfaces_mutex);
+       /* Look for a hole in the numbers. */
+       i = 0;
+       link = &ipmi_interfaces;
+       list_for_each_entry_rcu(tintf, &ipmi_interfaces, link) {
+               if (tintf->intf_num != i) {
+                       link = &tintf->link;
                        break;
                }
+               i++;
        }
-       spin_unlock_irqrestore(&interfaces_lock, flags);
-       if (rv)
-               goto out;
+       /* Add the new interface in numeric order. */
+       if (i == 0)
+               list_add_rcu(&intf->link, &ipmi_interfaces);
+       else
+               list_add_tail_rcu(&intf->link, link);
 
        rv = handlers->start_processing(send_info, intf);
        if (rv)
@@ -2497,8 +2724,9 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
 
        get_guid(intf);
 
-       if ((version_major > 1)
-           || ((version_major == 1) && (version_minor >= 5)))
+       if ((intf->ipmi_version_major > 1)
+           || ((intf->ipmi_version_major == 1)
+               && (intf->ipmi_version_minor >= 5)))
        {
                /* Start scanning the channels to see what is
                   available. */
@@ -2521,64 +2749,67 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
        if (rv == 0)
                rv = add_proc_entries(intf, i);
 
-       rv = ipmi_bmc_register(intf);
+       rv = ipmi_bmc_register(intf, i, sysfs_name);
 
  out:
        if (rv) {
                if (intf->proc_dir)
                        remove_proc_entries(intf);
+               intf->handlers = NULL;
+               list_del_rcu(&intf->link);
+               mutex_unlock(&ipmi_interfaces_mutex);
+               mutex_unlock(&smi_watchers_mutex);
+               synchronize_rcu();
                kref_put(&intf->refcount, intf_free);
-               if (i < MAX_IPMI_INTERFACES) {
-                       spin_lock_irqsave(&interfaces_lock, flags);
-                       ipmi_interfaces[i] = NULL;
-                       spin_unlock_irqrestore(&interfaces_lock, flags);
-               }
        } else {
-               spin_lock_irqsave(&interfaces_lock, flags);
-               ipmi_interfaces[i] = intf;
-               spin_unlock_irqrestore(&interfaces_lock, flags);
+               /* After this point the interface is legal to use. */
+               intf->intf_num = i;
+               mutex_unlock(&ipmi_interfaces_mutex);
                call_smi_watchers(i, intf->si_dev);
+               mutex_unlock(&smi_watchers_mutex);
        }
 
        return rv;
 }
 
+static void cleanup_smi_msgs(ipmi_smi_t intf)
+{
+       int              i;
+       struct seq_table *ent;
+
+       /* No need for locks, the interface is down. */
+       for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) {
+               ent = &(intf->seq_table[i]);
+               if (!ent->inuse)
+                       continue;
+               deliver_err_response(ent->recv_msg, IPMI_ERR_UNSPECIFIED);
+       }
+}
+
 int ipmi_unregister_smi(ipmi_smi_t intf)
 {
-       int                     i;
        struct ipmi_smi_watcher *w;
-       unsigned long           flags;
+       int    intf_num = intf->intf_num;
 
        ipmi_bmc_unregister(intf);
 
-       spin_lock_irqsave(&interfaces_lock, flags);
-       for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
-               if (ipmi_interfaces[i] == intf) {
-                       /* Set the interface number reserved until we
-                        * are done. */
-                       ipmi_interfaces[i] = IPMI_INVALID_INTERFACE_ENTRY;
-                       intf->intf_num = -1;
-                       break;
-               }
-       }
-       spin_unlock_irqrestore(&interfaces_lock,flags);
+       mutex_lock(&smi_watchers_mutex);
+       mutex_lock(&ipmi_interfaces_mutex);
+       intf->intf_num = -1;
+       intf->handlers = NULL;
+       list_del_rcu(&intf->link);
+       mutex_unlock(&ipmi_interfaces_mutex);
+       synchronize_rcu();
 
-       if (i == MAX_IPMI_INTERFACES)
-               return -ENODEV;
+       cleanup_smi_msgs(intf);
 
        remove_proc_entries(intf);
 
        /* Call all the watcher interfaces to tell them that
           an interface is gone. */
-       down_read(&smi_watchers_sem);
        list_for_each_entry(w, &smi_watchers, link)
-               w->smi_gone(i);
-       up_read(&smi_watchers_sem);
-
-       /* Allow the entry to be reused now. */
-       spin_lock_irqsave(&interfaces_lock, flags);
-       ipmi_interfaces[i] = NULL;
-       spin_unlock_irqrestore(&interfaces_lock,flags);
+               w->smi_gone(intf_num);
+       mutex_unlock(&smi_watchers_mutex);
 
        kref_put(&intf->refcount, intf_free);
        return 0;
@@ -2660,6 +2891,7 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t          intf,
        struct ipmi_ipmb_addr    *ipmb_addr;
        struct ipmi_recv_msg     *recv_msg;
        unsigned long            flags;
+       struct ipmi_smi_handlers *handlers;
 
        if (msg->rsp_size < 10) {
                /* Message not big enough, just ignore it. */
@@ -2716,10 +2948,16 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t          intf,
                printk("\n");
        }
 #endif
-               intf->handlers->sender(intf->send_info, msg, 0);
-
-               rv = -1; /* We used the message, so return the value that
-                           causes it to not be freed or queued. */
+               rcu_read_lock();
+               handlers = intf->handlers;
+               if (handlers) {
+                       handlers->sender(intf->send_info, msg, 0);
+                       /* We used the message, so return the value
+                          that causes it to not be freed or
+                          queued. */
+                       rv = -1;
+               }
+               rcu_read_unlock();
        } else {
                /* Deliver the message to the user. */
                spin_lock_irqsave(&intf->counter_lock, flags);
@@ -3309,16 +3547,6 @@ void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf)
        rcu_read_unlock();
 }
 
-static void
-handle_msg_timeout(struct ipmi_recv_msg *msg)
-{
-       msg->recv_type = IPMI_RESPONSE_RECV_TYPE;
-       msg->msg_data[0] = IPMI_TIMEOUT_COMPLETION_CODE;
-       msg->msg.netfn |= 1; /* Convert to a response. */
-       msg->msg.data_len = 1;
-       msg->msg.data = msg->msg_data;
-       deliver_response(msg);
-}
 
 static struct ipmi_smi_msg *
 smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg,
@@ -3350,7 +3578,11 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent,
                              struct list_head *timeouts, long timeout_period,
                              int slot, unsigned long *flags)
 {
-       struct ipmi_recv_msg *msg;
+       struct ipmi_recv_msg     *msg;
+       struct ipmi_smi_handlers *handlers;
+
+       if (intf->intf_num == -1)
+               return;
 
        if (!ent->inuse)
                return;
@@ -3393,13 +3625,19 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent,
                        return;
 
                spin_unlock_irqrestore(&intf->seq_lock, *flags);
+
                /* Send the new message.  We send with a zero
                 * priority.  It timed out, I doubt time is
                 * that critical now, and high priority
                 * messages are really only for messages to the
                 * local MC, which don't get resent. */
-               intf->handlers->sender(intf->send_info,
-                                      smi_msg, 0);
+               handlers = intf->handlers;
+               if (handlers)
+                       intf->handlers->sender(intf->send_info,
+                                              smi_msg, 0);
+               else
+                       ipmi_free_smi_msg(smi_msg);
+
                spin_lock_irqsave(&intf->seq_lock, *flags);
        }
 }
@@ -3411,18 +3649,12 @@ static void ipmi_timeout_handler(long timeout_period)
        struct ipmi_recv_msg *msg, *msg2;
        struct ipmi_smi_msg  *smi_msg, *smi_msg2;
        unsigned long        flags;
-       int                  i, j;
+       int                  i;
 
        INIT_LIST_HEAD(&timeouts);
 
-       spin_lock(&interfaces_lock);
-       for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
-               intf = ipmi_interfaces[i];
-               if (IPMI_INVALID_INTERFACE(intf))
-                       continue;
-               kref_get(&intf->refcount);
-               spin_unlock(&interfaces_lock);
-
+       rcu_read_lock();
+       list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
                /* See if any waiting messages need to be processed. */
                spin_lock_irqsave(&intf->waiting_msgs_lock, flags);
                list_for_each_entry_safe(smi_msg, smi_msg2,
@@ -3442,35 +3674,60 @@ static void ipmi_timeout_handler(long timeout_period)
                   have timed out, putting them in the timeouts
                   list. */
                spin_lock_irqsave(&intf->seq_lock, flags);
-               for (j = 0; j < IPMI_IPMB_NUM_SEQ; j++)
-                       check_msg_timeout(intf, &(intf->seq_table[j]),
-                                         &timeouts, timeout_period, j,
+               for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++)
+                       check_msg_timeout(intf, &(intf->seq_table[i]),
+                                         &timeouts, timeout_period, i,
                                          &flags);
                spin_unlock_irqrestore(&intf->seq_lock, flags);
 
                list_for_each_entry_safe(msg, msg2, &timeouts, link)
-                       handle_msg_timeout(msg);
-
-               kref_put(&intf->refcount, intf_free);
-               spin_lock(&interfaces_lock);
+                       deliver_err_response(msg, IPMI_TIMEOUT_COMPLETION_CODE);
+
+               /*
+                * Maintenance mode handling.  Check the timeout
+                * optimistically before we claim the lock.  It may
+                * mean a timeout gets missed occasionally, but that
+                * only means the timeout gets extended by one period
+                * in that case.  No big deal, and it avoids the lock
+                * most of the time.
+                */
+               if (intf->auto_maintenance_timeout > 0) {
+                       spin_lock_irqsave(&intf->maintenance_mode_lock, flags);
+                       if (intf->auto_maintenance_timeout > 0) {
+                               intf->auto_maintenance_timeout
+                                       -= timeout_period;
+                               if (!intf->maintenance_mode
+                                   && (intf->auto_maintenance_timeout <= 0))
+                               {
+                                       intf->maintenance_mode_enable = 0;
+                                       maintenance_mode_update(intf);
+                               }
+                       }
+                       spin_unlock_irqrestore(&intf->maintenance_mode_lock,
+                                              flags);
+               }
        }
-       spin_unlock(&interfaces_lock);
+       rcu_read_unlock();
 }
 
 static void ipmi_request_event(void)
 {
-       ipmi_smi_t intf;
-       int        i;
+       ipmi_smi_t               intf;
+       struct ipmi_smi_handlers *handlers;
 
-       spin_lock(&interfaces_lock);
-       for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
-               intf = ipmi_interfaces[i];
-               if (IPMI_INVALID_INTERFACE(intf))
+       rcu_read_lock();
+       /* Called from the timer, no need to check if handlers is
+        * valid. */
+       list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
+               /* No event requests when in maintenance mode. */
+               if (intf->maintenance_mode_enable)
                        continue;
 
-               intf->handlers->request_events(intf->send_info);
+               handlers = intf->handlers;
+               if (handlers)
+                       handlers->request_events(intf->send_info);
        }
-       spin_unlock(&interfaces_lock);
+       rcu_read_unlock();
 }
 
 static struct timer_list ipmi_timer;
@@ -3599,7 +3856,6 @@ static void send_panic_events(char *str)
        struct kernel_ipmi_msg            msg;
        ipmi_smi_t                        intf;
        unsigned char                     data[16];
-       int                               i;
        struct ipmi_system_interface_addr *si;
        struct ipmi_addr                  addr;
        struct ipmi_smi_msg               smi_msg;
@@ -3633,9 +3889,9 @@ static void send_panic_events(char *str)
        recv_msg.done = dummy_recv_done_handler;
 
        /* For every registered interface, send the event. */
-       for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
-               intf = ipmi_interfaces[i];
-               if (IPMI_INVALID_INTERFACE(intf))
+       list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
+               if (!intf->handlers)
+                       /* Interface is not ready. */
                        continue;
 
                /* Send the event announcing the panic. */
@@ -3660,13 +3916,14 @@ static void send_panic_events(char *str)
        if (!str) 
                return;
 
-       for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
+       /* For every registered interface, send the event. */
+       list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
                char                  *p = str;
                struct ipmi_ipmb_addr *ipmb;
                int                   j;
 
-               intf = ipmi_interfaces[i];
-               if (IPMI_INVALID_INTERFACE(intf))
+               if (intf->intf_num == -1)
+                       /* Interface was not ready yet. */
                        continue;
 
                /* First job here is to figure out where to send the
@@ -3792,7 +4049,6 @@ static int panic_event(struct notifier_block *this,
                       unsigned long         event,
                        void                  *ptr)
 {
-       int        i;
        ipmi_smi_t intf;
 
        if (has_panicked)
@@ -3800,9 +4056,9 @@ static int panic_event(struct notifier_block *this,
        has_panicked = 1;
 
        /* For every registered interface, set it to run to completion. */
-       for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
-               intf = ipmi_interfaces[i];
-               if (IPMI_INVALID_INTERFACE(intf))
+       list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
+               if (!intf->handlers)
+                       /* Interface is not ready. */
                        continue;
 
                intf->handlers->set_run_to_completion(intf->send_info, 1);
@@ -3823,7 +4079,6 @@ static struct notifier_block panic_block = {
 
 static int ipmi_init_msghandler(void)
 {
-       int i;
        int rv;
 
        if (initialized)
@@ -3838,9 +4093,6 @@ static int ipmi_init_msghandler(void)
        printk(KERN_INFO "ipmi message handler version "
               IPMI_DRIVER_VERSION "\n");
 
-       for (i = 0; i < MAX_IPMI_INTERFACES; i++)
-               ipmi_interfaces[i] = NULL;
-
 #ifdef CONFIG_PROC_FS
        proc_ipmi_root = proc_mkdir("ipmi", NULL);
        if (!proc_ipmi_root) {
index 8d941db834570a98893af2a28ad5fc1ea01e11ec..597eb4f88b845b2c69f77b7d2e4508aaea0cd289 100644 (file)
@@ -43,6 +43,9 @@
 
 #define PFX "IPMI poweroff: "
 
+static void ipmi_po_smi_gone(int if_num);
+static void ipmi_po_new_smi(int if_num, struct device *device);
+
 /* Definitions for controlling power off (if the system supports it).  It
  * conveniently matches the IPMI chassis control values. */
 #define IPMI_CHASSIS_POWER_DOWN                0       /* power down, the default. */
 /* the IPMI data command */
 static int poweroff_powercycle;
 
+/* Which interface to use, -1 means the first we see. */
+static int ifnum_to_use = -1;
+
+/* Our local state. */
+static int ready = 0;
+static ipmi_user_t ipmi_user;
+static int ipmi_ifnum;
+static void (*specific_poweroff_func)(ipmi_user_t user) = NULL;
+
+/* Holds the old poweroff function so we can restore it on removal. */
+static void (*old_poweroff_func)(void);
+
+static int set_param_ifnum(const char *val, struct kernel_param *kp)
+{
+       int rv = param_set_int(val, kp);
+       if (rv)
+               return rv;
+       if ((ifnum_to_use < 0) || (ifnum_to_use == ipmi_ifnum))
+               return 0;
+
+       ipmi_po_smi_gone(ipmi_ifnum);
+       ipmi_po_new_smi(ifnum_to_use, NULL);
+       return 0;
+}
+
+module_param_call(ifnum_to_use, set_param_ifnum, param_get_int,
+                 &ifnum_to_use, 0644);
+MODULE_PARM_DESC(ifnum_to_use, "The interface number to use for the watchdog "
+                "timer.  Setting to -1 defaults to the first registered "
+                "interface");
+
 /* parameter definition to allow user to flag power cycle */
 module_param(poweroff_powercycle, int, 0644);
 MODULE_PARM_DESC(poweroff_powercycle, " Set to non-zero to enable power cycle instead of power down. Power cycle is contingent on hardware support, otherwise it defaults back to power down.");
@@ -142,6 +176,42 @@ static int ipmi_request_in_rc_mode(ipmi_user_t            user,
 #define IPMI_ATCA_GET_ADDR_INFO_CMD    0x01
 #define IPMI_PICMG_ID                  0
 
+#define IPMI_NETFN_OEM                         0x2e
+#define IPMI_ATCA_PPS_GRACEFUL_RESTART         0x11
+#define IPMI_ATCA_PPS_IANA                     "\x00\x40\x0A"
+#define IPMI_MOTOROLA_MANUFACTURER_ID          0x0000A1
+#define IPMI_MOTOROLA_PPS_IPMC_PRODUCT_ID      0x0051
+
+static void (*atca_oem_poweroff_hook)(ipmi_user_t user) = NULL;
+
+static void pps_poweroff_atca (ipmi_user_t user)
+{
+        struct ipmi_system_interface_addr smi_addr;
+        struct kernel_ipmi_msg            send_msg;
+        int                               rv;
+        /*
+         * Configure IPMI address for local access
+         */
+        smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
+        smi_addr.channel = IPMI_BMC_CHANNEL;
+        smi_addr.lun = 0;
+
+        printk(KERN_INFO PFX "PPS powerdown hook used");
+
+        send_msg.netfn = IPMI_NETFN_OEM;
+        send_msg.cmd = IPMI_ATCA_PPS_GRACEFUL_RESTART;
+        send_msg.data = IPMI_ATCA_PPS_IANA;
+        send_msg.data_len = 3;
+        rv = ipmi_request_in_rc_mode(user,
+                                  (struct ipmi_addr *) &smi_addr,
+                                   &send_msg);
+        if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE) {
+                printk(KERN_ERR PFX "Unable to send ATCA ,"
+                       " IPMI error 0x%x\n", rv);
+        }
+       return;
+}
+
 static int ipmi_atca_detect (ipmi_user_t user)
 {
        struct ipmi_system_interface_addr smi_addr;
@@ -167,6 +237,13 @@ static int ipmi_atca_detect (ipmi_user_t user)
        rv = ipmi_request_wait_for_response(user,
                                            (struct ipmi_addr *) &smi_addr,
                                            &send_msg);
+
+        printk(KERN_INFO PFX "ATCA Detect mfg 0x%X prod 0x%X\n", mfg_id, prod_id);
+        if((mfg_id == IPMI_MOTOROLA_MANUFACTURER_ID)
+            && (prod_id == IPMI_MOTOROLA_PPS_IPMC_PRODUCT_ID)) {
+               printk(KERN_INFO PFX "Installing Pigeon Point Systems Poweroff Hook\n");
+               atca_oem_poweroff_hook = pps_poweroff_atca;
+       }
        return !rv;
 }
 
@@ -200,12 +277,19 @@ static void ipmi_poweroff_atca (ipmi_user_t user)
        rv = ipmi_request_in_rc_mode(user,
                                     (struct ipmi_addr *) &smi_addr,
                                     &send_msg);
-       if (rv) {
+        /** At this point, the system may be shutting down, and most
+         ** serial drivers (if used) will have interrupts turned off
+         ** it may be better to ignore IPMI_UNKNOWN_ERR_COMPLETION_CODE
+         ** return code
+         **/
+        if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE) {
                printk(KERN_ERR PFX "Unable to send ATCA powerdown message,"
                       " IPMI error 0x%x\n", rv);
                goto out;
        }
 
+       if(atca_oem_poweroff_hook)
+               return atca_oem_poweroff_hook(user);
  out:
        return;
 }
@@ -440,15 +524,6 @@ static struct poweroff_function poweroff_functions[] = {
                      / sizeof(struct poweroff_function))
 
 
-/* Our local state. */
-static int ready = 0;
-static ipmi_user_t ipmi_user;
-static void (*specific_poweroff_func)(ipmi_user_t user) = NULL;
-
-/* Holds the old poweroff function so we can restore it on removal. */
-static void (*old_poweroff_func)(void);
-
-
 /* Called on a powerdown request. */
 static void ipmi_poweroff_function (void)
 {
@@ -473,6 +548,9 @@ static void ipmi_po_new_smi(int if_num, struct device *device)
        if (ready)
                return;
 
+       if ((ifnum_to_use >= 0) && (ifnum_to_use != if_num))
+               return;
+
        rv = ipmi_create_user(if_num, &ipmi_poweroff_handler, NULL,
                              &ipmi_user);
        if (rv) {
@@ -481,6 +559,8 @@ static void ipmi_po_new_smi(int if_num, struct device *device)
                return;
        }
 
+       ipmi_ifnum = if_num;
+
         /*
          * Do a get device ide and store some results, since this is
         * used by several functions.
@@ -541,9 +621,15 @@ static void ipmi_po_new_smi(int if_num, struct device *device)
 
 static void ipmi_po_smi_gone(int if_num)
 {
-       /* This can never be called, because once poweroff driver is
-          registered, the interface can't go away until the power
-          driver is unregistered. */
+       if (!ready)
+               return;
+
+       if (ipmi_ifnum != if_num)
+               return;
+
+       ready = 0;
+       ipmi_destroy_user(ipmi_user);
+       pm_power_off = old_poweroff_func;
 }
 
 static struct ipmi_smi_watcher smi_watcher =
@@ -616,9 +702,9 @@ static int ipmi_poweroff_init (void)
                printk(KERN_ERR PFX "Unable to register SMI watcher: %d\n", rv);
                goto out_err;
        }
-#endif
 
  out_err:
+#endif
        return rv;
 }
 
index bb1fac104fda63470bae62d5c068263c00a5f8e6..81a0c89598e790bc767b6552642da1dc69b3968f 100644 (file)
 #include "ipmi_si_sm.h"
 #include <linux/init.h>
 #include <linux/dmi.h>
+#include <linux/string.h>
+#include <linux/ctype.h>
+
+#define PFX "ipmi_si: "
 
 /* Measure times between events in the driver. */
 #undef DEBUG_TIMING
@@ -92,7 +96,7 @@ enum si_intf_state {
 enum si_type {
     SI_KCS, SI_SMIC, SI_BT
 };
-static char *si_to_str[] = { "KCS", "SMIC", "BT" };
+static char *si_to_str[] = { "kcs", "smic", "bt" };
 
 #define DEVICE_NAME "ipmi_si"
 
@@ -222,7 +226,10 @@ struct smi_info
 static int force_kipmid[SI_MAX_PARMS];
 static int num_force_kipmid;
 
+static int unload_when_empty = 1;
+
 static int try_smi_init(struct smi_info *smi);
+static void cleanup_one_si(struct smi_info *to_clean);
 
 static ATOMIC_NOTIFIER_HEAD(xaction_notifier_list);
 static int register_xaction_notifier(struct notifier_block * nb)
@@ -240,14 +247,18 @@ static void deliver_recv_msg(struct smi_info *smi_info,
        spin_lock(&(smi_info->si_lock));
 }
 
-static void return_hosed_msg(struct smi_info *smi_info)
+static void return_hosed_msg(struct smi_info *smi_info, int cCode)
 {
        struct ipmi_smi_msg *msg = smi_info->curr_msg;
 
+       if (cCode < 0 || cCode > IPMI_ERR_UNSPECIFIED)
+               cCode = IPMI_ERR_UNSPECIFIED;
+       /* else use it as is */
+
        /* Make it a reponse */
        msg->rsp[0] = msg->data[0] | 4;
        msg->rsp[1] = msg->data[1];
-       msg->rsp[2] = 0xFF; /* Unknown error. */
+       msg->rsp[2] = cCode;
        msg->rsp_size = 3;
 
        smi_info->curr_msg = NULL;
@@ -298,7 +309,7 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info)
                        smi_info->curr_msg->data,
                        smi_info->curr_msg->data_size);
                if (err) {
-                       return_hosed_msg(smi_info);
+                       return_hosed_msg(smi_info, err);
                }
 
                rv = SI_SM_CALL_WITHOUT_DELAY;
@@ -640,7 +651,7 @@ static enum si_sm_result smi_event_handler(struct smi_info *smi_info,
                        /* If we were handling a user message, format
                            a response to send to the upper layer to
                            tell it about the error. */
-                       return_hosed_msg(smi_info);
+                       return_hosed_msg(smi_info, IPMI_ERR_UNSPECIFIED);
                }
                si_sm_result = smi_info->handlers->event(smi_info->si_sm, 0);
        }
@@ -684,22 +695,24 @@ static enum si_sm_result smi_event_handler(struct smi_info *smi_info,
        {
                /* We are idle and the upper layer requested that I fetch
                   events, so do so. */
-               unsigned char msg[2];
+               atomic_set(&smi_info->req_events, 0);
 
-               spin_lock(&smi_info->count_lock);
-               smi_info->flag_fetches++;
-               spin_unlock(&smi_info->count_lock);
+               smi_info->curr_msg = ipmi_alloc_smi_msg();
+               if (!smi_info->curr_msg)
+                       goto out;
 
-               atomic_set(&smi_info->req_events, 0);
-               msg[0] = (IPMI_NETFN_APP_REQUEST << 2);
-               msg[1] = IPMI_GET_MSG_FLAGS_CMD;
+               smi_info->curr_msg->data[0] = (IPMI_NETFN_APP_REQUEST << 2);
+               smi_info->curr_msg->data[1] = IPMI_READ_EVENT_MSG_BUFFER_CMD;
+               smi_info->curr_msg->data_size = 2;
 
                smi_info->handlers->start_transaction(
-                       smi_info->si_sm, msg, 2);
-               smi_info->si_state = SI_GETTING_FLAGS;
+                       smi_info->si_sm,
+                       smi_info->curr_msg->data,
+                       smi_info->curr_msg->data_size);
+               smi_info->si_state = SI_GETTING_EVENTS;
                goto restart;
        }
-
+ out:
        return si_sm_result;
 }
 
@@ -714,6 +727,15 @@ static void sender(void                *send_info,
        struct timeval    t;
 #endif
 
+       if (atomic_read(&smi_info->stop_operation)) {
+               msg->rsp[0] = msg->data[0] | 4;
+               msg->rsp[1] = msg->data[1];
+               msg->rsp[2] = IPMI_ERR_UNSPECIFIED;
+               msg->rsp_size = 3;
+               deliver_recv_msg(smi_info, msg);
+               return;
+       }
+
        spin_lock_irqsave(&(smi_info->msg_lock), flags);
 #ifdef DEBUG_TIMING
        do_gettimeofday(&t);
@@ -805,13 +827,21 @@ static void poll(void *send_info)
 {
        struct smi_info *smi_info = send_info;
 
-       smi_event_handler(smi_info, 0);
+       /*
+        * Make sure there is some delay in the poll loop so we can
+        * drive time forward and timeout things.
+        */
+       udelay(10);
+       smi_event_handler(smi_info, 10);
 }
 
 static void request_events(void *send_info)
 {
        struct smi_info *smi_info = send_info;
 
+       if (atomic_read(&smi_info->stop_operation))
+               return;
+
        atomic_set(&smi_info->req_events, 1);
 }
 
@@ -949,12 +979,21 @@ static int smi_start_processing(void       *send_info,
        return 0;
 }
 
+static void set_maintenance_mode(void *send_info, int enable)
+{
+       struct smi_info   *smi_info = send_info;
+
+       if (!enable)
+               atomic_set(&smi_info->req_events, 0);
+}
+
 static struct ipmi_smi_handlers handlers =
 {
        .owner                  = THIS_MODULE,
        .start_processing       = smi_start_processing,
        .sender                 = sender,
        .request_events         = request_events,
+       .set_maintenance_mode   = set_maintenance_mode,
        .set_run_to_completion  = set_run_to_completion,
        .poll                   = poll,
 };
@@ -987,6 +1026,16 @@ static int num_regshifts = 0;
 static int slave_addrs[SI_MAX_PARMS];
 static int num_slave_addrs = 0;
 
+#define IPMI_IO_ADDR_SPACE  0
+#define IPMI_MEM_ADDR_SPACE 1
+static char *addr_space_to_str[] = { "I/O", "mem" };
+
+static int hotmod_handler(const char *val, struct kernel_param *kp);
+
+module_param_call(hotmod, hotmod_handler, NULL, NULL, 0200);
+MODULE_PARM_DESC(hotmod, "Add and remove interfaces.  See"
+                " Documentation/IPMI.txt in the kernel sources for the"
+                " gory details.");
 
 module_param_named(trydefaults, si_trydefaults, bool, 0);
 MODULE_PARM_DESC(trydefaults, "Setting this to 'false' will disable the"
@@ -1038,12 +1087,12 @@ module_param_array(force_kipmid, int, &num_force_kipmid, 0);
 MODULE_PARM_DESC(force_kipmid, "Force the kipmi daemon to be enabled (1) or"
                 " disabled(0).  Normally the IPMI driver auto-detects"
                 " this, but the value may be overridden by this parm.");
+module_param(unload_when_empty, int, 0);
+MODULE_PARM_DESC(unload_when_empty, "Unload the module if no interfaces are"
+                " specified or found, default is 1.  Setting to 0"
+                " is useful for hot add of devices using hotmod.");
 
 
-#define IPMI_IO_ADDR_SPACE  0
-#define IPMI_MEM_ADDR_SPACE 1
-static char *addr_space_to_str[] = { "I/O", "memory" };
-
 static void std_irq_cleanup(struct smi_info *info)
 {
        if (info->si_type == SI_BT)
@@ -1317,6 +1366,234 @@ static int mem_setup(struct smi_info *info)
        return 0;
 }
 
+/*
+ * Parms come in as <op1>[:op2[:op3...]].  ops are:
+ *   add|remove,kcs|bt|smic,mem|i/o,<address>[,<opt1>[,<opt2>[,...]]]
+ * Options are:
+ *   rsp=<regspacing>
+ *   rsi=<regsize>
+ *   rsh=<regshift>
+ *   irq=<irq>
+ *   ipmb=<ipmb addr>
+ */
+enum hotmod_op { HM_ADD, HM_REMOVE };
+struct hotmod_vals {
+       char *name;
+       int  val;
+};
+static struct hotmod_vals hotmod_ops[] = {
+       { "add",        HM_ADD },
+       { "remove",     HM_REMOVE },
+       { NULL }
+};
+static struct hotmod_vals hotmod_si[] = {
+       { "kcs",        SI_KCS },
+       { "smic",       SI_SMIC },
+       { "bt",         SI_BT },
+       { NULL }
+};
+static struct hotmod_vals hotmod_as[] = {
+       { "mem",        IPMI_MEM_ADDR_SPACE },
+       { "i/o",        IPMI_IO_ADDR_SPACE },
+       { NULL }
+};
+static int ipmi_strcasecmp(const char *s1, const char *s2)
+{
+       while (*s1 || *s2) {
+               if (!*s1)
+                       return -1;
+               if (!*s2)
+                       return 1;
+               if (*s1 != *s2)
+                       return *s1 - *s2;
+               s1++;
+               s2++;
+       }
+       return 0;
+}
+static int parse_str(struct hotmod_vals *v, int *val, char *name, char **curr)
+{
+       char *s;
+       int  i;
+
+       s = strchr(*curr, ',');
+       if (!s) {
+               printk(KERN_WARNING PFX "No hotmod %s given.\n", name);
+               return -EINVAL;
+       }
+       *s = '\0';
+       s++;
+       for (i = 0; hotmod_ops[i].name; i++) {
+               if (ipmi_strcasecmp(*curr, v[i].name) == 0) {
+                       *val = v[i].val;
+                       *curr = s;
+                       return 0;
+               }
+       }
+
+       printk(KERN_WARNING PFX "Invalid hotmod %s '%s'\n", name, *curr);
+       return -EINVAL;
+}
+
+static int hotmod_handler(const char *val, struct kernel_param *kp)
+{
+       char *str = kstrdup(val, GFP_KERNEL);
+       int  rv = -EINVAL;
+       char *next, *curr, *s, *n, *o;
+       enum hotmod_op op;
+       enum si_type si_type;
+       int  addr_space;
+       unsigned long addr;
+       int regspacing;
+       int regsize;
+       int regshift;
+       int irq;
+       int ipmb;
+       int ival;
+       struct smi_info *info;
+
+       if (!str)
+               return -ENOMEM;
+
+       /* Kill any trailing spaces, as we can get a "\n" from echo. */
+       ival = strlen(str) - 1;
+       while ((ival >= 0) && isspace(str[ival])) {
+               str[ival] = '\0';
+               ival--;
+       }
+
+       for (curr = str; curr; curr = next) {
+               regspacing = 1;
+               regsize = 1;
+               regshift = 0;
+               irq = 0;
+               ipmb = 0x20;
+
+               next = strchr(curr, ':');
+               if (next) {
+                       *next = '\0';
+                       next++;
+               }
+
+               rv = parse_str(hotmod_ops, &ival, "operation", &curr);
+               if (rv)
+                       break;
+               op = ival;
+
+               rv = parse_str(hotmod_si, &ival, "interface type", &curr);
+               if (rv)
+                       break;
+               si_type = ival;
+
+               rv = parse_str(hotmod_as, &addr_space, "address space", &curr);
+               if (rv)
+                       break;
+
+               s = strchr(curr, ',');
+               if (s) {
+                       *s = '\0';
+                       s++;
+               }
+               addr = simple_strtoul(curr, &n, 0);
+               if ((*n != '\0') || (*curr == '\0')) {
+                       printk(KERN_WARNING PFX "Invalid hotmod address"
+                              " '%s'\n", curr);
+                       break;
+               }
+
+               while (s) {
+                       curr = s;
+                       s = strchr(curr, ',');
+                       if (s) {
+                               *s = '\0';
+                               s++;
+                       }
+                       o = strchr(curr, '=');
+                       if (o) {
+                               *o = '\0';
+                               o++;
+                       }
+#define HOTMOD_INT_OPT(name, val) \
+                       if (ipmi_strcasecmp(curr, name) == 0) {         \
+                               if (!o) {                               \
+                                       printk(KERN_WARNING PFX         \
+                                              "No option given for '%s'\n", \
+                                               curr);                  \
+                                       goto out;                       \
+                               }                                       \
+                               val = simple_strtoul(o, &n, 0);         \
+                               if ((*n != '\0') || (*o == '\0')) {     \
+                                       printk(KERN_WARNING PFX         \
+                                              "Bad option given for '%s'\n", \
+                                              curr);                   \
+                                       goto out;                       \
+                               }                                       \
+                       }
+
+                       HOTMOD_INT_OPT("rsp", regspacing)
+                       else HOTMOD_INT_OPT("rsi", regsize)
+                       else HOTMOD_INT_OPT("rsh", regshift)
+                       else HOTMOD_INT_OPT("irq", irq)
+                       else HOTMOD_INT_OPT("ipmb", ipmb)
+                       else {
+                               printk(KERN_WARNING PFX
+                                      "Invalid hotmod option '%s'\n",
+                                      curr);
+                               goto out;
+                       }
+#undef HOTMOD_INT_OPT
+               }
+
+               if (op == HM_ADD) {
+                       info = kzalloc(sizeof(*info), GFP_KERNEL);
+                       if (!info) {
+                               rv = -ENOMEM;
+                               goto out;
+                       }
+
+                       info->addr_source = "hotmod";
+                       info->si_type = si_type;
+                       info->io.addr_data = addr;
+                       info->io.addr_type = addr_space;
+                       if (addr_space == IPMI_MEM_ADDR_SPACE)
+                               info->io_setup = mem_setup;
+                       else
+                               info->io_setup = port_setup;
+
+                       info->io.addr = NULL;
+                       info->io.regspacing = regspacing;
+                       if (!info->io.regspacing)
+                               info->io.regspacing = DEFAULT_REGSPACING;
+                       info->io.regsize = regsize;
+                       if (!info->io.regsize)
+                               info->io.regsize = DEFAULT_REGSPACING;
+                       info->io.regshift = regshift;
+                       info->irq = irq;
+                       if (info->irq)
+                               info->irq_setup = std_irq_setup;
+                       info->slave_addr = ipmb;
+
+                       try_smi_init(info);
+               } else {
+                       /* remove */
+                       struct smi_info *e, *tmp_e;
+
+                       mutex_lock(&smi_infos_lock);
+                       list_for_each_entry_safe(e, tmp_e, &smi_infos, link) {
+                               if (e->io.addr_type != addr_space)
+                                       continue;
+                               if (e->si_type != si_type)
+                                       continue;
+                               if (e->io.addr_data == addr)
+                                       cleanup_one_si(e);
+                       }
+                       mutex_unlock(&smi_infos_lock);
+               }
+       }
+ out:
+       kfree(str);
+       return rv;
+}
 
 static __devinit void hardcode_find_bmc(void)
 {
@@ -1333,11 +1610,11 @@ static __devinit void hardcode_find_bmc(void)
 
                info->addr_source = "hardcoded";
 
-               if (!si_type[i] || strcmp(si_type[i], "kcs") == 0) {
+               if (!si_type[i] || ipmi_strcasecmp(si_type[i], "kcs") == 0) {
                        info->si_type = SI_KCS;
-               } else if (strcmp(si_type[i], "smic") == 0) {
+               } else if (ipmi_strcasecmp(si_type[i], "smic") == 0) {
                        info->si_type = SI_SMIC;
-               } else if (strcmp(si_type[i], "bt") == 0) {
+               } else if (ipmi_strcasecmp(si_type[i], "bt") == 0) {
                        info->si_type = SI_BT;
                } else {
                        printk(KERN_WARNING
@@ -1952,19 +2229,9 @@ static int try_get_dev_id(struct smi_info *smi_info)
 static int type_file_read_proc(char *page, char **start, off_t off,
                               int count, int *eof, void *data)
 {
-       char            *out = (char *) page;
        struct smi_info *smi = data;
 
-       switch (smi->si_type) {
-           case SI_KCS:
-               return sprintf(out, "kcs\n");
-           case SI_SMIC:
-               return sprintf(out, "smic\n");
-           case SI_BT:
-               return sprintf(out, "bt\n");
-           default:
-               return 0;
-       }
+       return sprintf(page, "%s\n", si_to_str[smi->si_type]);
 }
 
 static int stat_file_read_proc(char *page, char **start, off_t off,
@@ -2000,7 +2267,24 @@ static int stat_file_read_proc(char *page, char **start, off_t off,
        out += sprintf(out, "incoming_messages:     %ld\n",
                       smi->incoming_messages);
 
-       return (out - ((char *) page));
+       return out - page;
+}
+
+static int param_read_proc(char *page, char **start, off_t off,
+                          int count, int *eof, void *data)
+{
+       struct smi_info *smi = data;
+
+       return sprintf(page,
+                      "%s,%s,0x%lx,rsp=%d,rsi=%d,rsh=%d,irq=%d,ipmb=%d\n",
+                      si_to_str[smi->si_type],
+                      addr_space_to_str[smi->io.addr_type],
+                      smi->io.addr_data,
+                      smi->io.regspacing,
+                      smi->io.regsize,
+                      smi->io.regshift,
+                      smi->irq,
+                      smi->slave_addr);
 }
 
 /*
@@ -2362,6 +2646,7 @@ static int try_smi_init(struct smi_info *new_smi)
                               new_smi,
                               &new_smi->device_id,
                               new_smi->dev,
+                              "bmc",
                               new_smi->slave_addr);
        if (rv) {
                printk(KERN_ERR
@@ -2390,6 +2675,16 @@ static int try_smi_init(struct smi_info *new_smi)
                goto out_err_stop_timer;
        }
 
+       rv = ipmi_smi_add_proc_entry(new_smi->intf, "params",
+                                    param_read_proc, NULL,
+                                    new_smi, THIS_MODULE);
+       if (rv) {
+               printk(KERN_ERR
+                      "ipmi_si: Unable to create proc entry: %d\n",
+                      rv);
+               goto out_err_stop_timer;
+       }
+
        list_add_tail(&new_smi->link, &smi_infos);
 
        mutex_unlock(&smi_infos_lock);
@@ -2483,7 +2778,12 @@ static __devinit int init_ipmi_si(void)
 #endif
 
 #ifdef CONFIG_PCI
-       pci_module_init(&ipmi_pci_driver);
+       rv = pci_register_driver(&ipmi_pci_driver);
+       if (rv){
+               printk(KERN_ERR
+                      "init_ipmi_si: Unable to register PCI driver: %d\n",
+                      rv);
+       }
 #endif
 
        if (si_trydefaults) {
@@ -2498,7 +2798,7 @@ static __devinit int init_ipmi_si(void)
        }
 
        mutex_lock(&smi_infos_lock);
-       if (list_empty(&smi_infos)) {
+       if (unload_when_empty && list_empty(&smi_infos)) {
                mutex_unlock(&smi_infos_lock);
 #ifdef CONFIG_PCI
                pci_unregister_driver(&ipmi_pci_driver);
@@ -2513,7 +2813,7 @@ static __devinit int init_ipmi_si(void)
 }
 module_init(init_ipmi_si);
 
-static void __devexit cleanup_one_si(struct smi_info *to_clean)
+static void cleanup_one_si(struct smi_info *to_clean)
 {
        int           rv;
        unsigned long flags;
index 39d7e5ef1a2ba82ff6d9b3526f397b0e2184a550..e64ea7d25d241d858d7a3022e070de8952a4fc00 100644 (file)
@@ -141,12 +141,14 @@ static int start_smic_transaction(struct si_sm_data *smic,
 {
        unsigned int i;
 
-       if ((size < 2) || (size > MAX_SMIC_WRITE_SIZE)) {
-               return -1;
-       }
-       if ((smic->state != SMIC_IDLE) && (smic->state != SMIC_HOSED)) {
-               return -2;
-       }
+       if (size < 2)
+               return IPMI_REQ_LEN_INVALID_ERR;
+       if (size > MAX_SMIC_WRITE_SIZE)
+               return IPMI_REQ_LEN_EXCEEDED_ERR;
+
+       if ((smic->state != SMIC_IDLE) && (smic->state != SMIC_HOSED))
+               return IPMI_NOT_IN_MY_STATE_ERR;
+
        if (smic_debug & SMIC_DEBUG_MSG) {
                printk(KERN_INFO "start_smic_transaction -");
                for (i = 0; i < size; i ++) {
index 73f759eaa5a6a2a777e733cf9da9bf8b4c7fa9e9..90fb2a541916e2efba863662d4e3cffa35698af4 100644 (file)
 static int nowayout = WATCHDOG_NOWAYOUT;
 
 static ipmi_user_t watchdog_user = NULL;
+static int watchdog_ifnum;
 
 /* Default the timeout to 10 seconds. */
 static int timeout = 10;
@@ -161,6 +162,8 @@ static struct fasync_struct *fasync_q = NULL;
 static char pretimeout_since_last_heartbeat = 0;
 static char expect_close;
 
+static int ifnum_to_use = -1;
+
 static DECLARE_RWSEM(register_sem);
 
 /* Parameters to ipmi_set_timeout */
@@ -169,6 +172,8 @@ static DECLARE_RWSEM(register_sem);
 #define IPMI_SET_TIMEOUT_FORCE_HB              2
 
 static int ipmi_set_timeout(int do_heartbeat);
+static void ipmi_register_watchdog(int ipmi_intf);
+static void ipmi_unregister_watchdog(int ipmi_intf);
 
 /* If true, the driver will start running as soon as it is configured
    and ready. */
@@ -245,6 +250,26 @@ static int get_param_str(char *buffer, struct kernel_param *kp)
        return strlen(buffer);
 }
 
+
+static int set_param_wdog_ifnum(const char *val, struct kernel_param *kp)
+{
+       int rv = param_set_int(val, kp);
+       if (rv)
+               return rv;
+       if ((ifnum_to_use < 0) || (ifnum_to_use == watchdog_ifnum))
+               return 0;
+
+       ipmi_unregister_watchdog(watchdog_ifnum);
+       ipmi_register_watchdog(ifnum_to_use);
+       return 0;
+}
+
+module_param_call(ifnum_to_use, set_param_wdog_ifnum, get_param_int,
+                 &ifnum_to_use, 0644);
+MODULE_PARM_DESC(ifnum_to_use, "The interface number to use for the watchdog "
+                "timer.  Setting to -1 defaults to the first registered "
+                "interface");
+
 module_param_call(timeout, set_param_int, get_param_int, &timeout, 0644);
 MODULE_PARM_DESC(timeout, "Timeout value in seconds.");
 
@@ -263,12 +288,13 @@ module_param_call(preop, set_param_str, get_param_str, preop_op, 0644);
 MODULE_PARM_DESC(preop, "Pretimeout driver operation.  One of: "
                 "preop_none, preop_panic, preop_give_data.");
 
-module_param(start_now, int, 0);
+module_param(start_now, int, 0444);
 MODULE_PARM_DESC(start_now, "Set to 1 to start the watchdog as"
                 "soon as the driver is loaded.");
 
 module_param(nowayout, int, 0644);
-MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
+                "(default=CONFIG_WATCHDOG_NOWAYOUT)");
 
 /* Default state of the timer. */
 static unsigned char ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
@@ -872,6 +898,11 @@ static void ipmi_register_watchdog(int ipmi_intf)
        if (watchdog_user)
                goto out;
 
+       if ((ifnum_to_use >= 0) && (ifnum_to_use != ipmi_intf))
+               goto out;
+
+       watchdog_ifnum = ipmi_intf;
+
        rv = ipmi_create_user(ipmi_intf, &ipmi_hndlrs, NULL, &watchdog_user);
        if (rv < 0) {
                printk(KERN_CRIT PFX "Unable to register with ipmi\n");
@@ -901,6 +932,39 @@ static void ipmi_register_watchdog(int ipmi_intf)
        }
 }
 
+static void ipmi_unregister_watchdog(int ipmi_intf)
+{
+       int rv;
+
+       down_write(&register_sem);
+
+       if (!watchdog_user)
+               goto out;
+
+       if (watchdog_ifnum != ipmi_intf)
+               goto out;
+
+       /* Make sure no one can call us any more. */
+       misc_deregister(&ipmi_wdog_miscdev);
+
+       /* Wait to make sure the message makes it out.  The lower layer has
+          pointers to our buffers, we want to make sure they are done before
+          we release our memory. */
+       while (atomic_read(&set_timeout_tofree))
+               schedule_timeout_uninterruptible(1);
+
+       /* Disconnect from IPMI. */
+       rv = ipmi_destroy_user(watchdog_user);
+       if (rv) {
+               printk(KERN_WARNING PFX "error unlinking from IPMI: %d\n",
+                      rv);
+       }
+       watchdog_user = NULL;
+
+ out:
+       up_write(&register_sem);
+}
+
 #ifdef HAVE_NMI_HANDLER
 static int
 ipmi_nmi(void *dev_id, int cpu, int handled)
@@ -1004,9 +1068,7 @@ static void ipmi_new_smi(int if_num, struct device *device)
 
 static void ipmi_smi_gone(int if_num)
 {
-       /* This can never be called, because once the watchdog is
-          registered, the interface can't go away until the watchdog
-          is unregistered. */
+       ipmi_unregister_watchdog(if_num);
 }
 
 static struct ipmi_smi_watcher smi_watcher =
@@ -1148,30 +1210,32 @@ static int __init ipmi_wdog_init(void)
 
        check_parms();
 
+       register_reboot_notifier(&wdog_reboot_notifier);
+       atomic_notifier_chain_register(&panic_notifier_list,
+                       &wdog_panic_notifier);
+
        rv = ipmi_smi_watcher_register(&smi_watcher);
        if (rv) {
 #ifdef HAVE_NMI_HANDLER
                if (preaction_val == WDOG_PRETIMEOUT_NMI)
                        release_nmi(&ipmi_nmi_handler);
 #endif
+               atomic_notifier_chain_unregister(&panic_notifier_list,
+                                                &wdog_panic_notifier);
+               unregister_reboot_notifier(&wdog_reboot_notifier);
                printk(KERN_WARNING PFX "can't register smi watcher\n");
                return rv;
        }
 
-       register_reboot_notifier(&wdog_reboot_notifier);
-       atomic_notifier_chain_register(&panic_notifier_list,
-                       &wdog_panic_notifier);
-
        printk(KERN_INFO PFX "driver initialized\n");
 
        return 0;
 }
 
-static __exit void ipmi_unregister_watchdog(void)
+static void __exit ipmi_wdog_exit(void)
 {
-       int rv;
-
-       down_write(&register_sem);
+       ipmi_smi_watcher_unregister(&smi_watcher);
+       ipmi_unregister_watchdog(watchdog_ifnum);
 
 #ifdef HAVE_NMI_HANDLER
        if (nmi_handler_registered)
@@ -1179,37 +1243,8 @@ static __exit void ipmi_unregister_watchdog(void)
 #endif
 
        atomic_notifier_chain_unregister(&panic_notifier_list,
-                       &wdog_panic_notifier);
+                                        &wdog_panic_notifier);
        unregister_reboot_notifier(&wdog_reboot_notifier);
-
-       if (! watchdog_user)
-               goto out;
-
-       /* Make sure no one can call us any more. */
-       misc_deregister(&ipmi_wdog_miscdev);
-
-       /* Wait to make sure the message makes it out.  The lower layer has
-          pointers to our buffers, we want to make sure they are done before
-          we release our memory. */
-       while (atomic_read(&set_timeout_tofree))
-               schedule_timeout_uninterruptible(1);
-
-       /* Disconnect from IPMI. */
-       rv = ipmi_destroy_user(watchdog_user);
-       if (rv) {
-               printk(KERN_WARNING PFX "error unlinking from IPMI: %d\n",
-                      rv);
-       }
-       watchdog_user = NULL;
-
- out:
-       up_write(&register_sem);
-}
-
-static void __exit ipmi_wdog_exit(void)
-{
-       ipmi_smi_watcher_unregister(&smi_watcher);
-       ipmi_unregister_watchdog();
 }
 module_exit(ipmi_wdog_exit);
 module_init(ipmi_wdog_init);
index 1637c1d9a4baf9f801da84c1e99bd39986ac3ed3..5a747e685993314618e25729cf56b5f796679e0e 100644 (file)
@@ -172,12 +172,14 @@ static struct pci_driver isicom_driver = {
 static int prev_card = 3;      /*      start servicing isi_card[0]     */
 static struct tty_driver *isicom_normal;
 
-static struct timer_list tx;
+static DECLARE_COMPLETION(isi_timerdone);
 static char re_schedule = 1;
 
 static void isicom_tx(unsigned long _data);
 static void isicom_start(struct tty_struct *tty);
 
+static DEFINE_TIMER(tx, isicom_tx, 0, 0);
+
 /*   baud index mappings from linux defns to isi */
 
 static signed char linuxb_to_isib[] = {
@@ -193,9 +195,9 @@ struct      isi_board {
        unsigned short          shift_count;
        struct isi_port         * ports;
        signed char             count;
-       unsigned char           isa;
        spinlock_t              card_lock; /* Card wide lock 11/5/00 -sameer */
        unsigned long           flags;
+       unsigned int            index;
 };
 
 struct isi_port {
@@ -514,17 +516,11 @@ static void isicom_tx(unsigned long _data)
        /*      schedule another tx for hopefully in about 10ms */
 sched_again:
        if (!re_schedule) {
-               re_schedule = 2;
+               complete(&isi_timerdone);
                return;
        }
 
-       init_timer(&tx);
-       tx.expires = jiffies + HZ/100;
-       tx.data = 0;
-       tx.function = isicom_tx;
-       add_timer(&tx);
-
-       return;
+       mod_timer(&tx, jiffies + msecs_to_jiffies(10));
 }
 
 /*     Interrupt handlers      */
@@ -562,14 +558,12 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
        base = card->base;
        spin_lock(&card->card_lock);
 
-       if (card->isa == NO) {
-               /*
-                * disable any interrupts from the PCI card and lower the
-                * interrupt line
-                */
-               outw(0x8000, base+0x04);
-               ClearInterrupt(base);
-       }
+       /*
+        * disable any interrupts from the PCI card and lower the
+        * interrupt line
+        */
+       outw(0x8000, base+0x04);
+       ClearInterrupt(base);
 
        inw(base);              /* get the dummy word out */
        header = inw(base);
@@ -579,19 +573,13 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
        if (channel + 1 > card->port_count) {
                printk(KERN_WARNING "ISICOM: isicom_interrupt(0x%lx): "
                        "%d(channel) > port_count.\n", base, channel+1);
-               if (card->isa)
-                       ClearInterrupt(base);
-               else
-                       outw(0x0000, base+0x04); /* enable interrupts */
+               outw(0x0000, base+0x04); /* enable interrupts */
                spin_unlock(&card->card_lock);
                return IRQ_HANDLED;
        }
        port = card->ports + channel;
        if (!(port->flags & ASYNC_INITIALIZED)) {
-               if (card->isa)
-                       ClearInterrupt(base);
-               else
-                       outw(0x0000, base+0x04); /* enable interrupts */
+               outw(0x0000, base+0x04); /* enable interrupts */
                return IRQ_HANDLED;
        }
 
@@ -604,10 +592,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
                }
                if (byte_count & 0x01)
                        inw(base);
-               if (card->isa == YES)
-                       ClearInterrupt(base);
-               else
-                       outw(0x0000, base+0x04); /* enable interrupts */
+               outw(0x0000, base+0x04); /* enable interrupts */
                spin_unlock(&card->card_lock);
                return IRQ_HANDLED;
        }
@@ -708,10 +693,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
                }
                tty_flip_buffer_push(tty);
        }
-       if (card->isa == YES)
-               ClearInterrupt(base);
-       else
-               outw(0x0000, base+0x04); /* enable interrupts */
+       outw(0x0000, base+0x04); /* enable interrupts */
 
        return IRQ_HANDLED;
 }
@@ -964,8 +946,8 @@ static int isicom_open(struct tty_struct *tty, struct file *filp)
 {
        struct isi_port *port;
        struct isi_board *card;
-       unsigned int line, board;
-       int error;
+       unsigned int board;
+       int error, line;
 
        line = tty->index;
        if (line < 0 || line > PORT_COUNT-1)
@@ -1399,7 +1381,7 @@ static int isicom_ioctl(struct tty_struct *tty, struct file *filp,
 
 /* set_termios et all */
 static void isicom_set_termios(struct tty_struct *tty,
-       struct termios *old_termios)
+       struct ktermios *old_termios)
 {
        struct isi_port *port = tty->driver_data;
 
@@ -1520,37 +1502,6 @@ static void isicom_flush_buffer(struct tty_struct *tty)
  * Driver init and deinit functions
  */
 
-static int __devinit isicom_register_ioregion(struct pci_dev *pdev,
-       const unsigned int index)
-{
-       struct isi_board *board = pci_get_drvdata(pdev);
-
-       if (!board->base)
-               return -EINVAL;
-
-       if (!request_region(board->base, 16, ISICOM_NAME)) {
-               dev_dbg(&pdev->dev, "I/O Region 0x%lx-0x%lx is busy. Card%d "
-                       "will be disabled.\n", board->base, board->base + 15,
-                       index + 1);
-               return -EBUSY;
-       }
-
-       return 0;
-}
-
-static void isicom_unregister_ioregion(struct pci_dev *pdev)
-{
-       struct isi_board *board = pci_get_drvdata(pdev);
-
-       if (!board->base)
-               return;
-
-       release_region(board->base, 16);
-       dev_dbg(&pdev->dev, "I/O Region 0x%lx-0x%lx released.\n",
-               board->base, board->base + 15);
-       board->base = 0;
-}
-
 static const struct tty_operations isicom_ops = {
        .open                   = isicom_open,
        .close                  = isicom_close,
@@ -1571,70 +1522,6 @@ static const struct tty_operations isicom_ops = {
        .tiocmset               = isicom_tiocmset,
 };
 
-static int __devinit isicom_register_tty_driver(void)
-{
-       int error = -ENOMEM;
-
-       /* tty driver structure initialization */
-       isicom_normal = alloc_tty_driver(PORT_COUNT);
-       if (!isicom_normal)
-               goto end;
-
-       isicom_normal->owner                    = THIS_MODULE;
-       isicom_normal->name                     = "ttyM";
-       isicom_normal->major                    = ISICOM_NMAJOR;
-       isicom_normal->minor_start              = 0;
-       isicom_normal->type                     = TTY_DRIVER_TYPE_SERIAL;
-       isicom_normal->subtype                  = SERIAL_TYPE_NORMAL;
-       isicom_normal->init_termios             = tty_std_termios;
-       isicom_normal->init_termios.c_cflag     = B9600 | CS8 | CREAD | HUPCL |
-               CLOCAL;
-       isicom_normal->flags                    = TTY_DRIVER_REAL_RAW;
-       tty_set_operations(isicom_normal, &isicom_ops);
-
-       if ((error = tty_register_driver(isicom_normal))) {
-               pr_dbg("Couldn't register the dialin driver, error=%d\n",
-                       error);
-               put_tty_driver(isicom_normal);
-       }
-end:
-       return error;
-}
-
-static void isicom_unregister_tty_driver(void)
-{
-       int error;
-
-       if ((error = tty_unregister_driver(isicom_normal)))
-               pr_dbg("couldn't unregister normal driver, error=%d.\n", error);
-
-       put_tty_driver(isicom_normal);
-}
-
-static int __devinit isicom_register_isr(struct pci_dev *pdev,
-       const unsigned int index)
-{
-       struct isi_board *board = pci_get_drvdata(pdev);
-       unsigned long irqflags = IRQF_DISABLED;
-       int retval = -EINVAL;
-
-       if (!board->base)
-               goto end;
-
-       if (board->isa == NO)
-               irqflags |= IRQF_SHARED;
-
-       retval = request_irq(board->irq, isicom_interrupt, irqflags,
-               ISICOM_NAME, board);
-       if (retval < 0)
-               dev_warn(&pdev->dev, "Could not install handler at Irq %d. "
-                       "Card%d will be disabled.\n", board->irq, index + 1);
-       else
-               retval = 0;
-end:
-       return retval;
-}
-
 static int __devinit reset_card(struct pci_dev *pdev,
        const unsigned int card, unsigned int *signature)
 {
@@ -1656,36 +1543,23 @@ static int __devinit reset_card(struct pci_dev *pdev,
 
        *signature = inw(base + 0x4) & 0xff;
 
-       if (board->isa == YES) {
-               if (!(inw(base + 0xe) & 0x1) || (inw(base + 0x2))) {
-                       dev_dbg(&pdev->dev, "base+0x2=0x%lx, base+0xe=0x%lx\n",
-                               inw(base + 0x2), inw(base + 0xe));
-                       dev_err(&pdev->dev, "ISILoad:ISA Card%d reset failure "
-                               "(Possible bad I/O Port Address 0x%lx).\n",
-                               card + 1, base);
-                       retval = -EIO;
-                       goto end;
-               }
-       } else {
-               portcount = inw(base + 0x2);
-               if (!(inw(base + 0xe) & 0x1) || ((portcount != 0) &&
-                               (portcount != 4) && (portcount != 8))) {
-                       dev_dbg(&pdev->dev, "base+0x2=0x%lx, base+0xe=0x%lx\n",
-                               inw(base + 0x2), inw(base + 0xe));
-                       dev_err(&pdev->dev, "ISILoad:PCI Card%d reset failure "
-                               "(Possible bad I/O Port Address 0x%lx).\n",
-                               card + 1, base);
-                       retval = -EIO;
-                       goto end;
-               }
+       portcount = inw(base + 0x2);
+       if (!(inw(base + 0xe) & 0x1) || ((portcount != 0) &&
+                       (portcount != 4) && (portcount != 8))) {
+               dev_dbg(&pdev->dev, "base+0x2=0x%lx, base+0xe=0x%lx\n",
+                       inw(base + 0x2), inw(base + 0xe));
+               dev_err(&pdev->dev, "ISILoad:PCI Card%d reset failure "
+                       "(Possible bad I/O Port Address 0x%lx).\n",
+                       card + 1, base);
+               retval = -EIO;
+               goto end;
        }
 
        switch (*signature) {
        case 0xa5:
        case 0xbb:
        case 0xdd:
-               board->port_count = (board->isa == NO && portcount == 4) ? 4 :
-                       8;
+               board->port_count = (portcount == 4) ? 4 : 8;
                board->shift_count = 12;
                break;
        case 0xcc:
@@ -1831,6 +1705,11 @@ static int __devinit load_firmware(struct pci_dev *pdev,
                }
 
                data = kmalloc(word_count * 2, GFP_KERNEL);
+               if (data == NULL) {
+                       dev_err(&pdev->dev, "Card%d, firmware upload "
+                               "failed, not enough memory\n", index + 1);
+                       goto errrelfw;
+               }
                inw(base);
                insw(base, data, word_count);
                InterruptTheCard(base);
@@ -1879,8 +1758,6 @@ end:
 /*
  *     Insmod can set static symbols so keep these static
  */
-static int io[4];
-static int irq[4];
 static int card;
 
 static int __devinit isicom_probe(struct pci_dev *pdev,
@@ -1906,20 +1783,29 @@ static int __devinit isicom_probe(struct pci_dev *pdev,
                        break;
                }
 
+       board->index = index;
        board->base = ioaddr;
        board->irq = pciirq;
-       board->isa = NO;
        card++;
 
        pci_set_drvdata(pdev, board);
 
-       retval = isicom_register_ioregion(pdev, index);
-       if (retval < 0)
+       retval = pci_request_region(pdev, 3, ISICOM_NAME);
+       if (retval) {
+               dev_err(&pdev->dev, "I/O Region 0x%lx-0x%lx is busy. Card%d "
+                       "will be disabled.\n", board->base, board->base + 15,
+                       index + 1);
+               retval = -EBUSY;
                goto err;
+       }
 
-       retval = isicom_register_isr(pdev, index);
-       if (retval < 0)
+       retval = request_irq(board->irq, isicom_interrupt,
+                       IRQF_SHARED | IRQF_DISABLED, ISICOM_NAME, board);
+       if (retval < 0) {
+               dev_err(&pdev->dev, "Could not install handler at Irq %d. "
+                       "Card%d will be disabled.\n", board->irq, index + 1);
                goto errunrr;
+       }
 
        retval = reset_card(pdev, index, &signature);
        if (retval < 0)
@@ -1929,12 +1815,16 @@ static int __devinit isicom_probe(struct pci_dev *pdev,
        if (retval < 0)
                goto errunri;
 
+       for (index = 0; index < board->port_count; index++)
+               tty_register_device(isicom_normal, board->index * 16 + index,
+                               &pdev->dev);
+
        return 0;
 
 errunri:
        free_irq(board->irq, board);
 errunrr:
-       isicom_unregister_ioregion(pdev);
+       pci_release_region(pdev, 3);
 err:
        board->base = 0;
        return retval;
@@ -1943,18 +1833,21 @@ err:
 static void __devexit isicom_remove(struct pci_dev *pdev)
 {
        struct isi_board *board = pci_get_drvdata(pdev);
+       unsigned int i;
+
+       for (i = 0; i < board->port_count; i++)
+               tty_unregister_device(isicom_normal, board->index * 16 + i);
 
        free_irq(board->irq, board);
-       isicom_unregister_ioregion(pdev);
+       pci_release_region(pdev, 3);
 }
 
-static int __devinit isicom_setup(void)
+static int __init isicom_init(void)
 {
        int retval, idx, channel;
        struct isi_port *port;
 
        card = 0;
-       memset(isi_ports, 0, sizeof(isi_ports));
 
        for(idx = 0; idx < BOARD_COUNT; idx++) {
                port = &isi_ports[idx * 16];
@@ -1975,66 +1868,65 @@ static int __devinit isicom_setup(void)
                }
                isi_card[idx].base = 0;
                isi_card[idx].irq = 0;
-
-               if (!io[idx])
-                       continue;
-
-               if (irq[idx] == 2 || irq[idx] == 3 || irq[idx] == 4     ||
-                               irq[idx] == 5   || irq[idx] == 7        ||
-                               irq[idx] == 10  || irq[idx] == 11       ||
-                               irq[idx] == 12  || irq[idx] == 15) {
-                       printk(KERN_ERR "ISICOM: ISA not supported yet.\n");
-                       retval = -EINVAL;
-                       goto error;
-               } else
-                       printk(KERN_ERR "ISICOM: Irq %d unsupported. "
-                               "Disabling Card%d...\n", irq[idx], idx + 1);
        }
 
-       retval = isicom_register_tty_driver();
-       if (retval < 0)
+       /* tty driver structure initialization */
+       isicom_normal = alloc_tty_driver(PORT_COUNT);
+       if (!isicom_normal) {
+               retval = -ENOMEM;
                goto error;
+       }
+
+       isicom_normal->owner                    = THIS_MODULE;
+       isicom_normal->name                     = "ttyM";
+       isicom_normal->major                    = ISICOM_NMAJOR;
+       isicom_normal->minor_start              = 0;
+       isicom_normal->type                     = TTY_DRIVER_TYPE_SERIAL;
+       isicom_normal->subtype                  = SERIAL_TYPE_NORMAL;
+       isicom_normal->init_termios             = tty_std_termios;
+       isicom_normal->init_termios.c_cflag     = B9600 | CS8 | CREAD | HUPCL |
+               CLOCAL;
+       isicom_normal->flags                    = TTY_DRIVER_REAL_RAW |
+               TTY_DRIVER_DYNAMIC_DEV;
+       tty_set_operations(isicom_normal, &isicom_ops);
+
+       retval = tty_register_driver(isicom_normal);
+       if (retval) {
+               pr_dbg("Couldn't register the dialin driver\n");
+               goto err_puttty;
+       }
 
        retval = pci_register_driver(&isicom_driver);
        if (retval < 0) {
                printk(KERN_ERR "ISICOM: Unable to register pci driver.\n");
-               goto errtty;
+               goto err_unrtty;
        }
 
-       init_timer(&tx);
-       tx.expires = jiffies + 1;
-       tx.data = 0;
-       tx.function = isicom_tx;
-       re_schedule = 1;
-       add_timer(&tx);
+       mod_timer(&tx, jiffies + 1);
 
        return 0;
-errtty:
-       isicom_unregister_tty_driver();
+err_unrtty:
+       tty_unregister_driver(isicom_normal);
+err_puttty:
+       put_tty_driver(isicom_normal);
 error:
        return retval;
 }
 
 static void __exit isicom_exit(void)
 {
-       unsigned int index = 0;
-
        re_schedule = 0;
 
-       while (re_schedule != 2 && index++ < 100)
-               msleep(10);
+       wait_for_completion_timeout(&isi_timerdone, HZ);
 
        pci_unregister_driver(&isicom_driver);
-       isicom_unregister_tty_driver();
+       tty_unregister_driver(isicom_normal);
+       put_tty_driver(isicom_normal);
 }
 
-module_init(isicom_setup);
+module_init(isicom_init);
 module_exit(isicom_exit);
 
 MODULE_AUTHOR("MultiTech");
 MODULE_DESCRIPTION("Driver for the ISI series of cards by MultiTech");
 MODULE_LICENSE("GPL");
-module_param_array(io, int, NULL, 0);
-MODULE_PARM_DESC(io, "I/O ports for the cards");
-module_param_array(irq, int, NULL, 0);
-MODULE_PARM_DESC(irq, "Interrupts for the cards");
index bd9195e179569f758029e659ab26141fbc4879d3..68645d35187325baa50e8f5c6aec932469b5d67f 100644 (file)
  *     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.
  */
 
 /*****************************************************************************/
@@ -41,6 +33,7 @@
 #include <linux/device.h>
 #include <linux/wait.h>
 #include <linux/eisa.h>
+#include <linux/ctype.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #define        BRD_BRUMBY4     2
 #define        BRD_ONBOARD2    3
 #define        BRD_ONBOARD     4
-#define        BRD_BRUMBY8     5
-#define        BRD_BRUMBY16    6
 #define        BRD_ONBOARDE    7
-#define        BRD_ONBOARD32   9
-#define        BRD_ONBOARD2_32 10
-#define        BRD_ONBOARDRS   11
-#define        BRD_EASYIO      20
-#define        BRD_ECH         21
-#define        BRD_ECHMC       22
 #define        BRD_ECP         23
 #define BRD_ECPE       24
 #define        BRD_ECPMC       25
-#define        BRD_ECHPCI      26
-#define        BRD_ECH64PCI    27
-#define        BRD_EASYIOPCI   28
 #define        BRD_ECPPCI      29
 
 #define        BRD_BRUMBY      BRD_BRUMBY4
  *     interrupt is required.
  */
 
-typedef struct {
+struct stlconf {
        int             brdtype;
        int             ioaddr1;
        int             ioaddr2;
        unsigned long   memaddr;
        int             irq;
        int             irqtype;
-} stlconf_t;
-
-static stlconf_t       stli_brdconf[] = {
-       /*{ BRD_ECP, 0x2a0, 0, 0xcc000, 0, 0 },*/
 };
 
-static int     stli_nrbrds = ARRAY_SIZE(stli_brdconf);
+static unsigned int stli_nrbrds;
 
 /* stli_lock must NOT be taken holding brd_lock */
 static spinlock_t stli_lock;   /* TTY logic lock */
@@ -194,9 +172,11 @@ static struct tty_struct   *stli_txcooktty;
  *     with this termios initially. Basically all it defines is a raw port
  *     at 9600 baud, 8 data bits, no parity, 1 stop bit.
  */
-static struct termios          stli_deftermios = {
+static struct ktermios         stli_deftermios = {
        .c_cflag        = (B9600 | CS8 | CREAD | HUPCL | CLOCAL),
        .c_cc           = INIT_C_CC,
+       .c_ispeed       = 9600,
+       .c_ospeed       = 9600,
 };
 
 /*
@@ -205,13 +185,12 @@ static struct termios             stli_deftermios = {
  */
 static comstats_t      stli_comstats;
 static combrd_t                stli_brdstats;
-static asystats_t      stli_cdkstats;
-static stlibrd_t       stli_dummybrd;
-static stliport_t      stli_dummyport;
+static struct asystats stli_cdkstats;
 
 /*****************************************************************************/
 
-static stlibrd_t       *stli_brds[STL_MAXBRDS];
+static DEFINE_MUTEX(stli_brdslock);
+static struct stlibrd  *stli_brds[STL_MAXBRDS];
 
 static int             stli_shared;
 
@@ -223,6 +202,7 @@ static int          stli_shared;
  */
 #define        BST_FOUND       0x1
 #define        BST_STARTED     0x2
+#define        BST_PROBED      0x4
 
 /*
  *     Define the set of port state flags. These are marked for internal
@@ -255,18 +235,18 @@ static char       *stli_brdnames[] = {
        "Brumby",
        "Brumby",
        "ONboard-EI",
-       (char *) NULL,
+       NULL,
        "ONboard",
        "ONboard-MC",
        "ONboard-MC",
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
        "EasyIO",
        "EC8/32-AT",
        "EC8/32-MC",
@@ -304,12 +284,10 @@ static char       **stli_brdsp[] = {
  *     parse any module arguments.
  */
 
-typedef struct stlibrdtype {
+static struct stlibrdtype {
        char    *name;
        int     type;
-} stlibrdtype_t;
-
-static stlibrdtype_t   stli_brdstr[] = {
+} stli_brdstr[] = {
        { "stallion", BRD_STALLION },
        { "1", BRD_STALLION },
        { "brumby", BRD_BRUMBY },
@@ -379,6 +357,7 @@ MODULE_PARM_DESC(board2, "Board 2 config -> name[,ioaddr[,memaddr]");
 module_param_array(board3, charp, NULL, 0);
 MODULE_PARM_DESC(board3, "Board 3 config -> name[,ioaddr[,memaddr]");
 
+#if STLI_EISAPROBE != 0
 /*
  *     Set up a default memory address table for EISA board probing.
  *     The default addresses are all bellow 1Mbyte, which has to be the
@@ -396,14 +375,11 @@ static unsigned long      stli_eisamemprobeaddrs[] = {
 };
 
 static int     stli_eisamempsize = ARRAY_SIZE(stli_eisamemprobeaddrs);
+#endif
 
 /*
  *     Define the Stallion PCI vendor and device IDs.
  */
-#ifdef CONFIG_PCI
-#ifndef        PCI_VENDOR_ID_STALLION
-#define        PCI_VENDOR_ID_STALLION          0x124d
-#endif
 #ifndef PCI_DEVICE_ID_ECRA
 #define        PCI_DEVICE_ID_ECRA              0x0004
 #endif
@@ -414,7 +390,7 @@ static struct pci_device_id istallion_pci_tbl[] = {
 };
 MODULE_DEVICE_TABLE(pci, istallion_pci_tbl);
 
-#endif /* CONFIG_PCI */
+static struct pci_driver stli_pcidriver;
 
 /*****************************************************************************/
 
@@ -614,23 +590,11 @@ MODULE_DEVICE_TABLE(pci, istallion_pci_tbl);
 
 /*****************************************************************************/
 
-/*
- *     Define some handy local macros...
- */
-#undef MIN
-#define        MIN(a,b)        (((a) <= (b)) ? (a) : (b))
-
-#undef TOLOWER
-#define        TOLOWER(x)      ((((x) >= 'A') && ((x) <= 'Z')) ? ((x) + 0x20) : (x))
-
-/*****************************************************************************/
-
 /*
  *     Prototype all functions in this driver!
  */
 
-static int     stli_parsebrd(stlconf_t *confp, char **argp);
-static int     stli_init(void);
+static int     stli_parsebrd(struct stlconf *confp, char **argp);
 static int     stli_open(struct tty_struct *tty, struct file *filp);
 static void    stli_close(struct tty_struct *tty, struct file *filp);
 static int     stli_write(struct tty_struct *tty, const unsigned char *buf, int count);
@@ -639,7 +603,7 @@ static void stli_flushchars(struct tty_struct *tty);
 static int     stli_writeroom(struct tty_struct *tty);
 static int     stli_charsinbuffer(struct tty_struct *tty);
 static int     stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg);
-static void    stli_settermios(struct tty_struct *tty, struct termios *old);
+static void    stli_settermios(struct tty_struct *tty, struct ktermios *old);
 static void    stli_throttle(struct tty_struct *tty);
 static void    stli_unthrottle(struct tty_struct *tty);
 static void    stli_stop(struct tty_struct *tty);
@@ -649,86 +613,84 @@ static void       stli_breakctl(struct tty_struct *tty, int state);
 static void    stli_waituntilsent(struct tty_struct *tty, int timeout);
 static void    stli_sendxchar(struct tty_struct *tty, char ch);
 static void    stli_hangup(struct tty_struct *tty);
-static int     stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *pos);
+static int     stli_portinfo(struct stlibrd *brdp, struct stliport *portp, int portnr, char *pos);
 
-static int     stli_brdinit(stlibrd_t *brdp);
-static int     stli_startbrd(stlibrd_t *brdp);
+static int     stli_brdinit(struct stlibrd *brdp);
+static int     stli_startbrd(struct stlibrd *brdp);
 static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp);
 static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp);
 static int     stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg);
-static void    stli_brdpoll(stlibrd_t *brdp, cdkhdr_t __iomem *hdrp);
+static void    stli_brdpoll(struct stlibrd *brdp, cdkhdr_t __iomem *hdrp);
 static void    stli_poll(unsigned long arg);
-static int     stli_hostcmd(stlibrd_t *brdp, stliport_t *portp);
-static int     stli_initopen(stlibrd_t *brdp, stliport_t *portp);
-static int     stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait);
-static int     stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait);
-static int     stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp);
+static int     stli_hostcmd(struct stlibrd *brdp, struct stliport *portp);
+static int     stli_initopen(struct stlibrd *brdp, struct stliport *portp);
+static int     stli_rawopen(struct stlibrd *brdp, struct stliport *portp, unsigned long arg, int wait);
+static int     stli_rawclose(struct stlibrd *brdp, struct stliport *portp, unsigned long arg, int wait);
+static int     stli_waitcarrier(struct stlibrd *brdp, struct stliport *portp, struct file *filp);
 static void    stli_dohangup(struct work_struct *);
-static int     stli_setport(stliport_t *portp);
-static int     stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
-static void    stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
-static void    __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
-static void    stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp);
-static void    stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp);
+static int     stli_setport(struct stliport *portp);
+static int     stli_cmdwait(struct stlibrd *brdp, struct stliport *portp, unsigned long cmd, void *arg, int size, int copyback);
+static void    stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigned long cmd, void *arg, int size, int copyback);
+static void    __stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigned long cmd, void *arg, int size, int copyback);
+static void    stli_dodelaycmd(struct stliport *portp, cdkctrl_t __iomem *cp);
+static void    stli_mkasyport(struct stliport *portp, asyport_t *pp, struct ktermios *tiosp);
 static void    stli_mkasysigs(asysigs_t *sp, int dtr, int rts);
 static long    stli_mktiocm(unsigned long sigvalue);
-static void    stli_read(stlibrd_t *brdp, stliport_t *portp);
-static int     stli_getserial(stliport_t *portp, struct serial_struct __user *sp);
-static int     stli_setserial(stliport_t *portp, struct serial_struct __user *sp);
+static void    stli_read(struct stlibrd *brdp, struct stliport *portp);
+static int     stli_getserial(struct stliport *portp, struct serial_struct __user *sp);
+static int     stli_setserial(struct stliport *portp, struct serial_struct __user *sp);
 static int     stli_getbrdstats(combrd_t __user *bp);
-static int     stli_getportstats(stliport_t *portp, comstats_t __user *cp);
-static int     stli_portcmdstats(stliport_t *portp);
-static int     stli_clrportstats(stliport_t *portp, comstats_t __user *cp);
-static int     stli_getportstruct(stliport_t __user *arg);
-static int     stli_getbrdstruct(stlibrd_t __user *arg);
-static stlibrd_t *stli_allocbrd(void);
-
-static void    stli_ecpinit(stlibrd_t *brdp);
-static void    stli_ecpenable(stlibrd_t *brdp);
-static void    stli_ecpdisable(stlibrd_t *brdp);
-static void __iomem *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line);
-static void    stli_ecpreset(stlibrd_t *brdp);
-static void    stli_ecpintr(stlibrd_t *brdp);
-static void    stli_ecpeiinit(stlibrd_t *brdp);
-static void    stli_ecpeienable(stlibrd_t *brdp);
-static void    stli_ecpeidisable(stlibrd_t *brdp);
-static void __iomem *stli_ecpeigetmemptr(stlibrd_t *brdp, unsigned long offset, int line);
-static void    stli_ecpeireset(stlibrd_t *brdp);
-static void    stli_ecpmcenable(stlibrd_t *brdp);
-static void    stli_ecpmcdisable(stlibrd_t *brdp);
-static void __iomem *stli_ecpmcgetmemptr(stlibrd_t *brdp, unsigned long offset, int line);
-static void    stli_ecpmcreset(stlibrd_t *brdp);
-static void    stli_ecppciinit(stlibrd_t *brdp);
-static void __iomem *stli_ecppcigetmemptr(stlibrd_t *brdp, unsigned long offset, int line);
-static void    stli_ecppcireset(stlibrd_t *brdp);
-
-static void    stli_onbinit(stlibrd_t *brdp);
-static void    stli_onbenable(stlibrd_t *brdp);
-static void    stli_onbdisable(stlibrd_t *brdp);
-static void __iomem *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, int line);
-static void    stli_onbreset(stlibrd_t *brdp);
-static void    stli_onbeinit(stlibrd_t *brdp);
-static void    stli_onbeenable(stlibrd_t *brdp);
-static void    stli_onbedisable(stlibrd_t *brdp);
-static void __iomem *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line);
-static void    stli_onbereset(stlibrd_t *brdp);
-static void    stli_bbyinit(stlibrd_t *brdp);
-static void __iomem *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line);
-static void    stli_bbyreset(stlibrd_t *brdp);
-static void    stli_stalinit(stlibrd_t *brdp);
-static void __iomem *stli_stalgetmemptr(stlibrd_t *brdp, unsigned long offset, int line);
-static void    stli_stalreset(stlibrd_t *brdp);
-
-static stliport_t *stli_getport(int brdnr, int panelnr, int portnr);
-
-static int     stli_initecp(stlibrd_t *brdp);
-static int     stli_initonb(stlibrd_t *brdp);
-static int     stli_eisamemprobe(stlibrd_t *brdp);
-static int     stli_initports(stlibrd_t *brdp);
-
-#ifdef CONFIG_PCI
-static int     stli_initpcibrd(int brdtype, struct pci_dev *devp);
+static int     stli_getportstats(struct stliport *portp, comstats_t __user *cp);
+static int     stli_portcmdstats(struct stliport *portp);
+static int     stli_clrportstats(struct stliport *portp, comstats_t __user *cp);
+static int     stli_getportstruct(struct stliport __user *arg);
+static int     stli_getbrdstruct(struct stlibrd __user *arg);
+static struct stlibrd *stli_allocbrd(void);
+
+static void    stli_ecpinit(struct stlibrd *brdp);
+static void    stli_ecpenable(struct stlibrd *brdp);
+static void    stli_ecpdisable(struct stlibrd *brdp);
+static void __iomem *stli_ecpgetmemptr(struct stlibrd *brdp, unsigned long offset, int line);
+static void    stli_ecpreset(struct stlibrd *brdp);
+static void    stli_ecpintr(struct stlibrd *brdp);
+static void    stli_ecpeiinit(struct stlibrd *brdp);
+static void    stli_ecpeienable(struct stlibrd *brdp);
+static void    stli_ecpeidisable(struct stlibrd *brdp);
+static void __iomem *stli_ecpeigetmemptr(struct stlibrd *brdp, unsigned long offset, int line);
+static void    stli_ecpeireset(struct stlibrd *brdp);
+static void    stli_ecpmcenable(struct stlibrd *brdp);
+static void    stli_ecpmcdisable(struct stlibrd *brdp);
+static void __iomem *stli_ecpmcgetmemptr(struct stlibrd *brdp, unsigned long offset, int line);
+static void    stli_ecpmcreset(struct stlibrd *brdp);
+static void    stli_ecppciinit(struct stlibrd *brdp);
+static void __iomem *stli_ecppcigetmemptr(struct stlibrd *brdp, unsigned long offset, int line);
+static void    stli_ecppcireset(struct stlibrd *brdp);
+
+static void    stli_onbinit(struct stlibrd *brdp);
+static void    stli_onbenable(struct stlibrd *brdp);
+static void    stli_onbdisable(struct stlibrd *brdp);
+static void __iomem *stli_onbgetmemptr(struct stlibrd *brdp, unsigned long offset, int line);
+static void    stli_onbreset(struct stlibrd *brdp);
+static void    stli_onbeinit(struct stlibrd *brdp);
+static void    stli_onbeenable(struct stlibrd *brdp);
+static void    stli_onbedisable(struct stlibrd *brdp);
+static void __iomem *stli_onbegetmemptr(struct stlibrd *brdp, unsigned long offset, int line);
+static void    stli_onbereset(struct stlibrd *brdp);
+static void    stli_bbyinit(struct stlibrd *brdp);
+static void __iomem *stli_bbygetmemptr(struct stlibrd *brdp, unsigned long offset, int line);
+static void    stli_bbyreset(struct stlibrd *brdp);
+static void    stli_stalinit(struct stlibrd *brdp);
+static void __iomem *stli_stalgetmemptr(struct stlibrd *brdp, unsigned long offset, int line);
+static void    stli_stalreset(struct stlibrd *brdp);
+
+static struct stliport *stli_getport(unsigned int brdnr, unsigned int panelnr, unsigned int portnr);
+
+static int     stli_initecp(struct stlibrd *brdp);
+static int     stli_initonb(struct stlibrd *brdp);
+#if STLI_EISAPROBE != 0
+static int     stli_eisamemprobe(struct stlibrd *brdp);
 #endif
+static int     stli_initports(struct stlibrd *brdp);
 
 /*****************************************************************************/
 
@@ -766,136 +728,19 @@ static int       stli_timeron;
 
 static struct class *istallion_class;
 
-/*
- *     Loadable module initialization stuff.
- */
-
-static int __init istallion_module_init(void)
-{
-       stli_init();
-       return 0;
-}
-
-/*****************************************************************************/
-
-static void __exit istallion_module_exit(void)
-{
-       stlibrd_t       *brdp;
-       stliport_t      *portp;
-       int             i, j;
-
-       printk(KERN_INFO "Unloading %s: version %s\n", stli_drvtitle,
-               stli_drvversion);
-
-       /*
-        *      Free up all allocated resources used by the ports. This includes
-        *      memory and interrupts.
-        */
-       if (stli_timeron) {
-               stli_timeron = 0;
-               del_timer_sync(&stli_timerlist);
-       }
-
-       i = tty_unregister_driver(stli_serial);
-       if (i) {
-               printk("STALLION: failed to un-register tty driver, "
-                       "errno=%d\n", -i);
-               return;
-       }
-       put_tty_driver(stli_serial);
-       for (i = 0; i < 4; i++)
-               class_device_destroy(istallion_class, MKDEV(STL_SIOMEMMAJOR, i));
-       class_destroy(istallion_class);
-       if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem")))
-               printk("STALLION: failed to un-register serial memory device, "
-                       "errno=%d\n", -i);
-
-       kfree(stli_txcookbuf);
-
-       for (i = 0; (i < stli_nrbrds); i++) {
-               if ((brdp = stli_brds[i]) == NULL)
-                       continue;
-               for (j = 0; (j < STL_MAXPORTS); j++) {
-                       portp = brdp->ports[j];
-                       if (portp != NULL) {
-                               if (portp->tty != NULL)
-                                       tty_hangup(portp->tty);
-                               kfree(portp);
-                       }
-               }
-
-               iounmap(brdp->membase);
-               if (brdp->iosize > 0)
-                       release_region(brdp->iobase, brdp->iosize);
-               kfree(brdp);
-               stli_brds[i] = NULL;
-       }
-}
-
-module_init(istallion_module_init);
-module_exit(istallion_module_exit);
-
-/*****************************************************************************/
-
-/*
- *     Check for any arguments passed in on the module load command line.
- */
-
-static void stli_argbrds(void)
-{
-       stlconf_t conf;
-       stlibrd_t *brdp;
-       int i;
-
-       for (i = stli_nrbrds; i < ARRAY_SIZE(stli_brdsp); i++) {
-               memset(&conf, 0, sizeof(conf));
-               if (stli_parsebrd(&conf, stli_brdsp[i]) == 0)
-                       continue;
-               if ((brdp = stli_allocbrd()) == NULL)
-                       continue;
-               stli_nrbrds = i + 1;
-               brdp->brdnr = i;
-               brdp->brdtype = conf.brdtype;
-               brdp->iobase = conf.ioaddr1;
-               brdp->memaddr = conf.memaddr;
-               stli_brdinit(brdp);
-       }
-}
-
-/*****************************************************************************/
-
-/*
- *     Convert an ascii string number into an unsigned long.
- */
-
-static unsigned long stli_atol(char *str)
+static void stli_cleanup_ports(struct stlibrd *brdp)
 {
-       unsigned long val;
-       int base, c;
-       char *sp;
-
-       val = 0;
-       sp = str;
-       if ((*sp == '0') && (*(sp+1) == 'x')) {
-               base = 16;
-               sp += 2;
-       } else if (*sp == '0') {
-               base = 8;
-               sp++;
-       } else {
-               base = 10;
-       }
-
-       for (; (*sp != 0); sp++) {
-               c = (*sp > '9') ? (TOLOWER(*sp) - 'a' + 10) : (*sp - '0');
-               if ((c < 0) || (c >= base)) {
-                       printk("STALLION: invalid argument %s\n", str);
-                       val = 0;
-                       break;
+       struct stliport *portp;
+       unsigned int j;
+
+       for (j = 0; j < STL_MAXPORTS; j++) {
+               portp = brdp->ports[j];
+               if (portp != NULL) {
+                       if (portp->tty != NULL)
+                               tty_hangup(portp->tty);
+                       kfree(portp);
                }
-               val = (val * base) + c;
        }
-       return(val);
 }
 
 /*****************************************************************************/
@@ -904,16 +749,16 @@ static unsigned long stli_atol(char *str)
  *     Parse the supplied argument string, into the board conf struct.
  */
 
-static int stli_parsebrd(stlconf_t *confp, char **argp)
+static int stli_parsebrd(struct stlconf *confp, char **argp)
 {
+       unsigned int i;
        char *sp;
-       int i;
 
        if (argp[0] == NULL || *argp[0] == 0)
                return 0;
 
        for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++)
-               *sp = TOLOWER(*sp);
+               *sp = tolower(*sp);
 
        for (i = 0; i < ARRAY_SIZE(stli_brdstr); i++) {
                if (strcmp(stli_brdstr[i].name, argp[0]) == 0)
@@ -926,9 +771,9 @@ static int stli_parsebrd(stlconf_t *confp, char **argp)
 
        confp->brdtype = stli_brdstr[i].type;
        if (argp[1] != NULL && *argp[1] != 0)
-               confp->ioaddr1 = stli_atol(argp[1]);
+               confp->ioaddr1 = simple_strtoul(argp[1], NULL, 0);
        if (argp[2] !=  NULL && *argp[2] != 0)
-               confp->memaddr = stli_atol(argp[2]);
+               confp->memaddr = simple_strtoul(argp[2], NULL, 0);
        return(1);
 }
 
@@ -936,10 +781,10 @@ static int stli_parsebrd(stlconf_t *confp, char **argp)
 
 static int stli_open(struct tty_struct *tty, struct file *filp)
 {
-       stlibrd_t *brdp;
-       stliport_t *portp;
-       unsigned int minordev;
-       int brdnr, portnr, rc;
+       struct stlibrd *brdp;
+       struct stliport *portp;
+       unsigned int minordev, brdnr, portnr;
+       int rc;
 
        minordev = tty->index;
        brdnr = MINOR2BRD(minordev);
@@ -951,7 +796,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
        if ((brdp->state & BST_STARTED) == 0)
                return -ENODEV;
        portnr = MINOR2PORT(minordev);
-       if ((portnr < 0) || (portnr > brdp->nrports))
+       if (portnr > brdp->nrports)
                return -ENODEV;
 
        portp = brdp->ports[portnr];
@@ -1031,8 +876,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
 
 static void stli_close(struct tty_struct *tty, struct file *filp)
 {
-       stlibrd_t *brdp;
-       stliport_t *portp;
+       struct stlibrd *brdp;
+       struct stliport *portp;
        unsigned long flags;
 
        portp = tty->driver_data;
@@ -1109,7 +954,7 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
  *     this still all happens pretty quickly.
  */
 
-static int stli_initopen(stlibrd_t *brdp, stliport_t *portp)
+static int stli_initopen(struct stlibrd *brdp, struct stliport *portp)
 {
        struct tty_struct *tty;
        asynotify_t nt;
@@ -1157,7 +1002,7 @@ static int stli_initopen(stlibrd_t *brdp, stliport_t *portp)
  *     to overlap.
  */
 
-static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait)
+static int stli_rawopen(struct stlibrd *brdp, struct stliport *portp, unsigned long arg, int wait)
 {
        cdkhdr_t __iomem *hdrp;
        cdkctrl_t __iomem *cp;
@@ -1228,7 +1073,7 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
  *     wait is true then must have user context (to sleep).
  */
 
-static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait)
+static int stli_rawclose(struct stlibrd *brdp, struct stliport *portp, unsigned long arg, int wait)
 {
        cdkhdr_t __iomem *hdrp;
        cdkctrl_t __iomem *cp;
@@ -1292,7 +1137,7 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
  *     to complete (as opposed to initiating the command then returning).
  */
 
-static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback)
+static int stli_cmdwait(struct stlibrd *brdp, struct stliport *portp, unsigned long cmd, void *arg, int size, int copyback)
 {
        wait_event_interruptible(portp->raw_wait,
                        !test_bit(ST_CMDING, &portp->state));
@@ -1318,16 +1163,16 @@ static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, v
  *     waiting for the command to complete - so must have user context.
  */
 
-static int stli_setport(stliport_t *portp)
+static int stli_setport(struct stliport *portp)
 {
-       stlibrd_t *brdp;
+       struct stlibrd *brdp;
        asyport_t aport;
 
        if (portp == NULL)
                return -ENODEV;
        if (portp->tty == NULL)
                return -ENODEV;
-       if (portp->brdnr < 0 && portp->brdnr >= stli_nrbrds)
+       if (portp->brdnr >= stli_nrbrds)
                return -ENODEV;
        brdp = stli_brds[portp->brdnr];
        if (brdp == NULL)
@@ -1344,7 +1189,7 @@ static int stli_setport(stliport_t *portp)
  *     maybe because if we are clocal then we don't need to wait...
  */
 
-static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp)
+static int stli_waitcarrier(struct stlibrd *brdp, struct stliport *portp, struct file *filp)
 {
        unsigned long flags;
        int rc, doclocal;
@@ -1409,8 +1254,8 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun
        unsigned char __iomem *bits;
        unsigned char __iomem *shbuf;
        unsigned char *chbuf;
-       stliport_t *portp;
-       stlibrd_t *brdp;
+       struct stliport *portp;
+       struct stlibrd *brdp;
        unsigned int len, stlen, head, tail, size;
        unsigned long flags;
 
@@ -1419,7 +1264,7 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun
        portp = tty->driver_data;
        if (portp == NULL)
                return 0;
-       if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
+       if (portp->brdnr >= stli_nrbrds)
                return 0;
        brdp = stli_brds[portp->brdnr];
        if (brdp == NULL)
@@ -1445,12 +1290,12 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun
                stlen = len;
        }
 
-       len = MIN(len, count);
+       len = min(len, (unsigned int)count);
        count = 0;
        shbuf = (char __iomem *) EBRDGETMEMPTR(brdp, portp->txoffset);
 
        while (len > 0) {
-               stlen = MIN(len, stlen);
+               stlen = min(len, stlen);
                memcpy_toio(shbuf + head, chbuf, stlen);
                chbuf += stlen;
                len -= stlen;
@@ -1516,8 +1361,8 @@ static void stli_flushchars(struct tty_struct *tty)
        unsigned char __iomem *bits;
        cdkasy_t __iomem *ap;
        struct tty_struct *cooktty;
-       stliport_t *portp;
-       stlibrd_t *brdp;
+       struct stliport *portp;
+       struct stlibrd *brdp;
        unsigned int len, stlen, head, tail, size, count, cooksize;
        unsigned char *buf;
        unsigned char __iomem *shbuf;
@@ -1541,7 +1386,7 @@ static void stli_flushchars(struct tty_struct *tty)
        portp = tty->driver_data;
        if (portp == NULL)
                return;
-       if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
+       if (portp->brdnr >= stli_nrbrds)
                return;
        brdp = stli_brds[portp->brdnr];
        if (brdp == NULL)
@@ -1564,13 +1409,13 @@ static void stli_flushchars(struct tty_struct *tty)
                stlen = len;
        }
 
-       len = MIN(len, cooksize);
+       len = min(len, cooksize);
        count = 0;
        shbuf = EBRDGETMEMPTR(brdp, portp->txoffset);
        buf = stli_txcookbuf;
 
        while (len > 0) {
-               stlen = MIN(len, stlen);
+               stlen = min(len, stlen);
                memcpy_toio(shbuf + head, buf, stlen);
                buf += stlen;
                len -= stlen;
@@ -1604,8 +1449,8 @@ static void stli_flushchars(struct tty_struct *tty)
 static int stli_writeroom(struct tty_struct *tty)
 {
        cdkasyrq_t __iomem *rp;
-       stliport_t *portp;
-       stlibrd_t *brdp;
+       struct stliport *portp;
+       struct stlibrd *brdp;
        unsigned int head, tail, len;
        unsigned long flags;
 
@@ -1619,7 +1464,7 @@ static int stli_writeroom(struct tty_struct *tty)
        portp = tty->driver_data;
        if (portp == NULL)
                return 0;
-       if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
+       if (portp->brdnr >= stli_nrbrds)
                return 0;
        brdp = stli_brds[portp->brdnr];
        if (brdp == NULL)
@@ -1657,8 +1502,8 @@ static int stli_writeroom(struct tty_struct *tty)
 static int stli_charsinbuffer(struct tty_struct *tty)
 {
        cdkasyrq_t __iomem *rp;
-       stliport_t *portp;
-       stlibrd_t *brdp;
+       struct stliport *portp;
+       struct stlibrd *brdp;
        unsigned int head, tail, len;
        unsigned long flags;
 
@@ -1667,7 +1512,7 @@ static int stli_charsinbuffer(struct tty_struct *tty)
        portp = tty->driver_data;
        if (portp == NULL)
                return 0;
-       if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
+       if (portp->brdnr >= stli_nrbrds)
                return 0;
        brdp = stli_brds[portp->brdnr];
        if (brdp == NULL)
@@ -1695,10 +1540,10 @@ static int stli_charsinbuffer(struct tty_struct *tty)
  *     Generate the serial struct info.
  */
 
-static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp)
+static int stli_getserial(struct stliport *portp, struct serial_struct __user *sp)
 {
        struct serial_struct sio;
-       stlibrd_t *brdp;
+       struct stlibrd *brdp;
 
        memset(&sio, 0, sizeof(struct serial_struct));
        sio.type = PORT_UNKNOWN;
@@ -1728,7 +1573,7 @@ static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp)
  *     just quietly ignore any requests to change irq, etc.
  */
 
-static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp)
+static int stli_setserial(struct stliport *portp, struct serial_struct __user *sp)
 {
        struct serial_struct sio;
        int rc;
@@ -1759,13 +1604,13 @@ static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp)
 
 static int stli_tiocmget(struct tty_struct *tty, struct file *file)
 {
-       stliport_t *portp = tty->driver_data;
-       stlibrd_t *brdp;
+       struct stliport *portp = tty->driver_data;
+       struct stlibrd *brdp;
        int rc;
 
        if (portp == NULL)
                return -ENODEV;
-       if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
+       if (portp->brdnr >= stli_nrbrds)
                return 0;
        brdp = stli_brds[portp->brdnr];
        if (brdp == NULL)
@@ -1783,13 +1628,13 @@ static int stli_tiocmget(struct tty_struct *tty, struct file *file)
 static int stli_tiocmset(struct tty_struct *tty, struct file *file,
                         unsigned int set, unsigned int clear)
 {
-       stliport_t *portp = tty->driver_data;
-       stlibrd_t *brdp;
+       struct stliport *portp = tty->driver_data;
+       struct stlibrd *brdp;
        int rts = -1, dtr = -1;
 
        if (portp == NULL)
                return -ENODEV;
-       if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
+       if (portp->brdnr >= stli_nrbrds)
                return 0;
        brdp = stli_brds[portp->brdnr];
        if (brdp == NULL)
@@ -1814,8 +1659,8 @@ static int stli_tiocmset(struct tty_struct *tty, struct file *file,
 
 static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
 {
-       stliport_t *portp;
-       stlibrd_t *brdp;
+       struct stliport *portp;
+       struct stlibrd *brdp;
        unsigned int ival;
        int rc;
        void __user *argp = (void __user *)arg;
@@ -1823,7 +1668,7 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
        portp = tty->driver_data;
        if (portp == NULL)
                return -ENODEV;
-       if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
+       if (portp->brdnr >= stli_nrbrds)
                return 0;
        brdp = stli_brds[portp->brdnr];
        if (brdp == NULL)
@@ -1889,11 +1734,11 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
  *     Looks like it is true for the current ttys implementation..!!
  */
 
-static void stli_settermios(struct tty_struct *tty, struct termios *old)
+static void stli_settermios(struct tty_struct *tty, struct ktermios *old)
 {
-       stliport_t *portp;
-       stlibrd_t *brdp;
-       struct termios *tiosp;
+       struct stliport *portp;
+       struct stlibrd *brdp;
+       struct ktermios *tiosp;
        asyport_t aport;
 
        if (tty == NULL)
@@ -1901,7 +1746,7 @@ static void stli_settermios(struct tty_struct *tty, struct termios *old)
        portp = tty->driver_data;
        if (portp == NULL)
                return;
-       if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
+       if (portp->brdnr >= stli_nrbrds)
                return;
        brdp = stli_brds[portp->brdnr];
        if (brdp == NULL)
@@ -1937,7 +1782,7 @@ static void stli_settermios(struct tty_struct *tty, struct termios *old)
 
 static void stli_throttle(struct tty_struct *tty)
 {
-       stliport_t      *portp = tty->driver_data;
+       struct stliport *portp = tty->driver_data;
        if (portp == NULL)
                return;
        set_bit(ST_RXSTOP, &portp->state);
@@ -1953,7 +1798,7 @@ static void stli_throttle(struct tty_struct *tty)
 
 static void stli_unthrottle(struct tty_struct *tty)
 {
-       stliport_t      *portp = tty->driver_data;
+       struct stliport *portp = tty->driver_data;
        if (portp == NULL)
                return;
        clear_bit(ST_RXSTOP, &portp->state);
@@ -1992,7 +1837,7 @@ static void stli_start(struct tty_struct *tty)
 
 static void stli_dohangup(struct work_struct *ugly_api)
 {
-       stliport_t *portp = container_of(ugly_api, stliport_t, tqhangup);
+       struct stliport *portp = container_of(ugly_api, struct stliport, tqhangup);
        if (portp->tty != NULL) {
                tty_hangup(portp->tty);
        }
@@ -2009,14 +1854,14 @@ static void stli_dohangup(struct work_struct *ugly_api)
 
 static void stli_hangup(struct tty_struct *tty)
 {
-       stliport_t *portp;
-       stlibrd_t *brdp;
+       struct stliport *portp;
+       struct stlibrd *brdp;
        unsigned long flags;
 
        portp = tty->driver_data;
        if (portp == NULL)
                return;
-       if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
+       if (portp->brdnr >= stli_nrbrds)
                return;
        brdp = stli_brds[portp->brdnr];
        if (brdp == NULL)
@@ -2062,14 +1907,14 @@ static void stli_hangup(struct tty_struct *tty)
 
 static void stli_flushbuffer(struct tty_struct *tty)
 {
-       stliport_t *portp;
-       stlibrd_t *brdp;
+       struct stliport *portp;
+       struct stlibrd *brdp;
        unsigned long ftype, flags;
 
        portp = tty->driver_data;
        if (portp == NULL)
                return;
-       if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
+       if (portp->brdnr >= stli_nrbrds)
                return;
        brdp = stli_brds[portp->brdnr];
        if (brdp == NULL)
@@ -2099,14 +1944,14 @@ static void stli_flushbuffer(struct tty_struct *tty)
 
 static void stli_breakctl(struct tty_struct *tty, int state)
 {
-       stlibrd_t       *brdp;
-       stliport_t      *portp;
+       struct stlibrd  *brdp;
+       struct stliport *portp;
        long            arg;
 
        portp = tty->driver_data;
        if (portp == NULL)
                return;
-       if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
+       if (portp->brdnr >= stli_nrbrds)
                return;
        brdp = stli_brds[portp->brdnr];
        if (brdp == NULL)
@@ -2120,7 +1965,7 @@ static void stli_breakctl(struct tty_struct *tty, int state)
 
 static void stli_waituntilsent(struct tty_struct *tty, int timeout)
 {
-       stliport_t *portp;
+       struct stliport *portp;
        unsigned long tend;
 
        if (tty == NULL)
@@ -2146,14 +1991,14 @@ static void stli_waituntilsent(struct tty_struct *tty, int timeout)
 
 static void stli_sendxchar(struct tty_struct *tty, char ch)
 {
-       stlibrd_t       *brdp;
-       stliport_t      *portp;
+       struct stlibrd  *brdp;
+       struct stliport *portp;
        asyctrl_t       actrl;
 
        portp = tty->driver_data;
        if (portp == NULL)
                return;
-       if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
+       if (portp->brdnr >= stli_nrbrds)
                return;
        brdp = stli_brds[portp->brdnr];
        if (brdp == NULL)
@@ -2181,7 +2026,7 @@ static void stli_sendxchar(struct tty_struct *tty, char ch)
  *     short then padded with spaces).
  */
 
-static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *pos)
+static int stli_portinfo(struct stlibrd *brdp, struct stliport *portp, int portnr, char *pos)
 {
        char *sp, *uart;
        int rc, cnt;
@@ -2244,9 +2089,9 @@ static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *p
 
 static int stli_readproc(char *page, char **start, off_t off, int count, int *eof, void *data)
 {
-       stlibrd_t *brdp;
-       stliport_t *portp;
-       int brdnr, portnr, totalport;
+       struct stlibrd *brdp;
+       struct stliport *portp;
+       unsigned int brdnr, portnr, totalport;
        int curoff, maxoff;
        char *pos;
 
@@ -2316,7 +2161,7 @@ stli_readdone:
  *     entry point)
  */
 
-static void __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback)
+static void __stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigned long cmd, void *arg, int size, int copyback)
 {
        cdkhdr_t __iomem *hdrp;
        cdkctrl_t __iomem *cp;
@@ -2352,7 +2197,7 @@ static void __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd
        spin_unlock_irqrestore(&brd_lock, flags);
 }
 
-static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback)
+static void stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigned long cmd, void *arg, int size, int copyback)
 {
        unsigned long           flags;
 
@@ -2371,7 +2216,7 @@ static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd,
  *     more chars to unload.
  */
 
-static void stli_read(stlibrd_t *brdp, stliport_t *portp)
+static void stli_read(struct stlibrd *brdp, struct stliport *portp)
 {
        cdkasyrq_t __iomem *rp;
        char __iomem *shbuf;
@@ -2406,7 +2251,7 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp)
        while (len > 0) {
                unsigned char *cptr;
 
-               stlen = MIN(len, stlen);
+               stlen = min(len, stlen);
                tty_prepare_flip_string(tty, &cptr, stlen);
                memcpy_fromio(cptr, shbuf + tail, stlen);
                len -= stlen;
@@ -2433,7 +2278,7 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp)
  *     difficult to deal with them here.
  */
 
-static void stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp)
+static void stli_dodelaycmd(struct stliport *portp, cdkctrl_t __iomem *cp)
 {
        int cmd;
 
@@ -2481,7 +2326,7 @@ static void stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp)
  *     then port is still busy, otherwise no longer busy.
  */
 
-static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
+static int stli_hostcmd(struct stlibrd *brdp, struct stliport *portp)
 {
        cdkasy_t __iomem *ap;
        cdkctrl_t __iomem *cp;
@@ -2628,9 +2473,9 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
  *     at the cdk header structure.
  */
 
-static void stli_brdpoll(stlibrd_t *brdp, cdkhdr_t __iomem *hdrp)
+static void stli_brdpoll(struct stlibrd *brdp, cdkhdr_t __iomem *hdrp)
 {
-       stliport_t *portp;
+       struct stliport *portp;
        unsigned char hostbits[(STL_MAXCHANS / 8) + 1];
        unsigned char slavebits[(STL_MAXCHANS / 8) + 1];
        unsigned char __iomem *slavep;
@@ -2697,11 +2542,10 @@ static void stli_brdpoll(stlibrd_t *brdp, cdkhdr_t __iomem *hdrp)
 static void stli_poll(unsigned long arg)
 {
        cdkhdr_t __iomem *hdrp;
-       stlibrd_t *brdp;
-       int brdnr;
+       struct stlibrd *brdp;
+       unsigned int brdnr;
 
-       stli_timerlist.expires = STLI_TIMEOUT;
-       add_timer(&stli_timerlist);
+       mod_timer(&stli_timerlist, STLI_TIMEOUT);
 
 /*
  *     Check each board and do any servicing required.
@@ -2730,7 +2574,7 @@ static void stli_poll(unsigned long arg)
  *     the slave.
  */
 
-static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp)
+static void stli_mkasyport(struct stliport *portp, asyport_t *pp, struct ktermios *tiosp)
 {
        memset(pp, 0, sizeof(asyport_t));
 
@@ -2879,13 +2723,13 @@ static long stli_mktiocm(unsigned long sigvalue)
  *     we need to do here is set up the appropriate per port data structures.
  */
 
-static int stli_initports(stlibrd_t *brdp)
+static int stli_initports(struct stlibrd *brdp)
 {
-       stliport_t      *portp;
-       int             i, panelnr, panelport;
+       struct stliport *portp;
+       unsigned int i, panelnr, panelport;
 
        for (i = 0, panelnr = 0, panelport = 0; (i < brdp->nrports); i++) {
-               portp = kzalloc(sizeof(stliport_t), GFP_KERNEL);
+               portp = kzalloc(sizeof(struct stliport), GFP_KERNEL);
                if (!portp) {
                        printk("STALLION: failed to allocate port structure\n");
                        continue;
@@ -2919,7 +2763,7 @@ static int stli_initports(stlibrd_t *brdp)
  *     All the following routines are board specific hardware operations.
  */
 
-static void stli_ecpinit(stlibrd_t *brdp)
+static void stli_ecpinit(struct stlibrd *brdp)
 {
        unsigned long   memconf;
 
@@ -2934,21 +2778,21 @@ static void stli_ecpinit(stlibrd_t *brdp)
 
 /*****************************************************************************/
 
-static void stli_ecpenable(stlibrd_t *brdp)
+static void stli_ecpenable(struct stlibrd *brdp)
 {      
        outb(ECP_ATENABLE, (brdp->iobase + ECP_ATCONFR));
 }
 
 /*****************************************************************************/
 
-static void stli_ecpdisable(stlibrd_t *brdp)
+static void stli_ecpdisable(struct stlibrd *brdp)
 {      
        outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR));
 }
 
 /*****************************************************************************/
 
-static void __iomem *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
+static void __iomem *stli_ecpgetmemptr(struct stlibrd *brdp, unsigned long offset, int line)
 {      
        void __iomem *ptr;
        unsigned char val;
@@ -2969,7 +2813,7 @@ static void __iomem *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, in
 
 /*****************************************************************************/
 
-static void stli_ecpreset(stlibrd_t *brdp)
+static void stli_ecpreset(struct stlibrd *brdp)
 {      
        outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR));
        udelay(10);
@@ -2979,7 +2823,7 @@ static void stli_ecpreset(stlibrd_t *brdp)
 
 /*****************************************************************************/
 
-static void stli_ecpintr(stlibrd_t *brdp)
+static void stli_ecpintr(struct stlibrd *brdp)
 {      
        outb(0x1, brdp->iobase);
 }
@@ -2990,7 +2834,7 @@ static void stli_ecpintr(stlibrd_t *brdp)
  *     The following set of functions act on ECP EISA boards.
  */
 
-static void stli_ecpeiinit(stlibrd_t *brdp)
+static void stli_ecpeiinit(struct stlibrd *brdp)
 {
        unsigned long   memconf;
 
@@ -3008,21 +2852,21 @@ static void stli_ecpeiinit(stlibrd_t *brdp)
 
 /*****************************************************************************/
 
-static void stli_ecpeienable(stlibrd_t *brdp)
+static void stli_ecpeienable(struct stlibrd *brdp)
 {      
        outb(ECP_EIENABLE, (brdp->iobase + ECP_EICONFR));
 }
 
 /*****************************************************************************/
 
-static void stli_ecpeidisable(stlibrd_t *brdp)
+static void stli_ecpeidisable(struct stlibrd *brdp)
 {      
        outb(ECP_EIDISABLE, (brdp->iobase + ECP_EICONFR));
 }
 
 /*****************************************************************************/
 
-static void __iomem *stli_ecpeigetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
+static void __iomem *stli_ecpeigetmemptr(struct stlibrd *brdp, unsigned long offset, int line)
 {      
        void __iomem *ptr;
        unsigned char   val;
@@ -3046,7 +2890,7 @@ static void __iomem *stli_ecpeigetmemptr(stlibrd_t *brdp, unsigned long offset,
 
 /*****************************************************************************/
 
-static void stli_ecpeireset(stlibrd_t *brdp)
+static void stli_ecpeireset(struct stlibrd *brdp)
 {      
        outb(ECP_EISTOP, (brdp->iobase + ECP_EICONFR));
        udelay(10);
@@ -3060,21 +2904,21 @@ static void stli_ecpeireset(stlibrd_t *brdp)
  *     The following set of functions act on ECP MCA boards.
  */
 
-static void stli_ecpmcenable(stlibrd_t *brdp)
+static void stli_ecpmcenable(struct stlibrd *brdp)
 {      
        outb(ECP_MCENABLE, (brdp->iobase + ECP_MCCONFR));
 }
 
 /*****************************************************************************/
 
-static void stli_ecpmcdisable(stlibrd_t *brdp)
+static void stli_ecpmcdisable(struct stlibrd *brdp)
 {      
        outb(ECP_MCDISABLE, (brdp->iobase + ECP_MCCONFR));
 }
 
 /*****************************************************************************/
 
-static void __iomem *stli_ecpmcgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
+static void __iomem *stli_ecpmcgetmemptr(struct stlibrd *brdp, unsigned long offset, int line)
 {      
        void __iomem *ptr;
        unsigned char val;
@@ -3095,7 +2939,7 @@ static void __iomem *stli_ecpmcgetmemptr(stlibrd_t *brdp, unsigned long offset,
 
 /*****************************************************************************/
 
-static void stli_ecpmcreset(stlibrd_t *brdp)
+static void stli_ecpmcreset(struct stlibrd *brdp)
 {      
        outb(ECP_MCSTOP, (brdp->iobase + ECP_MCCONFR));
        udelay(10);
@@ -3109,7 +2953,7 @@ static void stli_ecpmcreset(stlibrd_t *brdp)
  *     The following set of functions act on ECP PCI boards.
  */
 
-static void stli_ecppciinit(stlibrd_t *brdp)
+static void stli_ecppciinit(struct stlibrd *brdp)
 {
        outb(ECP_PCISTOP, (brdp->iobase + ECP_PCICONFR));
        udelay(10);
@@ -3119,7 +2963,7 @@ static void stli_ecppciinit(stlibrd_t *brdp)
 
 /*****************************************************************************/
 
-static void __iomem *stli_ecppcigetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
+static void __iomem *stli_ecppcigetmemptr(struct stlibrd *brdp, unsigned long offset, int line)
 {      
        void __iomem *ptr;
        unsigned char   val;
@@ -3140,7 +2984,7 @@ static void __iomem *stli_ecppcigetmemptr(stlibrd_t *brdp, unsigned long offset,
 
 /*****************************************************************************/
 
-static void stli_ecppcireset(stlibrd_t *brdp)
+static void stli_ecppcireset(struct stlibrd *brdp)
 {      
        outb(ECP_PCISTOP, (brdp->iobase + ECP_PCICONFR));
        udelay(10);
@@ -3154,7 +2998,7 @@ static void stli_ecppcireset(stlibrd_t *brdp)
  *     The following routines act on ONboards.
  */
 
-static void stli_onbinit(stlibrd_t *brdp)
+static void stli_onbinit(struct stlibrd *brdp)
 {
        unsigned long   memconf;
 
@@ -3171,21 +3015,21 @@ static void stli_onbinit(stlibrd_t *brdp)
 
 /*****************************************************************************/
 
-static void stli_onbenable(stlibrd_t *brdp)
+static void stli_onbenable(struct stlibrd *brdp)
 {      
        outb((brdp->enabval | ONB_ATENABLE), (brdp->iobase + ONB_ATCONFR));
 }
 
 /*****************************************************************************/
 
-static void stli_onbdisable(stlibrd_t *brdp)
+static void stli_onbdisable(struct stlibrd *brdp)
 {      
        outb((brdp->enabval | ONB_ATDISABLE), (brdp->iobase + ONB_ATCONFR));
 }
 
 /*****************************************************************************/
 
-static void __iomem *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
+static void __iomem *stli_onbgetmemptr(struct stlibrd *brdp, unsigned long offset, int line)
 {      
        void __iomem *ptr;
 
@@ -3202,7 +3046,7 @@ static void __iomem *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, in
 
 /*****************************************************************************/
 
-static void stli_onbreset(stlibrd_t *brdp)
+static void stli_onbreset(struct stlibrd *brdp)
 {      
        outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR));
        udelay(10);
@@ -3216,7 +3060,7 @@ static void stli_onbreset(stlibrd_t *brdp)
  *     The following routines act on ONboard EISA.
  */
 
-static void stli_onbeinit(stlibrd_t *brdp)
+static void stli_onbeinit(struct stlibrd *brdp)
 {
        unsigned long   memconf;
 
@@ -3236,21 +3080,21 @@ static void stli_onbeinit(stlibrd_t *brdp)
 
 /*****************************************************************************/
 
-static void stli_onbeenable(stlibrd_t *brdp)
+static void stli_onbeenable(struct stlibrd *brdp)
 {      
        outb(ONB_EIENABLE, (brdp->iobase + ONB_EICONFR));
 }
 
 /*****************************************************************************/
 
-static void stli_onbedisable(stlibrd_t *brdp)
+static void stli_onbedisable(struct stlibrd *brdp)
 {      
        outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR));
 }
 
 /*****************************************************************************/
 
-static void __iomem *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
+static void __iomem *stli_onbegetmemptr(struct stlibrd *brdp, unsigned long offset, int line)
 {      
        void __iomem *ptr;
        unsigned char val;
@@ -3274,7 +3118,7 @@ static void __iomem *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, i
 
 /*****************************************************************************/
 
-static void stli_onbereset(stlibrd_t *brdp)
+static void stli_onbereset(struct stlibrd *brdp)
 {      
        outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR));
        udelay(10);
@@ -3288,7 +3132,7 @@ static void stli_onbereset(stlibrd_t *brdp)
  *     The following routines act on Brumby boards.
  */
 
-static void stli_bbyinit(stlibrd_t *brdp)
+static void stli_bbyinit(struct stlibrd *brdp)
 {
        outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR));
        udelay(10);
@@ -3300,7 +3144,7 @@ static void stli_bbyinit(stlibrd_t *brdp)
 
 /*****************************************************************************/
 
-static void __iomem *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
+static void __iomem *stli_bbygetmemptr(struct stlibrd *brdp, unsigned long offset, int line)
 {      
        void __iomem *ptr;
        unsigned char val;
@@ -3315,7 +3159,7 @@ static void __iomem *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, in
 
 /*****************************************************************************/
 
-static void stli_bbyreset(stlibrd_t *brdp)
+static void stli_bbyreset(struct stlibrd *brdp)
 {      
        outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR));
        udelay(10);
@@ -3329,7 +3173,7 @@ static void stli_bbyreset(stlibrd_t *brdp)
  *     The following routines act on original old Stallion boards.
  */
 
-static void stli_stalinit(stlibrd_t *brdp)
+static void stli_stalinit(struct stlibrd *brdp)
 {
        outb(0x1, brdp->iobase);
        mdelay(1000);
@@ -3337,7 +3181,7 @@ static void stli_stalinit(stlibrd_t *brdp)
 
 /*****************************************************************************/
 
-static void __iomem *stli_stalgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
+static void __iomem *stli_stalgetmemptr(struct stlibrd *brdp, unsigned long offset, int line)
 {      
        BUG_ON(offset > brdp->memsize);
        return brdp->membase + (offset % STAL_PAGESIZE);
@@ -3345,7 +3189,7 @@ static void __iomem *stli_stalgetmemptr(stlibrd_t *brdp, unsigned long offset, i
 
 /*****************************************************************************/
 
-static void stli_stalreset(stlibrd_t *brdp)
+static void stli_stalreset(struct stlibrd *brdp)
 {      
        u32 __iomem *vecp;
 
@@ -3362,21 +3206,22 @@ static void stli_stalreset(stlibrd_t *brdp)
  *     board types.
  */
 
-static int stli_initecp(stlibrd_t *brdp)
+static int stli_initecp(struct stlibrd *brdp)
 {
        cdkecpsig_t sig;
        cdkecpsig_t __iomem *sigsp;
        unsigned int status, nxtid;
        char *name;
-       int panelnr, nrports;
+       int retval, panelnr, nrports;
 
-       if (!request_region(brdp->iobase, brdp->iosize, "istallion"))
-               return -EIO;
-       
-       if ((brdp->iobase == 0) || (brdp->memaddr == 0))
-       {
-               release_region(brdp->iobase, brdp->iosize);
-               return -ENODEV;
+       if ((brdp->iobase == 0) || (brdp->memaddr == 0)) {
+               retval = -ENODEV;
+               goto err;
+       }
+
+       if (!request_region(brdp->iobase, brdp->iosize, "istallion")) {
+               retval = -EIO;
+               goto err;
        }
 
        brdp->iosize = ECP_IOSIZE;
@@ -3388,7 +3233,6 @@ static int stli_initecp(stlibrd_t *brdp)
  */
        switch (brdp->brdtype) {
        case BRD_ECP:
-               brdp->membase = (void *) brdp->memaddr;
                brdp->memsize = ECP_MEMSIZE;
                brdp->pagesize = ECP_ATPAGESIZE;
                brdp->init = stli_ecpinit;
@@ -3402,7 +3246,6 @@ static int stli_initecp(stlibrd_t *brdp)
                break;
 
        case BRD_ECPE:
-               brdp->membase = (void *) brdp->memaddr;
                brdp->memsize = ECP_MEMSIZE;
                brdp->pagesize = ECP_EIPAGESIZE;
                brdp->init = stli_ecpeiinit;
@@ -3416,7 +3259,6 @@ static int stli_initecp(stlibrd_t *brdp)
                break;
 
        case BRD_ECPMC:
-               brdp->membase = (void *) brdp->memaddr;
                brdp->memsize = ECP_MEMSIZE;
                brdp->pagesize = ECP_MCPAGESIZE;
                brdp->init = NULL;
@@ -3430,7 +3272,6 @@ static int stli_initecp(stlibrd_t *brdp)
                break;
 
        case BRD_ECPPCI:
-               brdp->membase = (void *) brdp->memaddr;
                brdp->memsize = ECP_PCIMEMSIZE;
                brdp->pagesize = ECP_PCIPAGESIZE;
                brdp->init = stli_ecppciinit;
@@ -3444,8 +3285,8 @@ static int stli_initecp(stlibrd_t *brdp)
                break;
 
        default:
-               release_region(brdp->iobase, brdp->iosize);
-               return -EINVAL;
+               retval = -EINVAL;
+               goto err_reg;
        }
 
 /*
@@ -3457,10 +3298,9 @@ static int stli_initecp(stlibrd_t *brdp)
        EBRDINIT(brdp);
 
        brdp->membase = ioremap(brdp->memaddr, brdp->memsize);
-       if (brdp->membase == NULL)
-       {
-               release_region(brdp->iobase, brdp->iosize);
-               return -ENOMEM;
+       if (brdp->membase == NULL) {
+               retval = -ENOMEM;
+               goto err_reg;
        }
 
 /*
@@ -3473,10 +3313,9 @@ static int stli_initecp(stlibrd_t *brdp)
        memcpy_fromio(&sig, sigsp, sizeof(cdkecpsig_t));
        EBRDDISABLE(brdp);
 
-       if (sig.magic != cpu_to_le32(ECP_MAGIC))
-       {
-               release_region(brdp->iobase, brdp->iosize);
-               return -ENODEV;
+       if (sig.magic != cpu_to_le32(ECP_MAGIC)) {
+               retval = -ENODEV;
+               goto err_unmap;
        }
 
 /*
@@ -3501,6 +3340,13 @@ static int stli_initecp(stlibrd_t *brdp)
 
        brdp->state |= BST_FOUND;
        return 0;
+err_unmap:
+       iounmap(brdp->membase);
+       brdp->membase = NULL;
+err_reg:
+       release_region(brdp->iobase, brdp->iosize);
+err:
+       return retval;
 }
 
 /*****************************************************************************/
@@ -3510,23 +3356,27 @@ static int stli_initecp(stlibrd_t *brdp)
  *     This handles only these board types.
  */
 
-static int stli_initonb(stlibrd_t *brdp)
+static int stli_initonb(struct stlibrd *brdp)
 {
        cdkonbsig_t sig;
        cdkonbsig_t __iomem *sigsp;
        char *name;
-       int i;
+       int i, retval;
 
 /*
  *     Do a basic sanity check on the IO and memory addresses.
  */
-       if (brdp->iobase == 0 || brdp->memaddr == 0)
-               return -ENODEV;
+       if (brdp->iobase == 0 || brdp->memaddr == 0) {
+               retval = -ENODEV;
+               goto err;
+       }
 
        brdp->iosize = ONB_IOSIZE;
        
-       if (!request_region(brdp->iobase, brdp->iosize, "istallion"))
-               return -EIO;
+       if (!request_region(brdp->iobase, brdp->iosize, "istallion")) {
+               retval = -EIO;
+               goto err;
+       }
 
 /*
  *     Based on the specific board type setup the common vars to access
@@ -3535,10 +3385,7 @@ static int stli_initonb(stlibrd_t *brdp)
  */
        switch (brdp->brdtype) {
        case BRD_ONBOARD:
-       case BRD_ONBOARD32:
        case BRD_ONBOARD2:
-       case BRD_ONBOARD2_32:
-       case BRD_ONBOARDRS:
                brdp->memsize = ONB_MEMSIZE;
                brdp->pagesize = ONB_ATPAGESIZE;
                brdp->init = stli_onbinit;
@@ -3569,8 +3416,6 @@ static int stli_initonb(stlibrd_t *brdp)
                break;
 
        case BRD_BRUMBY4:
-       case BRD_BRUMBY8:
-       case BRD_BRUMBY16:
                brdp->memsize = BBY_MEMSIZE;
                brdp->pagesize = BBY_PAGESIZE;
                brdp->init = stli_bbyinit;
@@ -3597,8 +3442,8 @@ static int stli_initonb(stlibrd_t *brdp)
                break;
 
        default:
-               release_region(brdp->iobase, brdp->iosize);
-               return -EINVAL;
+               retval = -EINVAL;
+               goto err_reg;
        }
 
 /*
@@ -3610,10 +3455,9 @@ static int stli_initonb(stlibrd_t *brdp)
        EBRDINIT(brdp);
 
        brdp->membase = ioremap(brdp->memaddr, brdp->memsize);
-       if (brdp->membase == NULL)
-       {
-               release_region(brdp->iobase, brdp->iosize);
-               return -ENOMEM;
+       if (brdp->membase == NULL) {
+               retval = -ENOMEM;
+               goto err_reg;
        }
 
 /*
@@ -3629,10 +3473,9 @@ static int stli_initonb(stlibrd_t *brdp)
        if (sig.magic0 != cpu_to_le16(ONB_MAGIC0) ||
            sig.magic1 != cpu_to_le16(ONB_MAGIC1) ||
            sig.magic2 != cpu_to_le16(ONB_MAGIC2) ||
-           sig.magic3 != cpu_to_le16(ONB_MAGIC3))
-       {
-               release_region(brdp->iobase, brdp->iosize);
-               return -ENODEV;
+           sig.magic3 != cpu_to_le16(ONB_MAGIC3)) {
+               retval = -ENODEV;
+               goto err_unmap;
        }
 
 /*
@@ -3654,6 +3497,13 @@ static int stli_initonb(stlibrd_t *brdp)
 
        brdp->state |= BST_FOUND;
        return 0;
+err_unmap:
+       iounmap(brdp->membase);
+       brdp->membase = NULL;
+err_reg:
+       release_region(brdp->iobase, brdp->iosize);
+err:
+       return retval;
 }
 
 /*****************************************************************************/
@@ -3664,14 +3514,15 @@ static int stli_initonb(stlibrd_t *brdp)
  *     read in the memory map, and get the show on the road...
  */
 
-static int stli_startbrd(stlibrd_t *brdp)
+static int stli_startbrd(struct stlibrd *brdp)
 {
        cdkhdr_t __iomem *hdrp;
        cdkmem_t __iomem *memp;
        cdkasy_t __iomem *ap;
        unsigned long flags;
-       stliport_t *portp;
-       int portnr, nrdevs, i, rc = 0;
+       unsigned int portnr, nrdevs, i;
+       struct stliport *portp;
+       int rc = 0;
        u32 memoff;
 
        spin_lock_irqsave(&brd_lock, flags);
@@ -3758,8 +3609,7 @@ stli_donestartup:
 
        if (! stli_timeron) {
                stli_timeron++;
-               stli_timerlist.expires = STLI_TIMEOUT;
-               add_timer(&stli_timerlist);
+               mod_timer(&stli_timerlist, STLI_TIMEOUT);
        }
 
        return rc;
@@ -3771,49 +3621,32 @@ stli_donestartup:
  *     Probe and initialize the specified board.
  */
 
-static int __init stli_brdinit(stlibrd_t *brdp)
+static int __devinit stli_brdinit(struct stlibrd *brdp)
 {
-       stli_brds[brdp->brdnr] = brdp;
+       int retval;
 
        switch (brdp->brdtype) {
        case BRD_ECP:
        case BRD_ECPE:
        case BRD_ECPMC:
        case BRD_ECPPCI:
-               stli_initecp(brdp);
+               retval = stli_initecp(brdp);
                break;
        case BRD_ONBOARD:
        case BRD_ONBOARDE:
        case BRD_ONBOARD2:
-       case BRD_ONBOARD32:
-       case BRD_ONBOARD2_32:
-       case BRD_ONBOARDRS:
        case BRD_BRUMBY4:
-       case BRD_BRUMBY8:
-       case BRD_BRUMBY16:
        case BRD_STALLION:
-               stli_initonb(brdp);
+               retval = stli_initonb(brdp);
                break;
-       case BRD_EASYIO:
-       case BRD_ECH:
-       case BRD_ECHMC:
-       case BRD_ECHPCI:
-               printk(KERN_ERR "STALLION: %s board type not supported in "
-                               "this driver\n", stli_brdnames[brdp->brdtype]);
-               return -ENODEV;
        default:
                printk(KERN_ERR "STALLION: board=%d is unknown board "
                                "type=%d\n", brdp->brdnr, brdp->brdtype);
-               return -ENODEV;
+               retval = -ENODEV;
        }
 
-       if ((brdp->state & BST_FOUND) == 0) {
-               printk(KERN_ERR "STALLION: %s board not found, board=%d "
-                               "io=%x mem=%x\n",
-                       stli_brdnames[brdp->brdtype], brdp->brdnr,
-                       brdp->iobase, (int) brdp->memaddr);
-               return -ENODEV;
-       }
+       if (retval)
+               return retval;
 
        stli_initports(brdp);
        printk(KERN_INFO "STALLION: %s found, board=%d io=%x mem=%x "
@@ -3823,6 +3656,7 @@ static int __init stli_brdinit(stlibrd_t *brdp)
        return 0;
 }
 
+#if STLI_EISAPROBE != 0
 /*****************************************************************************/
 
 /*
@@ -3830,7 +3664,7 @@ static int __init stli_brdinit(stlibrd_t *brdp)
  *     might be. This is a bit if hack, but it is the best we can do.
  */
 
-static int stli_eisamemprobe(stlibrd_t *brdp)
+static int stli_eisamemprobe(struct stlibrd *brdp)
 {
        cdkecpsig_t     ecpsig, __iomem *ecpsigp;
        cdkonbsig_t     onbsig, __iomem *onbsigp;
@@ -3916,10 +3750,11 @@ static int stli_eisamemprobe(stlibrd_t *brdp)
        }
        return 0;
 }
+#endif
 
 static int stli_getbrdnr(void)
 {
-       int i;
+       unsigned int i;
 
        for (i = 0; i < STL_MAXBRDS; i++) {
                if (!stli_brds[i]) {
@@ -3931,6 +3766,7 @@ static int stli_getbrdnr(void)
        return -1;
 }
 
+#if STLI_EISAPROBE != 0
 /*****************************************************************************/
 
 /*
@@ -3945,9 +3781,9 @@ static int stli_getbrdnr(void)
 
 static int stli_findeisabrds(void)
 {
-       stlibrd_t *brdp;
-       unsigned int iobase, eid;
-       int i;
+       struct stlibrd *brdp;
+       unsigned int iobase, eid, i;
+       int brdnr, found = 0;
 
 /*
  *     Firstly check if this is an EISA system.  If this is not an EISA system then
@@ -3985,9 +3821,11 @@ static int stli_findeisabrds(void)
  *             Allocate a board structure and initialize it.
  */
                if ((brdp = stli_allocbrd()) == NULL)
-                       return -ENOMEM;
-               if ((brdp->brdnr = stli_getbrdnr()) < 0)
-                       return -ENOMEM;
+                       return found ? : -ENOMEM;
+               brdnr = stli_getbrdnr();
+               if (brdnr < 0)
+                       return found ? : -ENOMEM;
+               brdp->brdnr = (unsigned int)brdnr;
                eid = inb(iobase + 0xc82);
                if (eid == ECP_EISAID)
                        brdp->brdtype = BRD_ECPE;
@@ -3999,11 +3837,24 @@ static int stli_findeisabrds(void)
                outb(0x1, (iobase + 0xc84));
                if (stli_eisamemprobe(brdp))
                        outb(0, (iobase + 0xc84));
-               stli_brdinit(brdp);
+               if (stli_brdinit(brdp) < 0) {
+                       kfree(brdp);
+                       continue;
+               }
+
+               stli_brds[brdp->brdnr] = brdp;
+               found++;
+
+               for (i = 0; i < brdp->nrports; i++)
+                       tty_register_device(stli_serial,
+                                       brdp->brdnr * STL_MAXPORTS + i, NULL);
        }
 
-       return 0;
+       return found;
 }
+#else
+static inline int stli_findeisabrds(void) { return 0; }
+#endif
 
 /*****************************************************************************/
 
@@ -4013,72 +3864,104 @@ static int stli_findeisabrds(void)
 
 /*****************************************************************************/
 
-#ifdef CONFIG_PCI
-
 /*
  *     We have a Stallion board. Allocate a board structure and
  *     initialize it. Read its IO and MEMORY resources from PCI
  *     configuration space.
  */
 
-static int stli_initpcibrd(int brdtype, struct pci_dev *devp)
+static int __devinit stli_pciprobe(struct pci_dev *pdev,
+               const struct pci_device_id *ent)
 {
-       stlibrd_t *brdp;
-
-       if (pci_enable_device(devp))
-               return -EIO;
-       if ((brdp = stli_allocbrd()) == NULL)
-               return -ENOMEM;
-       if ((brdp->brdnr = stli_getbrdnr()) < 0) {
+       struct stlibrd *brdp;
+       unsigned int i;
+       int brdnr, retval = -EIO;
+
+       retval = pci_enable_device(pdev);
+       if (retval)
+               goto err;
+       brdp = stli_allocbrd();
+       if (brdp == NULL) {
+               retval = -ENOMEM;
+               goto err;
+       }
+       mutex_lock(&stli_brdslock);
+       brdnr = stli_getbrdnr();
+       if (brdnr < 0) {
                printk(KERN_INFO "STALLION: too many boards found, "
                        "maximum supported %d\n", STL_MAXBRDS);
-               return 0;
+               mutex_unlock(&stli_brdslock);
+               retval = -EIO;
+               goto err_fr;
        }
-       brdp->brdtype = brdtype;
+       brdp->brdnr = (unsigned int)brdnr;
+       stli_brds[brdp->brdnr] = brdp;
+       mutex_unlock(&stli_brdslock);
+       brdp->brdtype = BRD_ECPPCI;
 /*
  *     We have all resources from the board, so lets setup the actual
  *     board structure now.
  */
-       brdp->iobase = pci_resource_start(devp, 3);
-       brdp->memaddr = pci_resource_start(devp, 2);
-       stli_brdinit(brdp);
+       brdp->iobase = pci_resource_start(pdev, 3);
+       brdp->memaddr = pci_resource_start(pdev, 2);
+       retval = stli_brdinit(brdp);
+       if (retval)
+               goto err_null;
+
+       brdp->state |= BST_PROBED;
+       pci_set_drvdata(pdev, brdp);
+
+       EBRDENABLE(brdp);
+       brdp->enable = NULL;
+       brdp->disable = NULL;
+
+       for (i = 0; i < brdp->nrports; i++)
+               tty_register_device(stli_serial, brdp->brdnr * STL_MAXPORTS + i,
+                               &pdev->dev);
 
        return 0;
+err_null:
+       stli_brds[brdp->brdnr] = NULL;
+err_fr:
+       kfree(brdp);
+err:
+       return retval;
 }
 
-/*****************************************************************************/
+static void stli_pciremove(struct pci_dev *pdev)
+{
+       struct stlibrd *brdp = pci_get_drvdata(pdev);
 
-/*
- *     Find all Stallion PCI boards that might be installed. Initialize each
- *     one as it is found.
- */
+       stli_cleanup_ports(brdp);
 
-static int stli_findpcibrds(void)
-{
-       struct pci_dev *dev = NULL;
+       iounmap(brdp->membase);
+       if (brdp->iosize > 0)
+               release_region(brdp->iobase, brdp->iosize);
 
-       while ((dev = pci_get_device(PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA, dev))) {
-               stli_initpcibrd(BRD_ECPPCI, dev);
-       }
-       return 0;
+       stli_brds[brdp->brdnr] = NULL;
+       kfree(brdp);
 }
 
-#endif
-
+static struct pci_driver stli_pcidriver = {
+       .name = "istallion",
+       .id_table = istallion_pci_tbl,
+       .probe = stli_pciprobe,
+       .remove = __devexit_p(stli_pciremove)
+};
 /*****************************************************************************/
 
 /*
  *     Allocate a new board structure. Fill out the basic info in it.
  */
 
-static stlibrd_t *stli_allocbrd(void)
+static struct stlibrd *stli_allocbrd(void)
 {
-       stlibrd_t *brdp;
+       struct stlibrd *brdp;
 
-       brdp = kzalloc(sizeof(stlibrd_t), GFP_KERNEL);
+       brdp = kzalloc(sizeof(struct stlibrd), GFP_KERNEL);
        if (!brdp) {
                printk(KERN_ERR "STALLION: failed to allocate memory "
-                               "(size=%Zd)\n", sizeof(stlibrd_t));
+                               "(size=%Zd)\n", sizeof(struct stlibrd));
                return NULL;
        }
        brdp->magic = STLI_BOARDMAGIC;
@@ -4094,43 +3977,37 @@ static stlibrd_t *stli_allocbrd(void)
 
 static int stli_initbrds(void)
 {
-       stlibrd_t *brdp, *nxtbrdp;
-       stlconf_t *confp;
-       int i, j;
-
-       if (stli_nrbrds > STL_MAXBRDS) {
-               printk(KERN_INFO "STALLION: too many boards in configuration "
-                       "table, truncating to %d\n", STL_MAXBRDS);
-               stli_nrbrds = STL_MAXBRDS;
-       }
+       struct stlibrd *brdp, *nxtbrdp;
+       struct stlconf conf;
+       unsigned int i, j, found = 0;
+       int retval;
 
-/*
- *     Firstly scan the list of static boards configured. Allocate
- *     resources and initialize the boards as found. If this is a
- *     module then let the module args override static configuration.
- */
-       for (i = 0; (i < stli_nrbrds); i++) {
-               confp = &stli_brdconf[i];
-               stli_parsebrd(confp, stli_brdsp[i]);
+       for (stli_nrbrds = 0; stli_nrbrds < ARRAY_SIZE(stli_brdsp);
+                       stli_nrbrds++) {
+               memset(&conf, 0, sizeof(conf));
+               if (stli_parsebrd(&conf, stli_brdsp[stli_nrbrds]) == 0)
+                       continue;
                if ((brdp = stli_allocbrd()) == NULL)
-                       return -ENOMEM;
-               brdp->brdnr = i;
-               brdp->brdtype = confp->brdtype;
-               brdp->iobase = confp->ioaddr1;
-               brdp->memaddr = confp->memaddr;
-               stli_brdinit(brdp);
+                       continue;
+               brdp->brdnr = stli_nrbrds;
+               brdp->brdtype = conf.brdtype;
+               brdp->iobase = conf.ioaddr1;
+               brdp->memaddr = conf.memaddr;
+               if (stli_brdinit(brdp) < 0) {
+                       kfree(brdp);
+                       continue;
+               }
+               stli_brds[brdp->brdnr] = brdp;
+               found++;
+
+               for (i = 0; i < brdp->nrports; i++)
+                       tty_register_device(stli_serial,
+                                       brdp->brdnr * STL_MAXPORTS + i, NULL);
        }
 
-/*
- *     Static configuration table done, so now use dynamic methods to
- *     see if any more boards should be configured.
- */
-       stli_argbrds();
-       if (STLI_EISAPROBE)
-               stli_findeisabrds();
-#ifdef CONFIG_PCI
-       stli_findpcibrds();
-#endif
+       retval = stli_findeisabrds();
+       if (retval > 0)
+               found += retval;
 
 /*
  *     All found boards are initialized. Now for a little optimization, if
@@ -4170,7 +4047,16 @@ static int stli_initbrds(void)
                }
        }
 
+       retval = pci_register_driver(&stli_pcidriver);
+       if (retval && found == 0) {
+               printk(KERN_ERR "Neither isa nor eisa cards found nor pci "
+                               "driver can be registered!\n");
+               goto err;
+       }
+
        return 0;
+err:
+       return retval;
 }
 
 /*****************************************************************************/
@@ -4185,12 +4071,13 @@ static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, lof
 {
        unsigned long flags;
        void __iomem *memptr;
-       stlibrd_t *brdp;
-       int brdnr, size, n;
+       struct stlibrd *brdp;
+       unsigned int brdnr;
+       int size, n;
        void *p;
        loff_t off = *offp;
 
-       brdnr = iminor(fp->f_dentry->d_inode);
+       brdnr = iminor(fp->f_path.dentry->d_inode);
        if (brdnr >= stli_nrbrds)
                return -ENODEV;
        brdp = stli_brds[brdnr];
@@ -4201,7 +4088,7 @@ static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, lof
        if (off >= brdp->memsize || off + count < off)
                return 0;
 
-       size = MIN(count, (brdp->memsize - off));
+       size = min(count, (size_t)(brdp->memsize - off));
 
        /*
         *      Copy the data a page at a time
@@ -4215,8 +4102,8 @@ static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, lof
                spin_lock_irqsave(&brd_lock, flags);
                EBRDENABLE(brdp);
                memptr = EBRDGETMEMPTR(brdp, off);
-               n = MIN(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize)));
-               n = MIN(n, PAGE_SIZE);
+               n = min(size, (int)(brdp->pagesize - (((unsigned long) off) % brdp->pagesize)));
+               n = min(n, (int)PAGE_SIZE);
                memcpy_fromio(p, memptr, n);
                EBRDDISABLE(brdp);
                spin_unlock_irqrestore(&brd_lock, flags);
@@ -4248,13 +4135,14 @@ static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t cou
 {
        unsigned long flags;
        void __iomem *memptr;
-       stlibrd_t *brdp;
+       struct stlibrd *brdp;
        char __user *chbuf;
-       int brdnr, size, n;
+       unsigned int brdnr;
+       int size, n;
        void *p;
        loff_t off = *offp;
 
-       brdnr = iminor(fp->f_dentry->d_inode);
+       brdnr = iminor(fp->f_path.dentry->d_inode);
 
        if (brdnr >= stli_nrbrds)
                return -ENODEV;
@@ -4267,7 +4155,7 @@ static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t cou
                return 0;
 
        chbuf = (char __user *) buf;
-       size = MIN(count, (brdp->memsize - off));
+       size = min(count, (size_t)(brdp->memsize - off));
 
        /*
         *      Copy the data a page at a time
@@ -4278,8 +4166,8 @@ static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t cou
                return -ENOMEM;
 
        while (size > 0) {
-               n = MIN(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize)));
-               n = MIN(n, PAGE_SIZE);
+               n = min(size, (int)(brdp->pagesize - (((unsigned long) off) % brdp->pagesize)));
+               n = min(n, (int)PAGE_SIZE);
                if (copy_from_user(p, chbuf, n)) {
                        if (count == 0)
                                count = -EFAULT;
@@ -4309,8 +4197,8 @@ out:
 
 static int stli_getbrdstats(combrd_t __user *bp)
 {
-       stlibrd_t *brdp;
-       int i;
+       struct stlibrd *brdp;
+       unsigned int i;
 
        if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t)))
                return -EFAULT;
@@ -4346,19 +4234,20 @@ static int stli_getbrdstats(combrd_t __user *bp)
  *     Resolve the referenced port number into a port struct pointer.
  */
 
-static stliport_t *stli_getport(int brdnr, int panelnr, int portnr)
+static struct stliport *stli_getport(unsigned int brdnr, unsigned int panelnr,
+               unsigned int portnr)
 {
-       stlibrd_t *brdp;
-       int i;
+       struct stlibrd *brdp;
+       unsigned int i;
 
-       if (brdnr < 0 || brdnr >= STL_MAXBRDS)
+       if (brdnr >= STL_MAXBRDS)
                return NULL;
        brdp = stli_brds[brdnr];
        if (brdp == NULL)
                return NULL;
        for (i = 0; (i < panelnr); i++)
                portnr += brdp->panels[i];
-       if ((portnr < 0) || (portnr >= brdp->nrports))
+       if (portnr >= brdp->nrports)
                return NULL;
        return brdp->ports[portnr];
 }
@@ -4371,10 +4260,10 @@ static stliport_t *stli_getport(int brdnr, int panelnr, int portnr)
  *     what port to get stats for (used through board control device).
  */
 
-static int stli_portcmdstats(stliport_t *portp)
+static int stli_portcmdstats(struct stliport *portp)
 {
        unsigned long   flags;
-       stlibrd_t       *brdp;
+       struct stlibrd  *brdp;
        int             rc;
 
        memset(&stli_comstats, 0, sizeof(comstats_t));
@@ -4445,9 +4334,9 @@ static int stli_portcmdstats(stliport_t *portp)
  *     what port to get stats for (used through board control device).
  */
 
-static int stli_getportstats(stliport_t *portp, comstats_t __user *cp)
+static int stli_getportstats(struct stliport *portp, comstats_t __user *cp)
 {
-       stlibrd_t *brdp;
+       struct stlibrd *brdp;
        int rc;
 
        if (!portp) {
@@ -4476,9 +4365,9 @@ static int stli_getportstats(stliport_t *portp, comstats_t __user *cp)
  *     Clear the port stats structure. We also return it zeroed out...
  */
 
-static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp)
+static int stli_clrportstats(struct stliport *portp, comstats_t __user *cp)
 {
-       stlibrd_t *brdp;
+       struct stlibrd *brdp;
        int rc;
 
        if (!portp) {
@@ -4515,17 +4404,18 @@ static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp)
  *     Return the entire driver ports structure to a user app.
  */
 
-static int stli_getportstruct(stliport_t __user *arg)
+static int stli_getportstruct(struct stliport __user *arg)
 {
-       stliport_t *portp;
+       struct stliport stli_dummyport;
+       struct stliport *portp;
 
-       if (copy_from_user(&stli_dummyport, arg, sizeof(stliport_t)))
+       if (copy_from_user(&stli_dummyport, arg, sizeof(struct stliport)))
                return -EFAULT;
        portp = stli_getport(stli_dummyport.brdnr, stli_dummyport.panelnr,
                 stli_dummyport.portnr);
        if (!portp)
                return -ENODEV;
-       if (copy_to_user(arg, portp, sizeof(stliport_t)))
+       if (copy_to_user(arg, portp, sizeof(struct stliport)))
                return -EFAULT;
        return 0;
 }
@@ -4536,18 +4426,19 @@ static int stli_getportstruct(stliport_t __user *arg)
  *     Return the entire driver board structure to a user app.
  */
 
-static int stli_getbrdstruct(stlibrd_t __user *arg)
+static int stli_getbrdstruct(struct stlibrd __user *arg)
 {
-       stlibrd_t *brdp;
+       struct stlibrd stli_dummybrd;
+       struct stlibrd *brdp;
 
-       if (copy_from_user(&stli_dummybrd, arg, sizeof(stlibrd_t)))
+       if (copy_from_user(&stli_dummybrd, arg, sizeof(struct stlibrd)))
                return -EFAULT;
-       if ((stli_dummybrd.brdnr < 0) || (stli_dummybrd.brdnr >= STL_MAXBRDS))
+       if (stli_dummybrd.brdnr >= STL_MAXBRDS)
                return -ENODEV;
        brdp = stli_brds[stli_dummybrd.brdnr];
        if (!brdp)
                return -ENODEV;
-       if (copy_to_user(arg, brdp, sizeof(stlibrd_t)))
+       if (copy_to_user(arg, brdp, sizeof(struct stlibrd)))
                return -EFAULT;
        return 0;
 }
@@ -4562,7 +4453,7 @@ static int stli_getbrdstruct(stlibrd_t __user *arg)
 
 static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg)
 {
-       stlibrd_t *brdp;
+       struct stlibrd *brdp;
        int brdnr, rc, done;
        void __user *argp = (void __user *)arg;
 
@@ -4661,46 +4552,53 @@ static const struct tty_operations stli_ops = {
 };
 
 /*****************************************************************************/
+/*
+ *     Loadable module initialization stuff.
+ */
+
+static void istallion_cleanup_isa(void)
+{
+       struct stlibrd  *brdp;
+       unsigned int j;
+
+       for (j = 0; (j < stli_nrbrds); j++) {
+               if ((brdp = stli_brds[j]) == NULL || (brdp->state & BST_PROBED))
+                       continue;
 
-static int __init stli_init(void)
+               stli_cleanup_ports(brdp);
+
+               iounmap(brdp->membase);
+               if (brdp->iosize > 0)
+                       release_region(brdp->iobase, brdp->iosize);
+               kfree(brdp);
+               stli_brds[j] = NULL;
+       }
+}
+
+static int __init istallion_module_init(void)
 {
-       int i;
+       unsigned int i;
+       int retval;
+
        printk(KERN_INFO "%s: version %s\n", stli_drvtitle, stli_drvversion);
 
        spin_lock_init(&stli_lock);
        spin_lock_init(&brd_lock);
 
-       stli_initbrds();
-
-       stli_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
-       if (!stli_serial)
-               return -ENOMEM;
-
-/*
- *     Allocate a temporary write buffer.
- */
        stli_txcookbuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL);
-       if (!stli_txcookbuf)
+       if (!stli_txcookbuf) {
                printk(KERN_ERR "STALLION: failed to allocate memory "
                                "(size=%d)\n", STLI_TXBUFSIZE);
+               retval = -ENOMEM;
+               goto err;
+       }
 
-/*
- *     Set up a character driver for the shared memory region. We need this
- *     to down load the slave code image. Also it is a useful debugging tool.
- */
-       if (register_chrdev(STL_SIOMEMMAJOR, "staliomem", &stli_fsiomem))
-               printk(KERN_ERR "STALLION: failed to register serial memory "
-                               "device\n");
-
-       istallion_class = class_create(THIS_MODULE, "staliomem");
-       for (i = 0; i < 4; i++)
-               class_device_create(istallion_class, NULL,
-                               MKDEV(STL_SIOMEMMAJOR, i),
-                               NULL, "staliomem%d", i);
+       stli_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
+       if (!stli_serial) {
+               retval = -ENOMEM;
+               goto err_free;
+       }
 
-/*
- *     Set up the tty driver structure and register us as a driver.
- */
        stli_serial->owner = THIS_MODULE;
        stli_serial->driver_name = stli_drvname;
        stli_serial->name = stli_serialname;
@@ -4709,15 +4607,79 @@ static int __init stli_init(void)
        stli_serial->type = TTY_DRIVER_TYPE_SERIAL;
        stli_serial->subtype = SERIAL_TYPE_NORMAL;
        stli_serial->init_termios = stli_deftermios;
-       stli_serial->flags = TTY_DRIVER_REAL_RAW;
+       stli_serial->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
        tty_set_operations(stli_serial, &stli_ops);
 
-       if (tty_register_driver(stli_serial)) {
-               put_tty_driver(stli_serial);
+       retval = tty_register_driver(stli_serial);
+       if (retval) {
                printk(KERN_ERR "STALLION: failed to register serial driver\n");
-               return -EBUSY;
+               goto err_ttyput;
        }
+
+       retval = stli_initbrds();
+       if (retval)
+               goto err_ttyunr;
+
+/*
+ *     Set up a character driver for the shared memory region. We need this
+ *     to down load the slave code image. Also it is a useful debugging tool.
+ */
+       retval = register_chrdev(STL_SIOMEMMAJOR, "staliomem", &stli_fsiomem);
+       if (retval) {
+               printk(KERN_ERR "STALLION: failed to register serial memory "
+                               "device\n");
+               goto err_deinit;
+       }
+
+       istallion_class = class_create(THIS_MODULE, "staliomem");
+       for (i = 0; i < 4; i++)
+               class_device_create(istallion_class, NULL,
+                               MKDEV(STL_SIOMEMMAJOR, i),
+                               NULL, "staliomem%d", i);
+
        return 0;
+err_deinit:
+       pci_unregister_driver(&stli_pcidriver);
+       istallion_cleanup_isa();
+err_ttyunr:
+       tty_unregister_driver(stli_serial);
+err_ttyput:
+       put_tty_driver(stli_serial);
+err_free:
+       kfree(stli_txcookbuf);
+err:
+       return retval;
 }
 
 /*****************************************************************************/
+
+static void __exit istallion_module_exit(void)
+{
+       unsigned int j;
+
+       printk(KERN_INFO "Unloading %s: version %s\n", stli_drvtitle,
+               stli_drvversion);
+
+       if (stli_timeron) {
+               stli_timeron = 0;
+               del_timer_sync(&stli_timerlist);
+       }
+
+       unregister_chrdev(STL_SIOMEMMAJOR, "staliomem");
+
+       for (j = 0; j < 4; j++)
+               class_device_destroy(istallion_class, MKDEV(STL_SIOMEMMAJOR,
+                                       j));
+       class_destroy(istallion_class);
+
+       pci_unregister_driver(&stli_pcidriver);
+       istallion_cleanup_isa();
+
+       tty_unregister_driver(stli_serial);
+       put_tty_driver(stli_serial);
+
+       kfree(stli_txcookbuf);
+}
+
+module_init(istallion_module_init);
+module_exit(istallion_module_exit);
index 20b6c8b30248f354f4bfcf5b3d6fffbb4a07a112..7a6c1c0b7a95861f9e4a70c4d6dca302491e5987 100644 (file)
@@ -710,7 +710,7 @@ static void k_fn(struct vc_data *vc, unsigned char value, char up_flag)
 
 static void k_cur(struct vc_data *vc, unsigned char value, char up_flag)
 {
-       static const char *cur_chars = "BDCA";
+       static const char cur_chars[] = "BDCA";
 
        if (up_flag)
                return;
index 1ecea7d448f14618e19112b6c84dd75a25c25d7d..b70b5388b5a81774b5050574cbd2383de0662455 100644 (file)
@@ -296,7 +296,7 @@ static int lp_wait_ready(int minor, int nonblock)
 static ssize_t lp_write(struct file * file, const char __user * buf,
                        size_t count, loff_t *ppos)
 {
-       unsigned int minor = iminor(file->f_dentry->d_inode);
+       unsigned int minor = iminor(file->f_path.dentry->d_inode);
        struct parport *port = lp_table[minor].dev->port;
        char *kbuf = lp_table[minor].lp_buffer;
        ssize_t retv = 0;
@@ -415,7 +415,7 @@ static ssize_t lp_read(struct file * file, char __user * buf,
                       size_t count, loff_t *ppos)
 {
        DEFINE_WAIT(wait);
-       unsigned int minor=iminor(file->f_dentry->d_inode);
+       unsigned int minor=iminor(file->f_path.dentry->d_inode);
        struct parport *port = lp_table[minor].dev->port;
        ssize_t retval = 0;
        char *kbuf = lp_table[minor].lp_buffer;
index e67eef4867ba02c8af26652b811b290057bf959e..089020e0ee5aa83ce48ff8b15470724a45eafdc4 100644 (file)
@@ -774,7 +774,7 @@ static loff_t memory_lseek(struct file * file, loff_t offset, int orig)
 {
        loff_t ret;
 
-       mutex_lock(&file->f_dentry->d_inode->i_mutex);
+       mutex_lock(&file->f_path.dentry->d_inode->i_mutex);
        switch (orig) {
                case 0:
                        file->f_pos = offset;
@@ -789,7 +789,7 @@ static loff_t memory_lseek(struct file * file, loff_t offset, int orig)
                default:
                        ret = -EINVAL;
        }
-       mutex_unlock(&file->f_dentry->d_inode->i_mutex);
+       mutex_unlock(&file->f_path.dentry->d_inode->i_mutex);
        return ret;
 }
 
index 7a484fc7cb9eae84d0a3b04e82f18c6e7e263955..7e975f606924e04b6d24eef36707cbc97723cebc 100644 (file)
@@ -199,6 +199,8 @@ int misc_register(struct miscdevice * misc)
        dev_t dev;
        int err = 0;
 
+       INIT_LIST_HEAD(&misc->list);
+
        down(&misc_sem);
        list_for_each_entry(c, &misc_list, list) {
                if (c->minor == misc->minor) {
index 22b9905c1e526f7521c0b70a143c766c1e0f534c..c09160383a5332c9635c4813215dabd9063bade8 100644 (file)
@@ -680,7 +680,7 @@ static int __init mmtimer_init(void)
        if (sn_rtc_cycles_per_second < 100000) {
                printk(KERN_ERR "%s: unable to determine clock frequency\n",
                       MMTIMER_NAME);
-               return -1;
+               goto out1;
        }
 
        mmtimer_femtoperiod = ((unsigned long)1E15 + sn_rtc_cycles_per_second /
@@ -689,13 +689,13 @@ static int __init mmtimer_init(void)
        if (request_irq(SGI_MMTIMER_VECTOR, mmtimer_interrupt, IRQF_PERCPU, MMTIMER_NAME, NULL)) {
                printk(KERN_WARNING "%s: unable to allocate interrupt.",
                        MMTIMER_NAME);
-               return -1;
+               goto out1;
        }
 
        if (misc_register(&mmtimer_miscdev)) {
                printk(KERN_ERR "%s: failed to register device\n",
                       MMTIMER_NAME);
-               return -1;
+               goto out2;
        }
 
        /* Get max numbered node, calculate slots needed */
@@ -709,16 +709,18 @@ static int __init mmtimer_init(void)
        if (timers == NULL) {
                printk(KERN_ERR "%s: failed to allocate memory for device\n",
                                MMTIMER_NAME);
-               return -1;
+               goto out3;
        }
 
+       memset(timers,0,(sizeof(mmtimer_t *)*maxn));
+
        /* Allocate mmtimer_t's for each online node */
        for_each_online_node(node) {
                timers[node] = kmalloc_node(sizeof(mmtimer_t)*NUM_COMPARATORS, GFP_KERNEL, node);
                if (timers[node] == NULL) {
                        printk(KERN_ERR "%s: failed to allocate memory for device\n",
                                MMTIMER_NAME);
-                       return -1;
+                       goto out4;
                }
                for (i=0; i< NUM_COMPARATORS; i++) {
                        mmtimer_t * base = timers[node] + i;
@@ -739,6 +741,17 @@ static int __init mmtimer_init(void)
               sn_rtc_cycles_per_second/(unsigned long)1E6);
 
        return 0;
+
+out4:
+       for_each_online_node(node) {
+               kfree(timers[node]);
+       }
+out3:
+       misc_deregister(&mmtimer_miscdev);
+out2:
+       free_irq(SGI_MMTIMER_VECTOR, NULL);
+out1:
+       return -1;
 }
 
 module_init(mmtimer_init);
index 2d025a9fd14ddeb5d6d52d5bce0411c10354a9bd..f391a24a1b442c1e8eb4aaf1c1857d015dfdc89b 100644 (file)
@@ -234,7 +234,7 @@ static void moxa_put_char(struct tty_struct *, unsigned char);
 static int moxa_ioctl(struct tty_struct *, struct file *, unsigned int, unsigned long);
 static void moxa_throttle(struct tty_struct *);
 static void moxa_unthrottle(struct tty_struct *);
-static void moxa_set_termios(struct tty_struct *, struct termios *);
+static void moxa_set_termios(struct tty_struct *, struct ktermios *);
 static void moxa_stop(struct tty_struct *);
 static void moxa_start(struct tty_struct *);
 static void moxa_hangup(struct tty_struct *);
@@ -261,7 +261,7 @@ static void MoxaPortEnable(int);
 static void MoxaPortDisable(int);
 static long MoxaPortGetMaxBaud(int);
 static long MoxaPortSetBaud(int, long);
-static int MoxaPortSetTermio(int, struct termios *, speed_t);
+static int MoxaPortSetTermio(int, struct ktermios *, speed_t);
 static int MoxaPortGetLineOut(int, int *, int *);
 static void MoxaPortLineCtrl(int, int, int);
 static void MoxaPortFlowCtrl(int, int, int, int, int, int);
@@ -355,6 +355,8 @@ static int __init moxa_init(void)
        moxaDriver->init_termios.c_oflag = 0;
        moxaDriver->init_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
        moxaDriver->init_termios.c_lflag = 0;
+       moxaDriver->init_termios.c_ispeed = 9600;
+       moxaDriver->init_termios.c_ospeed = 9600;
        moxaDriver->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(moxaDriver, &moxa_ops);
 
@@ -498,9 +500,12 @@ static void __exit moxa_exit(void)
                printk("Couldn't unregister MOXA Intellio family serial driver\n");
        put_tty_driver(moxaDriver);
 
-       for (i = 0; i < MAX_BOARDS; i++)
+       for (i = 0; i < MAX_BOARDS; i++) {
+               if (moxaBaseAddr[i])
+                       iounmap(moxaBaseAddr[i]);
                if (moxa_boards[i].busType == MOXA_BUS_TYPE_PCI)
                        pci_dev_put(moxa_boards[i].pciInfo.pdev);
+       }
 
        if (verbose)
                printk("Done\n");
@@ -861,7 +866,7 @@ static void moxa_unthrottle(struct tty_struct *tty)
 }
 
 static void moxa_set_termios(struct tty_struct *tty,
-                            struct termios *old_termios)
+                            struct ktermios *old_termios)
 {
        struct moxa_str *ch = (struct moxa_str *) tty->driver_data;
 
@@ -975,7 +980,7 @@ static void moxa_poll(unsigned long ignored)
 
 static void set_tty_param(struct tty_struct *tty)
 {
-       register struct termios *ts;
+       register struct ktermios *ts;
        struct moxa_str *ch;
        int rts, cts, txflow, rxflow, xany;
 
@@ -1146,7 +1151,7 @@ static void shut_down(struct moxa_str *ch)
 static void receive_data(struct moxa_str *ch)
 {
        struct tty_struct *tp;
-       struct termios *ts;
+       struct ktermios *ts;
        unsigned long flags;
 
        ts = NULL;
@@ -1909,9 +1914,9 @@ int MoxaPortsOfCard(int cardno)
  *
  *      Function 12:    Configure the port.
  *      Syntax:
- *      int  MoxaPortSetTermio(int port, struct termios *termio, speed_t baud);
+ *      int  MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud);
  *           int port           : port number (0 - 127)
- *           struct termios * termio : termio structure pointer
+ *           struct ktermios * termio : termio structure pointer
  *          speed_t baud       : baud rate
  *
  *           return:    -1      : this port is invalid or termio == NULL
@@ -2192,7 +2197,7 @@ long MoxaPortSetBaud(int port, long baud)
        return (baud);
 }
 
-int MoxaPortSetTermio(int port, struct termios *termio, speed_t baud)
+int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud)
 {
        void __iomem *ofsAddr;
        tcflag_t cflag;
index 5ed2486b7581dc18b0ca86ee4cefe017bb00975e..c063359baf78ea1f2f020124e4b5f18e598e9db0 100644 (file)
@@ -328,8 +328,8 @@ struct mxser_struct {
        int xmit_tail;
        int xmit_cnt;
        struct work_struct tqueue;
-       struct termios normal_termios;
-       struct termios callout_termios;
+       struct ktermios normal_termios;
+       struct ktermios callout_termios;
        wait_queue_head_t open_wait;
        wait_queue_head_t close_wait;
        wait_queue_head_t delta_msr_wait;
@@ -364,8 +364,8 @@ static int mxserBoardCAP[MXSER_BOARDS] = {
 static struct tty_driver *mxvar_sdriver;
 static struct mxser_struct mxvar_table[MXSER_PORTS];
 static struct tty_struct *mxvar_tty[MXSER_PORTS + 1];
-static struct termios *mxvar_termios[MXSER_PORTS + 1];
-static struct termios *mxvar_termios_locked[MXSER_PORTS + 1];
+static struct ktermios *mxvar_termios[MXSER_PORTS + 1];
+static struct ktermios *mxvar_termios_locked[MXSER_PORTS + 1];
 static struct mxser_log mxvar_log;
 static int mxvar_diagflag;
 static unsigned char mxser_msr[MXSER_PORTS + 1];
@@ -402,7 +402,7 @@ static int mxser_ioctl(struct tty_struct *, struct file *, uint, ulong);
 static int mxser_ioctl_special(unsigned int, void __user *);
 static void mxser_throttle(struct tty_struct *);
 static void mxser_unthrottle(struct tty_struct *);
-static void mxser_set_termios(struct tty_struct *, struct termios *);
+static void mxser_set_termios(struct tty_struct *, struct ktermios *);
 static void mxser_stop(struct tty_struct *);
 static void mxser_start(struct tty_struct *);
 static void mxser_hangup(struct tty_struct *);
@@ -414,7 +414,7 @@ static void mxser_check_modem_status(struct mxser_struct *, int);
 static int mxser_block_til_ready(struct tty_struct *, struct file *, struct mxser_struct *);
 static int mxser_startup(struct mxser_struct *);
 static void mxser_shutdown(struct mxser_struct *);
-static int mxser_change_speed(struct mxser_struct *, struct termios *old_termios);
+static int mxser_change_speed(struct mxser_struct *, struct ktermios *old_termios);
 static int mxser_get_serial_info(struct mxser_struct *, struct serial_struct __user *);
 static int mxser_set_serial_info(struct mxser_struct *, struct serial_struct __user *);
 static int mxser_get_lsr_info(struct mxser_struct *, unsigned int __user *);
@@ -515,6 +515,7 @@ static void __exit mxser_module_exit(void)
                        if (pdev != NULL) {     /* PCI */
                                release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2));
                                release_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3));
+                               pci_dev_put(pdev);
                        } else {
                                release_region(mxsercfg[i].ioaddr[0], 8 * mxsercfg[i].ports);
                                release_region(mxsercfg[i].vector, 1);
@@ -556,7 +557,7 @@ static int mxser_initbrd(int board, struct mxser_hwconf *hwconf)
        n = board * MXSER_PORTS_PER_BOARD;
        info = &mxvar_table[n];
        /*if (verbose) */  {
-               printk(KERN_DEBUG "        ttyM%d - ttyM%d ",
+               printk(KERN_DEBUG "        ttyMI%d - ttyMI%d ",
                        n, n + hwconf->ports - 1);
                printk(" max. baud rate = %d bps.\n",
                        hwconf->MaxCanSetBaudRate[0]);
@@ -717,7 +718,7 @@ static int mxser_init(void)
        /* Initialize the tty_driver structure */
        memset(mxvar_sdriver, 0, sizeof(struct tty_driver));
        mxvar_sdriver->magic = TTY_DRIVER_MAGIC;
-       mxvar_sdriver->name = "ttyM";
+       mxvar_sdriver->name = "ttyMI";
        mxvar_sdriver->major = ttymajor;
        mxvar_sdriver->minor_start = 0;
        mxvar_sdriver->num = MXSER_PORTS + 1;
@@ -725,6 +726,8 @@ static int mxser_init(void)
        mxvar_sdriver->subtype = SERIAL_TYPE_NORMAL;
        mxvar_sdriver->init_termios = tty_std_termios;
        mxvar_sdriver->init_termios.c_cflag = B9600|CS8|CREAD|HUPCL|CLOCAL;
+       mxvar_sdriver->init_termios.c_ispeed = 9600;
+       mxvar_sdriver->init_termios.c_ospeed = 9600;
        mxvar_sdriver->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(mxvar_sdriver, &mxser_ops);
        mxvar_sdriver->ttys = mxvar_tty;
@@ -839,9 +842,9 @@ static int mxser_init(void)
        index = 0;
        b = 0;
        while (b < n) {
-               pdev = pci_find_device(mxser_pcibrds[b].vendor,
+               pdev = pci_get_device(mxser_pcibrds[b].vendor,
                                mxser_pcibrds[b].device, pdev);
-                       if (pdev == NULL) {
+               if (pdev == NULL) {
                        b++;
                        continue;
                }
@@ -893,6 +896,9 @@ static int mxser_init(void)
                        if (mxser_initbrd(m, &hwconf) < 0)
                                continue;
                        m++;
+                       /* Keep an extra reference if we succeeded. It will
+                          be returned at unload time */
+                       pci_dev_get(pdev);
                }
        }
 #endif
@@ -994,7 +1000,7 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
                mxser_change_speed(info, NULL);
        }
 
-       info->session = current->signal->session;
+       info->session = process_session(current);
        info->pgrp = process_group(current);
 
        /*
@@ -1745,7 +1751,7 @@ static void mxser_unthrottle(struct tty_struct *tty)
        /* MX_UNLOCK(&info->slock); */
 }
 
-static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termios)
+static void mxser_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
        struct mxser_struct *info = tty->driver_data;
        unsigned long flags;
@@ -2537,7 +2543,7 @@ static void mxser_shutdown(struct mxser_struct *info)
  * This routine is called to set the UART divisor registers to match
  * the specified baud rate for a serial port.
  */
-static int mxser_change_speed(struct mxser_struct *info, struct termios *old_termios)
+static int mxser_change_speed(struct mxser_struct *info, struct ktermios *old_termios)
 {
        unsigned cflag, cval, fcr;
        int ret = 0;
diff --git a/drivers/char/mxser_new.c b/drivers/char/mxser_new.c
new file mode 100644 (file)
index 0000000..efa8076
--- /dev/null
@@ -0,0 +1,2804 @@
+/*
+ *          mxser.c  -- MOXA Smartio/Industio family multiport serial driver.
+ *
+ *      Copyright (C) 1999-2006  Moxa Technologies (support@moxa.com.tw).
+ *     Copyright (C) 2006       Jiri Slaby <jirislaby@gmail.com>
+ *
+ *      This code is loosely based on the 1.8 moxa driver which is based on
+ *     Linux serial driver, written by Linus Torvalds, Theodore T'so and
+ *     others.
+ *
+ *      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.
+ *
+ *     Fed through a cleanup, indent and remove of non 2.6 code by Alan Cox
+ *     <alan@redhat.com>. The original 1.8 code is available on www.moxa.com.
+ *     - Fixed x86_64 cleanness
+ *     - Fixed sleep with spinlock held in mxser_send_break
+ */
+
+#include <linux/module.h>
+#include <linux/autoconf.h>
+#include <linux/errno.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/timer.h>
+#include <linux/interrupt.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/serial.h>
+#include <linux/serial_reg.h>
+#include <linux/major.h>
+#include <linux/string.h>
+#include <linux/fcntl.h>
+#include <linux/ptrace.h>
+#include <linux/gfp.h>
+#include <linux/ioport.h>
+#include <linux/mm.h>
+#include <linux/smp_lock.h>
+#include <linux/delay.h>
+#include <linux/pci.h>
+
+#include <asm/system.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/bitops.h>
+#include <asm/uaccess.h>
+
+#include "mxser_new.h"
+
+#define        MXSER_VERSION   "2.0"
+#define        MXSERMAJOR       174
+#define        MXSERCUMAJOR     175
+
+#define        MXSER_EVENT_TXLOW       1
+
+#define MXSER_BOARDS           4       /* Max. boards */
+#define MXSER_PORTS_PER_BOARD  8       /* Max. ports per board */
+#define MXSER_PORTS            (MXSER_BOARDS * MXSER_PORTS_PER_BOARD)
+#define MXSER_ISR_PASS_LIMIT   99999L
+
+#define        MXSER_ERR_IOADDR        -1
+#define        MXSER_ERR_IRQ           -2
+#define        MXSER_ERR_IRQ_CONFLIT   -3
+#define        MXSER_ERR_VECTOR        -4
+
+#define WAKEUP_CHARS           256
+
+#define UART_MCR_AFE           0x20
+#define UART_LSR_SPECIAL       0x1E
+
+#define RELEVANT_IFLAG(iflag)  (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|\
+                                         IXON|IXOFF))
+
+#define C168_ASIC_ID    1
+#define C104_ASIC_ID    2
+#define C102_ASIC_ID   0xB
+#define CI132_ASIC_ID  4
+#define CI134_ASIC_ID  3
+#define CI104J_ASIC_ID  5
+
+#define MXSER_HIGHBAUD 1
+#define MXSER_HAS2     2
+
+/* This is only for PCI */
+static const struct {
+       int type;
+       int tx_fifo;
+       int rx_fifo;
+       int xmit_fifo_size;
+       int rx_high_water;
+       int rx_trigger;
+       int rx_low_water;
+       long max_baud;
+} Gpci_uart_info[] = {
+       {MOXA_OTHER_UART, 16, 16, 16, 14, 14, 1, 921600L},
+       {MOXA_MUST_MU150_HWID, 64, 64, 64, 48, 48, 16, 230400L},
+       {MOXA_MUST_MU860_HWID, 128, 128, 128, 96, 96, 32, 921600L}
+};
+#define UART_INFO_NUM  ARRAY_SIZE(Gpci_uart_info)
+
+struct mxser_cardinfo {
+       unsigned int nports;
+       char *name;
+       unsigned int flags;
+};
+
+static const struct mxser_cardinfo mxser_cards[] = {
+       { 8, "C168 series", },                  /* C168-ISA */
+       { 4, "C104 series", },                  /* C104-ISA */
+       { 4, "CI-104J series", },               /* CI104J */
+       { 8, "C168H/PCI series", },             /* C168-PCI */
+       { 4, "C104H/PCI series", },             /* C104-PCI */
+       { 4, "C102 series", MXSER_HAS2 },       /* C102-ISA */
+       { 4, "CI-132 series", MXSER_HAS2 },     /* CI132 */
+       { 4, "CI-134 series", },                /* CI134 */
+       { 2, "CP-132 series", },                /* CP132 */
+       { 4, "CP-114 series", },                /* CP114 */
+       { 4, "CT-114 series", },                /* CT114 */
+       { 2, "CP-102 series", MXSER_HIGHBAUD }, /* CP102 */
+       { 4, "CP-104U series", },               /* CP104U */
+       { 8, "CP-168U series", },               /* CP168U */
+       { 2, "CP-132U series", },               /* CP132U */
+       { 4, "CP-134U series", },               /* CP134U */
+       { 4, "CP-104JU series", },              /* CP104JU */
+       { 8, "Moxa UC7000 Serial", },           /* RC7000 */
+       { 8, "CP-118U series", },               /* CP118U */
+       { 2, "CP-102UL series", },              /* CP102UL */
+       { 2, "CP-102U series", },               /* CP102U */
+       { 8, "CP-118EL series", },              /* CP118EL */
+       { 8, "CP-168EL series", },              /* CP168EL */
+       { 4, "CP-104EL series", }               /* CP104EL */
+};
+
+/* driver_data correspond to the lines in the structure above
+   see also ISA probe function before you change something */
+static struct pci_device_id mxser_pcibrds[] = {
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C168),
+               .driver_data = 3 },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C104),
+               .driver_data = 4 },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP132),
+               .driver_data = 8 },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP114),
+               .driver_data = 9 },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CT114),
+               .driver_data = 10 },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102),
+               .driver_data = 11 },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP104U),
+               .driver_data = 12 },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP168U),
+               .driver_data = 13 },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP132U),
+               .driver_data = 14 },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP134U),
+               .driver_data = 15 },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP104JU),
+               .driver_data = 16 },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_RC7000),
+               .driver_data = 17 },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP118U),
+               .driver_data = 18 },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102UL),
+               .driver_data = 19 },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102U),
+               .driver_data = 20 },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP118EL),
+               .driver_data = 21 },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP168EL),
+               .driver_data = 22 },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP104EL),
+               .driver_data = 23 },
+       { }
+};
+MODULE_DEVICE_TABLE(pci, mxser_pcibrds);
+
+static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 };
+static int ttymajor = MXSERMAJOR;
+static int calloutmajor = MXSERCUMAJOR;
+
+/* Variables for insmod */
+
+MODULE_AUTHOR("Casper Yang");
+MODULE_DESCRIPTION("MOXA Smartio/Industio Family Multiport Board Device Driver");
+module_param_array(ioaddr, int, NULL, 0);
+module_param(ttymajor, int, 0);
+MODULE_LICENSE("GPL");
+
+struct mxser_log {
+       int tick;
+       unsigned long rxcnt[MXSER_PORTS];
+       unsigned long txcnt[MXSER_PORTS];
+};
+
+
+struct mxser_mon {
+       unsigned long rxcnt;
+       unsigned long txcnt;
+       unsigned long up_rxcnt;
+       unsigned long up_txcnt;
+       int modem_status;
+       unsigned char hold_reason;
+};
+
+struct mxser_mon_ext {
+       unsigned long rx_cnt[32];
+       unsigned long tx_cnt[32];
+       unsigned long up_rxcnt[32];
+       unsigned long up_txcnt[32];
+       int modem_status[32];
+
+       long baudrate[32];
+       int databits[32];
+       int stopbits[32];
+       int parity[32];
+       int flowctrl[32];
+       int fifo[32];
+       int iftype[32];
+};
+
+struct mxser_board;
+
+struct mxser_port {
+       struct mxser_board *board;
+       struct tty_struct *tty;
+
+       unsigned long ioaddr;
+       unsigned long opmode_ioaddr;
+       int max_baud;
+
+       int rx_high_water;
+       int rx_trigger;         /* Rx fifo trigger level */
+       int rx_low_water;
+       int baud_base;          /* max. speed */
+       long realbaud;
+       int type;               /* UART type */
+       int flags;              /* defined in tty.h */
+       long session;           /* Session of opening process */
+       long pgrp;              /* pgrp of opening process */
+
+       int x_char;             /* xon/xoff character */
+       int IER;                /* Interrupt Enable Register */
+       int MCR;                /* Modem control register */
+
+       unsigned char stop_rx;
+       unsigned char ldisc_stop_rx;
+
+       int custom_divisor;
+       int close_delay;
+       unsigned short closing_wait;
+       unsigned char err_shadow;
+       unsigned long event;
+
+       int count;              /* # of fd on device */
+       int blocked_open;       /* # of blocked opens */
+       struct async_icount icount; /* kernel counters for 4 input interrupts */
+       int timeout;
+
+       int read_status_mask;
+       int ignore_status_mask;
+       int xmit_fifo_size;
+       unsigned char *xmit_buf;
+       int xmit_head;
+       int xmit_tail;
+       int xmit_cnt;
+
+       struct ktermios normal_termios;
+       struct ktermios callout_termios;
+
+       struct mxser_mon mon_data;
+
+       spinlock_t slock;
+       struct work_struct tqueue;
+       wait_queue_head_t open_wait;
+       wait_queue_head_t close_wait;
+       wait_queue_head_t delta_msr_wait;
+};
+
+struct mxser_board {
+       unsigned int idx;
+       int irq;
+       const struct mxser_cardinfo *info;
+       unsigned long vector;
+       unsigned long vector_mask;
+
+       int chip_flag;
+       int uart_type;
+
+       struct mxser_port ports[MXSER_PORTS_PER_BOARD];
+};
+
+struct mxser_mstatus {
+       tcflag_t cflag;
+       int cts;
+       int dsr;
+       int ri;
+       int dcd;
+};
+
+static struct mxser_mstatus GMStatus[MXSER_PORTS];
+
+static int mxserBoardCAP[MXSER_BOARDS] = {
+       0, 0, 0, 0
+       /*  0x180, 0x280, 0x200, 0x320 */
+};
+
+static struct mxser_board mxser_boards[MXSER_BOARDS];
+static struct tty_driver *mxvar_sdriver;
+static struct mxser_log mxvar_log;
+static int mxvar_diagflag;
+static unsigned char mxser_msr[MXSER_PORTS + 1];
+static struct mxser_mon_ext mon_data_ext;
+static int mxser_set_baud_method[MXSER_PORTS + 1];
+static spinlock_t gm_lock;
+
+static int CheckIsMoxaMust(int io)
+{
+       u8 oldmcr, hwid;
+       int i;
+
+       outb(0, io + UART_LCR);
+       DISABLE_MOXA_MUST_ENCHANCE_MODE(io);
+       oldmcr = inb(io + UART_MCR);
+       outb(0, io + UART_MCR);
+       SET_MOXA_MUST_XON1_VALUE(io, 0x11);
+       if ((hwid = inb(io + UART_MCR)) != 0) {
+               outb(oldmcr, io + UART_MCR);
+               return MOXA_OTHER_UART;
+       }
+
+       GET_MOXA_MUST_HARDWARE_ID(io, &hwid);
+       for (i = 1; i < UART_INFO_NUM; i++) { /* 0 = OTHER_UART */
+               if (hwid == Gpci_uart_info[i].type)
+                       return (int)hwid;
+       }
+       return MOXA_OTHER_UART;
+}
+
+static void process_txrx_fifo(struct mxser_port *info)
+{
+       int i;
+
+       if ((info->type == PORT_16450) || (info->type == PORT_8250)) {
+               info->rx_trigger = 1;
+               info->rx_high_water = 1;
+               info->rx_low_water = 1;
+               info->xmit_fifo_size = 1;
+       } else
+               for (i = 0; i < UART_INFO_NUM; i++)
+                       if (info->board->chip_flag == Gpci_uart_info[i].type) {
+                               info->rx_trigger = Gpci_uart_info[i].rx_trigger;
+                               info->rx_low_water = Gpci_uart_info[i].rx_low_water;
+                               info->rx_high_water = Gpci_uart_info[i].rx_high_water;
+                               info->xmit_fifo_size = Gpci_uart_info[i].xmit_fifo_size;
+                               break;
+                       }
+}
+
+static void mxser_do_softint(struct work_struct *work)
+{
+       struct mxser_port *info = container_of(work, struct mxser_port, tqueue);
+       struct tty_struct *tty = info->tty;
+
+       if (test_and_clear_bit(MXSER_EVENT_TXLOW, &info->event))
+               tty_wakeup(tty);
+}
+
+static unsigned char mxser_get_msr(int baseaddr, int mode, int port)
+{
+       unsigned char status = 0;
+
+       status = inb(baseaddr + UART_MSR);
+
+       mxser_msr[port] &= 0x0F;
+       mxser_msr[port] |= status;
+       status = mxser_msr[port];
+       if (mode)
+               mxser_msr[port] = 0;
+
+       return status;
+}
+
+static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp,
+               struct mxser_port *port)
+{
+       DECLARE_WAITQUEUE(wait, current);
+       int retval;
+       int do_clocal = 0;
+       unsigned long flags;
+
+       /*
+        * If non-blocking mode is set, or the port is not enabled,
+        * then make the check up front and then exit.
+        */
+       if ((filp->f_flags & O_NONBLOCK) ||
+                       test_bit(TTY_IO_ERROR, &tty->flags)) {
+               port->flags |= ASYNC_NORMAL_ACTIVE;
+               return 0;
+       }
+
+       if (tty->termios->c_cflag & CLOCAL)
+               do_clocal = 1;
+
+       /*
+        * Block waiting for the carrier detect and the line to become
+        * free (i.e., not in use by the callout).  While we are in
+        * this loop, port->count is dropped by one, so that
+        * mxser_close() knows when to free things.  We restore it upon
+        * exit, either normal or abnormal.
+        */
+       retval = 0;
+       add_wait_queue(&port->open_wait, &wait);
+
+       spin_lock_irqsave(&port->slock, flags);
+       if (!tty_hung_up_p(filp))
+               port->count--;
+       spin_unlock_irqrestore(&port->slock, flags);
+       port->blocked_open++;
+       while (1) {
+               spin_lock_irqsave(&port->slock, flags);
+               outb(inb(port->ioaddr + UART_MCR) |
+                       UART_MCR_DTR | UART_MCR_RTS, port->ioaddr + UART_MCR);
+               spin_unlock_irqrestore(&port->slock, flags);
+               set_current_state(TASK_INTERRUPTIBLE);
+               if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) {
+                       if (port->flags & ASYNC_HUP_NOTIFY)
+                               retval = -EAGAIN;
+                       else
+                               retval = -ERESTARTSYS;
+                       break;
+               }
+               if (!(port->flags & ASYNC_CLOSING) &&
+                               (do_clocal ||
+                               (inb(port->ioaddr + UART_MSR) & UART_MSR_DCD)))
+                       break;
+               if (signal_pending(current)) {
+                       retval = -ERESTARTSYS;
+                       break;
+               }
+               schedule();
+       }
+       set_current_state(TASK_RUNNING);
+       remove_wait_queue(&port->open_wait, &wait);
+       if (!tty_hung_up_p(filp))
+               port->count++;
+       port->blocked_open--;
+       if (retval)
+               return retval;
+       port->flags |= ASYNC_NORMAL_ACTIVE;
+       return 0;
+}
+
+static int mxser_set_baud(struct mxser_port *info, long newspd)
+{
+       int quot = 0;
+       unsigned char cval;
+       int ret = 0;
+       unsigned long flags;
+
+       if (!info->tty || !info->tty->termios)
+               return ret;
+
+       if (!(info->ioaddr))
+               return ret;
+
+       if (newspd > info->max_baud)
+               return 0;
+
+       info->realbaud = newspd;
+       if (newspd == 134) {
+               quot = (2 * info->baud_base / 269);
+       } else if (newspd) {
+               quot = info->baud_base / newspd;
+               if (quot == 0)
+                       quot = 1;
+       } else {
+               quot = 0;
+       }
+
+       info->timeout = ((info->xmit_fifo_size * HZ * 10 * quot) / info->baud_base);
+       info->timeout += HZ / 50;       /* Add .02 seconds of slop */
+
+       if (quot) {
+               spin_lock_irqsave(&info->slock, flags);
+               info->MCR |= UART_MCR_DTR;
+               outb(info->MCR, info->ioaddr + UART_MCR);
+               spin_unlock_irqrestore(&info->slock, flags);
+       } else {
+               spin_lock_irqsave(&info->slock, flags);
+               info->MCR &= ~UART_MCR_DTR;
+               outb(info->MCR, info->ioaddr + UART_MCR);
+               spin_unlock_irqrestore(&info->slock, flags);
+               return ret;
+       }
+
+       cval = inb(info->ioaddr + UART_LCR);
+
+       outb(cval | UART_LCR_DLAB, info->ioaddr + UART_LCR);    /* set DLAB */
+
+       outb(quot & 0xff, info->ioaddr + UART_DLL);     /* LS of divisor */
+       outb(quot >> 8, info->ioaddr + UART_DLM);       /* MS of divisor */
+       outb(cval, info->ioaddr + UART_LCR);    /* reset DLAB */
+
+
+       return ret;
+}
+
+/*
+ * This routine is called to set the UART divisor registers to match
+ * the specified baud rate for a serial port.
+ */
+static int mxser_change_speed(struct mxser_port *info,
+               struct ktermios *old_termios)
+{
+       unsigned cflag, cval, fcr;
+       int ret = 0;
+       unsigned char status;
+       long baud;
+       unsigned long flags;
+
+       if (!info->tty || !info->tty->termios)
+               return ret;
+       cflag = info->tty->termios->c_cflag;
+       if (!(info->ioaddr))
+               return ret;
+
+       if (mxser_set_baud_method[info->tty->index] == 0) {
+               baud = tty_get_baud_rate(info->tty);
+               mxser_set_baud(info, baud);
+       }
+
+       /* byte size and parity */
+       switch (cflag & CSIZE) {
+       case CS5:
+               cval = 0x00;
+               break;
+       case CS6:
+               cval = 0x01;
+               break;
+       case CS7:
+               cval = 0x02;
+               break;
+       case CS8:
+               cval = 0x03;
+               break;
+       default:
+               cval = 0x00;
+               break;          /* too keep GCC shut... */
+       }
+       if (cflag & CSTOPB)
+               cval |= 0x04;
+       if (cflag & PARENB)
+               cval |= UART_LCR_PARITY;
+       if (!(cflag & PARODD))
+               cval |= UART_LCR_EPAR;
+       if (cflag & CMSPAR)
+               cval |= UART_LCR_SPAR;
+
+       if ((info->type == PORT_8250) || (info->type == PORT_16450)) {
+               if (info->board->chip_flag) {
+                       fcr = UART_FCR_ENABLE_FIFO;
+                       fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE;
+                       SET_MOXA_MUST_FIFO_VALUE(info);
+               } else
+                       fcr = 0;
+       } else {
+               fcr = UART_FCR_ENABLE_FIFO;
+               if (info->board->chip_flag) {
+                       fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE;
+                       SET_MOXA_MUST_FIFO_VALUE(info);
+               } else {
+                       switch (info->rx_trigger) {
+                       case 1:
+                               fcr |= UART_FCR_TRIGGER_1;
+                               break;
+                       case 4:
+                               fcr |= UART_FCR_TRIGGER_4;
+                               break;
+                       case 8:
+                               fcr |= UART_FCR_TRIGGER_8;
+                               break;
+                       default:
+                               fcr |= UART_FCR_TRIGGER_14;
+                               break;
+                       }
+               }
+       }
+
+       /* CTS flow control flag and modem status interrupts */
+       info->IER &= ~UART_IER_MSI;
+       info->MCR &= ~UART_MCR_AFE;
+       if (cflag & CRTSCTS) {
+               info->flags |= ASYNC_CTS_FLOW;
+               info->IER |= UART_IER_MSI;
+               if ((info->type == PORT_16550A) || (info->board->chip_flag)) {
+                       info->MCR |= UART_MCR_AFE;
+               } else {
+                       status = inb(info->ioaddr + UART_MSR);
+                       if (info->tty->hw_stopped) {
+                               if (status & UART_MSR_CTS) {
+                                       info->tty->hw_stopped = 0;
+                                       if (info->type != PORT_16550A &&
+                                                       !info->board->chip_flag) {
+                                               outb(info->IER & ~UART_IER_THRI,
+                                                       info->ioaddr +
+                                                       UART_IER);
+                                               info->IER |= UART_IER_THRI;
+                                               outb(info->IER, info->ioaddr +
+                                                               UART_IER);
+                                       }
+                                       set_bit(MXSER_EVENT_TXLOW, &info->event);
+                                       schedule_work(&info->tqueue);                           }
+                       } else {
+                               if (!(status & UART_MSR_CTS)) {
+                                       info->tty->hw_stopped = 1;
+                                       if ((info->type != PORT_16550A) &&
+                                                       (!info->board->chip_flag)) {
+                                               info->IER &= ~UART_IER_THRI;
+                                               outb(info->IER, info->ioaddr +
+                                                               UART_IER);
+                                       }
+                               }
+                       }
+               }
+       } else {
+               info->flags &= ~ASYNC_CTS_FLOW;
+       }
+       outb(info->MCR, info->ioaddr + UART_MCR);
+       if (cflag & CLOCAL) {
+               info->flags &= ~ASYNC_CHECK_CD;
+       } else {
+               info->flags |= ASYNC_CHECK_CD;
+               info->IER |= UART_IER_MSI;
+       }
+       outb(info->IER, info->ioaddr + UART_IER);
+
+       /*
+        * Set up parity check flag
+        */
+       info->read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
+       if (I_INPCK(info->tty))
+               info->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
+       if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
+               info->read_status_mask |= UART_LSR_BI;
+
+       info->ignore_status_mask = 0;
+
+       if (I_IGNBRK(info->tty)) {
+               info->ignore_status_mask |= UART_LSR_BI;
+               info->read_status_mask |= UART_LSR_BI;
+               /*
+                * If we're ignore parity and break indicators, ignore
+                * overruns too.  (For real raw support).
+                */
+               if (I_IGNPAR(info->tty)) {
+                       info->ignore_status_mask |=
+                                               UART_LSR_OE |
+                                               UART_LSR_PE |
+                                               UART_LSR_FE;
+                       info->read_status_mask |=
+                                               UART_LSR_OE |
+                                               UART_LSR_PE |
+                                               UART_LSR_FE;
+               }
+       }
+       if (info->board->chip_flag) {
+               spin_lock_irqsave(&info->slock, flags);
+               SET_MOXA_MUST_XON1_VALUE(info->ioaddr, START_CHAR(info->tty));
+               SET_MOXA_MUST_XOFF1_VALUE(info->ioaddr, STOP_CHAR(info->tty));
+               if (I_IXON(info->tty)) {
+                       ENABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->ioaddr);
+               } else {
+                       DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->ioaddr);
+               }
+               if (I_IXOFF(info->tty)) {
+                       ENABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(info->ioaddr);
+               } else {
+                       DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(info->ioaddr);
+               }
+               spin_unlock_irqrestore(&info->slock, flags);
+       }
+
+
+       outb(fcr, info->ioaddr + UART_FCR);     /* set fcr */
+       outb(cval, info->ioaddr + UART_LCR);
+
+       return ret;
+}
+
+static void mxser_check_modem_status(struct mxser_port *port, int status)
+{
+       /* update input line counters */
+       if (status & UART_MSR_TERI)
+               port->icount.rng++;
+       if (status & UART_MSR_DDSR)
+               port->icount.dsr++;
+       if (status & UART_MSR_DDCD)
+               port->icount.dcd++;
+       if (status & UART_MSR_DCTS)
+               port->icount.cts++;
+       port->mon_data.modem_status = status;
+       wake_up_interruptible(&port->delta_msr_wait);
+
+       if ((port->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
+               if (status & UART_MSR_DCD)
+                       wake_up_interruptible(&port->open_wait);
+               schedule_work(&port->tqueue);
+       }
+
+       if (port->flags & ASYNC_CTS_FLOW) {
+               if (port->tty->hw_stopped) {
+                       if (status & UART_MSR_CTS) {
+                               port->tty->hw_stopped = 0;
+
+                               if ((port->type != PORT_16550A) &&
+                                               (!port->board->chip_flag)) {
+                                       outb(port->IER & ~UART_IER_THRI,
+                                               port->ioaddr + UART_IER);
+                                       port->IER |= UART_IER_THRI;
+                                       outb(port->IER, port->ioaddr +
+                                                       UART_IER);
+                               }
+                               set_bit(MXSER_EVENT_TXLOW, &port->event);
+                               schedule_work(&port->tqueue);
+                       }
+               } else {
+                       if (!(status & UART_MSR_CTS)) {
+                               port->tty->hw_stopped = 1;
+                               if (port->type != PORT_16550A &&
+                                               !port->board->chip_flag) {
+                                       port->IER &= ~UART_IER_THRI;
+                                       outb(port->IER, port->ioaddr +
+                                                       UART_IER);
+                               }
+                       }
+               }
+       }
+}
+
+static int mxser_startup(struct mxser_port *info)
+{
+       unsigned long page;
+       unsigned long flags;
+
+       page = __get_free_page(GFP_KERNEL);
+       if (!page)
+               return -ENOMEM;
+
+       spin_lock_irqsave(&info->slock, flags);
+
+       if (info->flags & ASYNC_INITIALIZED) {
+               free_page(page);
+               spin_unlock_irqrestore(&info->slock, flags);
+               return 0;
+       }
+
+       if (!info->ioaddr || !info->type) {
+               if (info->tty)
+                       set_bit(TTY_IO_ERROR, &info->tty->flags);
+               free_page(page);
+               spin_unlock_irqrestore(&info->slock, flags);
+               return 0;
+       }
+       if (info->xmit_buf)
+               free_page(page);
+       else
+               info->xmit_buf = (unsigned char *) page;
+
+       /*
+        * Clear the FIFO buffers and disable them
+        * (they will be reenabled in mxser_change_speed())
+        */
+       if (info->board->chip_flag)
+               outb((UART_FCR_CLEAR_RCVR |
+                       UART_FCR_CLEAR_XMIT |
+                       MOXA_MUST_FCR_GDA_MODE_ENABLE), info->ioaddr + UART_FCR);
+       else
+               outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
+                       info->ioaddr + UART_FCR);
+
+       /*
+        * At this point there's no way the LSR could still be 0xFF;
+        * if it is, then bail out, because there's likely no UART
+        * here.
+        */
+       if (inb(info->ioaddr + UART_LSR) == 0xff) {
+               spin_unlock_irqrestore(&info->slock, flags);
+               if (capable(CAP_SYS_ADMIN)) {
+                       if (info->tty)
+                               set_bit(TTY_IO_ERROR, &info->tty->flags);
+                       return 0;
+               } else
+                       return -ENODEV;
+       }
+
+       /*
+        * Clear the interrupt registers.
+        */
+       (void) inb(info->ioaddr + UART_LSR);
+       (void) inb(info->ioaddr + UART_RX);
+       (void) inb(info->ioaddr + UART_IIR);
+       (void) inb(info->ioaddr + UART_MSR);
+
+       /*
+        * Now, initialize the UART
+        */
+       outb(UART_LCR_WLEN8, info->ioaddr + UART_LCR);  /* reset DLAB */
+       info->MCR = UART_MCR_DTR | UART_MCR_RTS;
+       outb(info->MCR, info->ioaddr + UART_MCR);
+
+       /*
+        * Finally, enable interrupts
+        */
+       info->IER = UART_IER_MSI | UART_IER_RLSI | UART_IER_RDI;
+
+       if (info->board->chip_flag)
+               info->IER |= MOXA_MUST_IER_EGDAI;
+       outb(info->IER, info->ioaddr + UART_IER);       /* enable interrupts */
+
+       /*
+        * And clear the interrupt registers again for luck.
+        */
+       (void) inb(info->ioaddr + UART_LSR);
+       (void) inb(info->ioaddr + UART_RX);
+       (void) inb(info->ioaddr + UART_IIR);
+       (void) inb(info->ioaddr + UART_MSR);
+
+       if (info->tty)
+               clear_bit(TTY_IO_ERROR, &info->tty->flags);
+       info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
+
+       /*
+        * and set the speed of the serial port
+        */
+       spin_unlock_irqrestore(&info->slock, flags);
+       mxser_change_speed(info, NULL);
+
+       info->flags |= ASYNC_INITIALIZED;
+       return 0;
+}
+
+/*
+ * This routine will shutdown a serial port; interrupts maybe disabled, and
+ * DTR is dropped if the hangup on close termio flag is on.
+ */
+static void mxser_shutdown(struct mxser_port *info)
+{
+       unsigned long flags;
+
+       if (!(info->flags & ASYNC_INITIALIZED))
+               return;
+
+       spin_lock_irqsave(&info->slock, flags);
+
+       /*
+        * clear delta_msr_wait queue to avoid mem leaks: we may free the irq
+        * here so the queue might never be waken up
+        */
+       wake_up_interruptible(&info->delta_msr_wait);
+
+       /*
+        * Free the IRQ, if necessary
+        */
+       if (info->xmit_buf) {
+               free_page((unsigned long) info->xmit_buf);
+               info->xmit_buf = NULL;
+       }
+
+       info->IER = 0;
+       outb(0x00, info->ioaddr + UART_IER);
+
+       if (!info->tty || (info->tty->termios->c_cflag & HUPCL))
+               info->MCR &= ~(UART_MCR_DTR | UART_MCR_RTS);
+       outb(info->MCR, info->ioaddr + UART_MCR);
+
+       /* clear Rx/Tx FIFO's */
+       if (info->board->chip_flag)
+               outb(UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT |
+                               MOXA_MUST_FCR_GDA_MODE_ENABLE,
+                               info->ioaddr + UART_FCR);
+       else
+               outb(UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT,
+                       info->ioaddr + UART_FCR);
+
+       /* read data port to reset things */
+       (void) inb(info->ioaddr + UART_RX);
+
+       if (info->tty)
+               set_bit(TTY_IO_ERROR, &info->tty->flags);
+
+       info->flags &= ~ASYNC_INITIALIZED;
+
+       if (info->board->chip_flag)
+               SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(info->ioaddr);
+
+       spin_unlock_irqrestore(&info->slock, flags);
+}
+
+/*
+ * This routine is called whenever a serial port is opened.  It
+ * enables interrupts for a serial port, linking in its async structure into
+ * the IRQ chain.   It also performs the serial-specific
+ * initialization for the tty structure.
+ */
+static int mxser_open(struct tty_struct *tty, struct file *filp)
+{
+       struct mxser_port *info;
+       int retval, line;
+
+       /* initialize driver_data in case something fails */
+       tty->driver_data = NULL;
+
+       line = tty->index;
+       if (line == MXSER_PORTS)
+               return 0;
+       if (line < 0 || line > MXSER_PORTS)
+               return -ENODEV;
+       info = &mxser_boards[line / MXSER_PORTS_PER_BOARD].ports[line % MXSER_PORTS_PER_BOARD];
+       if (!info->ioaddr)
+               return -ENODEV;
+
+       tty->driver_data = info;
+       info->tty = tty;
+       /*
+        * Start up serial port
+        */
+       info->count++;
+       retval = mxser_startup(info);
+       if (retval)
+               return retval;
+
+       retval = mxser_block_til_ready(tty, filp, info);
+       if (retval)
+               return retval;
+
+       if ((info->count == 1) && (info->flags & ASYNC_SPLIT_TERMIOS)) {
+               if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
+                       *tty->termios = info->normal_termios;
+               else
+                       *tty->termios = info->callout_termios;
+               mxser_change_speed(info, NULL);
+       }
+
+       info->session = process_session(current);
+       info->pgrp = process_group(current);
+
+       /* unmark here for very high baud rate (ex. 921600 bps) used */
+       tty->low_latency = 1;
+       return 0;
+}
+
+/*
+ * This routine is called when the serial port gets closed.  First, we
+ * wait for the last remaining data to be sent.  Then, we unlink its
+ * async structure from the interrupt chain if necessary, and we free
+ * that IRQ if nothing is left in the chain.
+ */
+static void mxser_close(struct tty_struct *tty, struct file *filp)
+{
+       struct mxser_port *info = tty->driver_data;
+
+       unsigned long timeout;
+       unsigned long flags;
+
+       if (tty->index == MXSER_PORTS)
+               return;
+       if (!info)
+               return;
+
+       spin_lock_irqsave(&info->slock, flags);
+
+       if (tty_hung_up_p(filp)) {
+               spin_unlock_irqrestore(&info->slock, flags);
+               return;
+       }
+       if ((tty->count == 1) && (info->count != 1)) {
+               /*
+                * Uh, oh.  tty->count is 1, which means that the tty
+                * structure will be freed.  Info->count should always
+                * be one in these conditions.  If it's greater than
+                * one, we've got real problems, since it means the
+                * serial port won't be shutdown.
+                */
+               printk(KERN_ERR "mxser_close: bad serial port count; "
+                       "tty->count is 1, info->count is %d\n", info->count);
+               info->count = 1;
+       }
+       if (--info->count < 0) {
+               printk(KERN_ERR "mxser_close: bad serial port count for "
+                       "ttys%d: %d\n", tty->index, info->count);
+               info->count = 0;
+       }
+       if (info->count) {
+               spin_unlock_irqrestore(&info->slock, flags);
+               return;
+       }
+       info->flags |= ASYNC_CLOSING;
+       spin_unlock_irqrestore(&info->slock, flags);
+       /*
+        * Save the termios structure, since this port may have
+        * separate termios for callout and dialin.
+        */
+       if (info->flags & ASYNC_NORMAL_ACTIVE)
+               info->normal_termios = *tty->termios;
+       /*
+        * Now we wait for the transmit buffer to clear; and we notify
+        * the line discipline to only process XON/XOFF characters.
+        */
+       tty->closing = 1;
+       if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE)
+               tty_wait_until_sent(tty, info->closing_wait);
+       /*
+        * At this point we stop accepting input.  To do this, we
+        * disable the receive line status interrupts, and tell the
+        * interrupt driver to stop checking the data ready bit in the
+        * line status register.
+        */
+       info->IER &= ~UART_IER_RLSI;
+       if (info->board->chip_flag)
+               info->IER &= ~MOXA_MUST_RECV_ISR;
+
+       if (info->flags & ASYNC_INITIALIZED) {
+               outb(info->IER, info->ioaddr + UART_IER);
+               /*
+                * Before we drop DTR, make sure the UART transmitter
+                * has completely drained; this is especially
+                * important if there is a transmit FIFO!
+                */
+               timeout = jiffies + HZ;
+               while (!(inb(info->ioaddr + UART_LSR) & UART_LSR_TEMT)) {
+                       schedule_timeout_interruptible(5);
+                       if (time_after(jiffies, timeout))
+                               break;
+               }
+       }
+       mxser_shutdown(info);
+
+       if (tty->driver->flush_buffer)
+               tty->driver->flush_buffer(tty);
+
+       tty_ldisc_flush(tty);
+
+       tty->closing = 0;
+       info->event = 0;
+       info->tty = NULL;
+       if (info->blocked_open) {
+               if (info->close_delay)
+                       schedule_timeout_interruptible(info->close_delay);
+               wake_up_interruptible(&info->open_wait);
+       }
+
+       info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
+       wake_up_interruptible(&info->close_wait);
+
+}
+
+static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count)
+{
+       int c, total = 0;
+       struct mxser_port *info = tty->driver_data;
+       unsigned long flags;
+
+       if (!info->xmit_buf)
+               return 0;
+
+       while (1) {
+               c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
+                                         SERIAL_XMIT_SIZE - info->xmit_head));
+               if (c <= 0)
+                       break;
+
+               memcpy(info->xmit_buf + info->xmit_head, buf, c);
+               spin_lock_irqsave(&info->slock, flags);
+               info->xmit_head = (info->xmit_head + c) &
+                                 (SERIAL_XMIT_SIZE - 1);
+               info->xmit_cnt += c;
+               spin_unlock_irqrestore(&info->slock, flags);
+
+               buf += c;
+               count -= c;
+               total += c;
+       }
+
+       if (info->xmit_cnt && !tty->stopped) {
+               if (!tty->hw_stopped ||
+                               (info->type == PORT_16550A) ||
+                               (info->board->chip_flag)) {
+                       spin_lock_irqsave(&info->slock, flags);
+                       outb(info->IER & ~UART_IER_THRI, info->ioaddr +
+                                       UART_IER);
+                       info->IER |= UART_IER_THRI;
+                       outb(info->IER, info->ioaddr + UART_IER);
+                       spin_unlock_irqrestore(&info->slock, flags);
+               }
+       }
+       return total;
+}
+
+static void mxser_put_char(struct tty_struct *tty, unsigned char ch)
+{
+       struct mxser_port *info = tty->driver_data;
+       unsigned long flags;
+
+       if (!info->xmit_buf)
+               return;
+
+       if (info->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
+               return;
+
+       spin_lock_irqsave(&info->slock, flags);
+       info->xmit_buf[info->xmit_head++] = ch;
+       info->xmit_head &= SERIAL_XMIT_SIZE - 1;
+       info->xmit_cnt++;
+       spin_unlock_irqrestore(&info->slock, flags);
+       if (!tty->stopped) {
+               if (!tty->hw_stopped ||
+                               (info->type == PORT_16550A) ||
+                               info->board->chip_flag) {
+                       spin_lock_irqsave(&info->slock, flags);
+                       outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER);
+                       info->IER |= UART_IER_THRI;
+                       outb(info->IER, info->ioaddr + UART_IER);
+                       spin_unlock_irqrestore(&info->slock, flags);
+               }
+       }
+}
+
+
+static void mxser_flush_chars(struct tty_struct *tty)
+{
+       struct mxser_port *info = tty->driver_data;
+       unsigned long flags;
+
+       if (info->xmit_cnt <= 0 ||
+                       tty->stopped ||
+                       !info->xmit_buf ||
+                       (tty->hw_stopped &&
+                        (info->type != PORT_16550A) &&
+                        (!info->board->chip_flag)
+                       ))
+               return;
+
+       spin_lock_irqsave(&info->slock, flags);
+
+       outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER);
+       info->IER |= UART_IER_THRI;
+       outb(info->IER, info->ioaddr + UART_IER);
+
+       spin_unlock_irqrestore(&info->slock, flags);
+}
+
+static int mxser_write_room(struct tty_struct *tty)
+{
+       struct mxser_port *info = tty->driver_data;
+       int ret;
+
+       ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
+       if (ret < 0)
+               ret = 0;
+       return ret;
+}
+
+static int mxser_chars_in_buffer(struct tty_struct *tty)
+{
+       struct mxser_port *info = tty->driver_data;
+       return info->xmit_cnt;
+}
+
+static void mxser_flush_buffer(struct tty_struct *tty)
+{
+       struct mxser_port *info = tty->driver_data;
+       char fcr;
+       unsigned long flags;
+
+
+       spin_lock_irqsave(&info->slock, flags);
+       info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
+
+       fcr = inb(info->ioaddr + UART_FCR);
+       outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
+               info->ioaddr + UART_FCR);
+       outb(fcr, info->ioaddr + UART_FCR);
+
+       spin_unlock_irqrestore(&info->slock, flags);
+
+       tty_wakeup(tty);
+}
+
+/*
+ * ------------------------------------------------------------
+ * friends of mxser_ioctl()
+ * ------------------------------------------------------------
+ */
+static int mxser_get_serial_info(struct mxser_port *info,
+               struct serial_struct __user *retinfo)
+{
+       struct serial_struct tmp;
+
+       if (!retinfo)
+               return -EFAULT;
+       memset(&tmp, 0, sizeof(tmp));
+       tmp.type = info->type;
+       tmp.line = info->tty->index;
+       tmp.port = info->ioaddr;
+       tmp.irq = info->board->irq;
+       tmp.flags = info->flags;
+       tmp.baud_base = info->baud_base;
+       tmp.close_delay = info->close_delay;
+       tmp.closing_wait = info->closing_wait;
+       tmp.custom_divisor = info->custom_divisor;
+       tmp.hub6 = 0;
+       if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
+               return -EFAULT;
+       return 0;
+}
+
+static int mxser_set_serial_info(struct mxser_port *info,
+               struct serial_struct __user *new_info)
+{
+       struct serial_struct new_serial;
+       unsigned int flags;
+       int retval = 0;
+
+       if (!new_info || !info->ioaddr)
+               return -EFAULT;
+       if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
+               return -EFAULT;
+
+       if ((new_serial.irq != info->board->irq) ||
+                       (new_serial.port != info->ioaddr) ||
+                       (new_serial.custom_divisor != info->custom_divisor) ||
+                       (new_serial.baud_base != info->baud_base))
+               return -EPERM;
+
+       flags = info->flags & ASYNC_SPD_MASK;
+
+       if (!capable(CAP_SYS_ADMIN)) {
+               if ((new_serial.baud_base != info->baud_base) ||
+                               (new_serial.close_delay != info->close_delay) ||
+                               ((new_serial.flags & ~ASYNC_USR_MASK) != (info->flags & ~ASYNC_USR_MASK)))
+                       return -EPERM;
+               info->flags = ((info->flags & ~ASYNC_USR_MASK) |
+                               (new_serial.flags & ASYNC_USR_MASK));
+       } else {
+               /*
+                * OK, past this point, all the error checking has been done.
+                * At this point, we start making changes.....
+                */
+               info->flags = ((info->flags & ~ASYNC_FLAGS) |
+                               (new_serial.flags & ASYNC_FLAGS));
+               info->close_delay = new_serial.close_delay * HZ / 100;
+               info->closing_wait = new_serial.closing_wait * HZ / 100;
+               info->tty->low_latency =
+                               (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+               info->tty->low_latency = 0;
+       }
+
+       info->type = new_serial.type;
+
+       process_txrx_fifo(info);
+
+       if (info->flags & ASYNC_INITIALIZED) {
+               if (flags != (info->flags & ASYNC_SPD_MASK))
+                       mxser_change_speed(info, NULL);
+       } else
+               retval = mxser_startup(info);
+
+       return retval;
+}
+
+/*
+ * mxser_get_lsr_info - get line status register info
+ *
+ * Purpose: Let user call ioctl() to get info when the UART physically
+ *         is emptied.  On bus types like RS485, the transmitter must
+ *         release the bus after transmitting. This must be done when
+ *         the transmit shift register is empty, not be done when the
+ *         transmit holding register is empty.  This functionality
+ *         allows an RS485 driver to be written in user space.
+ */
+static int mxser_get_lsr_info(struct mxser_port *info,
+               unsigned int __user *value)
+{
+       unsigned char status;
+       unsigned int result;
+       unsigned long flags;
+
+       spin_lock_irqsave(&info->slock, flags);
+       status = inb(info->ioaddr + UART_LSR);
+       spin_unlock_irqrestore(&info->slock, flags);
+       result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0);
+       return put_user(result, value);
+}
+
+/*
+ * This routine sends a break character out the serial port.
+ */
+static void mxser_send_break(struct mxser_port *info, int duration)
+{
+       unsigned long flags;
+
+       if (!info->ioaddr)
+               return;
+       set_current_state(TASK_INTERRUPTIBLE);
+       spin_lock_irqsave(&info->slock, flags);
+       outb(inb(info->ioaddr + UART_LCR) | UART_LCR_SBC,
+               info->ioaddr + UART_LCR);
+       spin_unlock_irqrestore(&info->slock, flags);
+       schedule_timeout(duration);
+       spin_lock_irqsave(&info->slock, flags);
+       outb(inb(info->ioaddr + UART_LCR) & ~UART_LCR_SBC,
+               info->ioaddr + UART_LCR);
+       spin_unlock_irqrestore(&info->slock, flags);
+}
+
+static int mxser_tiocmget(struct tty_struct *tty, struct file *file)
+{
+       struct mxser_port *info = tty->driver_data;
+       unsigned char control, status;
+       unsigned long flags;
+
+
+       if (tty->index == MXSER_PORTS)
+               return -ENOIOCTLCMD;
+       if (test_bit(TTY_IO_ERROR, &tty->flags))
+               return -EIO;
+
+       control = info->MCR;
+
+       spin_lock_irqsave(&info->slock, flags);
+       status = inb(info->ioaddr + UART_MSR);
+       if (status & UART_MSR_ANY_DELTA)
+               mxser_check_modem_status(info, status);
+       spin_unlock_irqrestore(&info->slock, flags);
+       return ((control & UART_MCR_RTS) ? TIOCM_RTS : 0) |
+                   ((control & UART_MCR_DTR) ? TIOCM_DTR : 0) |
+                   ((status & UART_MSR_DCD) ? TIOCM_CAR : 0) |
+                   ((status & UART_MSR_RI) ? TIOCM_RNG : 0) |
+                   ((status & UART_MSR_DSR) ? TIOCM_DSR : 0) |
+                   ((status & UART_MSR_CTS) ? TIOCM_CTS : 0);
+}
+
+static int mxser_tiocmset(struct tty_struct *tty, struct file *file,
+               unsigned int set, unsigned int clear)
+{
+       struct mxser_port *info = tty->driver_data;
+       unsigned long flags;
+
+
+       if (tty->index == MXSER_PORTS)
+               return -ENOIOCTLCMD;
+       if (test_bit(TTY_IO_ERROR, &tty->flags))
+               return -EIO;
+
+       spin_lock_irqsave(&info->slock, flags);
+
+       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;
+
+       outb(info->MCR, info->ioaddr + UART_MCR);
+       spin_unlock_irqrestore(&info->slock, flags);
+       return 0;
+}
+
+static int mxser_program_mode(int port)
+{
+       int id, i, j, n;
+
+       spin_lock(&gm_lock);
+       outb(0, port);
+       outb(0, port);
+       outb(0, port);
+       (void)inb(port);
+       (void)inb(port);
+       outb(0, port);
+       (void)inb(port);
+       spin_unlock(&gm_lock);
+
+       id = inb(port + 1) & 0x1F;
+       if ((id != C168_ASIC_ID) &&
+                       (id != C104_ASIC_ID) &&
+                       (id != C102_ASIC_ID) &&
+                       (id != CI132_ASIC_ID) &&
+                       (id != CI134_ASIC_ID) &&
+                       (id != CI104J_ASIC_ID))
+               return -1;
+       for (i = 0, j = 0; i < 4; i++) {
+               n = inb(port + 2);
+               if (n == 'M') {
+                       j = 1;
+               } else if ((j == 1) && (n == 1)) {
+                       j = 2;
+                       break;
+               } else
+                       j = 0;
+       }
+       if (j != 2)
+               id = -2;
+       return id;
+}
+
+static void mxser_normal_mode(int port)
+{
+       int i, n;
+
+       outb(0xA5, port + 1);
+       outb(0x80, port + 3);
+       outb(12, port + 0);     /* 9600 bps */
+       outb(0, port + 1);
+       outb(0x03, port + 3);   /* 8 data bits */
+       outb(0x13, port + 4);   /* loop back mode */
+       for (i = 0; i < 16; i++) {
+               n = inb(port + 5);
+               if ((n & 0x61) == 0x60)
+                       break;
+               if ((n & 1) == 1)
+                       (void)inb(port);
+       }
+       outb(0x00, port + 4);
+}
+
+#define CHIP_SK        0x01    /* Serial Data Clock  in Eprom */
+#define CHIP_DO        0x02    /* Serial Data Output in Eprom */
+#define CHIP_CS        0x04    /* Serial Chip Select in Eprom */
+#define CHIP_DI        0x08    /* Serial Data Input  in Eprom */
+#define EN_CCMD        0x000   /* Chip's command register     */
+#define EN0_RSARLO     0x008   /* Remote start address reg 0  */
+#define EN0_RSARHI     0x009   /* Remote start address reg 1  */
+#define EN0_RCNTLO     0x00A   /* Remote byte count reg WR    */
+#define EN0_RCNTHI     0x00B   /* Remote byte count reg WR    */
+#define EN0_DCFG       0x00E   /* Data configuration reg WR   */
+#define EN0_PORT       0x010   /* Rcv missed frame error counter RD */
+#define ENC_PAGE0      0x000   /* Select page 0 of chip registers   */
+#define ENC_PAGE3      0x0C0   /* Select page 3 of chip registers   */
+static int mxser_read_register(int port, unsigned short *regs)
+{
+       int i, k, value, id;
+       unsigned int j;
+
+       id = mxser_program_mode(port);
+       if (id < 0)
+               return id;
+       for (i = 0; i < 14; i++) {
+               k = (i & 0x3F) | 0x180;
+               for (j = 0x100; j > 0; j >>= 1) {
+                       outb(CHIP_CS, port);
+                       if (k & j) {
+                               outb(CHIP_CS | CHIP_DO, port);
+                               outb(CHIP_CS | CHIP_DO | CHIP_SK, port);        /* A? bit of read */
+                       } else {
+                               outb(CHIP_CS, port);
+                               outb(CHIP_CS | CHIP_SK, port);  /* A? bit of read */
+                       }
+               }
+               (void)inb(port);
+               value = 0;
+               for (k = 0, j = 0x8000; k < 16; k++, j >>= 1) {
+                       outb(CHIP_CS, port);
+                       outb(CHIP_CS | CHIP_SK, port);
+                       if (inb(port) & CHIP_DI)
+                               value |= j;
+               }
+               regs[i] = value;
+               outb(0, port);
+       }
+       mxser_normal_mode(port);
+       return id;
+}
+
+static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
+{
+       struct mxser_port *port;
+       int result, status;
+       unsigned int i, j;
+
+       switch (cmd) {
+       case MOXA_GET_CONF:
+/*             if (copy_to_user(argp, mxsercfg,
+                               sizeof(struct mxser_hwconf) * 4))
+                       return -EFAULT;
+               return 0;*/
+               return -ENXIO;
+       case MOXA_GET_MAJOR:
+               if (copy_to_user(argp, &ttymajor, sizeof(int)))
+                       return -EFAULT;
+               return 0;
+
+       case MOXA_GET_CUMAJOR:
+               if (copy_to_user(argp, &calloutmajor, sizeof(int)))
+                       return -EFAULT;
+               return 0;
+
+       case MOXA_CHKPORTENABLE:
+               result = 0;
+
+               for (i = 0; i < MXSER_BOARDS; i++)
+                       for (j = 0; j < MXSER_PORTS_PER_BOARD; j++)
+                               if (mxser_boards[i].ports[j].ioaddr)
+                                       result |= (1 << i);
+
+               return put_user(result, (unsigned long __user *)argp);
+       case MOXA_GETDATACOUNT:
+               if (copy_to_user(argp, &mxvar_log, sizeof(mxvar_log)))
+                       return -EFAULT;
+               return 0;
+       case MOXA_GETMSTATUS:
+               for (i = 0; i < MXSER_BOARDS; i++)
+                       for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) {
+                               port = &mxser_boards[i].ports[j];
+
+                               GMStatus[i].ri = 0;
+                               if (!port->ioaddr) {
+                                       GMStatus[i].dcd = 0;
+                                       GMStatus[i].dsr = 0;
+                                       GMStatus[i].cts = 0;
+                                       continue;
+                               }
+
+                               if (!port->tty || !port->tty->termios)
+                                       GMStatus[i].cflag =
+                                               port->normal_termios.c_cflag;
+                               else
+                                       GMStatus[i].cflag =
+                                               port->tty->termios->c_cflag;
+
+                               status = inb(port->ioaddr + UART_MSR);
+                               if (status & 0x80 /*UART_MSR_DCD */ )
+                                       GMStatus[i].dcd = 1;
+                               else
+                                       GMStatus[i].dcd = 0;
+
+                               if (status & 0x20 /*UART_MSR_DSR */ )
+                                       GMStatus[i].dsr = 1;
+                               else
+                                       GMStatus[i].dsr = 0;
+
+
+                               if (status & 0x10 /*UART_MSR_CTS */ )
+                                       GMStatus[i].cts = 1;
+                               else
+                                       GMStatus[i].cts = 0;
+                       }
+               if (copy_to_user(argp, GMStatus,
+                               sizeof(struct mxser_mstatus) * MXSER_PORTS))
+                       return -EFAULT;
+               return 0;
+       case MOXA_ASPP_MON_EXT: {
+               int status, p, shiftbit;
+               unsigned long opmode;
+               unsigned cflag, iflag;
+
+               for (i = 0; i < MXSER_BOARDS; i++)
+                       for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) {
+                               port = &mxser_boards[i].ports[j];
+                               if (!port->ioaddr)
+                                       continue;
+
+                               status = mxser_get_msr(port->ioaddr, 0, i);
+
+                               if (status & UART_MSR_TERI)
+                                       port->icount.rng++;
+                               if (status & UART_MSR_DDSR)
+                                       port->icount.dsr++;
+                               if (status & UART_MSR_DDCD)
+                                       port->icount.dcd++;
+                               if (status & UART_MSR_DCTS)
+                                       port->icount.cts++;
+
+                               port->mon_data.modem_status = status;
+                               mon_data_ext.rx_cnt[i] = port->mon_data.rxcnt;
+                               mon_data_ext.tx_cnt[i] = port->mon_data.txcnt;
+                               mon_data_ext.up_rxcnt[i] =
+                                       port->mon_data.up_rxcnt;
+                               mon_data_ext.up_txcnt[i] =
+                                       port->mon_data.up_txcnt;
+                               mon_data_ext.modem_status[i] =
+                                       port->mon_data.modem_status;
+                               mon_data_ext.baudrate[i] = port->realbaud;
+
+                               if (!port->tty || !port->tty->termios) {
+                                       cflag = port->normal_termios.c_cflag;
+                                       iflag = port->normal_termios.c_iflag;
+                               } else {
+                                       cflag = port->tty->termios->c_cflag;
+                                       iflag = port->tty->termios->c_iflag;
+                               }
+
+                               mon_data_ext.databits[i] = cflag & CSIZE;
+
+                               mon_data_ext.stopbits[i] = cflag & CSTOPB;
+
+                               mon_data_ext.parity[i] =
+                                       cflag & (PARENB | PARODD | CMSPAR);
+
+                               mon_data_ext.flowctrl[i] = 0x00;
+
+                               if (cflag & CRTSCTS)
+                                       mon_data_ext.flowctrl[i] |= 0x03;
+
+                               if (iflag & (IXON | IXOFF))
+                                       mon_data_ext.flowctrl[i] |= 0x0C;
+
+                               if (port->type == PORT_16550A)
+                                       mon_data_ext.fifo[i] = 1;
+                               else
+                                       mon_data_ext.fifo[i] = 0;
+
+                               p = i % 4;
+                               shiftbit = p * 2;
+                               opmode = inb(port->opmode_ioaddr) >> shiftbit;
+                               opmode &= OP_MODE_MASK;
+
+                               mon_data_ext.iftype[i] = opmode;
+
+                       }
+                       if (copy_to_user(argp, &mon_data_ext,
+                                               sizeof(mon_data_ext)))
+                               return -EFAULT;
+
+                       return 0;
+
+       } default:
+               return -ENOIOCTLCMD;
+       }
+       return 0;
+}
+
+static int mxser_ioctl(struct tty_struct *tty, struct file *file,
+               unsigned int cmd, unsigned long arg)
+{
+       struct mxser_port *info = tty->driver_data;
+       struct async_icount cprev, cnow;        /* kernel counter temps */
+       struct serial_icounter_struct __user *p_cuser;
+       unsigned long templ;
+       unsigned long flags;
+       void __user *argp = (void __user *)arg;
+       int retval;
+
+       if (tty->index == MXSER_PORTS)
+               return mxser_ioctl_special(cmd, argp);
+
+       if (cmd == MOXA_SET_OP_MODE || cmd == MOXA_GET_OP_MODE) {
+               int p;
+               unsigned long opmode;
+               static unsigned char ModeMask[] = { 0xfc, 0xf3, 0xcf, 0x3f };
+               int shiftbit;
+               unsigned char val, mask;
+
+               p = tty->index % 4;
+               if (cmd == MOXA_SET_OP_MODE) {
+                       if (get_user(opmode, (int __user *) argp))
+                               return -EFAULT;
+                       if (opmode != RS232_MODE &&
+                                       opmode != RS485_2WIRE_MODE &&
+                                       opmode != RS422_MODE &&
+                                       opmode != RS485_4WIRE_MODE)
+                               return -EFAULT;
+                       mask = ModeMask[p];
+                       shiftbit = p * 2;
+                       val = inb(info->opmode_ioaddr);
+                       val &= mask;
+                       val |= (opmode << shiftbit);
+                       outb(val, info->opmode_ioaddr);
+               } else {
+                       shiftbit = p * 2;
+                       opmode = inb(info->opmode_ioaddr) >> shiftbit;
+                       opmode &= OP_MODE_MASK;
+                       if (copy_to_user(argp, &opmode, sizeof(int)))
+                               return -EFAULT;
+               }
+               return 0;
+       }
+
+       if (cmd != TIOCGSERIAL && cmd != TIOCMIWAIT && cmd != TIOCGICOUNT &&
+                       test_bit(TTY_IO_ERROR, &tty->flags))
+               return -EIO;
+
+       switch (cmd) {
+       case TCSBRK:            /* SVID version: non-zero arg --> no break */
+               retval = tty_check_change(tty);
+               if (retval)
+                       return retval;
+               tty_wait_until_sent(tty, 0);
+               if (!arg)
+                       mxser_send_break(info, HZ / 4); /* 1/4 second */
+               return 0;
+       case TCSBRKP:           /* support for POSIX tcsendbreak() */
+               retval = tty_check_change(tty);
+               if (retval)
+                       return retval;
+               tty_wait_until_sent(tty, 0);
+               mxser_send_break(info, arg ? arg * (HZ / 10) : HZ / 4);
+               return 0;
+       case TIOCGSOFTCAR:
+               return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *)argp);
+       case TIOCSSOFTCAR:
+               if (get_user(templ, (unsigned long __user *) argp))
+                       return -EFAULT;
+               arg = templ;
+               tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0));
+               return 0;
+       case TIOCGSERIAL:
+               return mxser_get_serial_info(info, argp);
+       case TIOCSSERIAL:
+               return mxser_set_serial_info(info, argp);
+       case TIOCSERGETLSR:     /* Get line status register */
+               return mxser_get_lsr_info(info, argp);
+               /*
+                * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
+                * - mask passed in arg for lines of interest
+                *   (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
+                * Caller should use TIOCGICOUNT to see which one it was
+                */
+       case TIOCMIWAIT: {
+               DECLARE_WAITQUEUE(wait, current);
+               int ret;
+               spin_lock_irqsave(&info->slock, flags);
+               cprev = info->icount;   /* note the counters on entry */
+               spin_unlock_irqrestore(&info->slock, flags);
+
+               add_wait_queue(&info->delta_msr_wait, &wait);
+               while (1) {
+                       spin_lock_irqsave(&info->slock, flags);
+                       cnow = info->icount;    /* atomic copy */
+                       spin_unlock_irqrestore(&info->slock, flags);
+
+                       set_current_state(TASK_INTERRUPTIBLE);
+                       if (((arg & TIOCM_RNG) &&
+                                       (cnow.rng != cprev.rng)) ||
+                                       ((arg & TIOCM_DSR) &&
+                                       (cnow.dsr != cprev.dsr)) ||
+                                       ((arg & TIOCM_CD) &&
+                                       (cnow.dcd != cprev.dcd)) ||
+                                       ((arg & TIOCM_CTS) &&
+                                       (cnow.cts != cprev.cts))) {
+                               ret = 0;
+                               break;
+                       }
+                       /* see if a signal did it */
+                       if (signal_pending(current)) {
+                               ret = -ERESTARTSYS;
+                               break;
+                       }
+                       cprev = cnow;
+               }
+               current->state = TASK_RUNNING;
+               remove_wait_queue(&info->delta_msr_wait, &wait);
+               break;
+       }
+       /* NOTREACHED */
+       /*
+        * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
+        * Return: write counters to the user passed counter struct
+        * NB: both 1->0 and 0->1 transitions are counted except for
+        *     RI where only 0->1 is counted.
+        */
+       case TIOCGICOUNT:
+               spin_lock_irqsave(&info->slock, flags);
+               cnow = info->icount;
+               spin_unlock_irqrestore(&info->slock, flags);
+               p_cuser = argp;
+               if (put_user(cnow.frame, &p_cuser->frame))
+                       return -EFAULT;
+               if (put_user(cnow.brk, &p_cuser->brk))
+                       return -EFAULT;
+               if (put_user(cnow.overrun, &p_cuser->overrun))
+                       return -EFAULT;
+               if (put_user(cnow.buf_overrun, &p_cuser->buf_overrun))
+                       return -EFAULT;
+               if (put_user(cnow.parity, &p_cuser->parity))
+                       return -EFAULT;
+               if (put_user(cnow.rx, &p_cuser->rx))
+                       return -EFAULT;
+               if (put_user(cnow.tx, &p_cuser->tx))
+                       return -EFAULT;
+               put_user(cnow.cts, &p_cuser->cts);
+               put_user(cnow.dsr, &p_cuser->dsr);
+               put_user(cnow.rng, &p_cuser->rng);
+               put_user(cnow.dcd, &p_cuser->dcd);
+               return 0;
+       case MOXA_HighSpeedOn:
+               return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp);
+       case MOXA_SDS_RSTICOUNTER:
+               info->mon_data.rxcnt = 0;
+               info->mon_data.txcnt = 0;
+               return 0;
+       case MOXA_ASPP_SETBAUD:{
+               long baud;
+               if (get_user(baud, (long __user *)argp))
+                       return -EFAULT;
+               mxser_set_baud(info, baud);
+               return 0;
+       }
+       case MOXA_ASPP_GETBAUD:
+               if (copy_to_user(argp, &info->realbaud, sizeof(long)))
+                       return -EFAULT;
+
+               return 0;
+
+       case MOXA_ASPP_OQUEUE:{
+               int len, lsr;
+
+               len = mxser_chars_in_buffer(tty);
+
+               lsr = inb(info->ioaddr + UART_LSR) & UART_LSR_TEMT;
+
+               len += (lsr ? 0 : 1);
+
+               if (copy_to_user(argp, &len, sizeof(int)))
+                       return -EFAULT;
+
+               return 0;
+       }
+       case MOXA_ASPP_MON: {
+               int mcr, status;
+
+               status = mxser_get_msr(info->ioaddr, 1, tty->index);
+               mxser_check_modem_status(info, status);
+
+               mcr = inb(info->ioaddr + UART_MCR);
+               if (mcr & MOXA_MUST_MCR_XON_FLAG)
+                       info->mon_data.hold_reason &= ~NPPI_NOTIFY_XOFFHOLD;
+               else
+                       info->mon_data.hold_reason |= NPPI_NOTIFY_XOFFHOLD;
+
+               if (mcr & MOXA_MUST_MCR_TX_XON)
+                       info->mon_data.hold_reason &= ~NPPI_NOTIFY_XOFFXENT;
+               else
+                       info->mon_data.hold_reason |= NPPI_NOTIFY_XOFFXENT;
+
+               if (info->tty->hw_stopped)
+                       info->mon_data.hold_reason |= NPPI_NOTIFY_CTSHOLD;
+               else
+                       info->mon_data.hold_reason &= ~NPPI_NOTIFY_CTSHOLD;
+
+               if (copy_to_user(argp, &info->mon_data,
+                               sizeof(struct mxser_mon)))
+                       return -EFAULT;
+
+               return 0;
+       }
+       case MOXA_ASPP_LSTATUS: {
+               if (copy_to_user(argp, &info->err_shadow,
+                               sizeof(unsigned char)))
+                       return -EFAULT;
+
+               info->err_shadow = 0;
+               return 0;
+       }
+       case MOXA_SET_BAUD_METHOD: {
+               int method;
+
+               if (get_user(method, (int __user *)argp))
+                       return -EFAULT;
+               mxser_set_baud_method[tty->index] = method;
+               if (copy_to_user(argp, &method, sizeof(int)))
+                       return -EFAULT;
+
+               return 0;
+       }
+       default:
+               return -ENOIOCTLCMD;
+       }
+       return 0;
+}
+
+static void mxser_stoprx(struct tty_struct *tty)
+{
+       struct mxser_port *info = tty->driver_data;
+
+       info->ldisc_stop_rx = 1;
+       if (I_IXOFF(tty)) {
+               if (info->board->chip_flag) {
+                       info->IER &= ~MOXA_MUST_RECV_ISR;
+                       outb(info->IER, info->ioaddr + UART_IER);
+               } else {
+                       info->x_char = STOP_CHAR(tty);
+                       outb(0, info->ioaddr + UART_IER);
+                       info->IER |= UART_IER_THRI;
+                       outb(info->IER, info->ioaddr + UART_IER);
+               }
+       }
+
+       if (info->tty->termios->c_cflag & CRTSCTS) {
+               info->MCR &= ~UART_MCR_RTS;
+               outb(info->MCR, info->ioaddr + UART_MCR);
+       }
+}
+
+/*
+ * This routine is called by the upper-layer tty layer to signal that
+ * incoming characters should be throttled.
+ */
+static void mxser_throttle(struct tty_struct *tty)
+{
+       mxser_stoprx(tty);
+}
+
+static void mxser_unthrottle(struct tty_struct *tty)
+{
+       struct mxser_port *info = tty->driver_data;
+
+       /* startrx */
+       info->ldisc_stop_rx = 0;
+       if (I_IXOFF(tty)) {
+               if (info->x_char)
+                       info->x_char = 0;
+               else {
+                       if (info->board->chip_flag) {
+                               info->IER |= MOXA_MUST_RECV_ISR;
+                               outb(info->IER, info->ioaddr + UART_IER);
+                       } else {
+                               info->x_char = START_CHAR(tty);
+                               outb(0, info->ioaddr + UART_IER);
+                               info->IER |= UART_IER_THRI;
+                               outb(info->IER, info->ioaddr + UART_IER);
+                       }
+               }
+       }
+
+       if (info->tty->termios->c_cflag & CRTSCTS) {
+               info->MCR |= UART_MCR_RTS;
+               outb(info->MCR, info->ioaddr + UART_MCR);
+       }
+}
+
+/*
+ * mxser_stop() and mxser_start()
+ *
+ * This routines are called before setting or resetting tty->stopped.
+ * They enable or disable transmitter interrupts, as necessary.
+ */
+static void mxser_stop(struct tty_struct *tty)
+{
+       struct mxser_port *info = tty->driver_data;
+       unsigned long flags;
+
+       spin_lock_irqsave(&info->slock, flags);
+       if (info->IER & UART_IER_THRI) {
+               info->IER &= ~UART_IER_THRI;
+               outb(info->IER, info->ioaddr + UART_IER);
+       }
+       spin_unlock_irqrestore(&info->slock, flags);
+}
+
+static void mxser_start(struct tty_struct *tty)
+{
+       struct mxser_port *info = tty->driver_data;
+       unsigned long flags;
+
+       spin_lock_irqsave(&info->slock, flags);
+       if (info->xmit_cnt && info->xmit_buf) {
+               outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER);
+               info->IER |= UART_IER_THRI;
+               outb(info->IER, info->ioaddr + UART_IER);
+       }
+       spin_unlock_irqrestore(&info->slock, flags);
+}
+
+static void mxser_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
+{
+       struct mxser_port *info = tty->driver_data;
+       unsigned long flags;
+
+       if ((tty->termios->c_cflag != old_termios->c_cflag) ||
+                       (RELEVANT_IFLAG(tty->termios->c_iflag) != RELEVANT_IFLAG(old_termios->c_iflag))) {
+
+               mxser_change_speed(info, old_termios);
+
+               if ((old_termios->c_cflag & CRTSCTS) &&
+                               !(tty->termios->c_cflag & CRTSCTS)) {
+                       tty->hw_stopped = 0;
+                       mxser_start(tty);
+               }
+       }
+
+       /* Handle sw stopped */
+       if ((old_termios->c_iflag & IXON) &&
+                       !(tty->termios->c_iflag & IXON)) {
+               tty->stopped = 0;
+
+               if (info->board->chip_flag) {
+                       spin_lock_irqsave(&info->slock, flags);
+                       DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->ioaddr);
+                       spin_unlock_irqrestore(&info->slock, flags);
+               }
+
+               mxser_start(tty);
+       }
+}
+
+/*
+ * mxser_wait_until_sent() --- wait until the transmitter is empty
+ */
+static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
+{
+       struct mxser_port *info = tty->driver_data;
+       unsigned long orig_jiffies, char_time;
+       int lsr;
+
+       if (info->type == PORT_UNKNOWN)
+               return;
+
+       if (info->xmit_fifo_size == 0)
+               return;         /* Just in case.... */
+
+       orig_jiffies = jiffies;
+       /*
+        * Set the check interval to be 1/5 of the estimated time to
+        * send a single character, and make it at least 1.  The check
+        * interval should also be less than the timeout.
+        *
+        * Note: we have to use pretty tight timings here to satisfy
+        * the NIST-PCTS.
+        */
+       char_time = (info->timeout - HZ / 50) / info->xmit_fifo_size;
+       char_time = char_time / 5;
+       if (char_time == 0)
+               char_time = 1;
+       if (timeout && timeout < char_time)
+               char_time = timeout;
+       /*
+        * If the transmitter hasn't cleared in twice the approximate
+        * amount of time to send the entire FIFO, it probably won't
+        * ever clear.  This assumes the UART isn't doing flow
+        * control, which is currently the case.  Hence, if it ever
+        * takes longer than info->timeout, this is probably due to a
+        * UART bug of some kind.  So, we clamp the timeout parameter at
+        * 2*info->timeout.
+        */
+       if (!timeout || timeout > 2 * info->timeout)
+               timeout = 2 * info->timeout;
+#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
+       printk(KERN_DEBUG "In rs_wait_until_sent(%d) check=%lu...",
+               timeout, char_time);
+       printk("jiff=%lu...", jiffies);
+#endif
+       while (!((lsr = inb(info->ioaddr + UART_LSR)) & UART_LSR_TEMT)) {
+#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
+               printk("lsr = %d (jiff=%lu)...", lsr, jiffies);
+#endif
+               schedule_timeout_interruptible(char_time);
+               if (signal_pending(current))
+                       break;
+               if (timeout && time_after(jiffies, orig_jiffies + timeout))
+                       break;
+       }
+       set_current_state(TASK_RUNNING);
+
+#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
+       printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
+#endif
+}
+
+/*
+ * This routine is called by tty_hangup() when a hangup is signaled.
+ */
+void mxser_hangup(struct tty_struct *tty)
+{
+       struct mxser_port *info = tty->driver_data;
+
+       mxser_flush_buffer(tty);
+       mxser_shutdown(info);
+       info->event = 0;
+       info->count = 0;
+       info->flags &= ~ASYNC_NORMAL_ACTIVE;
+       info->tty = NULL;
+       wake_up_interruptible(&info->open_wait);
+}
+
+/*
+ * mxser_rs_break() --- routine which turns the break handling on or off
+ */
+static void mxser_rs_break(struct tty_struct *tty, int break_state)
+{
+       struct mxser_port *info = tty->driver_data;
+       unsigned long flags;
+
+       spin_lock_irqsave(&info->slock, flags);
+       if (break_state == -1)
+               outb(inb(info->ioaddr + UART_LCR) | UART_LCR_SBC,
+                       info->ioaddr + UART_LCR);
+       else
+               outb(inb(info->ioaddr + UART_LCR) & ~UART_LCR_SBC,
+                       info->ioaddr + UART_LCR);
+       spin_unlock_irqrestore(&info->slock, flags);
+}
+
+static void mxser_receive_chars(struct mxser_port *port, int *status)
+{
+       struct tty_struct *tty = port->tty;
+       unsigned char ch, gdl;
+       int ignored = 0;
+       int cnt = 0;
+       int recv_room;
+       int max = 256;
+       unsigned long flags;
+
+       spin_lock_irqsave(&port->slock, flags);
+
+       recv_room = tty->receive_room;
+       if ((recv_room == 0) && (!port->ldisc_stop_rx))
+               mxser_stoprx(tty);
+
+       if (port->board->chip_flag != MOXA_OTHER_UART) {
+
+               if (*status & UART_LSR_SPECIAL)
+                       goto intr_old;
+               if (port->board->chip_flag == MOXA_MUST_MU860_HWID &&
+                               (*status & MOXA_MUST_LSR_RERR))
+                       goto intr_old;
+               if (*status & MOXA_MUST_LSR_RERR)
+                       goto intr_old;
+
+               gdl = inb(port->ioaddr + MOXA_MUST_GDL_REGISTER);
+
+               if (port->board->chip_flag == MOXA_MUST_MU150_HWID)
+                       gdl &= MOXA_MUST_GDL_MASK;
+               if (gdl >= recv_room) {
+                       if (!port->ldisc_stop_rx)
+                               mxser_stoprx(tty);
+               }
+               while (gdl--) {
+                       ch = inb(port->ioaddr + UART_RX);
+                       tty_insert_flip_char(tty, ch, 0);
+                       cnt++;
+               }
+               goto end_intr;
+       }
+intr_old:
+
+       do {
+               if (max-- < 0)
+                       break;
+
+               ch = inb(port->ioaddr + UART_RX);
+               if (port->board->chip_flag && (*status & UART_LSR_OE))
+                       outb(0x23, port->ioaddr + UART_FCR);
+               *status &= port->read_status_mask;
+               if (*status & port->ignore_status_mask) {
+                       if (++ignored > 100)
+                               break;
+               } else {
+                       char flag = 0;
+                       if (*status & UART_LSR_SPECIAL) {
+                               if (*status & UART_LSR_BI) {
+                                       flag = TTY_BREAK;
+                                       port->icount.brk++;
+
+                                       if (port->flags & ASYNC_SAK)
+                                               do_SAK(tty);
+                               } else if (*status & UART_LSR_PE) {
+                                       flag = TTY_PARITY;
+                                       port->icount.parity++;
+                               } else if (*status & UART_LSR_FE) {
+                                       flag = TTY_FRAME;
+                                       port->icount.frame++;
+                               } else if (*status & UART_LSR_OE) {
+                                       flag = TTY_OVERRUN;
+                                       port->icount.overrun++;
+                               }
+                       }
+                       tty_insert_flip_char(tty, ch, flag);
+                       cnt++;
+                       if (cnt >= recv_room) {
+                               if (!port->ldisc_stop_rx)
+                                       mxser_stoprx(tty);
+                               break;
+                       }
+
+               }
+
+               if (port->board->chip_flag)
+                       break;
+
+               *status = inb(port->ioaddr + UART_LSR);
+       } while (*status & UART_LSR_DR);
+
+end_intr:
+       mxvar_log.rxcnt[port->tty->index] += cnt;
+       port->mon_data.rxcnt += cnt;
+       port->mon_data.up_rxcnt += cnt;
+       spin_unlock_irqrestore(&port->slock, flags);
+
+       tty_flip_buffer_push(tty);
+}
+
+static void mxser_transmit_chars(struct mxser_port *port)
+{
+       int count, cnt;
+       unsigned long flags;
+
+       spin_lock_irqsave(&port->slock, flags);
+
+       if (port->x_char) {
+               outb(port->x_char, port->ioaddr + UART_TX);
+               port->x_char = 0;
+               mxvar_log.txcnt[port->tty->index]++;
+               port->mon_data.txcnt++;
+               port->mon_data.up_txcnt++;
+               port->icount.tx++;
+               goto unlock;
+       }
+
+       if (port->xmit_buf == 0)
+               goto unlock;
+
+       if ((port->xmit_cnt <= 0) || port->tty->stopped ||
+                       (port->tty->hw_stopped &&
+                       (port->type != PORT_16550A) &&
+                       (!port->board->chip_flag))) {
+               port->IER &= ~UART_IER_THRI;
+               outb(port->IER, port->ioaddr + UART_IER);
+               goto unlock;
+       }
+
+       cnt = port->xmit_cnt;
+       count = port->xmit_fifo_size;
+       do {
+               outb(port->xmit_buf[port->xmit_tail++],
+                       port->ioaddr + UART_TX);
+               port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE - 1);
+               if (--port->xmit_cnt <= 0)
+                       break;
+       } while (--count > 0);
+       mxvar_log.txcnt[port->tty->index] += (cnt - port->xmit_cnt);
+
+       port->mon_data.txcnt += (cnt - port->xmit_cnt);
+       port->mon_data.up_txcnt += (cnt - port->xmit_cnt);
+       port->icount.tx += (cnt - port->xmit_cnt);
+
+       if (port->xmit_cnt < WAKEUP_CHARS) {
+               set_bit(MXSER_EVENT_TXLOW, &port->event);
+               schedule_work(&port->tqueue);
+       }
+       if (port->xmit_cnt <= 0) {
+               port->IER &= ~UART_IER_THRI;
+               outb(port->IER, port->ioaddr + UART_IER);
+       }
+unlock:
+       spin_unlock_irqrestore(&port->slock, flags);
+}
+
+/*
+ * This is the serial driver's generic interrupt routine
+ */
+static irqreturn_t mxser_interrupt(int irq, void *dev_id)
+{
+       int status, iir, i;
+       struct mxser_board *brd = NULL;
+       struct mxser_port *port;
+       int max, irqbits, bits, msr;
+       int pass_counter = 0;
+       unsigned int int_cnt;
+       int handled = IRQ_NONE;
+
+       for (i = 0; i < MXSER_BOARDS; i++)
+               if (dev_id == &mxser_boards[i]) {
+                       brd = dev_id;
+                       break;
+               }
+
+       if (i == MXSER_BOARDS)
+               goto irq_stop;
+       if (brd == NULL)
+               goto irq_stop;
+       max = brd->info->nports;
+       while (1) {
+               irqbits = inb(brd->vector) & brd->vector_mask;
+               if (irqbits == brd->vector_mask)
+                       break;
+
+               handled = IRQ_HANDLED;
+               for (i = 0, bits = 1; i < max; i++, irqbits |= bits, bits <<= 1) {
+                       if (irqbits == brd->vector_mask)
+                               break;
+                       if (bits & irqbits)
+                               continue;
+                       port = &brd->ports[i];
+
+                       int_cnt = 0;
+                       do {
+                               iir = inb(port->ioaddr + UART_IIR);
+                               if (iir & UART_IIR_NO_INT)
+                                       break;
+                               iir &= MOXA_MUST_IIR_MASK;
+                               if (!port->tty) {
+                                       status = inb(port->ioaddr + UART_LSR);
+                                       outb(0x27, port->ioaddr + UART_FCR);
+                                       inb(port->ioaddr + UART_MSR);
+                                       break;
+                               }
+
+                               status = inb(port->ioaddr + UART_LSR);
+
+                               if (status & UART_LSR_PE)
+                                       port->err_shadow |= NPPI_NOTIFY_PARITY;
+                               if (status & UART_LSR_FE)
+                                       port->err_shadow |= NPPI_NOTIFY_FRAMING;
+                               if (status & UART_LSR_OE)
+                                       port->err_shadow |=
+                                               NPPI_NOTIFY_HW_OVERRUN;
+                               if (status & UART_LSR_BI)
+                                       port->err_shadow |= NPPI_NOTIFY_BREAK;
+
+                               if (port->board->chip_flag) {
+                                       if (iir == MOXA_MUST_IIR_GDA ||
+                                           iir == MOXA_MUST_IIR_RDA ||
+                                           iir == MOXA_MUST_IIR_RTO ||
+                                           iir == MOXA_MUST_IIR_LSR)
+                                               mxser_receive_chars(port,
+                                                               &status);
+
+                               } else {
+                                       status &= port->read_status_mask;
+                                       if (status & UART_LSR_DR)
+                                               mxser_receive_chars(port,
+                                                               &status);
+                               }
+                               msr = inb(port->ioaddr + UART_MSR);
+                               if (msr & UART_MSR_ANY_DELTA)
+                                       mxser_check_modem_status(port, msr);
+
+                               if (port->board->chip_flag) {
+                                       if (iir == 0x02 && (status &
+                                                               UART_LSR_THRE))
+                                               mxser_transmit_chars(port);
+                               } else {
+                                       if (status & UART_LSR_THRE)
+                                               mxser_transmit_chars(port);
+                               }
+                       } while (int_cnt++ < MXSER_ISR_PASS_LIMIT);
+               }
+               if (pass_counter++ > MXSER_ISR_PASS_LIMIT)
+                       break;  /* Prevent infinite loops */
+       }
+
+irq_stop:
+       return handled;
+}
+
+static const struct tty_operations mxser_ops = {
+       .open = mxser_open,
+       .close = mxser_close,
+       .write = mxser_write,
+       .put_char = mxser_put_char,
+       .flush_chars = mxser_flush_chars,
+       .write_room = mxser_write_room,
+       .chars_in_buffer = mxser_chars_in_buffer,
+       .flush_buffer = mxser_flush_buffer,
+       .ioctl = mxser_ioctl,
+       .throttle = mxser_throttle,
+       .unthrottle = mxser_unthrottle,
+       .set_termios = mxser_set_termios,
+       .stop = mxser_stop,
+       .start = mxser_start,
+       .hangup = mxser_hangup,
+       .break_ctl = mxser_rs_break,
+       .wait_until_sent = mxser_wait_until_sent,
+       .tiocmget = mxser_tiocmget,
+       .tiocmset = mxser_tiocmset,
+};
+
+/*
+ * The MOXA Smartio/Industio serial driver boot-time initialization code!
+ */
+
+static void mxser_release_res(struct mxser_board *brd, struct pci_dev *pdev,
+               unsigned int irq)
+{
+       if (irq)
+               free_irq(brd->irq, brd);
+       if (pdev != NULL) {     /* PCI */
+               pci_release_region(pdev, 2);
+               pci_release_region(pdev, 3);
+               pci_dev_put(pdev);
+       } else {
+               release_region(brd->ports[0].ioaddr, 8 * brd->info->nports);
+               release_region(brd->vector, 1);
+       }
+}
+
+static int __devinit mxser_initbrd(struct mxser_board *brd,
+               struct pci_dev *pdev)
+{
+       struct mxser_port *info;
+       unsigned int i;
+       int retval;
+
+       printk(KERN_INFO "max. baud rate = %d bps.\n", brd->ports[0].max_baud);
+
+       for (i = 0; i < brd->info->nports; i++) {
+               info = &brd->ports[i];
+               info->board = brd;
+               info->stop_rx = 0;
+               info->ldisc_stop_rx = 0;
+
+               /* Enhance mode enabled here */
+               if (brd->chip_flag != MOXA_OTHER_UART)
+                       ENABLE_MOXA_MUST_ENCHANCE_MODE(info->ioaddr);
+
+               info->flags = ASYNC_SHARE_IRQ;
+               info->type = brd->uart_type;
+
+               process_txrx_fifo(info);
+
+               info->custom_divisor = info->baud_base * 16;
+               info->close_delay = 5 * HZ / 10;
+               info->closing_wait = 30 * HZ;
+               INIT_WORK(&info->tqueue, mxser_do_softint);
+               info->normal_termios = mxvar_sdriver->init_termios;
+               init_waitqueue_head(&info->open_wait);
+               init_waitqueue_head(&info->close_wait);
+               init_waitqueue_head(&info->delta_msr_wait);
+               memset(&info->mon_data, 0, sizeof(struct mxser_mon));
+               info->err_shadow = 0;
+               spin_lock_init(&info->slock);
+
+               /* before set INT ISR, disable all int */
+               outb(inb(info->ioaddr + UART_IER) & 0xf0,
+                       info->ioaddr + UART_IER);
+       }
+       /*
+        * Allocate the IRQ if necessary
+        */
+
+       retval = request_irq(brd->irq, mxser_interrupt,
+                       (brd->ports[0].flags & ASYNC_SHARE_IRQ) ? IRQF_SHARED :
+                       IRQF_DISABLED, "mxser", brd);
+       if (retval) {
+               printk(KERN_ERR "Board %s: Request irq failed, IRQ (%d) may "
+                       "conflict with another device.\n",
+                       brd->info->name, brd->irq);
+               /* We hold resources, we need to release them. */
+               mxser_release_res(brd, pdev, 0);
+               return retval;
+       }
+       return 0;
+}
+
+static int __init mxser_get_ISA_conf(int cap, struct mxser_board *brd)
+{
+       int id, i, bits;
+       unsigned short regs[16], irq;
+       unsigned char scratch, scratch2;
+
+       brd->chip_flag = MOXA_OTHER_UART;
+
+       id = mxser_read_register(cap, regs);
+       switch (id) {
+       case C168_ASIC_ID:
+               brd->info = &mxser_cards[0];
+               break;
+       case C104_ASIC_ID:
+               brd->info = &mxser_cards[1];
+               break;
+       case CI104J_ASIC_ID:
+               brd->info = &mxser_cards[2];
+               break;
+       case C102_ASIC_ID:
+               brd->info = &mxser_cards[5];
+               break;
+       case CI132_ASIC_ID:
+               brd->info = &mxser_cards[6];
+               break;
+       case CI134_ASIC_ID:
+               brd->info = &mxser_cards[7];
+               break;
+       default:
+               return 0;
+       }
+
+       irq = 0;
+       /* some ISA cards have 2 ports, but we want to see them as 4-port (why?)
+          Flag-hack checks if configuration should be read as 2-port here. */
+       if (brd->info->nports == 2 || (brd->info->flags & MXSER_HAS2)) {
+               irq = regs[9] & 0xF000;
+               irq = irq | (irq >> 4);
+               if (irq != (regs[9] & 0xFF00))
+                       return MXSER_ERR_IRQ_CONFLIT;
+       } else if (brd->info->nports == 4) {
+               irq = regs[9] & 0xF000;
+               irq = irq | (irq >> 4);
+               irq = irq | (irq >> 8);
+               if (irq != regs[9])
+                       return MXSER_ERR_IRQ_CONFLIT;
+       } else if (brd->info->nports == 8) {
+               irq = regs[9] & 0xF000;
+               irq = irq | (irq >> 4);
+               irq = irq | (irq >> 8);
+               if ((irq != regs[9]) || (irq != regs[10]))
+                       return MXSER_ERR_IRQ_CONFLIT;
+       }
+
+       if (!irq)
+               return MXSER_ERR_IRQ;
+       brd->irq = ((int)(irq & 0xF000) >> 12);
+       for (i = 0; i < 8; i++)
+               brd->ports[i].ioaddr = (int) regs[i + 1] & 0xFFF8;
+       if ((regs[12] & 0x80) == 0)
+               return MXSER_ERR_VECTOR;
+       brd->vector = (int)regs[11];    /* interrupt vector */
+       if (id == 1)
+               brd->vector_mask = 0x00FF;
+       else
+               brd->vector_mask = 0x000F;
+       for (i = 7, bits = 0x0100; i >= 0; i--, bits <<= 1) {
+               if (regs[12] & bits) {
+                       brd->ports[i].baud_base = 921600;
+                       brd->ports[i].max_baud = 921600;
+               } else {
+                       brd->ports[i].baud_base = 115200;
+                       brd->ports[i].max_baud = 115200;
+               }
+       }
+       scratch2 = inb(cap + UART_LCR) & (~UART_LCR_DLAB);
+       outb(scratch2 | UART_LCR_DLAB, cap + UART_LCR);
+       outb(0, cap + UART_EFR);        /* EFR is the same as FCR */
+       outb(scratch2, cap + UART_LCR);
+       outb(UART_FCR_ENABLE_FIFO, cap + UART_FCR);
+       scratch = inb(cap + UART_IIR);
+
+       if (scratch & 0xC0)
+               brd->uart_type = PORT_16550A;
+       else
+               brd->uart_type = PORT_16450;
+       if (!request_region(brd->ports[0].ioaddr, 8 * brd->info->nports,
+                       "mxser(IO)"))
+               return MXSER_ERR_IOADDR;
+       if (!request_region(brd->vector, 1, "mxser(vector)")) {
+               release_region(brd->ports[0].ioaddr, 8 * brd->info->nports);
+               return MXSER_ERR_VECTOR;
+       }
+       return brd->info->nports;
+}
+
+static int __devinit mxser_probe(struct pci_dev *pdev,
+               const struct pci_device_id *ent)
+{
+       struct mxser_board *brd;
+       unsigned int i, j;
+       unsigned long ioaddress;
+       int retval = -EINVAL;
+
+       for (i = 0; i < MXSER_BOARDS; i++)
+               if (mxser_boards[i].info == NULL)
+                       break;
+
+       if (i >= MXSER_BOARDS) {
+               printk(KERN_ERR "Too many Smartio/Industio family boards found "
+                       "(maximum %d), board not configured\n", MXSER_BOARDS);
+               goto err;
+       }
+
+       brd = &mxser_boards[i];
+       brd->idx = i * MXSER_PORTS_PER_BOARD;
+       printk(KERN_INFO "Found MOXA %s board (BusNo=%d, DevNo=%d)\n",
+               mxser_cards[ent->driver_data].name,
+               pdev->bus->number, PCI_SLOT(pdev->devfn));
+
+       retval = pci_enable_device(pdev);
+       if (retval) {
+               printk(KERN_ERR "Moxa SmartI/O PCI enable fail !\n");
+               goto err;
+       }
+
+       /* io address */
+       ioaddress = pci_resource_start(pdev, 2);
+       retval = pci_request_region(pdev, 2, "mxser(IO)");
+       if (retval)
+               goto err;
+
+       brd->info = &mxser_cards[ent->driver_data];
+       for (i = 0; i < brd->info->nports; i++)
+               brd->ports[i].ioaddr = ioaddress + 8 * i;
+
+       /* vector */
+       ioaddress = pci_resource_start(pdev, 3);
+       retval = pci_request_region(pdev, 3, "mxser(vector)");
+       if (retval)
+               goto err_relio;
+       brd->vector = ioaddress;
+
+       /* irq */
+       brd->irq = pdev->irq;
+
+       brd->chip_flag = CheckIsMoxaMust(brd->ports[0].ioaddr);
+       brd->uart_type = PORT_16550A;
+       brd->vector_mask = 0;
+
+       for (i = 0; i < brd->info->nports; i++) {
+               for (j = 0; j < UART_INFO_NUM; j++) {
+                       if (Gpci_uart_info[j].type == brd->chip_flag) {
+                               brd->ports[i].max_baud =
+                                       Gpci_uart_info[j].max_baud;
+
+                               /* exception....CP-102 */
+                               if (brd->info->flags & MXSER_HIGHBAUD)
+                                       brd->ports[i].max_baud = 921600;
+                               break;
+                       }
+               }
+       }
+
+       if (brd->chip_flag == MOXA_MUST_MU860_HWID) {
+               for (i = 0; i < brd->info->nports; i++) {
+                       if (i < 4)
+                               brd->ports[i].opmode_ioaddr = ioaddress + 4;
+                       else
+                               brd->ports[i].opmode_ioaddr = ioaddress + 0x0c;
+               }
+               outb(0, ioaddress + 4); /* default set to RS232 mode */
+               outb(0, ioaddress + 0x0c);      /* default set to RS232 mode */
+       }
+
+       for (i = 0; i < brd->info->nports; i++) {
+               brd->vector_mask |= (1 << i);
+               brd->ports[i].baud_base = 921600;
+       }
+
+       /* mxser_initbrd will hook ISR. */
+       if (mxser_initbrd(brd, pdev) < 0)
+               goto err_relvec;
+
+       for (i = 0; i < brd->info->nports; i++)
+               tty_register_device(mxvar_sdriver, brd->idx + i, &pdev->dev);
+
+       pci_set_drvdata(pdev, brd);
+
+       return 0;
+err_relvec:
+       pci_release_region(pdev, 3);
+err_relio:
+       pci_release_region(pdev, 2);
+       brd->info = NULL;
+err:
+       return retval;
+}
+
+static void __devexit mxser_remove(struct pci_dev *pdev)
+{
+       struct mxser_board *brd = pci_get_drvdata(pdev);
+       unsigned int i;
+
+       for (i = 0; i < brd->info->nports; i++)
+               tty_unregister_device(mxvar_sdriver, brd->idx + i);
+
+       mxser_release_res(brd, pdev, 1);
+}
+
+static struct pci_driver mxser_driver = {
+       .name = "mxser",
+       .id_table = mxser_pcibrds,
+       .probe = mxser_probe,
+       .remove = __devexit_p(mxser_remove)
+};
+
+static int __init mxser_module_init(void)
+{
+       struct mxser_board *brd;
+       unsigned long cap;
+       unsigned int i, m, isaloop;
+       int retval, b;
+
+       pr_debug("Loading module mxser ...\n");
+
+       mxvar_sdriver = alloc_tty_driver(MXSER_PORTS + 1);
+       if (!mxvar_sdriver)
+               return -ENOMEM;
+       spin_lock_init(&gm_lock);
+
+       printk(KERN_INFO "MOXA Smartio/Industio family driver version %s\n",
+               MXSER_VERSION);
+
+       /* Initialize the tty_driver structure */
+       mxvar_sdriver->magic = TTY_DRIVER_MAGIC;
+       mxvar_sdriver->name = "ttyMI";
+       mxvar_sdriver->major = ttymajor;
+       mxvar_sdriver->minor_start = 0;
+       mxvar_sdriver->num = MXSER_PORTS + 1;
+       mxvar_sdriver->type = TTY_DRIVER_TYPE_SERIAL;
+       mxvar_sdriver->subtype = SERIAL_TYPE_NORMAL;
+       mxvar_sdriver->init_termios = tty_std_termios;
+       mxvar_sdriver->init_termios.c_cflag = B9600|CS8|CREAD|HUPCL|CLOCAL;
+       mxvar_sdriver->flags = TTY_DRIVER_REAL_RAW|TTY_DRIVER_DYNAMIC_DEV;
+       tty_set_operations(mxvar_sdriver, &mxser_ops);
+
+       retval = tty_register_driver(mxvar_sdriver);
+       if (retval) {
+               printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family "
+                               "tty driver !\n");
+               goto err_put;
+       }
+
+       mxvar_diagflag = 0;
+
+       m = 0;
+       /* Start finding ISA boards here */
+       for (isaloop = 0; isaloop < 2; isaloop++)
+               for (b = 0; b < MXSER_BOARDS && m < MXSER_BOARDS; b++) {
+                       if (!isaloop)
+                               cap = mxserBoardCAP[b]; /* predefined */
+                       else
+                               cap = ioaddr[b]; /* module param */
+
+                       if (!cap)
+                               continue;
+
+                       brd = &mxser_boards[m];
+                       retval = mxser_get_ISA_conf(cap, brd);
+
+                       if (retval != 0)
+                               printk(KERN_INFO "Found MOXA %s board "
+                                       "(CAP=0x%x)\n",
+                                       brd->info->name, ioaddr[b]);
+
+                       if (retval <= 0) {
+                               if (retval == MXSER_ERR_IRQ)
+                                       printk(KERN_ERR "Invalid interrupt "
+                                               "number, board not "
+                                               "configured\n");
+                               else if (retval == MXSER_ERR_IRQ_CONFLIT)
+                                       printk(KERN_ERR "Invalid interrupt "
+                                               "number, board not "
+                                               "configured\n");
+                               else if (retval == MXSER_ERR_VECTOR)
+                                       printk(KERN_ERR "Invalid interrupt "
+                                               "vector, board not "
+                                               "configured\n");
+                               else if (retval == MXSER_ERR_IOADDR)
+                                       printk(KERN_ERR "Invalid I/O address, "
+                                               "board not configured\n");
+
+                               brd->info = NULL;
+                               continue;
+                       }
+
+                       /* mxser_initbrd will hook ISR. */
+                       if (mxser_initbrd(brd, NULL) < 0) {
+                               brd->info = NULL;
+                               continue;
+                       }
+
+                       brd->idx = m * MXSER_PORTS_PER_BOARD;
+                       for (i = 0; i < brd->info->nports; i++)
+                               tty_register_device(mxvar_sdriver, brd->idx + i,
+                                               NULL);
+
+                       m++;
+               }
+
+       retval = pci_register_driver(&mxser_driver);
+       if (retval) {
+               printk(KERN_ERR "Can't register pci driver\n");
+               if (!m) {
+                       retval = -ENODEV;
+                       goto err_unr;
+               } /* else: we have some ISA cards under control */
+       }
+
+       pr_debug("Done.\n");
+
+       return 0;
+err_unr:
+       tty_unregister_driver(mxvar_sdriver);
+err_put:
+       put_tty_driver(mxvar_sdriver);
+       return retval;
+}
+
+static void __exit mxser_module_exit(void)
+{
+       unsigned int i, j;
+
+       pr_debug("Unloading module mxser ...\n");
+
+       pci_unregister_driver(&mxser_driver);
+
+       for (i = 0; i < MXSER_BOARDS; i++) /* ISA remains */
+               if (mxser_boards[i].info != NULL)
+                       for (j = 0; j < mxser_boards[i].info->nports; j++)
+                               tty_unregister_device(mxvar_sdriver,
+                                               mxser_boards[i].idx + j);
+       tty_unregister_driver(mxvar_sdriver);
+       put_tty_driver(mxvar_sdriver);
+
+       for (i = 0; i < MXSER_BOARDS; i++)
+               if (mxser_boards[i].info != NULL)
+                       mxser_release_res(&mxser_boards[i], NULL, 1);
+
+       pr_debug("Done.\n");
+}
+
+module_init(mxser_module_init);
+module_exit(mxser_module_exit);
diff --git a/drivers/char/mxser_new.h b/drivers/char/mxser_new.h
new file mode 100644 (file)
index 0000000..a08f0ec
--- /dev/null
@@ -0,0 +1,450 @@
+#ifndef _MXSER_H
+#define _MXSER_H
+
+/*
+ *     Semi-public control interfaces
+ */
+
+/*
+ *     MOXA ioctls
+ */
+
+#define MOXA                   0x400
+#define MOXA_GETDATACOUNT      (MOXA + 23)
+#define        MOXA_GET_CONF           (MOXA + 35)
+#define MOXA_DIAGNOSE          (MOXA + 50)
+#define MOXA_CHKPORTENABLE     (MOXA + 60)
+#define MOXA_HighSpeedOn       (MOXA + 61)
+#define MOXA_GET_MAJOR         (MOXA + 63)
+#define MOXA_GET_CUMAJOR       (MOXA + 64)
+#define MOXA_GETMSTATUS                (MOXA + 65)
+#define MOXA_SET_OP_MODE       (MOXA + 66)
+#define MOXA_GET_OP_MODE       (MOXA + 67)
+
+#define RS232_MODE             0
+#define RS485_2WIRE_MODE       1
+#define RS422_MODE             2
+#define RS485_4WIRE_MODE       3
+#define OP_MODE_MASK           3
+// above add by Victor Yu. 01-05-2004
+
+#define TTY_THRESHOLD_THROTTLE  128
+
+#define LO_WATER               (TTY_FLIPBUF_SIZE)
+#define HI_WATER               (TTY_FLIPBUF_SIZE*2*3/4)
+
+// added by James. 03-11-2004.
+#define MOXA_SDS_GETICOUNTER   (MOXA + 68)
+#define MOXA_SDS_RSTICOUNTER   (MOXA + 69)
+// (above) added by James.
+
+#define MOXA_ASPP_OQUEUE       (MOXA + 70)
+#define MOXA_ASPP_SETBAUD      (MOXA + 71)
+#define MOXA_ASPP_GETBAUD      (MOXA + 72)
+#define MOXA_ASPP_MON          (MOXA + 73)
+#define MOXA_ASPP_LSTATUS      (MOXA + 74)
+#define MOXA_ASPP_MON_EXT      (MOXA + 75)
+#define MOXA_SET_BAUD_METHOD   (MOXA + 76)
+
+
+/* --------------------------------------------------- */
+
+#define NPPI_NOTIFY_PARITY     0x01
+#define NPPI_NOTIFY_FRAMING    0x02
+#define NPPI_NOTIFY_HW_OVERRUN 0x04
+#define NPPI_NOTIFY_SW_OVERRUN 0x08
+#define NPPI_NOTIFY_BREAK      0x10
+
+#define NPPI_NOTIFY_CTSHOLD         0x01       // Tx hold by CTS low
+#define NPPI_NOTIFY_DSRHOLD         0x02       // Tx hold by DSR low
+#define NPPI_NOTIFY_XOFFHOLD        0x08       // Tx hold by Xoff received
+#define NPPI_NOTIFY_XOFFXENT        0x10       // Xoff Sent
+
+//CheckIsMoxaMust return value
+#define MOXA_OTHER_UART                        0x00
+#define MOXA_MUST_MU150_HWID           0x01
+#define MOXA_MUST_MU860_HWID           0x02
+
+// follow just for Moxa Must chip define.
+//
+// when LCR register (offset 0x03) write following value,
+// the Must chip will enter enchance mode. And write value
+// on EFR (offset 0x02) bit 6,7 to change bank.
+#define MOXA_MUST_ENTER_ENCHANCE       0xBF
+
+// when enhance mode enable, access on general bank register
+#define MOXA_MUST_GDL_REGISTER         0x07
+#define MOXA_MUST_GDL_MASK             0x7F
+#define MOXA_MUST_GDL_HAS_BAD_DATA     0x80
+
+#define MOXA_MUST_LSR_RERR             0x80    // error in receive FIFO
+// enchance register bank select and enchance mode setting register
+// when LCR register equal to 0xBF
+#define MOXA_MUST_EFR_REGISTER         0x02
+// enchance mode enable
+#define MOXA_MUST_EFR_EFRB_ENABLE      0x10
+// enchance reister bank set 0, 1, 2
+#define MOXA_MUST_EFR_BANK0            0x00
+#define MOXA_MUST_EFR_BANK1            0x40
+#define MOXA_MUST_EFR_BANK2            0x80
+#define MOXA_MUST_EFR_BANK3            0xC0
+#define MOXA_MUST_EFR_BANK_MASK                0xC0
+
+// set XON1 value register, when LCR=0xBF and change to bank0
+#define MOXA_MUST_XON1_REGISTER                0x04
+
+// set XON2 value register, when LCR=0xBF and change to bank0
+#define MOXA_MUST_XON2_REGISTER                0x05
+
+// set XOFF1 value register, when LCR=0xBF and change to bank0
+#define MOXA_MUST_XOFF1_REGISTER       0x06
+
+// set XOFF2 value register, when LCR=0xBF and change to bank0
+#define MOXA_MUST_XOFF2_REGISTER       0x07
+
+#define MOXA_MUST_RBRTL_REGISTER       0x04
+#define MOXA_MUST_RBRTH_REGISTER       0x05
+#define MOXA_MUST_RBRTI_REGISTER       0x06
+#define MOXA_MUST_THRTL_REGISTER       0x07
+#define MOXA_MUST_ENUM_REGISTER                0x04
+#define MOXA_MUST_HWID_REGISTER                0x05
+#define MOXA_MUST_ECR_REGISTER         0x06
+#define MOXA_MUST_CSR_REGISTER         0x07
+
+// good data mode enable
+#define MOXA_MUST_FCR_GDA_MODE_ENABLE  0x20
+// only good data put into RxFIFO
+#define MOXA_MUST_FCR_GDA_ONLY_ENABLE  0x10
+
+// enable CTS interrupt
+#define MOXA_MUST_IER_ECTSI            0x80
+// enable RTS interrupt
+#define MOXA_MUST_IER_ERTSI            0x40
+// enable Xon/Xoff interrupt
+#define MOXA_MUST_IER_XINT             0x20
+// enable GDA interrupt
+#define MOXA_MUST_IER_EGDAI            0x10
+
+#define MOXA_MUST_RECV_ISR             (UART_IER_RDI | MOXA_MUST_IER_EGDAI)
+
+// GDA interrupt pending
+#define MOXA_MUST_IIR_GDA              0x1C
+#define MOXA_MUST_IIR_RDA              0x04
+#define MOXA_MUST_IIR_RTO              0x0C
+#define MOXA_MUST_IIR_LSR              0x06
+
+// recieved Xon/Xoff or specical interrupt pending
+#define MOXA_MUST_IIR_XSC              0x10
+
+// RTS/CTS change state interrupt pending
+#define MOXA_MUST_IIR_RTSCTS           0x20
+#define MOXA_MUST_IIR_MASK             0x3E
+
+#define MOXA_MUST_MCR_XON_FLAG         0x40
+#define MOXA_MUST_MCR_XON_ANY          0x80
+#define MOXA_MUST_MCR_TX_XON           0x08
+
+
+// software flow control on chip mask value
+#define MOXA_MUST_EFR_SF_MASK          0x0F
+// send Xon1/Xoff1
+#define MOXA_MUST_EFR_SF_TX1           0x08
+// send Xon2/Xoff2
+#define MOXA_MUST_EFR_SF_TX2           0x04
+// send Xon1,Xon2/Xoff1,Xoff2
+#define MOXA_MUST_EFR_SF_TX12          0x0C
+// don't send Xon/Xoff
+#define MOXA_MUST_EFR_SF_TX_NO         0x00
+// Tx software flow control mask
+#define MOXA_MUST_EFR_SF_TX_MASK       0x0C
+// don't receive Xon/Xoff
+#define MOXA_MUST_EFR_SF_RX_NO         0x00
+// receive Xon1/Xoff1
+#define MOXA_MUST_EFR_SF_RX1           0x02
+// receive Xon2/Xoff2
+#define MOXA_MUST_EFR_SF_RX2           0x01
+// receive Xon1,Xon2/Xoff1,Xoff2
+#define MOXA_MUST_EFR_SF_RX12          0x03
+// Rx software flow control mask
+#define MOXA_MUST_EFR_SF_RX_MASK       0x03
+
+//#define MOXA_MUST_MIN_XOFFLIMIT               66
+//#define MOXA_MUST_MIN_XONLIMIT                20
+//#define ID1_RX_TRIG                   120
+
+
+#define CHECK_MOXA_MUST_XOFFLIMIT(info) {      \
+       if ( (info)->IsMoxaMustChipFlag &&      \
+        (info)->HandFlow.XoffLimit < MOXA_MUST_MIN_XOFFLIMIT ) {       \
+               (info)->HandFlow.XoffLimit = MOXA_MUST_MIN_XOFFLIMIT;   \
+               (info)->HandFlow.XonLimit = MOXA_MUST_MIN_XONLIMIT;     \
+       }       \
+}
+
+#define ENABLE_MOXA_MUST_ENCHANCE_MODE(baseio) { \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr |= MOXA_MUST_EFR_EFRB_ENABLE;     \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define DISABLE_MOXA_MUST_ENCHANCE_MODE(baseio) {      \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_EFRB_ENABLE;    \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define SET_MOXA_MUST_XON1_VALUE(baseio, Value) {      \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
+       __efr |= MOXA_MUST_EFR_BANK0;   \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb((u8)(Value), (baseio)+MOXA_MUST_XON1_REGISTER);    \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define SET_MOXA_MUST_XON2_VALUE(baseio, Value) {      \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
+       __efr |= MOXA_MUST_EFR_BANK0;   \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb((u8)(Value), (baseio)+MOXA_MUST_XON2_REGISTER);    \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define SET_MOXA_MUST_XOFF1_VALUE(baseio, Value) {     \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
+       __efr |= MOXA_MUST_EFR_BANK0;   \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb((u8)(Value), (baseio)+MOXA_MUST_XOFF1_REGISTER);   \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define SET_MOXA_MUST_XOFF2_VALUE(baseio, Value) {     \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
+       __efr |= MOXA_MUST_EFR_BANK0;   \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb((u8)(Value), (baseio)+MOXA_MUST_XOFF2_REGISTER);   \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define SET_MOXA_MUST_RBRTL_VALUE(baseio, Value) {     \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
+       __efr |= MOXA_MUST_EFR_BANK1;   \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb((u8)(Value), (baseio)+MOXA_MUST_RBRTL_REGISTER);   \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define SET_MOXA_MUST_RBRTH_VALUE(baseio, Value) {     \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
+       __efr |= MOXA_MUST_EFR_BANK1;   \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb((u8)(Value), (baseio)+MOXA_MUST_RBRTH_REGISTER);   \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define SET_MOXA_MUST_RBRTI_VALUE(baseio, Value) {     \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
+       __efr |= MOXA_MUST_EFR_BANK1;   \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb((u8)(Value), (baseio)+MOXA_MUST_RBRTI_REGISTER);   \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define SET_MOXA_MUST_THRTL_VALUE(baseio, Value) {     \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
+       __efr |= MOXA_MUST_EFR_BANK1;   \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb((u8)(Value), (baseio)+MOXA_MUST_THRTL_REGISTER);   \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+//#define MOXA_MUST_RBRL_VALUE  4
+#define SET_MOXA_MUST_FIFO_VALUE(info) {       \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((info)->ioaddr+UART_LCR);        \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (info)->ioaddr+UART_LCR);        \
+       __efr = inb((info)->ioaddr+MOXA_MUST_EFR_REGISTER);     \
+       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
+       __efr |= MOXA_MUST_EFR_BANK1;   \
+       outb(__efr, (info)->ioaddr+MOXA_MUST_EFR_REGISTER);     \
+       outb((u8)((info)->rx_high_water), (info)->ioaddr+MOXA_MUST_RBRTH_REGISTER);     \
+       outb((u8)((info)->rx_trigger), (info)->ioaddr+MOXA_MUST_RBRTI_REGISTER);        \
+       outb((u8)((info)->rx_low_water), (info)->ioaddr+MOXA_MUST_RBRTL_REGISTER);      \
+       outb(__oldlcr, (info)->ioaddr+UART_LCR);        \
+}
+
+
+
+#define SET_MOXA_MUST_ENUM_VALUE(baseio, Value) {      \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
+       __efr |= MOXA_MUST_EFR_BANK2;   \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb((u8)(Value), (baseio)+MOXA_MUST_ENUM_REGISTER);    \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define GET_MOXA_MUST_HARDWARE_ID(baseio, pId) {       \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
+       __efr |= MOXA_MUST_EFR_BANK2;   \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       *pId = inb((baseio)+MOXA_MUST_HWID_REGISTER);   \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(baseio) {       \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_SF_MASK;        \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define SET_MOXA_MUST_JUST_TX_SOFTWARE_FLOW_CONTROL(baseio) {  \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_SF_MASK;        \
+       __efr |= MOXA_MUST_EFR_SF_TX1;  \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define ENABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(baseio) {    \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_SF_TX_MASK;     \
+       __efr |= MOXA_MUST_EFR_SF_TX1;  \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(baseio) {   \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_SF_TX_MASK;     \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define SET_MOXA_MUST_JUST_RX_SOFTWARE_FLOW_CONTROL(baseio) {  \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_SF_MASK;        \
+       __efr |= MOXA_MUST_EFR_SF_RX1;  \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define ENABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(baseio) {    \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_SF_RX_MASK;     \
+       __efr |= MOXA_MUST_EFR_SF_RX1;  \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(baseio) {   \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_SF_RX_MASK;     \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define ENABLE_MOXA_MUST_TX_RX_SOFTWARE_FLOW_CONTROL(baseio) { \
+       u8      __oldlcr, __efr;        \
+       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr &= ~MOXA_MUST_EFR_SF_MASK;        \
+       __efr |= (MOXA_MUST_EFR_SF_RX1|MOXA_MUST_EFR_SF_TX1);   \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       outb(__oldlcr, (baseio)+UART_LCR);      \
+}
+
+#define ENABLE_MOXA_MUST_XON_ANY_FLOW_CONTROL(baseio) {        \
+       u8      __oldmcr;       \
+       __oldmcr = inb((baseio)+UART_MCR);      \
+       __oldmcr |= MOXA_MUST_MCR_XON_ANY;      \
+       outb(__oldmcr, (baseio)+UART_MCR);      \
+}
+
+#define DISABLE_MOXA_MUST_XON_ANY_FLOW_CONTROL(baseio) {       \
+       u8      __oldmcr;       \
+       __oldmcr = inb((baseio)+UART_MCR);      \
+       __oldmcr &= ~MOXA_MUST_MCR_XON_ANY;     \
+       outb(__oldmcr, (baseio)+UART_MCR);      \
+}
+
+#define READ_MOXA_MUST_GDL(baseio)     inb((baseio)+MOXA_MUST_GDL_REGISTER)
+
+
+#ifndef INIT_WORK
+#define INIT_WORK(_work, _func, _data){        \
+       _data->tqueue.routine = _func;\
+       _data->tqueue.data = _data;\
+       }
+#endif
+
+#endif
index 203dc2b661d5cc8b4bba97e79b893650c0c3773b..103d338f21e24483c36adc71f9433daf017de0f4 100644 (file)
@@ -142,7 +142,7 @@ static ssize_t r3964_write(struct tty_struct * tty, struct file * file,
                       const unsigned char * buf, size_t nr);
 static int r3964_ioctl(struct tty_struct * tty, struct file * file,
                        unsigned int cmd, unsigned long arg);
-static void r3964_set_termios(struct tty_struct *tty, struct termios * old);
+static void r3964_set_termios(struct tty_struct *tty, struct ktermios * old);
 static unsigned int r3964_poll(struct tty_struct * tty, struct file * file,
                      struct poll_table_struct  *wait);
 static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
@@ -1347,7 +1347,7 @@ static int r3964_ioctl(struct tty_struct * tty, struct file * file,
    }
 }
 
-static void r3964_set_termios(struct tty_struct *tty, struct termios * old)
+static void r3964_set_termios(struct tty_struct *tty, struct ktermios * old)
 {
    TRACE_L("set_termios");
 }
index 603b9ade5eb089f16f041fc15e4876417a6c1505..e96a00fe13891b6f5f9fae1b2e1e6f1054d37956 100644 (file)
@@ -994,7 +994,7 @@ int is_ignored(int sig)
  *     when the ldisc is closed.
  */
  
-static void n_tty_set_termios(struct tty_struct *tty, struct termios * old)
+static void n_tty_set_termios(struct tty_struct *tty, struct ktermios * old)
 {
        if (!tty)
                return;
index 4d47d79bcea78aa4a0f4abc34137fc530fc36f7d..808d44e9a32a03bd1c2dc1e54432721e98a57e94 100644 (file)
@@ -41,7 +41,7 @@ void nsc_gpio_dump(struct nsc_gpio_ops *amp, unsigned index)
 ssize_t nsc_gpio_write(struct file *file, const char __user *data,
                       size_t len, loff_t *ppos)
 {
-       unsigned m = iminor(file->f_dentry->d_inode);
+       unsigned m = iminor(file->f_path.dentry->d_inode);
        struct nsc_gpio_ops *amp = file->private_data;
        struct device *dev = amp->dev;
        size_t i;
@@ -104,7 +104,7 @@ ssize_t nsc_gpio_write(struct file *file, const char __user *data,
 ssize_t nsc_gpio_read(struct file *file, char __user * buf,
                      size_t len, loff_t * ppos)
 {
-       unsigned m = iminor(file->f_dentry->d_inode);
+       unsigned m = iminor(file->f_path.dentry->d_inode);
        int value;
        struct nsc_gpio_ops *amp = file->private_data;
 
index 1bd12296dca51328a57b234587a30f6e3adf76aa..5152cedd8878ff235bcbe2a0b0a2d593e7ed08dd 100644 (file)
 #include <pcmcia/cisreg.h>
 #include <pcmcia/ds.h>
 
-#ifdef CONFIG_HDLC_MODULE
-#define CONFIG_HDLC 1
+#if defined(CONFIG_HDLC) || (defined(CONFIG_HDLC_MODULE) && defined(CONFIG_SYNCLINK_CS_MODULE))
+#define SYNCLINK_GENERIC_HDLC 1
+#else
+#define SYNCLINK_GENERIC_HDLC 0
 #endif
 
 #define GET_USER(error,value,addr) error = get_user(value,addr)
@@ -235,7 +237,7 @@ typedef struct _mgslpc_info {
        int dosyncppp;
        spinlock_t netlock;
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        struct net_device *netdev;
 #endif
 
@@ -392,7 +394,7 @@ static void tx_timeout(unsigned long context);
 
 static int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg);
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
 #define dev_to_port(D) (dev_to_hdlc(D)->priv)
 static void hdlcdev_tx_done(MGSLPC_INFO *info);
 static void hdlcdev_rx(MGSLPC_INFO *info, char *buf, int size);
@@ -1053,7 +1055,7 @@ static void tx_done(MGSLPC_INFO *info)
                info->drop_rts_on_tx_done = 0;
        }
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        if (info->netcount)
                hdlcdev_tx_done(info);
        else 
@@ -1164,7 +1166,7 @@ static void dcd_change(MGSLPC_INFO *info)
        }
        else
                info->input_signal_events.dcd_down++;
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        if (info->netcount) {
                if (info->serial_signals & SerialSignal_DCD)
                        netif_carrier_on(info->netdev);
@@ -2373,7 +2375,7 @@ static int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg)
  *     tty             pointer to tty structure
  *     termios         pointer to buffer to hold returned old termios
  */
-static void mgslpc_set_termios(struct tty_struct *tty, struct termios *old_termios)
+static void mgslpc_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
        MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data;
        unsigned long flags;
@@ -2953,7 +2955,7 @@ static void mgslpc_add_device(MGSLPC_INFO *info)
        printk( "SyncLink PC Card %s:IO=%04X IRQ=%d\n",
                info->device_name, info->io_base, info->irq_level);
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        hdlcdev_init(info);
 #endif
 }
@@ -2969,7 +2971,7 @@ static void mgslpc_remove_device(MGSLPC_INFO *remove_info)
                                last->next_device = info->next_device;
                        else
                                mgslpc_device_list = info->next_device;
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                        hdlcdev_exit(info);
 #endif
                        release_resources(info);
@@ -3901,7 +3903,7 @@ static int rx_get_frame(MGSLPC_INFO *info)
                                return_frame = 1;
                }
                framesize = 0;
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                {
                        struct net_device_stats *stats = hdlc_stats(info->netdev);
                        stats->rx_errors++;
@@ -3935,7 +3937,7 @@ static int rx_get_frame(MGSLPC_INFO *info)
                                ++framesize;
                        }
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                        if (info->netcount)
                                hdlcdev_rx(info, buf->data, framesize);
                        else
@@ -4091,7 +4093,7 @@ static void tx_timeout(unsigned long context)
 
        spin_unlock_irqrestore(&info->lock,flags);
        
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        if (info->netcount)
                hdlcdev_tx_done(info);
        else
@@ -4099,7 +4101,7 @@ static void tx_timeout(unsigned long context)
                bh_transmit(info);
 }
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
 
 /**
  * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.)
index c1e3dd837fc84fdef05d7eb987935fdfe79b4d78..4abd1eff61d667c79297e59235437405b3f6b451 100644 (file)
@@ -106,7 +106,7 @@ static inline void pp_enable_irq (struct pp_struct *pp)
 static ssize_t pp_read (struct file * file, char __user * buf, size_t count,
                        loff_t * ppos)
 {
-       unsigned int minor = iminor(file->f_dentry->d_inode);
+       unsigned int minor = iminor(file->f_path.dentry->d_inode);
        struct pp_struct *pp = file->private_data;
        char * kbuffer;
        ssize_t bytes_read = 0;
@@ -189,7 +189,7 @@ static ssize_t pp_read (struct file * file, char __user * buf, size_t count,
 static ssize_t pp_write (struct file * file, const char __user * buf,
                         size_t count, loff_t * ppos)
 {
-       unsigned int minor = iminor(file->f_dentry->d_inode);
+       unsigned int minor = iminor(file->f_path.dentry->d_inode);
        struct pp_struct *pp = file->private_data;
        char * kbuffer;
        ssize_t bytes_written = 0;
index 80d3eedd7f96f32997a69fa24f2134b38c8d1f1f..c07a1b5cd05d3f31204fab9eb7810e9704d96e08 100644 (file)
@@ -218,7 +218,7 @@ out:
        return retval;
 }
 
-static void pty_set_termios(struct tty_struct *tty, struct termios *old_termios)
+static void pty_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
         tty->termios->c_cflag &= ~(CSIZE | PARENB);
         tty->termios->c_cflag |= (CS8 | CREAD);
@@ -272,6 +272,8 @@ static void __init legacy_pty_init(void)
        pty_driver->init_termios.c_oflag = 0;
        pty_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
        pty_driver->init_termios.c_lflag = 0;
+       pty_driver->init_termios.c_ispeed = 38400;
+       pty_driver->init_termios.c_ospeed = 38400;
        pty_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW;
        pty_driver->other = pty_slave_driver;
        tty_set_operations(pty_driver, &pty_ops);
@@ -286,6 +288,8 @@ static void __init legacy_pty_init(void)
        pty_slave_driver->subtype = PTY_TYPE_SLAVE;
        pty_slave_driver->init_termios = tty_std_termios;
        pty_slave_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
+       pty_slave_driver->init_termios.c_ispeed = 38400;
+       pty_slave_driver->init_termios.c_ospeed = 38400;
        pty_slave_driver->flags = TTY_DRIVER_RESET_TERMIOS |
                                        TTY_DRIVER_REAL_RAW;
        pty_slave_driver->other = pty_driver;
@@ -366,6 +370,8 @@ static void __init unix98_pty_init(void)
        ptm_driver->init_termios.c_oflag = 0;
        ptm_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
        ptm_driver->init_termios.c_lflag = 0;
+       ptm_driver->init_termios.c_ispeed = 38400;
+       ptm_driver->init_termios.c_ospeed = 38400;
        ptm_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW |
                TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_DEVPTS_MEM;
        ptm_driver->other = pts_driver;
@@ -381,6 +387,8 @@ static void __init unix98_pty_init(void)
        pts_driver->subtype = PTY_TYPE_SLAVE;
        pts_driver->init_termios = tty_std_termios;
        pts_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
+       pts_driver->init_termios.c_ispeed = 38400;
+       pts_driver->init_termios.c_ospeed = 38400;
        pts_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW |
                TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_DEVPTS_MEM;
        pts_driver->other = ptm_driver;
index 4c6782a1ecdba4f5682ecfed4b8ffa45f7e40ec2..092a01cc02dae273cbce4b794b5a3834b60cbebe 100644 (file)
@@ -1048,7 +1048,7 @@ random_write(struct file * file, const char __user * buffer,
        if (p == buffer) {
                return (ssize_t)ret;
        } else {
-               struct inode *inode = file->f_dentry->d_inode;
+               struct inode *inode = file->f_path.dentry->d_inode;
                inode->i_mtime = current_fs_time(inode->i_sb);
                mark_inode_dirty(inode);
                return (ssize_t)(p - buffer);
index 3b32313f6eb46e7b05911ef48ef6aa48c1e0dfba..645e20a06ece382149b0f0eff59812aeed1d6a59 100644 (file)
@@ -75,7 +75,7 @@ static int raw_open(struct inode *inode, struct file *filp)
        filp->f_flags |= O_DIRECT;
        filp->f_mapping = bdev->bd_inode->i_mapping;
        if (++raw_devices[minor].inuse == 1)
-               filp->f_dentry->d_inode->i_mapping =
+               filp->f_path.dentry->d_inode->i_mapping =
                        bdev->bd_inode->i_mapping;
        filp->private_data = bdev;
        mutex_unlock(&raw_mutex);
index 7ac68cb3beddfa61df80e8ca0cfb22a3b53cf70b..e79b2ede8510c6cecbffffa1c0ba72f2823de580 100644 (file)
@@ -1026,6 +1026,7 @@ static int __init rio_init(void)
                        found++;
                } else {
                        iounmap(p->RIOHosts[p->RIONumHosts].Caddr);
+                       p->RIOHosts[p->RIONumHosts].Caddr = NULL;
                }
        }
 
@@ -1078,6 +1079,7 @@ static int __init rio_init(void)
                        found++;
                } else {
                        iounmap(p->RIOHosts[p->RIONumHosts].Caddr);
+                       p->RIOHosts[p->RIONumHosts].Caddr = NULL;
                }
 #else
                printk(KERN_ERR "Found an older RIO PCI card, but the driver is not " "compiled to support it.\n");
@@ -1117,8 +1119,10 @@ static int __init rio_init(void)
                                }
                        }
 
-                       if (!okboard)
+                       if (!okboard) {
                                iounmap(hp->Caddr);
+                               hp->Caddr = NULL;
+                       }
                }
        }
 
@@ -1188,6 +1192,8 @@ static void __exit rio_exit(void)
                }
                /* It is safe/allowed to del_timer a non-active timer */
                del_timer(&hp->timer);
+               if (hp->Caddr)
+                       iounmap(hp->Caddr);
                if (hp->Type == RIO_PCI)
                        pci_dev_put(hp->pdev);
        }
index 722dd3e7418594d643294e46caeafde0a93979ce..e2a94bfb2a436dd5d24e68fb8388721351a6acdb 100644 (file)
 static struct riscom_board * IRQ_to_board[16];
 static struct tty_driver *riscom_driver;
 
-static unsigned long baud_table[] =  {
-       0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
-       9600, 19200, 38400, 57600, 76800, 0, 
-};
-
 static struct riscom_board rc_board[RC_NBOARD] =  {
        {
                .base   = RC_IOBASE1,
@@ -1544,7 +1539,7 @@ static void rc_hangup(struct tty_struct * tty)
        wake_up_interruptible(&port->open_wait);
 }
 
-static void rc_set_termios(struct tty_struct * tty, struct termios * old_termios)
+static void rc_set_termios(struct tty_struct * tty, struct ktermios * old_termios)
 {
        struct riscom_port *port = (struct riscom_port *)tty->driver_data;
        unsigned long flags;
@@ -1619,6 +1614,8 @@ static inline int rc_init_drivers(void)
        riscom_driver->init_termios = tty_std_termios;
        riscom_driver->init_termios.c_cflag =
                B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+       riscom_driver->init_termios.c_ispeed = 9600;
+       riscom_driver->init_termios.c_ospeed = 9600;
        riscom_driver->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(riscom_driver, &riscom_ops);
        if ((error = tty_register_driver(riscom_driver)))  {
index bac80056f7e0c7e45893c7f7a46f9b2c196222af..e94a62e30fc4f5c01be2343a28468675ba9ca8c8 100644 (file)
@@ -712,7 +712,7 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev)
  *  user mode into the driver (exception handler).  *info CD manipulation is spinlock protected.
  */
 static void configure_r_port(struct r_port *info,
-                            struct termios *old_termios)
+                            struct ktermios *old_termios)
 {
        unsigned cflag;
        unsigned long flags;
@@ -1017,7 +1017,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
        /*
         * Info->count is now 1; so it's safe to sleep now.
         */
-       info->session = current->signal->session;
+       info->session = process_session(current);
        info->pgrp = process_group(current);
 
        if ((info->flags & ROCKET_INITIALIZED) == 0) {
@@ -1194,7 +1194,7 @@ static void rp_close(struct tty_struct *tty, struct file *filp)
 }
 
 static void rp_set_termios(struct tty_struct *tty,
-                          struct termios *old_termios)
+                          struct ktermios *old_termios)
 {
        struct r_port *info = (struct r_port *) tty->driver_data;
        CHANNEL_t *cp;
@@ -2214,7 +2214,7 @@ static int __init init_PCI(int boards_found)
        int count = 0;
 
        /*  Work through the PCI device list, pulling out ours */
-       while ((dev = pci_find_device(PCI_VENDOR_ID_RP, PCI_ANY_ID, dev))) {
+       while ((dev = pci_get_device(PCI_VENDOR_ID_RP, PCI_ANY_ID, dev))) {
                if (register_PCI(count + boards_found, dev))
                        count++;
        }
@@ -2436,6 +2436,8 @@ static int __init rp_init(void)
        rocket_driver->init_termios = tty_std_termios;
        rocket_driver->init_termios.c_cflag =
            B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+       rocket_driver->init_termios.c_ispeed = 9600;
+       rocket_driver->init_termios.c_ospeed = 9600;
 #ifdef ROCKET_SOFT_FLOW
        rocket_driver->flags |= TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
 #endif
index 4217d38caef90f83e7272b68c21a8d2202a1eb3f..75de5f66517aeb81bf3cec37db24baebaa03379a 100644 (file)
@@ -695,6 +695,8 @@ static int a2232_init_drivers(void)
        a2232_driver->init_termios = tty_std_termios;
        a2232_driver->init_termios.c_cflag =
                B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+       a2232_driver->init_termios.c_ispeed = 9600;
+       a2232_driver->init_termios.c_ospeed = 9600;
        a2232_driver->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(a2232_driver, &a2232_ops);
        if ((error = tty_register_driver(a2232_driver))) {
index 9ba13af234be4e041d323eddb5a8c58eb3ec264d..af50d32ae2c75a97fef06148de07d97c5713ef24 100644 (file)
@@ -1695,7 +1695,7 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
 
 
 static void
-cy_set_termios(struct tty_struct *tty, struct termios * old_termios)
+cy_set_termios(struct tty_struct *tty, struct ktermios * old_termios)
 {
   struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
 
index fc87070f18660b584003abd2184fc1ba6d0507f1..17d54e1331b2ea61475534e8b294cd6e2ebb7e3d 100644 (file)
@@ -979,7 +979,7 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
        }
 
        if (ret > 0) {
-               struct inode *inode = file->f_dentry->d_inode;
+               struct inode *inode = file->f_path.dentry->d_inode;
                inode->i_atime = current_fs_time(inode->i_sb);
        }
 
index 99137ab66b625f0e9e4d16dc836f6b13ac088aa2..20946f5127e0ca97b8b902fe3e22ae464722bcbf 100644 (file)
@@ -2311,7 +2311,7 @@ static void sx_hangup(struct tty_struct * tty)
 }
 
 
-static void sx_set_termios(struct tty_struct * tty, struct termios * old_termios)
+static void sx_set_termios(struct tty_struct * tty, struct ktermios * old_termios)
 {
        struct specialix_port *port = (struct specialix_port *)tty->driver_data;
        unsigned long flags;
@@ -2400,6 +2400,8 @@ static int sx_init_drivers(void)
        specialix_driver->init_termios = tty_std_termios;
        specialix_driver->init_termios.c_cflag =
                B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+       specialix_driver->init_termios.c_ispeed = 9600;
+       specialix_driver->init_termios.c_ospeed = 9600;
        specialix_driver->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(specialix_driver, &sx_ops);
 
@@ -2475,7 +2477,7 @@ static int __init specialix_init(void)
                                i++;
                                continue;
                        }
-                       pdev = pci_find_device (PCI_VENDOR_ID_SPECIALIX,
+                       pdev = pci_get_device (PCI_VENDOR_ID_SPECIALIX,
                                                PCI_DEVICE_ID_SPECIALIX_IO8,
                                                pdev);
                        if (!pdev) break;
@@ -2491,6 +2493,9 @@ static int __init specialix_init(void)
                        if (!sx_probe(&sx_board[i]))
                                found ++;
                }
+               /* May exit pci_get sequence early with lots of boards */
+               if (pdev != NULL)
+                       pci_dev_put(pdev);
        }
 #endif
 
index 5e2de62bce706dd7b4f7843e5f608c98f1cb96a3..e45113a7a472f7f1035d3fd92b2909b237bd298b 100644 (file)
 #include <linux/smp_lock.h>
 #include <linux/device.h>
 #include <linux/delay.h>
+#include <linux/ctype.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
 
-#ifdef CONFIG_PCI
 #include <linux/pci.h>
-#endif
 
 /*****************************************************************************/
 
 #define        BRD_ECH64PCI    27
 #define        BRD_EASYIOPCI   28
 
-/*
- *     Define a configuration structure to hold the board configuration.
- *     Need to set this up in the code (for now) with the boards that are
- *     to be configured into the system. This is what needs to be modified
- *     when adding/removing/modifying boards. Each line entry in the
- *     stl_brdconf[] array is a board. Each line contains io/irq/memory
- *     ranges for that board (as well as what type of board it is).
- *     Some examples:
- *             { BRD_EASYIO, 0x2a0, 0, 0, 10, 0 },
- *     This line would configure an EasyIO board (4 or 8, no difference),
- *     at io address 2a0 and irq 10.
- *     Another example:
- *             { BRD_ECH, 0x2a8, 0x280, 0, 12, 0 },
- *     This line will configure an EasyConnection 8/32 board at primary io
- *     address 2a8, secondary io address 280 and irq 12.
- *     Enter as many lines into this array as you want (only the first 4
- *     will actually be used!). Any combination of EasyIO and EasyConnection
- *     boards can be specified. EasyConnection 8/32 boards can share their
- *     secondary io addresses between each other.
- *
- *     NOTE: there is no need to put any entries in this table for PCI
- *     boards. They will be found automatically by the driver - provided
- *     PCI BIOS32 support is compiled into the kernel.
- */
-
-typedef struct {
-       int             brdtype;
+struct stlconf {
+       unsigned int    brdtype;
        int             ioaddr1;
        int             ioaddr2;
        unsigned long   memaddr;
        int             irq;
        int             irqtype;
-} stlconf_t;
-
-static stlconf_t       stl_brdconf[] = {
-       /*{ BRD_EASYIO, 0x2a0, 0, 0, 10, 0 },*/
 };
 
-static int     stl_nrbrds = ARRAY_SIZE(stl_brdconf);
+static unsigned int stl_nrbrds;
 
 /*****************************************************************************/
 
@@ -143,20 +113,13 @@ static struct tty_driver  *stl_serial;
  *     with this termios initially. Basically all it defines is a raw port
  *     at 9600, 8 data bits, 1 stop bit.
  */
-static struct termios          stl_deftermios = {
+static struct ktermios         stl_deftermios = {
        .c_cflag        = (B9600 | CS8 | CREAD | HUPCL | CLOCAL),
        .c_cc           = INIT_C_CC,
+       .c_ispeed       = 9600,
+       .c_ospeed       = 9600,
 };
 
-/*
- *     Define global stats structures. Not used often, and can be
- *     re-used for each stats call.
- */
-static comstats_t      stl_comstats;
-static combrd_t                stl_brdstats;
-static stlbrd_t                stl_dummybrd;
-static stlport_t       stl_dummyport;
-
 /*
  *     Define global place to put buffer overflow characters.
  */
@@ -164,13 +127,16 @@ static char               stl_unwanted[SC26198_RXFIFOSIZE];
 
 /*****************************************************************************/
 
-static stlbrd_t                *stl_brds[STL_MAXBRDS];
+static DEFINE_MUTEX(stl_brdslock);
+static struct stlbrd           *stl_brds[STL_MAXBRDS];
 
 /*
  *     Per board state flags. Used with the state field of the board struct.
  *     Not really much here!
  */
 #define        BRD_FOUND       0x1
+#define STL_PROBED     0x2
+
 
 /*
  *     Define the port structure istate flags. These set of flags are
@@ -187,32 +153,32 @@ static stlbrd_t           *stl_brds[STL_MAXBRDS];
  *     referencing boards when printing trace and stuff.
  */
 static char    *stl_brdnames[] = {
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
        "EasyIO",
        "EC8/32-AT",
        "EC8/32-MC",
-       (char *) NULL,
-       (char *) NULL,
-       (char *) NULL,
+       NULL,
+       NULL,
+       NULL,
        "EC8/32-PCI",
        "EC8/64-PCI",
        "EasyIO-PCI",
@@ -225,7 +191,7 @@ static char *stl_brdnames[] = {
  *     load line. These allow for easy board definitions, and easy
  *     modification of the io, memory and irq resoucres.
  */
-static int     stl_nargs = 0;
+static unsigned int stl_nargs;
 static char    *board0[4];
 static char    *board1[4];
 static char    *board2[4];
@@ -243,12 +209,10 @@ static char       **stl_brdsp[] = {
  *     parse any module arguments.
  */
 
-typedef struct stlbrdtype {
+static struct {
        char    *name;
        int     type;
-} stlbrdtype_t;
-
-static stlbrdtype_t    stl_brdstr[] = {
+} stl_brdstr[] = {
        { "easyio", BRD_EASYIO },
        { "eio", BRD_EASYIO },
        { "20", BRD_EASYIO },
@@ -282,9 +246,6 @@ static stlbrdtype_t stl_brdstr[] = {
 /*
  *     Define the module agruments.
  */
-MODULE_AUTHOR("Greg Ungerer");
-MODULE_DESCRIPTION("Stallion Multiport Serial Driver");
-MODULE_LICENSE("GPL");
 
 module_param_array(board0, charp, &stl_nargs, 0);
 MODULE_PARM_DESC(board0, "Board 0 config -> name[,ioaddr[,ioaddr2][,irq]]");
@@ -386,8 +347,6 @@ static spinlock_t stallion_lock;    /* Guard the tty driver */
 
 /*****************************************************************************/
 
-#ifdef CONFIG_PCI
-
 /*
  *     Define the Stallion PCI vendor and device IDs.
  */
@@ -407,22 +366,19 @@ static spinlock_t stallion_lock;  /* Guard the tty driver */
 /*
  *     Define structure to hold all Stallion PCI boards.
  */
-typedef struct stlpcibrd {
-       unsigned short          vendid;
-       unsigned short          devid;
-       int                     brdtype;
-} stlpcibrd_t;
-
-static stlpcibrd_t     stl_pcibrds[] = {
-       { PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECHPCI864, BRD_ECH64PCI },
-       { PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_EIOPCI, BRD_EASYIOPCI },
-       { PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECHPCI832, BRD_ECHPCI },
-       { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87410, BRD_ECHPCI },
-};
 
-static int     stl_nrpcibrds = ARRAY_SIZE(stl_pcibrds);
-
-#endif
+static struct pci_device_id stl_pcibrds[] = {
+       { PCI_DEVICE(PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECHPCI864),
+               .driver_data = BRD_ECH64PCI },
+       { PCI_DEVICE(PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_EIOPCI),
+               .driver_data = BRD_EASYIOPCI },
+       { PCI_DEVICE(PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECHPCI832),
+               .driver_data = BRD_ECHPCI },
+       { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87410),
+               .driver_data = BRD_ECHPCI },
+       { }
+};
+MODULE_DEVICE_TABLE(pci, stl_pcibrds);
 
 /*****************************************************************************/
 
@@ -442,134 +398,74 @@ static unsigned int      stl_baudrates[] = {
        9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600
 };
 
-/*
- *     Define some handy local macros...
- */
-#undef MIN
-#define        MIN(a,b)        (((a) <= (b)) ? (a) : (b))
-
-#undef TOLOWER
-#define        TOLOWER(x)      ((((x) >= 'A') && ((x) <= 'Z')) ? ((x) + 0x20) : (x))
-
 /*****************************************************************************/
 
 /*
  *     Declare all those functions in this driver!
  */
 
-static void    stl_argbrds(void);
-static int     stl_parsebrd(stlconf_t *confp, char **argp);
-
-static unsigned long stl_atol(char *str);
-
-static int     stl_init(void);
-static int     stl_open(struct tty_struct *tty, struct file *filp);
-static void    stl_close(struct tty_struct *tty, struct file *filp);
-static int     stl_write(struct tty_struct *tty, const unsigned char *buf, int count);
-static void    stl_putchar(struct tty_struct *tty, unsigned char ch);
-static void    stl_flushchars(struct tty_struct *tty);
-static int     stl_writeroom(struct tty_struct *tty);
-static int     stl_charsinbuffer(struct tty_struct *tty);
-static int     stl_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg);
-static void    stl_settermios(struct tty_struct *tty, struct termios *old);
-static void    stl_throttle(struct tty_struct *tty);
-static void    stl_unthrottle(struct tty_struct *tty);
-static void    stl_stop(struct tty_struct *tty);
-static void    stl_start(struct tty_struct *tty);
-static void    stl_flushbuffer(struct tty_struct *tty);
-static void    stl_breakctl(struct tty_struct *tty, int state);
-static void    stl_waituntilsent(struct tty_struct *tty, int timeout);
-static void    stl_sendxchar(struct tty_struct *tty, char ch);
-static void    stl_hangup(struct tty_struct *tty);
 static int     stl_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg);
-static int     stl_portinfo(stlport_t *portp, int portnr, char *pos);
-static int     stl_readproc(char *page, char **start, off_t off, int count, int *eof, void *data);
-
-static int     stl_brdinit(stlbrd_t *brdp);
-static int     stl_initports(stlbrd_t *brdp, stlpanel_t *panelp);
-static int     stl_getserial(stlport_t *portp, struct serial_struct __user *sp);
-static int     stl_setserial(stlport_t *portp, struct serial_struct __user *sp);
-static int     stl_getbrdstats(combrd_t __user *bp);
-static int     stl_getportstats(stlport_t *portp, comstats_t __user *cp);
-static int     stl_clrportstats(stlport_t *portp, comstats_t __user *cp);
-static int     stl_getportstruct(stlport_t __user *arg);
-static int     stl_getbrdstruct(stlbrd_t __user *arg);
-static int     stl_waitcarrier(stlport_t *portp, struct file *filp);
-static int     stl_eiointr(stlbrd_t *brdp);
-static int     stl_echatintr(stlbrd_t *brdp);
-static int     stl_echmcaintr(stlbrd_t *brdp);
-static int     stl_echpciintr(stlbrd_t *brdp);
-static int     stl_echpci64intr(stlbrd_t *brdp);
-static void    stl_offintr(struct work_struct *);
-static stlbrd_t *stl_allocbrd(void);
-static stlport_t *stl_getport(int brdnr, int panelnr, int portnr);
-
-static inline int      stl_initbrds(void);
-static inline int      stl_initeio(stlbrd_t *brdp);
-static inline int      stl_initech(stlbrd_t *brdp);
-static inline int      stl_getbrdnr(void);
-
-#ifdef CONFIG_PCI
-static inline int      stl_findpcibrds(void);
-static inline int      stl_initpcibrd(int brdtype, struct pci_dev *devp);
-#endif
+static int     stl_brdinit(struct stlbrd *brdp);
+static int     stl_getportstats(struct stlport *portp, comstats_t __user *cp);
+static int     stl_clrportstats(struct stlport *portp, comstats_t __user *cp);
+static int     stl_waitcarrier(struct stlport *portp, struct file *filp);
 
 /*
  *     CD1400 uart specific handling functions.
  */
-static void    stl_cd1400setreg(stlport_t *portp, int regnr, int value);
-static int     stl_cd1400getreg(stlport_t *portp, int regnr);
-static int     stl_cd1400updatereg(stlport_t *portp, int regnr, int value);
-static int     stl_cd1400panelinit(stlbrd_t *brdp, stlpanel_t *panelp);
-static void    stl_cd1400portinit(stlbrd_t *brdp, stlpanel_t *panelp, stlport_t *portp);
-static void    stl_cd1400setport(stlport_t *portp, struct termios *tiosp);
-static int     stl_cd1400getsignals(stlport_t *portp);
-static void    stl_cd1400setsignals(stlport_t *portp, int dtr, int rts);
-static void    stl_cd1400ccrwait(stlport_t *portp);
-static void    stl_cd1400enablerxtx(stlport_t *portp, int rx, int tx);
-static void    stl_cd1400startrxtx(stlport_t *portp, int rx, int tx);
-static void    stl_cd1400disableintrs(stlport_t *portp);
-static void    stl_cd1400sendbreak(stlport_t *portp, int len);
-static void    stl_cd1400flowctrl(stlport_t *portp, int state);
-static void    stl_cd1400sendflow(stlport_t *portp, int state);
-static void    stl_cd1400flush(stlport_t *portp);
-static int     stl_cd1400datastate(stlport_t *portp);
-static void    stl_cd1400eiointr(stlpanel_t *panelp, unsigned int iobase);
-static void    stl_cd1400echintr(stlpanel_t *panelp, unsigned int iobase);
-static void    stl_cd1400txisr(stlpanel_t *panelp, int ioaddr);
-static void    stl_cd1400rxisr(stlpanel_t *panelp, int ioaddr);
-static void    stl_cd1400mdmisr(stlpanel_t *panelp, int ioaddr);
-
-static inline int      stl_cd1400breakisr(stlport_t *portp, int ioaddr);
+static void    stl_cd1400setreg(struct stlport *portp, int regnr, int value);
+static int     stl_cd1400getreg(struct stlport *portp, int regnr);
+static int     stl_cd1400updatereg(struct stlport *portp, int regnr, int value);
+static int     stl_cd1400panelinit(struct stlbrd *brdp, struct stlpanel *panelp);
+static void    stl_cd1400portinit(struct stlbrd *brdp, struct stlpanel *panelp, struct stlport *portp);
+static void    stl_cd1400setport(struct stlport *portp, struct ktermios *tiosp);
+static int     stl_cd1400getsignals(struct stlport *portp);
+static void    stl_cd1400setsignals(struct stlport *portp, int dtr, int rts);
+static void    stl_cd1400ccrwait(struct stlport *portp);
+static void    stl_cd1400enablerxtx(struct stlport *portp, int rx, int tx);
+static void    stl_cd1400startrxtx(struct stlport *portp, int rx, int tx);
+static void    stl_cd1400disableintrs(struct stlport *portp);
+static void    stl_cd1400sendbreak(struct stlport *portp, int len);
+static void    stl_cd1400flowctrl(struct stlport *portp, int state);
+static void    stl_cd1400sendflow(struct stlport *portp, int state);
+static void    stl_cd1400flush(struct stlport *portp);
+static int     stl_cd1400datastate(struct stlport *portp);
+static void    stl_cd1400eiointr(struct stlpanel *panelp, unsigned int iobase);
+static void    stl_cd1400echintr(struct stlpanel *panelp, unsigned int iobase);
+static void    stl_cd1400txisr(struct stlpanel *panelp, int ioaddr);
+static void    stl_cd1400rxisr(struct stlpanel *panelp, int ioaddr);
+static void    stl_cd1400mdmisr(struct stlpanel *panelp, int ioaddr);
+
+static inline int      stl_cd1400breakisr(struct stlport *portp, int ioaddr);
 
 /*
  *     SC26198 uart specific handling functions.
  */
-static void    stl_sc26198setreg(stlport_t *portp, int regnr, int value);
-static int     stl_sc26198getreg(stlport_t *portp, int regnr);
-static int     stl_sc26198updatereg(stlport_t *portp, int regnr, int value);
-static int     stl_sc26198getglobreg(stlport_t *portp, int regnr);
-static int     stl_sc26198panelinit(stlbrd_t *brdp, stlpanel_t *panelp);
-static void    stl_sc26198portinit(stlbrd_t *brdp, stlpanel_t *panelp, stlport_t *portp);
-static void    stl_sc26198setport(stlport_t *portp, struct termios *tiosp);
-static int     stl_sc26198getsignals(stlport_t *portp);
-static void    stl_sc26198setsignals(stlport_t *portp, int dtr, int rts);
-static void    stl_sc26198enablerxtx(stlport_t *portp, int rx, int tx);
-static void    stl_sc26198startrxtx(stlport_t *portp, int rx, int tx);
-static void    stl_sc26198disableintrs(stlport_t *portp);
-static void    stl_sc26198sendbreak(stlport_t *portp, int len);
-static void    stl_sc26198flowctrl(stlport_t *portp, int state);
-static void    stl_sc26198sendflow(stlport_t *portp, int state);
-static void    stl_sc26198flush(stlport_t *portp);
-static int     stl_sc26198datastate(stlport_t *portp);
-static void    stl_sc26198wait(stlport_t *portp);
-static void    stl_sc26198txunflow(stlport_t *portp, struct tty_struct *tty);
-static void    stl_sc26198intr(stlpanel_t *panelp, unsigned int iobase);
-static void    stl_sc26198txisr(stlport_t *port);
-static void    stl_sc26198rxisr(stlport_t *port, unsigned int iack);
-static void    stl_sc26198rxbadch(stlport_t *portp, unsigned char status, char ch);
-static void    stl_sc26198rxbadchars(stlport_t *portp);
-static void    stl_sc26198otherisr(stlport_t *port, unsigned int iack);
+static void    stl_sc26198setreg(struct stlport *portp, int regnr, int value);
+static int     stl_sc26198getreg(struct stlport *portp, int regnr);
+static int     stl_sc26198updatereg(struct stlport *portp, int regnr, int value);
+static int     stl_sc26198getglobreg(struct stlport *portp, int regnr);
+static int     stl_sc26198panelinit(struct stlbrd *brdp, struct stlpanel *panelp);
+static void    stl_sc26198portinit(struct stlbrd *brdp, struct stlpanel *panelp, struct stlport *portp);
+static void    stl_sc26198setport(struct stlport *portp, struct ktermios *tiosp);
+static int     stl_sc26198getsignals(struct stlport *portp);
+static void    stl_sc26198setsignals(struct stlport *portp, int dtr, int rts);
+static void    stl_sc26198enablerxtx(struct stlport *portp, int rx, int tx);
+static void    stl_sc26198startrxtx(struct stlport *portp, int rx, int tx);
+static void    stl_sc26198disableintrs(struct stlport *portp);
+static void    stl_sc26198sendbreak(struct stlport *portp, int len);
+static void    stl_sc26198flowctrl(struct stlport *portp, int state);
+static void    stl_sc26198sendflow(struct stlport *portp, int state);
+static void    stl_sc26198flush(struct stlport *portp);
+static int     stl_sc26198datastate(struct stlport *portp);
+static void    stl_sc26198wait(struct stlport *portp);
+static void    stl_sc26198txunflow(struct stlport *portp, struct tty_struct *tty);
+static void    stl_sc26198intr(struct stlpanel *panelp, unsigned int iobase);
+static void    stl_sc26198txisr(struct stlport *port);
+static void    stl_sc26198rxisr(struct stlport *port, unsigned int iack);
+static void    stl_sc26198rxbadch(struct stlport *portp, unsigned char status, char ch);
+static void    stl_sc26198rxbadchars(struct stlport *portp);
+static void    stl_sc26198otherisr(struct stlport *port, unsigned int iack);
 
 /*****************************************************************************/
 
@@ -577,20 +473,20 @@ static void       stl_sc26198otherisr(stlport_t *port, unsigned int iack);
  *     Generic UART support structure.
  */
 typedef struct uart {
-       int     (*panelinit)(stlbrd_t *brdp, stlpanel_t *panelp);
-       void    (*portinit)(stlbrd_t *brdp, stlpanel_t *panelp, stlport_t *portp);
-       void    (*setport)(stlport_t *portp, struct termios *tiosp);
-       int     (*getsignals)(stlport_t *portp);
-       void    (*setsignals)(stlport_t *portp, int dtr, int rts);
-       void    (*enablerxtx)(stlport_t *portp, int rx, int tx);
-       void    (*startrxtx)(stlport_t *portp, int rx, int tx);
-       void    (*disableintrs)(stlport_t *portp);
-       void    (*sendbreak)(stlport_t *portp, int len);
-       void    (*flowctrl)(stlport_t *portp, int state);
-       void    (*sendflow)(stlport_t *portp, int state);
-       void    (*flush)(stlport_t *portp);
-       int     (*datastate)(stlport_t *portp);
-       void    (*intr)(stlpanel_t *panelp, unsigned int iobase);
+       int     (*panelinit)(struct stlbrd *brdp, struct stlpanel *panelp);
+       void    (*portinit)(struct stlbrd *brdp, struct stlpanel *panelp, struct stlport *portp);
+       void    (*setport)(struct stlport *portp, struct ktermios *tiosp);
+       int     (*getsignals)(struct stlport *portp);
+       void    (*setsignals)(struct stlport *portp, int dtr, int rts);
+       void    (*enablerxtx)(struct stlport *portp, int rx, int tx);
+       void    (*startrxtx)(struct stlport *portp, int rx, int tx);
+       void    (*disableintrs)(struct stlport *portp);
+       void    (*sendbreak)(struct stlport *portp, int len);
+       void    (*flowctrl)(struct stlport *portp, int state);
+       void    (*sendflow)(struct stlport *portp, int state);
+       void    (*flush)(struct stlport *portp);
+       int     (*datastate)(struct stlport *portp);
+       void    (*intr)(struct stlpanel *panelp, unsigned int iobase);
 } uart_t;
 
 /*
@@ -712,184 +608,35 @@ static const struct file_operations      stl_fsiomem = {
        .ioctl          = stl_memioctl,
 };
 
-/*****************************************************************************/
-
 static struct class *stallion_class;
 
-/*
- *     Loadable module initialization stuff.
- */
-
-static int __init stallion_module_init(void)
-{
-       stl_init();
-       return 0;
-}
-
-/*****************************************************************************/
-
-static void __exit stallion_module_exit(void)
-{
-       stlbrd_t        *brdp;
-       stlpanel_t      *panelp;
-       stlport_t       *portp;
-       int             i, j, k;
-
-#ifdef DEBUG
-       printk("cleanup_module()\n");
-#endif
-
-       printk(KERN_INFO "Unloading %s: version %s\n", stl_drvtitle,
-               stl_drvversion);
-
-/*
- *     Free up all allocated resources used by the ports. This includes
- *     memory and interrupts. As part of this process we will also do
- *     a hangup on every open port - to try to flush out any processes
- *     hanging onto ports.
- */
-       i = tty_unregister_driver(stl_serial);
-       put_tty_driver(stl_serial);
-       if (i) {
-               printk("STALLION: failed to un-register tty driver, "
-                       "errno=%d\n", -i);
-               return;
-       }
-       for (i = 0; i < 4; i++)
-               class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i));
-       if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem")))
-               printk("STALLION: failed to un-register serial memory device, "
-                       "errno=%d\n", -i);
-       class_destroy(stallion_class);
-
-       for (i = 0; (i < stl_nrbrds); i++) {
-               if ((brdp = stl_brds[i]) == (stlbrd_t *) NULL)
-                       continue;
-
-               free_irq(brdp->irq, brdp);
-
-               for (j = 0; (j < STL_MAXPANELS); j++) {
-                       panelp = brdp->panels[j];
-                       if (panelp == (stlpanel_t *) NULL)
-                               continue;
-                       for (k = 0; (k < STL_PORTSPERPANEL); k++) {
-                               portp = panelp->ports[k];
-                               if (portp == (stlport_t *) NULL)
-                                       continue;
-                               if (portp->tty != (struct tty_struct *) NULL)
-                                       stl_hangup(portp->tty);
-                               kfree(portp->tx.buf);
-                               kfree(portp);
-                       }
-                       kfree(panelp);
-               }
-
-               release_region(brdp->ioaddr1, brdp->iosize1);
-               if (brdp->iosize2 > 0)
-                       release_region(brdp->ioaddr2, brdp->iosize2);
-
-               kfree(brdp);
-               stl_brds[i] = (stlbrd_t *) NULL;
-       }
-}
-
-module_init(stallion_module_init);
-module_exit(stallion_module_exit);
-
-/*****************************************************************************/
-
 /*
  *     Check for any arguments passed in on the module load command line.
  */
 
-static void stl_argbrds(void)
-{
-       stlconf_t       conf;
-       stlbrd_t        *brdp;
-       int             i;
-
-#ifdef DEBUG
-       printk("stl_argbrds()\n");
-#endif
-
-       for (i = stl_nrbrds; (i < stl_nargs); i++) {
-               memset(&conf, 0, sizeof(conf));
-               if (stl_parsebrd(&conf, stl_brdsp[i]) == 0)
-                       continue;
-               if ((brdp = stl_allocbrd()) == (stlbrd_t *) NULL)
-                       continue;
-               stl_nrbrds = i + 1;
-               brdp->brdnr = i;
-               brdp->brdtype = conf.brdtype;
-               brdp->ioaddr1 = conf.ioaddr1;
-               brdp->ioaddr2 = conf.ioaddr2;
-               brdp->irq = conf.irq;
-               brdp->irqtype = conf.irqtype;
-               stl_brdinit(brdp);
-       }
-}
-
-/*****************************************************************************/
-
-/*
- *     Convert an ascii string number into an unsigned long.
- */
-
-static unsigned long stl_atol(char *str)
-{
-       unsigned long   val;
-       int             base, c;
-       char            *sp;
-
-       val = 0;
-       sp = str;
-       if ((*sp == '0') && (*(sp+1) == 'x')) {
-               base = 16;
-               sp += 2;
-       } else if (*sp == '0') {
-               base = 8;
-               sp++;
-       } else {
-               base = 10;
-       }
-
-       for (; (*sp != 0); sp++) {
-               c = (*sp > '9') ? (TOLOWER(*sp) - 'a' + 10) : (*sp - '0');
-               if ((c < 0) || (c >= base)) {
-                       printk("STALLION: invalid argument %s\n", str);
-                       val = 0;
-                       break;
-               }
-               val = (val * base) + c;
-       }
-       return val;
-}
-
 /*****************************************************************************/
 
 /*
  *     Parse the supplied argument string, into the board conf struct.
  */
 
-static int stl_parsebrd(stlconf_t *confp, char **argp)
+static int __init stl_parsebrd(struct stlconf *confp, char **argp)
 {
        char    *sp;
-       int     i;
+       unsigned int i;
 
-#ifdef DEBUG
-       printk("stl_parsebrd(confp=%x,argp=%x)\n", (int) confp, (int) argp);
-#endif
+       pr_debug("stl_parsebrd(confp=%p,argp=%p)\n", confp, argp);
 
-       if ((argp[0] == (char *) NULL) || (*argp[0] == 0))
+       if ((argp[0] == NULL) || (*argp[0] == 0))
                return 0;
 
-       for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++)
-               *sp = TOLOWER(*sp);
+       for (sp = argp[0], i = 0; (*sp != 0) && (i < 25); sp++, i++)
+               *sp = tolower(*sp);
 
-       for (i = 0; i < ARRAY_SIZE(stl_brdstr); i++) {
+       for (i = 0; i < ARRAY_SIZE(stl_brdstr); i++)
                if (strcmp(stl_brdstr[i].name, argp[0]) == 0)
                        break;
-       }
+
        if (i == ARRAY_SIZE(stl_brdstr)) {
                printk("STALLION: unknown board name, %s?\n", argp[0]);
                return 0;
@@ -898,16 +645,16 @@ static int stl_parsebrd(stlconf_t *confp, char **argp)
        confp->brdtype = stl_brdstr[i].type;
 
        i = 1;
-       if ((argp[i] != (char *) NULL) && (*argp[i] != 0))
-               confp->ioaddr1 = stl_atol(argp[i]);
+       if ((argp[i] != NULL) && (*argp[i] != 0))
+               confp->ioaddr1 = simple_strtoul(argp[i], NULL, 0);
        i++;
        if (confp->brdtype == BRD_ECH) {
-               if ((argp[i] != (char *) NULL) && (*argp[i] != 0))
-                       confp->ioaddr2 = stl_atol(argp[i]);
+               if ((argp[i] != NULL) && (*argp[i] != 0))
+                       confp->ioaddr2 = simple_strtoul(argp[i], NULL, 0);
                i++;
        }
-       if ((argp[i] != (char *) NULL) && (*argp[i] != 0))
-               confp->irq = stl_atol(argp[i]);
+       if ((argp[i] != NULL) && (*argp[i] != 0))
+               confp->irq = simple_strtoul(argp[i], NULL, 0);
        return 1;
 }
 
@@ -917,14 +664,14 @@ static int stl_parsebrd(stlconf_t *confp, char **argp)
  *     Allocate a new board structure. Fill out the basic info in it.
  */
 
-static stlbrd_t *stl_allocbrd(void)
+static struct stlbrd *stl_allocbrd(void)
 {
-       stlbrd_t        *brdp;
+       struct stlbrd   *brdp;
 
-       brdp = kzalloc(sizeof(stlbrd_t), GFP_KERNEL);
+       brdp = kzalloc(sizeof(struct stlbrd), GFP_KERNEL);
        if (!brdp) {
                printk("STALLION: failed to allocate memory (size=%Zd)\n",
-                       sizeof(stlbrd_t));
+                       sizeof(struct stlbrd));
                return NULL;
        }
 
@@ -936,26 +683,23 @@ static stlbrd_t *stl_allocbrd(void)
 
 static int stl_open(struct tty_struct *tty, struct file *filp)
 {
-       stlport_t       *portp;
-       stlbrd_t        *brdp;
-       unsigned int    minordev;
-       int             brdnr, panelnr, portnr, rc;
-
-#ifdef DEBUG
-       printk("stl_open(tty=%x,filp=%x): device=%s\n", (int) tty,
-               (int) filp, tty->name);
-#endif
+       struct stlport  *portp;
+       struct stlbrd   *brdp;
+       unsigned int    minordev, brdnr, panelnr;
+       int             portnr, rc;
+
+       pr_debug("stl_open(tty=%p,filp=%p): device=%s\n", tty, filp, tty->name);
 
        minordev = tty->index;
        brdnr = MINOR2BRD(minordev);
        if (brdnr >= stl_nrbrds)
                return -ENODEV;
        brdp = stl_brds[brdnr];
-       if (brdp == (stlbrd_t *) NULL)
+       if (brdp == NULL)
                return -ENODEV;
        minordev = MINOR2PORT(minordev);
-       for (portnr = -1, panelnr = 0; (panelnr < STL_MAXPANELS); panelnr++) {
-               if (brdp->panels[panelnr] == (stlpanel_t *) NULL)
+       for (portnr = -1, panelnr = 0; panelnr < STL_MAXPANELS; panelnr++) {
+               if (brdp->panels[panelnr] == NULL)
                        break;
                if (minordev < brdp->panels[panelnr]->nrports) {
                        portnr = minordev;
@@ -967,7 +711,7 @@ static int stl_open(struct tty_struct *tty, struct file *filp)
                return -ENODEV;
 
        portp = brdp->panels[panelnr]->ports[portnr];
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return -ENODEV;
 
 /*
@@ -1013,10 +757,10 @@ static int stl_open(struct tty_struct *tty, struct file *filp)
  *     previous opens still in effect. If we are a normal serial device
  *     then also we might have to wait for carrier.
  */
-       if (!(filp->f_flags & O_NONBLOCK)) {
+       if (!(filp->f_flags & O_NONBLOCK))
                if ((rc = stl_waitcarrier(portp, filp)) != 0)
                        return rc;
-       }
+
        portp->flags |= ASYNC_NORMAL_ACTIVE;
 
        return 0;
@@ -1029,14 +773,12 @@ static int stl_open(struct tty_struct *tty, struct file *filp)
  *     maybe because if we are clocal then we don't need to wait...
  */
 
-static int stl_waitcarrier(stlport_t *portp, struct file *filp)
+static int stl_waitcarrier(struct stlport *portp, struct file *filp)
 {
        unsigned long   flags;
        int             rc, doclocal;
 
-#ifdef DEBUG
-       printk("stl_waitcarrier(portp=%x,filp=%x)\n", (int) portp, (int) filp);
-#endif
+       pr_debug("stl_waitcarrier(portp=%p,filp=%p)\n", portp, filp);
 
        rc = 0;
        doclocal = 0;
@@ -1062,9 +804,8 @@ static int stl_waitcarrier(stlport_t *portp, struct file *filp)
                        break;
                }
                if (((portp->flags & ASYNC_CLOSING) == 0) &&
-                   (doclocal || (portp->sigs & TIOCM_CD))) {
+                   (doclocal || (portp->sigs & TIOCM_CD)))
                        break;
-               }
                if (signal_pending(current)) {
                        rc = -ERESTARTSYS;
                        break;
@@ -1083,17 +824,61 @@ static int stl_waitcarrier(stlport_t *portp, struct file *filp)
 
 /*****************************************************************************/
 
+static void stl_flushbuffer(struct tty_struct *tty)
+{
+       struct stlport  *portp;
+
+       pr_debug("stl_flushbuffer(tty=%p)\n", tty);
+
+       if (tty == NULL)
+               return;
+       portp = tty->driver_data;
+       if (portp == NULL)
+               return;
+
+       stl_flush(portp);
+       tty_wakeup(tty);
+}
+
+/*****************************************************************************/
+
+static void stl_waituntilsent(struct tty_struct *tty, int timeout)
+{
+       struct stlport  *portp;
+       unsigned long   tend;
+
+       pr_debug("stl_waituntilsent(tty=%p,timeout=%d)\n", tty, timeout);
+
+       if (tty == NULL)
+               return;
+       portp = tty->driver_data;
+       if (portp == NULL)
+               return;
+
+       if (timeout == 0)
+               timeout = HZ;
+       tend = jiffies + timeout;
+
+       while (stl_datastate(portp)) {
+               if (signal_pending(current))
+                       break;
+               msleep_interruptible(20);
+               if (time_after_eq(jiffies, tend))
+                       break;
+       }
+}
+
+/*****************************************************************************/
+
 static void stl_close(struct tty_struct *tty, struct file *filp)
 {
-       stlport_t       *portp;
+       struct stlport  *portp;
        unsigned long   flags;
 
-#ifdef DEBUG
-       printk("stl_close(tty=%x,filp=%x)\n", (int) tty, (int) filp);
-#endif
+       pr_debug("stl_close(tty=%p,filp=%p)\n", tty, filp);
 
        portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return;
 
        spin_lock_irqsave(&stallion_lock, flags);
@@ -1136,17 +921,17 @@ static void stl_close(struct tty_struct *tty, struct file *filp)
        stl_enablerxtx(portp, 0, 0);
        stl_flushbuffer(tty);
        portp->istate = 0;
-       if (portp->tx.buf != (char *) NULL) {
+       if (portp->tx.buf != NULL) {
                kfree(portp->tx.buf);
-               portp->tx.buf = (char *) NULL;
-               portp->tx.head = (char *) NULL;
-               portp->tx.tail = (char *) NULL;
+               portp->tx.buf = NULL;
+               portp->tx.head = NULL;
+               portp->tx.tail = NULL;
        }
        set_bit(TTY_IO_ERROR, &tty->flags);
        tty_ldisc_flush(tty);
 
        tty->closing = 0;
-       portp->tty = (struct tty_struct *) NULL;
+       portp->tty = NULL;
 
        if (portp->openwaitcnt) {
                if (portp->close_delay)
@@ -1167,20 +952,17 @@ static void stl_close(struct tty_struct *tty, struct file *filp)
 
 static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
-       stlport_t       *portp;
+       struct stlport  *portp;
        unsigned int    len, stlen;
        unsigned char   *chbuf;
        char            *head, *tail;
 
-#ifdef DEBUG
-       printk("stl_write(tty=%x,buf=%x,count=%d)\n",
-               (int) tty, (int) buf, count);
-#endif
+       pr_debug("stl_write(tty=%p,buf=%p,count=%d)\n", tty, buf, count);
 
        portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return 0;
-       if (portp->tx.buf == (char *) NULL)
+       if (portp->tx.buf == NULL)
                return 0;
 
 /*
@@ -1201,10 +983,10 @@ static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count
                stlen = len;
        }
 
-       len = MIN(len, count);
+       len = min(len, (unsigned int)count);
        count = 0;
        while (len > 0) {
-               stlen = MIN(len, stlen);
+               stlen = min(len, stlen);
                memcpy(head, chbuf, stlen);
                len -= stlen;
                chbuf += stlen;
@@ -1227,20 +1009,18 @@ static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count
 
 static void stl_putchar(struct tty_struct *tty, unsigned char ch)
 {
-       stlport_t       *portp;
+       struct stlport  *portp;
        unsigned int    len;
        char            *head, *tail;
 
-#ifdef DEBUG
-       printk("stl_putchar(tty=%x,ch=%x)\n", (int) tty, (int) ch);
-#endif
+       pr_debug("stl_putchar(tty=%p,ch=%x)\n", tty, ch);
 
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return;
        portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return;
-       if (portp->tx.buf == (char *) NULL)
+       if (portp->tx.buf == NULL)
                return;
 
        head = portp->tx.head;
@@ -1267,18 +1047,16 @@ static void stl_putchar(struct tty_struct *tty, unsigned char ch)
 
 static void stl_flushchars(struct tty_struct *tty)
 {
-       stlport_t       *portp;
+       struct stlport  *portp;
 
-#ifdef DEBUG
-       printk("stl_flushchars(tty=%x)\n", (int) tty);
-#endif
+       pr_debug("stl_flushchars(tty=%p)\n", tty);
 
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return;
        portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return;
-       if (portp->tx.buf == (char *) NULL)
+       if (portp->tx.buf == NULL)
                return;
 
        stl_startrxtx(portp, -1, 1);
@@ -1288,24 +1066,22 @@ static void stl_flushchars(struct tty_struct *tty)
 
 static int stl_writeroom(struct tty_struct *tty)
 {
-       stlport_t       *portp;
+       struct stlport  *portp;
        char            *head, *tail;
 
-#ifdef DEBUG
-       printk("stl_writeroom(tty=%x)\n", (int) tty);
-#endif
+       pr_debug("stl_writeroom(tty=%p)\n", tty);
 
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return 0;
        portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return 0;
-       if (portp->tx.buf == (char *) NULL)
+       if (portp->tx.buf == NULL)
                return 0;
 
        head = portp->tx.head;
        tail = portp->tx.tail;
-       return ((head >= tail) ? (STL_TXBUFSIZE - (head - tail) - 1) : (tail - head - 1));
+       return (head >= tail) ? (STL_TXBUFSIZE - (head - tail) - 1) : (tail - head - 1);
 }
 
 /*****************************************************************************/
@@ -1321,20 +1097,18 @@ static int stl_writeroom(struct tty_struct *tty)
 
 static int stl_charsinbuffer(struct tty_struct *tty)
 {
-       stlport_t       *portp;
+       struct stlport  *portp;
        unsigned int    size;
        char            *head, *tail;
 
-#ifdef DEBUG
-       printk("stl_charsinbuffer(tty=%x)\n", (int) tty);
-#endif
+       pr_debug("stl_charsinbuffer(tty=%p)\n", tty);
 
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return 0;
        portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return 0;
-       if (portp->tx.buf == (char *) NULL)
+       if (portp->tx.buf == NULL)
                return 0;
 
        head = portp->tx.head;
@@ -1351,14 +1125,12 @@ static int stl_charsinbuffer(struct tty_struct *tty)
  *     Generate the serial struct info.
  */
 
-static int stl_getserial(stlport_t *portp, struct serial_struct __user *sp)
+static int stl_getserial(struct stlport *portp, struct serial_struct __user *sp)
 {
        struct serial_struct    sio;
-       stlbrd_t                *brdp;
+       struct stlbrd           *brdp;
 
-#ifdef DEBUG
-       printk("stl_getserial(portp=%x,sp=%x)\n", (int) portp, (int) sp);
-#endif
+       pr_debug("stl_getserial(portp=%p,sp=%p)\n", portp, sp);
 
        memset(&sio, 0, sizeof(struct serial_struct));
        sio.line = portp->portnr;
@@ -1378,7 +1150,7 @@ static int stl_getserial(stlport_t *portp, struct serial_struct __user *sp)
        }
 
        brdp = stl_brds[portp->brdnr];
-       if (brdp != (stlbrd_t *) NULL)
+       if (brdp != NULL)
                sio.irq = brdp->irq;
 
        return copy_to_user(sp, &sio, sizeof(struct serial_struct)) ? -EFAULT : 0;
@@ -1392,13 +1164,11 @@ static int stl_getserial(stlport_t *portp, struct serial_struct __user *sp)
  *     just quietly ignore any requests to change irq, etc.
  */
 
-static int stl_setserial(stlport_t *portp, struct serial_struct __user *sp)
+static int stl_setserial(struct stlport *portp, struct serial_struct __user *sp)
 {
        struct serial_struct    sio;
 
-#ifdef DEBUG
-       printk("stl_setserial(portp=%x,sp=%x)\n", (int) portp, (int) sp);
-#endif
+       pr_debug("stl_setserial(portp=%p,sp=%p)\n", portp, sp);
 
        if (copy_from_user(&sio, sp, sizeof(struct serial_struct)))
                return -EFAULT;
@@ -1424,12 +1194,12 @@ static int stl_setserial(stlport_t *portp, struct serial_struct __user *sp)
 
 static int stl_tiocmget(struct tty_struct *tty, struct file *file)
 {
-       stlport_t       *portp;
+       struct stlport  *portp;
 
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return -ENODEV;
        portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return -ENODEV;
        if (tty->flags & (1 << TTY_IO_ERROR))
                return -EIO;
@@ -1440,13 +1210,13 @@ static int stl_tiocmget(struct tty_struct *tty, struct file *file)
 static int stl_tiocmset(struct tty_struct *tty, struct file *file,
                        unsigned int set, unsigned int clear)
 {
-       stlport_t       *portp;
+       struct stlport  *portp;
        int rts = -1, dtr = -1;
 
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return -ENODEV;
        portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return -ENODEV;
        if (tty->flags & (1 << TTY_IO_ERROR))
                return -EIO;
@@ -1466,27 +1236,24 @@ static int stl_tiocmset(struct tty_struct *tty, struct file *file,
 
 static int stl_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
 {
-       stlport_t       *portp;
+       struct stlport  *portp;
        unsigned int    ival;
        int             rc;
        void __user *argp = (void __user *)arg;
 
-#ifdef DEBUG
-       printk("stl_ioctl(tty=%x,file=%x,cmd=%x,arg=%x)\n",
-               (int) tty, (int) file, cmd, (int) arg);
-#endif
+       pr_debug("stl_ioctl(tty=%p,file=%p,cmd=%x,arg=%lx)\n", tty, file, cmd,
+                       arg);
 
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return -ENODEV;
        portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return -ENODEV;
 
        if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
-           (cmd != COM_GETPORTSTATS) && (cmd != COM_CLRPORTSTATS)) {
+           (cmd != COM_GETPORTSTATS) && (cmd != COM_CLRPORTSTATS))
                if (tty->flags & (1 << TTY_IO_ERROR))
                        return -EIO;
-       }
 
        rc = 0;
 
@@ -1531,19 +1298,37 @@ static int stl_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd
 
 /*****************************************************************************/
 
-static void stl_settermios(struct tty_struct *tty, struct termios *old)
+/*
+ *     Start the transmitter again. Just turn TX interrupts back on.
+ */
+
+static void stl_start(struct tty_struct *tty)
 {
-       stlport_t       *portp;
-       struct termios  *tiosp;
+       struct stlport  *portp;
 
-#ifdef DEBUG
-       printk("stl_settermios(tty=%x,old=%x)\n", (int) tty, (int) old);
-#endif
+       pr_debug("stl_start(tty=%p)\n", tty);
 
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return;
        portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
+               return;
+       stl_startrxtx(portp, -1, 1);
+}
+
+/*****************************************************************************/
+
+static void stl_settermios(struct tty_struct *tty, struct ktermios *old)
+{
+       struct stlport  *portp;
+       struct ktermios *tiosp;
+
+       pr_debug("stl_settermios(tty=%p,old=%p)\n", tty, old);
+
+       if (tty == NULL)
+               return;
+       portp = tty->driver_data;
+       if (portp == NULL)
                return;
 
        tiosp = tty->termios;
@@ -1571,16 +1356,14 @@ static void stl_settermios(struct tty_struct *tty, struct termios *old)
 
 static void stl_throttle(struct tty_struct *tty)
 {
-       stlport_t       *portp;
+       struct stlport  *portp;
 
-#ifdef DEBUG
-       printk("stl_throttle(tty=%x)\n", (int) tty);
-#endif
+       pr_debug("stl_throttle(tty=%p)\n", tty);
 
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return;
        portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return;
        stl_flowctrl(portp, 0);
 }
@@ -1593,16 +1376,14 @@ static void stl_throttle(struct tty_struct *tty)
 
 static void stl_unthrottle(struct tty_struct *tty)
 {
-       stlport_t       *portp;
+       struct stlport  *portp;
 
-#ifdef DEBUG
-       printk("stl_unthrottle(tty=%x)\n", (int) tty);
-#endif
+       pr_debug("stl_unthrottle(tty=%p)\n", tty);
 
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return;
        portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return;
        stl_flowctrl(portp, 1);
 }
@@ -1616,44 +1397,20 @@ static void stl_unthrottle(struct tty_struct *tty)
 
 static void stl_stop(struct tty_struct *tty)
 {
-       stlport_t       *portp;
+       struct stlport  *portp;
 
-#ifdef DEBUG
-       printk("stl_stop(tty=%x)\n", (int) tty);
-#endif
+       pr_debug("stl_stop(tty=%p)\n", tty);
 
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return;
        portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return;
        stl_startrxtx(portp, -1, 0);
 }
 
 /*****************************************************************************/
 
-/*
- *     Start the transmitter again. Just turn TX interrupts back on.
- */
-
-static void stl_start(struct tty_struct *tty)
-{
-       stlport_t       *portp;
-
-#ifdef DEBUG
-       printk("stl_start(tty=%x)\n", (int) tty);
-#endif
-
-       if (tty == (struct tty_struct *) NULL)
-               return;
-       portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
-               return;
-       stl_startrxtx(portp, -1, 1);
-}
-
-/*****************************************************************************/
-
 /*
  *     Hangup this port. This is pretty much like closing the port, only
  *     a little more brutal. No waiting for data to drain. Shutdown the
@@ -1662,16 +1419,14 @@ static void stl_start(struct tty_struct *tty)
 
 static void stl_hangup(struct tty_struct *tty)
 {
-       stlport_t       *portp;
+       struct stlport  *portp;
 
-#ifdef DEBUG
-       printk("stl_hangup(tty=%x)\n", (int) tty);
-#endif
+       pr_debug("stl_hangup(tty=%p)\n", tty);
 
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return;
        portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return;
 
        portp->flags &= ~ASYNC_INITIALIZED;
@@ -1682,13 +1437,13 @@ static void stl_hangup(struct tty_struct *tty)
        stl_flushbuffer(tty);
        portp->istate = 0;
        set_bit(TTY_IO_ERROR, &tty->flags);
-       if (portp->tx.buf != (char *) NULL) {
+       if (portp->tx.buf != NULL) {
                kfree(portp->tx.buf);
-               portp->tx.buf = (char *) NULL;
-               portp->tx.head = (char *) NULL;
-               portp->tx.tail = (char *) NULL;
+               portp->tx.buf = NULL;
+               portp->tx.head = NULL;
+               portp->tx.tail = NULL;
        }
-       portp->tty = (struct tty_struct *) NULL;
+       portp->tty = NULL;
        portp->flags &= ~ASYNC_NORMAL_ACTIVE;
        portp->refcount = 0;
        wake_up_interruptible(&portp->open_wait);
@@ -1696,38 +1451,16 @@ static void stl_hangup(struct tty_struct *tty)
 
 /*****************************************************************************/
 
-static void stl_flushbuffer(struct tty_struct *tty)
-{
-       stlport_t       *portp;
-
-#ifdef DEBUG
-       printk("stl_flushbuffer(tty=%x)\n", (int) tty);
-#endif
-
-       if (tty == (struct tty_struct *) NULL)
-               return;
-       portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
-               return;
-
-       stl_flush(portp);
-       tty_wakeup(tty);
-}
-
-/*****************************************************************************/
-
 static void stl_breakctl(struct tty_struct *tty, int state)
 {
-       stlport_t       *portp;
+       struct stlport  *portp;
 
-#ifdef DEBUG
-       printk("stl_breakctl(tty=%x,state=%d)\n", (int) tty, state);
-#endif
+       pr_debug("stl_breakctl(tty=%p,state=%d)\n", tty, state);
 
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return;
        portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return;
 
        stl_sendbreak(portp, ((state == -1) ? 1 : 2));
@@ -1735,48 +1468,16 @@ static void stl_breakctl(struct tty_struct *tty, int state)
 
 /*****************************************************************************/
 
-static void stl_waituntilsent(struct tty_struct *tty, int timeout)
-{
-       stlport_t       *portp;
-       unsigned long   tend;
-
-#ifdef DEBUG
-       printk("stl_waituntilsent(tty=%x,timeout=%d)\n", (int) tty, timeout);
-#endif
-
-       if (tty == (struct tty_struct *) NULL)
-               return;
-       portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
-               return;
-
-       if (timeout == 0)
-               timeout = HZ;
-       tend = jiffies + timeout;
-
-       while (stl_datastate(portp)) {
-               if (signal_pending(current))
-                       break;
-               msleep_interruptible(20);
-               if (time_after_eq(jiffies, tend))
-                       break;
-       }
-}
-
-/*****************************************************************************/
-
 static void stl_sendxchar(struct tty_struct *tty, char ch)
 {
-       stlport_t       *portp;
+       struct stlport  *portp;
 
-#ifdef DEBUG
-       printk("stl_sendxchar(tty=%x,ch=%x)\n", (int) tty, ch);
-#endif
+       pr_debug("stl_sendxchar(tty=%p,ch=%x)\n", tty, ch);
 
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return;
        portp = tty->driver_data;
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return;
 
        if (ch == STOP_CHAR(tty))
@@ -1797,7 +1498,7 @@ static void stl_sendxchar(struct tty_struct *tty, char ch)
  *     short then padded with spaces).
  */
 
-static int stl_portinfo(stlport_t *portp, int portnr, char *pos)
+static int stl_portinfo(struct stlport *portp, int portnr, char *pos)
 {
        char    *sp;
        int     sigs, cnt;
@@ -1826,7 +1527,7 @@ static int stl_portinfo(stlport_t *portp, int portnr, char *pos)
        *sp = ' ';
        sp += cnt;
 
-       for (cnt = (sp - pos); (cnt < (MAXLINE - 1)); cnt++)
+       for (cnt = sp - pos; cnt < (MAXLINE - 1); cnt++)
                *sp++ = ' ';
        if (cnt >= MAXLINE)
                pos[(MAXLINE - 2)] = '+';
@@ -1843,18 +1544,15 @@ static int stl_portinfo(stlport_t *portp, int portnr, char *pos)
 
 static int stl_readproc(char *page, char **start, off_t off, int count, int *eof, void *data)
 {
-       stlbrd_t        *brdp;
-       stlpanel_t      *panelp;
-       stlport_t       *portp;
-       int             brdnr, panelnr, portnr, totalport;
-       int             curoff, maxoff;
+       struct stlbrd   *brdp;
+       struct stlpanel *panelp;
+       struct stlport  *portp;
+       unsigned int    brdnr, panelnr, portnr;
+       int             totalport, curoff, maxoff;
        char            *pos;
 
-#ifdef DEBUG
-       printk("stl_readproc(page=%x,start=%x,off=%x,count=%d,eof=%x,"
-               "data=%x\n", (int) page, (int) start, (int) off, count,
-               (int) eof, (int) data);
-#endif
+       pr_debug("stl_readproc(page=%p,start=%p,off=%lx,count=%d,eof=%p,"
+               "data=%p\n", page, start, off, count, eof, data);
 
        pos = page;
        totalport = 0;
@@ -1873,9 +1571,9 @@ static int stl_readproc(char *page, char **start, off_t off, int count, int *eof
  *     We scan through for each board, panel and port. The offset is
  *     calculated on the fly, and irrelevant ports are skipped.
  */
-       for (brdnr = 0; (brdnr < stl_nrbrds); brdnr++) {
+       for (brdnr = 0; brdnr < stl_nrbrds; brdnr++) {
                brdp = stl_brds[brdnr];
-               if (brdp == (stlbrd_t *) NULL)
+               if (brdp == NULL)
                        continue;
                if (brdp->state == 0)
                        continue;
@@ -1887,9 +1585,9 @@ static int stl_readproc(char *page, char **start, off_t off, int count, int *eof
                }
 
                totalport = brdnr * STL_MAXPORTS;
-               for (panelnr = 0; (panelnr < brdp->nrpanels); panelnr++) {
+               for (panelnr = 0; panelnr < brdp->nrpanels; panelnr++) {
                        panelp = brdp->panels[panelnr];
-                       if (panelp == (stlpanel_t *) NULL)
+                       if (panelp == NULL)
                                continue;
 
                        maxoff = curoff + (panelp->nrports * MAXLINE);
@@ -1899,10 +1597,10 @@ static int stl_readproc(char *page, char **start, off_t off, int count, int *eof
                                continue;
                        }
 
-                       for (portnr = 0; (portnr < panelp->nrports); portnr++,
+                       for (portnr = 0; portnr < panelp->nrports; portnr++,
                            totalport++) {
                                portp = panelp->ports[portnr];
-                               if (portp == (stlport_t *) NULL)
+                               if (portp == NULL)
                                        continue;
                                if (off >= (curoff += MAXLINE))
                                        continue;
@@ -1917,7 +1615,7 @@ static int stl_readproc(char *page, char **start, off_t off, int count, int *eof
 
 stl_readdone:
        *start = page;
-       return (pos - page);
+       return pos - page;
 }
 
 /*****************************************************************************/
@@ -1929,11 +1627,9 @@ stl_readdone:
 
 static irqreturn_t stl_intr(int irq, void *dev_id)
 {
-       stlbrd_t        *brdp = (stlbrd_t *) dev_id;
+       struct stlbrd *brdp = dev_id;
 
-#ifdef DEBUG
-       printk("stl_intr(brdp=%x,irq=%d)\n", (int) brdp, irq);
-#endif
+       pr_debug("stl_intr(brdp=%p,irq=%d)\n", brdp, irq);
 
        return IRQ_RETVAL((* brdp->isr)(brdp));
 }
@@ -1944,9 +1640,9 @@ static irqreturn_t stl_intr(int irq, void *dev_id)
  *     Interrupt service routine for EasyIO board types.
  */
 
-static int stl_eiointr(stlbrd_t *brdp)
+static int stl_eiointr(struct stlbrd *brdp)
 {
-       stlpanel_t      *panelp;
+       struct stlpanel *panelp;
        unsigned int    iobase;
        int             handled = 0;
 
@@ -1967,18 +1663,17 @@ static int stl_eiointr(stlbrd_t *brdp)
  *     Interrupt service routine for ECH-AT board types.
  */
 
-static int stl_echatintr(stlbrd_t *brdp)
+static int stl_echatintr(struct stlbrd *brdp)
 {
-       stlpanel_t      *panelp;
-       unsigned int    ioaddr;
-       int             bnknr;
+       struct stlpanel *panelp;
+       unsigned int    ioaddr, bnknr;
        int             handled = 0;
 
        outb((brdp->ioctrlval | ECH_BRDENABLE), brdp->ioctrl);
 
        while (inb(brdp->iostatus) & ECH_INTRPEND) {
                handled = 1;
-               for (bnknr = 0; (bnknr < brdp->nrbnks); bnknr++) {
+               for (bnknr = 0; bnknr < brdp->nrbnks; bnknr++) {
                        ioaddr = brdp->bnkstataddr[bnknr];
                        if (inb(ioaddr) & ECH_PNLINTRPEND) {
                                panelp = brdp->bnk2panel[bnknr];
@@ -1998,16 +1693,15 @@ static int stl_echatintr(stlbrd_t *brdp)
  *     Interrupt service routine for ECH-MCA board types.
  */
 
-static int stl_echmcaintr(stlbrd_t *brdp)
+static int stl_echmcaintr(struct stlbrd *brdp)
 {
-       stlpanel_t      *panelp;
-       unsigned int    ioaddr;
-       int             bnknr;
+       struct stlpanel *panelp;
+       unsigned int    ioaddr, bnknr;
        int             handled = 0;
 
        while (inb(brdp->iostatus) & ECH_INTRPEND) {
                handled = 1;
-               for (bnknr = 0; (bnknr < brdp->nrbnks); bnknr++) {
+               for (bnknr = 0; bnknr < brdp->nrbnks; bnknr++) {
                        ioaddr = brdp->bnkstataddr[bnknr];
                        if (inb(ioaddr) & ECH_PNLINTRPEND) {
                                panelp = brdp->bnk2panel[bnknr];
@@ -2024,16 +1718,15 @@ static int stl_echmcaintr(stlbrd_t *brdp)
  *     Interrupt service routine for ECH-PCI board types.
  */
 
-static int stl_echpciintr(stlbrd_t *brdp)
+static int stl_echpciintr(struct stlbrd *brdp)
 {
-       stlpanel_t      *panelp;
-       unsigned int    ioaddr;
-       int             bnknr, recheck;
+       struct stlpanel *panelp;
+       unsigned int    ioaddr, bnknr, recheck;
        int             handled = 0;
 
        while (1) {
                recheck = 0;
-               for (bnknr = 0; (bnknr < brdp->nrbnks); bnknr++) {
+               for (bnknr = 0; bnknr < brdp->nrbnks; bnknr++) {
                        outb(brdp->bnkpageaddr[bnknr], brdp->ioctrl);
                        ioaddr = brdp->bnkstataddr[bnknr];
                        if (inb(ioaddr) & ECH_PNLINTRPEND) {
@@ -2055,16 +1748,15 @@ static int stl_echpciintr(stlbrd_t *brdp)
  *     Interrupt service routine for ECH-8/64-PCI board types.
  */
 
-static int stl_echpci64intr(stlbrd_t *brdp)
+static int stl_echpci64intr(struct stlbrd *brdp)
 {
-       stlpanel_t      *panelp;
-       unsigned int    ioaddr;
-       int             bnknr;
+       struct stlpanel *panelp;
+       unsigned int    ioaddr, bnknr;
        int             handled = 0;
 
        while (inb(brdp->ioctrl) & 0x1) {
                handled = 1;
-               for (bnknr = 0; (bnknr < brdp->nrbnks); bnknr++) {
+               for (bnknr = 0; bnknr < brdp->nrbnks; bnknr++) {
                        ioaddr = brdp->bnkstataddr[bnknr];
                        if (inb(ioaddr) & ECH_PNLINTRPEND) {
                                panelp = brdp->bnk2panel[bnknr];
@@ -2083,35 +1775,32 @@ static int stl_echpci64intr(stlbrd_t *brdp)
  */
 static void stl_offintr(struct work_struct *work)
 {
-       stlport_t               *portp = container_of(work, stlport_t, tqueue);
+       struct stlport          *portp = container_of(work, struct stlport, tqueue);
        struct tty_struct       *tty;
        unsigned int            oldsigs;
 
-#ifdef DEBUG
-       printk("stl_offintr(portp=%x)\n", (int) portp);
-#endif
+       pr_debug("stl_offintr(portp=%p)\n", portp);
 
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return;
 
        tty = portp->tty;
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return;
 
        lock_kernel();
-       if (test_bit(ASYI_TXLOW, &portp->istate)) {
+       if (test_bit(ASYI_TXLOW, &portp->istate))
                tty_wakeup(tty);
-       }
+
        if (test_bit(ASYI_DCDCHANGE, &portp->istate)) {
                clear_bit(ASYI_DCDCHANGE, &portp->istate);
                oldsigs = portp->sigs;
                portp->sigs = stl_getsignals(portp);
                if ((portp->sigs & TIOCM_CD) && ((oldsigs & TIOCM_CD) == 0))
                        wake_up_interruptible(&portp->open_wait);
-               if ((oldsigs & TIOCM_CD) && ((portp->sigs & TIOCM_CD) == 0)) {
+               if ((oldsigs & TIOCM_CD) && ((portp->sigs & TIOCM_CD) == 0))
                        if (portp->flags & ASYNC_CHECK_CD)
                                tty_hangup(tty);        /* FIXME: module removal race here - AKPM */
-               }
        }
        unlock_kernel();
 }
@@ -2122,14 +1811,13 @@ static void stl_offintr(struct work_struct *work)
  *     Initialize all the ports on a panel.
  */
 
-static int __init stl_initports(stlbrd_t *brdp, stlpanel_t *panelp)
+static int __devinit stl_initports(struct stlbrd *brdp, struct stlpanel *panelp)
 {
-       stlport_t       *portp;
-       int             chipmask, i;
+       struct stlport *portp;
+       unsigned int i;
+       int chipmask;
 
-#ifdef DEBUG
-       printk("stl_initports(brdp=%x,panelp=%x)\n", (int) brdp, (int) panelp);
-#endif
+       pr_debug("stl_initports(brdp=%p,panelp=%p)\n", brdp, panelp);
 
        chipmask = stl_panelinit(brdp, panelp);
 
@@ -2137,11 +1825,11 @@ static int __init stl_initports(stlbrd_t *brdp, stlpanel_t *panelp)
  *     All UART's are initialized (if found!). Now go through and setup
  *     each ports data structures.
  */
-       for (i = 0; (i < panelp->nrports); i++) {
-               portp = kzalloc(sizeof(stlport_t), GFP_KERNEL);
+       for (i = 0; i < panelp->nrports; i++) {
+               portp = kzalloc(sizeof(struct stlport), GFP_KERNEL);
                if (!portp) {
                        printk("STALLION: failed to allocate memory "
-                               "(size=%Zd)\n", sizeof(stlport_t));
+                               "(size=%Zd)\n", sizeof(struct stlport));
                        break;
                }
 
@@ -2164,7 +1852,30 @@ static int __init stl_initports(stlbrd_t *brdp, stlpanel_t *panelp)
                stl_portinit(brdp, panelp, portp);
        }
 
-       return(0);
+       return 0;
+}
+
+static void stl_cleanup_panels(struct stlbrd *brdp)
+{
+       struct stlpanel *panelp;
+       struct stlport *portp;
+       unsigned int j, k;
+
+       for (j = 0; j < STL_MAXPANELS; j++) {
+               panelp = brdp->panels[j];
+               if (panelp == NULL)
+                       continue;
+               for (k = 0; k < STL_PORTSPERPANEL; k++) {
+                       portp = panelp->ports[k];
+                       if (portp == NULL)
+                               continue;
+                       if (portp->tty != NULL)
+                               stl_hangup(portp->tty);
+                       kfree(portp->tx.buf);
+                       kfree(portp);
+               }
+               kfree(panelp);
+       }
 }
 
 /*****************************************************************************/
@@ -2173,16 +1884,14 @@ static int __init stl_initports(stlbrd_t *brdp, stlpanel_t *panelp)
  *     Try to find and initialize an EasyIO board.
  */
 
-static inline int stl_initeio(stlbrd_t *brdp)
+static int __devinit stl_initeio(struct stlbrd *brdp)
 {
-       stlpanel_t      *panelp;
+       struct stlpanel *panelp;
        unsigned int    status;
        char            *name;
-       int             rc;
+       int             retval;
 
-#ifdef DEBUG
-       printk("stl_initeio(brdp=%x)\n", (int) brdp);
-#endif
+       pr_debug("stl_initeio(brdp=%p)\n", brdp);
 
        brdp->ioctrl = brdp->ioaddr1 + 1;
        brdp->iostatus = brdp->ioaddr1 + 2;
@@ -2207,18 +1916,20 @@ static inline int stl_initeio(stlbrd_t *brdp)
                    (stl_vecmap[brdp->irq] == (unsigned char) 0xff)) {
                        printk("STALLION: invalid irq=%d for brd=%d\n",
                                brdp->irq, brdp->brdnr);
-                       return(-EINVAL);
+                       retval = -EINVAL;
+                       goto err;
                }
                outb((stl_vecmap[brdp->irq] | EIO_0WS |
                        ((brdp->irqtype) ? EIO_INTLEVEL : EIO_INTEDGE)),
                        brdp->ioctrl);
        }
 
+       retval = -EBUSY;
        if (!request_region(brdp->ioaddr1, brdp->iosize1, name)) {
                printk(KERN_WARNING "STALLION: Warning, board %d I/O address "
                        "%x conflicts with another device\n", brdp->brdnr, 
                        brdp->ioaddr1);
-               return(-EBUSY);
+               goto err;
        }
        
        if (brdp->iosize2 > 0)
@@ -2229,8 +1940,7 @@ static inline int stl_initeio(stlbrd_t *brdp)
                        printk(KERN_WARNING "STALLION: Warning, also "
                                "releasing board %d I/O address %x \n", 
                                brdp->brdnr, brdp->ioaddr1);
-                       release_region(brdp->ioaddr1, brdp->iosize1);
-                       return(-EBUSY);
+                       goto err_rel1;
                }
 
 /*
@@ -2239,6 +1949,7 @@ static inline int stl_initeio(stlbrd_t *brdp)
        brdp->clk = CD1400_CLK;
        brdp->isr = stl_eiointr;
 
+       retval = -ENODEV;
        switch (status & EIO_IDBITMASK) {
        case EIO_8PORTM:
                brdp->clk = CD1400_CLK8M;
@@ -2262,11 +1973,11 @@ static inline int stl_initeio(stlbrd_t *brdp)
                        brdp->nrports = 16;
                        break;
                default:
-                       return(-ENODEV);
+                       goto err_rel2;
                }
                break;
        default:
-               return(-ENODEV);
+               goto err_rel2;
        }
 
 /*
@@ -2274,11 +1985,12 @@ static inline int stl_initeio(stlbrd_t *brdp)
  *     can complete the setup.
  */
 
-       panelp = kzalloc(sizeof(stlpanel_t), GFP_KERNEL);
+       panelp = kzalloc(sizeof(struct stlpanel), GFP_KERNEL);
        if (!panelp) {
                printk(KERN_WARNING "STALLION: failed to allocate memory "
-                       "(size=%Zd)\n", sizeof(stlpanel_t));
-               return -ENOMEM;
+                       "(size=%Zd)\n", sizeof(struct stlpanel));
+               retval = -ENOMEM;
+               goto err_rel2;
        }
 
        panelp->magic = STL_PANELMAGIC;
@@ -2288,10 +2000,10 @@ static inline int stl_initeio(stlbrd_t *brdp)
        panelp->iobase = brdp->ioaddr1;
        panelp->hwid = status;
        if ((status & EIO_IDBITMASK) == EIO_MK3) {
-               panelp->uartp = (void *) &stl_sc26198uart;
+               panelp->uartp = &stl_sc26198uart;
                panelp->isr = stl_sc26198intr;
        } else {
-               panelp->uartp = (void *) &stl_cd1400uart;
+               panelp->uartp = &stl_cd1400uart;
                panelp->isr = stl_cd1400eiointr;
        }
 
@@ -2302,11 +2014,20 @@ static inline int stl_initeio(stlbrd_t *brdp)
        if (request_irq(brdp->irq, stl_intr, IRQF_SHARED, name, brdp) != 0) {
                printk("STALLION: failed to register interrupt "
                    "routine for %s irq=%d\n", name, brdp->irq);
-               rc = -ENODEV;
-       } else {
-               rc = 0;
+               retval = -ENODEV;
+               goto err_fr;
        }
-       return rc;
+
+       return 0;
+err_fr:
+       stl_cleanup_panels(brdp);
+err_rel2:
+       if (brdp->iosize2 > 0)
+               release_region(brdp->ioaddr2, brdp->iosize2);
+err_rel1:
+       release_region(brdp->ioaddr1, brdp->iosize1);
+err:
+       return retval;
 }
 
 /*****************************************************************************/
@@ -2316,16 +2037,14 @@ static inline int stl_initeio(stlbrd_t *brdp)
  *     dealing with all types of ECH board.
  */
 
-static inline int stl_initech(stlbrd_t *brdp)
+static int __devinit stl_initech(struct stlbrd *brdp)
 {
-       stlpanel_t      *panelp;
-       unsigned int    status, nxtid, ioaddr, conflict;
-       int             panelnr, banknr, i;
+       struct stlpanel *panelp;
+       unsigned int    status, nxtid, ioaddr, conflict, panelnr, banknr, i;
+       int             retval;
        char            *name;
 
-#ifdef DEBUG
-       printk("stl_initech(brdp=%x)\n", (int) brdp);
-#endif
+       pr_debug("stl_initech(brdp=%p)\n", brdp);
 
        status = 0;
        conflict = 0;
@@ -2342,20 +2061,23 @@ static inline int stl_initech(stlbrd_t *brdp)
                brdp->ioctrl = brdp->ioaddr1 + 1;
                brdp->iostatus = brdp->ioaddr1 + 1;
                status = inb(brdp->iostatus);
-               if ((status & ECH_IDBITMASK) != ECH_ID)
-                       return(-ENODEV);
+               if ((status & ECH_IDBITMASK) != ECH_ID) {
+                       retval = -ENODEV;
+                       goto err;
+               }
                if ((brdp->irq < 0) || (brdp->irq > 15) ||
                    (stl_vecmap[brdp->irq] == (unsigned char) 0xff)) {
                        printk("STALLION: invalid irq=%d for brd=%d\n",
                                brdp->irq, brdp->brdnr);
-                       return(-EINVAL);
+                       retval = -EINVAL;
+                       goto err;
                }
                status = ((brdp->ioaddr2 & ECH_ADDR2MASK) >> 1);
                status |= (stl_vecmap[brdp->irq] << 1);
                outb((status | ECH_BRDRESET), brdp->ioaddr1);
                brdp->ioctrlval = ECH_INTENABLE |
                        ((brdp->irqtype) ? ECH_INTLEVEL : ECH_INTEDGE);
-               for (i = 0; (i < 10); i++)
+               for (i = 0; i < 10; i++)
                        outb((brdp->ioctrlval | ECH_BRDENABLE), brdp->ioctrl);
                brdp->iosize1 = 2;
                brdp->iosize2 = 32;
@@ -2368,13 +2090,16 @@ static inline int stl_initech(stlbrd_t *brdp)
                brdp->ioctrl = brdp->ioaddr1 + 0x20;
                brdp->iostatus = brdp->ioctrl;
                status = inb(brdp->iostatus);
-               if ((status & ECH_IDBITMASK) != ECH_ID)
-                       return(-ENODEV);
+               if ((status & ECH_IDBITMASK) != ECH_ID) {
+                       retval = -ENODEV;
+                       goto err;
+               }
                if ((brdp->irq < 0) || (brdp->irq > 15) ||
                    (stl_vecmap[brdp->irq] == (unsigned char) 0xff)) {
                        printk("STALLION: invalid irq=%d for brd=%d\n",
                                brdp->irq, brdp->brdnr);
-                       return(-EINVAL);
+                       retval = -EINVAL;
+                       goto err;
                }
                outb(ECHMC_BRDRESET, brdp->ioctrl);
                outb(ECHMC_INTENABLE, brdp->ioctrl);
@@ -2401,19 +2126,20 @@ static inline int stl_initech(stlbrd_t *brdp)
 
        default:
                printk("STALLION: unknown board type=%d\n", brdp->brdtype);
-               return(-EINVAL);
-               break;
+               retval = -EINVAL;
+               goto err;
        }
 
 /*
  *     Check boards for possible IO address conflicts and return fail status 
  *     if an IO conflict found.
  */
+       retval = -EBUSY;
        if (!request_region(brdp->ioaddr1, brdp->iosize1, name)) {
                printk(KERN_WARNING "STALLION: Warning, board %d I/O address "
                        "%x conflicts with another device\n", brdp->brdnr, 
                        brdp->ioaddr1);
-               return(-EBUSY);
+               goto err;
        }
        
        if (brdp->iosize2 > 0)
@@ -2424,8 +2150,7 @@ static inline int stl_initech(stlbrd_t *brdp)
                        printk(KERN_WARNING "STALLION: Warning, also "
                                "releasing board %d I/O address %x \n", 
                                brdp->brdnr, brdp->ioaddr1);
-                       release_region(brdp->ioaddr1, brdp->iosize1);
-                       return(-EBUSY);
+                       goto err_rel1;
                }
 
 /*
@@ -2440,19 +2165,19 @@ static inline int stl_initech(stlbrd_t *brdp)
        panelnr = 0;
        nxtid = 0;
 
-       for (i = 0; (i < STL_MAXPANELS); i++) {
+       for (i = 0; i < STL_MAXPANELS; i++) {
                if (brdp->brdtype == BRD_ECHPCI) {
                        outb(nxtid, brdp->ioctrl);
                        ioaddr = brdp->ioaddr2;
                }
                status = inb(ioaddr + ECH_PNLSTATUS);
                if ((status & ECH_PNLIDMASK) != nxtid)
-                       break;
-               panelp = kzalloc(sizeof(stlpanel_t), GFP_KERNEL);
+                       goto err_fr;
+               panelp = kzalloc(sizeof(struct stlpanel), GFP_KERNEL);
                if (!panelp) {
                        printk("STALLION: failed to allocate memory "
-                               "(size=%Zd)\n", sizeof(stlpanel_t));
-                       break;
+                               "(size=%Zd)\n", sizeof(struct stlpanel));
+                       goto err_fr;
                }
                panelp->magic = STL_PANELMAGIC;
                panelp->brdnr = brdp->brdnr;
@@ -2465,7 +2190,7 @@ static inline int stl_initech(stlbrd_t *brdp)
                brdp->bnkstataddr[banknr++] = ioaddr + ECH_PNLSTATUS;
 
                if (status & ECH_PNLXPID) {
-                       panelp->uartp = (void *) &stl_sc26198uart;
+                       panelp->uartp = &stl_sc26198uart;
                        panelp->isr = stl_sc26198intr;
                        if (status & ECH_PNL16PORT) {
                                panelp->nrports = 16;
@@ -2473,11 +2198,10 @@ static inline int stl_initech(stlbrd_t *brdp)
                                brdp->bnkpageaddr[banknr] = nxtid;
                                brdp->bnkstataddr[banknr++] = ioaddr + 4 +
                                        ECH_PNLSTATUS;
-                       } else {
+                       } else
                                panelp->nrports = 8;
-                       }
                } else {
-                       panelp->uartp = (void *) &stl_cd1400uart;
+                       panelp->uartp = &stl_cd1400uart;
                        panelp->isr = stl_cd1400echintr;
                        if (status & ECH_PNL16PORT) {
                                panelp->nrports = 16;
@@ -2500,7 +2224,7 @@ static inline int stl_initech(stlbrd_t *brdp)
                brdp->panels[panelnr++] = panelp;
                if ((brdp->brdtype != BRD_ECHPCI) &&
                    (ioaddr >= (brdp->ioaddr2 + brdp->iosize2)))
-                       break;
+                       goto err_fr;
        }
 
        brdp->nrpanels = panelnr;
@@ -2512,12 +2236,19 @@ static inline int stl_initech(stlbrd_t *brdp)
        if (request_irq(brdp->irq, stl_intr, IRQF_SHARED, name, brdp) != 0) {
                printk("STALLION: failed to register interrupt "
                    "routine for %s irq=%d\n", name, brdp->irq);
-               i = -ENODEV;
-       } else {
-               i = 0;
+               retval = -ENODEV;
+               goto err_fr;
        }
 
-       return(i);
+       return 0;
+err_fr:
+       stl_cleanup_panels(brdp);
+       if (brdp->iosize2 > 0)
+               release_region(brdp->ioaddr2, brdp->iosize2);
+err_rel1:
+       release_region(brdp->ioaddr1, brdp->iosize1);
+err:
+       return retval;
 }
 
 /*****************************************************************************/
@@ -2529,48 +2260,61 @@ static inline int stl_initech(stlbrd_t *brdp)
  *     since the initial search and setup is very different.
  */
 
-static int __init stl_brdinit(stlbrd_t *brdp)
+static int __devinit stl_brdinit(struct stlbrd *brdp)
 {
-       int     i;
+       int i, retval;
 
-#ifdef DEBUG
-       printk("stl_brdinit(brdp=%x)\n", (int) brdp);
-#endif
+       pr_debug("stl_brdinit(brdp=%p)\n", brdp);
 
        switch (brdp->brdtype) {
        case BRD_EASYIO:
        case BRD_EASYIOPCI:
-               stl_initeio(brdp);
+               retval = stl_initeio(brdp);
+               if (retval)
+                       goto err;
                break;
        case BRD_ECH:
        case BRD_ECHMC:
        case BRD_ECHPCI:
        case BRD_ECH64PCI:
-               stl_initech(brdp);
+               retval = stl_initech(brdp);
+               if (retval)
+                       goto err;
                break;
        default:
                printk("STALLION: board=%d is unknown board type=%d\n",
                        brdp->brdnr, brdp->brdtype);
-               return(ENODEV);
+               retval = -ENODEV;
+               goto err;
        }
 
-       stl_brds[brdp->brdnr] = brdp;
        if ((brdp->state & BRD_FOUND) == 0) {
                printk("STALLION: %s board not found, board=%d io=%x irq=%d\n",
                        stl_brdnames[brdp->brdtype], brdp->brdnr,
                        brdp->ioaddr1, brdp->irq);
-               return(ENODEV);
+               goto err_free;
        }
 
-       for (i = 0; (i < STL_MAXPANELS); i++)
-               if (brdp->panels[i] != (stlpanel_t *) NULL)
+       for (i = 0; i < STL_MAXPANELS; i++)
+               if (brdp->panels[i] != NULL)
                        stl_initports(brdp, brdp->panels[i]);
 
        printk("STALLION: %s found, board=%d io=%x irq=%d "
                "nrpanels=%d nrports=%d\n", stl_brdnames[brdp->brdtype],
                brdp->brdnr, brdp->ioaddr1, brdp->irq, brdp->nrpanels,
                brdp->nrports);
-       return(0);
+
+       return 0;
+err_free:
+       free_irq(brdp->irq, brdp);
+
+       stl_cleanup_panels(brdp);
+
+       release_region(brdp->ioaddr1, brdp->iosize1);
+       if (brdp->iosize2 > 0)
+               release_region(brdp->ioaddr2, brdp->iosize2);
+err:
+       return retval;
 }
 
 /*****************************************************************************/
@@ -2579,59 +2323,62 @@ static int __init stl_brdinit(stlbrd_t *brdp)
  *     Find the next available board number that is free.
  */
 
-static inline int stl_getbrdnr(void)
+static int __devinit stl_getbrdnr(void)
 {
-       int     i;
+       unsigned int i;
 
-       for (i = 0; (i < STL_MAXBRDS); i++) {
-               if (stl_brds[i] == (stlbrd_t *) NULL) {
+       for (i = 0; i < STL_MAXBRDS; i++)
+               if (stl_brds[i] == NULL) {
                        if (i >= stl_nrbrds)
                                stl_nrbrds = i + 1;
-                       return(i);
+                       return i;
                }
-       }
-       return(-1);
+
+       return -1;
 }
 
 /*****************************************************************************/
-
-#ifdef CONFIG_PCI
-
 /*
  *     We have a Stallion board. Allocate a board structure and
  *     initialize it. Read its IO and IRQ resources from PCI
  *     configuration space.
  */
 
-static inline int stl_initpcibrd(int brdtype, struct pci_dev *devp)
+static int __devinit stl_pciprobe(struct pci_dev *pdev,
+               const struct pci_device_id *ent)
 {
-       stlbrd_t        *brdp;
-
-#ifdef DEBUG
-       printk("stl_initpcibrd(brdtype=%d,busnr=%x,devnr=%x)\n", brdtype,
-               devp->bus->number, devp->devfn);
-#endif
-
-       if (pci_enable_device(devp))
-               return(-EIO);
-       if ((brdp = stl_allocbrd()) == (stlbrd_t *) NULL)
-               return(-ENOMEM);
-       if ((brdp->brdnr = stl_getbrdnr()) < 0) {
-               printk("STALLION: too many boards found, "
+       struct stlbrd *brdp;
+       unsigned int i, brdtype = ent->driver_data;
+       int brdnr, retval = -ENODEV;
+
+       if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE)
+               goto err;
+
+       dev_info(&pdev->dev, "please, report this to LKML: %x/%x/%x\n",
+                       pdev->vendor, pdev->device, pdev->class);
+
+       retval = pci_enable_device(pdev);
+       if (retval)
+               goto err;
+       brdp = stl_allocbrd();
+       if (brdp == NULL) {
+               retval = -ENOMEM;
+               goto err;
+       }
+       mutex_lock(&stl_brdslock);
+       brdnr = stl_getbrdnr();
+       if (brdnr < 0) {
+               dev_err(&pdev->dev, "too many boards found, "
                        "maximum supported %d\n", STL_MAXBRDS);
-               return(0);
+               mutex_unlock(&stl_brdslock);
+               goto err_fr;
        }
-       brdp->brdtype = brdtype;
+       brdp->brdnr = (unsigned int)brdnr;
+       stl_brds[brdp->brdnr] = brdp;
+       mutex_unlock(&stl_brdslock);
 
-/*
- *     Different Stallion boards use the BAR registers in different ways,
- *     so set up io addresses based on board type.
- */
-#ifdef DEBUG
-       printk("%s(%d): BAR[]=%x,%x,%x,%x IRQ=%x\n", __FILE__, __LINE__,
-               pci_resource_start(devp, 0), pci_resource_start(devp, 1),
-               pci_resource_start(devp, 2), pci_resource_start(devp, 3), devp->irq);
-#endif
+       brdp->brdtype = brdtype;
+       brdp->state |= STL_PROBED;
 
 /*
  *     We have all resources from the board, so let's setup the actual
@@ -2639,120 +2386,70 @@ static inline int stl_initpcibrd(int brdtype, struct pci_dev *devp)
  */
        switch (brdtype) {
        case BRD_ECHPCI:
-               brdp->ioaddr2 = pci_resource_start(devp, 0);
-               brdp->ioaddr1 = pci_resource_start(devp, 1);
+               brdp->ioaddr2 = pci_resource_start(pdev, 0);
+               brdp->ioaddr1 = pci_resource_start(pdev, 1);
                break;
        case BRD_ECH64PCI:
-               brdp->ioaddr2 = pci_resource_start(devp, 2);
-               brdp->ioaddr1 = pci_resource_start(devp, 1);
+               brdp->ioaddr2 = pci_resource_start(pdev, 2);
+               brdp->ioaddr1 = pci_resource_start(pdev, 1);
                break;
        case BRD_EASYIOPCI:
-               brdp->ioaddr1 = pci_resource_start(devp, 2);
-               brdp->ioaddr2 = pci_resource_start(devp, 1);
+               brdp->ioaddr1 = pci_resource_start(pdev, 2);
+               brdp->ioaddr2 = pci_resource_start(pdev, 1);
                break;
-       default:
-               printk("STALLION: unknown PCI board type=%d\n", brdtype);
-               break;
-       }
-
-       brdp->irq = devp->irq;
-       stl_brdinit(brdp);
-
-       return(0);
-}
-
-/*****************************************************************************/
-
-/*
- *     Find all Stallion PCI boards that might be installed. Initialize each
- *     one as it is found.
- */
-
-
-static inline int stl_findpcibrds(void)
-{
-       struct pci_dev  *dev = NULL;
-       int             i, rc;
-
-#ifdef DEBUG
-       printk("stl_findpcibrds()\n");
-#endif
-
-       for (i = 0; (i < stl_nrpcibrds); i++)
-               while ((dev = pci_find_device(stl_pcibrds[i].vendid,
-                   stl_pcibrds[i].devid, dev))) {
-
-/*
- *                     Found a device on the PCI bus that has our vendor and
- *                     device ID. Need to check now that it is really us.
- */
-                       if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE)
-                               continue;
-
-                       rc = stl_initpcibrd(stl_pcibrds[i].brdtype, dev);
-                       if (rc)
-                               return(rc);
-               }
+       default:
+               dev_err(&pdev->dev, "unknown PCI board type=%u\n", brdtype);
+               break;
+       }
 
-       return(0);
-}
+       brdp->irq = pdev->irq;
+       retval = stl_brdinit(brdp);
+       if (retval)
+               goto err_null;
 
-#endif
+       pci_set_drvdata(pdev, brdp);
 
-/*****************************************************************************/
+       for (i = 0; i < brdp->nrports; i++)
+               tty_register_device(stl_serial,
+                               brdp->brdnr * STL_MAXPORTS + i, &pdev->dev);
 
-/*
- *     Scan through all the boards in the configuration and see what we
- *     can find. Handle EIO and the ECH boards a little differently here
- *     since the initial search and setup is too different.
- */
+       return 0;
+err_null:
+       stl_brds[brdp->brdnr] = NULL;
+err_fr:
+       kfree(brdp);
+err:
+       return retval;
+}
 
-static inline int stl_initbrds(void)
+static void __devexit stl_pciremove(struct pci_dev *pdev)
 {
-       stlbrd_t        *brdp;
-       stlconf_t       *confp;
-       int             i;
+       struct stlbrd *brdp = pci_get_drvdata(pdev);
+       unsigned int i;
 
-#ifdef DEBUG
-       printk("stl_initbrds()\n");
-#endif
+       free_irq(brdp->irq, brdp);
 
-       if (stl_nrbrds > STL_MAXBRDS) {
-               printk("STALLION: too many boards in configuration table, "
-                       "truncating to %d\n", STL_MAXBRDS);
-               stl_nrbrds = STL_MAXBRDS;
-       }
+       stl_cleanup_panels(brdp);
 
-/*
- *     Firstly scan the list of static boards configured. Allocate
- *     resources and initialize the boards as found.
- */
-       for (i = 0; (i < stl_nrbrds); i++) {
-               confp = &stl_brdconf[i];
-               stl_parsebrd(confp, stl_brdsp[i]);
-               if ((brdp = stl_allocbrd()) == (stlbrd_t *) NULL)
-                       return(-ENOMEM);
-               brdp->brdnr = i;
-               brdp->brdtype = confp->brdtype;
-               brdp->ioaddr1 = confp->ioaddr1;
-               brdp->ioaddr2 = confp->ioaddr2;
-               brdp->irq = confp->irq;
-               brdp->irqtype = confp->irqtype;
-               stl_brdinit(brdp);
-       }
+       release_region(brdp->ioaddr1, brdp->iosize1);
+       if (brdp->iosize2 > 0)
+               release_region(brdp->ioaddr2, brdp->iosize2);
 
-/*
- *     Find any dynamically supported boards. That is via module load
- *     line options or auto-detected on the PCI bus.
- */
-       stl_argbrds();
-#ifdef CONFIG_PCI
-       stl_findpcibrds();
-#endif
+       for (i = 0; i < brdp->nrports; i++)
+               tty_unregister_device(stl_serial,
+                               brdp->brdnr * STL_MAXPORTS + i);
 
-       return(0);
+       stl_brds[brdp->brdnr] = NULL;
+       kfree(brdp);
 }
 
+static struct pci_driver stl_pcidriver = {
+       .name = "stallion",
+       .id_table = stl_pcibrds,
+       .probe = stl_pciprobe,
+       .remove = __devexit_p(stl_pciremove)
+};
+
 /*****************************************************************************/
 
 /*
@@ -2761,17 +2458,18 @@ static inline int stl_initbrds(void)
 
 static int stl_getbrdstats(combrd_t __user *bp)
 {
-       stlbrd_t        *brdp;
-       stlpanel_t      *panelp;
-       int             i;
+       combrd_t        stl_brdstats;
+       struct stlbrd   *brdp;
+       struct stlpanel *panelp;
+       unsigned int i;
 
        if (copy_from_user(&stl_brdstats, bp, sizeof(combrd_t)))
                return -EFAULT;
        if (stl_brdstats.brd >= STL_MAXBRDS)
-               return(-ENODEV);
+               return -ENODEV;
        brdp = stl_brds[stl_brdstats.brd];
-       if (brdp == (stlbrd_t *) NULL)
-               return(-ENODEV);
+       if (brdp == NULL)
+               return -ENODEV;
 
        memset(&stl_brdstats, 0, sizeof(combrd_t));
        stl_brdstats.brd = brdp->brdnr;
@@ -2783,7 +2481,7 @@ static int stl_getbrdstats(combrd_t __user *bp)
        stl_brdstats.irq = brdp->irq;
        stl_brdstats.nrpanels = brdp->nrpanels;
        stl_brdstats.nrports = brdp->nrports;
-       for (i = 0; (i < brdp->nrpanels); i++) {
+       for (i = 0; i < brdp->nrpanels; i++) {
                panelp = brdp->panels[i];
                stl_brdstats.panels[i].panel = i;
                stl_brdstats.panels[i].hwid = panelp->hwid;
@@ -2799,24 +2497,24 @@ static int stl_getbrdstats(combrd_t __user *bp)
  *     Resolve the referenced port number into a port struct pointer.
  */
 
-static stlport_t *stl_getport(int brdnr, int panelnr, int portnr)
+static struct stlport *stl_getport(int brdnr, int panelnr, int portnr)
 {
-       stlbrd_t        *brdp;
-       stlpanel_t      *panelp;
+       struct stlbrd   *brdp;
+       struct stlpanel *panelp;
 
-       if ((brdnr < 0) || (brdnr >= STL_MAXBRDS))
-               return((stlport_t *) NULL);
+       if (brdnr < 0 || brdnr >= STL_MAXBRDS)
+               return NULL;
        brdp = stl_brds[brdnr];
-       if (brdp == (stlbrd_t *) NULL)
-               return((stlport_t *) NULL);
-       if ((panelnr < 0) || (panelnr >= brdp->nrpanels))
-               return((stlport_t *) NULL);
+       if (brdp == NULL)
+               return NULL;
+       if (panelnr < 0 || (unsigned int)panelnr >= brdp->nrpanels)
+               return NULL;
        panelp = brdp->panels[panelnr];
-       if (panelp == (stlpanel_t *) NULL)
-               return((stlport_t *) NULL);
-       if ((portnr < 0) || (portnr >= panelp->nrports))
-               return((stlport_t *) NULL);
-       return(panelp->ports[portnr]);
+       if (panelp == NULL)
+               return NULL;
+       if (portnr < 0 || (unsigned int)portnr >= panelp->nrports)
+               return NULL;
+       return panelp->ports[portnr];
 }
 
 /*****************************************************************************/
@@ -2827,8 +2525,9 @@ static stlport_t *stl_getport(int brdnr, int panelnr, int portnr)
  *     what port to get stats for (used through board control device).
  */
 
-static int stl_getportstats(stlport_t *portp, comstats_t __user *cp)
+static int stl_getportstats(struct stlport *portp, comstats_t __user *cp)
 {
+       comstats_t      stl_comstats;
        unsigned char   *head, *tail;
        unsigned long   flags;
 
@@ -2837,8 +2536,8 @@ static int stl_getportstats(stlport_t *portp, comstats_t __user *cp)
                        return -EFAULT;
                portp = stl_getport(stl_comstats.brd, stl_comstats.panel,
                        stl_comstats.port);
-               if (portp == (stlport_t *) NULL)
-                       return(-ENODEV);
+               if (portp == NULL)
+                       return -ENODEV;
        }
 
        portp->stats.state = portp->istate;
@@ -2853,25 +2552,24 @@ static int stl_getportstats(stlport_t *portp, comstats_t __user *cp)
        portp->stats.rxbuffered = 0;
 
        spin_lock_irqsave(&stallion_lock, flags);
-       if (portp->tty != (struct tty_struct *) NULL) {
+       if (portp->tty != NULL)
                if (portp->tty->driver_data == portp) {
                        portp->stats.ttystate = portp->tty->flags;
                        /* No longer available as a statistic */
                        portp->stats.rxbuffered = 1; /*portp->tty->flip.count; */
-                       if (portp->tty->termios != (struct termios *) NULL) {
+                       if (portp->tty->termios != NULL) {
                                portp->stats.cflags = portp->tty->termios->c_cflag;
                                portp->stats.iflags = portp->tty->termios->c_iflag;
                                portp->stats.oflags = portp->tty->termios->c_oflag;
                                portp->stats.lflags = portp->tty->termios->c_lflag;
                        }
                }
-       }
        spin_unlock_irqrestore(&stallion_lock, flags);
 
        head = portp->tx.head;
        tail = portp->tx.tail;
-       portp->stats.txbuffered = ((head >= tail) ? (head - tail) :
-               (STL_TXBUFSIZE - (tail - head)));
+       portp->stats.txbuffered = (head >= tail) ? (head - tail) :
+               (STL_TXBUFSIZE - (tail - head));
 
        portp->stats.signals = (unsigned long) stl_getsignals(portp);
 
@@ -2885,15 +2583,17 @@ static int stl_getportstats(stlport_t *portp, comstats_t __user *cp)
  *     Clear the port stats structure. We also return it zeroed out...
  */
 
-static int stl_clrportstats(stlport_t *portp, comstats_t __user *cp)
+static int stl_clrportstats(struct stlport *portp, comstats_t __user *cp)
 {
+       comstats_t      stl_comstats;
+
        if (!portp) {
                if (copy_from_user(&stl_comstats, cp, sizeof(comstats_t)))
                        return -EFAULT;
                portp = stl_getport(stl_comstats.brd, stl_comstats.panel,
                        stl_comstats.port);
-               if (portp == (stlport_t *) NULL)
-                       return(-ENODEV);
+               if (portp == NULL)
+                       return -ENODEV;
        }
 
        memset(&portp->stats, 0, sizeof(comstats_t));
@@ -2910,17 +2610,18 @@ static int stl_clrportstats(stlport_t *portp, comstats_t __user *cp)
  *     Return the entire driver ports structure to a user app.
  */
 
-static int stl_getportstruct(stlport_t __user *arg)
+static int stl_getportstruct(struct stlport __user *arg)
 {
-       stlport_t       *portp;
+       struct stlport  stl_dummyport;
+       struct stlport  *portp;
 
-       if (copy_from_user(&stl_dummyport, arg, sizeof(stlport_t)))
+       if (copy_from_user(&stl_dummyport, arg, sizeof(struct stlport)))
                return -EFAULT;
        portp = stl_getport(stl_dummyport.brdnr, stl_dummyport.panelnr,
                 stl_dummyport.portnr);
        if (!portp)
                return -ENODEV;
-       return copy_to_user(arg, portp, sizeof(stlport_t)) ? -EFAULT : 0;
+       return copy_to_user(arg, portp, sizeof(struct stlport)) ? -EFAULT : 0;
 }
 
 /*****************************************************************************/
@@ -2929,18 +2630,19 @@ static int stl_getportstruct(stlport_t __user *arg)
  *     Return the entire driver board structure to a user app.
  */
 
-static int stl_getbrdstruct(stlbrd_t __user *arg)
+static int stl_getbrdstruct(struct stlbrd __user *arg)
 {
-       stlbrd_t        *brdp;
+       struct stlbrd   stl_dummybrd;
+       struct stlbrd   *brdp;
 
-       if (copy_from_user(&stl_dummybrd, arg, sizeof(stlbrd_t)))
+       if (copy_from_user(&stl_dummybrd, arg, sizeof(struct stlbrd)))
                return -EFAULT;
-       if ((stl_dummybrd.brdnr < 0) || (stl_dummybrd.brdnr >= STL_MAXBRDS))
+       if (stl_dummybrd.brdnr >= STL_MAXBRDS)
                return -ENODEV;
        brdp = stl_brds[stl_dummybrd.brdnr];
        if (!brdp)
-               return(-ENODEV);
-       return copy_to_user(arg, brdp, sizeof(stlbrd_t)) ? -EFAULT : 0;
+               return -ENODEV;
+       return copy_to_user(arg, brdp, sizeof(struct stlbrd)) ? -EFAULT : 0;
 }
 
 /*****************************************************************************/
@@ -2956,14 +2658,11 @@ static int stl_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, uns
        int     brdnr, rc;
        void __user *argp = (void __user *)arg;
 
-#ifdef DEBUG
-       printk("stl_memioctl(ip=%x,fp=%x,cmd=%x,arg=%x)\n", (int) ip,
-               (int) fp, cmd, (int) arg);
-#endif
+       pr_debug("stl_memioctl(ip=%p,fp=%p,cmd=%x,arg=%lx)\n", ip, fp, cmd,arg);
 
        brdnr = iminor(ip);
        if (brdnr >= STL_MAXBRDS)
-               return(-ENODEV);
+               return -ENODEV;
        rc = 0;
 
        switch (cmd) {
@@ -2987,7 +2686,7 @@ static int stl_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, uns
                break;
        }
 
-       return(rc);
+       return rc;
 }
 
 static const struct tty_operations stl_ops = {
@@ -3014,55 +2713,6 @@ static const struct tty_operations stl_ops = {
        .tiocmset = stl_tiocmset,
 };
 
-/*****************************************************************************/
-
-static int __init stl_init(void)
-{
-       int i;
-       printk(KERN_INFO "%s: version %s\n", stl_drvtitle, stl_drvversion);
-
-       spin_lock_init(&stallion_lock);
-       spin_lock_init(&brd_lock);
-
-       stl_initbrds();
-
-       stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
-       if (!stl_serial)
-               return -1;
-
-/*
- *     Set up a character driver for per board stuff. This is mainly used
- *     to do stats ioctls on the ports.
- */
-       if (register_chrdev(STL_SIOMEMMAJOR, "staliomem", &stl_fsiomem))
-               printk("STALLION: failed to register serial board device\n");
-
-       stallion_class = class_create(THIS_MODULE, "staliomem");
-       for (i = 0; i < 4; i++)
-               class_device_create(stallion_class, NULL,
-                                   MKDEV(STL_SIOMEMMAJOR, i), NULL,
-                                   "staliomem%d", i);
-
-       stl_serial->owner = THIS_MODULE;
-       stl_serial->driver_name = stl_drvname;
-       stl_serial->name = "ttyE";
-       stl_serial->major = STL_SERIALMAJOR;
-       stl_serial->minor_start = 0;
-       stl_serial->type = TTY_DRIVER_TYPE_SERIAL;
-       stl_serial->subtype = SERIAL_TYPE_NORMAL;
-       stl_serial->init_termios = stl_deftermios;
-       stl_serial->flags = TTY_DRIVER_REAL_RAW;
-       tty_set_operations(stl_serial, &stl_ops);
-
-       if (tty_register_driver(stl_serial)) {
-               put_tty_driver(stl_serial);
-               printk("STALLION: failed to register serial driver\n");
-               return -1;
-       }
-
-       return 0;
-}
-
 /*****************************************************************************/
 /*                       CD1400 HARDWARE FUNCTIONS                           */
 /*****************************************************************************/
@@ -3073,21 +2723,21 @@ static int __init stl_init(void)
  *     (Maybe should make this inline...)
  */
 
-static int stl_cd1400getreg(stlport_t *portp, int regnr)
+static int stl_cd1400getreg(struct stlport *portp, int regnr)
 {
        outb((regnr + portp->uartaddr), portp->ioaddr);
        return inb(portp->ioaddr + EREG_DATA);
 }
 
-static void stl_cd1400setreg(stlport_t *portp, int regnr, int value)
+static void stl_cd1400setreg(struct stlport *portp, int regnr, int value)
 {
-       outb((regnr + portp->uartaddr), portp->ioaddr);
+       outb(regnr + portp->uartaddr, portp->ioaddr);
        outb(value, portp->ioaddr + EREG_DATA);
 }
 
-static int stl_cd1400updatereg(stlport_t *portp, int regnr, int value)
+static int stl_cd1400updatereg(struct stlport *portp, int regnr, int value)
 {
-       outb((regnr + portp->uartaddr), portp->ioaddr);
+       outb(regnr + portp->uartaddr, portp->ioaddr);
        if (inb(portp->ioaddr + EREG_DATA) != value) {
                outb(value, portp->ioaddr + EREG_DATA);
                return 1;
@@ -3103,16 +2753,14 @@ static int stl_cd1400updatereg(stlport_t *portp, int regnr, int value)
  *     identical when dealing with ports.
  */
 
-static int stl_cd1400panelinit(stlbrd_t *brdp, stlpanel_t *panelp)
+static int stl_cd1400panelinit(struct stlbrd *brdp, struct stlpanel *panelp)
 {
        unsigned int    gfrcr;
        int             chipmask, i, j;
        int             nrchips, uartaddr, ioaddr;
        unsigned long   flags;
 
-#ifdef DEBUG
-       printk("stl_panelinit(brdp=%x,panelp=%x)\n", (int) brdp, (int) panelp);
-#endif
+       pr_debug("stl_panelinit(brdp=%p,panelp=%p)\n", brdp, panelp);
 
        spin_lock_irqsave(&brd_lock, flags);
        BRDENABLE(panelp->brdnr, panelp->pagenr);
@@ -3122,13 +2770,12 @@ static int stl_cd1400panelinit(stlbrd_t *brdp, stlpanel_t *panelp)
  */
        chipmask = 0;
        nrchips = panelp->nrports / CD1400_PORTS;
-       for (i = 0; (i < nrchips); i++) {
+       for (i = 0; i < nrchips; i++) {
                if (brdp->brdtype == BRD_ECHPCI) {
                        outb((panelp->pagenr + (i >> 1)), brdp->ioctrl);
                        ioaddr = panelp->iobase;
-               } else {
+               } else
                        ioaddr = panelp->iobase + (EREG_BANKSIZE * (i >> 1));
-               }
                uartaddr = (i & 0x01) ? 0x080 : 0;
                outb((GFRCR + uartaddr), ioaddr);
                outb(0, (ioaddr + EREG_DATA));
@@ -3136,10 +2783,10 @@ static int stl_cd1400panelinit(stlbrd_t *brdp, stlpanel_t *panelp)
                outb(CCR_RESETFULL, (ioaddr + EREG_DATA));
                outb(CCR_RESETFULL, (ioaddr + EREG_DATA));
                outb((GFRCR + uartaddr), ioaddr);
-               for (j = 0; (j < CCR_MAXWAIT); j++) {
+               for (j = 0; j < CCR_MAXWAIT; j++)
                        if ((gfrcr = inb(ioaddr + EREG_DATA)) != 0)
                                break;
-               }
+
                if ((j >= CCR_MAXWAIT) || (gfrcr < 0x40) || (gfrcr > 0x60)) {
                        printk("STALLION: cd1400 not responding, "
                                "brd=%d panel=%d chip=%d\n",
@@ -3162,16 +2809,14 @@ static int stl_cd1400panelinit(stlbrd_t *brdp, stlpanel_t *panelp)
  *     Initialize hardware specific port registers.
  */
 
-static void stl_cd1400portinit(stlbrd_t *brdp, stlpanel_t *panelp, stlport_t *portp)
+static void stl_cd1400portinit(struct stlbrd *brdp, struct stlpanel *panelp, struct stlport *portp)
 {
        unsigned long flags;
-#ifdef DEBUG
-       printk("stl_cd1400portinit(brdp=%x,panelp=%x,portp=%x)\n",
-               (int) brdp, (int) panelp, (int) portp);
-#endif
+       pr_debug("stl_cd1400portinit(brdp=%p,panelp=%p,portp=%p)\n", brdp,
+                       panelp, portp);
 
-       if ((brdp == (stlbrd_t *) NULL) || (panelp == (stlpanel_t *) NULL) ||
-           (portp == (stlport_t *) NULL))
+       if ((brdp == NULL) || (panelp == NULL) ||
+           (portp == NULL))
                return;
 
        spin_lock_irqsave(&brd_lock, flags);
@@ -3195,15 +2840,13 @@ static void stl_cd1400portinit(stlbrd_t *brdp, stlpanel_t *panelp, stlport_t *po
  *     since it won't usually take too long to be ready.
  */
 
-static void stl_cd1400ccrwait(stlport_t *portp)
+static void stl_cd1400ccrwait(struct stlport *portp)
 {
        int     i;
 
-       for (i = 0; (i < CCR_MAXWAIT); i++) {
-               if (stl_cd1400getreg(portp, CCR) == 0) {
+       for (i = 0; i < CCR_MAXWAIT; i++)
+               if (stl_cd1400getreg(portp, CCR) == 0)
                        return;
-               }
-       }
 
        printk("STALLION: cd1400 not responding, port=%d panel=%d brd=%d\n",
                portp->portnr, portp->panelnr, portp->brdnr);
@@ -3216,9 +2859,9 @@ static void stl_cd1400ccrwait(stlport_t *portp)
  *     settings.
  */
 
-static void stl_cd1400setport(stlport_t *portp, struct termios *tiosp)
+static void stl_cd1400setport(struct stlport *portp, struct ktermios *tiosp)
 {
-       stlbrd_t        *brdp;
+       struct stlbrd   *brdp;
        unsigned long   flags;
        unsigned int    clkdiv, baudrate;
        unsigned char   cor1, cor2, cor3;
@@ -3242,7 +2885,7 @@ static void stl_cd1400setport(stlport_t *portp, struct termios *tiosp)
        sreroff = 0;
 
        brdp = stl_brds[portp->brdnr];
-       if (brdp == (stlbrd_t *) NULL)
+       if (brdp == NULL)
                return;
 
 /*
@@ -3339,8 +2982,8 @@ static void stl_cd1400setport(stlport_t *portp, struct termios *tiosp)
                baudrate = STL_CD1400MAXBAUD;
 
        if (baudrate > 0) {
-               for (clk = 0; (clk < CD1400_NUMCLKS); clk++) {
-                       clkdiv = ((portp->clk / stl_cd1400clkdivs[clk]) / baudrate);
+               for (clk = 0; clk < CD1400_NUMCLKS; clk++) {
+                       clkdiv = (portp->clk / stl_cd1400clkdivs[clk]) / baudrate;
                        if (clkdiv < 0x100)
                                break;
                }
@@ -3355,9 +2998,8 @@ static void stl_cd1400setport(stlport_t *portp, struct termios *tiosp)
                mcor2 |= MCOR2_DCD;
                sreron |= SRER_MODEM;
                portp->flags |= ASYNC_CHECK_CD;
-       } else {
+       } else
                portp->flags &= ~ASYNC_CHECK_CD;
-       }
 
 /*
  *     Setup cd1400 enhanced modes if we can. In particular we want to
@@ -3382,18 +3024,16 @@ static void stl_cd1400setport(stlport_t *portp, struct termios *tiosp)
  *     them all up.
  */
 
-#ifdef DEBUG
-       printk("SETPORT: portnr=%d panelnr=%d brdnr=%d\n",
+       pr_debug("SETPORT: portnr=%d panelnr=%d brdnr=%d\n",
                portp->portnr, portp->panelnr, portp->brdnr);
-       printk("    cor1=%x cor2=%x cor3=%x cor4=%x cor5=%x\n",
+       pr_debug("    cor1=%x cor2=%x cor3=%x cor4=%x cor5=%x\n",
                cor1, cor2, cor3, cor4, cor5);
-       printk("    mcor1=%x mcor2=%x rtpr=%x sreron=%x sreroff=%x\n",
+       pr_debug("    mcor1=%x mcor2=%x rtpr=%x sreron=%x sreroff=%x\n",
                mcor1, mcor2, rtpr, sreron, sreroff);
-       printk("    tcor=%x tbpr=%x rcor=%x rbpr=%x\n", clk, div, clk, div);
-       printk("    schr1=%x schr2=%x schr3=%x schr4=%x\n",
+       pr_debug("    tcor=%x tbpr=%x rcor=%x rbpr=%x\n", clk, div, clk, div);
+       pr_debug("    schr1=%x schr2=%x schr3=%x schr4=%x\n",
                tiosp->c_cc[VSTART], tiosp->c_cc[VSTOP],
                tiosp->c_cc[VSTART], tiosp->c_cc[VSTOP]);
-#endif
 
        spin_lock_irqsave(&brd_lock, flags);
        BRDENABLE(portp->brdnr, portp->pagenr);
@@ -3441,15 +3081,13 @@ static void stl_cd1400setport(stlport_t *portp, struct termios *tiosp)
  *     Set the state of the DTR and RTS signals.
  */
 
-static void stl_cd1400setsignals(stlport_t *portp, int dtr, int rts)
+static void stl_cd1400setsignals(struct stlport *portp, int dtr, int rts)
 {
        unsigned char   msvr1, msvr2;
        unsigned long   flags;
 
-#ifdef DEBUG
-       printk("stl_cd1400setsignals(portp=%x,dtr=%d,rts=%d)\n",
-               (int) portp, dtr, rts);
-#endif
+       pr_debug("stl_cd1400setsignals(portp=%p,dtr=%d,rts=%d)\n",
+                       portp, dtr, rts);
 
        msvr1 = 0;
        msvr2 = 0;
@@ -3475,15 +3113,13 @@ static void stl_cd1400setsignals(stlport_t *portp, int dtr, int rts)
  *     Return the state of the signals.
  */
 
-static int stl_cd1400getsignals(stlport_t *portp)
+static int stl_cd1400getsignals(struct stlport *portp)
 {
        unsigned char   msvr1, msvr2;
        unsigned long   flags;
        int             sigs;
 
-#ifdef DEBUG
-       printk("stl_cd1400getsignals(portp=%x)\n", (int) portp);
-#endif
+       pr_debug("stl_cd1400getsignals(portp=%p)\n", portp);
 
        spin_lock_irqsave(&brd_lock, flags);
        BRDENABLE(portp->brdnr, portp->pagenr);
@@ -3513,15 +3149,13 @@ static int stl_cd1400getsignals(stlport_t *portp)
  *     Enable/Disable the Transmitter and/or Receiver.
  */
 
-static void stl_cd1400enablerxtx(stlport_t *portp, int rx, int tx)
+static void stl_cd1400enablerxtx(struct stlport *portp, int rx, int tx)
 {
        unsigned char   ccr;
        unsigned long   flags;
 
-#ifdef DEBUG
-       printk("stl_cd1400enablerxtx(portp=%x,rx=%d,tx=%d)\n",
-               (int) portp, rx, tx);
-#endif
+       pr_debug("stl_cd1400enablerxtx(portp=%p,rx=%d,tx=%d)\n", portp, rx, tx);
+
        ccr = 0;
 
        if (tx == 0)
@@ -3549,15 +3183,12 @@ static void stl_cd1400enablerxtx(stlport_t *portp, int rx, int tx)
  *     Start/stop the Transmitter and/or Receiver.
  */
 
-static void stl_cd1400startrxtx(stlport_t *portp, int rx, int tx)
+static void stl_cd1400startrxtx(struct stlport *portp, int rx, int tx)
 {
        unsigned char   sreron, sreroff;
        unsigned long   flags;
 
-#ifdef DEBUG
-       printk("stl_cd1400startrxtx(portp=%x,rx=%d,tx=%d)\n",
-               (int) portp, rx, tx);
-#endif
+       pr_debug("stl_cd1400startrxtx(portp=%p,rx=%d,tx=%d)\n", portp, rx, tx);
 
        sreron = 0;
        sreroff = 0;
@@ -3589,13 +3220,12 @@ static void stl_cd1400startrxtx(stlport_t *portp, int rx, int tx)
  *     Disable all interrupts from this port.
  */
 
-static void stl_cd1400disableintrs(stlport_t *portp)
+static void stl_cd1400disableintrs(struct stlport *portp)
 {
        unsigned long   flags;
 
-#ifdef DEBUG
-       printk("stl_cd1400disableintrs(portp=%x)\n", (int) portp);
-#endif
+       pr_debug("stl_cd1400disableintrs(portp=%p)\n", portp);
+
        spin_lock_irqsave(&brd_lock, flags);
        BRDENABLE(portp->brdnr, portp->pagenr);
        stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
@@ -3606,13 +3236,11 @@ static void stl_cd1400disableintrs(stlport_t *portp)
 
 /*****************************************************************************/
 
-static void stl_cd1400sendbreak(stlport_t *portp, int len)
+static void stl_cd1400sendbreak(struct stlport *portp, int len)
 {
        unsigned long   flags;
 
-#ifdef DEBUG
-       printk("stl_cd1400sendbreak(portp=%x,len=%d)\n", (int) portp, len);
-#endif
+       pr_debug("stl_cd1400sendbreak(portp=%p,len=%d)\n", portp, len);
 
        spin_lock_irqsave(&brd_lock, flags);
        BRDENABLE(portp->brdnr, portp->pagenr);
@@ -3633,19 +3261,17 @@ static void stl_cd1400sendbreak(stlport_t *portp, int len)
  *     Take flow control actions...
  */
 
-static void stl_cd1400flowctrl(stlport_t *portp, int state)
+static void stl_cd1400flowctrl(struct stlport *portp, int state)
 {
        struct tty_struct       *tty;
        unsigned long           flags;
 
-#ifdef DEBUG
-       printk("stl_cd1400flowctrl(portp=%x,state=%x)\n", (int) portp, state);
-#endif
+       pr_debug("stl_cd1400flowctrl(portp=%p,state=%x)\n", portp, state);
 
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return;
        tty = portp->tty;
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return;
 
        spin_lock_irqsave(&brd_lock, flags);
@@ -3697,19 +3323,17 @@ static void stl_cd1400flowctrl(stlport_t *portp, int state)
  *     Send a flow control character...
  */
 
-static void stl_cd1400sendflow(stlport_t *portp, int state)
+static void stl_cd1400sendflow(struct stlport *portp, int state)
 {
        struct tty_struct       *tty;
        unsigned long           flags;
 
-#ifdef DEBUG
-       printk("stl_cd1400sendflow(portp=%x,state=%x)\n", (int) portp, state);
-#endif
+       pr_debug("stl_cd1400sendflow(portp=%p,state=%x)\n", portp, state);
 
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return;
        tty = portp->tty;
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return;
 
        spin_lock_irqsave(&brd_lock, flags);
@@ -3732,15 +3356,13 @@ static void stl_cd1400sendflow(stlport_t *portp, int state)
 
 /*****************************************************************************/
 
-static void stl_cd1400flush(stlport_t *portp)
+static void stl_cd1400flush(struct stlport *portp)
 {
        unsigned long   flags;
 
-#ifdef DEBUG
-       printk("stl_cd1400flush(portp=%x)\n", (int) portp);
-#endif
+       pr_debug("stl_cd1400flush(portp=%p)\n", portp);
 
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return;
 
        spin_lock_irqsave(&brd_lock, flags);
@@ -3763,13 +3385,11 @@ static void stl_cd1400flush(stlport_t *portp)
  *     maintains the busy port flag.
  */
 
-static int stl_cd1400datastate(stlport_t *portp)
+static int stl_cd1400datastate(struct stlport *portp)
 {
-#ifdef DEBUG
-       printk("stl_cd1400datastate(portp=%x)\n", (int) portp);
-#endif
+       pr_debug("stl_cd1400datastate(portp=%p)\n", portp);
 
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return 0;
 
        return test_bit(ASYI_TXBUSY, &portp->istate) ? 1 : 0;
@@ -3781,14 +3401,11 @@ static int stl_cd1400datastate(stlport_t *portp)
  *     Interrupt service routine for cd1400 EasyIO boards.
  */
 
-static void stl_cd1400eiointr(stlpanel_t *panelp, unsigned int iobase)
+static void stl_cd1400eiointr(struct stlpanel *panelp, unsigned int iobase)
 {
        unsigned char   svrtype;
 
-#ifdef DEBUG
-       printk("stl_cd1400eiointr(panelp=%x,iobase=%x)\n",
-               (int) panelp, iobase);
-#endif
+       pr_debug("stl_cd1400eiointr(panelp=%p,iobase=%x)\n", panelp, iobase);
 
        spin_lock(&brd_lock);
        outb(SVRR, iobase);
@@ -3814,14 +3431,11 @@ static void stl_cd1400eiointr(stlpanel_t *panelp, unsigned int iobase)
  *     Interrupt service routine for cd1400 panels.
  */
 
-static void stl_cd1400echintr(stlpanel_t *panelp, unsigned int iobase)
+static void stl_cd1400echintr(struct stlpanel *panelp, unsigned int iobase)
 {
        unsigned char   svrtype;
 
-#ifdef DEBUG
-       printk("stl_cd1400echintr(panelp=%x,iobase=%x)\n", (int) panelp,
-               iobase);
-#endif
+       pr_debug("stl_cd1400echintr(panelp=%p,iobase=%x)\n", panelp, iobase);
 
        outb(SVRR, iobase);
        svrtype = inb(iobase + EREG_DATA);
@@ -3843,7 +3457,7 @@ static void stl_cd1400echintr(stlpanel_t *panelp, unsigned int iobase)
  *     this is the only way to generate them on the cd1400.
  */
 
-static inline int stl_cd1400breakisr(stlport_t *portp, int ioaddr)
+static int stl_cd1400breakisr(struct stlport *portp, int ioaddr)
 {
        if (portp->brklen == 1) {
                outb((COR2 + portp->uartaddr), ioaddr);
@@ -3885,16 +3499,14 @@ static inline int stl_cd1400breakisr(stlport_t *portp, int ioaddr)
  *     be NULL if the buffer has been freed.
  */
 
-static void stl_cd1400txisr(stlpanel_t *panelp, int ioaddr)
+static void stl_cd1400txisr(struct stlpanel *panelp, int ioaddr)
 {
-       stlport_t       *portp;
+       struct stlport  *portp;
        int             len, stlen;
        char            *head, *tail;
        unsigned char   ioack, srer;
 
-#ifdef DEBUG
-       printk("stl_cd1400txisr(panelp=%x,ioaddr=%x)\n", (int) panelp, ioaddr);
-#endif
+       pr_debug("stl_cd1400txisr(panelp=%p,ioaddr=%x)\n", panelp, ioaddr);
 
        ioack = inb(ioaddr + EREG_TXACK);
        if (((ioack & panelp->ackmask) != 0) ||
@@ -3933,9 +3545,9 @@ static void stl_cd1400txisr(stlpanel_t *panelp, int ioaddr)
                }
                outb(srer, (ioaddr + EREG_DATA));
        } else {
-               len = MIN(len, CD1400_TXFIFOSIZE);
+               len = min(len, CD1400_TXFIFOSIZE);
                portp->stats.txtotal += len;
-               stlen = MIN(len, ((portp->tx.buf + STL_TXBUFSIZE) - tail));
+               stlen = min(len, ((portp->tx.buf + STL_TXBUFSIZE) - tail));
                outb((TDR + portp->uartaddr), ioaddr);
                outsb((ioaddr + EREG_DATA), tail, stlen);
                len -= stlen;
@@ -3966,17 +3578,15 @@ stl_txalldone:
  *     shutdown a port not in user context. Need to handle this case.
  */
 
-static void stl_cd1400rxisr(stlpanel_t *panelp, int ioaddr)
+static void stl_cd1400rxisr(struct stlpanel *panelp, int ioaddr)
 {
-       stlport_t               *portp;
+       struct stlport          *portp;
        struct tty_struct       *tty;
        unsigned int            ioack, len, buflen;
        unsigned char           status;
        char                    ch;
 
-#ifdef DEBUG
-       printk("stl_cd1400rxisr(panelp=%x,ioaddr=%x)\n", (int) panelp, ioaddr);
-#endif
+       pr_debug("stl_cd1400rxisr(panelp=%p,ioaddr=%x)\n", panelp, ioaddr);
 
        ioack = inb(ioaddr + EREG_RXACK);
        if ((ioack & panelp->ackmask) != 0) {
@@ -3990,13 +3600,13 @@ static void stl_cd1400rxisr(stlpanel_t *panelp, int ioaddr)
                outb((RDCR + portp->uartaddr), ioaddr);
                len = inb(ioaddr + EREG_DATA);
                if (tty == NULL || (buflen = tty_buffer_request_room(tty, len)) == 0) {
-                       len = MIN(len, sizeof(stl_unwanted));
+                       len = min(len, sizeof(stl_unwanted));
                        outb((RDSR + portp->uartaddr), ioaddr);
                        insb((ioaddr + EREG_DATA), &stl_unwanted[0], len);
                        portp->stats.rxlost += len;
                        portp->stats.rxtotal += len;
                } else {
-                       len = MIN(len, buflen);
+                       len = min(len, buflen);
                        if (len > 0) {
                                unsigned char *ptr;
                                outb((RDSR + portp->uartaddr), ioaddr);
@@ -4033,18 +3643,16 @@ static void stl_cd1400rxisr(stlpanel_t *panelp, int ioaddr)
                                                do_SAK(tty);
                                                BRDENABLE(portp->brdnr, portp->pagenr);
                                        }
-                               } else if (status & ST_PARITY) {
+                               } else if (status & ST_PARITY)
                                        status = TTY_PARITY;
-                               } else if (status & ST_FRAMING) {
+                               else if (status & ST_FRAMING)
                                        status = TTY_FRAME;
-                               } else if(status & ST_OVERRUN) {
+                               else if(status & ST_OVERRUN)
                                        status = TTY_OVERRUN;
-                               } else {
+                               else
                                        status = 0;
-                               }
-                       } else {
+                       } else
                                status = 0;
-                       }
                        tty_insert_flip_char(tty, ch, status);
                        tty_schedule_flip(tty);
                }
@@ -4066,15 +3674,13 @@ stl_rxalldone:
  *     processing routine.
  */
 
-static void stl_cd1400mdmisr(stlpanel_t *panelp, int ioaddr)
+static void stl_cd1400mdmisr(struct stlpanel *panelp, int ioaddr)
 {
-       stlport_t       *portp;
+       struct stlport  *portp;
        unsigned int    ioack;
        unsigned char   misr;
 
-#ifdef DEBUG
-       printk("stl_cd1400mdmisr(panelp=%x)\n", (int) panelp);
-#endif
+       pr_debug("stl_cd1400mdmisr(panelp=%p)\n", panelp);
 
        ioack = inb(ioaddr + EREG_MDACK);
        if (((ioack & panelp->ackmask) != 0) ||
@@ -4106,19 +3712,19 @@ static void stl_cd1400mdmisr(stlpanel_t *panelp, int ioaddr)
  *     (Maybe should make this inline...)
  */
 
-static int stl_sc26198getreg(stlport_t *portp, int regnr)
+static int stl_sc26198getreg(struct stlport *portp, int regnr)
 {
        outb((regnr | portp->uartaddr), (portp->ioaddr + XP_ADDR));
        return inb(portp->ioaddr + XP_DATA);
 }
 
-static void stl_sc26198setreg(stlport_t *portp, int regnr, int value)
+static void stl_sc26198setreg(struct stlport *portp, int regnr, int value)
 {
        outb((regnr | portp->uartaddr), (portp->ioaddr + XP_ADDR));
        outb(value, (portp->ioaddr + XP_DATA));
 }
 
-static int stl_sc26198updatereg(stlport_t *portp, int regnr, int value)
+static int stl_sc26198updatereg(struct stlport *portp, int regnr, int value)
 {
        outb((regnr | portp->uartaddr), (portp->ioaddr + XP_ADDR));
        if (inb(portp->ioaddr + XP_DATA) != value) {
@@ -4134,14 +3740,14 @@ static int stl_sc26198updatereg(stlport_t *portp, int regnr, int value)
  *     Functions to get and set the sc26198 global registers.
  */
 
-static int stl_sc26198getglobreg(stlport_t *portp, int regnr)
+static int stl_sc26198getglobreg(struct stlport *portp, int regnr)
 {
        outb(regnr, (portp->ioaddr + XP_ADDR));
        return inb(portp->ioaddr + XP_DATA);
 }
 
 #if 0
-static void stl_sc26198setglobreg(stlport_t *portp, int regnr, int value)
+static void stl_sc26198setglobreg(struct stlport *portp, int regnr, int value)
 {
        outb(regnr, (portp->ioaddr + XP_ADDR));
        outb(value, (portp->ioaddr + XP_DATA));
@@ -4156,15 +3762,12 @@ static void stl_sc26198setglobreg(stlport_t *portp, int regnr, int value)
  *     identical when dealing with ports.
  */
 
-static int stl_sc26198panelinit(stlbrd_t *brdp, stlpanel_t *panelp)
+static int stl_sc26198panelinit(struct stlbrd *brdp, struct stlpanel *panelp)
 {
        int     chipmask, i;
        int     nrchips, ioaddr;
 
-#ifdef DEBUG
-       printk("stl_sc26198panelinit(brdp=%x,panelp=%x)\n",
-               (int) brdp, (int) panelp);
-#endif
+       pr_debug("stl_sc26198panelinit(brdp=%p,panelp=%p)\n", brdp, panelp);
 
        BRDENABLE(panelp->brdnr, panelp->pagenr);
 
@@ -4176,7 +3779,7 @@ static int stl_sc26198panelinit(stlbrd_t *brdp, stlpanel_t *panelp)
        if (brdp->brdtype == BRD_ECHPCI)
                outb(panelp->pagenr, brdp->ioctrl);
 
-       for (i = 0; (i < nrchips); i++) {
+       for (i = 0; i < nrchips; i++) {
                ioaddr = panelp->iobase + (i * 4); 
                outb(SCCR, (ioaddr + XP_ADDR));
                outb(CR_RESETALL, (ioaddr + XP_DATA));
@@ -4204,15 +3807,13 @@ static int stl_sc26198panelinit(stlbrd_t *brdp, stlpanel_t *panelp)
  *     Initialize hardware specific port registers.
  */
 
-static void stl_sc26198portinit(stlbrd_t *brdp, stlpanel_t *panelp, stlport_t *portp)
+static void stl_sc26198portinit(struct stlbrd *brdp, struct stlpanel *panelp, struct stlport *portp)
 {
-#ifdef DEBUG
-       printk("stl_sc26198portinit(brdp=%x,panelp=%x,portp=%x)\n",
-               (int) brdp, (int) panelp, (int) portp);
-#endif
+       pr_debug("stl_sc26198portinit(brdp=%p,panelp=%p,portp=%p)\n", brdp,
+                       panelp, portp);
 
-       if ((brdp == (stlbrd_t *) NULL) || (panelp == (stlpanel_t *) NULL) ||
-           (portp == (stlport_t *) NULL))
+       if ((brdp == NULL) || (panelp == NULL) ||
+           (portp == NULL))
                return;
 
        portp->ioaddr = panelp->iobase + ((portp->portnr < 8) ? 0 : 4);
@@ -4232,9 +3833,9 @@ static void stl_sc26198portinit(stlbrd_t *brdp, stlpanel_t *panelp, stlport_t *p
  *     settings.
  */
 
-static void stl_sc26198setport(stlport_t *portp, struct termios *tiosp)
+static void stl_sc26198setport(struct stlport *portp, struct ktermios *tiosp)
 {
-       stlbrd_t        *brdp;
+       struct stlbrd   *brdp;
        unsigned long   flags;
        unsigned int    baudrate;
        unsigned char   mr0, mr1, mr2, clk;
@@ -4249,7 +3850,7 @@ static void stl_sc26198setport(stlport_t *portp, struct termios *tiosp)
        imroff = 0;
 
        brdp = stl_brds[portp->brdnr];
-       if (brdp == (stlbrd_t *) NULL)
+       if (brdp == NULL)
                return;
 
 /*
@@ -4298,9 +3899,8 @@ static void stl_sc26198setport(stlport_t *portp, struct termios *tiosp)
                        mr1 |= (MR1_PARENB | MR1_PARODD);
                else
                        mr1 |= (MR1_PARENB | MR1_PAREVEN);
-       } else {
+       } else
                mr1 |= MR1_PARNONE;
-       }
 
        mr1 |= MR1_ERRBLOCK;
 
@@ -4340,12 +3940,10 @@ static void stl_sc26198setport(stlport_t *portp, struct termios *tiosp)
        if (baudrate > STL_SC26198MAXBAUD)
                baudrate = STL_SC26198MAXBAUD;
 
-       if (baudrate > 0) {
-               for (clk = 0; (clk < SC26198_NRBAUDS); clk++) {
+       if (baudrate > 0)
+               for (clk = 0; clk < SC26198_NRBAUDS; clk++)
                        if (baudrate <= sc26198_baudtable[clk])
                                break;
-               }
-       }
 
 /*
  *     Check what form of modem signaling is required and set it up.
@@ -4367,9 +3965,9 @@ static void stl_sc26198setport(stlport_t *portp, struct termios *tiosp)
        if (tiosp->c_iflag & IXON) {
                mr0 |= MR0_SWFTX | MR0_SWFT;
                imron |= IR_XONXOFF;
-       } else {
+       } else
                imroff |= IR_XONXOFF;
-       }
+
        if (tiosp->c_iflag & IXOFF)
                mr0 |= MR0_SWFRX;
 
@@ -4383,15 +3981,13 @@ static void stl_sc26198setport(stlport_t *portp, struct termios *tiosp)
  *     them all up.
  */
 
-#ifdef DEBUG
-       printk("SETPORT: portnr=%d panelnr=%d brdnr=%d\n",
+       pr_debug("SETPORT: portnr=%d panelnr=%d brdnr=%d\n",
                portp->portnr, portp->panelnr, portp->brdnr);
-       printk("    mr0=%x mr1=%x mr2=%x clk=%x\n", mr0, mr1, mr2, clk);
-       printk("    iopr=%x imron=%x imroff=%x\n", iopr, imron, imroff);
-       printk("    schr1=%x schr2=%x schr3=%x schr4=%x\n",
+       pr_debug("    mr0=%x mr1=%x mr2=%x clk=%x\n", mr0, mr1, mr2, clk);
+       pr_debug("    iopr=%x imron=%x imroff=%x\n", iopr, imron, imroff);
+       pr_debug("    schr1=%x schr2=%x schr3=%x schr4=%x\n",
                tiosp->c_cc[VSTART], tiosp->c_cc[VSTOP],
                tiosp->c_cc[VSTART], tiosp->c_cc[VSTOP]);
-#endif
 
        spin_lock_irqsave(&brd_lock, flags);
        BRDENABLE(portp->brdnr, portp->pagenr);
@@ -4429,15 +4025,13 @@ static void stl_sc26198setport(stlport_t *portp, struct termios *tiosp)
  *     Set the state of the DTR and RTS signals.
  */
 
-static void stl_sc26198setsignals(stlport_t *portp, int dtr, int rts)
+static void stl_sc26198setsignals(struct stlport *portp, int dtr, int rts)
 {
        unsigned char   iopioron, iopioroff;
        unsigned long   flags;
 
-#ifdef DEBUG
-       printk("stl_sc26198setsignals(portp=%x,dtr=%d,rts=%d)\n",
-               (int) portp, dtr, rts);
-#endif
+       pr_debug("stl_sc26198setsignals(portp=%p,dtr=%d,rts=%d)\n", portp,
+                       dtr, rts);
 
        iopioron = 0;
        iopioroff = 0;
@@ -4464,15 +4058,13 @@ static void stl_sc26198setsignals(stlport_t *portp, int dtr, int rts)
  *     Return the state of the signals.
  */
 
-static int stl_sc26198getsignals(stlport_t *portp)
+static int stl_sc26198getsignals(struct stlport *portp)
 {
        unsigned char   ipr;
        unsigned long   flags;
        int             sigs;
 
-#ifdef DEBUG
-       printk("stl_sc26198getsignals(portp=%x)\n", (int) portp);
-#endif
+       pr_debug("stl_sc26198getsignals(portp=%p)\n", portp);
 
        spin_lock_irqsave(&brd_lock, flags);
        BRDENABLE(portp->brdnr, portp->pagenr);
@@ -4495,15 +4087,12 @@ static int stl_sc26198getsignals(stlport_t *portp)
  *     Enable/Disable the Transmitter and/or Receiver.
  */
 
-static void stl_sc26198enablerxtx(stlport_t *portp, int rx, int tx)
+static void stl_sc26198enablerxtx(struct stlport *portp, int rx, int tx)
 {
        unsigned char   ccr;
        unsigned long   flags;
 
-#ifdef DEBUG
-       printk("stl_sc26198enablerxtx(portp=%x,rx=%d,tx=%d)\n",
-               (int) portp, rx, tx);
-#endif
+       pr_debug("stl_sc26198enablerxtx(portp=%p,rx=%d,tx=%d)\n", portp, rx,tx);
 
        ccr = portp->crenable;
        if (tx == 0)
@@ -4529,15 +4118,12 @@ static void stl_sc26198enablerxtx(stlport_t *portp, int rx, int tx)
  *     Start/stop the Transmitter and/or Receiver.
  */
 
-static void stl_sc26198startrxtx(stlport_t *portp, int rx, int tx)
+static void stl_sc26198startrxtx(struct stlport *portp, int rx, int tx)
 {
        unsigned char   imr;
        unsigned long   flags;
 
-#ifdef DEBUG
-       printk("stl_sc26198startrxtx(portp=%x,rx=%d,tx=%d)\n",
-               (int) portp, rx, tx);
-#endif
+       pr_debug("stl_sc26198startrxtx(portp=%p,rx=%d,tx=%d)\n", portp, rx, tx);
 
        imr = portp->imr;
        if (tx == 0)
@@ -4565,13 +4151,11 @@ static void stl_sc26198startrxtx(stlport_t *portp, int rx, int tx)
  *     Disable all interrupts from this port.
  */
 
-static void stl_sc26198disableintrs(stlport_t *portp)
+static void stl_sc26198disableintrs(struct stlport *portp)
 {
        unsigned long   flags;
 
-#ifdef DEBUG
-       printk("stl_sc26198disableintrs(portp=%x)\n", (int) portp);
-#endif
+       pr_debug("stl_sc26198disableintrs(portp=%p)\n", portp);
 
        spin_lock_irqsave(&brd_lock, flags);
        BRDENABLE(portp->brdnr, portp->pagenr);
@@ -4583,22 +4167,20 @@ static void stl_sc26198disableintrs(stlport_t *portp)
 
 /*****************************************************************************/
 
-static void stl_sc26198sendbreak(stlport_t *portp, int len)
+static void stl_sc26198sendbreak(struct stlport *portp, int len)
 {
        unsigned long   flags;
 
-#ifdef DEBUG
-       printk("stl_sc26198sendbreak(portp=%x,len=%d)\n", (int) portp, len);
-#endif
+       pr_debug("stl_sc26198sendbreak(portp=%p,len=%d)\n", portp, len);
 
        spin_lock_irqsave(&brd_lock, flags);
        BRDENABLE(portp->brdnr, portp->pagenr);
        if (len == 1) {
                stl_sc26198setreg(portp, SCCR, CR_TXSTARTBREAK);
                portp->stats.txbreaks++;
-       } else {
+       } else
                stl_sc26198setreg(portp, SCCR, CR_TXSTOPBREAK);
-       }
+
        BRDDISABLE(portp->brdnr);
        spin_unlock_irqrestore(&brd_lock, flags);
 }
@@ -4609,20 +4191,18 @@ static void stl_sc26198sendbreak(stlport_t *portp, int len)
  *     Take flow control actions...
  */
 
-static void stl_sc26198flowctrl(stlport_t *portp, int state)
+static void stl_sc26198flowctrl(struct stlport *portp, int state)
 {
        struct tty_struct       *tty;
        unsigned long           flags;
        unsigned char           mr0;
 
-#ifdef DEBUG
-       printk("stl_sc26198flowctrl(portp=%x,state=%x)\n", (int) portp, state);
-#endif
+       pr_debug("stl_sc26198flowctrl(portp=%p,state=%x)\n", portp, state);
 
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return;
        tty = portp->tty;
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return;
 
        spin_lock_irqsave(&brd_lock, flags);
@@ -4680,20 +4260,18 @@ static void stl_sc26198flowctrl(stlport_t *portp, int state)
  *     Send a flow control character.
  */
 
-static void stl_sc26198sendflow(stlport_t *portp, int state)
+static void stl_sc26198sendflow(struct stlport *portp, int state)
 {
        struct tty_struct       *tty;
        unsigned long           flags;
        unsigned char           mr0;
 
-#ifdef DEBUG
-       printk("stl_sc26198sendflow(portp=%x,state=%x)\n", (int) portp, state);
-#endif
+       pr_debug("stl_sc26198sendflow(portp=%p,state=%x)\n", portp, state);
 
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return;
        tty = portp->tty;
-       if (tty == (struct tty_struct *) NULL)
+       if (tty == NULL)
                return;
 
        spin_lock_irqsave(&brd_lock, flags);
@@ -4721,15 +4299,13 @@ static void stl_sc26198sendflow(stlport_t *portp, int state)
 
 /*****************************************************************************/
 
-static void stl_sc26198flush(stlport_t *portp)
+static void stl_sc26198flush(struct stlport *portp)
 {
        unsigned long   flags;
 
-#ifdef DEBUG
-       printk("stl_sc26198flush(portp=%x)\n", (int) portp);
-#endif
+       pr_debug("stl_sc26198flush(portp=%p)\n", portp);
 
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return;
 
        spin_lock_irqsave(&brd_lock, flags);
@@ -4751,16 +4327,14 @@ static void stl_sc26198flush(stlport_t *portp)
  *     check the port statusy register to be sure.
  */
 
-static int stl_sc26198datastate(stlport_t *portp)
+static int stl_sc26198datastate(struct stlport *portp)
 {
        unsigned long   flags;
        unsigned char   sr;
 
-#ifdef DEBUG
-       printk("stl_sc26198datastate(portp=%x)\n", (int) portp);
-#endif
+       pr_debug("stl_sc26198datastate(portp=%p)\n", portp);
 
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return 0;
        if (test_bit(ASYI_TXBUSY, &portp->istate))
                return 1;
@@ -4781,18 +4355,16 @@ static int stl_sc26198datastate(stlport_t *portp)
  *     to process a command...
  */
 
-static void stl_sc26198wait(stlport_t *portp)
+static void stl_sc26198wait(struct stlport *portp)
 {
        int     i;
 
-#ifdef DEBUG
-       printk("stl_sc26198wait(portp=%x)\n", (int) portp);
-#endif
+       pr_debug("stl_sc26198wait(portp=%p)\n", portp);
 
-       if (portp == (stlport_t *) NULL)
+       if (portp == NULL)
                return;
 
-       for (i = 0; (i < 20); i++)
+       for (i = 0; i < 20; i++)
                stl_sc26198getglobreg(portp, TSTR);
 }
 
@@ -4804,7 +4376,7 @@ static void stl_sc26198wait(stlport_t *portp)
  *     automatic flow control modes of the sc26198.
  */
 
-static inline void stl_sc26198txunflow(stlport_t *portp, struct tty_struct *tty)
+static void stl_sc26198txunflow(struct stlport *portp, struct tty_struct *tty)
 {
        unsigned char   mr0;
 
@@ -4822,9 +4394,9 @@ static inline void stl_sc26198txunflow(stlport_t *portp, struct tty_struct *tty)
  *     Interrupt service routine for sc26198 panels.
  */
 
-static void stl_sc26198intr(stlpanel_t *panelp, unsigned int iobase)
+static void stl_sc26198intr(struct stlpanel *panelp, unsigned int iobase)
 {
-       stlport_t       *portp;
+       struct stlport  *portp;
        unsigned int    iack;
 
        spin_lock(&brd_lock);
@@ -4860,16 +4432,14 @@ static void stl_sc26198intr(stlpanel_t *panelp, unsigned int iobase)
  *     be NULL if the buffer has been freed.
  */
 
-static void stl_sc26198txisr(stlport_t *portp)
+static void stl_sc26198txisr(struct stlport *portp)
 {
        unsigned int    ioaddr;
        unsigned char   mr0;
        int             len, stlen;
        char            *head, *tail;
 
-#ifdef DEBUG
-       printk("stl_sc26198txisr(portp=%x)\n", (int) portp);
-#endif
+       pr_debug("stl_sc26198txisr(portp=%p)\n", portp);
 
        ioaddr = portp->ioaddr;
        head = portp->tx.head;
@@ -4894,9 +4464,9 @@ static void stl_sc26198txisr(stlport_t *portp)
                        outb(mr0, (ioaddr + XP_DATA));
                }
        } else {
-               len = MIN(len, SC26198_TXFIFOSIZE);
+               len = min(len, SC26198_TXFIFOSIZE);
                portp->stats.txtotal += len;
-               stlen = MIN(len, ((portp->tx.buf + STL_TXBUFSIZE) - tail));
+               stlen = min(len, ((portp->tx.buf + STL_TXBUFSIZE) - tail));
                outb(GTXFIFO, (ioaddr + XP_ADDR));
                outsb((ioaddr + XP_DATA), tail, stlen);
                len -= stlen;
@@ -4923,14 +4493,12 @@ static void stl_sc26198txisr(stlport_t *portp)
  *     shutdown a port not in user context. Need to handle this case.
  */
 
-static void stl_sc26198rxisr(stlport_t *portp, unsigned int iack)
+static void stl_sc26198rxisr(struct stlport *portp, unsigned int iack)
 {
        struct tty_struct       *tty;
        unsigned int            len, buflen, ioaddr;
 
-#ifdef DEBUG
-       printk("stl_sc26198rxisr(portp=%x,iack=%x)\n", (int) portp, iack);
-#endif
+       pr_debug("stl_sc26198rxisr(portp=%p,iack=%x)\n", portp, iack);
 
        tty = portp->tty;
        ioaddr = portp->ioaddr;
@@ -4939,13 +4507,13 @@ static void stl_sc26198rxisr(stlport_t *portp, unsigned int iack)
 
        if ((iack & IVR_TYPEMASK) == IVR_RXDATA) {
                if (tty == NULL || (buflen = tty_buffer_request_room(tty, len)) == 0) {
-                       len = MIN(len, sizeof(stl_unwanted));
+                       len = min(len, sizeof(stl_unwanted));
                        outb(GRXFIFO, (ioaddr + XP_ADDR));
                        insb((ioaddr + XP_DATA), &stl_unwanted[0], len);
                        portp->stats.rxlost += len;
                        portp->stats.rxtotal += len;
                } else {
-                       len = MIN(len, buflen);
+                       len = min(len, buflen);
                        if (len > 0) {
                                unsigned char *ptr;
                                outb(GRXFIFO, (ioaddr + XP_ADDR));
@@ -4965,8 +4533,8 @@ static void stl_sc26198rxisr(stlport_t *portp, unsigned int iack)
  *     flow control modes of the sc26198.
  */
        if (test_bit(ASYI_TXFLOWED, &portp->istate)) {
-               if ((tty != (struct tty_struct *) NULL) &&
-                   (tty->termios != (struct termios *) NULL) &&
+               if ((tty != NULL) &&
+                   (tty->termios != NULL) &&
                    (tty->termios->c_iflag & IXANY)) {
                        stl_sc26198txunflow(portp, tty);
                }
@@ -4979,7 +4547,7 @@ static void stl_sc26198rxisr(stlport_t *portp, unsigned int iack)
  *     Process an RX bad character.
  */
 
-static inline void stl_sc26198rxbadch(stlport_t *portp, unsigned char status, char ch)
+static void stl_sc26198rxbadch(struct stlport *portp, unsigned char status, char ch)
 {
        struct tty_struct       *tty;
        unsigned int            ioaddr;
@@ -4996,7 +4564,7 @@ static inline void stl_sc26198rxbadch(stlport_t *portp, unsigned char status, ch
        if (status & SR_RXBREAK)
                portp->stats.rxbreaks++;
 
-       if ((tty != (struct tty_struct *) NULL) &&
+       if ((tty != NULL) &&
            ((portp->rxignoremsk & status) == 0)) {
                if (portp->rxmarkmsk & status) {
                        if (status & SR_RXBREAK) {
@@ -5005,18 +4573,16 @@ static inline void stl_sc26198rxbadch(stlport_t *portp, unsigned char status, ch
                                        do_SAK(tty);
                                        BRDENABLE(portp->brdnr, portp->pagenr);
                                }
-                       } else if (status & SR_RXPARITY) {
+                       } else if (status & SR_RXPARITY)
                                status = TTY_PARITY;
-                       } else if (status & SR_RXFRAMING) {
+                       else if (status & SR_RXFRAMING)
                                status = TTY_FRAME;
-                       } else if(status & SR_RXOVERRUN) {
+                       else if(status & SR_RXOVERRUN)
                                status = TTY_OVERRUN;
-                       } else {
+                       else
                                status = 0;
-                       }
-               } else {
+               } else
                        status = 0;
-               }
 
                tty_insert_flip_char(tty, ch, status);
                tty_schedule_flip(tty);
@@ -5037,7 +4603,7 @@ static inline void stl_sc26198rxbadch(stlport_t *portp, unsigned char status, ch
  *     the FIFO).
  */
 
-static void stl_sc26198rxbadchars(stlport_t *portp)
+static void stl_sc26198rxbadchars(struct stlport *portp)
 {
        unsigned char   status, mr1;
        char            ch;
@@ -5070,13 +4636,11 @@ static void stl_sc26198rxbadchars(stlport_t *portp)
  *     processing time.
  */
 
-static void stl_sc26198otherisr(stlport_t *portp, unsigned int iack)
+static void stl_sc26198otherisr(struct stlport *portp, unsigned int iack)
 {
        unsigned char   cir, ipr, xisr;
 
-#ifdef DEBUG
-       printk("stl_sc26198otherisr(portp=%x,iack=%x)\n", (int) portp, iack);
-#endif
+       pr_debug("stl_sc26198otherisr(portp=%p,iack=%x)\n", portp, iack);
 
        cir = stl_sc26198getglobreg(portp, CIR);
 
@@ -5109,4 +4673,172 @@ static void stl_sc26198otherisr(stlport_t *portp, unsigned int iack)
        }
 }
 
-/*****************************************************************************/
+static void stl_free_isabrds(void)
+{
+       struct stlbrd *brdp;
+       unsigned int i;
+
+       for (i = 0; i < stl_nrbrds; i++) {
+               if ((brdp = stl_brds[i]) == NULL || (brdp->state & STL_PROBED))
+                       continue;
+
+               free_irq(brdp->irq, brdp);
+
+               stl_cleanup_panels(brdp);
+
+               release_region(brdp->ioaddr1, brdp->iosize1);
+               if (brdp->iosize2 > 0)
+                       release_region(brdp->ioaddr2, brdp->iosize2);
+
+               kfree(brdp);
+               stl_brds[i] = NULL;
+       }
+}
+
+/*
+ *     Loadable module initialization stuff.
+ */
+static int __init stallion_module_init(void)
+{
+       struct stlbrd   *brdp;
+       struct stlconf  conf;
+       unsigned int i, j;
+       int retval;
+
+       printk(KERN_INFO "%s: version %s\n", stl_drvtitle, stl_drvversion);
+
+       spin_lock_init(&stallion_lock);
+       spin_lock_init(&brd_lock);
+
+/*
+ *     Find any dynamically supported boards. That is via module load
+ *     line options.
+ */
+       for (i = stl_nrbrds; i < stl_nargs; i++) {
+               memset(&conf, 0, sizeof(conf));
+               if (stl_parsebrd(&conf, stl_brdsp[i]) == 0)
+                       continue;
+               if ((brdp = stl_allocbrd()) == NULL)
+                       continue;
+               brdp->brdnr = i;
+               brdp->brdtype = conf.brdtype;
+               brdp->ioaddr1 = conf.ioaddr1;
+               brdp->ioaddr2 = conf.ioaddr2;
+               brdp->irq = conf.irq;
+               brdp->irqtype = conf.irqtype;
+               if (stl_brdinit(brdp))
+                       kfree(brdp);
+               else {
+                       for (j = 0; j < brdp->nrports; j++)
+                               tty_register_device(stl_serial,
+                                       brdp->brdnr * STL_MAXPORTS + j, NULL);
+                       stl_brds[brdp->brdnr] = brdp;
+                       stl_nrbrds = i + 1;
+               }
+       }
+
+       /* this has to be _after_ isa finding because of locking */
+       retval = pci_register_driver(&stl_pcidriver);
+       if (retval && stl_nrbrds == 0)
+               goto err;
+
+       stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
+       if (!stl_serial) {
+               retval = -ENOMEM;
+               goto err_pcidr;
+       }
+
+/*
+ *     Set up a character driver for per board stuff. This is mainly used
+ *     to do stats ioctls on the ports.
+ */
+       if (register_chrdev(STL_SIOMEMMAJOR, "staliomem", &stl_fsiomem))
+               printk("STALLION: failed to register serial board device\n");
+
+       stallion_class = class_create(THIS_MODULE, "staliomem");
+       if (IS_ERR(stallion_class)) {
+               retval = PTR_ERR(stallion_class);
+               goto err_reg;
+       }
+       for (i = 0; i < 4; i++)
+               class_device_create(stallion_class, NULL,
+                                   MKDEV(STL_SIOMEMMAJOR, i), NULL,
+                                   "staliomem%d", i);
+
+       stl_serial->owner = THIS_MODULE;
+       stl_serial->driver_name = stl_drvname;
+       stl_serial->name = "ttyE";
+       stl_serial->major = STL_SERIALMAJOR;
+       stl_serial->minor_start = 0;
+       stl_serial->type = TTY_DRIVER_TYPE_SERIAL;
+       stl_serial->subtype = SERIAL_TYPE_NORMAL;
+       stl_serial->init_termios = stl_deftermios;
+       stl_serial->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
+       tty_set_operations(stl_serial, &stl_ops);
+
+       retval = tty_register_driver(stl_serial);
+       if (retval) {
+               printk("STALLION: failed to register serial driver\n");
+               goto err_clsdev;
+       }
+
+       return 0;
+err_clsdev:
+       for (i = 0; i < 4; i++)
+               class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i));
+       class_destroy(stallion_class);
+err_reg:
+       unregister_chrdev(STL_SIOMEMMAJOR, "staliomem");
+       put_tty_driver(stl_serial);
+err_pcidr:
+       pci_unregister_driver(&stl_pcidriver);
+       stl_free_isabrds();
+err:
+       return retval;
+}
+
+static void __exit stallion_module_exit(void)
+{
+       struct stlbrd *brdp;
+       unsigned int i, j;
+       int retval;
+
+       pr_debug("cleanup_module()\n");
+
+       printk(KERN_INFO "Unloading %s: version %s\n", stl_drvtitle,
+               stl_drvversion);
+
+/*
+ *     Free up all allocated resources used by the ports. This includes
+ *     memory and interrupts. As part of this process we will also do
+ *     a hangup on every open port - to try to flush out any processes
+ *     hanging onto ports.
+ */
+       for (i = 0; i < stl_nrbrds; i++) {
+               if ((brdp = stl_brds[i]) == NULL || (brdp->state & STL_PROBED))
+                       continue;
+               for (j = 0; j < brdp->nrports; j++)
+                       tty_unregister_device(stl_serial,
+                               brdp->brdnr * STL_MAXPORTS + j);
+       }
+       tty_unregister_driver(stl_serial);
+       put_tty_driver(stl_serial);
+
+       for (i = 0; i < 4; i++)
+               class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i));
+       if ((retval = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem")))
+               printk("STALLION: failed to un-register serial memory device, "
+                       "errno=%d\n", -retval);
+       class_destroy(stallion_class);
+
+       pci_unregister_driver(&stl_pcidriver);
+
+       stl_free_isabrds();
+}
+
+module_init(stallion_module_init);
+module_exit(stallion_module_exit);
+
+MODULE_AUTHOR("Greg Ungerer");
+MODULE_DESCRIPTION("Stallion Multiport Serial Driver");
+MODULE_LICENSE("GPL");
index cc10af08cb059b7f587586518011613541bf028b..a3008ce13015496c5eb409429379e769f93f904c 100644 (file)
@@ -32,7 +32,6 @@
  *      USA.
  *
  * Revision history:
- * $Log: sx.c,v $
  * Revision 1.33  2000/03/09 10:00:00  pvdl,wolff
  * - Fixed module and port counting
  * - Fixed signal handling
  *
  * */
 
-
-#define RCS_ID "$Id: sx.c,v 1.33 2000/03/08 10:01:02 wolff, pvdl Exp $"
-#define RCS_REV "$Revision: 1.33 $"
+#define SX_VERSION     1.33
 
 #include <linux/module.h>
 #include <linux/kdev_t.h>
 #include <linux/fcntl.h>
 #include <linux/major.h>
 #include <linux/delay.h>
+#include <linux/eisa.h>
 #include <linux/pci.h>
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/generic_serial.h>
 #include "sx.h"
 
-
 /* I don't think that this driver can handle more than 256 ports on
    one machine. You'll have to increase the number of boards in sx.h
    if you want more than 4 boards.  */
 #define PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8 0x2000
 #endif
 
-#ifdef CONFIG_PCI
-static struct pci_device_id sx_pci_tbl[] = {
-       { PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, PCI_ANY_ID, PCI_ANY_ID },
-       { 0 }
-};
-MODULE_DEVICE_TABLE(pci, sx_pci_tbl);
-#endif /* CONFIG_PCI */
-
 /* Configurable options: 
    (Don't be too sure that it'll work if you toggle them) */
 
 /* Am I paranoid or not ? ;-) */
 #undef SX_PARANOIA_CHECK
 
-
 /* 20 -> 2000 per second. The card should rate-limit interrupts at 100
    Hz, but it is user configurable. I don't recommend going above 1000
    Hz. The interrupt ratelimit might trigger if the interrupt is
@@ -277,7 +265,6 @@ MODULE_DEVICE_TABLE(pci, sx_pci_tbl);
    interrupt. Use polling. */
 #undef IRQ_RATE_LIMIT
 
-
 #if 0
 /* Not implemented */
 /* 
@@ -286,35 +273,33 @@ MODULE_DEVICE_TABLE(pci, sx_pci_tbl);
  */
 #define SX_REPORT_FIFO
 #define SX_REPORT_OVERRUN
-#endif 
-
+#endif
 
 /* Function prototypes */
-static void sx_disable_tx_interrupts (void * ptr); 
-static void sx_enable_tx_interrupts (void * ptr); 
-static void sx_disable_rx_interrupts (void * ptr); 
-static void sx_enable_rx_interrupts (void * ptr); 
-static int  sx_get_CD (void * ptr); 
-static void sx_shutdown_port (void * ptr);
-static int  sx_set_real_termios (void  *ptr);
-static void sx_close (void  *ptr);
-static int sx_chars_in_buffer (void * ptr);
-static int sx_init_board (struct sx_board *board);
-static int sx_init_portstructs (int nboards, int nports);
-static int sx_fw_ioctl (struct inode *inode, struct file *filp,
-                        unsigned int cmd, unsigned long arg);
+static void sx_disable_tx_interrupts(void *ptr);
+static void sx_enable_tx_interrupts(void *ptr);
+static void sx_disable_rx_interrupts(void *ptr);
+static void sx_enable_rx_interrupts(void *ptr);
+static int sx_get_CD(void *ptr);
+static void sx_shutdown_port(void *ptr);
+static int sx_set_real_termios(void *ptr);
+static void sx_close(void *ptr);
+static int sx_chars_in_buffer(void *ptr);
+static int sx_init_board(struct sx_board *board);
+static int sx_init_portstructs(int nboards, int nports);
+static int sx_fw_ioctl(struct inode *inode, struct file *filp,
+               unsigned int cmd, unsigned long arg);
 static int sx_init_drivers(void);
 
-
 static struct tty_driver *sx_driver;
 
+static DEFINE_MUTEX(sx_boards_lock);
 static struct sx_board boards[SX_NBOARDS];
 static struct sx_port *sx_ports;
 static int sx_initialized;
 static int sx_nports;
 static int sx_debug;
 
-
 /* You can have the driver poll your card. 
     - Set sx_poll to 1 to poll every timer tick (10ms on Intel). 
       This is used when the card cannot use an interrupt for some reason.
@@ -333,27 +318,36 @@ static int sx_slowpoll;
 
 static int sx_maxints = 100;
 
+#ifdef CONFIG_ISA
+
 /* These are the only open spaces in my computer. Yours may have more
    or less.... -- REW 
    duh: Card at 0xa0000 is possible on HP Netserver?? -- pvdl
 */
-static int sx_probe_addrs[]= {0xc0000, 0xd0000, 0xe0000, 
-                              0xc8000, 0xd8000, 0xe8000};
-static int si_probe_addrs[]= {0xc0000, 0xd0000, 0xe0000, 
-                              0xc8000, 0xd8000, 0xe8000, 0xa0000};
-static int si1_probe_addrs[]= { 0xd0000};
+static int sx_probe_addrs[] = {
+       0xc0000, 0xd0000, 0xe0000,
+       0xc8000, 0xd8000, 0xe8000
+};
+static int si_probe_addrs[] = {
+       0xc0000, 0xd0000, 0xe0000,
+       0xc8000, 0xd8000, 0xe8000, 0xa0000
+};
+static int si1_probe_addrs[] = {
+       0xd0000
+};
 
 #define NR_SX_ADDRS ARRAY_SIZE(sx_probe_addrs)
 #define NR_SI_ADDRS ARRAY_SIZE(si_probe_addrs)
 #define NR_SI1_ADDRS ARRAY_SIZE(si1_probe_addrs)
 
+module_param_array(sx_probe_addrs, int, NULL, 0);
+module_param_array(si_probe_addrs, int, NULL, 0);
+#endif
 
 /* Set the mask to all-ones. This alas, only supports 32 interrupts. 
    Some architectures may need more. */
 static int sx_irqmask = -1;
 
-module_param_array(sx_probe_addrs, int, NULL, 0);
-module_param_array(si_probe_addrs, int, NULL, 0);
 module_param(sx_poll, int, 0);
 module_param(sx_slowpoll, int, 0);
 module_param(sx_maxints, int, 0);
@@ -368,13 +362,12 @@ static struct real_driver sx_real_driver = {
        sx_disable_rx_interrupts,
        sx_enable_rx_interrupts,
        sx_get_CD,
-       sx_shutdown_port, 
-       sx_set_real_termios, 
+       sx_shutdown_port,
+       sx_set_real_termios,
        sx_chars_in_buffer,
        sx_close,
 };
 
-
 /* 
    This driver can spew a whole lot of debugging output at you. If you
    need maximum performance, you should disable the DEBUG define. To
@@ -385,23 +378,17 @@ static struct real_driver sx_real_driver = {
 */
 #define DEBUG
 
-
 #ifdef DEBUG
-#define sx_dprintk(f, str...) if (sx_debug & f) printk (str)
+#define sx_dprintk(f, str...)  if (sx_debug & f) printk (str)
 #else
-#define sx_dprintk(f, str...) /* nothing */
+#define sx_dprintk(f, str...)  /* nothing */
 #endif
 
+#define func_enter()   sx_dprintk(SX_DEBUG_FLOW, "sx: enter %s\n",__FUNCTION__)
+#define func_exit()    sx_dprintk(SX_DEBUG_FLOW, "sx: exit  %s\n",__FUNCTION__)
 
-
-#define func_enter() sx_dprintk (SX_DEBUG_FLOW, "sx: enter %s\n",__FUNCTION__)
-#define func_exit()  sx_dprintk (SX_DEBUG_FLOW, "sx: exit  %s\n", __FUNCTION__)
-
-#define func_enter2() sx_dprintk (SX_DEBUG_FLOW, "sx: enter %s (port %d)\n", \
-                                       __FUNCTION__, port->line)
-
-
-
+#define func_enter2()  sx_dprintk(SX_DEBUG_FLOW, "sx: enter %s (port %d)\n", \
+                               __FUNCTION__, port->line)
 
 /* 
  *  Firmware loader driver specific routines
@@ -409,31 +396,26 @@ static struct real_driver sx_real_driver = {
  */
 
 static const struct file_operations sx_fw_fops = {
-       .owner          = THIS_MODULE,
-       .ioctl          = sx_fw_ioctl,
+       .owner = THIS_MODULE,
+       .ioctl = sx_fw_ioctl,
 };
 
 static struct miscdevice sx_fw_device = {
        SXCTL_MISC_MINOR, "sxctl", &sx_fw_fops
 };
 
-
-
-
-
 #ifdef SX_PARANOIA_CHECK
 
 /* This doesn't work. Who's paranoid around here? Not me! */
 
-static inline int sx_paranoia_check(struct sx_port const * port,
+static inline int sx_paranoia_check(struct sx_port const *port,
                                    char *name, const char *routine)
 {
+       static const char *badmagic = KERN_ERR "sx: Warning: bad sx port magic "
+                       "number for device %s in %s\n";
+       static const char *badinfo = KERN_ERR "sx: Warning: null sx port for "
+                       "device %s in %s\n";
 
-       static const char *badmagic =
-         KERN_ERR "sx: Warning: bad sx port magic number for device %s in %s\n";
-       static const char *badinfo =
-         KERN_ERR "sx: Warning: null sx port for device %s in %s\n";
        if (!port) {
                printk(badinfo, name, routine);
                return 1;
@@ -456,23 +438,24 @@ static inline int sx_paranoia_check(struct sx_port const * port,
 #define TIMEOUT_1 30
 #define TIMEOUT_2 1000000
 
-
 #ifdef DEBUG
 static void my_hd_io(void __iomem *p, int len)
 {
        int i, j, ch;
        unsigned char __iomem *addr = p;
 
-       for (i=0;i<len;i+=16) {
-               printk ("%p ", addr+i);
-               for (j=0;j<16;j++) {
-                       printk ("%02x %s", readb(addr+j+i), (j==7)?" ":"");
+       for (i = 0; i < len; i += 16) {
+               printk("%p ", addr + i);
+               for (j = 0; j < 16; j++) {
+                       printk("%02x %s", readb(addr + j + i),
+                                       (j == 7) ? " " : "");
                }
-               for (j=0;j<16;j++) {
-                       ch = readb(addr+j+i);
-                       printk ("%c", (ch < 0x20)?'.':((ch > 0x7f)?'.':ch));
+               for (j = 0; j < 16; j++) {
+                       ch = readb(addr + j + i);
+                       printk("%c", (ch < 0x20) ? '.' :
+                                       ((ch > 0x7f) ? '.' : ch));
                }
-               printk ("\n");
+               printk("\n");
        }
 }
 static void my_hd(void *p, int len)
@@ -480,419 +463,468 @@ static void my_hd(void *p, int len)
        int i, j, ch;
        unsigned char *addr = p;
 
-       for (i=0;i<len;i+=16) {
-               printk ("%p ", addr+i);
-               for (j=0;j<16;j++) {
-                       printk ("%02x %s", addr[j+i], (j==7)?" ":"");
+       for (i = 0; i < len; i += 16) {
+               printk("%p ", addr + i);
+               for (j = 0; j < 16; j++) {
+                       printk("%02x %s", addr[j + i], (j == 7) ? " " : "");
                }
-               for (j=0;j<16;j++) {
-                       ch = addr[j+i];
-                       printk ("%c", (ch < 0x20)?'.':((ch > 0x7f)?'.':ch));
+               for (j = 0; j < 16; j++) {
+                       ch = addr[j + i];
+                       printk("%c", (ch < 0x20) ? '.' :
+                                       ((ch > 0x7f) ? '.' : ch));
                }
-               printk ("\n");
+               printk("\n");
        }
 }
 #endif
 
-
-
 /* This needs redoing for Alpha -- REW -- Done. */
 
-static inline void write_sx_byte (struct sx_board *board, int offset, u8 byte)
+static inline void write_sx_byte(struct sx_board *board, int offset, u8 byte)
 {
-       writeb (byte, board->base+offset);
+       writeb(byte, board->base + offset);
 }
 
-static inline u8 read_sx_byte (struct sx_board *board, int offset)
+static inline u8 read_sx_byte(struct sx_board *board, int offset)
 {
-       return readb (board->base+offset);
+       return readb(board->base + offset);
 }
 
-
-static inline void write_sx_word (struct sx_board *board, int offset, u16 word)
+static inline void write_sx_word(struct sx_board *board, int offset, u16 word)
 {
-       writew (word, board->base+offset);
+       writew(word, board->base + offset);
 }
 
-static inline u16 read_sx_word (struct sx_board *board, int offset)
+static inline u16 read_sx_word(struct sx_board *board, int offset)
 {
-       return readw (board->base + offset);
+       return readw(board->base + offset);
 }
 
-
-static int sx_busy_wait_eq (struct sx_board *board, 
-                           int offset, int mask, int correctval)
+static int sx_busy_wait_eq(struct sx_board *board,
+               int offset, int mask, int correctval)
 {
        int i;
 
-       func_enter ();
+       func_enter();
 
-       for (i=0; i < TIMEOUT_1 ;i++)
-               if ((read_sx_byte (board, offset) & mask) == correctval) {
-                       func_exit ();
+       for (i = 0; i < TIMEOUT_1; i++)
+               if ((read_sx_byte(board, offset) & mask) == correctval) {
+                       func_exit();
                        return 1;
                }
 
-       for (i=0; i < TIMEOUT_2 ;i++) {
-               if ((read_sx_byte (board, offset) & mask) == correctval) {
-                       func_exit ();
+       for (i = 0; i < TIMEOUT_2; i++) {
+               if ((read_sx_byte(board, offset) & mask) == correctval) {
+                       func_exit();
                        return 1;
                }
-               udelay (1);
+               udelay(1);
        }
 
-       func_exit ();
+       func_exit();
        return 0;
 }
 
-
-static int sx_busy_wait_neq (struct sx_board *board, 
-                            int offset, int mask, int badval)
+static int sx_busy_wait_neq(struct sx_board *board,
+               int offset, int mask, int badval)
 {
        int i;
 
-       func_enter ();
+       func_enter();
 
-       for (i=0; i < TIMEOUT_1 ;i++)
-               if ((read_sx_byte (board, offset) & mask) != badval) {
-                       func_exit ();
+       for (i = 0; i < TIMEOUT_1; i++)
+               if ((read_sx_byte(board, offset) & mask) != badval) {
+                       func_exit();
                        return 1;
                }
 
-       for (i=0; i < TIMEOUT_2 ;i++) {
-               if ((read_sx_byte (board, offset) & mask) != badval) {
-                       func_exit ();
+       for (i = 0; i < TIMEOUT_2; i++) {
+               if ((read_sx_byte(board, offset) & mask) != badval) {
+                       func_exit();
                        return 1;
                }
-               udelay (1);
+               udelay(1);
        }
 
-       func_exit ();
+       func_exit();
        return 0;
 }
 
-
-
 /* 5.6.4 of 6210028 r2.3 */
-static int sx_reset (struct sx_board *board)
+static int sx_reset(struct sx_board *board)
 {
-       func_enter ();
+       func_enter();
 
-       if (IS_SX_BOARD (board)) {
+       if (IS_SX_BOARD(board)) {
 
-               write_sx_byte (board, SX_CONFIG, 0);
-               write_sx_byte (board, SX_RESET, 1); /* Value doesn't matter */
+               write_sx_byte(board, SX_CONFIG, 0);
+               write_sx_byte(board, SX_RESET, 1); /* Value doesn't matter */
 
-               if (!sx_busy_wait_eq (board, SX_RESET_STATUS, 1, 0)) {
-                       printk (KERN_INFO "sx: Card doesn't respond to reset....\n");
+               if (!sx_busy_wait_eq(board, SX_RESET_STATUS, 1, 0)) {
+                       printk(KERN_INFO "sx: Card doesn't respond to "
+                                       "reset...\n");
                        return 0;
                }
        } else if (IS_EISA_BOARD(board)) {
-               outb(board->irq<<4, board->eisa_base+0xc02);
+               outb(board->irq << 4, board->eisa_base + 0xc02);
        } else if (IS_SI1_BOARD(board)) {
-               write_sx_byte (board, SI1_ISA_RESET,   0); // value does not matter
+               write_sx_byte(board, SI1_ISA_RESET, 0); /*value doesn't matter*/
        } else {
                /* Gory details of the SI/ISA board */
-               write_sx_byte (board, SI2_ISA_RESET,    SI2_ISA_RESET_SET);
-               write_sx_byte (board, SI2_ISA_IRQ11,    SI2_ISA_IRQ11_CLEAR);
-               write_sx_byte (board, SI2_ISA_IRQ12,    SI2_ISA_IRQ12_CLEAR);
-               write_sx_byte (board, SI2_ISA_IRQ15,    SI2_ISA_IRQ15_CLEAR);
-               write_sx_byte (board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_CLEAR);
-               write_sx_byte (board, SI2_ISA_IRQSET,   SI2_ISA_IRQSET_CLEAR);
+               write_sx_byte(board, SI2_ISA_RESET, SI2_ISA_RESET_SET);
+               write_sx_byte(board, SI2_ISA_IRQ11, SI2_ISA_IRQ11_CLEAR);
+               write_sx_byte(board, SI2_ISA_IRQ12, SI2_ISA_IRQ12_CLEAR);
+               write_sx_byte(board, SI2_ISA_IRQ15, SI2_ISA_IRQ15_CLEAR);
+               write_sx_byte(board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_CLEAR);
+               write_sx_byte(board, SI2_ISA_IRQSET, SI2_ISA_IRQSET_CLEAR);
        }
 
-       func_exit ();
+       func_exit();
        return 1;
 }
 
-
 /* This doesn't work on machines where "NULL" isn't 0 */
 /* If you have one of those, someone will need to write 
    the equivalent of this, which will amount to about 3 lines. I don't
    want to complicate this right now. -- REW
    (See, I do write comments every now and then :-) */
-#define OFFSETOF(strct, elem) ((long)&(((struct strct *)NULL)->elem))
-
-
-#define CHAN_OFFSET(port,elem) (port->ch_base + OFFSETOF (_SXCHANNEL, elem))
-#define MODU_OFFSET(board,addr,elem)    (addr + OFFSETOF (_SXMODULE, elem))
-#define  BRD_OFFSET(board,elem)                (OFFSETOF (_SXCARD, elem))
+#define OFFSETOF(strct, elem)  ((long)&(((struct strct *)NULL)->elem))
 
+#define CHAN_OFFSET(port,elem) (port->ch_base + OFFSETOF (_SXCHANNEL, elem))
+#define MODU_OFFSET(board,addr,elem)   (addr + OFFSETOF (_SXMODULE, elem))
+#define  BRD_OFFSET(board,elem)        (OFFSETOF (_SXCARD, elem))
 
 #define sx_write_channel_byte(port, elem, val) \
-   write_sx_byte (port->board, CHAN_OFFSET (port, elem), val)
+       write_sx_byte (port->board, CHAN_OFFSET (port, elem), val)
 
 #define sx_read_channel_byte(port, elem) \
-   read_sx_byte (port->board, CHAN_OFFSET (port, elem))
+       read_sx_byte (port->board, CHAN_OFFSET (port, elem))
 
 #define sx_write_channel_word(port, elem, val) \
-   write_sx_word (port->board, CHAN_OFFSET (port, elem), val)
+       write_sx_word (port->board, CHAN_OFFSET (port, elem), val)
 
 #define sx_read_channel_word(port, elem) \
-   read_sx_word (port->board, CHAN_OFFSET (port, elem))
-
+       read_sx_word (port->board, CHAN_OFFSET (port, elem))
 
 #define sx_write_module_byte(board, addr, elem, val) \
-   write_sx_byte (board, MODU_OFFSET (board, addr, elem), val)
+       write_sx_byte (board, MODU_OFFSET (board, addr, elem), val)
 
 #define sx_read_module_byte(board, addr, elem) \
-   read_sx_byte (board, MODU_OFFSET (board, addr, elem))
+       read_sx_byte (board, MODU_OFFSET (board, addr, elem))
 
 #define sx_write_module_word(board, addr, elem, val) \
-   write_sx_word (board, MODU_OFFSET (board, addr, elem), val)
+       write_sx_word (board, MODU_OFFSET (board, addr, elem), val)
 
 #define sx_read_module_word(board, addr, elem) \
-   read_sx_word (board, MODU_OFFSET (board, addr, elem))
-
+       read_sx_word (board, MODU_OFFSET (board, addr, elem))
 
 #define sx_write_board_byte(board, elem, val) \
-   write_sx_byte (board, BRD_OFFSET (board, elem), val)
+       write_sx_byte (board, BRD_OFFSET (board, elem), val)
 
 #define sx_read_board_byte(board, elem) \
-   read_sx_byte (board, BRD_OFFSET (board, elem))
+       read_sx_byte (board, BRD_OFFSET (board, elem))
 
 #define sx_write_board_word(board, elem, val) \
-   write_sx_word (board, BRD_OFFSET (board, elem), val)
+       write_sx_word (board, BRD_OFFSET (board, elem), val)
 
 #define sx_read_board_word(board, elem) \
-   read_sx_word (board, BRD_OFFSET (board, elem))
-
+       read_sx_word (board, BRD_OFFSET (board, elem))
 
-static int sx_start_board (struct sx_board *board)
+static int sx_start_board(struct sx_board *board)
 {
-       if (IS_SX_BOARD (board)) {
-               write_sx_byte (board, SX_CONFIG, SX_CONF_BUSEN);
+       if (IS_SX_BOARD(board)) {
+               write_sx_byte(board, SX_CONFIG, SX_CONF_BUSEN);
        } else if (IS_EISA_BOARD(board)) {
                write_sx_byte(board, SI2_EISA_OFF, SI2_EISA_VAL);
-               outb((board->irq<<4)|4, board->eisa_base+0xc02);
+               outb((board->irq << 4) | 4, board->eisa_base + 0xc02);
        } else if (IS_SI1_BOARD(board)) {
-               write_sx_byte (board, SI1_ISA_RESET_CLEAR, 0);
-               write_sx_byte (board, SI1_ISA_INTCL, 0);
+               write_sx_byte(board, SI1_ISA_RESET_CLEAR, 0);
+               write_sx_byte(board, SI1_ISA_INTCL, 0);
        } else {
                /* Don't bug me about the clear_set. 
                   I haven't the foggiest idea what it's about -- REW */
-               write_sx_byte (board, SI2_ISA_RESET,    SI2_ISA_RESET_CLEAR);
-               write_sx_byte (board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_SET);
+               write_sx_byte(board, SI2_ISA_RESET, SI2_ISA_RESET_CLEAR);
+               write_sx_byte(board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_SET);
        }
        return 1;
 }
 
 #define SX_IRQ_REG_VAL(board) \
-        ((board->flags & SX_ISA_BOARD)?(board->irq << 4):0)
+       ((board->flags & SX_ISA_BOARD) ? (board->irq << 4) : 0)
 
 /* Note. The SX register is write-only. Therefore, we have to enable the
    bus too. This is a no-op, if you don't mess with this driver... */
-static int sx_start_interrupts (struct sx_board *board)
+static int sx_start_interrupts(struct sx_board *board)
 {
 
        /* Don't call this with board->irq == 0 */
 
        if (IS_SX_BOARD(board)) {
-               write_sx_byte (board, SX_CONFIG, SX_IRQ_REG_VAL (board) | 
-                                                SX_CONF_BUSEN | 
-                                                SX_CONF_HOSTIRQ);
+               write_sx_byte(board, SX_CONFIG, SX_IRQ_REG_VAL(board) |
+                               SX_CONF_BUSEN | SX_CONF_HOSTIRQ);
        } else if (IS_EISA_BOARD(board)) {
-               inb(board->eisa_base+0xc03);  
+               inb(board->eisa_base + 0xc03);
        } else if (IS_SI1_BOARD(board)) {
-              write_sx_byte (board, SI1_ISA_INTCL,0);
-              write_sx_byte (board, SI1_ISA_INTCL_CLEAR,0);
+               write_sx_byte(board, SI1_ISA_INTCL, 0);
+               write_sx_byte(board, SI1_ISA_INTCL_CLEAR, 0);
        } else {
                switch (board->irq) {
-               case 11:write_sx_byte (board, SI2_ISA_IRQ11, SI2_ISA_IRQ11_SET);break;
-               case 12:write_sx_byte (board, SI2_ISA_IRQ12, SI2_ISA_IRQ12_SET);break;
-               case 15:write_sx_byte (board, SI2_ISA_IRQ15, SI2_ISA_IRQ15_SET);break;
-               default:printk (KERN_INFO "sx: SI/XIO card doesn't support interrupt %d.\n", 
-                               board->irq);
-               return 0;
+               case 11:
+                       write_sx_byte(board, SI2_ISA_IRQ11, SI2_ISA_IRQ11_SET);
+                       break;
+               case 12:
+                       write_sx_byte(board, SI2_ISA_IRQ12, SI2_ISA_IRQ12_SET);
+                       break;
+               case 15:
+                       write_sx_byte(board, SI2_ISA_IRQ15, SI2_ISA_IRQ15_SET);
+                       break;
+               default:
+                       printk(KERN_INFO "sx: SI/XIO card doesn't support "
+                                       "interrupt %d.\n", board->irq);
+                       return 0;
                }
-               write_sx_byte (board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_SET);
+               write_sx_byte(board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_SET);
        }
 
        return 1;
 }
 
-
-static int sx_send_command (struct sx_port *port, 
-                           int command, int mask, int newstat)
+static int sx_send_command(struct sx_port *port,
+               int command, int mask, int newstat)
 {
-       func_enter2 ();
-       write_sx_byte (port->board, CHAN_OFFSET (port, hi_hstat), command);
-       func_exit ();
-       return sx_busy_wait_eq (port->board, CHAN_OFFSET (port, hi_hstat), mask, newstat);
+       func_enter2();
+       write_sx_byte(port->board, CHAN_OFFSET(port, hi_hstat), command);
+       func_exit();
+       return sx_busy_wait_eq(port->board, CHAN_OFFSET(port, hi_hstat), mask,
+                       newstat);
 }
 
-
-static char *mod_type_s (int module_type)
+static char *mod_type_s(int module_type)
 {
        switch (module_type) {
-       case TA4:       return "TA4";
-       case TA8:       return "TA8";
-       case TA4_ASIC:  return "TA4_ASIC";
-       case TA8_ASIC:  return "TA8_ASIC";
-       case MTA_CD1400:return "MTA_CD1400";
-       case SXDC:      return "SXDC";
-       default:return "Unknown/invalid";
+       case TA4:
+               return "TA4";
+       case TA8:
+               return "TA8";
+       case TA4_ASIC:
+               return "TA4_ASIC";
+       case TA8_ASIC:
+               return "TA8_ASIC";
+       case MTA_CD1400:
+               return "MTA_CD1400";
+       case SXDC:
+               return "SXDC";
+       default:
+               return "Unknown/invalid";
        }
 }
 
-
-static char *pan_type_s (int pan_type)
+static char *pan_type_s(int pan_type)
 {
        switch (pan_type) {
-       case MOD_RS232DB25:     return "MOD_RS232DB25";
-       case MOD_RS232RJ45:     return "MOD_RS232RJ45";
-       case MOD_RS422DB25:     return "MOD_RS422DB25";
-       case MOD_PARALLEL:      return "MOD_PARALLEL";
-       case MOD_2_RS232DB25:   return "MOD_2_RS232DB25";
-       case MOD_2_RS232RJ45:   return "MOD_2_RS232RJ45";
-       case MOD_2_RS422DB25:   return "MOD_2_RS422DB25";
-       case MOD_RS232DB25MALE: return "MOD_RS232DB25MALE";
-       case MOD_2_PARALLEL:    return "MOD_2_PARALLEL";
-       case MOD_BLANK:         return "empty";
-       default:return "invalid";
+       case MOD_RS232DB25:
+               return "MOD_RS232DB25";
+       case MOD_RS232RJ45:
+               return "MOD_RS232RJ45";
+       case MOD_RS422DB25:
+               return "MOD_RS422DB25";
+       case MOD_PARALLEL:
+               return "MOD_PARALLEL";
+       case MOD_2_RS232DB25:
+               return "MOD_2_RS232DB25";
+       case MOD_2_RS232RJ45:
+               return "MOD_2_RS232RJ45";
+       case MOD_2_RS422DB25:
+               return "MOD_2_RS422DB25";
+       case MOD_RS232DB25MALE:
+               return "MOD_RS232DB25MALE";
+       case MOD_2_PARALLEL:
+               return "MOD_2_PARALLEL";
+       case MOD_BLANK:
+               return "empty";
+       default:
+               return "invalid";
        }
 }
 
-
-static int mod_compat_type (int module_type)
+static int mod_compat_type(int module_type)
 {
        return module_type >> 4;
 }
 
 static void sx_reconfigure_port(struct sx_port *port)
 {
-       if (sx_read_channel_byte (port, hi_hstat) == HS_IDLE_OPEN) {
-               if (sx_send_command (port, HS_CONFIG, -1, HS_IDLE_OPEN) != 1) {
-                       printk (KERN_WARNING "sx: Sent reconfigure command, but card didn't react.\n");
+       if (sx_read_channel_byte(port, hi_hstat) == HS_IDLE_OPEN) {
+               if (sx_send_command(port, HS_CONFIG, -1, HS_IDLE_OPEN) != 1) {
+                       printk(KERN_WARNING "sx: Sent reconfigure command, but "
+                                       "card didn't react.\n");
                }
        } else {
-               sx_dprintk (SX_DEBUG_TERMIOS, 
-                           "sx: Not sending reconfigure: port isn't open (%02x).\n", 
-                           sx_read_channel_byte (port, hi_hstat));
-       }       
+               sx_dprintk(SX_DEBUG_TERMIOS, "sx: Not sending reconfigure: "
+                               "port isn't open (%02x).\n",
+                               sx_read_channel_byte(port, hi_hstat));
+       }
 }
 
-static void sx_setsignals (struct sx_port *port, int dtr, int rts)
+static void sx_setsignals(struct sx_port *port, int dtr, int rts)
 {
        int t;
-       func_enter2 ();
+       func_enter2();
 
-       t = sx_read_channel_byte (port, hi_op);
-       if (dtr >= 0) t = dtr? (t | OP_DTR): (t & ~OP_DTR);
-       if (rts >= 0) t = rts? (t | OP_RTS): (t & ~OP_RTS);
-       sx_write_channel_byte (port, hi_op, t);
-       sx_dprintk (SX_DEBUG_MODEMSIGNALS, "setsignals: %d/%d\n", dtr, rts);
+       t = sx_read_channel_byte(port, hi_op);
+       if (dtr >= 0)
+               t = dtr ? (t | OP_DTR) : (t & ~OP_DTR);
+       if (rts >= 0)
+               t = rts ? (t | OP_RTS) : (t & ~OP_RTS);
+       sx_write_channel_byte(port, hi_op, t);
+       sx_dprintk(SX_DEBUG_MODEMSIGNALS, "setsignals: %d/%d\n", dtr, rts);
 
-       func_exit ();
+       func_exit();
 }
 
-
-
-static int sx_getsignals (struct sx_port *port)
+static int sx_getsignals(struct sx_port *port)
 {
-       int i_stat,o_stat;
-
-       o_stat = sx_read_channel_byte (port, hi_op);
-       i_stat = sx_read_channel_byte (port, hi_ip);
-
-       sx_dprintk (SX_DEBUG_MODEMSIGNALS, "getsignals: %d/%d  (%d/%d) %02x/%02x\n",
-                   (o_stat & OP_DTR) != 0, (o_stat & OP_RTS) != 0,
-                   port->c_dcd, sx_get_CD (port),
-                   sx_read_channel_byte (port, hi_ip),
-                   sx_read_channel_byte (port, hi_state));
-
-       return (((o_stat & OP_DTR)?TIOCM_DTR:0) |
-               ((o_stat & OP_RTS)?TIOCM_RTS:0) |
-               ((i_stat & IP_CTS)?TIOCM_CTS:0) |
-               ((i_stat & IP_DCD)?TIOCM_CAR:0) |
-               ((i_stat & IP_DSR)?TIOCM_DSR:0) |
-               ((i_stat & IP_RI)?TIOCM_RNG:0)
-               );
+       int i_stat, o_stat;
+
+       o_stat = sx_read_channel_byte(port, hi_op);
+       i_stat = sx_read_channel_byte(port, hi_ip);
+
+       sx_dprintk(SX_DEBUG_MODEMSIGNALS, "getsignals: %d/%d  (%d/%d) "
+                       "%02x/%02x\n",
+                       (o_stat & OP_DTR) != 0, (o_stat & OP_RTS) != 0,
+                       port->c_dcd, sx_get_CD(port),
+                       sx_read_channel_byte(port, hi_ip),
+                       sx_read_channel_byte(port, hi_state));
+
+       return (((o_stat & OP_DTR) ? TIOCM_DTR : 0) |
+               ((o_stat & OP_RTS) ? TIOCM_RTS : 0) |
+               ((i_stat & IP_CTS) ? TIOCM_CTS : 0) |
+               ((i_stat & IP_DCD) ? TIOCM_CAR : 0) |
+               ((i_stat & IP_DSR) ? TIOCM_DSR : 0) |
+               ((i_stat & IP_RI) ? TIOCM_RNG : 0));
 }
 
-
-static void sx_set_baud (struct sx_port *port)
+static void sx_set_baud(struct sx_port *port)
 {
        int t;
 
        if (port->board->ta_type == MOD_SXDC) {
                switch (port->gs.baud) {
-                 /* Save some typing work... */
-#define e(x) case x:t= BAUD_ ## x ; break
-                       e(50);e(75);e(110);e(150);e(200);e(300);e(600);
-                        e(1200);e(1800);e(2000);e(2400);e(4800);e(7200);
-                        e(9600);e(14400);e(19200);e(28800);e(38400);
-                        e(56000);e(57600);e(64000);e(76800);e(115200);
-                       e(128000);e(150000);e(230400);e(256000);e(460800);
-                        e(921600);
-               case 134    :t = BAUD_134_5;   break;
-               case 0      :t = -1;
-                                                                break;
+                       /* Save some typing work... */
+#define e(x) case x: t = BAUD_ ## x; break
+                       e(50);
+                       e(75);
+                       e(110);
+                       e(150);
+                       e(200);
+                       e(300);
+                       e(600);
+                       e(1200);
+                       e(1800);
+                       e(2000);
+                       e(2400);
+                       e(4800);
+                       e(7200);
+                       e(9600);
+                       e(14400);
+                       e(19200);
+                       e(28800);
+                       e(38400);
+                       e(56000);
+                       e(57600);
+                       e(64000);
+                       e(76800);
+                       e(115200);
+                       e(128000);
+                       e(150000);
+                       e(230400);
+                       e(256000);
+                       e(460800);
+                       e(921600);
+               case 134:
+                       t = BAUD_134_5;
+                       break;
+               case 0:
+                       t = -1;
+                       break;
                default:
                        /* Can I return "invalid"? */
                        t = BAUD_9600;
-                       printk (KERN_INFO "sx: unsupported baud rate: %d.\n", port->gs.baud);
+                       printk(KERN_INFO "sx: unsupported baud rate: %d.\n",
+                                       port->gs.baud);
                        break;
                }
 #undef e
                if (t > 0) {
-                       /* The baud rate is not set to 0, so we're enabeling DTR... -- REW */
-                       sx_setsignals (port, 1, -1); 
+/* The baud rate is not set to 0, so we're enabeling DTR... -- REW */
+                       sx_setsignals(port, 1, -1);
                        /* XXX This is not TA & MTA compatible */
-                       sx_write_channel_byte (port, hi_csr, 0xff);
+                       sx_write_channel_byte(port, hi_csr, 0xff);
 
-                       sx_write_channel_byte (port, hi_txbaud, t);
-                       sx_write_channel_byte (port, hi_rxbaud, t);
+                       sx_write_channel_byte(port, hi_txbaud, t);
+                       sx_write_channel_byte(port, hi_rxbaud, t);
                } else {
-                       sx_setsignals (port, 0, -1);
+                       sx_setsignals(port, 0, -1);
                }
        } else {
                switch (port->gs.baud) {
-#define e(x) case x:t= CSR_ ## x ; break
-                       e(75);e(150);e(300);e(600);e(1200);e(2400);e(4800);
-                        e(1800);e(9600);
-                       e(19200);e(57600);e(38400);
-                       /* TA supports 110, but not 115200, MTA supports 115200, but not 110 */
-               case 110: 
+#define e(x) case x: t = CSR_ ## x; break
+                       e(75);
+                       e(150);
+                       e(300);
+                       e(600);
+                       e(1200);
+                       e(2400);
+                       e(4800);
+                       e(1800);
+                       e(9600);
+                       e(19200);
+                       e(57600);
+                       e(38400);
+/* TA supports 110, but not 115200, MTA supports 115200, but not 110 */
+               case 110:
                        if (port->board->ta_type == MOD_TA) {
                                t = CSR_110;
                                break;
                        } else {
                                t = CSR_9600;
-                               printk (KERN_INFO "sx: Unsupported baud rate: %d.\n", port->gs.baud);
+                               printk(KERN_INFO "sx: Unsupported baud rate: "
+                                               "%d.\n", port->gs.baud);
                                break;
                        }
-               case 115200: 
+               case 115200:
                        if (port->board->ta_type == MOD_TA) {
                                t = CSR_9600;
-                               printk (KERN_INFO "sx: Unsupported baud rate: %d.\n", port->gs.baud);
+                               printk(KERN_INFO "sx: Unsupported baud rate: "
+                                               "%d.\n", port->gs.baud);
                                break;
                        } else {
                                t = CSR_110;
                                break;
                        }
-               case 0      :t = -1;
-                                                                break;
+               case 0:
+                       t = -1;
+                       break;
                default:
                        t = CSR_9600;
-                       printk (KERN_INFO "sx: Unsupported baud rate: %d.\n", port->gs.baud);
+                       printk(KERN_INFO "sx: Unsupported baud rate: %d.\n",
+                                       port->gs.baud);
                        break;
                }
 #undef e
                if (t >= 0) {
-                       sx_setsignals (port, 1, -1);
-                       sx_write_channel_byte (port, hi_csr, t * 0x11);
+                       sx_setsignals(port, 1, -1);
+                       sx_write_channel_byte(port, hi_csr, t * 0x11);
                } else {
-                       sx_setsignals (port, 0, -1);
+                       sx_setsignals(port, 0, -1);
                }
        }
 }
 
-
 /* Simon Allen's version of this routine was 225 lines long. 85 is a lot
    better. -- REW */
 
-static int sx_set_real_termios (void *ptr)
+static int sx_set_real_termios(void *ptr)
 {
        struct sx_port *port = ptr;
 
@@ -907,80 +939,83 @@ static int sx_set_real_termios (void *ptr)
           belongs (next to the drop dtr if baud == 0) -- REW */
        /* sx_setsignals (port, 1, -1); */
 
-       sx_set_baud (port);
+       sx_set_baud(port);
 
 #define CFLAG port->gs.tty->termios->c_cflag
-       sx_write_channel_byte (port, hi_mr1,
-                              (C_PARENB (port->gs.tty)? MR1_WITH:MR1_NONE) |
-                              (C_PARODD (port->gs.tty)? MR1_ODD:MR1_EVEN) |
-                              (C_CRTSCTS(port->gs.tty)? MR1_RTS_RXFLOW:0) |
-                              (((CFLAG & CSIZE)==CS8) ? MR1_8_BITS:0) |
-                              (((CFLAG & CSIZE)==CS7) ? MR1_7_BITS:0) |
-                              (((CFLAG & CSIZE)==CS6) ? MR1_6_BITS:0) |
-                              (((CFLAG & CSIZE)==CS5) ? MR1_5_BITS:0) );
-
-       sx_write_channel_byte (port, hi_mr2,
-                              (C_CRTSCTS(port->gs.tty)?MR2_CTS_TXFLOW:0) |
-                              (C_CSTOPB (port->gs.tty)?MR2_2_STOP:MR2_1_STOP));
+       sx_write_channel_byte(port, hi_mr1,
+                       (C_PARENB(port->gs.tty) ? MR1_WITH : MR1_NONE) |
+                       (C_PARODD(port->gs.tty) ? MR1_ODD : MR1_EVEN) |
+                       (C_CRTSCTS(port->gs.tty) ? MR1_RTS_RXFLOW : 0) |
+                       (((CFLAG & CSIZE) == CS8) ? MR1_8_BITS : 0) |
+                       (((CFLAG & CSIZE) == CS7) ? MR1_7_BITS : 0) |
+                       (((CFLAG & CSIZE) == CS6) ? MR1_6_BITS : 0) |
+                       (((CFLAG & CSIZE) == CS5) ? MR1_5_BITS : 0));
+
+       sx_write_channel_byte(port, hi_mr2,
+                       (C_CRTSCTS(port->gs.tty) ? MR2_CTS_TXFLOW : 0) |
+                       (C_CSTOPB(port->gs.tty) ? MR2_2_STOP :
+                       MR2_1_STOP));
 
        switch (CFLAG & CSIZE) {
-       case CS8:sx_write_channel_byte (port, hi_mask, 0xff);break;
-       case CS7:sx_write_channel_byte (port, hi_mask, 0x7f);break;
-       case CS6:sx_write_channel_byte (port, hi_mask, 0x3f);break;
-       case CS5:sx_write_channel_byte (port, hi_mask, 0x1f);break;
+       case CS8:
+               sx_write_channel_byte(port, hi_mask, 0xff);
+               break;
+       case CS7:
+               sx_write_channel_byte(port, hi_mask, 0x7f);
+               break;
+       case CS6:
+               sx_write_channel_byte(port, hi_mask, 0x3f);
+               break;
+       case CS5:
+               sx_write_channel_byte(port, hi_mask, 0x1f);
+               break;
        default:
-               printk (KERN_INFO "sx: Invalid wordsize: %u\n", CFLAG & CSIZE);
+               printk(KERN_INFO "sx: Invalid wordsize: %u\n", CFLAG & CSIZE);
                break;
        }
 
-       sx_write_channel_byte (port, hi_prtcl, 
-                              (I_IXON   (port->gs.tty)?SP_TXEN:0) |
-                              (I_IXOFF  (port->gs.tty)?SP_RXEN:0) |
-                              (I_IXANY  (port->gs.tty)?SP_TANY:0) |
-                              SP_DCEN);
+       sx_write_channel_byte(port, hi_prtcl,
+                       (I_IXON(port->gs.tty) ? SP_TXEN : 0) |
+                       (I_IXOFF(port->gs.tty) ? SP_RXEN : 0) |
+                       (I_IXANY(port->gs.tty) ? SP_TANY : 0) | SP_DCEN);
 
-       sx_write_channel_byte (port, hi_break, 
-                              (I_IGNBRK(port->gs.tty)?BR_IGN:0 |
-                               I_BRKINT(port->gs.tty)?BR_INT:0));
+       sx_write_channel_byte(port, hi_break,
+                       (I_IGNBRK(port->gs.tty) ? BR_IGN : 0 |
+                       I_BRKINT(port->gs.tty) ? BR_INT : 0));
 
-       sx_write_channel_byte (port, hi_txon,  START_CHAR (port->gs.tty));
-       sx_write_channel_byte (port, hi_rxon,  START_CHAR (port->gs.tty));
-       sx_write_channel_byte (port, hi_txoff, STOP_CHAR  (port->gs.tty));
-       sx_write_channel_byte (port, hi_rxoff, STOP_CHAR  (port->gs.tty));
+       sx_write_channel_byte(port, hi_txon, START_CHAR(port->gs.tty));
+       sx_write_channel_byte(port, hi_rxon, START_CHAR(port->gs.tty));
+       sx_write_channel_byte(port, hi_txoff, STOP_CHAR(port->gs.tty));
+       sx_write_channel_byte(port, hi_rxoff, STOP_CHAR(port->gs.tty));
 
        sx_reconfigure_port(port);
 
        /* Tell line discipline whether we will do input cooking */
-       if(I_OTHER(port->gs.tty)) {
+       if (I_OTHER(port->gs.tty)) {
                clear_bit(TTY_HW_COOK_IN, &port->gs.tty->flags);
        } else {
                set_bit(TTY_HW_COOK_IN, &port->gs.tty->flags);
        }
-       sx_dprintk (SX_DEBUG_TERMIOS, "iflags: %x(%d) ",
-                   port->gs.tty->termios->c_iflag, 
-                   I_OTHER(port->gs.tty));
-
+       sx_dprintk(SX_DEBUG_TERMIOS, "iflags: %x(%d) ",
+                       port->gs.tty->termios->c_iflag, I_OTHER(port->gs.tty));
 
 /* Tell line discipline whether we will do output cooking.
  * If OPOST is set and no other output flags are set then we can do output
  * processing.  Even if only *one* other flag in the O_OTHER group is set
  * we do cooking in software.
  */
-       if(O_OPOST(port->gs.tty) && !O_OTHER(port->gs.tty)) {
+       if (O_OPOST(port->gs.tty) && !O_OTHER(port->gs.tty)) {
                set_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags);
        } else {
                clear_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags);
        }
-       sx_dprintk (SX_DEBUG_TERMIOS, "oflags: %x(%d)\n",
-                   port->gs.tty->termios->c_oflag, 
-                   O_OTHER(port->gs.tty));
+       sx_dprintk(SX_DEBUG_TERMIOS, "oflags: %x(%d)\n",
+                       port->gs.tty->termios->c_oflag, O_OTHER(port->gs.tty));
        /* port->c_dcd = sx_get_CD (port); */
-       func_exit ();
+       func_exit();
        return 0;
 }
 
-
-
 /* ********************************************************************** *
  *                   the interrupt related routines                       *
  * ********************************************************************** */
@@ -996,245 +1031,260 @@ static int sx_set_real_termios (void *ptr)
    know I'm dead against that, but I think it is required in this
    case.  */
 
-
-static void sx_transmit_chars (struct sx_port *port)
+static void sx_transmit_chars(struct sx_port *port)
 {
        int c;
        int tx_ip;
        int txroom;
 
-       func_enter2 ();
-       sx_dprintk (SX_DEBUG_TRANSMIT, "Port %p: transmit %d chars\n", 
-                   port, port->gs.xmit_cnt);
+       func_enter2();
+       sx_dprintk(SX_DEBUG_TRANSMIT, "Port %p: transmit %d chars\n",
+                       port, port->gs.xmit_cnt);
 
-       if (test_and_set_bit (SX_PORT_TRANSMIT_LOCK, &port->locks)) {
+       if (test_and_set_bit(SX_PORT_TRANSMIT_LOCK, &port->locks)) {
                return;
        }
 
        while (1) {
                c = port->gs.xmit_cnt;
 
-               sx_dprintk (SX_DEBUG_TRANSMIT, "Copying %d ", c);
-               tx_ip  = sx_read_channel_byte (port, hi_txipos);
+               sx_dprintk(SX_DEBUG_TRANSMIT, "Copying %d ", c);
+               tx_ip = sx_read_channel_byte(port, hi_txipos);
 
                /* Took me 5 minutes to deduce this formula. 
                   Luckily it is literally in the manual in section 6.5.4.3.5 */
-               txroom = (sx_read_channel_byte (port, hi_txopos) - tx_ip - 1) & 0xff;
+               txroom = (sx_read_channel_byte(port, hi_txopos) - tx_ip - 1) &
+                               0xff;
 
                /* Don't copy more bytes than there is room for in the buffer */
                if (c > txroom)
                        c = txroom;
-               sx_dprintk (SX_DEBUG_TRANSMIT, " %d(%d) ", c, txroom );
+               sx_dprintk(SX_DEBUG_TRANSMIT, " %d(%d) ", c, txroom);
 
                /* Don't copy past the end of the hardware transmit buffer */
-               if (c > 0x100 - tx_ip) 
+               if (c > 0x100 - tx_ip)
                        c = 0x100 - tx_ip;
 
-               sx_dprintk (SX_DEBUG_TRANSMIT, " %d(%d) ", c, 0x100-tx_ip );
+               sx_dprintk(SX_DEBUG_TRANSMIT, " %d(%d) ", c, 0x100 - tx_ip);
 
                /* Don't copy pas the end of the source buffer */
-               if (c > SERIAL_XMIT_SIZE - port->gs.xmit_tail) 
+               if (c > SERIAL_XMIT_SIZE - port->gs.xmit_tail)
                        c = SERIAL_XMIT_SIZE - port->gs.xmit_tail;
 
-               sx_dprintk (SX_DEBUG_TRANSMIT, " %d(%ld) \n", 
-                           c, SERIAL_XMIT_SIZE- port->gs.xmit_tail);
-
-               /* If for one reason or another, we can't copy more data, we're done! */
-               if (c == 0) break;
+               sx_dprintk(SX_DEBUG_TRANSMIT, " %d(%ld) \n",
+                               c, SERIAL_XMIT_SIZE - port->gs.xmit_tail);
 
+               /* If for one reason or another, we can't copy more data, we're
+                  done! */
+               if (c == 0)
+                       break;
 
-               memcpy_toio (port->board->base + CHAN_OFFSET(port,hi_txbuf) + tx_ip, 
-                            port->gs.xmit_buf + port->gs.xmit_tail, c);
+               memcpy_toio(port->board->base + CHAN_OFFSET(port, hi_txbuf) +
+                       tx_ip, port->gs.xmit_buf + port->gs.xmit_tail, c);
 
                /* Update the pointer in the card */
-               sx_write_channel_byte (port, hi_txipos, (tx_ip+c) & 0xff);
+               sx_write_channel_byte(port, hi_txipos, (tx_ip + c) & 0xff);
 
                /* Update the kernel buffer end */
-               port->gs.xmit_tail = (port->gs.xmit_tail + c) & (SERIAL_XMIT_SIZE-1);
+               port->gs.xmit_tail = (port->gs.xmit_tail + c) &
+                               (SERIAL_XMIT_SIZE - 1);
 
                /* This one last. (this is essential)
-                  It would allow others to start putting more data into the buffer! */
+                  It would allow others to start putting more data into the
+                  buffer! */
                port->gs.xmit_cnt -= c;
        }
 
        if (port->gs.xmit_cnt == 0) {
-               sx_disable_tx_interrupts (port);
+               sx_disable_tx_interrupts(port);
        }
 
        if ((port->gs.xmit_cnt <= port->gs.wakeup_chars) && port->gs.tty) {
                tty_wakeup(port->gs.tty);
-               sx_dprintk (SX_DEBUG_TRANSMIT, "Waking up.... ldisc (%d)....\n",
-                           port->gs.wakeup_chars); 
+               sx_dprintk(SX_DEBUG_TRANSMIT, "Waking up.... ldisc (%d)....\n",
+                               port->gs.wakeup_chars);
        }
 
-       clear_bit (SX_PORT_TRANSMIT_LOCK, &port->locks);
-       func_exit ();
+       clear_bit(SX_PORT_TRANSMIT_LOCK, &port->locks);
+       func_exit();
 }
 
-
 /* Note the symmetry between receiving chars and transmitting them!
    Note: The kernel should have implemented both a receive buffer and
    a transmit buffer. */
 
 /* Inlined: Called only once. Remove the inline when you add another call */
-static inline void sx_receive_chars (struct sx_port *port)
+static inline void sx_receive_chars(struct sx_port *port)
 {
        int c;
        int rx_op;
        struct tty_struct *tty;
-       int copied=0;
+       int copied = 0;
        unsigned char *rp;
 
-       func_enter2 ();
+       func_enter2();
        tty = port->gs.tty;
        while (1) {
-               rx_op = sx_read_channel_byte (port, hi_rxopos);
-               c = (sx_read_channel_byte (port, hi_rxipos) - rx_op) & 0xff;
+               rx_op = sx_read_channel_byte(port, hi_rxopos);
+               c = (sx_read_channel_byte(port, hi_rxipos) - rx_op) & 0xff;
 
-               sx_dprintk (SX_DEBUG_RECEIVE, "rxop=%d, c = %d.\n", rx_op, c); 
+               sx_dprintk(SX_DEBUG_RECEIVE, "rxop=%d, c = %d.\n", rx_op, c);
 
                /* Don't copy past the end of the hardware receive buffer */
-               if (rx_op + c > 0x100) c = 0x100 - rx_op;
+               if (rx_op + c > 0x100)
+                       c = 0x100 - rx_op;
 
-               sx_dprintk (SX_DEBUG_RECEIVE, "c = %d.\n", c);
+               sx_dprintk(SX_DEBUG_RECEIVE, "c = %d.\n", c);
 
                /* Don't copy more bytes than there is room for in the buffer */
 
                c = tty_prepare_flip_string(tty, &rp, c);
 
-               sx_dprintk (SX_DEBUG_RECEIVE, "c = %d.\n", c); 
+               sx_dprintk(SX_DEBUG_RECEIVE, "c = %d.\n", c);
 
                /* If for one reason or another, we can't copy more data, we're done! */
-               if (c == 0) break;
+               if (c == 0)
+                       break;
 
-               sx_dprintk (SX_DEBUG_RECEIVE , "Copying over %d chars. First is %d at %lx\n", c, 
-                           read_sx_byte (port->board, CHAN_OFFSET(port,hi_rxbuf) + rx_op),
-                           CHAN_OFFSET(port, hi_rxbuf)); 
-               memcpy_fromio (rp,
-                              port->board->base + CHAN_OFFSET(port,hi_rxbuf) + rx_op, c);
+               sx_dprintk(SX_DEBUG_RECEIVE, "Copying over %d chars. First is "
+                               "%d at %lx\n", c, read_sx_byte(port->board,
+                                       CHAN_OFFSET(port, hi_rxbuf) + rx_op),
+                               CHAN_OFFSET(port, hi_rxbuf));
+               memcpy_fromio(rp, port->board->base +
+                               CHAN_OFFSET(port, hi_rxbuf) + rx_op, c);
 
                /* This one last. ( Not essential.)
-                  It allows the card to start putting more data into the buffer! 
+                  It allows the card to start putting more data into the
+                  buffer!
                   Update the pointer in the card */
-               sx_write_channel_byte (port, hi_rxopos, (rx_op + c) & 0xff);
+               sx_write_channel_byte(port, hi_rxopos, (rx_op + c) & 0xff);
 
                copied += c;
        }
        if (copied) {
                struct timeval tv;
 
-               do_gettimeofday (&tv);
-               sx_dprintk (SX_DEBUG_RECEIVE, 
-                           "pushing flipq port %d (%3d chars): %d.%06d  (%d/%d)\n", 
-                           port->line, copied, 
-                           (int) (tv.tv_sec % 60), (int)tv.tv_usec, tty->raw, tty->real_raw);
+               do_gettimeofday(&tv);
+               sx_dprintk(SX_DEBUG_RECEIVE, "pushing flipq port %d (%3d "
+                               "chars): %d.%06d  (%d/%d)\n", port->line,
+                               copied, (int)(tv.tv_sec % 60), (int)tv.tv_usec,
+                               tty->raw, tty->real_raw);
 
-               /* Tell the rest of the system the news. Great news. New characters! */
-               tty_flip_buffer_push (tty);
+               /* Tell the rest of the system the news. Great news. New
+                  characters! */
+               tty_flip_buffer_push(tty);
                /*    tty_schedule_flip (tty); */
        }
 
-       func_exit ();
+       func_exit();
 }
 
 /* Inlined: it is called only once. Remove the inline if you add another 
    call */
-static inline void sx_check_modem_signals (struct sx_port *port)
+static inline void sx_check_modem_signals(struct sx_port *port)
 {
        int hi_state;
        int c_dcd;
 
-       hi_state = sx_read_channel_byte (port, hi_state);
-       sx_dprintk (SX_DEBUG_MODEMSIGNALS, "Checking modem signals (%d/%d)\n",
-                   port->c_dcd, sx_get_CD (port));
+       hi_state = sx_read_channel_byte(port, hi_state);
+       sx_dprintk(SX_DEBUG_MODEMSIGNALS, "Checking modem signals (%d/%d)\n",
+                       port->c_dcd, sx_get_CD(port));
 
        if (hi_state & ST_BREAK) {
                hi_state &= ~ST_BREAK;
-               sx_dprintk (SX_DEBUG_MODEMSIGNALS, "got a break.\n");
-               sx_write_channel_byte (port, hi_state, hi_state);
-               gs_got_break (&port->gs);
+               sx_dprintk(SX_DEBUG_MODEMSIGNALS, "got a break.\n");
+               sx_write_channel_byte(port, hi_state, hi_state);
+               gs_got_break(&port->gs);
        }
        if (hi_state & ST_DCD) {
                hi_state &= ~ST_DCD;
-               sx_dprintk (SX_DEBUG_MODEMSIGNALS, "got a DCD change.\n");
-               sx_write_channel_byte (port, hi_state, hi_state);
-               c_dcd = sx_get_CD (port);
-               sx_dprintk (SX_DEBUG_MODEMSIGNALS, "DCD is now %d\n", c_dcd);
+               sx_dprintk(SX_DEBUG_MODEMSIGNALS, "got a DCD change.\n");
+               sx_write_channel_byte(port, hi_state, hi_state);
+               c_dcd = sx_get_CD(port);
+               sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD is now %d\n", c_dcd);
                if (c_dcd != port->c_dcd) {
                        port->c_dcd = c_dcd;
-                       if (sx_get_CD (port)) {
+                       if (sx_get_CD(port)) {
                                /* DCD went UP */
-                               if ((sx_read_channel_byte(port, hi_hstat) != HS_IDLE_CLOSED) &&
-                                               !(port->gs.tty->termios->c_cflag & CLOCAL) ) {
-                                       /* Are we blocking in open?*/
-                                       sx_dprintk (SX_DEBUG_MODEMSIGNALS, "DCD active, unblocking open\n");
-                                       wake_up_interruptible(&port->gs.open_wait);
+                               if ((sx_read_channel_byte(port, hi_hstat) !=
+                                               HS_IDLE_CLOSED) &&
+                                               !(port->gs.tty->termios->
+                                                       c_cflag & CLOCAL)) {
+                                       /* Are we blocking in open? */
+                                       sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD "
+                                               "active, unblocking open\n");
+                                       wake_up_interruptible(&port->gs.
+                                                       open_wait);
                                } else {
-                                       sx_dprintk (SX_DEBUG_MODEMSIGNALS, "DCD raised. Ignoring.\n");
+                                       sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD "
+                                               "raised. Ignoring.\n");
                                }
                        } else {
                                /* DCD went down! */
-                               if (!(port->gs.tty->termios->c_cflag & CLOCAL) ) {
-                                       sx_dprintk (SX_DEBUG_MODEMSIGNALS, "DCD dropped. hanging up....\n");
-                                       tty_hangup (port->gs.tty);
+                               if (!(port->gs.tty->termios->c_cflag & CLOCAL)){
+                                       sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD "
+                                               "dropped. hanging up....\n");
+                                       tty_hangup(port->gs.tty);
                                } else {
-                                       sx_dprintk (SX_DEBUG_MODEMSIGNALS, "DCD dropped. ignoring.\n");
+                                       sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD "
+                                               "dropped. ignoring.\n");
                                }
                        }
                } else {
-                       sx_dprintk (SX_DEBUG_MODEMSIGNALS, "Hmmm. card told us DCD changed, but it didn't.\n");
+                       sx_dprintk(SX_DEBUG_MODEMSIGNALS, "Hmmm. card told us "
+                               "DCD changed, but it didn't.\n");
                }
        }
 }
 
-
 /* This is what an interrupt routine should look like. 
  * Small, elegant, clear.
  */
 
-static irqreturn_t sx_interrupt (int irq, void *ptr)
+static irqreturn_t sx_interrupt(int irq, void *ptr)
 {
        struct sx_board *board = ptr;
        struct sx_port *port;
        int i;
 
-       func_enter ();
-       sx_dprintk (SX_DEBUG_FLOW, "sx: enter sx_interrupt (%d/%d)\n", irq, board->irq); 
+       func_enter();
+       sx_dprintk(SX_DEBUG_FLOW, "sx: enter sx_interrupt (%d/%d)\n", irq,
+                       board->irq);
 
        /* AAargh! The order in which to do these things is essential and
           not trivial. 
 
           - Rate limit goes before "recursive". Otherwise a series of
-            recursive calls will hang the machine in the interrupt routine. 
+          recursive calls will hang the machine in the interrupt routine.
 
           - hardware twiddling goes before "recursive". Otherwise when we
-            poll the card, and a recursive interrupt happens, we won't
-            ack the card, so it might keep on interrupting us. (especially
-            level sensitive interrupt systems like PCI).
+          poll the card, and a recursive interrupt happens, we won't
+          ack the card, so it might keep on interrupting us. (especially
+          level sensitive interrupt systems like PCI).
 
           - Rate limit goes before hardware twiddling. Otherwise we won't
-            catch a card that has gone bonkers.
+          catch a card that has gone bonkers.
 
           - The "initialized" test goes after the hardware twiddling. Otherwise
-            the card will stick us in the interrupt routine again.
+          the card will stick us in the interrupt routine again.
 
           - The initialized test goes before recursive. 
-       */
-
-
+        */
 
 #ifdef IRQ_RATE_LIMIT
        /* Aaargh! I'm ashamed. This costs more lines-of-code than the
-          actual interrupt routine!. (Well, used to when I wrote that comment) */
+          actual interrupt routine!. (Well, used to when I wrote that
+          comment) */
        {
                static int lastjif;
-               static int nintr=0;
+               static int nintr = 0;
 
                if (lastjif == jiffies) {
                        if (++nintr > IRQ_RATE_LIMIT) {
-                               free_irq (board->irq, board);
-                               printk (KERN_ERR "sx: Too many interrupts. Turning off interrupt %d.\n", 
-                                             board->irq);
+                               free_irq(board->irq, board);
+                               printk(KERN_ERR "sx: Too many interrupts. "
+                                               "Turning off interrupt %d.\n",
+                                               board->irq);
                        }
                } else {
                        lastjif = jiffies;
@@ -1243,19 +1293,20 @@ static irqreturn_t sx_interrupt (int irq, void *ptr)
        }
 #endif
 
-
        if (board->irq == irq) {
                /* Tell the card we've noticed the interrupt. */
 
-               sx_write_board_word (board, cc_int_pending, 0);
-               if (IS_SX_BOARD (board)) {
-                       write_sx_byte (board, SX_RESET_IRQ, 1);
+               sx_write_board_word(board, cc_int_pending, 0);
+               if (IS_SX_BOARD(board)) {
+                       write_sx_byte(board, SX_RESET_IRQ, 1);
                } else if (IS_EISA_BOARD(board)) {
-                       inb(board->eisa_base+0xc03);
-                       write_sx_word(board, 8, 0); 
+                       inb(board->eisa_base + 0xc03);
+                       write_sx_word(board, 8, 0);
                } else {
-                       write_sx_byte (board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_CLEAR);
-                       write_sx_byte (board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_SET);
+                       write_sx_byte(board, SI2_ISA_INTCLEAR,
+                                       SI2_ISA_INTCLEAR_CLEAR);
+                       write_sx_byte(board, SI2_ISA_INTCLEAR,
+                                       SI2_ISA_INTCLEAR_SET);
                }
        }
 
@@ -1264,53 +1315,48 @@ static irqreturn_t sx_interrupt (int irq, void *ptr)
        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);
+       if (test_and_set_bit(SX_BOARD_INTR_LOCK, &board->locks)) {
+               printk(KERN_ERR "Recursive interrupt! (%d)\n", board->irq);
                return IRQ_HANDLED;
        }
 
-        for (i=0;i<board->nports;i++) {
+       for (i = 0; i < board->nports; i++) {
                port = &board->ports[i];
                if (port->gs.flags & GS_ACTIVE) {
-                       if (sx_read_channel_byte (port, hi_state)) {
-                               sx_dprintk (SX_DEBUG_INTERRUPTS, 
-                                           "Port %d: modem signal change?... \n", i);
-                               sx_check_modem_signals (port); 
+                       if (sx_read_channel_byte(port, hi_state)) {
+                               sx_dprintk(SX_DEBUG_INTERRUPTS, "Port %d: "
+                                               "modem signal change?... \n",i);
+                               sx_check_modem_signals(port);
                        }
                        if (port->gs.xmit_cnt) {
-                               sx_transmit_chars (port);
+                               sx_transmit_chars(port);
                        }
                        if (!(port->gs.flags & SX_RX_THROTTLE)) {
-                               sx_receive_chars (port);
+                               sx_receive_chars(port);
                        }
                }
        }
 
-       clear_bit (SX_BOARD_INTR_LOCK, &board->locks);
+       clear_bit(SX_BOARD_INTR_LOCK, &board->locks);
 
-       sx_dprintk (SX_DEBUG_FLOW, "sx: exit sx_interrupt (%d/%d)\n", irq, board->irq); 
-        func_exit ();
+       sx_dprintk(SX_DEBUG_FLOW, "sx: exit sx_interrupt (%d/%d)\n", irq,
+                       board->irq);
+       func_exit();
        return IRQ_HANDLED;
 }
 
-
-static void sx_pollfunc (unsigned long data)
+static void sx_pollfunc(unsigned long data)
 {
-       struct sx_board *board = (struct sx_board *) data;
-
-       func_enter ();
+       struct sx_board *board = (struct sx_board *)data;
 
-       sx_interrupt (0, board);
+       func_enter();
 
-       init_timer(&board->timer);
+       sx_interrupt(0, board);
 
-       board->timer.expires = jiffies + sx_poll;
-       add_timer (&board->timer);
-       func_exit ();
+       mod_timer(&board->timer, jiffies + sx_poll);
+       func_exit();
 }
 
-
-
 /* ********************************************************************** *
  *                Here are the routines that actually                     *
  *              interface with the generic_serial driver                  *
@@ -1319,9 +1365,9 @@ static void sx_pollfunc (unsigned long data)
 /* Ehhm. I don't know how to fiddle with interrupts on the SX card. --REW */
 /* Hmm. Ok I figured it out. You don't.  */
 
-static void sx_disable_tx_interrupts (void * ptr) 
+static void sx_disable_tx_interrupts(void *ptr)
 {
-       struct sx_port *port = ptr; 
+       struct sx_port *port = ptr;
        func_enter2();
 
        port->gs.flags &= ~GS_TX_INTEN;
@@ -1329,30 +1375,28 @@ static void sx_disable_tx_interrupts (void * ptr)
        func_exit();
 }
 
-
-static void sx_enable_tx_interrupts (void * ptr) 
+static void sx_enable_tx_interrupts(void *ptr)
 {
-       struct sx_port *port = ptr; 
+       struct sx_port *port = ptr;
        int data_in_buffer;
        func_enter2();
 
        /* First transmit the characters that we're supposed to */
-       sx_transmit_chars (port);
+       sx_transmit_chars(port);
 
        /* The sx card will never interrupt us if we don't fill the buffer
           past 25%. So we keep considering interrupts off if that's the case. */
-       data_in_buffer = (sx_read_channel_byte (port, hi_txipos) - 
-                         sx_read_channel_byte (port, hi_txopos)) & 0xff;
+       data_in_buffer = (sx_read_channel_byte(port, hi_txipos) -
+                         sx_read_channel_byte(port, hi_txopos)) & 0xff;
 
        /* XXX Must be "HIGH_WATER" for SI card according to doc. */
-       if (data_in_buffer < LOW_WATER) 
+       if (data_in_buffer < LOW_WATER)
                port->gs.flags &= ~GS_TX_INTEN;
 
        func_exit();
 }
 
-
-static void sx_disable_rx_interrupts (void * ptr) 
+static void sx_disable_rx_interrupts(void *ptr)
 {
        /*  struct sx_port *port = ptr; */
        func_enter();
@@ -1360,7 +1404,7 @@ static void sx_disable_rx_interrupts (void * ptr)
        func_exit();
 }
 
-static void sx_enable_rx_interrupts (void * ptr) 
+static void sx_enable_rx_interrupts(void *ptr)
 {
        /*  struct sx_port *port = ptr; */
        func_enter();
@@ -1368,55 +1412,48 @@ static void sx_enable_rx_interrupts (void * ptr)
        func_exit();
 }
 
-
 /* Jeez. Isn't this simple? */
-static int sx_get_CD (void * ptr) 
+static int sx_get_CD(void *ptr)
 {
        struct sx_port *port = ptr;
        func_enter2();
 
        func_exit();
-       return ((sx_read_channel_byte (port, hi_ip) & IP_DCD) != 0);
+       return ((sx_read_channel_byte(port, hi_ip) & IP_DCD) != 0);
 }
 
-
 /* Jeez. Isn't this simple? */
-static int sx_chars_in_buffer (void * ptr) 
+static int sx_chars_in_buffer(void *ptr)
 {
        struct sx_port *port = ptr;
        func_enter2();
 
        func_exit();
-       return ((sx_read_channel_byte (port, hi_txipos) - 
-                sx_read_channel_byte (port, hi_txopos)) & 0xff);
+       return ((sx_read_channel_byte(port, hi_txipos) -
+                sx_read_channel_byte(port, hi_txopos)) & 0xff);
 }
 
-
-static void sx_shutdown_port (void * ptr) 
+static void sx_shutdown_port(void *ptr)
 {
-       struct sx_port *port = ptr; 
+       struct sx_port *port = ptr;
 
        func_enter();
 
-       port->gs.flags &= ~ GS_ACTIVE;
+       port->gs.flags &= ~GS_ACTIVE;
        if (port->gs.tty && (port->gs.tty->termios->c_cflag & HUPCL)) {
-               sx_setsignals (port, 0, 0);
+               sx_setsignals(port, 0, 0);
                sx_reconfigure_port(port);
        }
 
        func_exit();
 }
 
-
-
-
-
 /* ********************************************************************** *
  *                Here are the routines that actually                     *
  *               interface with the rest of the system                    *
  * ********************************************************************** */
 
-static int sx_open  (struct tty_struct * tty, struct file * filp)
+static int sx_open(struct tty_struct *tty, struct file *filp)
 {
        struct sx_port *port;
        int retval, line;
@@ -1429,18 +1466,18 @@ static int sx_open  (struct tty_struct * tty, struct file * filp)
        }
 
        line = tty->index;
-       sx_dprintk (SX_DEBUG_OPEN, "%d: opening line %d. tty=%p ctty=%p, np=%d)\n", 
-                   current->pid, line, tty, current->signal->tty, sx_nports);
+       sx_dprintk(SX_DEBUG_OPEN, "%d: opening line %d. tty=%p ctty=%p, "
+                       "np=%d)\n", current->pid, line, tty,
+                       current->signal->tty, sx_nports);
 
        if ((line < 0) || (line >= SX_NPORTS) || (line >= sx_nports))
                return -ENODEV;
 
-       port = & sx_ports[line];
+       port = &sx_ports[line];
        port->c_dcd = 0; /* Make sure that the first interrupt doesn't detect a
-                           1 -> 0 transition. */
+                           1 -> 0 transition. */
 
-
-       sx_dprintk (SX_DEBUG_OPEN, "port = %p c_dcd = %d\n", port, port->c_dcd);
+       sx_dprintk(SX_DEBUG_OPEN, "port = %p c_dcd = %d\n", port, port->c_dcd);
 
        spin_lock_irqsave(&port->gs.driver_lock, flags);
 
@@ -1449,13 +1486,13 @@ static int sx_open  (struct tty_struct * tty, struct file * filp)
        port->gs.count++;
        spin_unlock_irqrestore(&port->gs.driver_lock, flags);
 
-       sx_dprintk (SX_DEBUG_OPEN, "starting port\n");
+       sx_dprintk(SX_DEBUG_OPEN, "starting port\n");
 
        /*
         * Start up serial port
         */
        retval = gs_init_port(&port->gs);
-       sx_dprintk (SX_DEBUG_OPEN, "done gs_init\n");
+       sx_dprintk(SX_DEBUG_OPEN, "done gs_init\n");
        if (retval) {
                port->gs.count--;
                return retval;
@@ -1463,19 +1500,20 @@ static int sx_open  (struct tty_struct * tty, struct file * filp)
 
        port->gs.flags |= GS_ACTIVE;
        if (port->gs.count <= 1)
-               sx_setsignals (port, 1,1);
+               sx_setsignals(port, 1, 1);
 
 #if 0
        if (sx_debug & SX_DEBUG_OPEN)
-               my_hd (port, sizeof (*port));
+               my_hd(port, sizeof(*port));
 #else
        if (sx_debug & SX_DEBUG_OPEN)
-               my_hd_io (port->board->base + port->ch_base, sizeof (*port));
+               my_hd_io(port->board->base + port->ch_base, sizeof(*port));
 #endif
 
        if (port->gs.count <= 1) {
-               if (sx_send_command (port, HS_LOPEN, -1, HS_IDLE_OPEN) != 1) {
-                       printk (KERN_ERR "sx: Card didn't respond to LOPEN command.\n");
+               if (sx_send_command(port, HS_LOPEN, -1, HS_IDLE_OPEN) != 1) {
+                       printk(KERN_ERR "sx: Card didn't respond to LOPEN "
+                                       "command.\n");
                        spin_lock_irqsave(&port->gs.driver_lock, flags);
                        port->gs.count--;
                        spin_unlock_irqrestore(&port->gs.driver_lock, flags);
@@ -1484,75 +1522,76 @@ static int sx_open  (struct tty_struct * tty, struct file * filp)
        }
 
        retval = gs_block_til_ready(port, filp);
-       sx_dprintk (SX_DEBUG_OPEN, "Block til ready returned %d. Count=%d\n", 
-                   retval, port->gs.count);
+       sx_dprintk(SX_DEBUG_OPEN, "Block til ready returned %d. Count=%d\n",
+                       retval, port->gs.count);
 
        if (retval) {
-               /* 
               * Don't lower gs.count here because sx_close() will be called later
-                */ 
+/*
+ * Don't lower gs.count here because sx_close() will be called later
+ */
 
                return retval;
        }
        /* tty->low_latency = 1; */
 
-       port->c_dcd = sx_get_CD (port);
-       sx_dprintk (SX_DEBUG_OPEN, "at open: cd=%d\n", port->c_dcd);
+       port->c_dcd = sx_get_CD(port);
+       sx_dprintk(SX_DEBUG_OPEN, "at open: cd=%d\n", port->c_dcd);
 
        func_exit();
        return 0;
 
 }
 
-
-static void sx_close (void *ptr)
+static void sx_close(void *ptr)
 {
-       struct sx_port *port = ptr; 
+       struct sx_port *port = ptr;
        /* Give the port 5 seconds to close down. */
-       int to = 5 * HZ; 
+       int to = 5 * HZ;
 
-       func_enter ();
+       func_enter();
 
-       sx_setsignals (port, 0, 0);
-       sx_reconfigure_port(port);      
-       sx_send_command (port, HS_CLOSE, 0, 0);
+       sx_setsignals(port, 0, 0);
+       sx_reconfigure_port(port);
+       sx_send_command(port, HS_CLOSE, 0, 0);
 
-       while (to-- && (sx_read_channel_byte (port, hi_hstat) != HS_IDLE_CLOSED))
+       while (to-- && (sx_read_channel_byte(port, hi_hstat) != HS_IDLE_CLOSED))
                if (msleep_interruptible(10))
                        break;
-       if (sx_read_channel_byte (port, hi_hstat) != HS_IDLE_CLOSED) {
-               if (sx_send_command (port, HS_FORCE_CLOSED, -1, HS_IDLE_CLOSED) != 1) {
-                       printk (KERN_ERR 
-                               "sx: sent the force_close command, but card didn't react\n");
+       if (sx_read_channel_byte(port, hi_hstat) != HS_IDLE_CLOSED) {
+               if (sx_send_command(port, HS_FORCE_CLOSED, -1, HS_IDLE_CLOSED)
+                               != 1) {
+                       printk(KERN_ERR "sx: sent the force_close command, but "
+                                       "card didn't react\n");
                } else
-                       sx_dprintk (SX_DEBUG_CLOSE, "sent the force_close command.\n");
+                       sx_dprintk(SX_DEBUG_CLOSE, "sent the force_close "
+                                       "command.\n");
        }
 
-       sx_dprintk (SX_DEBUG_CLOSE, "waited %d jiffies for close. count=%d\n", 
-                   5 * HZ - to - 1, port->gs.count);
+       sx_dprintk(SX_DEBUG_CLOSE, "waited %d jiffies for close. count=%d\n",
+                       5 * HZ - to - 1, port->gs.count);
 
-       if(port->gs.count) {
-               sx_dprintk(SX_DEBUG_CLOSE, "WARNING port count:%d\n", port->gs.count);
-               //printk ("%s SETTING port count to zero: %p count: %d\n", __FUNCTION__, port, port->gs.count);
-               //port->gs.count = 0;
+       if (port->gs.count) {
+               sx_dprintk(SX_DEBUG_CLOSE, "WARNING port count:%d\n",
+                               port->gs.count);
+               /*printk("%s SETTING port count to zero: %p count: %d\n",
+                               __FUNCTION__, port, port->gs.count);
+               port->gs.count = 0;*/
        }
 
-       func_exit ();
+       func_exit();
 }
 
-
-
 /* This is relatively thorough. But then again it is only 20 lines. */
-#define MARCHUP    for (i=min;i<max;i++) 
-#define MARCHDOWN  for (i=max-1;i>=min;i--)
-#define W0         write_sx_byte (board, i, 0x55)
-#define W1         write_sx_byte (board, i, 0xaa)
-#define R0         if (read_sx_byte (board, i) != 0x55) return 1
-#define R1         if (read_sx_byte (board, i) != 0xaa) return 1
+#define MARCHUP                for (i = min; i < max; i++)
+#define MARCHDOWN      for (i = max - 1; i >= min; i--)
+#define W0             write_sx_byte(board, i, 0x55)
+#define W1             write_sx_byte(board, i, 0xaa)
+#define R0             if (read_sx_byte(board, i) != 0x55) return 1
+#define R1             if (read_sx_byte(board, i) != 0xaa) return 1
 
 /* This memtest takes a human-noticable time. You normally only do it
    once a boot, so I guess that it is worth it. */
-static int do_memtest (struct sx_board *board, int min, int max)
+static int do_memtest(struct sx_board *board, int min, int max)
 {
        int i;
 
@@ -1561,16 +1600,37 @@ static int do_memtest (struct sx_board *board, int min, int max)
           intermittent errors. -- REW
           (For the theory behind memory testing see: 
           Testing Semiconductor Memories by A.J. van de Goor.) */
-       MARCHUP  {W0;}
-       MARCHUP   {R0;W1;R1;W0;R0;W1;}
-       MARCHUP   {R1;W0;W1;}
-       MARCHDOWN {R1;W0;W1;W0;}
-       MARCHDOWN {R0;W1;W0;}
+       MARCHUP {
+               W0;
+       }
+       MARCHUP {
+               R0;
+               W1;
+               R1;
+               W0;
+               R0;
+               W1;
+       }
+       MARCHUP {
+               R1;
+               W0;
+               W1;
+       }
+       MARCHDOWN {
+               R1;
+               W0;
+               W1;
+               W0;
+       }
+       MARCHDOWN {
+               R0;
+               W1;
+               W0;
+       }
 
        return 0;
 }
 
-
 #undef MARCHUP
 #undef MARCHDOWN
 #undef W0
@@ -1578,33 +1638,54 @@ static int do_memtest (struct sx_board *board, int min, int max)
 #undef R0
 #undef R1
 
-#define MARCHUP    for (i=min;i<max;i+=2) 
-#define MARCHDOWN  for (i=max-1;i>=min;i-=2)
-#define W0         write_sx_word (board, i, 0x55aa)
-#define W1         write_sx_word (board, i, 0xaa55)
-#define R0         if (read_sx_word (board, i) != 0x55aa) return 1
-#define R1         if (read_sx_word (board, i) != 0xaa55) return 1
+#define MARCHUP                for (i = min; i < max; i += 2)
+#define MARCHDOWN      for (i = max - 1; i >= min; i -= 2)
+#define W0             write_sx_word(board, i, 0x55aa)
+#define W1             write_sx_word(board, i, 0xaa55)
+#define R0             if (read_sx_word(board, i) != 0x55aa) return 1
+#define R1             if (read_sx_word(board, i) != 0xaa55) return 1
 
 #if 0
 /* This memtest takes a human-noticable time. You normally only do it
    once a boot, so I guess that it is worth it. */
-static int do_memtest_w (struct sx_board *board, int min, int max)
+static int do_memtest_w(struct sx_board *board, int min, int max)
 {
        int i;
 
-       MARCHUP   {W0;}
-       MARCHUP   {R0;W1;R1;W0;R0;W1;}
-       MARCHUP   {R1;W0;W1;}
-       MARCHDOWN {R1;W0;W1;W0;}
-       MARCHDOWN {R0;W1;W0;}
+       MARCHUP {
+               W0;
+       }
+       MARCHUP {
+               R0;
+               W1;
+               R1;
+               W0;
+               R0;
+               W1;
+       }
+       MARCHUP {
+               R1;
+               W0;
+               W1;
+       }
+       MARCHDOWN {
+               R1;
+               W0;
+               W1;
+               W0;
+       }
+       MARCHDOWN {
+               R0;
+               W1;
+               W0;
+       }
 
        return 0;
 }
 #endif
 
-
-static int sx_fw_ioctl (struct inode *inode, struct file *filp,
-                        unsigned int cmd, unsigned long arg)
+static int sx_fw_ioctl(struct inode *inode, struct file *filp,
+               unsigned int cmd, unsigned long arg)
 {
        int rc = 0;
        int __user *descr = (int __user *)arg;
@@ -1616,7 +1697,7 @@ static int sx_fw_ioctl (struct inode *inode, struct file *filp,
 
        func_enter();
 
-#if 0 
+#if 0
        /* Removed superuser check: Sysops can use the permissions on the device
           file to restrict access. Recommendation: Root only. (root.root 600) */
        if (!capable(CAP_SYS_ADMIN)) {
@@ -1624,103 +1705,115 @@ static int sx_fw_ioctl (struct inode *inode, struct file *filp,
        }
 #endif
 
-       sx_dprintk (SX_DEBUG_FIRMWARE, "IOCTL %x: %lx\n", cmd, arg);
+       sx_dprintk(SX_DEBUG_FIRMWARE, "IOCTL %x: %lx\n", cmd, arg);
 
-       if (!board) board = &boards[0];
+       if (!board)
+               board = &boards[0];
        if (board->flags & SX_BOARD_PRESENT) {
-               sx_dprintk (SX_DEBUG_FIRMWARE, "Board present! (%x)\n", 
-                           board->flags);
+               sx_dprintk(SX_DEBUG_FIRMWARE, "Board present! (%x)\n",
+                               board->flags);
        } else {
-               sx_dprintk (SX_DEBUG_FIRMWARE, "Board not present! (%x) all:", 
-                           board->flags);
-               for (i=0;i< SX_NBOARDS;i++)
-                       sx_dprintk (SX_DEBUG_FIRMWARE, "<%x> ", boards[i].flags);
-               sx_dprintk (SX_DEBUG_FIRMWARE, "\n");
+               sx_dprintk(SX_DEBUG_FIRMWARE, "Board not present! (%x) all:",
+                               board->flags);
+               for (i = 0; i < SX_NBOARDS; i++)
+                       sx_dprintk(SX_DEBUG_FIRMWARE, "<%x> ", boards[i].flags);
+               sx_dprintk(SX_DEBUG_FIRMWARE, "\n");
                return -EIO;
        }
 
        switch (cmd) {
        case SXIO_SET_BOARD:
-               sx_dprintk (SX_DEBUG_FIRMWARE, "set board to %ld\n", arg);
-               if (arg >= SX_NBOARDS) return -EIO;
-               sx_dprintk (SX_DEBUG_FIRMWARE, "not out of range\n");
-               if (!(boards[arg].flags & SX_BOARD_PRESENT)) return -EIO;
-               sx_dprintk (SX_DEBUG_FIRMWARE, ".. and present!\n");
+               sx_dprintk(SX_DEBUG_FIRMWARE, "set board to %ld\n", arg);
+               if (arg >= SX_NBOARDS)
+                       return -EIO;
+               sx_dprintk(SX_DEBUG_FIRMWARE, "not out of range\n");
+               if (!(boards[arg].flags & SX_BOARD_PRESENT))
+                       return -EIO;
+               sx_dprintk(SX_DEBUG_FIRMWARE, ".. and present!\n");
                board = &boards[arg];
                break;
        case SXIO_GET_TYPE:
-               rc = -ENOENT; /* If we manage to miss one, return error. */
-               if (IS_SX_BOARD (board)) rc = SX_TYPE_SX;
-               if (IS_CF_BOARD (board)) rc = SX_TYPE_CF;
-               if (IS_SI_BOARD (board)) rc = SX_TYPE_SI;
-               if (IS_SI1_BOARD (board)) rc = SX_TYPE_SI;
-               if (IS_EISA_BOARD (board)) rc = SX_TYPE_SI;
-               sx_dprintk (SX_DEBUG_FIRMWARE, "returning type= %d\n", rc);
+               rc = -ENOENT;   /* If we manage to miss one, return error. */
+               if (IS_SX_BOARD(board))
+                       rc = SX_TYPE_SX;
+               if (IS_CF_BOARD(board))
+                       rc = SX_TYPE_CF;
+               if (IS_SI_BOARD(board))
+                       rc = SX_TYPE_SI;
+               if (IS_SI1_BOARD(board))
+                       rc = SX_TYPE_SI;
+               if (IS_EISA_BOARD(board))
+                       rc = SX_TYPE_SI;
+               sx_dprintk(SX_DEBUG_FIRMWARE, "returning type= %d\n", rc);
                break;
        case SXIO_DO_RAMTEST:
-               if (sx_initialized) /* Already initialized: better not ramtest the board.  */
+               if (sx_initialized)     /* Already initialized: better not ramtest the board.  */
                        return -EPERM;
-               if (IS_SX_BOARD (board)) {
-                       rc          = do_memtest   (board, 0, 0x7000);
-                       if (!rc) rc = do_memtest   (board, 0, 0x7000);
-                       /*if (!rc) rc = do_memtest_w (board, 0, 0x7000);*/
+               if (IS_SX_BOARD(board)) {
+                       rc = do_memtest(board, 0, 0x7000);
+                       if (!rc)
+                               rc = do_memtest(board, 0, 0x7000);
+                       /*if (!rc) rc = do_memtest_w (board, 0, 0x7000); */
                } else {
-                       rc             = do_memtest   (board, 0, 0x7ff8);
+                       rc = do_memtest(board, 0, 0x7ff8);
                        /* if (!rc) rc = do_memtest_w (board, 0, 0x7ff8); */
                }
-               sx_dprintk (SX_DEBUG_FIRMWARE, "returning memtest result= %d\n", rc);
+               sx_dprintk(SX_DEBUG_FIRMWARE, "returning memtest result= %d\n",
+                          rc);
                break;
        case SXIO_DOWNLOAD:
-               if (sx_initialized) /* Already initialized */
+               if (sx_initialized)     /* Already initialized */
                        return -EEXIST;
-               if (!sx_reset (board)) 
+               if (!sx_reset(board))
                        return -EIO;
-               sx_dprintk (SX_DEBUG_INIT, "reset the board...\n");
-
-               tmp = kmalloc (SX_CHUNK_SIZE, GFP_USER);
-               if (!tmp) return -ENOMEM;
-               get_user (nbytes, descr++);
-               get_user (offset, descr++); 
-               get_user (data,  descr++);
+               sx_dprintk(SX_DEBUG_INIT, "reset the board...\n");
+
+               tmp = kmalloc(SX_CHUNK_SIZE, GFP_USER);
+               if (!tmp)
+                       return -ENOMEM;
+               get_user(nbytes, descr++);
+               get_user(offset, descr++);
+               get_user(data, descr++);
                while (nbytes && data) {
-                       for (i=0;i<nbytes;i += SX_CHUNK_SIZE) {
-                               if (copy_from_user(tmp, (char __user *)data+i, 
-                                                  (i + SX_CHUNK_SIZE >
-                                                   nbytes) ? nbytes - i :
-                                                             SX_CHUNK_SIZE)) {
-                                       kfree (tmp);
+                       for (i = 0; i < nbytes; i += SX_CHUNK_SIZE) {
+                               if (copy_from_user(tmp, (char __user *)data + i,
+                                               (i + SX_CHUNK_SIZE > nbytes) ?
+                                               nbytes - i : SX_CHUNK_SIZE)) {
+                                       kfree(tmp);
                                        return -EFAULT;
                                }
-                               memcpy_toio(board->base2 + offset + i, tmp, 
-                                               (i+SX_CHUNK_SIZE>nbytes)?nbytes-i:SX_CHUNK_SIZE);
+                               memcpy_toio(board->base2 + offset + i, tmp,
+                                               (i + SX_CHUNK_SIZE > nbytes) ?
+                                               nbytes - i : SX_CHUNK_SIZE);
                        }
 
-                       get_user (nbytes, descr++);
-                       get_user (offset, descr++); 
-                       get_user (data,   descr++);
+                       get_user(nbytes, descr++);
+                       get_user(offset, descr++);
+                       get_user(data, descr++);
                }
-               kfree (tmp);
-               sx_nports += sx_init_board (board);
+               kfree(tmp);
+               sx_nports += sx_init_board(board);
                rc = sx_nports;
                break;
        case SXIO_INIT:
-               if (sx_initialized) /* Already initialized */
+               if (sx_initialized)     /* Already initialized */
                        return -EEXIST;
                /* This is not allowed until all boards are initialized... */
-               for (i=0;i<SX_NBOARDS;i++) {
-                       if ( (boards[i].flags & SX_BOARD_PRESENT) &&
-                            !(boards[i].flags & SX_BOARD_INITIALIZED))
+               for (i = 0; i < SX_NBOARDS; i++) {
+                       if ((boards[i].flags & SX_BOARD_PRESENT) &&
+                               !(boards[i].flags & SX_BOARD_INITIALIZED))
                                return -EIO;
                }
-               for (i=0;i<SX_NBOARDS;i++)
-                       if (!(boards[i].flags & SX_BOARD_PRESENT)) break;
-
-               sx_dprintk (SX_DEBUG_FIRMWARE, "initing portstructs, %d boards, "
-                           "%d channels, first board: %d ports\n", 
-                           i, sx_nports, boards[0].nports);
-               rc = sx_init_portstructs (i, sx_nports);
-               sx_init_drivers ();
-               if (rc >= 0) 
+               for (i = 0; i < SX_NBOARDS; i++)
+                       if (!(boards[i].flags & SX_BOARD_PRESENT))
+                               break;
+
+               sx_dprintk(SX_DEBUG_FIRMWARE, "initing portstructs, %d boards, "
+                               "%d channels, first board: %d ports\n",
+                               i, sx_nports, boards[0].nports);
+               rc = sx_init_portstructs(i, sx_nports);
+               sx_init_drivers();
+               if (rc >= 0)
                        sx_initialized++;
                break;
        case SXIO_SETDEBUG:
@@ -1737,32 +1830,32 @@ static int sx_fw_ioctl (struct inode *inode, struct file *filp,
                rc = sx_nports;
                break;
        default:
-               printk (KERN_WARNING "Unknown ioctl on firmware device (%x).\n", cmd);
+               printk(KERN_WARNING "Unknown ioctl on firmware device (%x).\n",
+                               cmd);
                break;
        }
-       func_exit ();
+       func_exit();
        return rc;
 }
 
-
-static void sx_break (struct tty_struct * tty, int flag)
+static void sx_break(struct tty_struct *tty, int flag)
 {
        struct sx_port *port = tty->driver_data;
        int rv;
 
-       func_enter ();
+       func_enter();
 
-       if (flag) 
-               rv = sx_send_command (port, HS_START, -1, HS_IDLE_BREAK);
-       else 
-               rv = sx_send_command (port, HS_STOP, -1, HS_IDLE_OPEN);
-       if (rv != 1) printk (KERN_ERR "sx: couldn't send break (%x).\n",
-                       read_sx_byte (port->board, CHAN_OFFSET (port, hi_hstat)));
+       if (flag)
+               rv = sx_send_command(port, HS_START, -1, HS_IDLE_BREAK);
+       else
+               rv = sx_send_command(port, HS_STOP, -1, HS_IDLE_OPEN);
+       if (rv != 1)
+               printk(KERN_ERR "sx: couldn't send break (%x).\n",
+                       read_sx_byte(port->board, CHAN_OFFSET(port, hi_hstat)));
 
-       func_exit ();
+       func_exit();
 }
 
-
 static int sx_tiocmget(struct tty_struct *tty, struct file *file)
 {
        struct sx_port *port = tty->driver_data;
@@ -1770,7 +1863,7 @@ static int sx_tiocmget(struct tty_struct *tty, struct file *file)
 }
 
 static int sx_tiocmset(struct tty_struct *tty, struct file *file,
-                      unsigned int set, unsigned int clear)
+               unsigned int set, unsigned int clear)
 {
        struct sx_port *port = tty->driver_data;
        int rts = -1, dtr = -1;
@@ -1789,8 +1882,8 @@ static int sx_tiocmset(struct tty_struct *tty, struct file *file,
        return 0;
 }
 
-static int sx_ioctl (struct tty_struct * tty, struct file * filp, 
-                     unsigned int cmd, unsigned long arg)
+static int sx_ioctl(struct tty_struct *tty, struct file *filp,
+               unsigned int cmd, unsigned long arg)
 {
        int rc;
        struct sx_port *port = tty->driver_data;
@@ -1803,10 +1896,10 @@ static int sx_ioctl (struct tty_struct * tty, struct file * filp,
        switch (cmd) {
        case TIOCGSOFTCAR:
                rc = put_user(((tty->termios->c_cflag & CLOCAL) ? 1 : 0),
-                             (unsigned __user *) argp);
+                               (unsigned __user *)argp);
                break;
        case TIOCSSOFTCAR:
-               if ((rc = get_user(ival, (unsigned __user *) argp)) == 0) {
+               if ((rc = get_user(ival, (unsigned __user *)argp)) == 0) {
                        tty->termios->c_cflag =
                                (tty->termios->c_cflag & ~CLOCAL) |
                                (ival ? CLOCAL : 0);
@@ -1827,7 +1920,6 @@ static int sx_ioctl (struct tty_struct * tty, struct file * filp,
        return rc;
 }
 
-
 /* The throttle/unthrottle scheme for the Specialix card is different
  * from other drivers and deserves some explanation. 
  * The Specialix hardware takes care of XON/XOFF
@@ -1844,7 +1936,7 @@ static int sx_ioctl (struct tty_struct * tty, struct file * filp,
  * flow control scheme is in use for that port. -- Simon Allen
  */
 
-static void sx_throttle (struct tty_struct * tty)
+static void sx_throttle(struct tty_struct *tty)
 {
        struct sx_port *port = (struct sx_port *)tty->driver_data;
 
@@ -1852,14 +1944,13 @@ static void sx_throttle (struct tty_struct * tty)
        /* If the port is using any type of input flow
         * control then throttle the port.
         */
-       if((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty)) ) {
+       if ((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty))) {
                port->gs.flags |= SX_RX_THROTTLE;
        }
        func_exit();
 }
 
-
-static void sx_unthrottle (struct tty_struct * tty)
+static void sx_unthrottle(struct tty_struct *tty)
 {
        struct sx_port *port = (struct sx_port *)tty->driver_data;
 
@@ -1873,15 +1964,11 @@ static void sx_unthrottle (struct tty_struct * tty)
        return;
 }
 
-
 /* ********************************************************************** *
  *                    Here are the initialization routines.               *
  * ********************************************************************** */
 
-
-
-
-static int sx_init_board (struct sx_board *board)
+static int sx_init_board(struct sx_board *board)
 {
        int addr;
        int chans;
@@ -1893,36 +1980,38 @@ static int sx_init_board (struct sx_board *board)
 
        board->flags |= SX_BOARD_INITIALIZED;
 
-       if (read_sx_byte (board, 0))
+       if (read_sx_byte(board, 0))
                /* CF boards may need this. */
-               write_sx_byte(board,0, 0);
+               write_sx_byte(board, 0, 0);
 
        /* This resets the processor again, to make sure it didn't do any
           foolish things while we were downloading the image */
-       if (!sx_reset (board))
+       if (!sx_reset(board))
                return 0;
 
-       sx_start_board (board);
-       udelay (10);
-       if (!sx_busy_wait_neq (board, 0, 0xff, 0)) {
-               printk (KERN_ERR "sx: Ooops. Board won't initialize.\n");
+       sx_start_board(board);
+       udelay(10);
+       if (!sx_busy_wait_neq(board, 0, 0xff, 0)) {
+               printk(KERN_ERR "sx: Ooops. Board won't initialize.\n");
                return 0;
        }
 
        /* Ok. So now the processor on the card is running. It gathered
           some info for us... */
-       sx_dprintk (SX_DEBUG_INIT, "The sxcard structure:\n");
-       if (sx_debug & SX_DEBUG_INIT) my_hd_io (board->base, 0x10);
-       sx_dprintk (SX_DEBUG_INIT, "the first sx_module structure:\n");
-       if (sx_debug & SX_DEBUG_INIT) my_hd_io (board->base + 0x80, 0x30);
-
-       sx_dprintk (SX_DEBUG_INIT, 
-                   "init_status: %x, %dk memory, firmware V%x.%02x,\n", 
-                   read_sx_byte (board, 0), read_sx_byte(board, 1), 
-                   read_sx_byte (board, 5), read_sx_byte(board, 4));
-
-       if (read_sx_byte (board, 0) == 0xff) {
-               printk (KERN_INFO "sx: No modules found. Sorry.\n");
+       sx_dprintk(SX_DEBUG_INIT, "The sxcard structure:\n");
+       if (sx_debug & SX_DEBUG_INIT)
+               my_hd_io(board->base, 0x10);
+       sx_dprintk(SX_DEBUG_INIT, "the first sx_module structure:\n");
+       if (sx_debug & SX_DEBUG_INIT)
+               my_hd_io(board->base + 0x80, 0x30);
+
+       sx_dprintk(SX_DEBUG_INIT, "init_status: %x, %dk memory, firmware "
+                       "V%x.%02x,\n",
+                       read_sx_byte(board, 0), read_sx_byte(board, 1),
+                       read_sx_byte(board, 5), read_sx_byte(board, 4));
+
+       if (read_sx_byte(board, 0) == 0xff) {
+               printk(KERN_INFO "sx: No modules found. Sorry.\n");
                board->nports = 0;
                return 0;
        }
@@ -1930,82 +2019,97 @@ static int sx_init_board (struct sx_board *board)
        chans = 0;
 
        if (IS_SX_BOARD(board)) {
-               sx_write_board_word (board, cc_int_count, sx_maxints);
+               sx_write_board_word(board, cc_int_count, sx_maxints);
        } else {
                if (sx_maxints)
-                       sx_write_board_word (board, cc_int_count, SI_PROCESSOR_CLOCK/8/sx_maxints);
+                       sx_write_board_word(board, cc_int_count,
+                                       SI_PROCESSOR_CLOCK / 8 / sx_maxints);
        }
 
        /* grab the first module type... */
-       /*  board->ta_type = mod_compat_type (read_sx_byte (board, 0x80 + 0x08)); */
-       board->ta_type = mod_compat_type (sx_read_module_byte (board, 0x80, mc_chip));
+       /* board->ta_type = mod_compat_type (read_sx_byte (board, 0x80 + 0x08)); */
+       board->ta_type = mod_compat_type(sx_read_module_byte(board, 0x80,
+                               mc_chip));
 
        /* XXX byteorder */
-       for (addr = 0x80;addr != 0;addr = read_sx_word (board, addr) & 0x7fff) {
-               type = sx_read_module_byte (board, addr, mc_chip);
-               sx_dprintk (SX_DEBUG_INIT, "Module at %x: %d channels\n", 
-                           addr, read_sx_byte (board, addr + 2));
-
-               chans += sx_read_module_byte (board, addr, mc_type);
-
-               sx_dprintk (SX_DEBUG_INIT, "module is an %s, which has %s/%s panels\n", 
-                           mod_type_s (type),
-                           pan_type_s (sx_read_module_byte (board, addr, mc_mods) & 0xf),
-                           pan_type_s (sx_read_module_byte (board, addr, mc_mods) >> 4));
-
-               sx_dprintk (SX_DEBUG_INIT, "CD1400 versions: %x/%x, ASIC version: %x\n", 
-                           sx_read_module_byte (board, addr, mc_rev1),
-                           sx_read_module_byte (board, addr, mc_rev2),
-                           sx_read_module_byte (board, addr, mc_mtaasic_rev));
+       for (addr = 0x80; addr != 0; addr = read_sx_word(board, addr) & 0x7fff){
+               type = sx_read_module_byte(board, addr, mc_chip);
+               sx_dprintk(SX_DEBUG_INIT, "Module at %x: %d channels\n",
+                               addr, read_sx_byte(board, addr + 2));
+
+               chans += sx_read_module_byte(board, addr, mc_type);
+
+               sx_dprintk(SX_DEBUG_INIT, "module is an %s, which has %s/%s "
+                               "panels\n",
+                               mod_type_s(type),
+                               pan_type_s(sx_read_module_byte(board, addr,
+                                               mc_mods) & 0xf),
+                               pan_type_s(sx_read_module_byte(board, addr,
+                                               mc_mods) >> 4));
+
+               sx_dprintk(SX_DEBUG_INIT, "CD1400 versions: %x/%x, ASIC "
+                       "version: %x\n",
+                       sx_read_module_byte(board, addr, mc_rev1),
+                       sx_read_module_byte(board, addr, mc_rev2),
+                       sx_read_module_byte(board, addr, mc_mtaasic_rev));
 
                /* The following combinations are illegal: It should theoretically
                   work, but timing problems make the bus HANG. */
 
-               if (mod_compat_type (type) != board->ta_type) {
-                       printk (KERN_ERR "sx: This is an invalid configuration.\n"
-                               "Don't mix TA/MTA/SXDC on the same hostadapter.\n");
-                       chans=0;
+               if (mod_compat_type(type) != board->ta_type) {
+                       printk(KERN_ERR "sx: This is an invalid "
+                               "configuration.\nDon't mix TA/MTA/SXDC on the "
+                               "same hostadapter.\n");
+                       chans = 0;
                        break;
                }
-               if ((IS_EISA_BOARD(board) || 
-                    IS_SI_BOARD(board)) && (mod_compat_type(type) == 4)) {
-                       printk (KERN_ERR "sx: This is an invalid configuration.\n"
-                               "Don't use SXDCs on an SI/XIO adapter.\n");
-                       chans=0;
+               if ((IS_EISA_BOARD(board) ||
+                               IS_SI_BOARD(board)) &&
+                               (mod_compat_type(type) == 4)) {
+                       printk(KERN_ERR "sx: This is an invalid "
+                               "configuration.\nDon't use SXDCs on an SI/XIO "
+                               "adapter.\n");
+                       chans = 0;
                        break;
                }
-#if 0 /* Problem fixed: firmware 3.05 */
+#if 0                          /* Problem fixed: firmware 3.05 */
                if (IS_SX_BOARD(board) && (type == TA8)) {
                        /* There are some issues with the firmware and the DCD/RTS
                           lines. It might work if you tie them together or something.
-                          It might also work if you get a newer sx_firmware.   Therefore
+                          It might also work if you get a newer sx_firmware.   Therefore
                           this is just a warning. */
-                       printk (KERN_WARNING "sx: The SX host doesn't work too well "
-                               "with the TA8 adapters.\nSpecialix is working on it.\n");
+                       printk(KERN_WARNING
+                              "sx: The SX host doesn't work too well "
+                              "with the TA8 adapters.\nSpecialix is working on it.\n");
                }
 #endif
        }
 
        if (chans) {
-               /* board->flags |= SX_BOARD_PRESENT; */
-               if(board->irq > 0) {
+               if (board->irq > 0) {
                        /* fixed irq, probably PCI */
-                       if(sx_irqmask & (1 << board->irq)) { /* may we use this irq? */
-                               if(request_irq(board->irq, sx_interrupt, IRQF_SHARED | IRQF_DISABLED, "sx", board)) {
-                                       printk(KERN_ERR "sx: Cannot allocate irq %d.\n", board->irq);
+                       if (sx_irqmask & (1 << board->irq)) {   /* may we use this irq? */
+                               if (request_irq(board->irq, sx_interrupt,
+                                               IRQF_SHARED | IRQF_DISABLED,
+                                               "sx", board)) {
+                                       printk(KERN_ERR "sx: Cannot allocate "
+                                               "irq %d.\n", board->irq);
                                        board->irq = 0;
                                }
                        } else
                                board->irq = 0;
-               } else if(board->irq < 0 && sx_irqmask) {
+               } else if (board->irq < 0 && sx_irqmask) {
                        /* auto-allocate irq */
                        int irqnr;
-                       int irqmask = sx_irqmask & (IS_SX_BOARD(board) ? SX_ISA_IRQ_MASK : SI2_ISA_IRQ_MASK);
-                       for(irqnr = 15; irqnr > 0; irqnr--)
-                               if(irqmask & (1 << irqnr))
-                                       if(! request_irq(irqnr, sx_interrupt, IRQF_SHARED | IRQF_DISABLED, "sx", board))
+                       int irqmask = sx_irqmask & (IS_SX_BOARD(board) ?
+                                       SX_ISA_IRQ_MASK : SI2_ISA_IRQ_MASK);
+                       for (irqnr = 15; irqnr > 0; irqnr--)
+                               if (irqmask & (1 << irqnr))
+                                       if (!request_irq(irqnr, sx_interrupt,
+                                               IRQF_SHARED | IRQF_DISABLED,
+                                               "sx", board))
                                                break;
-                       if(! irqnr)
+                       if (!irqnr)
                                printk(KERN_ERR "sx: Cannot allocate IRQ.\n");
                        board->irq = irqnr;
                } else
@@ -2013,52 +2117,48 @@ static int sx_init_board (struct sx_board *board)
 
                if (board->irq) {
                        /* Found a valid interrupt, start up interrupts! */
-                       sx_dprintk (SX_DEBUG_INIT, "Using irq %d.\n", board->irq);
-                       sx_start_interrupts (board);
+                       sx_dprintk(SX_DEBUG_INIT, "Using irq %d.\n",
+                                       board->irq);
+                       sx_start_interrupts(board);
                        board->poll = sx_slowpoll;
                        board->flags |= SX_IRQ_ALLOCATED;
                } else {
                        /* no irq: setup board for polled operation */
                        board->poll = sx_poll;
-                       sx_dprintk (SX_DEBUG_INIT, "Using poll-interval %d.\n", board->poll);
+                       sx_dprintk(SX_DEBUG_INIT, "Using poll-interval %d.\n",
+                                       board->poll);
                }
 
-               /* The timer should be initialized anyway: That way we can safely
-                        del_timer it when the module is unloaded. */
-               init_timer (&board->timer);
+               /* The timer should be initialized anyway: That way we can
+                  safely del_timer it when the module is unloaded. */
+               setup_timer(&board->timer, sx_pollfunc, (unsigned long)board);
 
-               if (board->poll) {
-                       board->timer.data = (unsigned long) board;
-                       board->timer.function = sx_pollfunc;
-                       board->timer.expires = jiffies + board->poll;
-                       add_timer (&board->timer);
-               }
+               if (board->poll)
+                       mod_timer(&board->timer, jiffies + board->poll);
        } else {
                board->irq = 0;
        }
 
        board->nports = chans;
-       sx_dprintk (SX_DEBUG_INIT, "returning %d ports.", board->nports);
+       sx_dprintk(SX_DEBUG_INIT, "returning %d ports.", board->nports);
 
        func_exit();
        return chans;
 }
 
-
-static void printheader(void)
+static void __devinit printheader(void)
 {
        static int header_printed;
 
        if (!header_printed) {
-               printk (KERN_INFO "Specialix SX driver "
-                       "(C) 1998/1999 R.E.Wolff@BitWizard.nl \n");
-               printk (KERN_INFO "sx: version %s\n", RCS_ID);
+               printk(KERN_INFO "Specialix SX driver "
+                       "(C) 1998/1999 R.E.Wolff@BitWizard.nl\n");
+               printk(KERN_INFO "sx: version " __stringify(SX_VERSION) "\n");
                header_printed = 1;
        }
 }
 
-
-static int probe_sx (struct sx_board *board)
+static int __devinit probe_sx(struct sx_board *board)
 {
        struct vpd_prom vpdp;
        char *p;
@@ -2066,51 +2166,57 @@ static int probe_sx (struct sx_board *board)
 
        func_enter();
 
-       if (!IS_CF_BOARD (board)) {    
-               sx_dprintk (SX_DEBUG_PROBE, "Going to verify vpd prom at %p.\n", 
-                           board->base + SX_VPD_ROM);
+       if (!IS_CF_BOARD(board)) {
+               sx_dprintk(SX_DEBUG_PROBE, "Going to verify vpd prom at %p.\n",
+                               board->base + SX_VPD_ROM);
 
                if (sx_debug & SX_DEBUG_PROBE)
                        my_hd_io(board->base + SX_VPD_ROM, 0x40);
 
-               p = (char *) &vpdp;
-               for (i=0;i< sizeof (struct vpd_prom);i++)
-                       *p++ = read_sx_byte (board, SX_VPD_ROM + i*2);
+               p = (char *)&vpdp;
+               for (i = 0; i < sizeof(struct vpd_prom); i++)
+                       *p++ = read_sx_byte(board, SX_VPD_ROM + i * 2);
 
                if (sx_debug & SX_DEBUG_PROBE)
-                       my_hd (&vpdp, 0x20);
+                       my_hd(&vpdp, 0x20);
 
-               sx_dprintk (SX_DEBUG_PROBE, "checking identifier...\n");
+               sx_dprintk(SX_DEBUG_PROBE, "checking identifier...\n");
 
-               if (strncmp (vpdp.identifier, SX_VPD_IDENT_STRING, 16) != 0) {
-                       sx_dprintk (SX_DEBUG_PROBE, "Got non-SX identifier: '%s'\n", 
-                                   vpdp.identifier); 
+               if (strncmp(vpdp.identifier, SX_VPD_IDENT_STRING, 16) != 0) {
+                       sx_dprintk(SX_DEBUG_PROBE, "Got non-SX identifier: "
+                                       "'%s'\n", vpdp.identifier);
                        return 0;
                }
        }
 
-       printheader ();
-
-       if (!IS_CF_BOARD (board)) {
-               printk (KERN_DEBUG "sx: Found an SX board at %lx\n", board->hw_base);
-               printk (KERN_DEBUG "sx: hw_rev: %d, assembly level: %d, uniq ID:%08x, ", 
-                       vpdp.hwrev, vpdp.hwass, vpdp.uniqid);
-               printk (           "Manufactured: %d/%d\n", 
-                       1970 + vpdp.myear, vpdp.mweek);
+       printheader();
 
+       if (!IS_CF_BOARD(board)) {
+               printk(KERN_DEBUG "sx: Found an SX board at %lx\n",
+                       board->hw_base);
+               printk(KERN_DEBUG "sx: hw_rev: %d, assembly level: %d, "
+                               "uniq ID:%08x, ",
+                               vpdp.hwrev, vpdp.hwass, vpdp.uniqid);
+               printk("Manufactured: %d/%d\n", 1970 + vpdp.myear, vpdp.mweek);
 
-               if ((((vpdp.uniqid >> 24) & SX_UNIQUEID_MASK) != SX_PCI_UNIQUEID1) &&
-                   (((vpdp.uniqid >> 24) & SX_UNIQUEID_MASK) != SX_ISA_UNIQUEID1)) {
-                       /* This might be a bit harsh. This was the primary reason the
-                          SX/ISA card didn't work at first... */
-                       printk (KERN_ERR "sx: Hmm. Not an SX/PCI or SX/ISA card. Sorry: giving up.\n");
+               if ((((vpdp.uniqid >> 24) & SX_UNIQUEID_MASK) !=
+                               SX_PCI_UNIQUEID1) && (((vpdp.uniqid >> 24) &
+                               SX_UNIQUEID_MASK) != SX_ISA_UNIQUEID1)) {
+                       /* This might be a bit harsh. This was the primary
+                          reason the SX/ISA card didn't work at first... */
+                       printk(KERN_ERR "sx: Hmm. Not an SX/PCI or SX/ISA "
+                                       "card. Sorry: giving up.\n");
                        return (0);
                }
 
-               if (((vpdp.uniqid >> 24) & SX_UNIQUEID_MASK) == SX_ISA_UNIQUEID1) {
+               if (((vpdp.uniqid >> 24) & SX_UNIQUEID_MASK) ==
+                               SX_ISA_UNIQUEID1) {
                        if (((unsigned long)board->hw_base) & 0x8000) {
-                               printk (KERN_WARNING "sx: Warning: There may be hardware problems with the card at %lx.\n", board->hw_base);
-                               printk (KERN_WARNING "sx: Read sx.txt for more info.\n");
+                               printk(KERN_WARNING "sx: Warning: There may be "
+                                       "hardware problems with the card at "
+                                       "%lx.\n", board->hw_base);
+                               printk(KERN_WARNING "sx: Read sx.txt for more "
+                                               "info.\n");
                        }
                }
        }
@@ -2118,17 +2224,15 @@ static int probe_sx (struct sx_board *board)
        board->nports = -1;
 
        /* This resets the processor, and keeps it off the bus. */
-       if (!sx_reset (board)) 
+       if (!sx_reset(board))
                return 0;
-       sx_dprintk (SX_DEBUG_INIT, "reset the board...\n");
-
-       board->flags |= SX_BOARD_PRESENT;
+       sx_dprintk(SX_DEBUG_INIT, "reset the board...\n");
 
        func_exit();
        return 1;
 }
 
-
+#if defined(CONFIG_ISA) || defined(CONFIG_EISA)
 
 /* Specialix probes for this card at 32k increments from 640k to 16M.
    I consider machines with less than 16M unlikely nowadays, so I'm
@@ -2136,28 +2240,27 @@ static int probe_sx (struct sx_board *board)
    card. 0xe0000 and 0xf0000 are taken by the BIOS. That only leaves 
    0xc0000, 0xc8000, 0xd0000 and 0xd8000 . */
 
-static int probe_si (struct sx_board *board)
+static int __devinit probe_si(struct sx_board *board)
 {
        int i;
 
        func_enter();
-       sx_dprintk (SX_DEBUG_PROBE, "Going to verify SI signature hw %lx at %p.\n", board->hw_base,
-                   board->base + SI2_ISA_ID_BASE);
+       sx_dprintk(SX_DEBUG_PROBE, "Going to verify SI signature hw %lx at "
+               "%p.\n", board->hw_base, board->base + SI2_ISA_ID_BASE);
 
        if (sx_debug & SX_DEBUG_PROBE)
                my_hd_io(board->base + SI2_ISA_ID_BASE, 0x8);
 
        if (!IS_EISA_BOARD(board)) {
-         if( IS_SI1_BOARD(board) ) 
-           {
-               for (i=0;i<8;i++) {
-                 write_sx_byte (board, SI2_ISA_ID_BASE+7-i,i); 
-
+               if (IS_SI1_BOARD(board)) {
+                       for (i = 0; i < 8; i++) {
+                               write_sx_byte(board, SI2_ISA_ID_BASE + 7 - i,i);
+                       }
                }
-           }
-               for (i=0;i<8;i++) {
-                       if ((read_sx_byte (board, SI2_ISA_ID_BASE+7-i) & 7) != i) {
-                               func_exit ();
+               for (i = 0; i < 8; i++) {
+                       if ((read_sx_byte(board, SI2_ISA_ID_BASE + 7 - i) & 7)
+                                       != i) {
+                               func_exit();
                                return 0;
                        }
                }
@@ -2167,20 +2270,20 @@ static int probe_si (struct sx_board *board)
           but to prevent trouble, we'd better double check that we don't
           have an SI1 board when we're probing for an SI2 board.... */
 
-       write_sx_byte (board, SI2_ISA_ID_BASE,0x10); 
-       if ( IS_SI1_BOARD(board)) {
+       write_sx_byte(board, SI2_ISA_ID_BASE, 0x10);
+       if (IS_SI1_BOARD(board)) {
                /* This should be an SI1 board, which has this
                   location writable... */
-               if (read_sx_byte (board, SI2_ISA_ID_BASE) != 0x10) {
-                       func_exit ();
-                       return 0; 
+               if (read_sx_byte(board, SI2_ISA_ID_BASE) != 0x10) {
+                       func_exit();
+                       return 0;
                }
        } else {
                /* This should be an SI2 board, which has the bottom
                   3 bits non-writable... */
-               if (read_sx_byte (board, SI2_ISA_ID_BASE) == 0x10) {
-                       func_exit ();
-                       return 0; 
+               if (read_sx_byte(board, SI2_ISA_ID_BASE) == 0x10) {
+                       func_exit();
+                       return 0;
                }
        }
 
@@ -2188,45 +2291,44 @@ static int probe_si (struct sx_board *board)
           but to prevent trouble, we'd better double check that we don't
           have an SI1 board when we're probing for an SI2 board.... */
 
-       write_sx_byte (board, SI2_ISA_ID_BASE,0x10); 
-       if ( IS_SI1_BOARD(board)) {
+       write_sx_byte(board, SI2_ISA_ID_BASE, 0x10);
+       if (IS_SI1_BOARD(board)) {
                /* This should be an SI1 board, which has this
                   location writable... */
-               if (read_sx_byte (board, SI2_ISA_ID_BASE) != 0x10) {
+               if (read_sx_byte(board, SI2_ISA_ID_BASE) != 0x10) {
                        func_exit();
-                       return 0; 
+                       return 0;
                }
        } else {
                /* This should be an SI2 board, which has the bottom
                   3 bits non-writable... */
-               if (read_sx_byte (board, SI2_ISA_ID_BASE) == 0x10) {
-                       func_exit ();
-                       return 0; 
+               if (read_sx_byte(board, SI2_ISA_ID_BASE) == 0x10) {
+                       func_exit();
+                       return 0;
                }
        }
 
-       printheader ();
+       printheader();
 
-       printk (KERN_DEBUG "sx: Found an SI board at %lx\n", board->hw_base);
+       printk(KERN_DEBUG "sx: Found an SI board at %lx\n", board->hw_base);
        /* Compared to the SX boards, it is a complete guess as to what
-                this card is up to... */
+          this card is up to... */
 
        board->nports = -1;
 
        /* This resets the processor, and keeps it off the bus. */
-       if (!sx_reset (board)) 
+       if (!sx_reset(board))
                return 0;
-       sx_dprintk (SX_DEBUG_INIT, "reset the board...\n");
-
-       board->flags |= SX_BOARD_PRESENT;
+       sx_dprintk(SX_DEBUG_INIT, "reset the board...\n");
 
        func_exit();
        return 1;
 }
+#endif
 
 static const struct tty_operations sx_ops = {
        .break_ctl = sx_break,
-       .open   = sx_open,
+       .open = sx_open,
        .close = gs_close,
        .write = gs_write,
        .put_char = gs_put_char,
@@ -2261,34 +2363,23 @@ static int sx_init_drivers(void)
        sx_driver->type = TTY_DRIVER_TYPE_SERIAL;
        sx_driver->subtype = SERIAL_TYPE_NORMAL;
        sx_driver->init_termios = tty_std_termios;
-       sx_driver->init_termios.c_cflag =
-         B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+       sx_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+       sx_driver->init_termios.c_ispeed = 9600;
+       sx_driver->init_termios.c_ospeed = 9600;
        sx_driver->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(sx_driver, &sx_ops);
 
        if ((error = tty_register_driver(sx_driver))) {
                put_tty_driver(sx_driver);
                printk(KERN_ERR "sx: Couldn't register sx driver, error = %d\n",
-                      error);
+                       error);
                return 1;
        }
        func_exit();
        return 0;
 }
 
-
-static void * ckmalloc (int size)
-{
-       void *p;
-
-       p = kmalloc(size, GFP_KERNEL);
-       if (p) 
-               memset(p, 0, size);
-       return p;
-}
-
-
-static int sx_init_portstructs (int nboards, int nports)
+static int sx_init_portstructs(int nboards, int nports)
 {
        struct sx_board *board;
        struct sx_port *port;
@@ -2299,8 +2390,9 @@ static int sx_init_portstructs (int nboards, int nports)
        func_enter();
 
        /* Many drivers statically allocate the maximum number of ports
-          There is no reason not to allocate them dynamically. Is there? -- REW */
-       sx_ports          = ckmalloc(nports * sizeof (struct sx_port));
+          There is no reason not to allocate them dynamically.
+          Is there? -- REW */
+       sx_ports = kcalloc(nports, sizeof(struct sx_port), GFP_KERNEL);
        if (!sx_ports)
                return -ENOMEM;
 
@@ -2308,10 +2400,10 @@ static int sx_init_portstructs (int nboards, int nports)
        for (i = 0; i < nboards; i++) {
                board = &boards[i];
                board->ports = port;
-               for (j=0; j < boards[i].nports;j++) {
-                       sx_dprintk (SX_DEBUG_INIT, "initing port %d\n", j);
+               for (j = 0; j < boards[i].nports; j++) {
+                       sx_dprintk(SX_DEBUG_INIT, "initing port %d\n", j);
                        port->gs.magic = SX_MAGIC;
-                       port->gs.close_delay = HZ/2;
+                       port->gs.close_delay = HZ / 2;
                        port->gs.closing_wait = 30 * HZ;
                        port->board = board;
                        port->gs.rd = &sx_real_driver;
@@ -2323,8 +2415,8 @@ static int sx_init_portstructs (int nboards, int nports)
                         * Initializing wait queue
                         */
                        init_waitqueue_head(&port->gs.open_wait);
-                       init_waitqueue_head(&port->gs.close_wait);              
-                       
+                       init_waitqueue_head(&port->gs.close_wait);
+
                        port++;
                }
        }
@@ -2335,28 +2427,36 @@ static int sx_init_portstructs (int nboards, int nports)
                board = &boards[i];
                board->port_base = portno;
                /* Possibly the configuration was rejected. */
-               sx_dprintk (SX_DEBUG_PROBE, "Board has %d channels\n", board->nports);
-               if (board->nports <= 0) continue;
+               sx_dprintk(SX_DEBUG_PROBE, "Board has %d channels\n",
+                               board->nports);
+               if (board->nports <= 0)
+                       continue;
                /* XXX byteorder ?? */
-               for (addr = 0x80;addr != 0;addr = read_sx_word (board, addr) & 0x7fff) {
-                       chans = sx_read_module_byte (board, addr, mc_type); 
-                       sx_dprintk (SX_DEBUG_PROBE, "Module at %x: %d channels\n", addr, chans);
-                       sx_dprintk (SX_DEBUG_PROBE, "Port at");
-                       for (j=0;j<chans;j++) {
-                               /* The "sx-way" is the way it SHOULD be done. That way in the 
-                                  future, the firmware may for example pack the structures a bit
-                                  more efficient. Neil tells me it isn't going to happen anytime
-                                  soon though. */
+               for (addr = 0x80; addr != 0;
+                               addr = read_sx_word(board, addr) & 0x7fff) {
+                       chans = sx_read_module_byte(board, addr, mc_type);
+                       sx_dprintk(SX_DEBUG_PROBE, "Module at %x: %d "
+                                       "channels\n", addr, chans);
+                       sx_dprintk(SX_DEBUG_PROBE, "Port at");
+                       for (j = 0; j < chans; j++) {
+                               /* The "sx-way" is the way it SHOULD be done.
+                                  That way in the future, the firmware may for
+                                  example pack the structures a bit more
+                                  efficient. Neil tells me it isn't going to
+                                  happen anytime soon though. */
                                if (IS_SX_BOARD(board))
-                                       port->ch_base = sx_read_module_word (board, addr+j*2, mc_chan_pointer);
+                                       port->ch_base = sx_read_module_word(
+                                                       board, addr + j * 2,
+                                                       mc_chan_pointer);
                                else
-                                       port->ch_base = addr + 0x100 + 0x300*j;
+                                       port->ch_base = addr + 0x100 + 0x300 *j;
 
-                               sx_dprintk (SX_DEBUG_PROBE, " %x", port->ch_base);
+                               sx_dprintk(SX_DEBUG_PROBE, " %x",
+                                               port->ch_base);
                                port->line = portno++;
                                port++;
                        }
-                       sx_dprintk (SX_DEBUG_PROBE, "\n");
+                       sx_dprintk(SX_DEBUG_PROBE, "\n");
                }
                /* This has to be done earlier. */
                /* board->flags |= SX_BOARD_INITIALIZED; */
@@ -2366,6 +2466,17 @@ static int sx_init_portstructs (int nboards, int nports)
        return 0;
 }
 
+static unsigned int sx_find_free_board(void)
+{
+       unsigned int i;
+
+       for (i = 0; i < SX_NBOARDS; i++)
+               if (!(boards[i].flags & SX_BOARD_PRESENT))
+                       break;
+
+       return i;
+}
+
 static void __exit sx_release_drivers(void)
 {
        func_enter();
@@ -2374,7 +2485,122 @@ static void __exit sx_release_drivers(void)
        func_exit();
 }
 
-#ifdef CONFIG_PCI
+static void __devexit sx_remove_card(struct sx_board *board,
+               struct pci_dev *pdev)
+{
+       if (board->flags & SX_BOARD_INITIALIZED) {
+               /* The board should stop messing with us. (actually I mean the
+                  interrupt) */
+               sx_reset(board);
+               if ((board->irq) && (board->flags & SX_IRQ_ALLOCATED))
+                       free_irq(board->irq, board);
+
+               /* It is safe/allowed to del_timer a non-active timer */
+               del_timer(&board->timer);
+               if (pdev) {
+                       pci_iounmap(pdev, board->base);
+                       pci_release_region(pdev, IS_CF_BOARD(board) ? 3 : 2);
+               } else {
+                       iounmap(board->base);
+                       release_region(board->hw_base, board->hw_len);
+               }
+
+               board->flags &= ~(SX_BOARD_INITIALIZED | SX_BOARD_PRESENT);
+       }
+}
+
+#ifdef CONFIG_EISA
+
+static int __devinit sx_eisa_probe(struct device *dev)
+{
+       struct eisa_device *edev = to_eisa_device(dev);
+       struct sx_board *board;
+       unsigned long eisa_slot = edev->base_addr;
+       unsigned int i;
+       int retval = -EIO;
+
+       mutex_lock(&sx_boards_lock);
+       i = sx_find_free_board();
+       if (i == SX_NBOARDS) {
+               mutex_unlock(&sx_boards_lock);
+               goto err;
+       }
+       board = &boards[i];
+       board->flags |= SX_BOARD_PRESENT;
+       mutex_unlock(&sx_boards_lock);
+
+       dev_info(dev, "XIO : Signature found in EISA slot %lu, "
+                "Product %d Rev %d (REPORT THIS TO LKLM)\n",
+                eisa_slot >> 12,
+                inb(eisa_slot + EISA_VENDOR_ID_OFFSET + 2),
+                inb(eisa_slot + EISA_VENDOR_ID_OFFSET + 3));
+
+       board->eisa_base = eisa_slot;
+       board->flags &= ~SX_BOARD_TYPE;
+       board->flags |= SI_EISA_BOARD;
+
+       board->hw_base = ((inb(eisa_slot + 0xc01) << 8) +
+                         inb(eisa_slot + 0xc00)) << 16;
+       board->hw_len = SI2_EISA_WINDOW_LEN;
+       if (!request_region(board->hw_base, board->hw_len, "sx")) {
+               dev_err(dev, "can't request region\n");
+               goto err_flag;
+       }
+       board->base2 =
+       board->base = ioremap(board->hw_base, SI2_EISA_WINDOW_LEN);
+       if (!board->base) {
+               dev_err(dev, "can't remap memory\n");
+               goto err_reg;
+       }
+
+       sx_dprintk(SX_DEBUG_PROBE, "IO hw_base address: %lx\n", board->hw_base);
+       sx_dprintk(SX_DEBUG_PROBE, "base: %p\n", board->base);
+       board->irq = inb(eisa_slot + 0xc02) >> 4;
+       sx_dprintk(SX_DEBUG_PROBE, "IRQ: %d\n", board->irq);
+
+       if (!probe_si(board))
+               goto err_unmap;
+
+       dev_set_drvdata(dev, board);
+
+       return 0;
+err_unmap:
+       iounmap(board->base);
+err_reg:
+       release_region(board->hw_base, board->hw_len);
+err_flag:
+       board->flags &= ~SX_BOARD_PRESENT;
+err:
+       return retval;
+}
+
+static int __devexit sx_eisa_remove(struct device *dev)
+{
+       struct sx_board *board = dev_get_drvdata(dev);
+
+       sx_remove_card(board, NULL);
+
+       return 0;
+}
+
+static struct eisa_device_id sx_eisa_tbl[] = {
+       { "SLX" },
+       { "" }
+};
+
+MODULE_DEVICE_TABLE(eisa, sx_eisa_tbl);
+
+static struct eisa_driver sx_eisadriver = {
+       .id_table = sx_eisa_tbl,
+       .driver = {
+               .name = "sx",
+               .probe = sx_eisa_probe,
+               .remove = __devexit_p(sx_eisa_remove),
+       }
+};
+
+#endif
+
  /******************************************************** 
  * Setting bit 17 in the CNTRL register of the PLX 9050  * 
  * chip forces a retry on writes while a read is pending.*
@@ -2386,233 +2612,265 @@ static void __exit sx_release_drivers(void)
    EEprom.  As the bit is read/write for the CPU, we can fix it here,
    if we detect that it isn't set correctly. -- REW */
 
-static void fix_sx_pci (struct pci_dev *pdev, struct sx_board *board)
+static void __devinit fix_sx_pci(struct pci_dev *pdev, struct sx_board *board)
 {
        unsigned int hwbase;
        void __iomem *rebase;
        unsigned int t;
 
-#define CNTRL_REG_OFFSET        0x50
-#define CNTRL_REG_GOODVALUE     0x18260000
+#define CNTRL_REG_OFFSET       0x50
+#define CNTRL_REG_GOODVALUE    0x18260000
 
        pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase);
        hwbase &= PCI_BASE_ADDRESS_MEM_MASK;
        rebase = ioremap(hwbase, 0x80);
-       t = readl (rebase + CNTRL_REG_OFFSET);
+       t = readl(rebase + CNTRL_REG_OFFSET);
        if (t != CNTRL_REG_GOODVALUE) {
-               printk (KERN_DEBUG "sx: performing cntrl reg fix: %08x -> %08x\n", t, CNTRL_REG_GOODVALUE); 
-               writel (CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET);
+               printk(KERN_DEBUG "sx: performing cntrl reg fix: %08x -> "
+                       "%08x\n", t, CNTRL_REG_GOODVALUE);
+               writel(CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET);
        }
        iounmap(rebase);
 }
-#endif
-
 
-static int __init sx_init(void) 
+static int __devinit sx_pci_probe(struct pci_dev *pdev,
+                                 const struct pci_device_id *ent)
 {
-       int i;
-       int found = 0;
-       int eisa_slot;
        struct sx_board *board;
+       unsigned int i, reg;
+       int retval = -EIO;
 
-#ifdef CONFIG_PCI
-       struct pci_dev *pdev = NULL;
-       unsigned int tint;
-       unsigned short tshort;
-#endif
+       mutex_lock(&sx_boards_lock);
+       i = sx_find_free_board();
+       if (i == SX_NBOARDS) {
+               mutex_unlock(&sx_boards_lock);
+               goto err;
+       }
+       board = &boards[i];
+       board->flags |= SX_BOARD_PRESENT;
+       mutex_unlock(&sx_boards_lock);
 
-       func_enter();
-       sx_dprintk (SX_DEBUG_INIT, "Initing sx module... (sx_debug=%d)\n", sx_debug);
-       if (abs ((long) (&sx_debug) - sx_debug) < 0x10000) {
-               printk (KERN_WARNING "sx: sx_debug is an address, instead of a value. "
-                       "Assuming -1.\n");
-               printk ("(%p)\n", &sx_debug);
-               sx_debug=-1;
+       retval = pci_enable_device(pdev);
+       if (retval)
+               goto err_flag;
+
+       board->flags &= ~SX_BOARD_TYPE;
+       board->flags |= (pdev->subsystem_vendor == 0x200) ? SX_PCI_BOARD :
+               SX_CFPCI_BOARD;
+
+       /* CF boards use base address 3.... */
+       reg = IS_CF_BOARD(board) ? 3 : 2;
+       retval = pci_request_region(pdev, reg, "sx");
+       if (retval) {
+               dev_err(&pdev->dev, "can't request region\n");
+               goto err_flag;
+       }
+       board->hw_base = pci_resource_start(pdev, reg);
+       board->base2 =
+       board->base = pci_iomap(pdev, reg, WINDOW_LEN(board));
+       if (!board->base) {
+               dev_err(&pdev->dev, "ioremap failed\n");
+               goto err_reg;
        }
 
-       if (misc_register(&sx_fw_device) < 0) {
-               printk(KERN_ERR "SX: Unable to register firmware loader driver.\n");
-               return -EIO;
+       /* Most of the stuff on the CF board is offset by 0x18000 ....  */
+       if (IS_CF_BOARD(board))
+               board->base += 0x18000;
+
+       board->irq = pdev->irq;
+
+       dev_info(&pdev->dev, "Got a specialix card: %p(%d) %x.\n", board->base,
+                board->irq, board->flags);
+
+       if (!probe_sx(board)) {
+               retval = -EIO;
+               goto err_unmap;
        }
 
-#ifdef CONFIG_PCI
-       while ((pdev = pci_find_device (PCI_VENDOR_ID_SPECIALIX, 
-                                       PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, 
-                                             pdev))) {
-               if (pci_enable_device(pdev))
-                       continue;
+       fix_sx_pci(pdev, board);
 
-               /* Specialix has a whole bunch of cards with
-                  0x2000 as the device ID. They say its because
-                  the standard requires it. Stupid standard. */
-               /* It seems that reading a word doesn't work reliably on 2.0.
-                  Also, reading a non-aligned dword doesn't work. So we read the
-                  whole dword at 0x2c and extract the word at 0x2e (SUBSYSTEM_ID)
-                  ourselves */
-               /* I don't know why the define doesn't work, constant 0x2c does --REW */ 
-               pci_read_config_dword (pdev, 0x2c, &tint);
-               tshort = (tint >> 16) & 0xffff;
-               sx_dprintk (SX_DEBUG_PROBE, "Got a specialix card: %x.\n", tint);
-               /* sx_dprintk (SX_DEBUG_PROBE, "pdev = %d/%d    (%x)\n", pdev, tint); */ 
-               if ((tshort != 0x0200) && (tshort != 0x0300)) {
-                       sx_dprintk (SX_DEBUG_PROBE, "But it's not an SX card (%d)...\n", 
-                                   tshort);
-                       continue;
-               }
-               board = &boards[found];
+       pci_set_drvdata(pdev, board);
 
-               board->flags &= ~SX_BOARD_TYPE;
-               board->flags |= (tshort == 0x200)?SX_PCI_BOARD:
-                                                 SX_CFPCI_BOARD;
-
-               /* CF boards use base address 3.... */
-               if (IS_CF_BOARD (board))
-                       board->hw_base = pci_resource_start (pdev, 3);
-               else
-                       board->hw_base = pci_resource_start (pdev, 2);
-               board->base2 = 
-               board->base = ioremap(board->hw_base, WINDOW_LEN (board));
-               if (!board->base) {
-                       printk(KERN_ERR "ioremap failed\n");
-                       /* XXX handle error */
-               }
+       return 0;
+err_unmap:
+       pci_iounmap(pdev, board->base);
+err_reg:
+       pci_release_region(pdev, reg);
+err_flag:
+       board->flags &= ~SX_BOARD_PRESENT;
+err:
+       return retval;
+}
 
-               /* Most of the stuff on the CF board is offset by
-                  0x18000 ....  */
-               if (IS_CF_BOARD (board)) board->base += 0x18000;
+static void __devexit sx_pci_remove(struct pci_dev *pdev)
+{
+       struct sx_board *board = pci_get_drvdata(pdev);
 
-               board->irq = pdev->irq;
+       sx_remove_card(board, pdev);
+}
 
-               sx_dprintk (SX_DEBUG_PROBE, "Got a specialix card: %x/%p(%d) %x.\n", 
-                           tint, boards[found].base, board->irq, board->flags);
+/* Specialix has a whole bunch of cards with 0x2000 as the device ID. They say
+   its because the standard requires it. So check for SUBVENDOR_ID. */
+static struct pci_device_id sx_pci_tbl[] = {
+       { PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8,
+               .subvendor = 0x0200,.subdevice = PCI_ANY_ID },
+       { PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8,
+               .subvendor = 0x0300,.subdevice = PCI_ANY_ID },
+       { 0 }
+};
 
-               if (probe_sx (board)) {
-                       found++;
-                       fix_sx_pci (pdev, board);
-               } else 
-                       iounmap(board->base2);
-       }
+MODULE_DEVICE_TABLE(pci, sx_pci_tbl);
+
+static struct pci_driver sx_pcidriver = {
+       .name = "sx",
+       .id_table = sx_pci_tbl,
+       .probe = sx_pci_probe,
+       .remove = __devexit_p(sx_pci_remove)
+};
+
+static int __init sx_init(void)
+{
+#ifdef CONFIG_EISA
+       int retval1;
 #endif
+#ifdef CONFIG_ISA
+       struct sx_board *board;
+       unsigned int i;
+#endif
+       unsigned int found = 0;
+       int retval;
+
+       func_enter();
+       sx_dprintk(SX_DEBUG_INIT, "Initing sx module... (sx_debug=%d)\n",
+                       sx_debug);
+       if (abs((long)(&sx_debug) - sx_debug) < 0x10000) {
+               printk(KERN_WARNING "sx: sx_debug is an address, instead of a "
+                               "value. Assuming -1.\n(%p)\n", &sx_debug);
+               sx_debug = -1;
+       }
 
-       for (i=0;i<NR_SX_ADDRS;i++) {
+       if (misc_register(&sx_fw_device) < 0) {
+               printk(KERN_ERR "SX: Unable to register firmware loader "
+                               "driver.\n");
+               return -EIO;
+       }
+#ifdef CONFIG_ISA
+       for (i = 0; i < NR_SX_ADDRS; i++) {
                board = &boards[found];
                board->hw_base = sx_probe_addrs[i];
+               board->hw_len = SX_WINDOW_LEN;
+               if (!request_region(board->hw_base, board->hw_len, "sx"))
+                       continue;
                board->base2 =
-               board->base = ioremap(board->hw_base, SX_WINDOW_LEN);
+               board->base = ioremap(board->hw_base, board->hw_len);
+               if (!board->base)
+                       goto err_sx_reg;
                board->flags &= ~SX_BOARD_TYPE;
-               board->flags |= SX_ISA_BOARD;
-               board->irq = sx_irqmask?-1:0;
+               board->flags |= SX_ISA_BOARD;
+               board->irq = sx_irqmask ? -1 : 0;
 
-               if (probe_sx (board)) {
+               if (probe_sx(board)) {
+                       board->flags |= SX_BOARD_PRESENT;
                        found++;
                } else {
                        iounmap(board->base);
+err_sx_reg:
+                       release_region(board->hw_base, board->hw_len);
                }
        }
 
-       for (i=0;i<NR_SI_ADDRS;i++) {
+       for (i = 0; i < NR_SI_ADDRS; i++) {
                board = &boards[found];
                board->hw_base = si_probe_addrs[i];
+               board->hw_len = SI2_ISA_WINDOW_LEN;
+               if (!request_region(board->hw_base, board->hw_len, "sx"))
+                       continue;
                board->base2 =
-               board->base = ioremap(board->hw_base, SI2_ISA_WINDOW_LEN);
+               board->base = ioremap(board->hw_base, board->hw_len);
+               if (!board->base)
+                       goto err_si_reg;
                board->flags &= ~SX_BOARD_TYPE;
-               board->flags |=  SI_ISA_BOARD;
-               board->irq = sx_irqmask ?-1:0;
+               board->flags |= SI_ISA_BOARD;
+               board->irq = sx_irqmask ? -1 : 0;
 
-               if (probe_si (board)) {
+               if (probe_si(board)) {
+                       board->flags |= SX_BOARD_PRESENT;
                        found++;
                } else {
-                       iounmap (board->base);
+                       iounmap(board->base);
+err_si_reg:
+                       release_region(board->hw_base, board->hw_len);
                }
        }
-       for (i=0;i<NR_SI1_ADDRS;i++) {
+       for (i = 0; i < NR_SI1_ADDRS; i++) {
                board = &boards[found];
                board->hw_base = si1_probe_addrs[i];
+               board->hw_len = SI1_ISA_WINDOW_LEN;
+               if (!request_region(board->hw_base, board->hw_len, "sx"))
+                       continue;
                board->base2 =
-               board->base = ioremap(board->hw_base, SI1_ISA_WINDOW_LEN);
+               board->base = ioremap(board->hw_base, board->hw_len);
+               if (!board->base)
+                       goto err_si1_reg;
                board->flags &= ~SX_BOARD_TYPE;
-               board->flags |=  SI1_ISA_BOARD;
-               board->irq = sx_irqmask ?-1:0;
+               board->flags |= SI1_ISA_BOARD;
+               board->irq = sx_irqmask ? -1 : 0;
 
-               if (probe_si (board)) {
+               if (probe_si(board)) {
+                       board->flags |= SX_BOARD_PRESENT;
                        found++;
                } else {
-                       iounmap (board->base);
+                       iounmap(board->base);
+err_si1_reg:
+                       release_region(board->hw_base, board->hw_len);
                }
        }
+#endif
+#ifdef CONFIG_EISA
+       retval1 = eisa_driver_register(&sx_eisadriver);
+#endif
+       retval = pci_register_driver(&sx_pcidriver);
 
-        sx_dprintk(SX_DEBUG_PROBE, "Probing for EISA cards\n");
-        for(eisa_slot=0x1000; eisa_slot<0x10000; eisa_slot+=0x1000)
-        {
-                if((inb(eisa_slot+0xc80)==0x4d) &&
-                   (inb(eisa_slot+0xc81)==0x98))
-                {
-                       sx_dprintk(SX_DEBUG_PROBE, "%s : Signature found in EISA slot %d, Product %d Rev %d\n",
-                                               "XIO", (eisa_slot>>12), inb(eisa_slot+0xc82), inb(eisa_slot+0xc83));
-
-                       board = &boards[found];
-                       board->eisa_base = eisa_slot;
-                       board->flags &= ~SX_BOARD_TYPE;
-                       board->flags |= SI_EISA_BOARD;
-
-                       board->hw_base = (((inb(0xc01+eisa_slot) << 8) + inb(0xc00+eisa_slot)) << 16);
-                       board->base2 =
-                       board->base = ioremap(board->hw_base, SI2_EISA_WINDOW_LEN);
-
-                       sx_dprintk(SX_DEBUG_PROBE, "IO hw_base address: %lx\n", board->hw_base);
-                       sx_dprintk(SX_DEBUG_PROBE, "base: %p\n", board->base);
-                       board->irq = inb(board->eisa_base+0xc02)>>4; 
-                       sx_dprintk(SX_DEBUG_PROBE, "IRQ: %d\n", board->irq);
-                       
-                       probe_si(board);
-
-                       found++;
-               }
-       }
        if (found) {
-               printk (KERN_INFO "sx: total of %d boards detected.\n", found);
-       } else {
-               misc_deregister(&sx_fw_device);
+               printk(KERN_INFO "sx: total of %d boards detected.\n", found);
+               retval = 0;
+       } else if (retval) {
+#ifdef CONFIG_EISA
+               retval = retval1;
+               if (retval1)
+#endif
+                       misc_deregister(&sx_fw_device);
        }
 
        func_exit();
-       return found?0:-EIO;
+       return retval;
 }
 
-
-static void __exit sx_exit (void)
+static void __exit sx_exit(void)
 {
-       int i; 
-       struct sx_board *board;
+       int i;
 
        func_enter();
-       for (i = 0; i < SX_NBOARDS; i++) {
-               board = &boards[i];
-               if (board->flags & SX_BOARD_INITIALIZED) {
-                       sx_dprintk (SX_DEBUG_CLEANUP, "Cleaning up board at %p\n", board->base);
-                       /* The board should stop messing with us.
-                          (actually I mean the interrupt) */
-                       sx_reset (board);
-                       if ((board->irq) && (board->flags & SX_IRQ_ALLOCATED))
-                               free_irq (board->irq, board);
-
-                       /* It is safe/allowed to del_timer a non-active timer */
-                       del_timer (& board->timer);
-                       iounmap(board->base);
-               }
-       }
+#ifdef CONFIG_EISA
+       eisa_driver_unregister(&sx_eisadriver);
+#endif
+       pci_unregister_driver(&sx_pcidriver);
+
+       for (i = 0; i < SX_NBOARDS; i++)
+               sx_remove_card(&boards[i], NULL);
+
        if (misc_deregister(&sx_fw_device) < 0) {
-               printk (KERN_INFO "sx: couldn't deregister firmware loader device\n");
+               printk(KERN_INFO "sx: couldn't deregister firmware loader "
+                               "device\n");
        }
-       sx_dprintk (SX_DEBUG_CLEANUP, "Cleaning up drivers (%d)\n", sx_initialized);
+       sx_dprintk(SX_DEBUG_CLEANUP, "Cleaning up drivers (%d)\n",
+                       sx_initialized);
        if (sx_initialized)
-               sx_release_drivers ();
+               sx_release_drivers();
 
-       kfree (sx_ports);
+       kfree(sx_ports);
        func_exit();
 }
 
 module_init(sx_init);
 module_exit(sx_exit);
-
-
index e01f83cbe299fcb70bacf95e8ca536214068032c..432aad0a2dddfd7a2d3d2d6e51c4fb10944c6c8e 100644 (file)
@@ -35,6 +35,7 @@ struct sx_board {
   void __iomem *base;
   void __iomem *base2;
   unsigned long hw_base;
+  resource_size_t hw_len;
   int eisa_base;
   int port_base; /* Number of the first port */
   struct sx_port *ports;
index 147c30da81ea1602df22426c9c95c8dd644e37f1..acc6fab601ccaa6f592052595a3587810607c522 100644 (file)
 #include <linux/hdlc.h>
 #include <linux/dma-mapping.h>
 
-#ifdef CONFIG_HDLC_MODULE
-#define CONFIG_HDLC 1
+#if defined(CONFIG_HDLC) || (defined(CONFIG_HDLC_MODULE) && defined(CONFIG_SYNCLINK_MODULE))
+#define SYNCLINK_GENERIC_HDLC 1
+#else
+#define SYNCLINK_GENERIC_HDLC 0
 #endif
 
 #define GET_USER(error,value,addr) error = get_user(value,addr)
@@ -320,7 +322,7 @@ struct mgsl_struct {
        int dosyncppp;
        spinlock_t netlock;
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        struct net_device *netdev;
 #endif
 };
@@ -728,7 +730,7 @@ static void usc_loopmode_send_done( struct mgsl_struct * info );
 
 static int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigned long arg);
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
 #define dev_to_port(D) (dev_to_hdlc(D)->priv)
 static void hdlcdev_tx_done(struct mgsl_struct *info);
 static void hdlcdev_rx(struct mgsl_struct *info, char *buf, int size);
@@ -1277,7 +1279,7 @@ static void mgsl_isr_transmit_status( struct mgsl_struct *info )
                info->drop_rts_on_tx_done = 0;
        }
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        if (info->netcount)
                hdlcdev_tx_done(info);
        else 
@@ -1342,7 +1344,7 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info )
                                info->input_signal_events.dcd_up++;
                        } else
                                info->input_signal_events.dcd_down++;
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                        if (info->netcount) {
                                if (status & MISCSTATUS_DCD)
                                        netif_carrier_on(info->netdev);
@@ -3058,7 +3060,7 @@ static int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigne
  *     
  * Return Value:               None
  */
-static void mgsl_set_termios(struct tty_struct *tty, struct termios *old_termios)
+static void mgsl_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
        struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data;
        unsigned long flags;
@@ -4313,7 +4315,7 @@ static void mgsl_add_device( struct mgsl_struct *info )
                        info->max_frame_size );
        }
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        hdlcdev_init(info);
 #endif
 
@@ -4403,6 +4405,8 @@ static int mgsl_init_tty(void)
        serial_driver->init_termios = tty_std_termios;
        serial_driver->init_termios.c_cflag =
                B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+       serial_driver->init_termios.c_ispeed = 9600;
+       serial_driver->init_termios.c_ospeed = 9600;
        serial_driver->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(serial_driver, &mgsl_ops);
        if ((rc = tty_register_driver(serial_driver)) < 0) {
@@ -4471,7 +4475,7 @@ static void synclink_cleanup(void)
 
        info = mgsl_device_list;
        while(info) {
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                hdlcdev_exit(info);
 #endif
                mgsl_release_resources(info);
@@ -6645,7 +6649,7 @@ static int mgsl_get_rx_frame(struct mgsl_struct *info)
                                return_frame = 1;
                }
                framesize = 0;
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                {
                        struct net_device_stats *stats = hdlc_stats(info->netdev);
                        stats->rx_errors++;
@@ -6721,7 +6725,7 @@ static int mgsl_get_rx_frame(struct mgsl_struct *info)
                                                *ptmp);
                        }
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                        if (info->netcount)
                                hdlcdev_rx(info,info->intermediate_rxbuffer,framesize);
                        else
@@ -7625,7 +7629,7 @@ static void mgsl_tx_timeout(unsigned long context)
 
        spin_unlock_irqrestore(&info->irq_spinlock,flags);
        
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        if (info->netcount)
                hdlcdev_tx_done(info);
        else
@@ -7701,7 +7705,7 @@ static int usc_loopmode_active( struct mgsl_struct * info)
        return usc_InReg( info, CCSR ) & BIT7 ? 1 : 0 ;
 }
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
 
 /**
  * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.)
index 07f34d43dc7fe4eb4a961bf7a464a23241b32711..792c79c315e00292abc21e7febea957c171506c0 100644 (file)
 
 #include "linux/synclink.h"
 
-#ifdef CONFIG_HDLC_MODULE
-#define CONFIG_HDLC 1
+#if defined(CONFIG_HDLC) || (defined(CONFIG_HDLC_MODULE) && defined(CONFIG_SYNCLINK_GT_MODULE))
+#define SYNCLINK_GENERIC_HDLC 1
+#else
+#define SYNCLINK_GENERIC_HDLC 0
 #endif
 
 /*
@@ -149,7 +151,7 @@ static struct tty_driver *serial_driver;
 static int  open(struct tty_struct *tty, struct file * filp);
 static void close(struct tty_struct *tty, struct file * filp);
 static void hangup(struct tty_struct *tty);
-static void set_termios(struct tty_struct *tty, struct termios *old_termios);
+static void set_termios(struct tty_struct *tty, struct ktermios *old_termios);
 
 static int  write(struct tty_struct *tty, const unsigned char *buf, int count);
 static void put_char(struct tty_struct *tty, unsigned char ch);
@@ -171,7 +173,7 @@ static void set_break(struct tty_struct *tty, int break_state);
 /*
  * generic HDLC support and callbacks
  */
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
 #define dev_to_port(D) (dev_to_hdlc(D)->priv)
 static void hdlcdev_tx_done(struct slgt_info *info);
 static void hdlcdev_rx(struct slgt_info *info, char *buf, int size);
@@ -359,7 +361,7 @@ struct slgt_info {
        int netcount;
        int dosyncppp;
        spinlock_t netlock;
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        struct net_device *netdev;
 #endif
 
@@ -814,7 +816,7 @@ static void hangup(struct tty_struct *tty)
        wake_up_interruptible(&info->open_wait);
 }
 
-static void set_termios(struct tty_struct *tty, struct termios *old_termios)
+static void set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
        struct slgt_info *info = tty->driver_data;
        unsigned long flags;
@@ -1354,7 +1356,7 @@ static void set_break(struct tty_struct *tty, int break_state)
        spin_unlock_irqrestore(&info->lock,flags);
 }
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
 
 /**
  * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.)
@@ -2002,7 +2004,7 @@ static void dcd_change(struct slgt_info *info)
        } else {
                info->input_signal_events.dcd_down++;
        }
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        if (info->netcount) {
                if (info->signals & SerialSignal_DCD)
                        netif_carrier_on(info->netdev);
@@ -2180,7 +2182,7 @@ static void isr_txeom(struct slgt_info *info, unsigned short status)
                        set_signals(info);
                }
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                if (info->netcount)
                        hdlcdev_tx_done(info);
                else
@@ -3306,7 +3308,7 @@ static void add_device(struct slgt_info *info)
                devstr, info->device_name, info->phys_reg_addr,
                info->irq_level, info->max_frame_size);
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        hdlcdev_init(info);
 #endif
 }
@@ -3488,7 +3490,7 @@ static void slgt_cleanup(void)
        /* release devices */
        info = slgt_device_list;
        while(info) {
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                hdlcdev_exit(info);
 #endif
                free_dma_bufs(info);
@@ -3522,6 +3524,7 @@ static int __init slgt_init(void)
 
        if (!slgt_device_list) {
                printk("%s no devices found\n",driver_name);
+               pci_unregister_driver(&pci_driver);
                return -ENODEV;
        }
 
@@ -3543,6 +3546,8 @@ static int __init slgt_init(void)
        serial_driver->init_termios = tty_std_termios;
        serial_driver->init_termios.c_cflag =
                B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+       serial_driver->init_termios.c_ispeed = 9600;
+       serial_driver->init_termios.c_ospeed = 9600;
        serial_driver->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(serial_driver, &ops);
        if ((rc = tty_register_driver(serial_driver)) < 0) {
@@ -4433,7 +4438,7 @@ check_again:
                        framesize = 0;
        }
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        if (framesize == 0) {
                struct net_device_stats *stats = hdlc_stats(info->netdev);
                stats->rx_errors++;
@@ -4476,7 +4481,7 @@ check_again:
                                framesize++;
                        }
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                        if (info->netcount)
                                hdlcdev_rx(info,info->tmp_rbuf, framesize);
                        else
@@ -4779,7 +4784,7 @@ static void tx_timeout(unsigned long context)
        info->tx_count = 0;
        spin_unlock_irqrestore(&info->lock,flags);
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        if (info->netcount)
                hdlcdev_tx_done(info);
        else
index 13a57245cf2ec112e1b6442f8b3d1e1e43fec828..53e8ccf94fe33be05e76f7d3f1b6c7a6b8a2f394 100644 (file)
 #include <linux/workqueue.h>
 #include <linux/hdlc.h>
 
-#ifdef CONFIG_HDLC_MODULE
-#define CONFIG_HDLC 1
+#if defined(CONFIG_HDLC) || (defined(CONFIG_HDLC_MODULE) && defined(CONFIG_SYNCLINKMP_MODULE))
+#define SYNCLINK_GENERIC_HDLC 1
+#else
+#define SYNCLINK_GENERIC_HDLC 0
 #endif
 
 #define GET_USER(error,value,addr) error = get_user(value,addr)
@@ -280,7 +282,7 @@ typedef struct _synclinkmp_info {
        int dosyncppp;
        spinlock_t netlock;
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        struct net_device *netdev;
 #endif
 
@@ -517,7 +519,7 @@ static struct tty_driver *serial_driver;
 static int  open(struct tty_struct *tty, struct file * filp);
 static void close(struct tty_struct *tty, struct file * filp);
 static void hangup(struct tty_struct *tty);
-static void set_termios(struct tty_struct *tty, struct termios *old_termios);
+static void set_termios(struct tty_struct *tty, struct ktermios *old_termios);
 
 static int  write(struct tty_struct *tty, const unsigned char *buf, int count);
 static void put_char(struct tty_struct *tty, unsigned char ch);
@@ -536,7 +538,7 @@ static void throttle(struct tty_struct * tty);
 static void unthrottle(struct tty_struct * tty);
 static void set_break(struct tty_struct *tty, int break_state);
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
 #define dev_to_port(D) (dev_to_hdlc(D)->priv)
 static void hdlcdev_tx_done(SLMP_INFO *info);
 static void hdlcdev_rx(SLMP_INFO *info, char *buf, int size);
@@ -916,7 +918,7 @@ static void hangup(struct tty_struct *tty)
 
 /* Set new termios settings
  */
-static void set_termios(struct tty_struct *tty, struct termios *old_termios)
+static void set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
        SLMP_INFO *info = (SLMP_INFO *)tty->driver_data;
        unsigned long flags;
@@ -1607,7 +1609,7 @@ static void set_break(struct tty_struct *tty, int break_state)
        spin_unlock_irqrestore(&info->lock,flags);
 }
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
 
 /**
  * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.)
@@ -2339,7 +2341,7 @@ static void isr_txeom(SLMP_INFO * info, unsigned char status)
                        set_signals(info);
                }
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                if (info->netcount)
                        hdlcdev_tx_done(info);
                else
@@ -2523,7 +2525,7 @@ void isr_io_pin( SLMP_INFO *info, u16 status )
                                info->input_signal_events.dcd_up++;
                        } else
                                info->input_signal_events.dcd_down++;
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                        if (info->netcount) {
                                if (status & SerialSignal_DCD)
                                        netif_carrier_on(info->netdev);
@@ -3783,7 +3785,7 @@ void add_device(SLMP_INFO *info)
                info->irq_level,
                info->max_frame_size );
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        hdlcdev_init(info);
 #endif
 }
@@ -3977,7 +3979,7 @@ static void synclinkmp_cleanup(void)
        /* release devices */
        info = synclinkmp_device_list;
        while(info) {
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                hdlcdev_exit(info);
 #endif
                free_dma_bufs(info);
@@ -4032,6 +4034,8 @@ static int __init synclinkmp_init(void)
        serial_driver->init_termios = tty_std_termios;
        serial_driver->init_termios.c_cflag =
                B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+       serial_driver->init_termios.c_ispeed = 9600;
+       serial_driver->init_termios.c_ospeed = 9600;
        serial_driver->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(serial_driver, &ops);
        if ((rc = tty_register_driver(serial_driver)) < 0) {
@@ -4979,7 +4983,7 @@ CheckAgain:
                        info->icount.rxcrc++;
 
                framesize = 0;
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                {
                        struct net_device_stats *stats = hdlc_stats(info->netdev);
                        stats->rx_errors++;
@@ -5020,7 +5024,7 @@ CheckAgain:
                                        index = 0;
                        }
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                        if (info->netcount)
                                hdlcdev_rx(info,info->tmp_rx_buf,framesize);
                        else
@@ -5531,7 +5535,7 @@ void tx_timeout(unsigned long context)
 
        spin_unlock_irqrestore(&info->lock,flags);
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        if (info->netcount)
                hdlcdev_tx_done(info);
        else
index c64f5bcff947198e0e10734c2b4666bf0b5fec58..05810c8d20bca7162794f399014153f1c9390add 100644 (file)
@@ -182,6 +182,18 @@ static struct sysrq_key_op sysrq_showstate_op = {
        .enable_mask    = SYSRQ_ENABLE_DUMP,
 };
 
+static void sysrq_handle_showstate_blocked(int key, struct tty_struct *tty)
+{
+       show_state_filter(TASK_UNINTERRUPTIBLE);
+}
+static struct sysrq_key_op sysrq_showstate_blocked_op = {
+       .handler        = sysrq_handle_showstate_blocked,
+       .help_msg       = "showBlockedTasks",
+       .action_msg     = "Show Blocked State",
+       .enable_mask    = SYSRQ_ENABLE_DUMP,
+};
+
+
 static void sysrq_handle_showmem(int key, struct tty_struct *tty)
 {
        show_mem();
@@ -304,7 +316,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = {
        /* May be assigned at init time by SMP VOYAGER */
        NULL,                           /* v */
        NULL,                           /* w */
-       NULL,                           /* x */
+       &sysrq_showstate_blocked_op,    /* x */
        NULL,                           /* y */
        NULL                            /* z */
 };
index bb1bad4c18f9e5718e56d014ecff7ebbe235c1fe..4c431cb7cf1b1f21f1c32389d738c005c0df7a9d 100644 (file)
@@ -164,7 +164,7 @@ static ssize_t tanbac_tb0219_read(struct file *file, char __user *buf, size_t le
        unsigned int minor;
        char value;
 
-       minor = iminor(file->f_dentry->d_inode);
+       minor = iminor(file->f_path.dentry->d_inode);
        switch (minor) {
        case 0:
                value = get_led();
@@ -200,7 +200,7 @@ static ssize_t tanbac_tb0219_write(struct file *file, const char __user *data,
        int retval = 0;
        char c;
 
-       minor = iminor(file->f_dentry->d_inode);
+       minor = iminor(file->f_path.dentry->d_inode);
        switch (minor) {
        case 0:
                type = TYPE_LED;
index 9df0ca1be0e31a4e25310e58b370c10da4227c78..47fb20f696953391c7ce1b10bf248c68a3b60028 100644 (file)
@@ -285,7 +285,7 @@ static ssize_t
 tipar_write (struct file *file, const char __user *buf, size_t count,
                loff_t * ppos)
 {
-       unsigned int minor = iminor(file->f_dentry->d_inode) - TIPAR_MINOR;
+       unsigned int minor = iminor(file->f_path.dentry->d_inode) - TIPAR_MINOR;
        ssize_t n;
 
        parport_claim_or_block(table[minor].dev);
@@ -313,7 +313,7 @@ static ssize_t
 tipar_read(struct file *file, char __user *buf, size_t count, loff_t * ppos)
 {
        int b = 0;
-       unsigned int minor = iminor(file->f_dentry->d_inode) - TIPAR_MINOR;
+       unsigned int minor = iminor(file->f_path.dentry->d_inode) - TIPAR_MINOR;
        ssize_t retval = 0;
        ssize_t n = 0;
 
index dd36fd04a8421c8c873e7754408ca196de64eaf7..07067c31c4ec7344237ce33165e85760b88afebb 100644 (file)
@@ -249,6 +249,7 @@ int tosh_smm(SMMRegisters *regs)
 
        return eax;
 }
+EXPORT_SYMBOL(tosh_smm);
 
 
 static int tosh_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
index 774fa861169ad5af8392639178366db761356679..33e1f66e39cb62550a762724b8dcbfd4d7d5326b 100644 (file)
@@ -1155,6 +1155,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vend
 
        if (sysfs_create_group(&dev->kobj, chip->vendor.attr_group)) {
                list_del(&chip->list);
+               misc_deregister(&chip->vendor.miscdev);
                put_device(dev);
                clear_bit(chip->dev_num, dev_mask);
                kfree(chip);
index b3cfc8bc613c7bbfeee7ef7ce037e638793f32a0..4044c864fdd4da888c1d09126ebb2ce3af77637b 100644 (file)
 #define TTY_PARANOIA_CHECK 1
 #define CHECK_TTY_COUNT 1
 
-struct termios tty_std_termios = {     /* for the benefit of tty drivers  */
+struct ktermios tty_std_termios = {    /* for the benefit of tty drivers  */
        .c_iflag = ICRNL | IXON,
        .c_oflag = OPOST | ONLCR,
        .c_cflag = B38400 | CS8 | CREAD | HUPCL,
        .c_lflag = ISIG | ICANON | ECHO | ECHOE | ECHOK |
                   ECHOCTL | ECHOKE | IEXTEN,
-       .c_cc = INIT_C_CC
+       .c_cc = INIT_C_CC,
+       .c_ispeed = 38400,
+       .c_ospeed = 38400
 };
 
 EXPORT_SYMBOL(tty_std_termios);
@@ -126,7 +128,7 @@ EXPORT_SYMBOL(tty_std_termios);
    
 LIST_HEAD(tty_drivers);                        /* linked list of tty drivers */
 
-/* Semaphore to protect creating and releasing a tty. This is shared with
+/* Mutex to protect creating and releasing a tty. This is shared with
    vt.c for deeply disgusting hack reasons */
 DEFINE_MUTEX(tty_mutex);
 EXPORT_SYMBOL(tty_mutex);
@@ -250,7 +252,7 @@ static int check_tty_count(struct tty_struct *tty, const char *routine)
                                    "!= #fd's(%d) in %s\n",
                       tty->name, tty->count, count, routine);
                return count;
-       }       
+       }
 #endif
        return 0;
 }
@@ -259,18 +261,6 @@ static int check_tty_count(struct tty_struct *tty, const char *routine)
  * Tty buffer allocation management
  */
 
-
-/**
- *     tty_buffer_free_all             -       free buffers used by a tty
- *     @tty: tty to free from
- *
- *     Remove all the buffers pending on a tty whether queued with data
- *     or in the free ring. Must be called when the tty is no longer in use
- *
- *     Locking: none
- */
-
-
 /**
  *     tty_buffer_free_all             -       free buffers used by a tty
  *     @tty: tty to free from
@@ -614,7 +604,7 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string_flags);
  *     they are not on hot paths so a little discipline won't do 
  *     any harm.
  *
- *     Locking: takes termios_sem
+ *     Locking: takes termios_mutex
  */
  
 static void tty_set_termios_ldisc(struct tty_struct *tty, int num)
@@ -915,7 +905,7 @@ static void tty_ldisc_enable(struct tty_struct *tty)
  *     context.
  *
  *     Locking: takes tty_ldisc_lock.
- *             called functions take termios_sem
+ *              called functions take termios_mutex
  */
  
 static int tty_set_ldisc(struct tty_struct *tty, int ldisc)
@@ -1251,6 +1241,22 @@ void tty_ldisc_flush(struct tty_struct *tty)
 }
 
 EXPORT_SYMBOL_GPL(tty_ldisc_flush);
+
+/**
+ *     tty_reset_termios       -       reset terminal state
+ *     @tty: tty to reset
+ *
+ *     Restore a terminal to the driver default state
+ */
+
+static void tty_reset_termios(struct tty_struct *tty)
+{
+       mutex_lock(&tty->termios_mutex);
+       *tty->termios = tty->driver->init_termios;
+       tty->termios->c_ispeed = tty_termios_input_baud_rate(tty->termios);
+       tty->termios->c_ospeed = tty_termios_baud_rate(tty->termios);
+       mutex_unlock(&tty->termios_mutex);
+}
        
 /**
  *     do_tty_hangup           -       actual handler for hangup events
@@ -1267,12 +1273,12 @@ EXPORT_SYMBOL_GPL(tty_ldisc_flush);
  *
  *     Locking:
  *             BKL
- *             redirect lock for undoing redirection
- *             file list lock for manipulating list of ttys
- *             tty_ldisc_lock from called functions
- *             termios_sem resetting termios data
- *             tasklist_lock to walk task list for hangup event
- *
+ *               redirect lock for undoing redirection
+ *               file list lock for manipulating list of ttys
+ *               tty_ldisc_lock from called functions
+ *               termios_mutex resetting termios data
+ *               tasklist_lock to walk task list for hangup event
+ *                 ->siglock to protect ->signal/->sighand
  */
 static void do_tty_hangup(struct work_struct *work)
 {
@@ -1339,11 +1345,7 @@ static void do_tty_hangup(struct work_struct *work)
         * N_TTY.
         */
        if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS)
-       {
-               mutex_lock(&tty->termios_mutex);
-               *tty->termios = tty->driver->init_termios;
-               mutex_unlock(&tty->termios_mutex);
-       }
+               tty_reset_termios(tty);
        
        /* Defer ldisc switch */
        /* tty_deferred_ldisc_switch(N_TTY);
@@ -1354,14 +1356,18 @@ static void do_tty_hangup(struct work_struct *work)
        read_lock(&tasklist_lock);
        if (tty->session > 0) {
                do_each_task_pid(tty->session, PIDTYPE_SID, p) {
+                       spin_lock_irq(&p->sighand->siglock);
                        if (p->signal->tty == tty)
                                p->signal->tty = NULL;
-                       if (!p->signal->leader)
+                       if (!p->signal->leader) {
+                               spin_unlock_irq(&p->sighand->siglock);
                                continue;
-                       group_send_sig_info(SIGHUP, SEND_SIG_PRIV, p);
-                       group_send_sig_info(SIGCONT, SEND_SIG_PRIV, p);
+                       }
+                       __group_send_sig_info(SIGHUP, SEND_SIG_PRIV, p);
+                       __group_send_sig_info(SIGCONT, SEND_SIG_PRIV, p);
                        if (tty->pgrp > 0)
                                p->signal->tty_old_pgrp = tty->pgrp;
+                       spin_unlock_irq(&p->sighand->siglock);
                } while_each_task_pid(tty->session, PIDTYPE_SID, p);
        }
        read_unlock(&tasklist_lock);
@@ -1453,6 +1459,14 @@ int tty_hung_up_p(struct file * filp)
 
 EXPORT_SYMBOL(tty_hung_up_p);
 
+static void session_clear_tty(pid_t session)
+{
+       struct task_struct *p;
+       do_each_task_pid(session, PIDTYPE_SID, p) {
+               proc_clear_tty(p);
+       } while_each_task_pid(session, PIDTYPE_SID, p);
+}
+
 /**
  *     disassociate_ctty       -       disconnect controlling tty
  *     @on_exit: true if exiting so need to "hang up" the session
@@ -1469,31 +1483,35 @@ EXPORT_SYMBOL(tty_hung_up_p);
  *     The argument on_exit is set to 1 if called when a process is
  *     exiting; it is 0 if called by the ioctl TIOCNOTTY.
  *
- *     Locking: tty_mutex is taken to protect current->signal->tty
+ *     Locking:
  *             BKL is taken for hysterical raisins
- *             Tasklist lock is taken (under tty_mutex) to walk process
- *             lists for the session.
+ *               tty_mutex is taken to protect tty
+ *               ->siglock is taken to protect ->signal/->sighand
+ *               tasklist_lock is taken to walk process list for sessions
+ *                 ->siglock is taken to protect ->signal/->sighand
  */
 
 void disassociate_ctty(int on_exit)
 {
        struct tty_struct *tty;
-       struct task_struct *p;
        int tty_pgrp = -1;
+       int session;
 
        lock_kernel();
 
        mutex_lock(&tty_mutex);
-       tty = current->signal->tty;
+       tty = get_current_tty();
        if (tty) {
                tty_pgrp = tty->pgrp;
                mutex_unlock(&tty_mutex);
+               /* XXX: here we race, there is nothing protecting tty */
                if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY)
                        tty_vhangup(tty);
        } else {
-               if (current->signal->tty_old_pgrp) {
-                       kill_pg(current->signal->tty_old_pgrp, SIGHUP, on_exit);
-                       kill_pg(current->signal->tty_old_pgrp, SIGCONT, on_exit);
+               pid_t old_pgrp = current->signal->tty_old_pgrp;
+               if (old_pgrp) {
+                       kill_pg(old_pgrp, SIGHUP, on_exit);
+                       kill_pg(old_pgrp, SIGCONT, on_exit);
                }
                mutex_unlock(&tty_mutex);
                unlock_kernel();        
@@ -1505,19 +1523,29 @@ void disassociate_ctty(int on_exit)
                        kill_pg(tty_pgrp, SIGCONT, on_exit);
        }
 
-       /* Must lock changes to tty_old_pgrp */
-       mutex_lock(&tty_mutex);
+       spin_lock_irq(&current->sighand->siglock);
        current->signal->tty_old_pgrp = 0;
-       tty->session = 0;
-       tty->pgrp = -1;
+       session = process_session(current);
+       spin_unlock_irq(&current->sighand->siglock);
+
+       mutex_lock(&tty_mutex);
+       /* It is possible that do_tty_hangup has free'd this tty */
+       tty = get_current_tty();
+       if (tty) {
+               tty->session = 0;
+               tty->pgrp = 0;
+       } else {
+#ifdef TTY_DEBUG_HANGUP
+               printk(KERN_DEBUG "error attempted to write to tty [0x%p]"
+                      " = NULL", tty);
+#endif
+       }
+       mutex_unlock(&tty_mutex);
 
        /* Now clear signal->tty under the lock */
        read_lock(&tasklist_lock);
-       do_each_task_pid(current->signal->session, PIDTYPE_SID, p) {
-               p->signal->tty = NULL;
-       } while_each_task_pid(current->signal->session, PIDTYPE_SID, p);
+       session_clear_tty(session);
        read_unlock(&tasklist_lock);
-       mutex_unlock(&tty_mutex);
        unlock_kernel();
 }
 
@@ -1615,7 +1643,7 @@ static ssize_t tty_read(struct file * file, char __user * buf, size_t count,
        struct tty_ldisc *ld;
 
        tty = (struct tty_struct *)file->private_data;
-       inode = file->f_dentry->d_inode;
+       inode = file->f_path.dentry->d_inode;
        if (tty_paranoia_check(tty, inode, "tty_read"))
                return -EIO;
        if (!tty || (test_bit(TTY_IO_ERROR, &tty->flags)))
@@ -1718,7 +1746,7 @@ static inline ssize_t do_tty_write(
                cond_resched();
        }
        if (written) {
-               struct inode *inode = file->f_dentry->d_inode;
+               struct inode *inode = file->f_path.dentry->d_inode;
                inode->i_mtime = current_fs_time(inode->i_sb);
                ret = written;
        }
@@ -1749,7 +1777,7 @@ static ssize_t tty_write(struct file * file, const char __user * buf, size_t cou
                         loff_t *ppos)
 {
        struct tty_struct * tty;
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        ssize_t ret;
        struct tty_ldisc *ld;
        
@@ -1856,8 +1884,8 @@ 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 ktermios *tp, **tp_loc, *o_tp, **o_tp_loc;
+       struct ktermios *ltp, **ltp_loc, *o_ltp, **o_ltp_loc;
        int retval = 0;
 
        /* check whether we're reopening an existing tty */
@@ -1904,7 +1932,7 @@ static int init_dev(struct tty_driver *driver, int idx,
        }
 
        if (!*tp_loc) {
-               tp = (struct termios *) kmalloc(sizeof(struct termios),
+               tp = (struct ktermios *) kmalloc(sizeof(struct ktermios),
                                                GFP_KERNEL);
                if (!tp)
                        goto free_mem_out;
@@ -1912,11 +1940,11 @@ static int init_dev(struct tty_driver *driver, int idx,
        }
 
        if (!*ltp_loc) {
-               ltp = (struct termios *) kmalloc(sizeof(struct termios),
+               ltp = (struct ktermios *) kmalloc(sizeof(struct ktermios),
                                                 GFP_KERNEL);
                if (!ltp)
                        goto free_mem_out;
-               memset(ltp, 0, sizeof(struct termios));
+               memset(ltp, 0, sizeof(struct ktermios));
        }
 
        if (driver->type == TTY_DRIVER_TYPE_PTY) {
@@ -1937,19 +1965,19 @@ static int init_dev(struct tty_driver *driver, int idx,
                }
 
                if (!*o_tp_loc) {
-                       o_tp = (struct termios *)
-                               kmalloc(sizeof(struct termios), GFP_KERNEL);
+                       o_tp = (struct ktermios *)
+                               kmalloc(sizeof(struct ktermios), GFP_KERNEL);
                        if (!o_tp)
                                goto free_mem_out;
                        *o_tp = driver->other->init_termios;
                }
 
                if (!*o_ltp_loc) {
-                       o_ltp = (struct termios *)
-                               kmalloc(sizeof(struct termios), GFP_KERNEL);
+                       o_ltp = (struct ktermios *)
+                               kmalloc(sizeof(struct ktermios), GFP_KERNEL);
                        if (!o_ltp)
                                goto free_mem_out;
-                       memset(o_ltp, 0, sizeof(struct termios));
+                       memset(o_ltp, 0, sizeof(struct ktermios));
                }
 
                /*
@@ -1988,6 +2016,9 @@ static int init_dev(struct tty_driver *driver, int idx,
                *ltp_loc = ltp;
        tty->termios = *tp_loc;
        tty->termios_locked = *ltp_loc;
+       /* Compatibility until drivers always set this */
+       tty->termios->c_ispeed = tty_termios_input_baud_rate(tty->termios);
+       tty->termios->c_ospeed = tty_termios_baud_rate(tty->termios);
        driver->refcount++;
        tty->count++;
 
@@ -2090,7 +2121,7 @@ release_mem_out:
 static void release_mem(struct tty_struct *tty, int idx)
 {
        struct tty_struct *o_tty;
-       struct termios *tp;
+       struct ktermios *tp;
        int devpts = tty->driver->flags & TTY_DRIVER_DEVPTS_MEM;
 
        if ((o_tty = tty->link) != NULL) {
@@ -2156,7 +2187,7 @@ static void release_dev(struct file * filp)
        unsigned long flags;
        
        tty = (struct tty_struct *)filp->private_data;
-       if (tty_paranoia_check(tty, filp->f_dentry->d_inode, "release_dev"))
+       if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "release_dev"))
                return;
 
        check_tty_count(tty, "release_dev");
@@ -2337,16 +2368,10 @@ static void release_dev(struct file * filp)
         * tty.
         */
        if (tty_closing || o_tty_closing) {
-               struct task_struct *p;
-
                read_lock(&tasklist_lock);
-               do_each_task_pid(tty->session, PIDTYPE_SID, p) {
-                       p->signal->tty = NULL;
-               } while_each_task_pid(tty->session, PIDTYPE_SID, p);
+               session_clear_tty(tty->session);
                if (o_tty)
-                       do_each_task_pid(o_tty->session, PIDTYPE_SID, p) {
-                               p->signal->tty = NULL;
-                       } while_each_task_pid(o_tty->session, PIDTYPE_SID, p);
+                       session_clear_tty(o_tty->session);
                read_unlock(&tasklist_lock);
        }
 
@@ -2443,9 +2468,9 @@ static void release_dev(struct file * filp)
  *     The termios state of a pty is reset on first open so that
  *     settings don't persist across reuse.
  *
- *     Locking: tty_mutex protects current->signal->tty, get_tty_driver and
- *             init_dev work. tty->count should protect the rest.
- *             task_lock is held to update task details for sessions
+ *     Locking: tty_mutex protects tty, get_tty_driver and init_dev work.
+ *              tty->count should protect the rest.
+ *              ->siglock protects ->signal/->sighand
  */
 
 static int tty_open(struct inode * inode, struct file * filp)
@@ -2467,12 +2492,13 @@ retry_open:
        mutex_lock(&tty_mutex);
 
        if (device == MKDEV(TTYAUX_MAJOR,0)) {
-               if (!current->signal->tty) {
+               tty = get_current_tty();
+               if (!tty) {
                        mutex_unlock(&tty_mutex);
                        return -ENXIO;
                }
-               driver = current->signal->tty->driver;
-               index = current->signal->tty->index;
+               driver = tty->driver;
+               index = tty->index;
                filp->f_flags |= O_NONBLOCK; /* Don't let /dev/tty block */
                /* noctty = 1; */
                goto got_driver;
@@ -2547,17 +2573,16 @@ got_driver:
                        filp->f_op = &tty_fops;
                goto retry_open;
        }
+
+       mutex_lock(&tty_mutex);
+       spin_lock_irq(&current->sighand->siglock);
        if (!noctty &&
            current->signal->leader &&
            !current->signal->tty &&
-           tty->session == 0) {
-               task_lock(current);
-               current->signal->tty = tty;
-               task_unlock(current);
-               current->signal->tty_old_pgrp = 0;
-               tty->session = current->signal->session;
-               tty->pgrp = process_group(current);
-       }
+           tty->session == 0)
+               __proc_set_tty(current, tty);
+       spin_unlock_irq(&current->sighand->siglock);
+       mutex_unlock(&tty_mutex);
        return 0;
 }
 
@@ -2672,7 +2697,7 @@ static unsigned int tty_poll(struct file * filp, poll_table * wait)
        int ret = 0;
 
        tty = (struct tty_struct *)filp->private_data;
-       if (tty_paranoia_check(tty, filp->f_dentry->d_inode, "tty_poll"))
+       if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "tty_poll"))
                return 0;
                
        ld = tty_ldisc_ref_wait(tty);
@@ -2688,7 +2713,7 @@ static int tty_fasync(int fd, struct file * filp, int on)
        int retval;
 
        tty = (struct tty_struct *)filp->private_data;
-       if (tty_paranoia_check(tty, filp->f_dentry->d_inode, "tty_fasync"))
+       if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "tty_fasync"))
                return 0;
        
        retval = fasync_helper(fd, filp, on, &tty->fasync);
@@ -2747,7 +2772,7 @@ static int tiocsti(struct tty_struct *tty, char __user *p)
  *
  *     Copies the kernel idea of the window size into the user buffer.
  *
- *     Locking: tty->termios_sem is taken to ensure the winsize data
+ *     Locking: tty->termios_mutex is taken to ensure the winsize data
  *             is consistent.
  */
 
@@ -2774,8 +2799,8 @@ static int tiocgwinsz(struct tty_struct *tty, struct winsize __user * arg)
  *     Locking:
  *             Called function use the console_sem is used to ensure we do
  *     not try and resize the console twice at once.
- *             The tty->termios_sem is used to ensure we don't double
- *     resize and get confused. Lock order - tty->termios.sem before
+ *             The tty->termios_mutex is used to ensure we don't double
+ *     resize and get confused. Lock order - tty->termios_mutex before
  *     console sem
  */
 
@@ -2880,25 +2905,28 @@ static int fionbio(struct file *file, int __user *p)
  *     leader to set this tty as the controlling tty for the session.
  *
  *     Locking:
- *             Takes tasklist lock internally to walk sessions
- *             Takes task_lock() when updating signal->tty
  *             Takes tty_mutex() to protect tty instance
- *
+ *             Takes tasklist_lock internally to walk sessions
+ *             Takes ->siglock() when updating signal->tty
  */
 
 static int tiocsctty(struct tty_struct *tty, int arg)
 {
-       struct task_struct *p;
-
+       int ret = 0;
        if (current->signal->leader &&
-           (current->signal->session == tty->session))
-               return 0;
+                       (process_session(current) == tty->session))
+               return ret;
+
+       mutex_lock(&tty_mutex);
        /*
         * The process must be a session leader and
         * not have a controlling tty already.
         */
-       if (!current->signal->leader || current->signal->tty)
-               return -EPERM;
+       if (!current->signal->leader || current->signal->tty) {
+               ret = -EPERM;
+               goto unlock;
+       }
+
        if (tty->session > 0) {
                /*
                 * This tty is already the controlling
@@ -2908,24 +2936,18 @@ static int tiocsctty(struct tty_struct *tty, int arg)
                        /*
                         * Steal it away
                         */
-
                        read_lock(&tasklist_lock);
-                       do_each_task_pid(tty->session, PIDTYPE_SID, p) {
-                               p->signal->tty = NULL;
-                       } while_each_task_pid(tty->session, PIDTYPE_SID, p);
+                       session_clear_tty(tty->session);
                        read_unlock(&tasklist_lock);
-               } else
-                       return -EPERM;
+               } else {
+                       ret = -EPERM;
+                       goto unlock;
+               }
        }
-       mutex_lock(&tty_mutex);
-       task_lock(current);
-       current->signal->tty = tty;
-       task_unlock(current);
+       proc_set_tty(current, tty);
+unlock:
        mutex_unlock(&tty_mutex);
-       current->signal->tty_old_pgrp = 0;
-       tty->session = current->signal->session;
-       tty->pgrp = process_group(current);
-       return 0;
+       return ret;
 }
 
 /**
@@ -2937,7 +2959,7 @@ static int tiocsctty(struct tty_struct *tty, int arg)
  *     Obtain the process group of the tty. If there is no process group
  *     return an error.
  *
- *     Locking: none. Reference to ->signal->tty is safe.
+ *     Locking: none. Reference to current->signal->tty is safe.
  */
 
 static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p)
@@ -2974,13 +2996,13 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t
                return retval;
        if (!current->signal->tty ||
            (current->signal->tty != real_tty) ||
-           (real_tty->session != current->signal->session))
+           (real_tty->session != process_session(current)))
                return -ENOTTY;
        if (get_user(pgrp, p))
                return -EFAULT;
        if (pgrp < 0)
                return -EINVAL;
-       if (session_of_pgrp(pgrp) != current->signal->session)
+       if (session_of_pgrp(pgrp) != process_session(current))
                return -EPERM;
        real_tty->pgrp = pgrp;
        return 0;
@@ -2995,7 +3017,7 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t
  *     Obtain the session id of the tty. If there is no session
  *     return an error.
  *
- *     Locking: none. Reference to ->signal->tty is safe.
+ *     Locking: none. Reference to current->signal->tty is safe.
  */
 
 static int tiocgsid(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p)
@@ -3214,14 +3236,11 @@ int tty_ioctl(struct inode * inode, struct file * file,
                        clear_bit(TTY_EXCLUSIVE, &tty->flags);
                        return 0;
                case TIOCNOTTY:
-                       /* FIXME: taks lock or tty_mutex ? */
                        if (current->signal->tty != tty)
                                return -ENOTTY;
                        if (current->signal->leader)
                                disassociate_ctty(0);
-                       task_lock(current);
-                       current->signal->tty = NULL;
-                       task_unlock(current);
+                       proc_clear_tty(current);
                        return 0;
                case TIOCSCTTY:
                        return tiocsctty(tty, arg);
@@ -3321,7 +3340,7 @@ static void __do_SAK(struct work_struct *work)
        
        if (!tty)
                return;
-       session  = tty->session;
+       session = tty->session;
        
        /* We don't want an ldisc switch during this */
        disc = tty_ldisc_ref(tty);
@@ -3336,7 +3355,7 @@ static void __do_SAK(struct work_struct *work)
        /* Kill the entire session */
        do_each_task_pid(session, PIDTYPE_SID, p) {
                printk(KERN_NOTICE "SAK: killed process %d"
-                       " (%s): p->signal->session==tty->session\n",
+                       " (%s): process_session(p)==tty->session\n",
                        p->pid, p->comm);
                send_sig(SIGKILL, p, 1);
        } while_each_task_pid(session, PIDTYPE_SID, p);
@@ -3346,7 +3365,7 @@ static void __do_SAK(struct work_struct *work)
        do_each_thread(g, p) {
                if (p->signal->tty == tty) {
                        printk(KERN_NOTICE "SAK: killed process %d"
-                           " (%s): p->signal->session==tty->session\n",
+                           " (%s): process_session(p)==tty->session\n",
                            p->pid, p->comm);
                        send_sig(SIGKILL, p, 1);
                        continue;
@@ -3456,84 +3475,6 @@ static void flush_to_ldisc(struct work_struct *work)
        tty_ldisc_deref(disc);
 }
 
-/*
- * Routine which returns the baud rate of the tty
- *
- * Note that the baud_table needs to be kept in sync with the
- * include/asm/termbits.h file.
- */
-static int baud_table[] = {
-       0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
-       9600, 19200, 38400, 57600, 115200, 230400, 460800,
-#ifdef __sparc__
-       76800, 153600, 307200, 614400, 921600
-#else
-       500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000,
-       2500000, 3000000, 3500000, 4000000
-#endif
-};
-
-static int n_baud_table = ARRAY_SIZE(baud_table);
-
-/**
- *     tty_termios_baud_rate
- *     @termios: termios structure
- *
- *     Convert termios baud rate data into a speed. This should be called
- *     with the termios lock held if this termios is a terminal termios
- *     structure. May change the termios data.
- *
- *     Locking: none
- */
-int tty_termios_baud_rate(struct termios *termios)
-{
-       unsigned int cbaud;
-       
-       cbaud = termios->c_cflag & CBAUD;
-
-       if (cbaud & CBAUDEX) {
-               cbaud &= ~CBAUDEX;
-
-               if (cbaud < 1 || cbaud + 15 > n_baud_table)
-                       termios->c_cflag &= ~CBAUDEX;
-               else
-                       cbaud += 15;
-       }
-       return baud_table[cbaud];
-}
-
-EXPORT_SYMBOL(tty_termios_baud_rate);
-
-/**
- *     tty_get_baud_rate       -       get tty bit rates
- *     @tty: tty to query
- *
- *     Returns the baud rate as an integer for this terminal. The
- *     termios lock must be held by the caller and the terminal bit
- *     flags may be updated.
- *
- *     Locking: none
- */
-int tty_get_baud_rate(struct tty_struct *tty)
-{
-       int baud = tty_termios_baud_rate(tty->termios);
-
-       if (baud == 38400 && tty->alt_speed) {
-               if (!tty->warned) {
-                       printk(KERN_WARNING "Use of setserial/setrocket to "
-                                           "set SPD_* flags is deprecated\n");
-                       tty->warned = 1;
-               }
-               baud = tty->alt_speed;
-       }
-       
-       return baud;
-}
-
-EXPORT_SYMBOL(tty_get_baud_rate);
-
 /**
  *     tty_flip_buffer_push    -       terminal
  *     @tty: tty to push
@@ -3756,8 +3697,8 @@ int tty_register_driver(struct tty_driver *driver)
 
        if (p) {
                driver->ttys = (struct tty_struct **)p;
-               driver->termios = (struct termios **)(p + driver->num);
-               driver->termios_locked = (struct termios **)(p + driver->num * 2);
+               driver->termios = (struct ktermios **)(p + driver->num);
+               driver->termios_locked = (struct ktermios **)(p + driver->num * 2);
        } else {
                driver->ttys = NULL;
                driver->termios = NULL;
@@ -3796,7 +3737,7 @@ EXPORT_SYMBOL(tty_register_driver);
 int tty_unregister_driver(struct tty_driver *driver)
 {
        int i;
-       struct termios *tp;
+       struct ktermios *tp;
        void *p;
 
        if (driver->refcount)
@@ -3834,9 +3775,52 @@ int tty_unregister_driver(struct tty_driver *driver)
        cdev_del(&driver->cdev);
        return 0;
 }
-
 EXPORT_SYMBOL(tty_unregister_driver);
 
+dev_t tty_devnum(struct tty_struct *tty)
+{
+       return MKDEV(tty->driver->major, tty->driver->minor_start) + tty->index;
+}
+EXPORT_SYMBOL(tty_devnum);
+
+void proc_clear_tty(struct task_struct *p)
+{
+       spin_lock_irq(&p->sighand->siglock);
+       p->signal->tty = NULL;
+       spin_unlock_irq(&p->sighand->siglock);
+}
+EXPORT_SYMBOL(proc_clear_tty);
+
+void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty)
+{
+       if (tty) {
+               tty->session = process_session(tsk);
+               tty->pgrp = process_group(tsk);
+       }
+       tsk->signal->tty = tty;
+       tsk->signal->tty_old_pgrp = 0;
+}
+
+void proc_set_tty(struct task_struct *tsk, struct tty_struct *tty)
+{
+       spin_lock_irq(&tsk->sighand->siglock);
+       __proc_set_tty(tsk, tty);
+       spin_unlock_irq(&tsk->sighand->siglock);
+}
+
+struct tty_struct *get_current_tty(void)
+{
+       struct tty_struct *tty;
+       WARN_ON_ONCE(!mutex_is_locked(&tty_mutex));
+       tty = current->signal->tty;
+       /*
+        * session->tty can be changed/cleared from under us, make sure we
+        * issue the load. The obtained pointer, when not NULL, is valid as
+        * long as we hold tty_mutex.
+        */
+       barrier();
+       return tty;
+}
 
 /*
  * Initialize the console device. This is called *early*, so
index 3b6fa7b0be8ba81c1f9d658cf63740394225172d..dee47f40c6a3878656f5bcacddcabd98c34da676 100644 (file)
@@ -36,6 +36,7 @@
 #define TERMIOS_FLUSH  1
 #define TERMIOS_WAIT   2
 #define TERMIOS_TERMIO 4
+#define TERMIOS_OLD    8
 
 
 /**
@@ -84,9 +85,9 @@ stop_waiting:
 
 EXPORT_SYMBOL(tty_wait_until_sent);
 
-static void unset_locked_termios(struct termios *termios,
-                                struct termios *old,
-                                struct termios *locked)
+static void unset_locked_termios(struct ktermios *termios,
+                                struct ktermios *old,
+                                struct ktermios *locked)
 {
        int     i;
        
@@ -105,8 +106,204 @@ static void unset_locked_termios(struct termios *termios,
        for (i=0; i < NCCS; i++)
                termios->c_cc[i] = locked->c_cc[i] ?
                        old->c_cc[i] : termios->c_cc[i];
+       /* FIXME: What should we do for i/ospeed */
 }
 
+/*
+ * Routine which returns the baud rate of the tty
+ *
+ * Note that the baud_table needs to be kept in sync with the
+ * include/asm/termbits.h file.
+ */
+static const speed_t baud_table[] = {
+       0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
+       9600, 19200, 38400, 57600, 115200, 230400, 460800,
+#ifdef __sparc__
+       76800, 153600, 307200, 614400, 921600
+#else
+       500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000,
+       2500000, 3000000, 3500000, 4000000
+#endif
+};
+
+#ifndef __sparc__
+static const tcflag_t baud_bits[] = {
+       B0, B50, B75, B110, B134, B150, B200, B300, B600,
+       B1200, B1800, B2400, B4800, B9600, B19200, B38400,
+       B57600, B115200, B230400, B460800, B500000, B576000,
+       B921600, B1000000, B1152000, B1500000, B2000000, B2500000,
+       B3000000, B3500000, B4000000
+};
+#else
+static const tcflag_t baud_bits[] = {
+       B0, B50, B75, B110, B134, B150, B200, B300, B600,
+       B1200, B1800, B2400, B4800, B9600, B19200, B38400,
+       B57600, B115200, B230400, B460800, B76800, B153600,
+       B307200, B614400, B921600
+};
+#endif
+
+static int n_baud_table = ARRAY_SIZE(baud_table);
+
+/**
+ *     tty_termios_baud_rate
+ *     @termios: termios structure
+ *
+ *     Convert termios baud rate data into a speed. This should be called
+ *     with the termios lock held if this termios is a terminal termios
+ *     structure. May change the termios data. Device drivers can call this
+ *     function but should use ->c_[io]speed directly as they are updated.
+ *
+ *     Locking: none
+ */
+
+speed_t tty_termios_baud_rate(struct ktermios *termios)
+{
+       unsigned int cbaud;
+
+       cbaud = termios->c_cflag & CBAUD;
+
+#ifdef BOTHER
+       /* Magic token for arbitary speed via c_ispeed/c_ospeed */
+       if (cbaud == BOTHER)
+               return termios->c_ospeed;
+#endif
+       if (cbaud & CBAUDEX) {
+               cbaud &= ~CBAUDEX;
+
+               if (cbaud < 1 || cbaud + 15 > n_baud_table)
+                       termios->c_cflag &= ~CBAUDEX;
+               else
+                       cbaud += 15;
+       }
+       return baud_table[cbaud];
+}
+
+EXPORT_SYMBOL(tty_termios_baud_rate);
+
+/**
+ *     tty_termios_input_baud_rate
+ *     @termios: termios structure
+ *
+ *     Convert termios baud rate data into a speed. This should be called
+ *     with the termios lock held if this termios is a terminal termios
+ *     structure. May change the termios data. Device drivers can call this
+ *     function but should use ->c_[io]speed directly as they are updated.
+ *
+ *     Locking: none
+ */
+
+speed_t tty_termios_input_baud_rate(struct ktermios *termios)
+{
+#ifdef IBSHIFT
+       unsigned int cbaud = (termios->c_cflag >> IBSHIFT) & CBAUD;
+
+       if (cbaud == B0)
+               return tty_termios_baud_rate(termios);
+
+       /* Magic token for arbitary speed via c_ispeed*/
+       if (cbaud == BOTHER)
+               return termios->c_ispeed;
+
+       if (cbaud & CBAUDEX) {
+               cbaud &= ~CBAUDEX;
+
+               if (cbaud < 1 || cbaud + 15 > n_baud_table)
+                       termios->c_cflag &= ~(CBAUDEX << IBSHIFT);
+               else
+                       cbaud += 15;
+       }
+       return baud_table[cbaud];
+#else
+       return tty_termios_baud_rate(termios);
+#endif
+}
+
+EXPORT_SYMBOL(tty_termios_input_baud_rate);
+
+#ifdef BOTHER
+
+/**
+ *     tty_termios_encode_baud_rate
+ *     @termios: termios structure
+ *     @ispeed: input speed
+ *     @ospeed: output speed
+ *
+ *     Encode the speeds set into the passed termios structure. This is
+ *     used as a library helper for drivers os that they can report back
+ *     the actual speed selected when it differs from the speed requested
+ *
+ *     For now input and output speed must agree.
+ *
+ *     Locking: Caller should hold termios lock. This is already held
+ *     when calling this function from the driver termios handler.
+ */
+
+void tty_termios_encode_baud_rate(struct ktermios *termios, speed_t ibaud, speed_t obaud)
+{
+       int i = 0;
+       int ifound = 0, ofound = 0;
+
+       termios->c_ispeed = ibaud;
+       termios->c_ospeed = obaud;
+
+       termios->c_cflag &= ~CBAUD;
+       /* Identical speed means no input encoding (ie B0 << IBSHIFT)*/
+       if (termios->c_ispeed == termios->c_ospeed)
+               ifound = 1;
+
+       do {
+               if (obaud == baud_table[i]) {
+                       termios->c_cflag |= baud_bits[i];
+                       ofound = 1;
+                       /* So that if ibaud == obaud we don't set it */
+                       continue;
+               }
+               if (ibaud == baud_table[i]) {
+                       termios->c_cflag |= (baud_bits[i] << IBSHIFT);
+                       ifound = 1;
+               }
+       }
+       while(++i < n_baud_table);
+       if (!ofound)
+               termios->c_cflag |= BOTHER;
+       if (!ifound)
+               termios->c_cflag |= (BOTHER << IBSHIFT);
+}
+
+EXPORT_SYMBOL_GPL(tty_termios_encode_baud_rate);
+
+#endif
+
+/**
+ *     tty_get_baud_rate       -       get tty bit rates
+ *     @tty: tty to query
+ *
+ *     Returns the baud rate as an integer for this terminal. The
+ *     termios lock must be held by the caller and the terminal bit
+ *     flags may be updated.
+ *
+ *     Locking: none
+ */
+
+speed_t tty_get_baud_rate(struct tty_struct *tty)
+{
+       speed_t baud = tty_termios_baud_rate(tty->termios);
+
+       if (baud == 38400 && tty->alt_speed) {
+               if (!tty->warned) {
+                       printk(KERN_WARNING "Use of setserial/setrocket to "
+                                           "set SPD_* flags is deprecated\n");
+                       tty->warned = 1;
+               }
+               baud = tty->alt_speed;
+       }
+
+       return baud;
+}
+
+EXPORT_SYMBOL(tty_get_baud_rate);
+
 /**
  *     change_termios          -       update termios values
  *     @tty: tty to update
@@ -119,10 +316,10 @@ static void unset_locked_termios(struct termios *termios,
  *     Locking: termios_sem
  */
 
-static void change_termios(struct tty_struct * tty, struct termios * new_termios)
+static void change_termios(struct tty_struct * tty, struct ktermios * new_termios)
 {
        int canon_change;
-       struct termios old_termios = *tty->termios;
+       struct ktermios old_termios = *tty->termios;
        struct tty_ldisc *ld;
        
        /*
@@ -195,23 +392,39 @@ static void change_termios(struct tty_struct * tty, struct termios * new_termios
 
 static int set_termios(struct tty_struct * tty, void __user *arg, int opt)
 {
-       struct termios tmp_termios;
+       struct ktermios tmp_termios;
        struct tty_ldisc *ld;
        int retval = tty_check_change(tty);
 
        if (retval)
                return retval;
 
+       memcpy(&tmp_termios, tty->termios, sizeof(struct ktermios));
+
        if (opt & TERMIOS_TERMIO) {
-               memcpy(&tmp_termios, tty->termios, sizeof(struct termios));
                if (user_termio_to_kernel_termios(&tmp_termios,
                                                (struct termio __user *)arg))
                        return -EFAULT;
+#ifdef TCGETS2
+       } else if (opt & TERMIOS_OLD) {
+               if (user_termios_to_kernel_termios_1(&tmp_termios,
+                                               (struct termios __user *)arg))
+                       return -EFAULT;
        } else {
                if (user_termios_to_kernel_termios(&tmp_termios,
-                                               (struct termios __user *)arg))
+                                               (struct termios2 __user *)arg))
                        return -EFAULT;
        }
+#else
+       } else if (user_termios_to_kernel_termios(&tmp_termios,
+                                       (struct termios __user *)arg))
+               return -EFAULT;
+#endif
+
+       /* If old style Bfoo values are used then load c_ispeed/c_ospeed with the real speed
+          so its unconditionally usable */
+       tmp_termios.c_ispeed = tty_termios_input_baud_rate(&tmp_termios);
+       tmp_termios.c_ospeed = tty_termios_baud_rate(&tmp_termios);
 
        ld = tty_ldisc_ref(tty);
        
@@ -286,8 +499,8 @@ static int get_sgttyb(struct tty_struct * tty, struct sgttyb __user * sgttyb)
        struct sgttyb tmp;
 
        mutex_lock(&tty->termios_mutex);
-       tmp.sg_ispeed = 0;
-       tmp.sg_ospeed = 0;
+       tmp.sg_ispeed = tty->termios->c_ispeed;
+       tmp.sg_ospeed = tty->termios->c_ospeed;
        tmp.sg_erase = tty->termios->c_cc[VERASE];
        tmp.sg_kill = tty->termios->c_cc[VKILL];
        tmp.sg_flags = get_sgflags(tty);
@@ -296,7 +509,7 @@ static int get_sgttyb(struct tty_struct * tty, struct sgttyb __user * sgttyb)
        return copy_to_user(sgttyb, &tmp, sizeof(tmp)) ? -EFAULT : 0;
 }
 
-static void set_sgflags(struct termios * termios, int flags)
+static void set_sgflags(struct ktermios * termios, int flags)
 {
        termios->c_iflag = ICRNL | IXON;
        termios->c_oflag = 0;
@@ -337,7 +550,7 @@ static int set_sgttyb(struct tty_struct * tty, struct sgttyb __user * sgttyb)
 {
        int retval;
        struct sgttyb tmp;
-       struct termios termios;
+       struct ktermios termios;
 
        retval = tty_check_change(tty);
        if (retval)
@@ -351,6 +564,10 @@ static int set_sgttyb(struct tty_struct * tty, struct sgttyb __user * sgttyb)
        termios.c_cc[VERASE] = tmp.sg_erase;
        termios.c_cc[VKILL] = tmp.sg_kill;
        set_sgflags(&termios, tmp.sg_flags);
+       /* Try and encode into Bfoo format */
+#ifdef BOTHER
+       tty_termios_encode_baud_rate(&termios, termios.c_ispeed, termios.c_ospeed);
+#endif
        mutex_unlock(&tty->termios_mutex);
        change_termios(tty, &termios);
        return 0;
@@ -481,16 +698,33 @@ int n_tty_ioctl(struct tty_struct * tty, struct file * file,
                case TIOCSLTC:
                        return set_ltchars(real_tty, p);
 #endif
+               case TCSETSF:
+                       return set_termios(real_tty, p,  TERMIOS_FLUSH | TERMIOS_WAIT | TERMIOS_OLD);
+               case TCSETSW:
+                       return set_termios(real_tty, p, TERMIOS_WAIT | TERMIOS_OLD);
+               case TCSETS:
+                       return set_termios(real_tty, p, TERMIOS_OLD);
+#ifndef TCGETS2
                case TCGETS:
                        if (kernel_termios_to_user_termios((struct termios __user *)arg, real_tty->termios))
                                return -EFAULT;
                        return 0;
-               case TCSETSF:
+#else
+               case TCGETS:
+                       if (kernel_termios_to_user_termios_1((struct termios __user *)arg, real_tty->termios))
+                               return -EFAULT;
+                       return 0;
+               case TCGETS2:
+                       if (kernel_termios_to_user_termios((struct termios2 __user *)arg, real_tty->termios))
+                               return -EFAULT;
+                       return 0;
+               case TCSETSF2:
                        return set_termios(real_tty, p,  TERMIOS_FLUSH | TERMIOS_WAIT);
-               case TCSETSW:
+               case TCSETSW2:
                        return set_termios(real_tty, p, TERMIOS_WAIT);
-               case TCSETS:
+               case TCSETS2:
                        return set_termios(real_tty, p, 0);
+#endif
                case TCGETA:
                        return get_termio(real_tty, p);
                case TCSETAF:
index f442b574b44ad00e40d5e08c570197c1deace7c6..26776517f04c7eaa0e705ec83aee988452fa4c6e 100644 (file)
@@ -72,7 +72,7 @@ static loff_t vcs_lseek(struct file *file, loff_t offset, int orig)
        int size;
 
        down(&con_buf_sem);
-       size = vcs_size(file->f_dentry->d_inode);
+       size = vcs_size(file->f_path.dentry->d_inode);
        switch (orig) {
                default:
                        up(&con_buf_sem);
@@ -98,7 +98,7 @@ static loff_t vcs_lseek(struct file *file, loff_t offset, int orig)
 static ssize_t
 vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        unsigned int currcons = iminor(inode);
        struct vc_data *vc;
        long pos;
@@ -271,7 +271,7 @@ unlock_out:
 static ssize_t
 vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        unsigned int currcons = iminor(inode);
        struct vc_data *vc;
        long pos;
index 73c78bf75d7f4e09e7affd373a8dd7fbbbc6b497..94d79cb8ce8d559ac4690eabb7e30f7ad1cb00d2 100644 (file)
@@ -442,7 +442,7 @@ static ssize_t viotap_write(struct file *file, const char *buf,
        if (op == NULL)
                return -ENOMEM;
 
-       get_dev_info(file->f_dentry->d_inode, &devi);
+       get_dev_info(file->f_path.dentry->d_inode, &devi);
 
        /*
         * We need to make sure we can send a request.  We use
@@ -532,7 +532,7 @@ static ssize_t viotap_read(struct file *file, char *buf, size_t count,
        if (op == NULL)
                return -ENOMEM;
 
-       get_dev_info(file->f_dentry->d_inode, &devi);
+       get_dev_info(file->f_path.dentry->d_inode, &devi);
 
        /*
         * We need to make sure we can send a request.  We use
@@ -612,7 +612,7 @@ static int viotap_ioctl(struct inode *inode, struct file *file,
        if (op == NULL)
                return -ENOMEM;
 
-       get_dev_info(file->f_dentry->d_inode, &devi);
+       get_dev_info(file->f_path.dentry->d_inode, &devi);
 
        down(&reqSem);
 
@@ -777,7 +777,7 @@ static int viotap_open(struct inode *inode, struct file *file)
        if (op == NULL)
                return -ENOMEM;
 
-       get_dev_info(file->f_dentry->d_inode, &devi);
+       get_dev_info(file->f_path.dentry->d_inode, &devi);
 
        /* Note: We currently only support one mode! */
        if ((devi.devno >= viotape_numdev) || (devi.mode)) {
@@ -822,7 +822,7 @@ static int viotap_release(struct inode *inode, struct file *file)
                return -ENOMEM;
        init_completion(&op->com);
 
-       get_dev_info(file->f_dentry->d_inode, &devi);
+       get_dev_info(file->f_path.dentry->d_inode, &devi);
 
        if (devi.devno >= viotape_numdev) {
                ret = -ENODEV;
index d0b94dd1af6da1253aeadf7c92d570d28c709982..e01317cb1a0e08d4799582f5d7ecbad49765ef22 100644 (file)
@@ -153,6 +153,8 @@ static int scc_init_drivers(void)
        scc_driver->init_termios = tty_std_termios;
        scc_driver->init_termios.c_cflag =
          B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+       scc_driver->init_termios.c_ispeed = 9600;
+       scc_driver->init_termios.c_ospeed = 9600;
        scc_driver->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(scc_driver, &scc_ops);
 
index 8e794930517111ec3013f79f0f486c1ad7998265..a744dad9cf450f6a911efaa62f31983f47cdfe14 100644 (file)
@@ -506,7 +506,7 @@ static ssize_t gpio_read(struct file *file, char __user *buf, size_t len,
        unsigned int pin;
        char value = '0';
 
-       pin = iminor(file->f_dentry->d_inode);
+       pin = iminor(file->f_path.dentry->d_inode);
        if (pin >= giu_nr_pins)
                return -EBADF;
 
@@ -530,7 +530,7 @@ static ssize_t gpio_write(struct file *file, const char __user *data,
        char c;
        int retval = 0;
 
-       pin = iminor(file->f_dentry->d_inode);
+       pin = iminor(file->f_path.dentry->d_inode);
        if (pin >= giu_nr_pins)
                return -EBADF;
 
index 75ff0286e1adee4bd7ac0b5f067a4a28339ef4a5..a8239dac994fee2264bf638bd3f5bff3176f446f 100644 (file)
@@ -152,7 +152,7 @@ static void gotoxy(struct vc_data *vc, int new_x, int new_y);
 static void save_cur(struct vc_data *vc);
 static void reset_terminal(struct vc_data *vc, int do_clear);
 static void con_flush_chars(struct tty_struct *tty);
-static void set_vesa_blanking(char __user *p);
+static int set_vesa_blanking(char __user *p);
 static void set_cursor(struct vc_data *vc);
 static void hide_cursor(struct vc_data *vc);
 static void console_callback(struct work_struct *ignored);
@@ -2369,7 +2369,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
                        ret = __put_user(data, p);
                        break;
                case TIOCL_SETVESABLANK:
-                       set_vesa_blanking(p);
+                       ret = set_vesa_blanking(p);
                        break;
                case TIOCL_GETKMSGREDIRECT:
                        data = kmsg_redirect;
@@ -3313,11 +3313,15 @@ postcore_initcall(vtconsole_class_init);
  *     Screen blanking
  */
 
-static void set_vesa_blanking(char __user *p)
+static int set_vesa_blanking(char __user *p)
 {
-    unsigned int mode;
-    get_user(mode, p + 1);
-    vesa_blank_mode = (mode < 4) ? mode : 0;
+       unsigned int mode;
+
+       if (get_user(mode, p + 1))
+               return -EFAULT;
+
+       vesa_blank_mode = (mode < 4) ? mode : 0;
+       return 0;
 }
 
 void do_blank_screen(int entering_gfx)
index 4e7a1145e78fd472a70f9442e3a0c7bec461741d..cb86967e2c5f51ede04fd92b8cc553cb9475cbe8 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/watchdog.h>
 #include <asm/bitops.h>
 #include <asm/uaccess.h>
+#include <asm/arch/at91_st.h>
 
 
 #define WDT_DEFAULT_TIME       5       /* seconds */
index e275dd4a705dea0503e19b1d3ad21ac75832e045..61138726b501ea710459f3f36dbbef085eee475f 100644 (file)
@@ -634,7 +634,7 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
        usb_pcwd->intr_size = (le16_to_cpu(endpoint->wMaxPacketSize) > 8 ? le16_to_cpu(endpoint->wMaxPacketSize) : 8);
 
        /* set up the memory buffer's */
-       if (!(usb_pcwd->intr_buffer = usb_buffer_alloc(udev, usb_pcwd->intr_size, SLAB_ATOMIC, &usb_pcwd->intr_dma))) {
+       if (!(usb_pcwd->intr_buffer = usb_buffer_alloc(udev, usb_pcwd->intr_size, GFP_ATOMIC, &usb_pcwd->intr_dma))) {
                printk(KERN_ERR PFX "Out of memory\n");
                goto error;
        }
index 7fcb77a9d0111855948d5a02003c2845e8f5a8b3..8ab61ef97b4c7da1029203c42dbe68f244aab888 100644 (file)
@@ -142,6 +142,39 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_LE,
                        acpi_pm_check_graylist);
 #endif
 
+#ifndef CONFIG_X86_64
+#include "mach_timer.h"
+#define PMTMR_EXPECTED_RATE \
+  ((CALIBRATE_LATCH * (PMTMR_TICKS_PER_SEC >> 10)) / (CLOCK_TICK_RATE>>10))
+/*
+ * Some boards have the PMTMR running way too fast. We check
+ * the PMTMR rate against PIT channel 2 to catch these cases.
+ */
+static int verify_pmtmr_rate(void)
+{
+       u32 value1, value2;
+       unsigned long count, delta;
+
+       mach_prepare_counter();
+       value1 = read_pmtmr();
+       mach_countup(&count);
+       value2 = read_pmtmr();
+       delta = (value2 - value1) & ACPI_PM_MASK;
+
+       /* Check that the PMTMR delta is within 5% of what we expect */
+       if (delta < (PMTMR_EXPECTED_RATE * 19) / 20 ||
+           delta > (PMTMR_EXPECTED_RATE * 21) / 20) {
+               printk(KERN_INFO "PM-Timer running at invalid rate: %lu%% "
+                       "of normal - aborting.\n",
+                       100UL * delta / PMTMR_EXPECTED_RATE);
+               return -1;
+       }
+
+       return 0;
+}
+#else
+#define verify_pmtmr_rate() (0)
+#endif
 
 static int __init init_acpi_pm_clocksource(void)
 {
@@ -173,6 +206,9 @@ static int __init init_acpi_pm_clocksource(void)
        return -ENODEV;
 
 pm_good:
+       if (verify_pmtmr_rate() != 0)
+               return -ENODEV;
+
        return clocksource_register(&clocksource_acpi_pm);
 }
 
index 7a7c6e6dfe4ff20acc0a5a59724f2e435b947d3a..47ab42db122a6b87f654e668ba5bd4f3ae70725f 100644 (file)
@@ -1537,7 +1537,6 @@ int cpufreq_update_policy(unsigned int cpu)
 }
 EXPORT_SYMBOL(cpufreq_update_policy);
 
-#ifdef CONFIG_HOTPLUG_CPU
 static int cpufreq_cpu_callback(struct notifier_block *nfb,
                                        unsigned long action, void *hcpu)
 {
@@ -1577,7 +1576,6 @@ static struct notifier_block __cpuinitdata cpufreq_cpu_notifier =
 {
     .notifier_call = cpufreq_cpu_callback,
 };
-#endif /* CONFIG_HOTPLUG_CPU */
 
 /*********************************************************************
  *               REGISTER / UNREGISTER CPUFREQ DRIVER                *
index adb554153f672a48d2d4d9f711513ef93d5ce9c8..e816535ab305e33b06ec2368dc668fa43a4f3b21 100644 (file)
@@ -51,4 +51,17 @@ config CRYPTO_DEV_PADLOCK_SHA
          If unsure say M. The compiled module will be
          called padlock-sha.ko
 
+config CRYPTO_DEV_GEODE
+       tristate "Support for the Geode LX AES engine"
+       depends on CRYPTO && X86_32
+       select CRYPTO_ALGAPI
+       select CRYPTO_BLKCIPHER
+       default m
+       help
+         Say 'Y' here to use the AMD Geode LX processor on-board AES
+         engine for the CryptoAPI AES alogrithm.
+
+         To compile this driver as a module, choose M here: the module
+         will be called geode-aes.
+
 endmenu
index 4c3d0ec1cf805a8b8407d959b6e085e9a2864460..6059cf8694141c077dc592e3186865d815aa6097 100644 (file)
@@ -1,3 +1,4 @@
 obj-$(CONFIG_CRYPTO_DEV_PADLOCK) += padlock.o
 obj-$(CONFIG_CRYPTO_DEV_PADLOCK_AES) += padlock-aes.o
 obj-$(CONFIG_CRYPTO_DEV_PADLOCK_SHA) += padlock-sha.o
+obj-$(CONFIG_CRYPTO_DEV_GEODE) += geode-aes.o
diff --git a/drivers/crypto/geode-aes.c b/drivers/crypto/geode-aes.c
new file mode 100644 (file)
index 0000000..43a6839
--- /dev/null
@@ -0,0 +1,474 @@
+ /* Copyright (C) 2004-2006, Advanced Micro Devices, 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.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/pci.h>
+#include <linux/pci_ids.h>
+#include <linux/crypto.h>
+#include <linux/spinlock.h>
+#include <crypto/algapi.h>
+
+#include <asm/io.h>
+#include <asm/delay.h>
+
+#include "geode-aes.h"
+
+/* Register definitions */
+
+#define AES_CTRLA_REG  0x0000
+
+#define AES_CTRL_START     0x01
+#define AES_CTRL_DECRYPT   0x00
+#define AES_CTRL_ENCRYPT   0x02
+#define AES_CTRL_WRKEY     0x04
+#define AES_CTRL_DCA       0x08
+#define AES_CTRL_SCA       0x10
+#define AES_CTRL_CBC       0x20
+
+#define AES_INTR_REG  0x0008
+
+#define AES_INTRA_PENDING (1 << 16)
+#define AES_INTRB_PENDING (1 << 17)
+
+#define AES_INTR_PENDING  (AES_INTRA_PENDING | AES_INTRB_PENDING)
+#define AES_INTR_MASK     0x07
+
+#define AES_SOURCEA_REG   0x0010
+#define AES_DSTA_REG      0x0014
+#define AES_LENA_REG      0x0018
+#define AES_WRITEKEY0_REG 0x0030
+#define AES_WRITEIV0_REG  0x0040
+
+/*  A very large counter that is used to gracefully bail out of an
+ *  operation in case of trouble
+ */
+
+#define AES_OP_TIMEOUT    0x50000
+
+/* Static structures */
+
+static void __iomem * _iobase;
+static spinlock_t lock;
+
+/* Write a 128 bit field (either a writable key or IV) */
+static inline void
+_writefield(u32 offset, void *value)
+{
+       int i;
+       for(i = 0; i < 4; i++)
+               iowrite32(((u32 *) value)[i], _iobase + offset + (i * 4));
+}
+
+/* Read a 128 bit field (either a writable key or IV) */
+static inline void
+_readfield(u32 offset, void *value)
+{
+       int i;
+       for(i = 0; i < 4; i++)
+               ((u32 *) value)[i] = ioread32(_iobase + offset + (i * 4));
+}
+
+static int
+do_crypt(void *src, void *dst, int len, u32 flags)
+{
+       u32 status;
+       u32 counter = AES_OP_TIMEOUT;
+
+       iowrite32(virt_to_phys(src), _iobase + AES_SOURCEA_REG);
+       iowrite32(virt_to_phys(dst), _iobase + AES_DSTA_REG);
+       iowrite32(len,  _iobase + AES_LENA_REG);
+
+       /* Start the operation */
+       iowrite32(AES_CTRL_START | flags, _iobase + AES_CTRLA_REG);
+
+       do
+               status = ioread32(_iobase + AES_INTR_REG);
+       while(!(status & AES_INTRA_PENDING) && --counter);
+
+       /* Clear the event */
+       iowrite32((status & 0xFF) | AES_INTRA_PENDING, _iobase + AES_INTR_REG);
+       return counter ? 0 : 1;
+}
+
+static unsigned int
+geode_aes_crypt(struct geode_aes_op *op)
+{
+
+       u32 flags = 0;
+       int iflags;
+
+       if (op->len == 0 || op->src == op->dst)
+               return 0;
+
+       if (op->flags & AES_FLAGS_COHERENT)
+               flags |= (AES_CTRL_DCA | AES_CTRL_SCA);
+
+       if (op->dir == AES_DIR_ENCRYPT)
+               flags |= AES_CTRL_ENCRYPT;
+
+       /* Start the critical section */
+
+       spin_lock_irqsave(&lock, iflags);
+
+       if (op->mode == AES_MODE_CBC) {
+               flags |= AES_CTRL_CBC;
+               _writefield(AES_WRITEIV0_REG, op->iv);
+       }
+
+       if (op->flags & AES_FLAGS_USRKEY) {
+               flags |= AES_CTRL_WRKEY;
+               _writefield(AES_WRITEKEY0_REG, op->key);
+       }
+
+       do_crypt(op->src, op->dst, op->len, flags);
+
+       if (op->mode == AES_MODE_CBC)
+               _readfield(AES_WRITEIV0_REG, op->iv);
+
+       spin_unlock_irqrestore(&lock, iflags);
+
+       return op->len;
+}
+
+/* CRYPTO-API Functions */
+
+static int
+geode_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int len)
+{
+       struct geode_aes_op *op = crypto_tfm_ctx(tfm);
+
+       if (len != AES_KEY_LENGTH) {
+               tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
+               return -EINVAL;
+       }
+
+       memcpy(op->key, key, len);
+       return 0;
+}
+
+static void
+geode_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
+{
+       struct geode_aes_op *op = crypto_tfm_ctx(tfm);
+
+       if ((out == NULL) || (in == NULL))
+               return;
+
+       op->src = (void *) in;
+       op->dst = (void *) out;
+       op->mode = AES_MODE_ECB;
+       op->flags = 0;
+       op->len = AES_MIN_BLOCK_SIZE;
+       op->dir = AES_DIR_ENCRYPT;
+
+       geode_aes_crypt(op);
+}
+
+
+static void
+geode_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
+{
+       struct geode_aes_op *op = crypto_tfm_ctx(tfm);
+
+       if ((out == NULL) || (in == NULL))
+               return;
+
+       op->src = (void *) in;
+       op->dst = (void *) out;
+       op->mode = AES_MODE_ECB;
+       op->flags = 0;
+       op->len = AES_MIN_BLOCK_SIZE;
+       op->dir = AES_DIR_DECRYPT;
+
+       geode_aes_crypt(op);
+}
+
+
+static struct crypto_alg geode_alg = {
+       .cra_name               =       "aes",
+       .cra_driver_name        =       "geode-aes-128",
+       .cra_priority           =       300,
+       .cra_alignmask          =       15,
+       .cra_flags              =       CRYPTO_ALG_TYPE_CIPHER,
+       .cra_blocksize          =       AES_MIN_BLOCK_SIZE,
+       .cra_ctxsize            =       sizeof(struct geode_aes_op),
+       .cra_module             =       THIS_MODULE,
+       .cra_list               =       LIST_HEAD_INIT(geode_alg.cra_list),
+       .cra_u                  =       {
+               .cipher = {
+                       .cia_min_keysize        =  AES_KEY_LENGTH,
+                       .cia_max_keysize        =  AES_KEY_LENGTH,
+                       .cia_setkey             =  geode_setkey,
+                       .cia_encrypt            =  geode_encrypt,
+                       .cia_decrypt            =  geode_decrypt
+               }
+       }
+};
+
+static int
+geode_cbc_decrypt(struct blkcipher_desc *desc,
+                 struct scatterlist *dst, struct scatterlist *src,
+                 unsigned int nbytes)
+{
+       struct geode_aes_op *op = crypto_blkcipher_ctx(desc->tfm);
+       struct blkcipher_walk walk;
+       int err, ret;
+
+       blkcipher_walk_init(&walk, dst, src, nbytes);
+       err = blkcipher_walk_virt(desc, &walk);
+
+       while((nbytes = walk.nbytes)) {
+               op->src = walk.src.virt.addr,
+               op->dst = walk.dst.virt.addr;
+               op->mode = AES_MODE_CBC;
+               op->len = nbytes - (nbytes % AES_MIN_BLOCK_SIZE);
+               op->dir = AES_DIR_DECRYPT;
+
+               memcpy(op->iv, walk.iv, AES_IV_LENGTH);
+
+               ret = geode_aes_crypt(op);
+
+               memcpy(walk.iv, op->iv, AES_IV_LENGTH);
+               nbytes -= ret;
+
+               err = blkcipher_walk_done(desc, &walk, nbytes);
+       }
+
+       return err;
+}
+
+static int
+geode_cbc_encrypt(struct blkcipher_desc *desc,
+                 struct scatterlist *dst, struct scatterlist *src,
+                 unsigned int nbytes)
+{
+       struct geode_aes_op *op = crypto_blkcipher_ctx(desc->tfm);
+       struct blkcipher_walk walk;
+       int err, ret;
+
+       blkcipher_walk_init(&walk, dst, src, nbytes);
+       err = blkcipher_walk_virt(desc, &walk);
+
+       while((nbytes = walk.nbytes)) {
+               op->src = walk.src.virt.addr,
+               op->dst = walk.dst.virt.addr;
+               op->mode = AES_MODE_CBC;
+               op->len = nbytes - (nbytes % AES_MIN_BLOCK_SIZE);
+               op->dir = AES_DIR_ENCRYPT;
+
+               memcpy(op->iv, walk.iv, AES_IV_LENGTH);
+
+               ret = geode_aes_crypt(op);
+               nbytes -= ret;
+               err = blkcipher_walk_done(desc, &walk, nbytes);
+       }
+
+       return err;
+}
+
+static struct crypto_alg geode_cbc_alg = {
+       .cra_name               =       "cbc(aes)",
+       .cra_driver_name        =       "cbc-aes-geode-128",
+       .cra_priority           =       400,
+       .cra_flags              =       CRYPTO_ALG_TYPE_BLKCIPHER,
+       .cra_blocksize          =       AES_MIN_BLOCK_SIZE,
+       .cra_ctxsize            =       sizeof(struct geode_aes_op),
+       .cra_alignmask          =       15,
+       .cra_type               =       &crypto_blkcipher_type,
+       .cra_module             =       THIS_MODULE,
+       .cra_list               =       LIST_HEAD_INIT(geode_cbc_alg.cra_list),
+       .cra_u                  =       {
+               .blkcipher = {
+                       .min_keysize            =       AES_KEY_LENGTH,
+                       .max_keysize            =       AES_KEY_LENGTH,
+                       .setkey                 =       geode_setkey,
+                       .encrypt                =       geode_cbc_encrypt,
+                       .decrypt                =       geode_cbc_decrypt,
+               }
+       }
+};
+
+static int
+geode_ecb_decrypt(struct blkcipher_desc *desc,
+                 struct scatterlist *dst, struct scatterlist *src,
+                 unsigned int nbytes)
+{
+       struct geode_aes_op *op = crypto_blkcipher_ctx(desc->tfm);
+       struct blkcipher_walk walk;
+       int err, ret;
+
+       blkcipher_walk_init(&walk, dst, src, nbytes);
+       err = blkcipher_walk_virt(desc, &walk);
+
+       while((nbytes = walk.nbytes)) {
+               op->src = walk.src.virt.addr,
+               op->dst = walk.dst.virt.addr;
+               op->mode = AES_MODE_ECB;
+               op->len = nbytes - (nbytes % AES_MIN_BLOCK_SIZE);
+               op->dir = AES_DIR_DECRYPT;
+
+               ret = geode_aes_crypt(op);
+               nbytes -= ret;
+               err = blkcipher_walk_done(desc, &walk, nbytes);
+       }
+
+       return err;
+}
+
+static int
+geode_ecb_encrypt(struct blkcipher_desc *desc,
+                 struct scatterlist *dst, struct scatterlist *src,
+                 unsigned int nbytes)
+{
+       struct geode_aes_op *op = crypto_blkcipher_ctx(desc->tfm);
+       struct blkcipher_walk walk;
+       int err, ret;
+
+       blkcipher_walk_init(&walk, dst, src, nbytes);
+       err = blkcipher_walk_virt(desc, &walk);
+
+       while((nbytes = walk.nbytes)) {
+               op->src = walk.src.virt.addr,
+               op->dst = walk.dst.virt.addr;
+               op->mode = AES_MODE_ECB;
+               op->len = nbytes - (nbytes % AES_MIN_BLOCK_SIZE);
+               op->dir = AES_DIR_ENCRYPT;
+
+               ret = geode_aes_crypt(op);
+               nbytes -= ret;
+               ret =  blkcipher_walk_done(desc, &walk, nbytes);
+       }
+
+       return err;
+}
+
+static struct crypto_alg geode_ecb_alg = {
+       .cra_name               =       "ecb(aes)",
+       .cra_driver_name        =       "ecb-aes-geode-128",
+       .cra_priority           =       400,
+       .cra_flags              =       CRYPTO_ALG_TYPE_BLKCIPHER,
+       .cra_blocksize          =       AES_MIN_BLOCK_SIZE,
+       .cra_ctxsize            =       sizeof(struct geode_aes_op),
+       .cra_alignmask          =       15,
+       .cra_type               =       &crypto_blkcipher_type,
+       .cra_module             =       THIS_MODULE,
+       .cra_list               =       LIST_HEAD_INIT(geode_ecb_alg.cra_list),
+       .cra_u                  =       {
+               .blkcipher = {
+                       .min_keysize            =       AES_KEY_LENGTH,
+                       .max_keysize            =       AES_KEY_LENGTH,
+                       .setkey                 =       geode_setkey,
+                       .encrypt                =       geode_ecb_encrypt,
+                       .decrypt                =       geode_ecb_decrypt,
+               }
+       }
+};
+
+static void
+geode_aes_remove(struct pci_dev *dev)
+{
+       crypto_unregister_alg(&geode_alg);
+       crypto_unregister_alg(&geode_ecb_alg);
+       crypto_unregister_alg(&geode_cbc_alg);
+
+       pci_iounmap(dev, _iobase);
+       _iobase = NULL;
+
+       pci_release_regions(dev);
+       pci_disable_device(dev);
+}
+
+
+static int
+geode_aes_probe(struct pci_dev *dev, const struct pci_device_id *id)
+{
+       int ret;
+
+       if ((ret = pci_enable_device(dev)))
+               return ret;
+
+       if ((ret = pci_request_regions(dev, "geode-aes-128")))
+               goto eenable;
+
+       _iobase = pci_iomap(dev, 0, 0);
+
+       if (_iobase == NULL) {
+               ret = -ENOMEM;
+               goto erequest;
+       }
+
+       spin_lock_init(&lock);
+
+       /* Clear any pending activity */
+       iowrite32(AES_INTR_PENDING | AES_INTR_MASK, _iobase + AES_INTR_REG);
+
+       if ((ret = crypto_register_alg(&geode_alg)))
+               goto eiomap;
+
+       if ((ret = crypto_register_alg(&geode_ecb_alg)))
+               goto ealg;
+
+       if ((ret = crypto_register_alg(&geode_cbc_alg)))
+               goto eecb;
+
+       printk(KERN_NOTICE "geode-aes: GEODE AES engine enabled.\n");
+       return 0;
+
+ eecb:
+       crypto_unregister_alg(&geode_ecb_alg);
+
+ ealg:
+       crypto_unregister_alg(&geode_alg);
+
+ eiomap:
+       pci_iounmap(dev, _iobase);
+
+ erequest:
+       pci_release_regions(dev);
+
+ eenable:
+       pci_disable_device(dev);
+
+       printk(KERN_ERR "geode-aes:  GEODE AES initialization failed.\n");
+       return ret;
+}
+
+static struct pci_device_id geode_aes_tbl[] = {
+       { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LX_AES, PCI_ANY_ID, PCI_ANY_ID} ,
+       { 0, }
+};
+
+MODULE_DEVICE_TABLE(pci, geode_aes_tbl);
+
+static struct pci_driver geode_aes_driver = {
+       .name = "Geode LX AES",
+       .id_table = geode_aes_tbl,
+       .probe = geode_aes_probe,
+       .remove = __devexit_p(geode_aes_remove)
+};
+
+static int __init
+geode_aes_init(void)
+{
+       return pci_module_init(&geode_aes_driver);
+}
+
+static void __exit
+geode_aes_exit(void)
+{
+       pci_unregister_driver(&geode_aes_driver);
+}
+
+MODULE_AUTHOR("Advanced Micro Devices, Inc.");
+MODULE_DESCRIPTION("Geode LX Hardware AES driver");
+MODULE_LICENSE("GPL");
+
+module_init(geode_aes_init);
+module_exit(geode_aes_exit);
diff --git a/drivers/crypto/geode-aes.h b/drivers/crypto/geode-aes.h
new file mode 100644 (file)
index 0000000..8003a36
--- /dev/null
@@ -0,0 +1,40 @@
+/* Copyright (C) 2003-2006, Advanced Micro Devices, 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.
+ */
+
+#ifndef _GEODE_AES_H_
+#define _GEODE_AES_H_
+
+#define AES_KEY_LENGTH 16
+#define AES_IV_LENGTH  16
+
+#define AES_MIN_BLOCK_SIZE 16
+
+#define AES_MODE_ECB 0
+#define AES_MODE_CBC 1
+
+#define AES_DIR_DECRYPT 0
+#define AES_DIR_ENCRYPT 1
+
+#define AES_FLAGS_USRKEY   (1 << 0)
+#define AES_FLAGS_COHERENT (1 << 1)
+
+struct geode_aes_op {
+
+       void *src;
+       void *dst;
+
+       u32 mode;
+       u32 dir;
+       u32 flags;
+       int len;
+
+       u8 key[AES_KEY_LENGTH];
+       u8 iv[AES_IV_LENGTH];
+};
+
+#endif
index 0358419a0e48b7870f044920ae318c6d50187ef3..8e872610461954d54197d77fc18eb53af5ea4341 100644 (file)
@@ -636,10 +636,10 @@ static int ioat_self_test(struct ioat_device *device)
        dma_cookie_t cookie;
        int err = 0;
 
-       src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, SLAB_KERNEL);
+       src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL);
        if (!src)
                return -ENOMEM;
-       dest = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, SLAB_KERNEL);
+       dest = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL);
        if (!dest) {
                kfree(src);
                return -ENOMEM;
index 75e9e38330ff4d4de4785ba116c7c2cd20fb6f4d..1b4fc922180386cd4107ec42f4328b4f50584be4 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/sysdev.h>
 #include <linux/ctype.h>
 #include <linux/kthread.h>
+#include <linux/freezer.h>
 #include <asm/uaccess.h>
 #include <asm/page.h>
 #include <asm/edac.h>
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
new file mode 100644 (file)
index 0000000..96d4a0b
--- /dev/null
@@ -0,0 +1,18 @@
+#
+# HID driver configuration
+#
+menu "HID Devices"
+       depends on INPUT
+
+config HID
+       tristate "Generic HID support"
+       default y
+       ---help---
+         Say Y here if you want generic HID support to connect keyboards,
+         mice, joysticks, graphic tablets, or any other HID based devices
+         to your computer. You also need to select particular types of
+         HID devices you want to compile support for, in the particular
+         driver menu (USB, Bluetooth)
+
+endmenu
+
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
new file mode 100644 (file)
index 0000000..6432392
--- /dev/null
@@ -0,0 +1,15 @@
+#
+# Makefile for the HID driver
+#
+
+# Multipart objects.
+hid-objs       := hid-core.o hid-input.o
+
+# Optional parts of multipart objects.
+
+obj-$(CONFIG_HID)              += hid.o
+
+ifeq ($(CONFIG_INPUT_DEBUG),y)
+EXTRA_CFLAGS += -DDEBUG
+endif
+
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
new file mode 100644 (file)
index 0000000..18c2b3c
--- /dev/null
@@ -0,0 +1,1003 @@
+/*
+ *  HID support for Linux
+ *
+ *  Copyright (c) 1999 Andreas Gal
+ *  Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
+ *  Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
+ *  Copyright (c) 2006 Jiri Kosina
+ */
+
+/*
+ * 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/module.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/list.h>
+#include <linux/mm.h>
+#include <linux/smp_lock.h>
+#include <linux/spinlock.h>
+#include <asm/unaligned.h>
+#include <asm/byteorder.h>
+#include <linux/input.h>
+#include <linux/wait.h>
+
+#undef DEBUG
+#undef DEBUG_DATA
+
+#include <linux/hid.h>
+#include <linux/hiddev.h>
+
+/*
+ * Version Information
+ */
+
+#define DRIVER_VERSION "v2.6"
+#define DRIVER_AUTHOR "Andreas Gal, Vojtech Pavlik"
+#define DRIVER_DESC "USB HID core driver"
+#define DRIVER_LICENSE "GPL"
+
+/*
+ * Module parameters.
+ */
+
+static unsigned int hid_mousepoll_interval;
+module_param_named(mousepoll, hid_mousepoll_interval, uint, 0644);
+MODULE_PARM_DESC(mousepoll, "Polling interval of mice");
+
+/*
+ * Register a new report for a device.
+ */
+
+static struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id)
+{
+       struct hid_report_enum *report_enum = device->report_enum + type;
+       struct hid_report *report;
+
+       if (report_enum->report_id_hash[id])
+               return report_enum->report_id_hash[id];
+
+       if (!(report = kzalloc(sizeof(struct hid_report), GFP_KERNEL)))
+               return NULL;
+
+       if (id != 0)
+               report_enum->numbered = 1;
+
+       report->id = id;
+       report->type = type;
+       report->size = 0;
+       report->device = device;
+       report_enum->report_id_hash[id] = report;
+
+       list_add_tail(&report->list, &report_enum->report_list);
+
+       return report;
+}
+
+/*
+ * Register a new field for this report.
+ */
+
+static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values)
+{
+       struct hid_field *field;
+
+       if (report->maxfield == HID_MAX_FIELDS) {
+               dbg("too many fields in report");
+               return NULL;
+       }
+
+       if (!(field = kzalloc(sizeof(struct hid_field) + usages * sizeof(struct hid_usage)
+               + values * sizeof(unsigned), GFP_KERNEL))) return NULL;
+
+       field->index = report->maxfield++;
+       report->field[field->index] = field;
+       field->usage = (struct hid_usage *)(field + 1);
+       field->value = (unsigned *)(field->usage + usages);
+       field->report = report;
+
+       return field;
+}
+
+/*
+ * Open a collection. The type/usage is pushed on the stack.
+ */
+
+static int open_collection(struct hid_parser *parser, unsigned type)
+{
+       struct hid_collection *collection;
+       unsigned usage;
+
+       usage = parser->local.usage[0];
+
+       if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) {
+               dbg("collection stack overflow");
+               return -1;
+       }
+
+       if (parser->device->maxcollection == parser->device->collection_size) {
+               collection = kmalloc(sizeof(struct hid_collection) *
+                               parser->device->collection_size * 2, GFP_KERNEL);
+               if (collection == NULL) {
+                       dbg("failed to reallocate collection array");
+                       return -1;
+               }
+               memcpy(collection, parser->device->collection,
+                       sizeof(struct hid_collection) *
+                       parser->device->collection_size);
+               memset(collection + parser->device->collection_size, 0,
+                       sizeof(struct hid_collection) *
+                       parser->device->collection_size);
+               kfree(parser->device->collection);
+               parser->device->collection = collection;
+               parser->device->collection_size *= 2;
+       }
+
+       parser->collection_stack[parser->collection_stack_ptr++] =
+               parser->device->maxcollection;
+
+       collection = parser->device->collection +
+               parser->device->maxcollection++;
+       collection->type = type;
+       collection->usage = usage;
+       collection->level = parser->collection_stack_ptr - 1;
+
+       if (type == HID_COLLECTION_APPLICATION)
+               parser->device->maxapplication++;
+
+       return 0;
+}
+
+/*
+ * Close a collection.
+ */
+
+static int close_collection(struct hid_parser *parser)
+{
+       if (!parser->collection_stack_ptr) {
+               dbg("collection stack underflow");
+               return -1;
+       }
+       parser->collection_stack_ptr--;
+       return 0;
+}
+
+/*
+ * Climb up the stack, search for the specified collection type
+ * and return the usage.
+ */
+
+static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type)
+{
+       int n;
+       for (n = parser->collection_stack_ptr - 1; n >= 0; n--)
+               if (parser->device->collection[parser->collection_stack[n]].type == type)
+                       return parser->device->collection[parser->collection_stack[n]].usage;
+       return 0; /* we know nothing about this usage type */
+}
+
+/*
+ * Add a usage to the temporary parser table.
+ */
+
+static int hid_add_usage(struct hid_parser *parser, unsigned usage)
+{
+       if (parser->local.usage_index >= HID_MAX_USAGES) {
+               dbg("usage index exceeded");
+               return -1;
+       }
+       parser->local.usage[parser->local.usage_index] = usage;
+       parser->local.collection_index[parser->local.usage_index] =
+               parser->collection_stack_ptr ?
+               parser->collection_stack[parser->collection_stack_ptr - 1] : 0;
+       parser->local.usage_index++;
+       return 0;
+}
+
+/*
+ * Register a new field for this report.
+ */
+
+static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsigned flags)
+{
+       struct hid_report *report;
+       struct hid_field *field;
+       int usages;
+       unsigned offset;
+       int i;
+
+       if (!(report = hid_register_report(parser->device, report_type, parser->global.report_id))) {
+               dbg("hid_register_report failed");
+               return -1;
+       }
+
+       if (parser->global.logical_maximum < parser->global.logical_minimum) {
+               dbg("logical range invalid %d %d", parser->global.logical_minimum, parser->global.logical_maximum);
+               return -1;
+       }
+
+       offset = report->size;
+       report->size += parser->global.report_size * parser->global.report_count;
+
+       if (!parser->local.usage_index) /* Ignore padding fields */
+               return 0;
+
+       usages = max_t(int, parser->local.usage_index, parser->global.report_count);
+
+       if ((field = hid_register_field(report, usages, parser->global.report_count)) == NULL)
+               return 0;
+
+       field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL);
+       field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL);
+       field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION);
+
+       for (i = 0; i < usages; i++) {
+               int j = i;
+               /* Duplicate the last usage we parsed if we have excess values */
+               if (i >= parser->local.usage_index)
+                       j = parser->local.usage_index - 1;
+               field->usage[i].hid = parser->local.usage[j];
+               field->usage[i].collection_index =
+                       parser->local.collection_index[j];
+       }
+
+       field->maxusage = usages;
+       field->flags = flags;
+       field->report_offset = offset;
+       field->report_type = report_type;
+       field->report_size = parser->global.report_size;
+       field->report_count = parser->global.report_count;
+       field->logical_minimum = parser->global.logical_minimum;
+       field->logical_maximum = parser->global.logical_maximum;
+       field->physical_minimum = parser->global.physical_minimum;
+       field->physical_maximum = parser->global.physical_maximum;
+       field->unit_exponent = parser->global.unit_exponent;
+       field->unit = parser->global.unit;
+
+       return 0;
+}
+
+/*
+ * Read data value from item.
+ */
+
+static u32 item_udata(struct hid_item *item)
+{
+       switch (item->size) {
+               case 1: return item->data.u8;
+               case 2: return item->data.u16;
+               case 4: return item->data.u32;
+       }
+       return 0;
+}
+
+static s32 item_sdata(struct hid_item *item)
+{
+       switch (item->size) {
+               case 1: return item->data.s8;
+               case 2: return item->data.s16;
+               case 4: return item->data.s32;
+       }
+       return 0;
+}
+
+/*
+ * Process a global item.
+ */
+
+static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
+{
+       switch (item->tag) {
+
+               case HID_GLOBAL_ITEM_TAG_PUSH:
+
+                       if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) {
+                               dbg("global enviroment stack overflow");
+                               return -1;
+                       }
+
+                       memcpy(parser->global_stack + parser->global_stack_ptr++,
+                               &parser->global, sizeof(struct hid_global));
+                       return 0;
+
+               case HID_GLOBAL_ITEM_TAG_POP:
+
+                       if (!parser->global_stack_ptr) {
+                               dbg("global enviroment stack underflow");
+                               return -1;
+                       }
+
+                       memcpy(&parser->global, parser->global_stack + --parser->global_stack_ptr,
+                               sizeof(struct hid_global));
+                       return 0;
+
+               case HID_GLOBAL_ITEM_TAG_USAGE_PAGE:
+                       parser->global.usage_page = item_udata(item);
+                       return 0;
+
+               case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM:
+                       parser->global.logical_minimum = item_sdata(item);
+                       return 0;
+
+               case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM:
+                       if (parser->global.logical_minimum < 0)
+                               parser->global.logical_maximum = item_sdata(item);
+                       else
+                               parser->global.logical_maximum = item_udata(item);
+                       return 0;
+
+               case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM:
+                       parser->global.physical_minimum = item_sdata(item);
+                       return 0;
+
+               case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM:
+                       if (parser->global.physical_minimum < 0)
+                               parser->global.physical_maximum = item_sdata(item);
+                       else
+                               parser->global.physical_maximum = item_udata(item);
+                       return 0;
+
+               case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT:
+                       parser->global.unit_exponent = item_sdata(item);
+                       return 0;
+
+               case HID_GLOBAL_ITEM_TAG_UNIT:
+                       parser->global.unit = item_udata(item);
+                       return 0;
+
+               case HID_GLOBAL_ITEM_TAG_REPORT_SIZE:
+                       if ((parser->global.report_size = item_udata(item)) > 32) {
+                               dbg("invalid report_size %d", parser->global.report_size);
+                               return -1;
+                       }
+                       return 0;
+
+               case HID_GLOBAL_ITEM_TAG_REPORT_COUNT:
+                       if ((parser->global.report_count = item_udata(item)) > HID_MAX_USAGES) {
+                               dbg("invalid report_count %d", parser->global.report_count);
+                               return -1;
+                       }
+                       return 0;
+
+               case HID_GLOBAL_ITEM_TAG_REPORT_ID:
+                       if ((parser->global.report_id = item_udata(item)) == 0) {
+                               dbg("report_id 0 is invalid");
+                               return -1;
+                       }
+                       return 0;
+
+               default:
+                       dbg("unknown global tag 0x%x", item->tag);
+                       return -1;
+       }
+}
+
+/*
+ * Process a local item.
+ */
+
+static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
+{
+       __u32 data;
+       unsigned n;
+
+       if (item->size == 0) {
+               dbg("item data expected for local item");
+               return -1;
+       }
+
+       data = item_udata(item);
+
+       switch (item->tag) {
+
+               case HID_LOCAL_ITEM_TAG_DELIMITER:
+
+                       if (data) {
+                               /*
+                                * We treat items before the first delimiter
+                                * as global to all usage sets (branch 0).
+                                * In the moment we process only these global
+                                * items and the first delimiter set.
+                                */
+                               if (parser->local.delimiter_depth != 0) {
+                                       dbg("nested delimiters");
+                                       return -1;
+                               }
+                               parser->local.delimiter_depth++;
+                               parser->local.delimiter_branch++;
+                       } else {
+                               if (parser->local.delimiter_depth < 1) {
+                                       dbg("bogus close delimiter");
+                                       return -1;
+                               }
+                               parser->local.delimiter_depth--;
+                       }
+                       return 1;
+
+               case HID_LOCAL_ITEM_TAG_USAGE:
+
+                       if (parser->local.delimiter_branch > 1) {
+                               dbg("alternative usage ignored");
+                               return 0;
+                       }
+
+                       if (item->size <= 2)
+                               data = (parser->global.usage_page << 16) + data;
+
+                       return hid_add_usage(parser, data);
+
+               case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
+
+                       if (parser->local.delimiter_branch > 1) {
+                               dbg("alternative usage ignored");
+                               return 0;
+                       }
+
+                       if (item->size <= 2)
+                               data = (parser->global.usage_page << 16) + data;
+
+                       parser->local.usage_minimum = data;
+                       return 0;
+
+               case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM:
+
+                       if (parser->local.delimiter_branch > 1) {
+                               dbg("alternative usage ignored");
+                               return 0;
+                       }
+
+                       if (item->size <= 2)
+                               data = (parser->global.usage_page << 16) + data;
+
+                       for (n = parser->local.usage_minimum; n <= data; n++)
+                               if (hid_add_usage(parser, n)) {
+                                       dbg("hid_add_usage failed\n");
+                                       return -1;
+                               }
+                       return 0;
+
+               default:
+
+                       dbg("unknown local item tag 0x%x", item->tag);
+                       return 0;
+       }
+       return 0;
+}
+
+/*
+ * Process a main item.
+ */
+
+static int hid_parser_main(struct hid_parser *parser, struct hid_item *item)
+{
+       __u32 data;
+       int ret;
+
+       data = item_udata(item);
+
+       switch (item->tag) {
+               case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION:
+                       ret = open_collection(parser, data & 0xff);
+                       break;
+               case HID_MAIN_ITEM_TAG_END_COLLECTION:
+                       ret = close_collection(parser);
+                       break;
+               case HID_MAIN_ITEM_TAG_INPUT:
+                       ret = hid_add_field(parser, HID_INPUT_REPORT, data);
+                       break;
+               case HID_MAIN_ITEM_TAG_OUTPUT:
+                       ret = hid_add_field(parser, HID_OUTPUT_REPORT, data);
+                       break;
+               case HID_MAIN_ITEM_TAG_FEATURE:
+                       ret = hid_add_field(parser, HID_FEATURE_REPORT, data);
+                       break;
+               default:
+                       dbg("unknown main item tag 0x%x", item->tag);
+                       ret = 0;
+       }
+
+       memset(&parser->local, 0, sizeof(parser->local));       /* Reset the local parser environment */
+
+       return ret;
+}
+
+/*
+ * Process a reserved item.
+ */
+
+static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item)
+{
+       dbg("reserved item type, tag 0x%x", item->tag);
+       return 0;
+}
+
+/*
+ * Free a report and all registered fields. The field->usage and
+ * field->value table's are allocated behind the field, so we need
+ * only to free(field) itself.
+ */
+
+static void hid_free_report(struct hid_report *report)
+{
+       unsigned n;
+
+       for (n = 0; n < report->maxfield; n++)
+               kfree(report->field[n]);
+       kfree(report);
+}
+
+/*
+ * Free a device structure, all reports, and all fields.
+ */
+
+void hid_free_device(struct hid_device *device)
+{
+       unsigned i,j;
+
+       for (i = 0; i < HID_REPORT_TYPES; i++) {
+               struct hid_report_enum *report_enum = device->report_enum + i;
+
+               for (j = 0; j < 256; j++) {
+                       struct hid_report *report = report_enum->report_id_hash[j];
+                       if (report)
+                               hid_free_report(report);
+               }
+       }
+
+       kfree(device->rdesc);
+       kfree(device);
+}
+EXPORT_SYMBOL_GPL(hid_free_device);
+
+/*
+ * Fetch a report description item from the data stream. We support long
+ * items, though they are not used yet.
+ */
+
+static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item)
+{
+       u8 b;
+
+       if ((end - start) <= 0)
+               return NULL;
+
+       b = *start++;
+
+       item->type = (b >> 2) & 3;
+       item->tag  = (b >> 4) & 15;
+
+       if (item->tag == HID_ITEM_TAG_LONG) {
+
+               item->format = HID_ITEM_FORMAT_LONG;
+
+               if ((end - start) < 2)
+                       return NULL;
+
+               item->size = *start++;
+               item->tag  = *start++;
+
+               if ((end - start) < item->size)
+                       return NULL;
+
+               item->data.longdata = start;
+               start += item->size;
+               return start;
+       }
+
+       item->format = HID_ITEM_FORMAT_SHORT;
+       item->size = b & 3;
+
+       switch (item->size) {
+
+               case 0:
+                       return start;
+
+               case 1:
+                       if ((end - start) < 1)
+                               return NULL;
+                       item->data.u8 = *start++;
+                       return start;
+
+               case 2:
+                       if ((end - start) < 2)
+                               return NULL;
+                       item->data.u16 = le16_to_cpu(get_unaligned((__le16*)start));
+                       start = (__u8 *)((__le16 *)start + 1);
+                       return start;
+
+               case 3:
+                       item->size++;
+                       if ((end - start) < 4)
+                               return NULL;
+                       item->data.u32 = le32_to_cpu(get_unaligned((__le32*)start));
+                       start = (__u8 *)((__le32 *)start + 1);
+                       return start;
+       }
+
+       return NULL;
+}
+
+/*
+ * Parse a report description into a hid_device structure. Reports are
+ * enumerated, fields are attached to these reports.
+ */
+
+struct hid_device *hid_parse_report(__u8 *start, unsigned size)
+{
+       struct hid_device *device;
+       struct hid_parser *parser;
+       struct hid_item item;
+       __u8 *end;
+       unsigned i;
+       static int (*dispatch_type[])(struct hid_parser *parser,
+                                     struct hid_item *item) = {
+               hid_parser_main,
+               hid_parser_global,
+               hid_parser_local,
+               hid_parser_reserved
+       };
+
+       if (!(device = kzalloc(sizeof(struct hid_device), GFP_KERNEL)))
+               return NULL;
+
+       if (!(device->collection = kzalloc(sizeof(struct hid_collection) *
+                                  HID_DEFAULT_NUM_COLLECTIONS, GFP_KERNEL))) {
+               kfree(device);
+               return NULL;
+       }
+       device->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
+
+       for (i = 0; i < HID_REPORT_TYPES; i++)
+               INIT_LIST_HEAD(&device->report_enum[i].report_list);
+
+       if (!(device->rdesc = (__u8 *)kmalloc(size, GFP_KERNEL))) {
+               kfree(device->collection);
+               kfree(device);
+               return NULL;
+       }
+       memcpy(device->rdesc, start, size);
+       device->rsize = size;
+
+       if (!(parser = kzalloc(sizeof(struct hid_parser), GFP_KERNEL))) {
+               kfree(device->rdesc);
+               kfree(device->collection);
+               kfree(device);
+               return NULL;
+       }
+       parser->device = device;
+
+       end = start + size;
+       while ((start = fetch_item(start, end, &item)) != NULL) {
+
+               if (item.format != HID_ITEM_FORMAT_SHORT) {
+                       dbg("unexpected long global item");
+                       kfree(device->collection);
+                       hid_free_device(device);
+                       kfree(parser);
+                       return NULL;
+               }
+
+               if (dispatch_type[item.type](parser, &item)) {
+                       dbg("item %u %u %u %u parsing failed\n",
+                               item.format, (unsigned)item.size, (unsigned)item.type, (unsigned)item.tag);
+                       kfree(device->collection);
+                       hid_free_device(device);
+                       kfree(parser);
+                       return NULL;
+               }
+
+               if (start == end) {
+                       if (parser->collection_stack_ptr) {
+                               dbg("unbalanced collection at end of report description");
+                               kfree(device->collection);
+                               hid_free_device(device);
+                               kfree(parser);
+                               return NULL;
+                       }
+                       if (parser->local.delimiter_depth) {
+                               dbg("unbalanced delimiter at end of report description");
+                               kfree(device->collection);
+                               hid_free_device(device);
+                               kfree(parser);
+                               return NULL;
+                       }
+                       kfree(parser);
+                       return device;
+               }
+       }
+
+       dbg("item fetching failed at offset %d\n", (int)(end - start));
+       kfree(device->collection);
+       hid_free_device(device);
+       kfree(parser);
+       return NULL;
+}
+EXPORT_SYMBOL_GPL(hid_parse_report);
+
+/*
+ * Convert a signed n-bit integer to signed 32-bit integer. Common
+ * cases are done through the compiler, the screwed things has to be
+ * done by hand.
+ */
+
+static s32 snto32(__u32 value, unsigned n)
+{
+       switch (n) {
+               case 8:  return ((__s8)value);
+               case 16: return ((__s16)value);
+               case 32: return ((__s32)value);
+       }
+       return value & (1 << (n - 1)) ? value | (-1 << n) : value;
+}
+
+/*
+ * Convert a signed 32-bit integer to a signed n-bit integer.
+ */
+
+static u32 s32ton(__s32 value, unsigned n)
+{
+       s32 a = value >> (n - 1);
+       if (a && a != -1)
+               return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1;
+       return value & ((1 << n) - 1);
+}
+
+/*
+ * Extract/implement a data field from/to a little endian report (bit array).
+ *
+ * Code sort-of follows HID spec:
+ *     http://www.usb.org/developers/devclass_docs/HID1_11.pdf
+ *
+ * While the USB HID spec allows unlimited length bit fields in "report
+ * descriptors", most devices never use more than 16 bits.
+ * One model of UPS is claimed to report "LINEV" as a 32-bit field.
+ * Search linux-kernel and linux-usb-devel archives for "hid-core extract".
+ */
+
+static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n)
+{
+       u64 x;
+
+       WARN_ON(n > 32);
+
+       report += offset >> 3;  /* adjust byte index */
+       offset &= 7;            /* now only need bit offset into one byte */
+       x = get_unaligned((u64 *) report);
+       x = le64_to_cpu(x);
+       x = (x >> offset) & ((1ULL << n) - 1);  /* extract bit field */
+       return (u32) x;
+}
+
+/*
+ * "implement" : set bits in a little endian bit stream.
+ * Same concepts as "extract" (see comments above).
+ * The data mangled in the bit stream remains in little endian
+ * order the whole time. It make more sense to talk about
+ * endianness of register values by considering a register
+ * a "cached" copy of the little endiad bit stream.
+ */
+static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value)
+{
+       u64 x;
+       u64 m = (1ULL << n) - 1;
+
+       WARN_ON(n > 32);
+
+       WARN_ON(value > m);
+       value &= m;
+
+       report += offset >> 3;
+       offset &= 7;
+
+       x = get_unaligned((u64 *)report);
+       x &= cpu_to_le64(~(m << offset));
+       x |= cpu_to_le64(((u64) value) << offset);
+       put_unaligned(x, (u64 *) report);
+}
+
+/*
+ * Search an array for a value.
+ */
+
+static __inline__ int search(__s32 *array, __s32 value, unsigned n)
+{
+       while (n--) {
+               if (*array++ == value)
+                       return 0;
+       }
+       return -1;
+}
+
+static void hid_process_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value, int interrupt)
+{
+       hid_dump_input(usage, value);
+       if (hid->claimed & HID_CLAIMED_INPUT)
+               hidinput_hid_event(hid, field, usage, value);
+       if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event)
+               hid->hiddev_hid_event(hid, field, usage, value);
+}
+
+/*
+ * Analyse a received field, and fetch the data from it. The field
+ * content is stored for next report processing (we do differential
+ * reporting to the layer).
+ */
+
+void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, int interrupt)
+{
+       unsigned n;
+       unsigned count = field->report_count;
+       unsigned offset = field->report_offset;
+       unsigned size = field->report_size;
+       __s32 min = field->logical_minimum;
+       __s32 max = field->logical_maximum;
+       __s32 *value;
+
+       if (!(value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC)))
+               return;
+
+       for (n = 0; n < count; n++) {
+
+                       value[n] = min < 0 ? snto32(extract(data, offset + n * size, size), size) :
+                                                   extract(data, offset + n * size, size);
+
+                       if (!(field->flags & HID_MAIN_ITEM_VARIABLE) /* Ignore report if ErrorRollOver */
+                           && value[n] >= min && value[n] <= max
+                           && field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1)
+                               goto exit;
+       }
+
+       for (n = 0; n < count; n++) {
+
+               if (HID_MAIN_ITEM_VARIABLE & field->flags) {
+                       hid_process_event(hid, field, &field->usage[n], value[n], interrupt);
+                       continue;
+               }
+
+               if (field->value[n] >= min && field->value[n] <= max
+                       && field->usage[field->value[n] - min].hid
+                       && search(value, field->value[n], count))
+                               hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt);
+
+               if (value[n] >= min && value[n] <= max
+                       && field->usage[value[n] - min].hid
+                       && search(field->value, value[n], count))
+                               hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt);
+       }
+
+       memcpy(field->value, value, count * sizeof(__s32));
+exit:
+       kfree(value);
+}
+EXPORT_SYMBOL_GPL(hid_input_field);
+
+/*
+ * Output the field into the report.
+ */
+
+static void hid_output_field(struct hid_field *field, __u8 *data)
+{
+       unsigned count = field->report_count;
+       unsigned offset = field->report_offset;
+       unsigned size = field->report_size;
+       unsigned n;
+
+       for (n = 0; n < count; n++) {
+               if (field->logical_minimum < 0) /* signed values */
+                       implement(data, offset + n * size, size, s32ton(field->value[n], size));
+               else                            /* unsigned values */
+                       implement(data, offset + n * size, size, field->value[n]);
+       }
+}
+
+/*
+ * Create a report.
+ */
+
+void hid_output_report(struct hid_report *report, __u8 *data)
+{
+       unsigned n;
+
+       if (report->id > 0)
+               *data++ = report->id;
+
+       for (n = 0; n < report->maxfield; n++)
+               hid_output_field(report->field[n], data);
+}
+EXPORT_SYMBOL_GPL(hid_output_report);
+
+/*
+ * Set a field value. The report this field belongs to has to be
+ * created and transferred to the device, to set this value in the
+ * device.
+ */
+
+int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
+{
+       unsigned size = field->report_size;
+
+       hid_dump_input(field->usage + offset, value);
+
+       if (offset >= field->report_count) {
+               dbg("offset (%d) exceeds report_count (%d)", offset, field->report_count);
+               hid_dump_field(field, 8);
+               return -1;
+       }
+       if (field->logical_minimum < 0) {
+               if (value != snto32(s32ton(value, size), size)) {
+                       dbg("value %d is out of range", value);
+                       return -1;
+               }
+       }
+       field->value[offset] = value;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(hid_set_field);
+
+int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt)
+{
+       struct hid_report_enum *report_enum = hid->report_enum + type;
+       struct hid_report *report;
+       int n, rsize;
+
+       if (!hid)
+               return -ENODEV;
+
+       if (!size) {
+               dbg("empty report");
+               return -1;
+       }
+
+#ifdef DEBUG_DATA
+       printk(KERN_DEBUG __FILE__ ": report (size %u) (%snumbered)\n", len, report_enum->numbered ? "" : "un");
+#endif
+
+       n = 0;                          /* Normally report number is 0 */
+       if (report_enum->numbered) {    /* Device uses numbered reports, data[0] is report number */
+               n = *data++;
+               size--;
+       }
+
+#ifdef DEBUG_DATA
+       {
+               int i;
+               printk(KERN_DEBUG __FILE__ ": report %d (size %u) = ", n, size);
+               for (i = 0; i < size; i++)
+                       printk(" %02x", data[i]);
+               printk("\n");
+       }
+#endif
+
+       if (!(report = report_enum->report_id_hash[n])) {
+               dbg("undefined report_id %d received", n);
+               return -1;
+       }
+
+       rsize = ((report->size - 1) >> 3) + 1;
+
+       if (size < rsize) {
+               dbg("report %d is too short, (%d < %d)", report->id, size, rsize);
+               return -1;
+       }
+
+       if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event)
+               hid->hiddev_report_event(hid, report);
+
+       for (n = 0; n < report->maxfield; n++)
+               hid_input_field(hid, report->field[n], data, interrupt);
+
+       if (hid->claimed & HID_CLAIMED_INPUT)
+               hidinput_report_event(hid, report);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(hid_input_report);
+
+MODULE_LICENSE(DRIVER_LICENSE);
+
similarity index 88%
rename from drivers/usb/input/hid-input.c
rename to drivers/hid/hid-input.c
index 68e7ebb978a9721c0eb13ce6d0d4710c00d78c42..14cdf09316ced7ef613fa1caa42a970f2407b6d0 100644 (file)
@@ -2,8 +2,9 @@
  * $Id: hid-input.c,v 1.2 2002/04/23 00:59:25 rdamazio Exp $
  *
  *  Copyright (c) 2000-2001 Vojtech Pavlik
+ *  Copyright (c) 2006 Jiri Kosina
  *
- *  USB HID to Linux Input mapping
+ *  HID to Linux Input mapping
  */
 
 /*
@@ -33,7 +34,7 @@
 
 #undef DEBUG
 
-#include "hid.h"
+#include <linux/hid.h>
 
 #define unk    KEY_UNKNOWN
 
@@ -81,42 +82,42 @@ struct hidinput_key_translation {
 
 static struct hidinput_key_translation powerbook_fn_keys[] = {
        { KEY_BACKSPACE, KEY_DELETE },
-       { KEY_F1,       KEY_BRIGHTNESSDOWN,     POWERBOOK_FLAG_FKEY },
-       { KEY_F2,       KEY_BRIGHTNESSUP,       POWERBOOK_FLAG_FKEY },
-       { KEY_F3,       KEY_MUTE,               POWERBOOK_FLAG_FKEY },
-       { KEY_F4,       KEY_VOLUMEDOWN,         POWERBOOK_FLAG_FKEY },
-       { KEY_F5,       KEY_VOLUMEUP,           POWERBOOK_FLAG_FKEY },
-       { KEY_F6,       KEY_NUMLOCK,            POWERBOOK_FLAG_FKEY },
-       { KEY_F7,       KEY_SWITCHVIDEOMODE,    POWERBOOK_FLAG_FKEY },
-       { KEY_F8,       KEY_KBDILLUMTOGGLE,     POWERBOOK_FLAG_FKEY },
-       { KEY_F9,       KEY_KBDILLUMDOWN,       POWERBOOK_FLAG_FKEY },
-       { KEY_F10,      KEY_KBDILLUMUP,         POWERBOOK_FLAG_FKEY },
-       { KEY_UP,       KEY_PAGEUP },
-       { KEY_DOWN,     KEY_PAGEDOWN },
-       { KEY_LEFT,     KEY_HOME },
-       { KEY_RIGHT,    KEY_END },
+       { KEY_F1,       KEY_BRIGHTNESSDOWN,     POWERBOOK_FLAG_FKEY },
+       { KEY_F2,       KEY_BRIGHTNESSUP,       POWERBOOK_FLAG_FKEY },
+       { KEY_F3,       KEY_MUTE,               POWERBOOK_FLAG_FKEY },
+       { KEY_F4,       KEY_VOLUMEDOWN,         POWERBOOK_FLAG_FKEY },
+       { KEY_F5,       KEY_VOLUMEUP,           POWERBOOK_FLAG_FKEY },
+       { KEY_F6,       KEY_NUMLOCK,            POWERBOOK_FLAG_FKEY },
+       { KEY_F7,       KEY_SWITCHVIDEOMODE,    POWERBOOK_FLAG_FKEY },
+       { KEY_F8,       KEY_KBDILLUMTOGGLE,     POWERBOOK_FLAG_FKEY },
+       { KEY_F9,       KEY_KBDILLUMDOWN,       POWERBOOK_FLAG_FKEY },
+       { KEY_F10,      KEY_KBDILLUMUP,         POWERBOOK_FLAG_FKEY },
+       { KEY_UP,       KEY_PAGEUP },
+       { KEY_DOWN,     KEY_PAGEDOWN },
+       { KEY_LEFT,     KEY_HOME },
+       { KEY_RIGHT,    KEY_END },
        { }
 };
 
 static struct hidinput_key_translation powerbook_numlock_keys[] = {
-       { KEY_J,        KEY_KP1 },
-       { KEY_K,        KEY_KP2 },
-       { KEY_L,        KEY_KP3 },
-       { KEY_U,        KEY_KP4 },
-       { KEY_I,        KEY_KP5 },
-       { KEY_O,        KEY_KP6 },
-       { KEY_7,        KEY_KP7 },
-       { KEY_8,        KEY_KP8 },
-       { KEY_9,        KEY_KP9 },
-       { KEY_M,        KEY_KP0 },
-       { KEY_DOT,      KEY_KPDOT },
-       { KEY_SLASH,    KEY_KPPLUS },
+       { KEY_J,        KEY_KP1 },
+       { KEY_K,        KEY_KP2 },
+       { KEY_L,        KEY_KP3 },
+       { KEY_U,        KEY_KP4 },
+       { KEY_I,        KEY_KP5 },
+       { KEY_O,        KEY_KP6 },
+       { KEY_7,        KEY_KP7 },
+       { KEY_8,        KEY_KP8 },
+       { KEY_9,        KEY_KP9 },
+       { KEY_M,        KEY_KP0 },
+       { KEY_DOT,      KEY_KPDOT },
+       { KEY_SLASH,    KEY_KPPLUS },
        { KEY_SEMICOLON, KEY_KPMINUS },
-       { KEY_P,        KEY_KPASTERISK },
-       { KEY_MINUS,    KEY_KPEQUAL },
-       { KEY_0,        KEY_KPSLASH },
-       { KEY_F6,       KEY_NUMLOCK },
-       { KEY_KPENTER,  KEY_KPENTER },
+       { KEY_P,        KEY_KPASTERISK },
+       { KEY_MINUS,    KEY_KPEQUAL },
+       { KEY_0,        KEY_KPSLASH },
+       { KEY_F6,       KEY_NUMLOCK },
+       { KEY_KPENTER,  KEY_KPENTER },
        { KEY_BACKSPACE, KEY_BACKSPACE },
        { }
 };
@@ -127,11 +128,6 @@ static struct hidinput_key_translation powerbook_iso_keyboard[] = {
        { }
 };
 
-static int usbhid_pb_fnmode = 1;
-module_param_named(pb_fnmode, usbhid_pb_fnmode, int, 0644);
-MODULE_PARM_DESC(pb_fnmode,
-       "Mode of fn key on PowerBooks (0 = disabled, 1 = fkeyslast, 2 = fkeysfirst)");
-
 static struct hidinput_key_translation *find_translation(struct hidinput_key_translation *table, u16 from)
 {
        struct hidinput_key_translation *trans;
@@ -145,7 +141,7 @@ static struct hidinput_key_translation *find_translation(struct hidinput_key_tra
 }
 
 static int hidinput_pb_event(struct hid_device *hid, struct input_dev *input,
-                            struct hid_usage *usage, __s32 value)
+               struct hid_usage *usage, __s32 value)
 {
        struct hidinput_key_translation *trans;
 
@@ -158,7 +154,7 @@ static int hidinput_pb_event(struct hid_device *hid, struct input_dev *input,
                return 1;
        }
 
-       if (usbhid_pb_fnmode) {
+       if (hid->pb_fnmode) {
                int do_translate;
 
                trans = find_translation(powerbook_fn_keys, usage->code);
@@ -167,8 +163,8 @@ static int hidinput_pb_event(struct hid_device *hid, struct input_dev *input,
                                do_translate = 1;
                        else if (trans->flags & POWERBOOK_FLAG_FKEY)
                                do_translate =
-                                       (usbhid_pb_fnmode == 2 &&  (hid->quirks & HID_QUIRK_POWERBOOK_FN_ON)) ||
-                                       (usbhid_pb_fnmode == 1 && !(hid->quirks & HID_QUIRK_POWERBOOK_FN_ON));
+                                       (hid->pb_fnmode == 2 &&  (hid->quirks & HID_QUIRK_POWERBOOK_FN_ON)) ||
+                                       (hid->pb_fnmode == 1 && !(hid->quirks & HID_QUIRK_POWERBOOK_FN_ON));
                        else
                                do_translate = (hid->quirks & HID_QUIRK_POWERBOOK_FN_ON);
 
@@ -185,7 +181,7 @@ static int hidinput_pb_event(struct hid_device *hid, struct input_dev *input,
                }
 
                if (test_bit(usage->code, hid->pb_pressed_numlock) ||
-                   test_bit(LED_NUML, input->led)) {
+                               test_bit(LED_NUML, input->led)) {
                        trans = find_translation(powerbook_numlock_keys, usage->code);
 
                        if (trans) {
@@ -227,10 +223,11 @@ static void hidinput_pb_setup(struct input_dev *input)
 
        for (trans = powerbook_iso_keyboard; trans->from; trans++)
                set_bit(trans->to, input->keybit);
+
 }
 #else
 static inline int hidinput_pb_event(struct hid_device *hid, struct input_dev *input,
-                                   struct hid_usage *usage, __s32 value)
+               struct hid_usage *usage, __s32 value)
 {
        return 0;
 }
@@ -581,6 +578,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                || ((device->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_7) && (usage->hid == 0x00090007)))
                goto ignore;
 
+       if ((device->quirks & HID_QUIRK_BAD_RELATIVE_KEYS) &&
+               usage->type == EV_KEY && (field->flags & HID_MAIN_ITEM_RELATIVE))
+               field->flags &= ~HID_MAIN_ITEM_RELATIVE;
+
        set_bit(usage->type, input->evbit);
 
        while (usage->code <= max && test_and_set_bit(usage->code, bit))
@@ -720,8 +721,9 @@ void hidinput_report_event(struct hid_device *hid, struct hid_report *report)
        list_for_each_entry(hidinput, &hid->inputs, list)
                input_sync(hidinput->input);
 }
+EXPORT_SYMBOL_GPL(hidinput_report_event);
 
-static int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field)
+int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field)
 {
        struct hid_report *report;
        int i, j;
@@ -736,41 +738,7 @@ static int hidinput_find_field(struct hid_device *hid, unsigned int type, unsign
        }
        return -1;
 }
-
-static int hidinput_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
-{
-       struct hid_device *hid = dev->private;
-       struct hid_field *field;
-       int offset;
-
-       if (type == EV_FF)
-               return input_ff_event(dev, type, code, value);
-
-       if (type != EV_LED)
-               return -1;
-
-       if ((offset = hidinput_find_field(hid, type, code, &field)) == -1) {
-               warn("event field not found");
-               return -1;
-       }
-
-       hid_set_field(field, offset, value);
-       hid_submit_report(hid, field->report, USB_DIR_OUT);
-
-       return 0;
-}
-
-static int hidinput_open(struct input_dev *dev)
-{
-       struct hid_device *hid = dev->private;
-       return hid_open(hid);
-}
-
-static void hidinput_close(struct input_dev *dev)
-{
-       struct hid_device *hid = dev->private;
-       hid_close(hid);
-}
+EXPORT_SYMBOL_GPL(hidinput_find_field);
 
 /*
  * Register the input device; print a message.
@@ -780,7 +748,6 @@ static void hidinput_close(struct input_dev *dev)
 
 int hidinput_connect(struct hid_device *hid)
 {
-       struct usb_device *dev = hid->dev;
        struct hid_report *report;
        struct hid_input *hidinput = NULL;
        struct input_dev *input_dev;
@@ -814,16 +781,18 @@ int hidinput_connect(struct hid_device *hid)
                                }
 
                                input_dev->private = hid;
-                               input_dev->event = hidinput_input_event;
-                               input_dev->open = hidinput_open;
-                               input_dev->close = hidinput_close;
+                               input_dev->event = hid->hidinput_input_event;
+                               input_dev->open = hid->hidinput_open;
+                               input_dev->close = hid->hidinput_close;
 
                                input_dev->name = hid->name;
                                input_dev->phys = hid->phys;
                                input_dev->uniq = hid->uniq;
-                               usb_to_input_id(dev, &input_dev->id);
-                               input_dev->cdev.dev = &hid->intf->dev;
-
+                               input_dev->id.bustype = hid->bus;
+                               input_dev->id.vendor  = hid->vendor;
+                               input_dev->id.product = hid->product;
+                               input_dev->id.version = hid->version;
+                               input_dev->cdev.dev = hid->dev;
                                hidinput->input = input_dev;
                                list_add_tail(&hidinput->list, &hid->inputs);
                        }
@@ -845,16 +814,12 @@ int hidinput_connect(struct hid_device *hid)
                        }
                }
 
-       /* This only gets called when we are a single-input (most of the
-        * time). IOW, not a HID_QUIRK_MULTI_INPUT. The hid_ff_init() is
-        * only useful in this case, and not for multi-input quirks. */
-       if (hidinput) {
-               hid_ff_init(hid);
+       if (hidinput)
                input_register_device(hidinput->input);
-       }
 
        return 0;
 }
+EXPORT_SYMBOL_GPL(hidinput_connect);
 
 void hidinput_disconnect(struct hid_device *hid)
 {
@@ -866,3 +831,5 @@ void hidinput_disconnect(struct hid_device *hid)
                kfree(hidinput);
        }
 }
+EXPORT_SYMBOL_GPL(hidinput_disconnect);
+
index 04bee524e31ae1677d8ecc425f3eb9ebde6024d3..90f91d039ee29eed9c239dfb586465a28182205c 100644 (file)
@@ -196,11 +196,11 @@ config I2C_IBM_IIC
          will be called i2c-ibm_iic.
 
 config I2C_IOP3XX
-       tristate "Intel IOP3xx and IXP4xx on-chip I2C interface"
-       depends on (ARCH_IOP32X || ARCH_IOP33X || ARCH_IXP4XX) && I2C
+       tristate "Intel IOPx3xx and IXP4xx on-chip I2C interface"
+       depends on (ARCH_IOP32X || ARCH_IOP33X || ARCH_IXP4XX || ARCH_IOP13XX) && I2C
        help
          Say Y here if you want to use the IIC bus controller on
-         the Intel IOP3xx I/O Processors or IXP4xx Network Processors.
+         the Intel IOPx3xx I/O Processors or IXP4xx Network Processors.
 
          This driver can also be built as a module.  If so, the module
          will be called i2c-iop3xx.
index c95a6c154165d7bfcf940e94a2e2d5d51e575110..c3b1567c852a711595c1dbd4ac2575afe7d83044 100644 (file)
@@ -357,133 +357,6 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
 
 
 #ifdef CONFIG_I2C_PXA_SLAVE
-/*
- * I2C EEPROM emulation.
- */
-static struct i2c_eeprom_emu eeprom = {
-       .size = I2C_EEPROM_EMU_SIZE,
-       .watch = LIST_HEAD_INIT(eeprom.watch),
-};
-
-struct i2c_eeprom_emu *i2c_pxa_get_eeprom(void)
-{
-       return &eeprom;
-}
-
-int i2c_eeprom_emu_addwatcher(struct i2c_eeprom_emu *emu, void *data,
-                             unsigned int addr, unsigned int size,
-                             struct i2c_eeprom_emu_watcher *watcher)
-{
-       struct i2c_eeprom_emu_watch *watch;
-       unsigned long flags;
-
-       if (addr + size > emu->size)
-               return -EINVAL;
-
-       watch = kmalloc(sizeof(struct i2c_eeprom_emu_watch), GFP_KERNEL);
-       if (watch) {
-               watch->start = addr;
-               watch->end = addr + size - 1;
-               watch->ops = watcher;
-               watch->data = data;
-
-               local_irq_save(flags);
-               list_add(&watch->node, &emu->watch);
-               local_irq_restore(flags);
-       }
-
-       return watch ? 0 : -ENOMEM;
-}
-
-void i2c_eeprom_emu_delwatcher(struct i2c_eeprom_emu *emu, void *data,
-                              struct i2c_eeprom_emu_watcher *watcher)
-{
-       struct i2c_eeprom_emu_watch *watch, *n;
-       unsigned long flags;
-
-       list_for_each_entry_safe(watch, n, &emu->watch, node) {
-               if (watch->ops == watcher && watch->data == data) {
-                       local_irq_save(flags);
-                       list_del(&watch->node);
-                       local_irq_restore(flags);
-                       kfree(watch);
-               }
-       }
-}
-
-static void i2c_eeprom_emu_event(void *ptr, i2c_slave_event_t event)
-{
-       struct i2c_eeprom_emu *emu = ptr;
-
-       eedbg(3, "i2c_eeprom_emu_event: %d\n", event);
-
-       switch (event) {
-       case I2C_SLAVE_EVENT_START_WRITE:
-               emu->seen_start = 1;
-               eedbg(2, "i2c_eeprom: write initiated\n");
-               break;
-
-       case I2C_SLAVE_EVENT_START_READ:
-               emu->seen_start = 0;
-               eedbg(2, "i2c_eeprom: read initiated\n");
-               break;
-
-       case I2C_SLAVE_EVENT_STOP:
-               emu->seen_start = 0;
-               eedbg(2, "i2c_eeprom: received stop\n");
-               break;
-
-       default:
-               eedbg(0, "i2c_eeprom: unhandled event\n");
-               break;
-       }
-}
-
-static int i2c_eeprom_emu_read(void *ptr)
-{
-       struct i2c_eeprom_emu *emu = ptr;
-       int ret;
-
-       ret = emu->bytes[emu->ptr];
-       emu->ptr = (emu->ptr + 1) % emu->size;
-
-       return ret;
-}
-
-static void i2c_eeprom_emu_write(void *ptr, unsigned int val)
-{
-       struct i2c_eeprom_emu *emu = ptr;
-       struct i2c_eeprom_emu_watch *watch;
-
-       if (emu->seen_start != 0) {
-               eedbg(2, "i2c_eeprom_emu_write: setting ptr %02x\n", val);
-               emu->ptr = val;
-               emu->seen_start = 0;
-               return;
-       }
-
-       emu->bytes[emu->ptr] = val;
-
-       eedbg(1, "i2c_eeprom_emu_write: ptr=0x%02x, val=0x%02x\n",
-             emu->ptr, val);
-
-       list_for_each_entry(watch, &emu->watch, node) {
-               if (!watch->ops || !watch->ops->write)
-                       continue;
-               if (watch->start <= emu->ptr && watch->end >= emu->ptr)
-                       watch->ops->write(watch->data, emu->ptr, val);
-       }
-
-       emu->ptr = (emu->ptr + 1) % emu->size;
-}
-
-struct i2c_slave_client eeprom_client = {
-       .data   = &eeprom,
-       .event  = i2c_eeprom_emu_event,
-       .read   = i2c_eeprom_emu_read,
-       .write  = i2c_eeprom_emu_write
-};
-
 /*
  * PXA I2C Slave mode
  */
@@ -963,11 +836,9 @@ static int i2c_pxa_probe(struct platform_device *dev)
        i2c->slave_addr = I2C_PXA_SLAVE_ADDR;
 
 #ifdef CONFIG_I2C_PXA_SLAVE
-       i2c->slave = &eeprom_client;
        if (plat) {
                i2c->slave_addr = plat->slave_addr;
-               if (plat->slave)
-                       i2c->slave = plat->slave;
+               i2c->slave = plat->slave;
        }
 #endif
 
index 94a4e9a3013c0c470ea93d95f4f5020d14f0141a..2e22a2ffa60631fe640f6127e96b23321a9b0899 100644 (file)
@@ -119,7 +119,7 @@ static ssize_t i2cdev_read (struct file *file, char __user *buf, size_t count,
                return -ENOMEM;
 
        pr_debug("i2c-dev: i2c-%d reading %zd bytes.\n",
-               iminor(file->f_dentry->d_inode), count);
+               iminor(file->f_path.dentry->d_inode), count);
 
        ret = i2c_master_recv(client,tmp,count);
        if (ret >= 0)
@@ -147,7 +147,7 @@ static ssize_t i2cdev_write (struct file *file, const char __user *buf, size_t c
        }
 
        pr_debug("i2c-dev: i2c-%d writing %zd bytes.\n",
-               iminor(file->f_dentry->d_inode), count);
+               iminor(file->f_path.dentry->d_inode), count);
 
        ret = i2c_master_send(client,tmp,count);
        kfree(tmp);
index 0c68d0f0d8e513e028784faf5e5ef7c3a524f599..e23bc0d62159c54032bc713f5ab0c996b629c2c8 100644 (file)
@@ -389,14 +389,6 @@ config BLK_DEV_RZ1000
          Linux. This may slow disk throughput by a few percent, but at least
          things will operate 100% reliably.
 
-config BLK_DEV_SL82C105
-       tristate "Winbond SL82c105 support"
-       depends on PCI && (PPC || ARM) && BLK_DEV_IDEPCI
-       help
-         If you have a Winbond SL82c105 IDE controller, say Y here to enable
-         special configuration for this chip. This is common on various CHRP
-         motherboards, but could be used elsewhere. If in doubt, say Y.
-
 config BLK_DEV_IDEDMA_PCI
        bool "Generic PCI bus-master DMA support"
        depends on PCI && BLK_DEV_IDEPCI
@@ -712,6 +704,14 @@ config BLK_DEV_SIS5513
 
          Please read the comments at the top of <file:drivers/ide/pci/sis5513.c>.
 
+config BLK_DEV_SL82C105
+       tristate "Winbond SL82c105 support"
+       depends on (PPC || ARM)
+       help
+         If you have a Winbond SL82c105 IDE controller, say Y here to enable
+         special configuration for this chip. This is common on various CHRP
+         motherboards, but could be used elsewhere. If in doubt, say Y.
+
 config BLK_DEV_SLC90E66
        tristate "SLC90E66 chipset support"
        help
index 287a66201150a0bd32432817a4357705b767329c..16890769dca686dff62ec62bc0c2f741b7ef190c 100644 (file)
@@ -973,8 +973,8 @@ ide_settings_t *ide_find_setting_by_name (ide_drive_t *drive, char *name)
  *     @drive: drive
  *
  *     Automatically remove all the driver specific settings for this
- *     drive. This function may sleep and must not be called from IRQ
- *     context. The caller must hold ide_setting_sem.
+ *     drive. This function may not be called from IRQ context. The
+ *     caller must hold ide_setting_sem.
  */
  
 static void auto_remove_settings (ide_drive_t *drive)
@@ -1874,11 +1874,22 @@ void ide_unregister_subdriver(ide_drive_t *drive, ide_driver_t *driver)
 {
        unsigned long flags;
        
-       down(&ide_setting_sem);
-       spin_lock_irqsave(&ide_lock, flags);
 #ifdef CONFIG_PROC_FS
        ide_remove_proc_entries(drive->proc, driver->proc);
 #endif
+       down(&ide_setting_sem);
+       spin_lock_irqsave(&ide_lock, flags);
+       /*
+        * ide_setting_sem protects the settings list
+        * ide_lock protects the use of settings
+        *
+        * so we need to hold both, ide_settings_sem because we want to
+        * modify the settings list, and ide_lock because we cannot take
+        * a setting out that is being used.
+        *
+        * OTOH both ide_{read,write}_setting are only ever used under
+        * ide_setting_sem.
+        */
        auto_remove_settings(drive);
        spin_unlock_irqrestore(&ide_lock, flags);
        up(&ide_setting_sem);
index d419e4bb54f4454e965aacbc32d1f7a902f62fdb..89109be5162ceb615ce03d92a3c34ec5a278f839 100644 (file)
@@ -586,11 +586,11 @@ static unsigned int __devinit init_chipset_ali15x3 (struct pci_dev *dev, const c
 {
        unsigned long flags;
        u8 tmpbyte;
-       struct pci_dev *north = pci_find_slot(0, PCI_DEVFN(0,0));
+       struct pci_dev *north = pci_get_slot(dev->bus, PCI_DEVFN(0,0));
 
        pci_read_config_byte(dev, PCI_REVISION_ID, &m5229_revision);
 
-       isa_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL);
+       isa_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL);
 
 #if defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_PROC_FS)
        if (!ali_proc) {
@@ -613,8 +613,7 @@ static unsigned int __devinit init_chipset_ali15x3 (struct pci_dev *dev, const c
                 * clear bit 7
                 */
                pci_write_config_byte(dev, 0x4b, tmpbyte & 0x7F);
-               local_irq_restore(flags);
-               return 0;
+               goto out;
        }
 
        /*
@@ -637,10 +636,8 @@ static unsigned int __devinit init_chipset_ali15x3 (struct pci_dev *dev, const c
         * box without a device at 0:0.0. The ALi bridge will be at
         * 0:0.0 so if we didn't find one we know what is cooking.
         */
-       if (north && north->vendor != PCI_VENDOR_ID_AL) {
-               local_irq_restore(flags);
-               return 0;
-       }
+       if (north && north->vendor != PCI_VENDOR_ID_AL)
+               goto out;
 
        if (m5229_revision < 0xC5 && isa_dev)
        {       
@@ -661,6 +658,9 @@ static unsigned int __devinit init_chipset_ali15x3 (struct pci_dev *dev, const c
                        pci_write_config_byte(isa_dev, 0x79, tmpbyte | 0x02);
                }
        }
+out:
+       pci_dev_put(north);
+       pci_dev_put(isa_dev);
        local_irq_restore(flags);
        return 0;
 }
index 6c097e80b4dff9716b4ad0220fa520b101991389..3ca581063f7247f3a7ed59af0f10d196e6b7da5f 100644 (file)
@@ -9,6 +9,7 @@
  *  Split from:
  *  linux/drivers/ide/pdc202xx.c       Version 0.35    Mar. 30, 2002
  *  Copyright (C) 1998-2002            Andre Hedrick <andre@linux-ide.org>
+ *  Copyright (C) 2005-2006            MontaVista Software, Inc.
  *  Portions Copyright (C) 1999 Promise Technology, Inc.
  *  Author: Frank Tiernan (frankt@promise.com)
  *  Released under terms of General Public License
@@ -168,12 +169,8 @@ static int pdcnew_new_tune_chipset (ide_drive_t *drive, u8 xferspeed)
  */
 static void pdcnew_tune_drive(ide_drive_t *drive, u8 pio)
 {
-       u8 speed;
-
-       if (pio == 5) pio = 4;
-       speed = XFER_PIO_0 + ide_get_best_pio_mode(drive, 255, pio, NULL);
-
-       (void)pdcnew_new_tune_chipset(drive, speed);
+       pio = ide_get_best_pio_mode(drive, pio, 4, NULL);
+       (void)pdcnew_new_tune_chipset(drive, XFER_PIO_0 + pio);
 }
 
 static u8 pdcnew_new_cable_detect (ide_hwif_t *hwif)
@@ -207,10 +204,8 @@ static int config_chipset_for_dma (ide_drive_t *drive)
 
        speed = ide_dma_speed(drive, pdcnew_ratemask(drive));
 
-       if (!(speed)) {
-               hwif->tuneproc(drive, 5);
+       if (!speed)
                return 0;
-       }
 
        (void) hwif->speedproc(drive, speed);
        return ide_dma_enable(drive);
@@ -234,7 +229,7 @@ static int pdcnew_config_drive_xfer_rate (ide_drive_t *drive)
 
        } else if ((id->capability & 8) || (id->field_valid & 2)) {
 fast_ata_pio:
-               hwif->tuneproc(drive, 5);
+               hwif->tuneproc(drive, 255);
                return hwif->ide_dma_off_quietly(drive);
        }
        /* IORDY not supported */
@@ -362,6 +357,7 @@ static int __devinit init_setup_pdc20270(struct pci_dev *dev,
                                         ide_pci_device_t *d)
 {
        struct pci_dev *findev = NULL;
+       int ret;
 
        if ((dev->bus->self &&
             dev->bus->self->vendor == PCI_VENDOR_ID_DEC) &&
@@ -369,14 +365,16 @@ static int __devinit init_setup_pdc20270(struct pci_dev *dev,
                if (PCI_SLOT(dev->devfn) & 2)
                        return -ENODEV;
                d->extra = 0;
-               while ((findev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, findev)) != NULL) {
+               while ((findev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, findev)) != NULL) {
                        if ((findev->vendor == dev->vendor) &&
                            (findev->device == dev->device) &&
                            (PCI_SLOT(findev->devfn) & 2)) {
                                if (findev->irq != dev->irq) {
                                        findev->irq = dev->irq;
                                }
-                               return ide_setup_pci_devices(dev, findev, d);
+                               ret = ide_setup_pci_devices(dev, findev, d);
+                               pci_dev_put(findev);
+                               return ret;
                        }
                }
        }
index 92edf76bd7adb1880b677558a56bc7d1528c47b2..6b313139b5e4d2e84c2fce00df84f36267126af3 100644 (file)
@@ -800,9 +800,10 @@ static unsigned int __devinit init_chipset_sis5513 (struct pci_dev *dev, const c
 
                        if (trueid == 0x5517) { /* SiS 961/961B */
 
-                               lpc_bridge = pci_find_slot(0x00, 0x10); /* Bus 0, Dev 2, Fn 0 */
+                               lpc_bridge = pci_get_slot(dev->bus, 0x10); /* Bus 0, Dev 2, Fn 0 */
                                pci_read_config_byte(lpc_bridge, PCI_REVISION_ID, &sbrev);
                                pci_read_config_byte(dev, 0x49, &prefctl);
+                               pci_dev_put(lpc_bridge);
 
                                if (sbrev == 0x10 && (prefctl & 0x80)) {
                                        printk(KERN_INFO "SIS5513: SiS 961B MuTIOL IDE UDMA133 controller\n");
index 0b4b604985153a4915aba1635c3e2ebaad14b638..5afefe8692fe7fe6199e127841adb23ff84ec779 100644 (file)
@@ -299,14 +299,14 @@ static void sl82c105_selectproc(ide_drive_t *drive)
        //DBG(("sl82c105_selectproc(drive:%s)\n", drive->name));
 
        mask = hwif->channel ? CTRL_P1F16 : CTRL_P0F16;
-       old = val = *((u32 *)&hwif->hwif_data);
+       old = val = (u32)pci_get_drvdata(dev);
        if (drive->using_dma)
                val &= ~mask;
        else
                val |= mask;
        if (old != val) {
                pci_write_config_dword(dev, 0x40, val); 
-               *((u32 *)&hwif->hwif_data) = val;
+               pci_set_drvdata(dev, (void *)val);
        }
 }
 
@@ -316,14 +316,13 @@ static void sl82c105_selectproc(ide_drive_t *drive)
  */
 static void sl82c105_resetproc(ide_drive_t *drive)
 {
-       ide_hwif_t *hwif = HWIF(drive);
-       struct pci_dev *dev = hwif->pci_dev;
+       struct pci_dev *dev = HWIF(drive)->pci_dev;
        u32 val;
 
        DBG(("sl82c105_resetproc(drive:%s)\n", drive->name));
 
        pci_read_config_dword(dev, 0x40, &val);
-       *((u32 *)&hwif->hwif_data) = val;
+       pci_set_drvdata(dev, (void *)val);
 }
        
 /*
@@ -394,6 +393,7 @@ static unsigned int __devinit init_chipset_sl82c105(struct pci_dev *dev, const c
        pci_read_config_dword(dev, 0x40, &val);
        val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16;
        pci_write_config_dword(dev, 0x40, val);
+       pci_set_drvdata(dev, (void *)val);
 
        return dev->irq;
 }
@@ -404,30 +404,25 @@ static unsigned int __devinit init_chipset_sl82c105(struct pci_dev *dev, const c
 
 static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
 {
-       struct pci_dev *dev = hwif->pci_dev;
        unsigned int rev;
        u8 dma_state;
-       u32 val;
-       
+
        DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index));
 
        hwif->tuneproc = tune_sl82c105;
        hwif->selectproc = sl82c105_selectproc;
        hwif->resetproc = sl82c105_resetproc;
-       
-       /* Default to PIO 0 for fallback unless tuned otherwise,
-        * we always autotune PIO, this is done before DMA is
-        * checked, so there is no risk of accidentally disabling
-        * DMA
-         */
+
+       /*
+        * Default to PIO 0 for fallback unless tuned otherwise.
+        * We always autotune PIO,  this is done before DMA is checked,
+        * so there's no risk of accidentally disabling DMA
+        */
        hwif->drives[0].pio_speed = XFER_PIO_0;
        hwif->drives[0].autotune = 1;
-       hwif->drives[1].pio_speed = XFER_PIO_1;
+       hwif->drives[1].pio_speed = XFER_PIO_0;
        hwif->drives[1].autotune = 1;
 
-       pci_read_config_dword(dev, 0x40, &val);
-       *((u32 *)&hwif->hwif_data) = val;
-       
        hwif->atapi_dma = 0;
        hwif->mwdma_mask = 0;
        hwif->swdma_mask = 0;
index eb7ab112c05010fec0f9048ef2b8c1a837d62eb4..61f1a9665a7f911729ae17faad0492a5b89309fe 100644 (file)
@@ -282,11 +282,11 @@ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const
         * Find the ISA bridge to see how good the IDE is.
         */
        via_config = via_config_find(&isa);
-       if (!via_config->id) {
-               printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n");
-               pci_dev_put(isa);
-               return -ENODEV;
-       }
+
+       /* We checked this earlier so if it fails here deeep badness
+          is involved */
+
+       BUG_ON(!via_config->id);
 
        /*
         * Setup or disable Clk66 if appropriate
@@ -494,6 +494,17 @@ static ide_pci_device_t via82cxxx_chipsets[] __devinitdata = {
 
 static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
+       struct pci_dev *isa = NULL;
+       struct via_isa_bridge *via_config;
+       /*
+        * Find the ISA bridge and check we know what it is.
+        */
+       via_config = via_config_find(&isa);
+       pci_dev_put(isa);
+       if (!via_config->id) {
+               printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n");
+               return -ENODEV;
+       }
        return ide_setup_pci_device(dev, &via82cxxx_chipsets[id->driver_data]);
 }
 
index 672b92ef9f21cdd6e3cd939125d43734bcb4f0d4..e7d56573fe5627fcd4c35b13d1d4f973b6248d09 100644 (file)
@@ -36,7 +36,7 @@ config IEEE1394_VERBOSEDEBUG
          else says N.
 
 config IEEE1394_OUI_DB
-       bool "OUI Database built-in"
+       bool "OUI Database built-in (deprecated)"
        depends on IEEE1394
        help
          If you say Y here, then an OUI list (vendor unique ID's) will be
@@ -67,16 +67,11 @@ config IEEE1394_CONFIG_ROM_IP1394
          eth1394 option below.
 
 config IEEE1394_EXPORT_FULL_API
-       bool "Export all symbols of ieee1394's API"
+       bool "Export all symbols of ieee1394's API (deprecated)"
        depends on IEEE1394
        default n
        help
-         Export all symbols of ieee1394's driver programming interface, even
-         those that are not currently used by the standard IEEE 1394 drivers.
-
-         This option does not affect the interface to userspace applications.
-         Say Y here if you want to compile externally developed drivers that
-         make extended use of ieee1394's API. It is otherwise safe to say N.
+         This option will be removed soon.  Don't worry, say N.
 
 comment "Device Drivers"
        depends on IEEE1394
@@ -125,7 +120,7 @@ comment "SBP-2 support (for storage devices) requires SCSI"
 
 config IEEE1394_SBP2
        tristate "SBP-2 support (Harddisks etc.)"
-       depends on IEEE1394 && SCSI && (PCI || BROKEN)
+       depends on IEEE1394 && SCSI
        help
          This option enables you to use SBP-2 devices connected to an IEEE
          1394 bus.  SBP-2 devices include storage devices like harddisks and
@@ -161,17 +156,12 @@ config IEEE1394_ETH1394
          MCAP, therefore multicast support is significantly limited.
 
 config IEEE1394_DV1394
-       tristate "OHCI-DV I/O support"
+       tristate "OHCI-DV I/O support (deprecated)"
        depends on IEEE1394 && IEEE1394_OHCI1394
        help
-         This driver allows you to transmit and receive DV (digital video)
-         streams on an OHCI-1394 card using a simple frame-oriented
-         interface.
-
-         The user-space API for dv1394 is documented in dv1394.h.
-
-         To compile this driver as a module, say M here: the
-         module will be called dv1394.
+         The dv1394 driver will be removed from Linux in a future release.
+         Its functionality is now provided by raw1394 together with libraries
+         such as libiec61883.
 
 config IEEE1394_RAWIO
        tristate "Raw IEEE1394 I/O support"
index 6f53611fe255dab1e8fd9da548eb990e067ba427..d9650d3d77a004b383637217db95d21e8f46a164 100644 (file)
@@ -3,8 +3,11 @@
 #
 
 ieee1394-objs := ieee1394_core.o ieee1394_transactions.o hosts.o \
-                highlevel.o csr.o nodemgr.o oui.o dma.o iso.o \
+                highlevel.o csr.o nodemgr.o dma.o iso.o \
                 csr1212.o config_roms.o
+ifdef CONFIG_IEEE1394_OUI_DB
+ieee1394-objs += oui.o
+endif
 
 obj-$(CONFIG_IEEE1394) += ieee1394.o
 obj-$(CONFIG_IEEE1394_PCILYNX) += pcilynx.o
index ab0c80f61b9d184152d6ed2005cfae5f360e7835..52ac83e0ebee9bb510fd3b2a0051bffe2b1d0a25 100644 (file)
@@ -158,12 +158,10 @@ static void host_reset(struct hpsb_host *host)
  */
 static inline void calculate_expire(struct csr_control *csr)
 {
-       unsigned long usecs =
-               (csr->split_timeout_hi & 0x07) * USEC_PER_SEC +
-               (csr->split_timeout_lo >> 19) * 125L;
-
-       csr->expire = usecs_to_jiffies(usecs > 100000L ? usecs : 100000L);
+       unsigned int usecs = (csr->split_timeout_hi & 7) * 1000000 +
+                            (csr->split_timeout_lo >> 19) * 125;
 
+       csr->expire = usecs_to_jiffies(usecs > 100000 ? usecs : 100000);
        HPSB_VERBOSE("CSR: setting expire to %lu, HZ=%u", csr->expire, HZ);
 }
 
index 6c72f04b2b5db0399f5be66ecbe5653101819892..1084da4d88a9d68799954ecac8e0a70eedf9b9d2 100644 (file)
@@ -1536,27 +1536,20 @@ static ssize_t dv1394_read(struct file *file,  char __user *buffer, size_t count
 
 static long dv1394_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-       struct video_card *video;
+       struct video_card *video = file_to_video_card(file);
        unsigned long flags;
        int ret = -EINVAL;
        void __user *argp = (void __user *)arg;
 
        DECLARE_WAITQUEUE(wait, current);
 
-       lock_kernel();
-       video = file_to_video_card(file);
-
        /* serialize this to prevent multi-threaded mayhem */
        if (file->f_flags & O_NONBLOCK) {
-               if (!mutex_trylock(&video->mtx)) {
-                       unlock_kernel();
+               if (!mutex_trylock(&video->mtx))
                        return -EAGAIN;
-               }
        } else {
-               if (mutex_lock_interruptible(&video->mtx)) {
-                       unlock_kernel();
+               if (mutex_lock_interruptible(&video->mtx))
                        return -ERESTARTSYS;
-               }
        }
 
        switch(cmd)
@@ -1780,7 +1773,6 @@ static long dv1394_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
  out:
        mutex_unlock(&video->mtx);
-       unlock_kernel();
        return ret;
 }
 
@@ -2188,12 +2180,8 @@ static struct ieee1394_device_id dv1394_id_table[] = {
 MODULE_DEVICE_TABLE(ieee1394, dv1394_id_table);
 
 static struct hpsb_protocol_driver dv1394_driver = {
-       .name           = "DV/1394 Driver",
+       .name           = "dv1394",
        .id_table       = dv1394_id_table,
-       .driver         = {
-               .name   = "dv1394",
-               .bus    = &ieee1394_bus_type,
-       },
 };
 
 
@@ -2587,6 +2575,10 @@ static int __init dv1394_init_module(void)
 {
        int ret;
 
+       printk(KERN_WARNING
+              "WARNING: The dv1394 driver is unsupported and will be removed "
+              "from Linux soon. Use raw1394 instead.\n");
+
        cdev_init(&dv1394_cdev, &dv1394_fops);
        dv1394_cdev.owner = THIS_MODULE;
        kobject_set_name(&dv1394_cdev.kobj, "dv1394");
index 31e5cc49d61a01899cea3e6d5220809f2b889be7..97e5c3dd044d05aacae220ab5b67d02c5fe2bce6 100644 (file)
@@ -133,7 +133,7 @@ struct eth1394_node_info {
 #define ETH1394_DRIVER_NAME "eth1394"
 static const char driver_name[] = ETH1394_DRIVER_NAME;
 
-static kmem_cache_t *packet_task_cache;
+static struct kmem_cache *packet_task_cache;
 
 static struct hpsb_highlevel eth1394_highlevel;
 
@@ -474,12 +474,10 @@ static struct ieee1394_device_id eth1394_id_table[] = {
 MODULE_DEVICE_TABLE(ieee1394, eth1394_id_table);
 
 static struct hpsb_protocol_driver eth1394_proto_driver = {
-       .name           = "IPv4 over 1394 Driver",
+       .name           = ETH1394_DRIVER_NAME,
        .id_table       = eth1394_id_table,
        .update         = eth1394_update,
        .driver         = {
-               .name           = ETH1394_DRIVER_NAME,
-               .bus            = &ieee1394_bus_type,
                .probe          = eth1394_probe,
                .remove         = eth1394_remove,
        },
index 50f2dd2c7e20afecc2dde1b95c78eeac070730da..4b330117067ac7f3d54fec4665a324968e7b148f 100644 (file)
@@ -24,7 +24,6 @@ struct hpsb_address_serve {
 /* Only the following structures are of interest to actual highlevel drivers. */
 
 struct hpsb_highlevel {
-       struct module *owner;
        const char *name;
 
        /* Any of the following pointers can legally be NULL, except for
index 8f4378a1631ce2035fa2634cd33d0d046582f098..ee82a5320bf7b5c353db56485c2b1ab31f673b33 100644 (file)
@@ -44,9 +44,10 @@ static void delayed_reset_bus(struct work_struct *work)
 
        CSR_SET_BUS_INFO_GENERATION(host->csr.rom, generation);
        if (csr1212_generate_csr_image(host->csr.rom) != CSR1212_SUCCESS) {
-               /* CSR image creation failed, reset generation field and do not
-                * issue a bus reset. */
-               CSR_SET_BUS_INFO_GENERATION(host->csr.rom, host->csr.generation);
+               /* CSR image creation failed.
+                * Reset generation field and do not issue a bus reset. */
+               CSR_SET_BUS_INFO_GENERATION(host->csr.rom,
+                                           host->csr.generation);
                return;
        }
 
@@ -54,7 +55,8 @@ static void delayed_reset_bus(struct work_struct *work)
 
        host->update_config_rom = 0;
        if (host->driver->set_hw_config_rom)
-               host->driver->set_hw_config_rom(host, host->csr.rom->bus_info_data);
+               host->driver->set_hw_config_rom(host,
+                                               host->csr.rom->bus_info_data);
 
        host->csr.gen_timestamp[host->csr.generation] = jiffies;
        hpsb_reset_bus(host, SHORT_RESET);
@@ -70,7 +72,8 @@ static int dummy_devctl(struct hpsb_host *h, enum devctl_cmd c, int arg)
        return -1;
 }
 
-static int dummy_isoctl(struct hpsb_iso *iso, enum isoctl_cmd command, unsigned long arg)
+static int dummy_isoctl(struct hpsb_iso *iso, enum isoctl_cmd command,
+                       unsigned long arg)
 {
        return -1;
 }
@@ -123,15 +126,13 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
        int i;
        int hostnum = 0;
 
-       h = kzalloc(sizeof(*h) + extra, SLAB_KERNEL);
+       h = kzalloc(sizeof(*h) + extra, GFP_KERNEL);
        if (!h)
                return NULL;
 
        h->csr.rom = csr1212_create_csr(&csr_bus_ops, CSR_BUS_INFO_SIZE, h);
-       if (!h->csr.rom) {
-               kfree(h);
-               return NULL;
-       }
+       if (!h->csr.rom)
+               goto fail;
 
        h->hostdata = h + 1;
        h->driver = drv;
@@ -151,16 +152,15 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
        init_timer(&h->timeout);
        h->timeout.data = (unsigned long) h;
        h->timeout.function = abort_timedouts;
-       h->timeout_interval = HZ / 20; // 50ms by default
+       h->timeout_interval = HZ / 20; /* 50ms, half of minimum SPLIT_TIMEOUT */
 
        h->topology_map = h->csr.topology_map + 3;
        h->speed_map = (u8 *)(h->csr.speed_map + 2);
 
        mutex_lock(&host_num_alloc);
-
        while (nodemgr_for_each_host(&hostnum, alloc_hostnum_cb))
                hostnum++;
-
+       mutex_unlock(&host_num_alloc);
        h->id = hostnum;
 
        memcpy(&h->device, &nodemgr_dev_template_host, sizeof(h->device));
@@ -171,13 +171,19 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
        h->class_dev.class = &hpsb_host_class;
        snprintf(h->class_dev.class_id, BUS_ID_SIZE, "fw-host%d", h->id);
 
-       device_register(&h->device);
-       class_device_register(&h->class_dev);
+       if (device_register(&h->device))
+               goto fail;
+       if (class_device_register(&h->class_dev)) {
+               device_unregister(&h->device);
+               goto fail;
+       }
        get_device(&h->device);
 
-       mutex_unlock(&host_num_alloc);
-
        return h;
+
+fail:
+       kfree(h);
+       return NULL;
 }
 
 int hpsb_add_host(struct hpsb_host *host)
@@ -229,7 +235,8 @@ int hpsb_update_config_rom_image(struct hpsb_host *host)
        if (time_before(jiffies, host->csr.gen_timestamp[next_gen] + 60 * HZ))
                /* Wait 60 seconds from the last time this generation number was
                 * used. */
-               reset_delay = (60 * HZ) + host->csr.gen_timestamp[next_gen] - jiffies;
+               reset_delay =
+                       (60 * HZ) + host->csr.gen_timestamp[next_gen] - jiffies;
        else
                /* Wait 1 second in case some other code wants to change the
                 * Config ROM in the near future. */
index 5fccf9f7a1d2e2a72eabffa78404156824156950..9a48ca20d1fd0dfdc788a6c78f465340f378b601 100644 (file)
@@ -1237,10 +1237,10 @@ EXPORT_SYMBOL(highlevel_remove_host);
 /** nodemgr.c **/
 EXPORT_SYMBOL(hpsb_node_fill_packet);
 EXPORT_SYMBOL(hpsb_node_write);
-EXPORT_SYMBOL(hpsb_register_protocol);
+EXPORT_SYMBOL(__hpsb_register_protocol);
 EXPORT_SYMBOL(hpsb_unregister_protocol);
-EXPORT_SYMBOL(ieee1394_bus_type);
 #ifdef CONFIG_IEEE1394_EXPORT_FULL_API
+EXPORT_SYMBOL(ieee1394_bus_type);
 EXPORT_SYMBOL(nodemgr_for_each_host);
 #endif
 
index af4a78a8ef3b124f61e9a9b667cc8b9f5383ee7f..536ba3f580fd49995fc812353167d8cc65307570 100644 (file)
@@ -217,7 +217,7 @@ void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size,
 /* return the index (within a minor number block) of a file */
 static inline unsigned char ieee1394_file_to_instance(struct file *file)
 {
-       return file->f_dentry->d_inode->i_cindex;
+       return file->f_path.dentry->d_inode->i_cindex;
 }
 
 extern int hpsb_disable_irm;
index 8e7b83f84485a1933b209d4017a74a288d19b64a..61307ca296ae4745c26c2242d24aae238c2361a5 100644 (file)
@@ -14,7 +14,9 @@
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/kthread.h>
+#include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/freezer.h>
 #include <asm/atomic.h>
 
 #include "csr.h"
@@ -66,7 +68,7 @@ static int nodemgr_check_speed(struct nodemgr_csr_info *ci, u64 addr,
 {
        quadlet_t q;
        u8 i, *speed, old_speed, good_speed;
-       int ret;
+       int error;
 
        speed = &(ci->host->speed[NODEID_TO_NODE(ci->nodeid)]);
        old_speed = *speed;
@@ -78,9 +80,9 @@ static int nodemgr_check_speed(struct nodemgr_csr_info *ci, u64 addr,
         * just finished its initialization. */
        for (i = IEEE1394_SPEED_100; i <= old_speed; i++) {
                *speed = i;
-               ret = hpsb_read(ci->host, ci->nodeid, ci->generation, addr,
-                               &q, sizeof(quadlet_t));
-               if (ret)
+               error = hpsb_read(ci->host, ci->nodeid, ci->generation, addr,
+                                 &q, sizeof(quadlet_t));
+               if (error)
                        break;
                *buffer = q;
                good_speed = i;
@@ -94,19 +96,19 @@ static int nodemgr_check_speed(struct nodemgr_csr_info *ci, u64 addr,
                return 0;
        }
        *speed = old_speed;
-       return ret;
+       return error;
 }
 
 static int nodemgr_bus_read(struct csr1212_csr *csr, u64 addr, u16 length,
-                            void *buffer, void *__ci)
+                           void *buffer, void *__ci)
 {
        struct nodemgr_csr_info *ci = (struct nodemgr_csr_info*)__ci;
-       int i, ret;
+       int i, error;
 
        for (i = 1; ; i++) {
-               ret = hpsb_read(ci->host, ci->nodeid, ci->generation, addr,
-                               buffer, length);
-               if (!ret) {
+               error = hpsb_read(ci->host, ci->nodeid, ci->generation, addr,
+                                 buffer, length);
+               if (!error) {
                        ci->speed_unverified = 0;
                        break;
                }
@@ -117,14 +119,14 @@ static int nodemgr_bus_read(struct csr1212_csr *csr, u64 addr, u16 length,
                /* The ieee1394_core guessed the node's speed capability from
                 * the self ID.  Check whether a lower speed works. */
                if (ci->speed_unverified && length == sizeof(quadlet_t)) {
-                       ret = nodemgr_check_speed(ci, addr, buffer);
-                       if (!ret)
+                       error = nodemgr_check_speed(ci, addr, buffer);
+                       if (!error)
                                break;
                }
                if (msleep_interruptible(334))
                        return -EINTR;
        }
-       return ret;
+       return error;
 }
 
 static int nodemgr_get_max_rom(quadlet_t *bus_info_data, void *__ci)
@@ -259,9 +261,20 @@ static struct device nodemgr_dev_template_ne = {
        .release        = nodemgr_release_ne,
 };
 
+/* This dummy driver prevents the host devices from being scanned. We have no
+ * useful drivers for them yet, and there would be a deadlock possible if the
+ * driver core scans the host device while the host's low-level driver (i.e.
+ * the host's parent device) is being removed. */
+static struct device_driver nodemgr_mid_layer_driver = {
+       .bus            = &ieee1394_bus_type,
+       .name           = "nodemgr",
+       .owner          = THIS_MODULE,
+};
+
 struct device nodemgr_dev_template_host = {
        .bus            = &ieee1394_bus_type,
        .release        = nodemgr_release_host,
+       .driver         = &nodemgr_mid_layer_driver,
 };
 
 
@@ -306,8 +319,8 @@ static ssize_t fw_drv_show_##field (struct device_driver *drv, char *buf) \
        return sprintf(buf, format_string, (type)driver->field);\
 }                                                              \
 static struct driver_attribute driver_attr_drv_##field = {     \
-        .attr = {.name = __stringify(field), .mode = S_IRUGO },        \
-        .show   = fw_drv_show_##field,                         \
+       .attr = {.name = __stringify(field), .mode = S_IRUGO }, \
+       .show   = fw_drv_show_##field,                          \
 };
 
 
@@ -361,7 +374,7 @@ static ssize_t fw_show_ne_tlabels_mask(struct device *dev,
 #endif
        spin_unlock_irqrestore(&hpsb_tlabel_lock, flags);
 
-       return sprintf(buf, "0x%016llx\n", tm);
+       return sprintf(buf, "0x%016llx\n", (unsigned long long)tm);
 }
 static DEVICE_ATTR(tlabels_mask, S_IRUGO, fw_show_ne_tlabels_mask, NULL);
 #endif /* HPSB_DEBUG_TLABELS */
@@ -373,11 +386,11 @@ static ssize_t fw_set_ignore_driver(struct device *dev, struct device_attribute
        int state = simple_strtoul(buf, NULL, 10);
 
        if (state == 1) {
-               down_write(&dev->bus->subsys.rwsem);
-               device_release_driver(dev);
                ud->ignore_driver = 1;
-               up_write(&dev->bus->subsys.rwsem);
-       } else if (!state)
+               down_write(&ieee1394_bus_type.subsys.rwsem);
+               device_release_driver(dev);
+               up_write(&ieee1394_bus_type.subsys.rwsem);
+       } else if (state == 0)
                ud->ignore_driver = 0;
 
        return count;
@@ -412,11 +425,14 @@ static ssize_t fw_get_destroy_node(struct bus_type *bus, char *buf)
 static BUS_ATTR(destroy_node, S_IWUSR | S_IRUGO, fw_get_destroy_node, fw_set_destroy_node);
 
 
-static ssize_t fw_set_rescan(struct bus_type *bus, const char *buf, size_t count)
+static ssize_t fw_set_rescan(struct bus_type *bus, const char *buf,
+                            size_t count)
 {
+       int error = 0;
+
        if (simple_strtoul(buf, NULL, 10) == 1)
-               bus_rescan_devices(&ieee1394_bus_type);
-       return count;
+               error = bus_rescan_devices(&ieee1394_bus_type);
+       return error ? error : count;
 }
 static ssize_t fw_get_rescan(struct bus_type *bus, char *buf)
 {
@@ -432,7 +448,7 @@ static ssize_t fw_set_ignore_drivers(struct bus_type *bus, const char *buf, size
 
        if (state == 1)
                ignore_drivers = 1;
-       else if (!state)
+       else if (state == 0)
                ignore_drivers = 0;
 
        return count;
@@ -525,7 +541,7 @@ static ssize_t fw_show_drv_device_ids(struct device_driver *drv, char *buf)
        int length = 0;
        char *scratch = buf;
 
-        driver = container_of(drv, struct hpsb_protocol_driver, driver);
+       driver = container_of(drv, struct hpsb_protocol_driver, driver);
 
        for (id = driver->id_table; id->match_flags != 0; id++) {
                int need_coma = 0;
@@ -582,7 +598,11 @@ static void nodemgr_create_drv_files(struct hpsb_protocol_driver *driver)
        int i;
 
        for (i = 0; i < ARRAY_SIZE(fw_drv_attrs); i++)
-               driver_create_file(drv, fw_drv_attrs[i]);
+               if (driver_create_file(drv, fw_drv_attrs[i]))
+                       goto fail;
+       return;
+fail:
+       HPSB_ERR("Failed to add sysfs attribute for driver %s", driver->name);
 }
 
 
@@ -602,7 +622,12 @@ static void nodemgr_create_ne_dev_files(struct node_entry *ne)
        int i;
 
        for (i = 0; i < ARRAY_SIZE(fw_ne_attrs); i++)
-               device_create_file(dev, fw_ne_attrs[i]);
+               if (device_create_file(dev, fw_ne_attrs[i]))
+                       goto fail;
+       return;
+fail:
+       HPSB_ERR("Failed to add sysfs attribute for node %016Lx",
+                (unsigned long long)ne->guid);
 }
 
 
@@ -612,11 +637,16 @@ static void nodemgr_create_host_dev_files(struct hpsb_host *host)
        int i;
 
        for (i = 0; i < ARRAY_SIZE(fw_host_attrs); i++)
-               device_create_file(dev, fw_host_attrs[i]);
+               if (device_create_file(dev, fw_host_attrs[i]))
+                       goto fail;
+       return;
+fail:
+       HPSB_ERR("Failed to add sysfs attribute for host %d", host->id);
 }
 
 
-static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host, nodeid_t nodeid);
+static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host,
+                                              nodeid_t nodeid);
 
 static void nodemgr_update_host_dev_links(struct hpsb_host *host)
 {
@@ -627,12 +657,18 @@ static void nodemgr_update_host_dev_links(struct hpsb_host *host)
        sysfs_remove_link(&dev->kobj, "busmgr_id");
        sysfs_remove_link(&dev->kobj, "host_id");
 
-       if ((ne = find_entry_by_nodeid(host, host->irm_id)))
-               sysfs_create_link(&dev->kobj, &ne->device.kobj, "irm_id");
-       if ((ne = find_entry_by_nodeid(host, host->busmgr_id)))
-               sysfs_create_link(&dev->kobj, &ne->device.kobj, "busmgr_id");
-       if ((ne = find_entry_by_nodeid(host, host->node_id)))
-               sysfs_create_link(&dev->kobj, &ne->device.kobj, "host_id");
+       if ((ne = find_entry_by_nodeid(host, host->irm_id)) &&
+           sysfs_create_link(&dev->kobj, &ne->device.kobj, "irm_id"))
+               goto fail;
+       if ((ne = find_entry_by_nodeid(host, host->busmgr_id)) &&
+           sysfs_create_link(&dev->kobj, &ne->device.kobj, "busmgr_id"))
+               goto fail;
+       if ((ne = find_entry_by_nodeid(host, host->node_id)) &&
+           sysfs_create_link(&dev->kobj, &ne->device.kobj, "host_id"))
+               goto fail;
+       return;
+fail:
+       HPSB_ERR("Failed to update sysfs attributes for host %d", host->id);
 }
 
 static void nodemgr_create_ud_dev_files(struct unit_directory *ud)
@@ -641,32 +677,39 @@ static void nodemgr_create_ud_dev_files(struct unit_directory *ud)
        int i;
 
        for (i = 0; i < ARRAY_SIZE(fw_ud_attrs); i++)
-               device_create_file(dev, fw_ud_attrs[i]);
-
+               if (device_create_file(dev, fw_ud_attrs[i]))
+                       goto fail;
        if (ud->flags & UNIT_DIRECTORY_SPECIFIER_ID)
-               device_create_file(dev, &dev_attr_ud_specifier_id);
-
+               if (device_create_file(dev, &dev_attr_ud_specifier_id))
+                       goto fail;
        if (ud->flags & UNIT_DIRECTORY_VERSION)
-               device_create_file(dev, &dev_attr_ud_version);
-
+               if (device_create_file(dev, &dev_attr_ud_version))
+                       goto fail;
        if (ud->flags & UNIT_DIRECTORY_VENDOR_ID) {
-               device_create_file(dev, &dev_attr_ud_vendor_id);
-               if (ud->vendor_name_kv)
-                       device_create_file(dev, &dev_attr_ud_vendor_name_kv);
+               if (device_create_file(dev, &dev_attr_ud_vendor_id))
+                       goto fail;
+               if (ud->vendor_name_kv &&
+                   device_create_file(dev, &dev_attr_ud_vendor_name_kv))
+                       goto fail;
        }
-
        if (ud->flags & UNIT_DIRECTORY_MODEL_ID) {
-               device_create_file(dev, &dev_attr_ud_model_id);
-               if (ud->model_name_kv)
-                       device_create_file(dev, &dev_attr_ud_model_name_kv);
+               if (device_create_file(dev, &dev_attr_ud_model_id))
+                       goto fail;
+               if (ud->model_name_kv &&
+                   device_create_file(dev, &dev_attr_ud_model_name_kv))
+                       goto fail;
        }
+       return;
+fail:
+       HPSB_ERR("Failed to add sysfs attributes for unit %s",
+                ud->device.bus_id);
 }
 
 
 static int nodemgr_bus_match(struct device * dev, struct device_driver * drv)
 {
-        struct hpsb_protocol_driver *driver;
-        struct unit_directory *ud;
+       struct hpsb_protocol_driver *driver;
+       struct unit_directory *ud;
        struct ieee1394_device_id *id;
 
        /* We only match unit directories */
@@ -674,55 +717,77 @@ static int nodemgr_bus_match(struct device * dev, struct device_driver * drv)
                return 0;
 
        ud = container_of(dev, struct unit_directory, device);
-       driver = container_of(drv, struct hpsb_protocol_driver, driver);
-
        if (ud->ne->in_limbo || ud->ignore_driver)
                return 0;
 
-        for (id = driver->id_table; id->match_flags != 0; id++) {
-                if ((id->match_flags & IEEE1394_MATCH_VENDOR_ID) &&
-                    id->vendor_id != ud->vendor_id)
-                        continue;
+       /* We only match drivers of type hpsb_protocol_driver */
+       if (drv == &nodemgr_mid_layer_driver)
+               return 0;
 
-                if ((id->match_flags & IEEE1394_MATCH_MODEL_ID) &&
-                    id->model_id != ud->model_id)
-                        continue;
+       driver = container_of(drv, struct hpsb_protocol_driver, driver);
+       for (id = driver->id_table; id->match_flags != 0; id++) {
+               if ((id->match_flags & IEEE1394_MATCH_VENDOR_ID) &&
+                   id->vendor_id != ud->vendor_id)
+                       continue;
 
-                if ((id->match_flags & IEEE1394_MATCH_SPECIFIER_ID) &&
-                    id->specifier_id != ud->specifier_id)
-                        continue;
+               if ((id->match_flags & IEEE1394_MATCH_MODEL_ID) &&
+                   id->model_id != ud->model_id)
+                       continue;
 
-                if ((id->match_flags & IEEE1394_MATCH_VERSION) &&
-                    id->version != ud->version)
-                        continue;
+               if ((id->match_flags & IEEE1394_MATCH_SPECIFIER_ID) &&
+                   id->specifier_id != ud->specifier_id)
+                       continue;
+
+               if ((id->match_flags & IEEE1394_MATCH_VERSION) &&
+                   id->version != ud->version)
+                       continue;
 
                return 1;
-        }
+       }
 
        return 0;
 }
 
 
+static DEFINE_MUTEX(nodemgr_serialize_remove_uds);
+
 static void nodemgr_remove_uds(struct node_entry *ne)
 {
-       struct class_device *cdev, *next;
-       struct unit_directory *ud;
-
-       list_for_each_entry_safe(cdev, next, &nodemgr_ud_class.children, node) {
-               ud = container_of(cdev, struct unit_directory, class_dev);
-
-               if (ud->ne != ne)
-                       continue;
-
+       struct class_device *cdev;
+       struct unit_directory *tmp, *ud;
+
+       /* Iteration over nodemgr_ud_class.children has to be protected by
+        * nodemgr_ud_class.sem, but class_device_unregister() will eventually
+        * take nodemgr_ud_class.sem too. Therefore pick out one ud at a time,
+        * release the semaphore, and then unregister the ud. Since this code
+        * may be called from other contexts besides the knodemgrds, protect the
+        * gap after release of the semaphore by nodemgr_serialize_remove_uds.
+        */
+       mutex_lock(&nodemgr_serialize_remove_uds);
+       for (;;) {
+               ud = NULL;
+               down(&nodemgr_ud_class.sem);
+               list_for_each_entry(cdev, &nodemgr_ud_class.children, node) {
+                       tmp = container_of(cdev, struct unit_directory,
+                                          class_dev);
+                       if (tmp->ne == ne) {
+                               ud = tmp;
+                               break;
+                       }
+               }
+               up(&nodemgr_ud_class.sem);
+               if (ud == NULL)
+                       break;
                class_device_unregister(&ud->class_dev);
                device_unregister(&ud->device);
        }
+       mutex_unlock(&nodemgr_serialize_remove_uds);
 }
 
 
 static void nodemgr_remove_ne(struct node_entry *ne)
 {
-       struct device *dev = &ne->device;
+       struct device *dev;
 
        dev = get_device(&ne->device);
        if (!dev)
@@ -747,7 +812,7 @@ static int __nodemgr_remove_host_dev(struct device *dev, void *data)
 
 static void nodemgr_remove_host_dev(struct device *dev)
 {
-       device_for_each_child(dev, NULL, __nodemgr_remove_host_dev);
+       WARN_ON(device_for_each_child(dev, NULL, __nodemgr_remove_host_dev));
        sysfs_remove_link(&dev->kobj, "irm_id");
        sysfs_remove_link(&dev->kobj, "busmgr_id");
        sysfs_remove_link(&dev->kobj, "host_id");
@@ -761,16 +826,16 @@ static void nodemgr_update_bus_options(struct node_entry *ne)
 #endif
        quadlet_t busoptions = be32_to_cpu(ne->csr->bus_info_data[2]);
 
-       ne->busopt.irmc         = (busoptions >> 31) & 1;
-       ne->busopt.cmc          = (busoptions >> 30) & 1;
-       ne->busopt.isc          = (busoptions >> 29) & 1;
-       ne->busopt.bmc          = (busoptions >> 28) & 1;
-       ne->busopt.pmc          = (busoptions >> 27) & 1;
-       ne->busopt.cyc_clk_acc  = (busoptions >> 16) & 0xff;
-       ne->busopt.max_rec      = 1 << (((busoptions >> 12) & 0xf) + 1);
+       ne->busopt.irmc         = (busoptions >> 31) & 1;
+       ne->busopt.cmc          = (busoptions >> 30) & 1;
+       ne->busopt.isc          = (busoptions >> 29) & 1;
+       ne->busopt.bmc          = (busoptions >> 28) & 1;
+       ne->busopt.pmc          = (busoptions >> 27) & 1;
+       ne->busopt.cyc_clk_acc  = (busoptions >> 16) & 0xff;
+       ne->busopt.max_rec      = 1 << (((busoptions >> 12) & 0xf) + 1);
        ne->busopt.max_rom      = (busoptions >> 8) & 0x3;
-       ne->busopt.generation   = (busoptions >> 4) & 0xf;
-       ne->busopt.lnkspd       = busoptions & 0x7;
+       ne->busopt.generation   = (busoptions >> 4) & 0xf;
+       ne->busopt.lnkspd       = busoptions & 0x7;
 
        HPSB_VERBOSE("NodeMgr: raw=0x%08x irmc=%d cmc=%d isc=%d bmc=%d pmc=%d "
                     "cyc_clk_acc=%d max_rec=%d max_rom=%d gen=%d lspd=%d",
@@ -791,7 +856,7 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr
 
        ne = kzalloc(sizeof(*ne), GFP_KERNEL);
        if (!ne)
-               return NULL;
+               goto fail_alloc;
 
        ne->host = host;
        ne->nodeid = nodeid;
@@ -814,12 +879,15 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr
        snprintf(ne->class_dev.class_id, BUS_ID_SIZE, "%016Lx",
                 (unsigned long long)(ne->guid));
 
-       device_register(&ne->device);
-       class_device_register(&ne->class_dev);
+       if (device_register(&ne->device))
+               goto fail_devreg;
+       if (class_device_register(&ne->class_dev))
+               goto fail_classdevreg;
        get_device(&ne->device);
 
-       if (ne->guid_vendor_oui)
-               device_create_file(&ne->device, &dev_attr_ne_guid_vendor_oui);
+       if (ne->guid_vendor_oui &&
+           device_create_file(&ne->device, &dev_attr_ne_guid_vendor_oui))
+               goto fail_addoiu;
        nodemgr_create_ne_dev_files(ne);
 
        nodemgr_update_bus_options(ne);
@@ -829,17 +897,28 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr
                   NODE_BUS_ARGS(host, nodeid), (unsigned long long)guid);
 
        return ne;
+
+fail_addoiu:
+       put_device(&ne->device);
+fail_classdevreg:
+       device_unregister(&ne->device);
+fail_devreg:
+       kfree(ne);
+fail_alloc:
+       HPSB_ERR("Failed to create node ID:BUS[" NODE_BUS_FMT "]  GUID[%016Lx]",
+                NODE_BUS_ARGS(host, nodeid), (unsigned long long)guid);
+
+       return NULL;
 }
 
 
 static struct node_entry *find_entry_by_guid(u64 guid)
 {
-       struct class *class = &nodemgr_ne_class;
        struct class_device *cdev;
        struct node_entry *ne, *ret_ne = NULL;
 
-       down_read(&class->subsys.rwsem);
-       list_for_each_entry(cdev, &class->children, node) {
+       down(&nodemgr_ne_class.sem);
+       list_for_each_entry(cdev, &nodemgr_ne_class.children, node) {
                ne = container_of(cdev, struct node_entry, class_dev);
 
                if (ne->guid == guid) {
@@ -847,20 +926,20 @@ static struct node_entry *find_entry_by_guid(u64 guid)
                        break;
                }
        }
-       up_read(&class->subsys.rwsem);
+       up(&nodemgr_ne_class.sem);
 
-        return ret_ne;
+       return ret_ne;
 }
 
 
-static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host, nodeid_t nodeid)
+static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host,
+                                              nodeid_t nodeid)
 {
-       struct class *class = &nodemgr_ne_class;
        struct class_device *cdev;
        struct node_entry *ne, *ret_ne = NULL;
 
-       down_read(&class->subsys.rwsem);
-       list_for_each_entry(cdev, &class->children, node) {
+       down(&nodemgr_ne_class.sem);
+       list_for_each_entry(cdev, &nodemgr_ne_class.children, node) {
                ne = container_of(cdev, struct node_entry, class_dev);
 
                if (ne->host == host && ne->nodeid == nodeid) {
@@ -868,7 +947,7 @@ static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host, nodeid_t
                        break;
                }
        }
-       up_read(&class->subsys.rwsem);
+       up(&nodemgr_ne_class.sem);
 
        return ret_ne;
 }
@@ -890,13 +969,25 @@ static void nodemgr_register_device(struct node_entry *ne,
        snprintf(ud->class_dev.class_id, BUS_ID_SIZE, "%s-%u",
                 ne->device.bus_id, ud->id);
 
-       device_register(&ud->device);
-       class_device_register(&ud->class_dev);
+       if (device_register(&ud->device))
+               goto fail_devreg;
+       if (class_device_register(&ud->class_dev))
+               goto fail_classdevreg;
        get_device(&ud->device);
 
-       if (ud->vendor_oui)
-               device_create_file(&ud->device, &dev_attr_ud_vendor_oui);
+       if (ud->vendor_oui &&
+           device_create_file(&ud->device, &dev_attr_ud_vendor_oui))
+               goto fail_addoui;
        nodemgr_create_ud_dev_files(ud);
+
+       return;
+
+fail_addoui:
+       put_device(&ud->device);
+fail_classdevreg:
+       device_unregister(&ud->device);
+fail_devreg:
+       HPSB_ERR("Failed to create unit %s", ud->device.bus_id);
 }      
 
 
@@ -976,10 +1067,9 @@ static struct unit_directory *nodemgr_process_unit_directory
                        /* Logical Unit Number */
                        if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) {
                                if (ud->flags & UNIT_DIRECTORY_HAS_LUN) {
-                                       ud_child = kmalloc(sizeof(*ud_child), GFP_KERNEL);
+                                       ud_child = kmemdup(ud, sizeof(*ud_child), GFP_KERNEL);
                                        if (!ud_child)
                                                goto unit_directory_error;
-                                       memcpy(ud_child, ud, sizeof(*ud_child));
                                        nodemgr_register_device(ne, ud_child, &ne->device);
                                        ud_child = NULL;
                                        
@@ -1093,10 +1183,16 @@ static void nodemgr_process_root_directory(struct host_info *hi, struct node_ent
                last_key_id = kv->key.id;
        }
 
-       if (ne->vendor_oui)
-               device_create_file(&ne->device, &dev_attr_ne_vendor_oui);
-       if (ne->vendor_name_kv)
-               device_create_file(&ne->device, &dev_attr_ne_vendor_name_kv);
+       if (ne->vendor_oui &&
+           device_create_file(&ne->device, &dev_attr_ne_vendor_oui))
+               goto fail;
+       if (ne->vendor_name_kv &&
+           device_create_file(&ne->device, &dev_attr_ne_vendor_name_kv))
+               goto fail;
+       return;
+fail:
+       HPSB_ERR("Failed to add sysfs attribute for node %016Lx",
+                (unsigned long long)ne->guid);
 }
 
 #ifdef CONFIG_HOTPLUG
@@ -1160,16 +1256,20 @@ static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp,
 #endif /* CONFIG_HOTPLUG */
 
 
-int hpsb_register_protocol(struct hpsb_protocol_driver *driver)
+int __hpsb_register_protocol(struct hpsb_protocol_driver *drv,
+                            struct module *owner)
 {
-       int ret;
+       int error;
 
-       /* This will cause a probe for devices */
-       ret = driver_register(&driver->driver);
-       if (!ret)
-               nodemgr_create_drv_files(driver);
+       drv->driver.bus = &ieee1394_bus_type;
+       drv->driver.owner = owner;
+       drv->driver.name = drv->name;
 
-       return ret;
+       /* This will cause a probe for devices */
+       error = driver_register(&drv->driver);
+       if (!error)
+               nodemgr_create_drv_files(drv);
+       return error;
 }
 
 void hpsb_unregister_protocol(struct hpsb_protocol_driver *driver)
@@ -1297,26 +1397,25 @@ static void nodemgr_node_scan_one(struct host_info *hi,
 
 static void nodemgr_node_scan(struct host_info *hi, int generation)
 {
-        int count;
-        struct hpsb_host *host = hi->host;
-        struct selfid *sid = (struct selfid *)host->topology_map;
-        nodeid_t nodeid = LOCAL_BUS;
+       int count;
+       struct hpsb_host *host = hi->host;
+       struct selfid *sid = (struct selfid *)host->topology_map;
+       nodeid_t nodeid = LOCAL_BUS;
 
-        /* Scan each node on the bus */
-        for (count = host->selfid_count; count; count--, sid++) {
-                if (sid->extended)
-                        continue;
+       /* Scan each node on the bus */
+       for (count = host->selfid_count; count; count--, sid++) {
+               if (sid->extended)
+                       continue;
 
-                if (!sid->link_active) {
-                        nodeid++;
-                        continue;
-                }
-                nodemgr_node_scan_one(hi, nodeid++, generation);
-        }
+               if (!sid->link_active) {
+                       nodeid++;
+                       continue;
+               }
+               nodemgr_node_scan_one(hi, nodeid++, generation);
+       }
 }
 
 
-/* Caller needs to hold nodemgr_ud_class.subsys.rwsem as reader. */
 static void nodemgr_suspend_ne(struct node_entry *ne)
 {
        struct class_device *cdev;
@@ -1326,21 +1425,22 @@ static void nodemgr_suspend_ne(struct node_entry *ne)
                   NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid);
 
        ne->in_limbo = 1;
-       device_create_file(&ne->device, &dev_attr_ne_in_limbo);
+       WARN_ON(device_create_file(&ne->device, &dev_attr_ne_in_limbo));
 
-       down_write(&ne->device.bus->subsys.rwsem);
+       down(&nodemgr_ud_class.sem);
        list_for_each_entry(cdev, &nodemgr_ud_class.children, node) {
                ud = container_of(cdev, struct unit_directory, class_dev);
-
                if (ud->ne != ne)
                        continue;
 
+               down_write(&ieee1394_bus_type.subsys.rwsem);
                if (ud->device.driver &&
                    (!ud->device.driver->suspend ||
                      ud->device.driver->suspend(&ud->device, PMSG_SUSPEND)))
                        device_release_driver(&ud->device);
+               up_write(&ieee1394_bus_type.subsys.rwsem);
        }
-       up_write(&ne->device.bus->subsys.rwsem);
+       up(&nodemgr_ud_class.sem);
 }
 
 
@@ -1352,45 +1452,47 @@ static void nodemgr_resume_ne(struct node_entry *ne)
        ne->in_limbo = 0;
        device_remove_file(&ne->device, &dev_attr_ne_in_limbo);
 
-       down_read(&nodemgr_ud_class.subsys.rwsem);
-       down_read(&ne->device.bus->subsys.rwsem);
+       down(&nodemgr_ud_class.sem);
        list_for_each_entry(cdev, &nodemgr_ud_class.children, node) {
                ud = container_of(cdev, struct unit_directory, class_dev);
-
                if (ud->ne != ne)
                        continue;
 
+               down_read(&ieee1394_bus_type.subsys.rwsem);
                if (ud->device.driver && ud->device.driver->resume)
                        ud->device.driver->resume(&ud->device);
+               up_read(&ieee1394_bus_type.subsys.rwsem);
        }
-       up_read(&ne->device.bus->subsys.rwsem);
-       up_read(&nodemgr_ud_class.subsys.rwsem);
+       up(&nodemgr_ud_class.sem);
 
        HPSB_DEBUG("Node resumed: ID:BUS[" NODE_BUS_FMT "]  GUID[%016Lx]",
                   NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid);
 }
 
 
-/* Caller needs to hold nodemgr_ud_class.subsys.rwsem as reader. */
 static void nodemgr_update_pdrv(struct node_entry *ne)
 {
        struct unit_directory *ud;
        struct hpsb_protocol_driver *pdrv;
        struct class_device *cdev;
 
+       down(&nodemgr_ud_class.sem);
        list_for_each_entry(cdev, &nodemgr_ud_class.children, node) {
                ud = container_of(cdev, struct unit_directory, class_dev);
-               if (ud->ne != ne || !ud->device.driver)
+               if (ud->ne != ne)
                        continue;
 
-               pdrv = container_of(ud->device.driver, struct hpsb_protocol_driver, driver);
-
-               if (pdrv->update && pdrv->update(ud)) {
-                       down_write(&ud->device.bus->subsys.rwsem);
-                       device_release_driver(&ud->device);
-                       up_write(&ud->device.bus->subsys.rwsem);
+               down_write(&ieee1394_bus_type.subsys.rwsem);
+               if (ud->device.driver) {
+                       pdrv = container_of(ud->device.driver,
+                                           struct hpsb_protocol_driver,
+                                           driver);
+                       if (pdrv->update && pdrv->update(ud))
+                               device_release_driver(&ud->device);
                }
+               up_write(&ieee1394_bus_type.subsys.rwsem);
        }
+       up(&nodemgr_ud_class.sem);
 }
 
 
@@ -1404,7 +1506,7 @@ static void nodemgr_irm_write_bc(struct node_entry *ne, int generation)
 {
        const u64 bc_addr = (CSR_REGISTER_BASE | CSR_BROADCAST_CHANNEL);
        quadlet_t bc_remote, bc_local;
-       int ret;
+       int error;
 
        if (!ne->host->is_irm || ne->generation != generation ||
            ne->nodeid == ne->host->node_id)
@@ -1413,16 +1515,14 @@ static void nodemgr_irm_write_bc(struct node_entry *ne, int generation)
        bc_local = cpu_to_be32(ne->host->csr.broadcast_channel);
 
        /* Check if the register is implemented and 1394a compliant. */
-       ret = hpsb_read(ne->host, ne->nodeid, generation, bc_addr, &bc_remote,
-                       sizeof(bc_remote));
-       if (!ret && bc_remote & cpu_to_be32(0x80000000) &&
+       error = hpsb_read(ne->host, ne->nodeid, generation, bc_addr, &bc_remote,
+                         sizeof(bc_remote));
+       if (!error && bc_remote & cpu_to_be32(0x80000000) &&
            bc_remote != bc_local)
                hpsb_node_write(ne, bc_addr, &bc_local, sizeof(bc_local));
 }
 
 
-/* Caller needs to hold nodemgr_ud_class.subsys.rwsem as reader because the
- * calls to nodemgr_update_pdrv() and nodemgr_suspend_ne() here require it. */
 static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int generation)
 {
        struct device *dev;
@@ -1455,7 +1555,6 @@ static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int ge
 static void nodemgr_node_probe(struct host_info *hi, int generation)
 {
        struct hpsb_host *host = hi->host;
-       struct class *class = &nodemgr_ne_class;
        struct class_device *cdev;
        struct node_entry *ne;
 
@@ -1468,18 +1567,18 @@ static void nodemgr_node_probe(struct host_info *hi, int generation)
         * while probes are time-consuming. (Well, those probes need some
         * improvement...) */
 
-       down_read(&class->subsys.rwsem);
-       list_for_each_entry(cdev, &class->children, node) {
+       down(&nodemgr_ne_class.sem);
+       list_for_each_entry(cdev, &nodemgr_ne_class.children, node) {
                ne = container_of(cdev, struct node_entry, class_dev);
                if (!ne->needs_probe)
                        nodemgr_probe_ne(hi, ne, generation);
        }
-       list_for_each_entry(cdev, &class->children, node) {
+       list_for_each_entry(cdev, &nodemgr_ne_class.children, node) {
                ne = container_of(cdev, struct node_entry, class_dev);
                if (ne->needs_probe)
                        nodemgr_probe_ne(hi, ne, generation);
        }
-        up_read(&class->subsys.rwsem);
+       up(&nodemgr_ne_class.sem);
 
 
        /* If we had a bus reset while we were scanning the bus, it is
@@ -1497,15 +1596,14 @@ static void nodemgr_node_probe(struct host_info *hi, int generation)
         * just removed.  */
 
        if (generation == get_hpsb_generation(host))
-               bus_rescan_devices(&ieee1394_bus_type);
-
-       return;
+               if (bus_rescan_devices(&ieee1394_bus_type))
+                       HPSB_DEBUG("bus_rescan_devices had an error");
 }
 
 static int nodemgr_send_resume_packet(struct hpsb_host *host)
 {
        struct hpsb_packet *packet;
-       int ret = 1;
+       int error = -ENOMEM;
 
        packet = hpsb_make_phypacket(host,
                        EXTPHYPACKET_TYPE_RESUME |
@@ -1513,12 +1611,12 @@ static int nodemgr_send_resume_packet(struct hpsb_host *host)
        if (packet) {
                packet->no_waiter = 1;
                packet->generation = get_hpsb_generation(host);
-               ret = hpsb_send_packet(packet);
+               error = hpsb_send_packet(packet);
        }
-       if (ret)
+       if (error)
                HPSB_WARN("fw-host%d: Failed to broadcast resume packet",
                          host->id);
-       return ret;
+       return error;
 }
 
 /* Perform a few high-level IRM responsibilities. */
@@ -1691,19 +1789,18 @@ exit:
 
 int nodemgr_for_each_host(void *__data, int (*cb)(struct hpsb_host *, void *))
 {
-       struct class *class = &hpsb_host_class;
        struct class_device *cdev;
        struct hpsb_host *host;
        int error = 0;
 
-       down_read(&class->subsys.rwsem);
-       list_for_each_entry(cdev, &class->children, node) {
+       down(&hpsb_host_class.sem);
+       list_for_each_entry(cdev, &hpsb_host_class.children, node) {
                host = container_of(cdev, struct hpsb_host, class_dev);
 
                if ((error = cb(host, __data)))
                        break;
        }
-       up_read(&class->subsys.rwsem);
+       up(&hpsb_host_class.sem);
 
        return error;
 }
@@ -1725,10 +1822,10 @@ int nodemgr_for_each_host(void *__data, int (*cb)(struct hpsb_host *, void *))
 
 void hpsb_node_fill_packet(struct node_entry *ne, struct hpsb_packet *pkt)
 {
-        pkt->host = ne->host;
-        pkt->generation = ne->generation;
+       pkt->host = ne->host;
+       pkt->generation = ne->generation;
        barrier();
-        pkt->node_id = ne->nodeid;
+       pkt->node_id = ne->nodeid;
 }
 
 int hpsb_node_write(struct node_entry *ne, u64 addr,
@@ -1788,26 +1885,25 @@ static struct hpsb_highlevel nodemgr_highlevel = {
 
 int init_ieee1394_nodemgr(void)
 {
-       int ret;
+       int error;
 
-       ret = class_register(&nodemgr_ne_class);
-       if (ret < 0)
-               return ret;
+       error = class_register(&nodemgr_ne_class);
+       if (error)
+               return error;
 
-       ret = class_register(&nodemgr_ud_class);
-       if (ret < 0) {
+       error = class_register(&nodemgr_ud_class);
+       if (error) {
                class_unregister(&nodemgr_ne_class);
-               return ret;
+               return error;
        }
-
+       error = driver_register(&nodemgr_mid_layer_driver);
        hpsb_register_highlevel(&nodemgr_highlevel);
-
        return 0;
 }
 
 void cleanup_ieee1394_nodemgr(void)
 {
-        hpsb_unregister_highlevel(&nodemgr_highlevel);
+       hpsb_unregister_highlevel(&nodemgr_highlevel);
 
        class_unregister(&nodemgr_ud_class);
        class_unregister(&nodemgr_ne_class);
index 0e1e7d930783e7320a78a7f993fc10f756cadc6f..e25cbadb8be0144e4a1bea0326c23b96bcfce16f 100644 (file)
@@ -144,7 +144,12 @@ struct hpsb_protocol_driver {
        struct device_driver driver;
 };
 
-int hpsb_register_protocol(struct hpsb_protocol_driver *driver);
+int __hpsb_register_protocol(struct hpsb_protocol_driver *, struct module *);
+static inline int hpsb_register_protocol(struct hpsb_protocol_driver *driver)
+{
+       return __hpsb_register_protocol(driver, THIS_MODULE);
+}
+
 void hpsb_unregister_protocol(struct hpsb_protocol_driver *driver);
 
 static inline int hpsb_node_entry_valid(struct node_entry *ne)
index 6e8ea9110c46cfcd92de98d01df75c1f1529ea0b..628130a58af3fe9205750bdf4b68eb225815fbaa 100644 (file)
@@ -468,7 +468,6 @@ static int get_nb_iso_ctx(struct ti_ohci *ohci, int reg)
 /* Global initialization */
 static void ohci_initialize(struct ti_ohci *ohci)
 {
-       char irq_buf[16];
        quadlet_t buf;
        int num_ports, i;
 
@@ -586,11 +585,10 @@ static void ohci_initialize(struct ti_ohci *ohci)
        reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_linkEnable);
 
        buf = reg_read(ohci, OHCI1394_Version);
-       sprintf (irq_buf, "%d", ohci->dev->irq);
-       PRINT(KERN_INFO, "OHCI-1394 %d.%d (PCI): IRQ=[%s]  "
+       PRINT(KERN_INFO, "OHCI-1394 %d.%d (PCI): IRQ=[%d]  "
              "MMIO=[%llx-%llx]  Max Packet=[%d]  IR/IT contexts=[%d/%d]",
              ((((buf) >> 16) & 0xf) + (((buf) >> 20) & 0xf) * 10),
-             ((((buf) >> 4) & 0xf) + ((buf) & 0xf) * 10), irq_buf,
+             ((((buf) >> 4) & 0xf) + ((buf) & 0xf) * 10), ohci->dev->irq,
              (unsigned long long)pci_resource_start(ohci->dev, 0),
              (unsigned long long)pci_resource_start(ohci->dev, 0) + OHCI1394_REGISTER_SIZE - 1,
              ohci->max_packet_size,
@@ -1225,7 +1223,7 @@ static int ohci_iso_recv_init(struct hpsb_iso *iso)
        int ctx;
        int ret = -ENOMEM;
 
-       recv = kmalloc(sizeof(*recv), SLAB_KERNEL);
+       recv = kmalloc(sizeof(*recv), GFP_KERNEL);
        if (!recv)
                return -ENOMEM;
 
@@ -1918,7 +1916,7 @@ static int ohci_iso_xmit_init(struct hpsb_iso *iso)
        int ctx;
        int ret = -ENOMEM;
 
-       xmit = kmalloc(sizeof(*xmit), SLAB_KERNEL);
+       xmit = kmalloc(sizeof(*xmit), GFP_KERNEL);
        if (!xmit)
                return -ENOMEM;
 
@@ -3021,7 +3019,7 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
                        return -ENOMEM;
                }
 
-               d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, SLAB_KERNEL, d->prg_bus+i);
+               d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, GFP_KERNEL, d->prg_bus+i);
                OHCI_DMA_ALLOC("pool dma_rcv prg[%d]", i);
 
                 if (d->prg_cpu[i] != NULL) {
@@ -3117,7 +3115,7 @@ alloc_dma_trm_ctx(struct ti_ohci *ohci, struct dma_trm_ctx *d,
        OHCI_DMA_ALLOC("dma_rcv prg pool");
 
        for (i = 0; i < d->num_desc; i++) {
-               d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, SLAB_KERNEL, d->prg_bus+i);
+               d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, GFP_KERNEL, d->prg_bus+i);
                OHCI_DMA_ALLOC("pool dma_trm prg[%d]", i);
 
                 if (d->prg_cpu[i] != NULL) {
@@ -3217,6 +3215,18 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
        struct ti_ohci *ohci;   /* shortcut to currently handled device */
        resource_size_t ohci_base;
 
+#ifdef CONFIG_PPC_PMAC
+       /* Necessary on some machines if ohci1394 was loaded/ unloaded before */
+       if (machine_is(powermac)) {
+               struct device_node *ofn = pci_device_to_OF_node(dev);
+
+               if (ofn) {
+                       pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, ofn, 0, 1);
+                       pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 1);
+               }
+       }
+#endif /* CONFIG_PPC_PMAC */
+
         if (pci_enable_device(dev))
                FAIL(-ENXIO, "Failed to enable OHCI hardware");
         pci_set_master(dev);
@@ -3505,17 +3515,14 @@ static void ohci1394_pci_remove(struct pci_dev *pdev)
 #endif
 
 #ifdef CONFIG_PPC_PMAC
-       /* On UniNorth, power down the cable and turn off the chip
-        * clock when the module is removed to save power on
-        * laptops. Turning it back ON is done by the arch code when
-        * pci_enable_device() is called */
-       {
-               struct device_node* of_node;
+       /* On UniNorth, power down the cable and turn off the chip clock
+        * to save power on laptops */
+       if (machine_is(powermac)) {
+               struct device_node* ofn = pci_device_to_OF_node(ohci->dev);
 
-               of_node = pci_device_to_OF_node(ohci->dev);
-               if (of_node) {
-                       pmac_call_feature(PMAC_FTR_1394_ENABLE, of_node, 0, 0);
-                       pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, of_node, 0, 0);
+               if (ofn) {
+                       pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 0);
+                       pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, ofn, 0, 0);
                }
        }
 #endif /* CONFIG_PPC_PMAC */
@@ -3529,59 +3536,102 @@ static void ohci1394_pci_remove(struct pci_dev *pdev)
 }
 
 #ifdef CONFIG_PM
-static int ohci1394_pci_resume (struct pci_dev *pdev)
-{
-/* PowerMac resume code comes first */
-#ifdef CONFIG_PPC_PMAC
-       if (machine_is(powermac)) {
-               struct device_node *of_node;
-
-               /* Re-enable 1394 */
-               of_node = pci_device_to_OF_node (pdev);
-               if (of_node)
-                       pmac_call_feature (PMAC_FTR_1394_ENABLE, of_node, 0, 1);
-       }
-#endif /* CONFIG_PPC_PMAC */
-
-       pci_set_power_state(pdev, PCI_D0);
-       pci_restore_state(pdev);
-       return pci_enable_device(pdev);
-}
-
-static int ohci1394_pci_suspend (struct pci_dev *pdev, pm_message_t state)
+static int ohci1394_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 {
        int err;
+       struct ti_ohci *ohci = pci_get_drvdata(pdev);
 
        printk(KERN_INFO "%s does not fully support suspend and resume yet\n",
               OHCI1394_DRIVER_NAME);
 
+       if (!ohci) {
+               printk(KERN_ERR "%s: tried to suspend nonexisting host\n",
+                      OHCI1394_DRIVER_NAME);
+               return -ENXIO;
+       }
+       DBGMSG("suspend called");
+
+       /* Clear the async DMA contexts and stop using the controller */
+       hpsb_bus_reset(ohci->host);
+
+       /* See ohci1394_pci_remove() for comments on this sequence */
+       reg_write(ohci, OHCI1394_ConfigROMhdr, 0);
+       reg_write(ohci, OHCI1394_BusOptions,
+                 (reg_read(ohci, OHCI1394_BusOptions) & 0x0000f007) |
+                 0x00ff0000);
+       reg_write(ohci, OHCI1394_IntMaskClear, 0xffffffff);
+       reg_write(ohci, OHCI1394_IntEventClear, 0xffffffff);
+       reg_write(ohci, OHCI1394_IsoXmitIntMaskClear, 0xffffffff);
+       reg_write(ohci, OHCI1394_IsoXmitIntEventClear, 0xffffffff);
+       reg_write(ohci, OHCI1394_IsoRecvIntMaskClear, 0xffffffff);
+       reg_write(ohci, OHCI1394_IsoRecvIntEventClear, 0xffffffff);
+       set_phy_reg(ohci, 4, ~0xc0 & get_phy_reg(ohci, 4));
+       reg_write(ohci, OHCI1394_LinkControlClear, 0xffffffff);
+       ohci_devctl(ohci->host, RESET_BUS, LONG_RESET_NO_FORCE_ROOT);
+       ohci_soft_reset(ohci);
+
        err = pci_save_state(pdev);
        if (err) {
-               printk(KERN_ERR "%s: pci_save_state failed with %d\n",
-                      OHCI1394_DRIVER_NAME, err);
+               PRINT(KERN_ERR, "pci_save_state failed with %d", err);
                return err;
        }
        err = pci_set_power_state(pdev, pci_choose_state(pdev, state));
-#ifdef OHCI1394_DEBUG
        if (err)
-               printk(KERN_DEBUG "%s: pci_set_power_state failed with %d\n",
-                      OHCI1394_DRIVER_NAME, err);
-#endif /* OHCI1394_DEBUG */
+               DBGMSG("pci_set_power_state failed with %d", err);
 
 /* PowerMac suspend code comes last */
 #ifdef CONFIG_PPC_PMAC
        if (machine_is(powermac)) {
-               struct device_node *of_node;
+               struct device_node *ofn = pci_device_to_OF_node(pdev);
 
-               /* Disable 1394 */
-               of_node = pci_device_to_OF_node (pdev);
-               if (of_node)
-                       pmac_call_feature(PMAC_FTR_1394_ENABLE, of_node, 0, 0);
+               if (ofn)
+                       pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 0);
        }
 #endif /* CONFIG_PPC_PMAC */
 
        return 0;
 }
+
+static int ohci1394_pci_resume(struct pci_dev *pdev)
+{
+       int err;
+       struct ti_ohci *ohci = pci_get_drvdata(pdev);
+
+       if (!ohci) {
+               printk(KERN_ERR "%s: tried to resume nonexisting host\n",
+                      OHCI1394_DRIVER_NAME);
+               return -ENXIO;
+       }
+       DBGMSG("resume called");
+
+/* PowerMac resume code comes first */
+#ifdef CONFIG_PPC_PMAC
+       if (machine_is(powermac)) {
+               struct device_node *ofn = pci_device_to_OF_node(pdev);
+
+               if (ofn)
+                       pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 1);
+       }
+#endif /* CONFIG_PPC_PMAC */
+
+       pci_set_power_state(pdev, PCI_D0);
+       pci_restore_state(pdev);
+       err = pci_enable_device(pdev);
+       if (err) {
+               PRINT(KERN_ERR, "pci_enable_device failed with %d", err);
+               return err;
+       }
+
+       /* See ohci1394_pci_probe() for comments on this sequence */
+       ohci_soft_reset(ohci);
+       reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_LPS);
+       reg_write(ohci, OHCI1394_IntEventClear, 0xffffffff);
+       reg_write(ohci, OHCI1394_IntMaskClear, 0xffffffff);
+       mdelay(50);
+       ohci_initialize(ohci);
+
+       return 0;
+}
 #endif /* CONFIG_PM */
 
 #define PCI_CLASS_FIREWIRE_OHCI     ((PCI_CLASS_SERIAL_FIREWIRE << 8) | 0x10)
index 0a7412e27eb49bf18e67408c81b6c56b4192346e..13a617917bf2c2a2f5f96898088392a74d40cea5 100644 (file)
@@ -1428,10 +1428,9 @@ static int __devinit add_card(struct pci_dev *dev,
                struct i2c_algo_bit_data i2c_adapter_data;
 
                error = -ENOMEM;
-               i2c_ad = kmalloc(sizeof(*i2c_ad), SLAB_KERNEL);
+               i2c_ad = kmemdup(&bit_ops, sizeof(*i2c_ad), GFP_KERNEL);
                if (!i2c_ad) FAIL("failed to allocate I2C adapter memory");
 
-               memcpy(i2c_ad, &bit_ops, sizeof(struct i2c_adapter));
                 i2c_adapter_data = bit_data;
                 i2c_ad->algo_data = &i2c_adapter_data;
                 i2c_adapter_data.data = lynx;
index c7731d1bcd89da69559e342be57f2fe6aa1fae3d..50daabf6e5fa38317ce247246945a40191975db7 100644 (file)
@@ -27,12 +27,12 @@ struct file_info {
 
         struct hpsb_host *host;
 
-        struct list_head req_pending;
-        struct list_head req_complete;
+        struct list_head req_pending;  /* protected by reqlists_lock */
+        struct list_head req_complete; /* protected by reqlists_lock */
         spinlock_t reqlists_lock;
         wait_queue_head_t wait_complete;
 
-        struct list_head addr_list;
+        struct list_head addr_list;    /* protected by host_info_lock */
 
         u8 __user *fcp_buffer;
 
@@ -63,7 +63,7 @@ struct arm_addr {
         u8     client_transactions;
         u64    recvb;
         u16    rec_length;
-        u8     *addr_space_buffer; /* accessed by read/write/lock */
+        u8     *addr_space_buffer; /* accessed by read/write/lock requests */
 };
 
 struct pending_request {
@@ -79,7 +79,7 @@ struct pending_request {
 struct host_info {
         struct list_head list;
         struct hpsb_host *host;
-        struct list_head file_info_list;
+        struct list_head file_info_list;  /* protected by host_info_lock */
 };
 
 #endif  /* IEEE1394_RAW1394_PRIVATE_H */
index 5ec4f5eb6b19834b56fe7a53827321470c24ae20..ad2108f27a04783643b84b4b9beb663e3e6f5cdd 100644 (file)
@@ -99,6 +99,21 @@ static struct hpsb_address_ops arm_ops = {
 
 static void queue_complete_cb(struct pending_request *req);
 
+#include <asm/current.h>
+static void print_old_iso_deprecation(void)
+{
+       static pid_t p;
+
+       if (p == current->pid)
+               return;
+       p = current->pid;
+       printk(KERN_WARNING "raw1394: WARNING - Program \"%s\" uses unsupported"
+              " isochronous request types which will be removed in a next"
+              " kernel release\n", current->comm);
+       printk(KERN_WARNING "raw1394: Update your software to use libraw1394's"
+              " newer interface\n");
+}
+
 static struct pending_request *__alloc_pending_request(gfp_t flags)
 {
        struct pending_request *req;
@@ -112,7 +127,7 @@ static struct pending_request *__alloc_pending_request(gfp_t flags)
 
 static inline struct pending_request *alloc_pending_request(void)
 {
-       return __alloc_pending_request(SLAB_KERNEL);
+       return __alloc_pending_request(GFP_KERNEL);
 }
 
 static void free_pending_request(struct pending_request *req)
@@ -259,7 +274,7 @@ static void host_reset(struct hpsb_host *host)
        if (hi != NULL) {
                list_for_each_entry(fi, &hi->file_info_list, list) {
                        if (fi->notification == RAW1394_NOTIFY_ON) {
-                               req = __alloc_pending_request(SLAB_ATOMIC);
+                               req = __alloc_pending_request(GFP_ATOMIC);
 
                                if (req != NULL) {
                                        req->file_info = fi;
@@ -306,13 +321,13 @@ static void iso_receive(struct hpsb_host *host, int channel, quadlet_t * data,
                        if (!(fi->listen_channels & (1ULL << channel)))
                                continue;
 
-                       req = __alloc_pending_request(SLAB_ATOMIC);
+                       req = __alloc_pending_request(GFP_ATOMIC);
                        if (!req)
                                break;
 
                        if (!ibs) {
                                ibs = kmalloc(sizeof(*ibs) + length,
-                                             SLAB_ATOMIC);
+                                             GFP_ATOMIC);
                                if (!ibs) {
                                        kfree(req);
                                        break;
@@ -367,13 +382,13 @@ static void fcp_request(struct hpsb_host *host, int nodeid, int direction,
                        if (!fi->fcp_buffer)
                                continue;
 
-                       req = __alloc_pending_request(SLAB_ATOMIC);
+                       req = __alloc_pending_request(GFP_ATOMIC);
                        if (!req)
                                break;
 
                        if (!ibs) {
                                ibs = kmalloc(sizeof(*ibs) + length,
-                                             SLAB_ATOMIC);
+                                             GFP_ATOMIC);
                                if (!ibs) {
                                        kfree(req);
                                        break;
@@ -593,7 +608,7 @@ static int state_initialized(struct file_info *fi, struct pending_request *req)
        switch (req->req.type) {
        case RAW1394_REQ_LIST_CARDS:
                spin_lock_irqsave(&host_info_lock, flags);
-               khl = kmalloc(sizeof(*khl) * host_count, SLAB_ATOMIC);
+               khl = kmalloc(sizeof(*khl) * host_count, GFP_ATOMIC);
 
                if (khl) {
                        req->req.misc = host_count;
@@ -1045,7 +1060,7 @@ static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer,
        }
        if (arm_addr->notification_options & ARM_READ) {
                DBGMSG("arm_read -> entering notification-section");
-               req = __alloc_pending_request(SLAB_ATOMIC);
+               req = __alloc_pending_request(GFP_ATOMIC);
                if (!req) {
                        DBGMSG("arm_read -> rcode_conflict_error");
                        spin_unlock_irqrestore(&host_info_lock, irqflags);
@@ -1064,7 +1079,7 @@ static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer,
                            sizeof(struct arm_response) +
                            sizeof(struct arm_request_response);
                }
-               req->data = kmalloc(size, SLAB_ATOMIC);
+               req->data = kmalloc(size, GFP_ATOMIC);
                if (!(req->data)) {
                        free_pending_request(req);
                        DBGMSG("arm_read -> rcode_conflict_error");
@@ -1198,7 +1213,7 @@ static int arm_write(struct hpsb_host *host, int nodeid, int destid,
        }
        if (arm_addr->notification_options & ARM_WRITE) {
                DBGMSG("arm_write -> entering notification-section");
-               req = __alloc_pending_request(SLAB_ATOMIC);
+               req = __alloc_pending_request(GFP_ATOMIC);
                if (!req) {
                        DBGMSG("arm_write -> rcode_conflict_error");
                        spin_unlock_irqrestore(&host_info_lock, irqflags);
@@ -1209,7 +1224,7 @@ static int arm_write(struct hpsb_host *host, int nodeid, int destid,
                    sizeof(struct arm_request) + sizeof(struct arm_response) +
                    (length) * sizeof(byte_t) +
                    sizeof(struct arm_request_response);
-               req->data = kmalloc(size, SLAB_ATOMIC);
+               req->data = kmalloc(size, GFP_ATOMIC);
                if (!(req->data)) {
                        free_pending_request(req);
                        DBGMSG("arm_write -> rcode_conflict_error");
@@ -1400,7 +1415,7 @@ static int arm_lock(struct hpsb_host *host, int nodeid, quadlet_t * store,
        if (arm_addr->notification_options & ARM_LOCK) {
                byte_t *buf1, *buf2;
                DBGMSG("arm_lock -> entering notification-section");
-               req = __alloc_pending_request(SLAB_ATOMIC);
+               req = __alloc_pending_request(GFP_ATOMIC);
                if (!req) {
                        DBGMSG("arm_lock -> rcode_conflict_error");
                        spin_unlock_irqrestore(&host_info_lock, irqflags);
@@ -1408,7 +1423,7 @@ static int arm_lock(struct hpsb_host *host, int nodeid, quadlet_t * store,
                                                           The request may be retried */
                }
                size = sizeof(struct arm_request) + sizeof(struct arm_response) + 3 * sizeof(*store) + sizeof(struct arm_request_response);     /* maximum */
-               req->data = kmalloc(size, SLAB_ATOMIC);
+               req->data = kmalloc(size, GFP_ATOMIC);
                if (!(req->data)) {
                        free_pending_request(req);
                        DBGMSG("arm_lock -> rcode_conflict_error");
@@ -1628,7 +1643,7 @@ static int arm_lock64(struct hpsb_host *host, int nodeid, octlet_t * store,
        if (arm_addr->notification_options & ARM_LOCK) {
                byte_t *buf1, *buf2;
                DBGMSG("arm_lock64 -> entering notification-section");
-               req = __alloc_pending_request(SLAB_ATOMIC);
+               req = __alloc_pending_request(GFP_ATOMIC);
                if (!req) {
                        spin_unlock_irqrestore(&host_info_lock, irqflags);
                        DBGMSG("arm_lock64 -> rcode_conflict_error");
@@ -1636,7 +1651,7 @@ static int arm_lock64(struct hpsb_host *host, int nodeid, octlet_t * store,
                                                           The request may be retried */
                }
                size = sizeof(struct arm_request) + sizeof(struct arm_response) + 3 * sizeof(*store) + sizeof(struct arm_request_response);     /* maximum */
-               req->data = kmalloc(size, SLAB_ATOMIC);
+               req->data = kmalloc(size, GFP_ATOMIC);
                if (!(req->data)) {
                        free_pending_request(req);
                        spin_unlock_irqrestore(&host_info_lock, irqflags);
@@ -1737,7 +1752,7 @@ static int arm_register(struct file_info *fi, struct pending_request *req)
                return (-EINVAL);
        }
        /* addr-list-entry for fileinfo */
-       addr = kmalloc(sizeof(*addr), SLAB_KERNEL);
+       addr = kmalloc(sizeof(*addr), GFP_KERNEL);
        if (!addr) {
                req->req.length = 0;
                return (-ENOMEM);
@@ -2103,7 +2118,7 @@ static int write_phypacket(struct file_info *fi, struct pending_request *req)
 static int get_config_rom(struct file_info *fi, struct pending_request *req)
 {
        int ret = sizeof(struct raw1394_request);
-       quadlet_t *data = kmalloc(req->req.length, SLAB_KERNEL);
+       quadlet_t *data = kmalloc(req->req.length, GFP_KERNEL);
        int status;
 
        if (!data)
@@ -2133,7 +2148,7 @@ static int get_config_rom(struct file_info *fi, struct pending_request *req)
 static int update_config_rom(struct file_info *fi, struct pending_request *req)
 {
        int ret = sizeof(struct raw1394_request);
-       quadlet_t *data = kmalloc(req->req.length, SLAB_KERNEL);
+       quadlet_t *data = kmalloc(req->req.length, GFP_KERNEL);
        if (!data)
                return -ENOMEM;
        if (copy_from_user(data, int2ptr(req->req.sendb), req->req.length)) {
@@ -2292,6 +2307,7 @@ static int state_connected(struct file_info *fi, struct pending_request *req)
                return sizeof(struct raw1394_request);
 
        case RAW1394_REQ_ISO_SEND:
+               print_old_iso_deprecation();
                return handle_iso_send(fi, req, node);
 
        case RAW1394_REQ_ARM_REGISTER:
@@ -2310,6 +2326,7 @@ static int state_connected(struct file_info *fi, struct pending_request *req)
                return reset_notification(fi, req);
 
        case RAW1394_REQ_ISO_LISTEN:
+               print_old_iso_deprecation();
                handle_iso_listen(fi, req);
                return sizeof(struct raw1394_request);
 
@@ -2443,7 +2460,7 @@ static void queue_rawiso_event(struct file_info *fi)
        /* only one ISO activity event may be in the queue */
        if (!__rawiso_event_in_queue(fi)) {
                struct pending_request *req =
-                   __alloc_pending_request(SLAB_ATOMIC);
+                   __alloc_pending_request(GFP_ATOMIC);
 
                if (req) {
                        req->file_info = fi;
@@ -2779,7 +2796,7 @@ static int raw1394_open(struct inode *inode, struct file *file)
 {
        struct file_info *fi;
 
-       fi = kzalloc(sizeof(*fi), SLAB_KERNEL);
+       fi = kzalloc(sizeof(*fi), GFP_KERNEL);
        if (!fi)
                return -ENOMEM;
 
@@ -2970,12 +2987,8 @@ static struct ieee1394_device_id raw1394_id_table[] = {
 MODULE_DEVICE_TABLE(ieee1394, raw1394_id_table);
 
 static struct hpsb_protocol_driver raw1394_driver = {
-       .name = "raw1394 Driver",
+       .name = "raw1394",
        .id_table = raw1394_id_table,
-       .driver = {
-                  .name = "raw1394",
-                  .bus = &ieee1394_bus_type,
-                  },
 };
 
 /******************************************************************************/
index cd156d4e779e973511e67562ab0f1d9f9919bed5..e68b80b7340daf5861deb4921450d78f6c244dcf 100644 (file)
  * driver. It also registers as a SCSI lower-level driver in order to accept
  * SCSI commands for transport using SBP-2.
  *
- * You may access any attached SBP-2 storage devices as if they were SCSI
- * devices (e.g. mount /dev/sda1,  fdisk, mkfs, etc.).
+ * You may access any attached SBP-2 (usually storage devices) as regular
+ * SCSI devices. E.g. mount /dev/sda1, fdisk, mkfs, etc..
  *
- * Current Issues:
+ * See http://www.t10.org/drafts.htm#sbp2 for the final draft of the SBP-2
+ * specification and for where to purchase the official standard.
  *
- *     - Error Handling: SCSI aborts and bus reset requests are handled somewhat
- *       but the code needs additional debugging.
+ * TODO:
+ *   - look into possible improvements of the SCSI error handlers
+ *   - handle Unit_Characteristics.mgt_ORB_timeout and .ORB_size
+ *   - handle Logical_Unit_Number.ordered
+ *   - handle src == 1 in status blocks
+ *   - reimplement the DMA mapping in absence of physical DMA so that
+ *     bus_to_virt is no longer required
+ *   - debug the handling of absent physical DMA
+ *   - replace CONFIG_IEEE1394_SBP2_PHYS_DMA by automatic detection
+ *     (this is easy but depends on the previous two TODO items)
+ *   - make the parameter serialize_io configurable per device
+ *   - move all requests to fetch agent registers into non-atomic context,
+ *     replace all usages of sbp2util_node_write_no_wait by true transactions
+ * Grep for inline FIXME comments below.
  */
 
 #include <linux/blkdev.h>
@@ -49,7 +62,6 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
-#include <linux/pci.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/stat.h>
  * (probably due to PCI latency/throughput issues with the part). You can
  * bump down the speed if you are running into problems.
  */
-static int max_speed = IEEE1394_SPEED_MAX;
-module_param(max_speed, int, 0644);
-MODULE_PARM_DESC(max_speed, "Force max speed (3 = 800mb, 2 = 400mb, 1 = 200mb, 0 = 100mb)");
+static int sbp2_max_speed = IEEE1394_SPEED_MAX;
+module_param_named(max_speed, sbp2_max_speed, int, 0644);
+MODULE_PARM_DESC(max_speed, "Force max speed "
+                "(3 = 800Mb/s, 2 = 400Mb/s, 1 = 200Mb/s, 0 = 100Mb/s)");
 
 /*
  * Set serialize_io to 1 if you'd like only one scsi command sent
  * down to us at a time (debugging). This might be necessary for very
  * badly behaved sbp2 devices.
- *
- * TODO: Make this configurable per device.
  */
-static int serialize_io = 1;
-module_param(serialize_io, int, 0444);
-MODULE_PARM_DESC(serialize_io, "Serialize I/O coming from scsi drivers (default = 1, faster = 0)");
+static int sbp2_serialize_io = 1;
+module_param_named(serialize_io, sbp2_serialize_io, int, 0444);
+MODULE_PARM_DESC(serialize_io, "Serialize I/O coming from scsi drivers "
+                "(default = 1, faster = 0)");
 
 /*
  * Bump up max_sectors if you'd like to support very large sized
@@ -121,10 +133,10 @@ MODULE_PARM_DESC(serialize_io, "Serialize I/O coming from scsi drivers (default
  * the Oxsemi sbp2 chipsets have no problems supporting very large
  * transfer sizes.
  */
-static int max_sectors = SBP2_MAX_SECTORS;
-module_param(max_sectors, int, 0444);
-MODULE_PARM_DESC(max_sectors, "Change max sectors per I/O supported (default = "
-                __stringify(SBP2_MAX_SECTORS) ")");
+static int sbp2_max_sectors = SBP2_MAX_SECTORS;
+module_param_named(max_sectors, sbp2_max_sectors, int, 0444);
+MODULE_PARM_DESC(max_sectors, "Change max sectors per I/O supported "
+                "(default = " __stringify(SBP2_MAX_SECTORS) ")");
 
 /*
  * Exclusive login to sbp2 device? In most cases, the sbp2 driver should
@@ -139,9 +151,10 @@ MODULE_PARM_DESC(max_sectors, "Change max sectors per I/O supported (default = "
  * concurrent logins. Depending on firmware, four or two concurrent logins
  * are possible on OXFW911 and newer Oxsemi bridges.
  */
-static int exclusive_login = 1;
-module_param(exclusive_login, int, 0644);
-MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device (default = 1)");
+static int sbp2_exclusive_login = 1;
+module_param_named(exclusive_login, sbp2_exclusive_login, int, 0644);
+MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device "
+                "(default = 1)");
 
 /*
  * If any of the following workarounds is required for your device to work,
@@ -179,123 +192,123 @@ MODULE_PARM_DESC(workarounds, "Work around device bugs (default = 0"
        ", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE)
        ", or a combination)");
 
-/*
- * Export information about protocols/devices supported by this driver.
- */
-static struct ieee1394_device_id sbp2_id_table[] = {
-       {
-        .match_flags = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION,
-        .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff,
-        .version = SBP2_SW_VERSION_ENTRY & 0xffffff},
-       {}
-};
-
-MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table);
-
-/*
- * Debug levels, configured via kernel config, or enable here.
- */
-
-#define CONFIG_IEEE1394_SBP2_DEBUG 0
-/* #define CONFIG_IEEE1394_SBP2_DEBUG_ORBS */
-/* #define CONFIG_IEEE1394_SBP2_DEBUG_DMA */
-/* #define CONFIG_IEEE1394_SBP2_DEBUG 1 */
-/* #define CONFIG_IEEE1394_SBP2_DEBUG 2 */
-/* #define CONFIG_IEEE1394_SBP2_PACKET_DUMP */
-
-#ifdef CONFIG_IEEE1394_SBP2_DEBUG_ORBS
-#define SBP2_ORB_DEBUG(fmt, args...)   HPSB_ERR("sbp2(%s): "fmt, __FUNCTION__, ## args)
-static u32 global_outstanding_command_orbs = 0;
-#define outstanding_orb_incr global_outstanding_command_orbs++
-#define outstanding_orb_decr global_outstanding_command_orbs--
-#else
-#define SBP2_ORB_DEBUG(fmt, args...)   do {} while (0)
-#define outstanding_orb_incr           do {} while (0)
-#define outstanding_orb_decr           do {} while (0)
-#endif
-
-#ifdef CONFIG_IEEE1394_SBP2_DEBUG_DMA
-#define SBP2_DMA_ALLOC(fmt, args...) \
-       HPSB_ERR("sbp2(%s)alloc(%d): "fmt, __FUNCTION__, \
-                ++global_outstanding_dmas, ## args)
-#define SBP2_DMA_FREE(fmt, args...) \
-       HPSB_ERR("sbp2(%s)free(%d): "fmt, __FUNCTION__, \
-                --global_outstanding_dmas, ## args)
-static u32 global_outstanding_dmas = 0;
-#else
-#define SBP2_DMA_ALLOC(fmt, args...)   do {} while (0)
-#define SBP2_DMA_FREE(fmt, args...)    do {} while (0)
-#endif
 
-#if CONFIG_IEEE1394_SBP2_DEBUG >= 2
-#define SBP2_DEBUG(fmt, args...)       HPSB_ERR("sbp2: "fmt, ## args)
-#define SBP2_INFO(fmt, args...)                HPSB_ERR("sbp2: "fmt, ## args)
-#define SBP2_NOTICE(fmt, args...)      HPSB_ERR("sbp2: "fmt, ## args)
-#define SBP2_WARN(fmt, args...)                HPSB_ERR("sbp2: "fmt, ## args)
-#elif CONFIG_IEEE1394_SBP2_DEBUG == 1
-#define SBP2_DEBUG(fmt, args...)       HPSB_DEBUG("sbp2: "fmt, ## args)
-#define SBP2_INFO(fmt, args...)                HPSB_INFO("sbp2: "fmt, ## args)
-#define SBP2_NOTICE(fmt, args...)      HPSB_NOTICE("sbp2: "fmt, ## args)
-#define SBP2_WARN(fmt, args...)                HPSB_WARN("sbp2: "fmt, ## args)
-#else
-#define SBP2_DEBUG(fmt, args...)       do {} while (0)
-#define SBP2_INFO(fmt, args...)                HPSB_INFO("sbp2: "fmt, ## args)
-#define SBP2_NOTICE(fmt, args...)       HPSB_NOTICE("sbp2: "fmt, ## args)
-#define SBP2_WARN(fmt, args...)         HPSB_WARN("sbp2: "fmt, ## args)
-#endif
-
-#define SBP2_ERR(fmt, args...)         HPSB_ERR("sbp2: "fmt, ## args)
-#define SBP2_DEBUG_ENTER()             SBP2_DEBUG("%s", __FUNCTION__)
+#define SBP2_INFO(fmt, args...)        HPSB_INFO("sbp2: "fmt, ## args)
+#define SBP2_ERR(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args)
 
 /*
  * Globals
  */
+static void sbp2scsi_complete_all_commands(struct sbp2_lu *, u32);
+static void sbp2scsi_complete_command(struct sbp2_lu *, u32, struct scsi_cmnd *,
+                                     void (*)(struct scsi_cmnd *));
+static struct sbp2_lu *sbp2_alloc_device(struct unit_directory *);
+static int sbp2_start_device(struct sbp2_lu *);
+static void sbp2_remove_device(struct sbp2_lu *);
+static int sbp2_login_device(struct sbp2_lu *);
+static int sbp2_reconnect_device(struct sbp2_lu *);
+static int sbp2_logout_device(struct sbp2_lu *);
+static void sbp2_host_reset(struct hpsb_host *);
+static int sbp2_handle_status_write(struct hpsb_host *, int, int, quadlet_t *,
+                                   u64, size_t, u16);
+static int sbp2_agent_reset(struct sbp2_lu *, int);
+static void sbp2_parse_unit_directory(struct sbp2_lu *,
+                                     struct unit_directory *);
+static int sbp2_set_busy_timeout(struct sbp2_lu *);
+static int sbp2_max_speed_and_size(struct sbp2_lu *);
 
-static void sbp2scsi_complete_all_commands(struct scsi_id_instance_data *scsi_id,
-                                          u32 status);
-
-static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
-                                     u32 scsi_status, struct scsi_cmnd *SCpnt,
-                                     void (*done)(struct scsi_cmnd *));
-
-static struct scsi_host_template scsi_driver_template;
 
 static const u8 sbp2_speedto_max_payload[] = { 0x7, 0x8, 0x9, 0xA, 0xB, 0xC };
 
-static void sbp2_host_reset(struct hpsb_host *host);
-
-static int sbp2_probe(struct device *dev);
-static int sbp2_remove(struct device *dev);
-static int sbp2_update(struct unit_directory *ud);
-
 static struct hpsb_highlevel sbp2_highlevel = {
-       .name =         SBP2_DEVICE_NAME,
-       .host_reset =   sbp2_host_reset,
+       .name           = SBP2_DEVICE_NAME,
+       .host_reset     = sbp2_host_reset,
 };
 
 static struct hpsb_address_ops sbp2_ops = {
-       .write = sbp2_handle_status_write
+       .write          = sbp2_handle_status_write
 };
 
 #ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
+static int sbp2_handle_physdma_write(struct hpsb_host *, int, int, quadlet_t *,
+                                    u64, size_t, u16);
+static int sbp2_handle_physdma_read(struct hpsb_host *, int, quadlet_t *, u64,
+                                   size_t, u16);
+
 static struct hpsb_address_ops sbp2_physdma_ops = {
-       .read = sbp2_handle_physdma_read,
-       .write = sbp2_handle_physdma_write,
+       .read           = sbp2_handle_physdma_read,
+       .write          = sbp2_handle_physdma_write,
 };
 #endif
 
+
+/*
+ * Interface to driver core and IEEE 1394 core
+ */
+static struct ieee1394_device_id sbp2_id_table[] = {
+       {
+        .match_flags   = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION,
+        .specifier_id  = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff,
+        .version       = SBP2_SW_VERSION_ENTRY & 0xffffff},
+       {}
+};
+MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table);
+
+static int sbp2_probe(struct device *);
+static int sbp2_remove(struct device *);
+static int sbp2_update(struct unit_directory *);
+
 static struct hpsb_protocol_driver sbp2_driver = {
-       .name           = "SBP2 Driver",
+       .name           = SBP2_DEVICE_NAME,
        .id_table       = sbp2_id_table,
        .update         = sbp2_update,
        .driver         = {
-               .name           = SBP2_DEVICE_NAME,
-               .bus            = &ieee1394_bus_type,
                .probe          = sbp2_probe,
                .remove         = sbp2_remove,
        },
 };
 
+
+/*
+ * Interface to SCSI core
+ */
+static int sbp2scsi_queuecommand(struct scsi_cmnd *,
+                                void (*)(struct scsi_cmnd *));
+static int sbp2scsi_abort(struct scsi_cmnd *);
+static int sbp2scsi_reset(struct scsi_cmnd *);
+static int sbp2scsi_slave_alloc(struct scsi_device *);
+static int sbp2scsi_slave_configure(struct scsi_device *);
+static void sbp2scsi_slave_destroy(struct scsi_device *);
+static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *,
+                                          struct device_attribute *, char *);
+
+static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL);
+
+static struct device_attribute *sbp2_sysfs_sdev_attrs[] = {
+       &dev_attr_ieee1394_id,
+       NULL
+};
+
+static struct scsi_host_template sbp2_shost_template = {
+       .module                  = THIS_MODULE,
+       .name                    = "SBP-2 IEEE-1394",
+       .proc_name               = SBP2_DEVICE_NAME,
+       .queuecommand            = sbp2scsi_queuecommand,
+       .eh_abort_handler        = sbp2scsi_abort,
+       .eh_device_reset_handler = sbp2scsi_reset,
+       .slave_alloc             = sbp2scsi_slave_alloc,
+       .slave_configure         = sbp2scsi_slave_configure,
+       .slave_destroy           = sbp2scsi_slave_destroy,
+       .this_id                 = -1,
+       .sg_tablesize            = SG_ALL,
+       .use_clustering          = ENABLE_CLUSTERING,
+       .cmd_per_lun             = SBP2_MAX_CMDS,
+       .can_queue               = SBP2_MAX_CMDS,
+       .emulated                = 1,
+       .sdev_attrs              = sbp2_sysfs_sdev_attrs,
+};
+
+
 /*
  * List of devices with known bugs.
  *
@@ -363,8 +376,6 @@ static inline void sbp2util_be32_to_cpu_buffer(void *buffer, int length)
 
        for (length = (length >> 2); length--; )
                temp[length] = be32_to_cpu(temp[length]);
-
-       return;
 }
 
 /*
@@ -376,8 +387,6 @@ static inline void sbp2util_cpu_to_be32_buffer(void *buffer, int length)
 
        for (length = (length >> 2); length--; )
                temp[length] = cpu_to_be32(temp[length]);
-
-       return;
 }
 #else /* BIG_ENDIAN */
 /* Why waste the cpu cycles? */
@@ -385,344 +394,246 @@ static inline void sbp2util_cpu_to_be32_buffer(void *buffer, int length)
 #define sbp2util_cpu_to_be32_buffer(x,y) do {} while (0)
 #endif
 
-#ifdef CONFIG_IEEE1394_SBP2_PACKET_DUMP
-/*
- * Debug packet dump routine. Length is in bytes.
- */
-static void sbp2util_packet_dump(void *buffer, int length, char *dump_name,
-                                u32 dump_phys_addr)
-{
-       int i;
-       unsigned char *dump = buffer;
-
-       if (!dump || !length || !dump_name)
-               return;
-
-       if (dump_phys_addr)
-               printk("[%s, 0x%x]", dump_name, dump_phys_addr);
-       else
-               printk("[%s]", dump_name);
-       for (i = 0; i < length; i++) {
-               if (i > 0x3f) {
-                       printk("\n   ...");
-                       break;
-               }
-               if ((i & 0x3) == 0)
-                       printk("  ");
-               if ((i & 0xf) == 0)
-                       printk("\n   ");
-               printk("%02x ", (int)dump[i]);
-       }
-       printk("\n");
-
-       return;
-}
-#else
-#define sbp2util_packet_dump(w,x,y,z) do {} while (0)
-#endif
-
-static DECLARE_WAIT_QUEUE_HEAD(access_wq);
+static DECLARE_WAIT_QUEUE_HEAD(sbp2_access_wq);
 
 /*
  * Waits for completion of an SBP-2 access request.
  * Returns nonzero if timed out or prematurely interrupted.
  */
-static int sbp2util_access_timeout(struct scsi_id_instance_data *scsi_id,
-                                  int timeout)
+static int sbp2util_access_timeout(struct sbp2_lu *lu, int timeout)
 {
-       long leftover = wait_event_interruptible_timeout(
-                               access_wq, scsi_id->access_complete, timeout);
+       long leftover;
 
-       scsi_id->access_complete = 0;
+       leftover = wait_event_interruptible_timeout(
+                       sbp2_access_wq, lu->access_complete, timeout);
+       lu->access_complete = 0;
        return leftover <= 0;
 }
 
-/* Frees an allocated packet */
-static void sbp2_free_packet(struct hpsb_packet *packet)
+static void sbp2_free_packet(void *packet)
 {
        hpsb_free_tlabel(packet);
        hpsb_free_packet(packet);
 }
 
-/* This is much like hpsb_node_write(), except it ignores the response
- * subaction and returns immediately. Can be used from interrupts.
+/*
+ * This is much like hpsb_node_write(), except it ignores the response
+ * subaction and returns immediately. Can be used from atomic context.
  */
 static int sbp2util_node_write_no_wait(struct node_entry *ne, u64 addr,
-                                      quadlet_t *buffer, size_t length)
+                                      quadlet_t *buf, size_t len)
 {
        struct hpsb_packet *packet;
 
-       packet = hpsb_make_writepacket(ne->host, ne->nodeid,
-                                      addr, buffer, length);
+       packet = hpsb_make_writepacket(ne->host, ne->nodeid, addr, buf, len);
        if (!packet)
                return -ENOMEM;
 
-       hpsb_set_packet_complete_task(packet,
-                                     (void (*)(void *))sbp2_free_packet,
-                                     packet);
-
+       hpsb_set_packet_complete_task(packet, sbp2_free_packet, packet);
        hpsb_node_fill_packet(ne, packet);
-
        if (hpsb_send_packet(packet) < 0) {
                sbp2_free_packet(packet);
                return -EIO;
        }
-
        return 0;
 }
 
-static void sbp2util_notify_fetch_agent(struct scsi_id_instance_data *scsi_id,
-                                       u64 offset, quadlet_t *data, size_t len)
+static void sbp2util_notify_fetch_agent(struct sbp2_lu *lu, u64 offset,
+                                       quadlet_t *data, size_t len)
 {
-       /*
-        * There is a small window after a bus reset within which the node
-        * entry's generation is current but the reconnect wasn't completed.
-        */
-       if (unlikely(atomic_read(&scsi_id->state) == SBP2LU_STATE_IN_RESET))
+       /* There is a small window after a bus reset within which the node
+        * entry's generation is current but the reconnect wasn't completed. */
+       if (unlikely(atomic_read(&lu->state) == SBP2LU_STATE_IN_RESET))
                return;
 
-       if (hpsb_node_write(scsi_id->ne,
-                           scsi_id->sbp2_command_block_agent_addr + offset,
+       if (hpsb_node_write(lu->ne, lu->command_block_agent_addr + offset,
                            data, len))
                SBP2_ERR("sbp2util_notify_fetch_agent failed.");
-       /*
-        * Now accept new SCSI commands, unless a bus reset happended during
-        * hpsb_node_write.
-        */
-       if (likely(atomic_read(&scsi_id->state) != SBP2LU_STATE_IN_RESET))
-               scsi_unblock_requests(scsi_id->scsi_host);
+
+       /* Now accept new SCSI commands, unless a bus reset happended during
+        * hpsb_node_write. */
+       if (likely(atomic_read(&lu->state) != SBP2LU_STATE_IN_RESET))
+               scsi_unblock_requests(lu->shost);
 }
 
 static void sbp2util_write_orb_pointer(struct work_struct *work)
 {
-       struct scsi_id_instance_data *scsi_id =
-               container_of(work, struct scsi_id_instance_data,
-                            protocol_work.work);
+       struct sbp2_lu *lu = container_of(work, struct sbp2_lu, protocol_work);
        quadlet_t data[2];
 
-       data[0] = ORB_SET_NODE_ID(scsi_id->hi->host->node_id);
-       data[1] = scsi_id->last_orb_dma;
+       data[0] = ORB_SET_NODE_ID(lu->hi->host->node_id);
+       data[1] = lu->last_orb_dma;
        sbp2util_cpu_to_be32_buffer(data, 8);
-       sbp2util_notify_fetch_agent(scsi_id, SBP2_ORB_POINTER_OFFSET, data, 8);
+       sbp2util_notify_fetch_agent(lu, SBP2_ORB_POINTER_OFFSET, data, 8);
 }
 
 static void sbp2util_write_doorbell(struct work_struct *work)
 {
-       struct scsi_id_instance_data *scsi_id =
-               container_of(work, struct scsi_id_instance_data,
-                            protocol_work.work);
-       sbp2util_notify_fetch_agent(scsi_id, SBP2_DOORBELL_OFFSET, NULL, 4);
+       struct sbp2_lu *lu = container_of(work, struct sbp2_lu, protocol_work);
+
+       sbp2util_notify_fetch_agent(lu, SBP2_DOORBELL_OFFSET, NULL, 4);
 }
 
-/*
- * This function is called to create a pool of command orbs used for
- * command processing. It is called when a new sbp2 device is detected.
- */
-static int sbp2util_create_command_orb_pool(struct scsi_id_instance_data *scsi_id)
+static int sbp2util_create_command_orb_pool(struct sbp2_lu *lu)
 {
-       struct sbp2scsi_host_info *hi = scsi_id->hi;
+       struct sbp2_fwhost_info *hi = lu->hi;
        int i;
        unsigned long flags, orbs;
-       struct sbp2_command_info *command;
+       struct sbp2_command_info *cmd;
 
-       orbs = serialize_io ? 2 : SBP2_MAX_CMDS;
+       orbs = sbp2_serialize_io ? 2 : SBP2_MAX_CMDS;
 
-       spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags);
+       spin_lock_irqsave(&lu->cmd_orb_lock, flags);
        for (i = 0; i < orbs; i++) {
-               command = kzalloc(sizeof(*command), GFP_ATOMIC);
-               if (!command) {
-                       spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock,
-                                              flags);
+               cmd = kzalloc(sizeof(*cmd), GFP_ATOMIC);
+               if (!cmd) {
+                       spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
                        return -ENOMEM;
                }
-               command->command_orb_dma =
-                   pci_map_single(hi->host->pdev, &command->command_orb,
-                                  sizeof(struct sbp2_command_orb),
-                                  PCI_DMA_TODEVICE);
-               SBP2_DMA_ALLOC("single command orb DMA");
-               command->sge_dma =
-                   pci_map_single(hi->host->pdev,
-                                  &command->scatter_gather_element,
-                                  sizeof(command->scatter_gather_element),
-                                  PCI_DMA_BIDIRECTIONAL);
-               SBP2_DMA_ALLOC("scatter_gather_element");
-               INIT_LIST_HEAD(&command->list);
-               list_add_tail(&command->list, &scsi_id->sbp2_command_orb_completed);
-       }
-       spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
+               cmd->command_orb_dma = dma_map_single(&hi->host->device,
+                                               &cmd->command_orb,
+                                               sizeof(struct sbp2_command_orb),
+                                               DMA_TO_DEVICE);
+               cmd->sge_dma = dma_map_single(&hi->host->device,
+                                       &cmd->scatter_gather_element,
+                                       sizeof(cmd->scatter_gather_element),
+                                       DMA_BIDIRECTIONAL);
+               INIT_LIST_HEAD(&cmd->list);
+               list_add_tail(&cmd->list, &lu->cmd_orb_completed);
+       }
+       spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
        return 0;
 }
 
-/*
- * This function is called to delete a pool of command orbs.
- */
-static void sbp2util_remove_command_orb_pool(struct scsi_id_instance_data *scsi_id)
+static void sbp2util_remove_command_orb_pool(struct sbp2_lu *lu)
 {
-       struct hpsb_host *host = scsi_id->hi->host;
+       struct hpsb_host *host = lu->hi->host;
        struct list_head *lh, *next;
-       struct sbp2_command_info *command;
+       struct sbp2_command_info *cmd;
        unsigned long flags;
 
-       spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags);
-       if (!list_empty(&scsi_id->sbp2_command_orb_completed)) {
-               list_for_each_safe(lh, next, &scsi_id->sbp2_command_orb_completed) {
-                       command = list_entry(lh, struct sbp2_command_info, list);
-
-                       /* Release our generic DMA's */
-                       pci_unmap_single(host->pdev, command->command_orb_dma,
+       spin_lock_irqsave(&lu->cmd_orb_lock, flags);
+       if (!list_empty(&lu->cmd_orb_completed))
+               list_for_each_safe(lh, next, &lu->cmd_orb_completed) {
+                       cmd = list_entry(lh, struct sbp2_command_info, list);
+                       dma_unmap_single(&host->device, cmd->command_orb_dma,
                                         sizeof(struct sbp2_command_orb),
-                                        PCI_DMA_TODEVICE);
-                       SBP2_DMA_FREE("single command orb DMA");
-                       pci_unmap_single(host->pdev, command->sge_dma,
-                                        sizeof(command->scatter_gather_element),
-                                        PCI_DMA_BIDIRECTIONAL);
-                       SBP2_DMA_FREE("scatter_gather_element");
-
-                       kfree(command);
+                                        DMA_TO_DEVICE);
+                       dma_unmap_single(&host->device, cmd->sge_dma,
+                                        sizeof(cmd->scatter_gather_element),
+                                        DMA_BIDIRECTIONAL);
+                       kfree(cmd);
                }
-       }
-       spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
+       spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
        return;
 }
 
 /*
- * This function finds the sbp2_command for a given outstanding command
- * orb.Only looks at the inuse list.
+ * Finds the sbp2_command for a given outstanding command ORB.
+ * Only looks at the in-use list.
  */
 static struct sbp2_command_info *sbp2util_find_command_for_orb(
-               struct scsi_id_instance_data *scsi_id, dma_addr_t orb)
+                               struct sbp2_lu *lu, dma_addr_t orb)
 {
-       struct sbp2_command_info *command;
+       struct sbp2_command_info *cmd;
        unsigned long flags;
 
-       spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags);
-       if (!list_empty(&scsi_id->sbp2_command_orb_inuse)) {
-               list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) {
-                       if (command->command_orb_dma == orb) {
-                               spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
-                               return command;
+       spin_lock_irqsave(&lu->cmd_orb_lock, flags);
+       if (!list_empty(&lu->cmd_orb_inuse))
+               list_for_each_entry(cmd, &lu->cmd_orb_inuse, list)
+                       if (cmd->command_orb_dma == orb) {
+                               spin_unlock_irqrestore(
+                                               &lu->cmd_orb_lock, flags);
+                               return cmd;
                        }
-               }
-       }
-       spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
-
-       SBP2_ORB_DEBUG("could not match command orb %x", (unsigned int)orb);
-
+       spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
        return NULL;
 }
 
 /*
- * This function finds the sbp2_command for a given outstanding SCpnt.
- * Only looks at the inuse list.
- * Must be called with scsi_id->sbp2_command_orb_lock held.
+ * Finds the sbp2_command for a given outstanding SCpnt.
+ * Only looks at the in-use list.
+ * Must be called with lu->cmd_orb_lock held.
  */
 static struct sbp2_command_info *sbp2util_find_command_for_SCpnt(
-               struct scsi_id_instance_data *scsi_id, void *SCpnt)
+                               struct sbp2_lu *lu, void *SCpnt)
 {
-       struct sbp2_command_info *command;
+       struct sbp2_command_info *cmd;
 
-       if (!list_empty(&scsi_id->sbp2_command_orb_inuse))
-               list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list)
-                       if (command->Current_SCpnt == SCpnt)
-                               return command;
+       if (!list_empty(&lu->cmd_orb_inuse))
+               list_for_each_entry(cmd, &lu->cmd_orb_inuse, list)
+                       if (cmd->Current_SCpnt == SCpnt)
+                               return cmd;
        return NULL;
 }
 
-/*
- * This function allocates a command orb used to send a scsi command.
- */
 static struct sbp2_command_info *sbp2util_allocate_command_orb(
-               struct scsi_id_instance_data *scsi_id,
-               struct scsi_cmnd *Current_SCpnt,
-               void (*Current_done)(struct scsi_cmnd *))
+                               struct sbp2_lu *lu,
+                               struct scsi_cmnd *Current_SCpnt,
+                               void (*Current_done)(struct scsi_cmnd *))
 {
        struct list_head *lh;
-       struct sbp2_command_info *command = NULL;
+       struct sbp2_command_info *cmd = NULL;
        unsigned long flags;
 
-       spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags);
-       if (!list_empty(&scsi_id->sbp2_command_orb_completed)) {
-               lh = scsi_id->sbp2_command_orb_completed.next;
+       spin_lock_irqsave(&lu->cmd_orb_lock, flags);
+       if (!list_empty(&lu->cmd_orb_completed)) {
+               lh = lu->cmd_orb_completed.next;
                list_del(lh);
-               command = list_entry(lh, struct sbp2_command_info, list);
-               command->Current_done = Current_done;
-               command->Current_SCpnt = Current_SCpnt;
-               list_add_tail(&command->list, &scsi_id->sbp2_command_orb_inuse);
-       } else {
+               cmd = list_entry(lh, struct sbp2_command_info, list);
+               cmd->Current_done = Current_done;
+               cmd->Current_SCpnt = Current_SCpnt;
+               list_add_tail(&cmd->list, &lu->cmd_orb_inuse);
+       } else
                SBP2_ERR("%s: no orbs available", __FUNCTION__);
-       }
-       spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
-       return command;
-}
-
-/* Free our DMA's */
-static void sbp2util_free_command_dma(struct sbp2_command_info *command)
-{
-       struct scsi_id_instance_data *scsi_id =
-               (struct scsi_id_instance_data *)command->Current_SCpnt->device->host->hostdata[0];
-       struct hpsb_host *host;
-
-       if (!scsi_id) {
-               SBP2_ERR("%s: scsi_id == NULL", __FUNCTION__);
-               return;
-       }
-
-       host = scsi_id->ud->ne->host;
-
-       if (command->cmd_dma) {
-               if (command->dma_type == CMD_DMA_SINGLE) {
-                       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(host->pdev, command->cmd_dma,
-                                      command->dma_size, command->dma_dir);
-                       SBP2_DMA_FREE("single page");
-               } /* XXX: Check for CMD_DMA_NONE bug */
-               command->dma_type = CMD_DMA_NONE;
-               command->cmd_dma = 0;
-       }
-
-       if (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;
-       }
+       spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
+       return cmd;
 }
 
 /*
- * This function moves a command to the completed orb list.
- * Must be called with scsi_id->sbp2_command_orb_lock held.
+ * Unmaps the DMAs of a command and moves the command to the completed ORB list.
+ * Must be called with lu->cmd_orb_lock held.
  */
-static void sbp2util_mark_command_completed(
-               struct scsi_id_instance_data *scsi_id,
-               struct sbp2_command_info *command)
+static void sbp2util_mark_command_completed(struct sbp2_lu *lu,
+                                           struct sbp2_command_info *cmd)
 {
-       list_del(&command->list);
-       sbp2util_free_command_dma(command);
-       list_add_tail(&command->list, &scsi_id->sbp2_command_orb_completed);
+       struct hpsb_host *host = lu->ud->ne->host;
+
+       if (cmd->cmd_dma) {
+               if (cmd->dma_type == CMD_DMA_SINGLE)
+                       dma_unmap_single(&host->device, cmd->cmd_dma,
+                                        cmd->dma_size, cmd->dma_dir);
+               else if (cmd->dma_type == CMD_DMA_PAGE)
+                       dma_unmap_page(&host->device, cmd->cmd_dma,
+                                      cmd->dma_size, cmd->dma_dir);
+               /* XXX: Check for CMD_DMA_NONE bug */
+               cmd->dma_type = CMD_DMA_NONE;
+               cmd->cmd_dma = 0;
+       }
+       if (cmd->sge_buffer) {
+               dma_unmap_sg(&host->device, cmd->sge_buffer,
+                            cmd->dma_size, cmd->dma_dir);
+               cmd->sge_buffer = NULL;
+       }
+       list_move_tail(&cmd->list, &lu->cmd_orb_completed);
 }
 
 /*
- * Is scsi_id valid? Is the 1394 node still present?
+ * Is lu valid? Is the 1394 node still present?
  */
-static inline int sbp2util_node_is_available(struct scsi_id_instance_data *scsi_id)
+static inline int sbp2util_node_is_available(struct sbp2_lu *lu)
 {
-       return scsi_id && scsi_id->ne && !scsi_id->ne->in_limbo;
+       return lu && lu->ne && !lu->ne->in_limbo;
 }
 
 /*********************************************
  * IEEE-1394 core driver stack related section
  *********************************************/
-static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud);
 
 static int sbp2_probe(struct device *dev)
 {
        struct unit_directory *ud;
-       struct scsi_id_instance_data *scsi_id;
-
-       SBP2_DEBUG_ENTER();
+       struct sbp2_lu *lu;
 
        ud = container_of(dev, struct unit_directory, device);
 
@@ -731,67 +642,58 @@ static int sbp2_probe(struct device *dev)
        if (ud->flags & UNIT_DIRECTORY_HAS_LUN_DIRECTORY)
                return -ENODEV;
 
-       scsi_id = sbp2_alloc_device(ud);
-
-       if (!scsi_id)
+       lu = sbp2_alloc_device(ud);
+       if (!lu)
                return -ENOMEM;
 
-       sbp2_parse_unit_directory(scsi_id, ud);
-
-       return sbp2_start_device(scsi_id);
+       sbp2_parse_unit_directory(lu, ud);
+       return sbp2_start_device(lu);
 }
 
 static int sbp2_remove(struct device *dev)
 {
        struct unit_directory *ud;
-       struct scsi_id_instance_data *scsi_id;
+       struct sbp2_lu *lu;
        struct scsi_device *sdev;
 
-       SBP2_DEBUG_ENTER();
-
        ud = container_of(dev, struct unit_directory, device);
-       scsi_id = ud->device.driver_data;
-       if (!scsi_id)
+       lu = ud->device.driver_data;
+       if (!lu)
                return 0;
 
-       if (scsi_id->scsi_host) {
+       if (lu->shost) {
                /* Get rid of enqueued commands if there is no chance to
                 * send them. */
-               if (!sbp2util_node_is_available(scsi_id))
-                       sbp2scsi_complete_all_commands(scsi_id, DID_NO_CONNECT);
-               /* scsi_remove_device() will trigger shutdown functions of SCSI
+               if (!sbp2util_node_is_available(lu))
+                       sbp2scsi_complete_all_commands(lu, DID_NO_CONNECT);
+               /* scsi_remove_device() may trigger shutdown functions of SCSI
                 * highlevel drivers which would deadlock if blocked. */
-               atomic_set(&scsi_id->state, SBP2LU_STATE_IN_SHUTDOWN);
-               scsi_unblock_requests(scsi_id->scsi_host);
+               atomic_set(&lu->state, SBP2LU_STATE_IN_SHUTDOWN);
+               scsi_unblock_requests(lu->shost);
        }
-       sdev = scsi_id->sdev;
+       sdev = lu->sdev;
        if (sdev) {
-               scsi_id->sdev = NULL;
+               lu->sdev = NULL;
                scsi_remove_device(sdev);
        }
 
-       sbp2_logout_device(scsi_id);
-       sbp2_remove_device(scsi_id);
+       sbp2_logout_device(lu);
+       sbp2_remove_device(lu);
 
        return 0;
 }
 
 static int sbp2_update(struct unit_directory *ud)
 {
-       struct scsi_id_instance_data *scsi_id = ud->device.driver_data;
-
-       SBP2_DEBUG_ENTER();
+       struct sbp2_lu *lu = ud->device.driver_data;
 
-       if (sbp2_reconnect_device(scsi_id)) {
+       if (sbp2_reconnect_device(lu)) {
+               /* Reconnect has failed. Perhaps we didn't reconnect fast
+                * enough. Try a regular login, but first log out just in
+                * case of any weirdness. */
+               sbp2_logout_device(lu);
 
-               /*
-                * Ok, reconnect has failed. Perhaps we didn't
-                * reconnect fast enough. Try doing a regular login, but
-                * first do a logout just in case of any weirdness.
-                */
-               sbp2_logout_device(scsi_id);
-
-               if (sbp2_login_device(scsi_id)) {
+               if (sbp2_login_device(lu)) {
                        /* Login failed too, just fail, and the backend
                         * will call our sbp2_remove for us */
                        SBP2_ERR("Failed to reconnect to sbp2 device!");
@@ -799,69 +701,59 @@ static int sbp2_update(struct unit_directory *ud)
                }
        }
 
-       /* Set max retries to something large on the device. */
-       sbp2_set_busy_timeout(scsi_id);
+       sbp2_set_busy_timeout(lu);
+       sbp2_agent_reset(lu, 1);
+       sbp2_max_speed_and_size(lu);
 
-       /* Do a SBP-2 fetch agent reset. */
-       sbp2_agent_reset(scsi_id, 1);
-
-       /* Get the max speed and packet size that we can use. */
-       sbp2_max_speed_and_size(scsi_id);
-
-       /* Complete any pending commands with busy (so they get
-        * retried) and remove them from our queue
-        */
-       sbp2scsi_complete_all_commands(scsi_id, DID_BUS_BUSY);
+       /* Complete any pending commands with busy (so they get retried)
+        * and remove them from our queue. */
+       sbp2scsi_complete_all_commands(lu, DID_BUS_BUSY);
 
        /* Accept new commands unless there was another bus reset in the
         * meantime. */
-       if (hpsb_node_entry_valid(scsi_id->ne)) {
-               atomic_set(&scsi_id->state, SBP2LU_STATE_RUNNING);
-               scsi_unblock_requests(scsi_id->scsi_host);
+       if (hpsb_node_entry_valid(lu->ne)) {
+               atomic_set(&lu->state, SBP2LU_STATE_RUNNING);
+               scsi_unblock_requests(lu->shost);
        }
        return 0;
 }
 
-/* This functions is called by the sbp2_probe, for each new device. We now
- * allocate one scsi host for each scsi_id (unit directory). */
-static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud)
+static struct sbp2_lu *sbp2_alloc_device(struct unit_directory *ud)
 {
-       struct sbp2scsi_host_info *hi;
-       struct Scsi_Host *scsi_host = NULL;
-       struct scsi_id_instance_data *scsi_id = NULL;
+       struct sbp2_fwhost_info *hi;
+       struct Scsi_Host *shost = NULL;
+       struct sbp2_lu *lu = NULL;
 
-       SBP2_DEBUG_ENTER();
-
-       scsi_id = kzalloc(sizeof(*scsi_id), GFP_KERNEL);
-       if (!scsi_id) {
-               SBP2_ERR("failed to create scsi_id");
+       lu = kzalloc(sizeof(*lu), GFP_KERNEL);
+       if (!lu) {
+               SBP2_ERR("failed to create lu");
                goto failed_alloc;
        }
 
-       scsi_id->ne = ud->ne;
-       scsi_id->ud = ud;
-       scsi_id->speed_code = IEEE1394_SPEED_100;
-       scsi_id->max_payload_size = sbp2_speedto_max_payload[IEEE1394_SPEED_100];
-       scsi_id->status_fifo_addr = CSR1212_INVALID_ADDR_SPACE;
-       INIT_LIST_HEAD(&scsi_id->sbp2_command_orb_inuse);
-       INIT_LIST_HEAD(&scsi_id->sbp2_command_orb_completed);
-       INIT_LIST_HEAD(&scsi_id->scsi_list);
-       spin_lock_init(&scsi_id->sbp2_command_orb_lock);
-       atomic_set(&scsi_id->state, SBP2LU_STATE_RUNNING);
-       INIT_DELAYED_WORK(&scsi_id->protocol_work, NULL);
+       lu->ne = ud->ne;
+       lu->ud = ud;
+       lu->speed_code = IEEE1394_SPEED_100;
+       lu->max_payload_size = sbp2_speedto_max_payload[IEEE1394_SPEED_100];
+       lu->status_fifo_addr = CSR1212_INVALID_ADDR_SPACE;
+       INIT_LIST_HEAD(&lu->cmd_orb_inuse);
+       INIT_LIST_HEAD(&lu->cmd_orb_completed);
+       INIT_LIST_HEAD(&lu->lu_list);
+       spin_lock_init(&lu->cmd_orb_lock);
+       atomic_set(&lu->state, SBP2LU_STATE_RUNNING);
+       INIT_WORK(&lu->protocol_work, NULL);
 
-       ud->device.driver_data = scsi_id;
+       ud->device.driver_data = lu;
 
        hi = hpsb_get_hostinfo(&sbp2_highlevel, ud->ne->host);
        if (!hi) {
-               hi = hpsb_create_hostinfo(&sbp2_highlevel, ud->ne->host, sizeof(*hi));
+               hi = hpsb_create_hostinfo(&sbp2_highlevel, ud->ne->host,
+                                         sizeof(*hi));
                if (!hi) {
                        SBP2_ERR("failed to allocate hostinfo");
                        goto failed_alloc;
                }
-               SBP2_DEBUG("sbp2_alloc_device: allocated hostinfo");
                hi->host = ud->ne->host;
-               INIT_LIST_HEAD(&hi->scsi_ids);
+               INIT_LIST_HEAD(&hi->logical_units);
 
 #ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
                /* Handle data movement if physical dma is not
@@ -881,9 +773,9 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
                goto failed_alloc;
        }
 
-       scsi_id->hi = hi;
+       lu->hi = hi;
 
-       list_add_tail(&scsi_id->scsi_list, &hi->scsi_ids);
+       list_add_tail(&lu->lu_list, &hi->logical_units);
 
        /* Register the status FIFO address range. We could use the same FIFO
         * for targets at different nodes. However we need different FIFOs per
@@ -893,302 +785,214 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
         * then be performed as unified transactions. This slightly reduces
         * bandwidth usage, and some Prolific based devices seem to require it.
         */
-       scsi_id->status_fifo_addr = hpsb_allocate_and_register_addrspace(
+       lu->status_fifo_addr = hpsb_allocate_and_register_addrspace(
                        &sbp2_highlevel, ud->ne->host, &sbp2_ops,
                        sizeof(struct sbp2_status_block), sizeof(quadlet_t),
                        ud->ne->host->low_addr_space, CSR1212_ALL_SPACE_END);
-       if (scsi_id->status_fifo_addr == CSR1212_INVALID_ADDR_SPACE) {
+       if (lu->status_fifo_addr == CSR1212_INVALID_ADDR_SPACE) {
                SBP2_ERR("failed to allocate status FIFO address range");
                goto failed_alloc;
        }
 
-       /* Register our host with the SCSI stack. */
-       scsi_host = scsi_host_alloc(&scsi_driver_template,
-                                   sizeof(unsigned long));
-       if (!scsi_host) {
+       shost = scsi_host_alloc(&sbp2_shost_template, sizeof(unsigned long));
+       if (!shost) {
                SBP2_ERR("failed to register scsi host");
                goto failed_alloc;
        }
 
-       scsi_host->hostdata[0] = (unsigned long)scsi_id;
+       shost->hostdata[0] = (unsigned long)lu;
 
-       if (!scsi_add_host(scsi_host, &ud->device)) {
-               scsi_id->scsi_host = scsi_host;
-               return scsi_id;
+       if (!scsi_add_host(shost, &ud->device)) {
+               lu->shost = shost;
+               return lu;
        }
 
        SBP2_ERR("failed to add scsi host");
-       scsi_host_put(scsi_host);
+       scsi_host_put(shost);
 
 failed_alloc:
-       sbp2_remove_device(scsi_id);
+       sbp2_remove_device(lu);
        return NULL;
 }
 
 static void sbp2_host_reset(struct hpsb_host *host)
 {
-       struct sbp2scsi_host_info *hi;
-       struct scsi_id_instance_data *scsi_id;
+       struct sbp2_fwhost_info *hi;
+       struct sbp2_lu *lu;
 
        hi = hpsb_get_hostinfo(&sbp2_highlevel, host);
        if (!hi)
                return;
-       list_for_each_entry(scsi_id, &hi->scsi_ids, scsi_list)
-               if (likely(atomic_read(&scsi_id->state) !=
+       list_for_each_entry(lu, &hi->logical_units, lu_list)
+               if (likely(atomic_read(&lu->state) !=
                           SBP2LU_STATE_IN_SHUTDOWN)) {
-                       atomic_set(&scsi_id->state, SBP2LU_STATE_IN_RESET);
-                       scsi_block_requests(scsi_id->scsi_host);
+                       atomic_set(&lu->state, SBP2LU_STATE_IN_RESET);
+                       scsi_block_requests(lu->shost);
                }
 }
 
-/*
- * This function is where we first pull the node unique ids, and then
- * allocate memory and register a SBP-2 device.
- */
-static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
+static int sbp2_start_device(struct sbp2_lu *lu)
 {
-       struct sbp2scsi_host_info *hi = scsi_id->hi;
+       struct sbp2_fwhost_info *hi = lu->hi;
        int error;
 
-       SBP2_DEBUG_ENTER();
-
-       /* Login FIFO DMA */
-       scsi_id->login_response =
-               pci_alloc_consistent(hi->host->pdev,
+       lu->login_response = dma_alloc_coherent(&hi->host->device,
                                     sizeof(struct sbp2_login_response),
-                                    &scsi_id->login_response_dma);
-       if (!scsi_id->login_response)
+                                    &lu->login_response_dma, GFP_KERNEL);
+       if (!lu->login_response)
                goto alloc_fail;
-       SBP2_DMA_ALLOC("consistent DMA region for login FIFO");
 
-       /* Query logins ORB DMA */
-       scsi_id->query_logins_orb =
-               pci_alloc_consistent(hi->host->pdev,
+       lu->query_logins_orb = dma_alloc_coherent(&hi->host->device,
                                     sizeof(struct sbp2_query_logins_orb),
-                                    &scsi_id->query_logins_orb_dma);
-       if (!scsi_id->query_logins_orb)
+                                    &lu->query_logins_orb_dma, GFP_KERNEL);
+       if (!lu->query_logins_orb)
                goto alloc_fail;
-       SBP2_DMA_ALLOC("consistent DMA region for query logins ORB");
 
-       /* Query logins response DMA */
-       scsi_id->query_logins_response =
-               pci_alloc_consistent(hi->host->pdev,
+       lu->query_logins_response = dma_alloc_coherent(&hi->host->device,
                                     sizeof(struct sbp2_query_logins_response),
-                                    &scsi_id->query_logins_response_dma);
-       if (!scsi_id->query_logins_response)
+                                    &lu->query_logins_response_dma, GFP_KERNEL);
+       if (!lu->query_logins_response)
                goto alloc_fail;
-       SBP2_DMA_ALLOC("consistent DMA region for query logins response");
 
-       /* Reconnect ORB DMA */
-       scsi_id->reconnect_orb =
-               pci_alloc_consistent(hi->host->pdev,
+       lu->reconnect_orb = dma_alloc_coherent(&hi->host->device,
                                     sizeof(struct sbp2_reconnect_orb),
-                                    &scsi_id->reconnect_orb_dma);
-       if (!scsi_id->reconnect_orb)
+                                    &lu->reconnect_orb_dma, GFP_KERNEL);
+       if (!lu->reconnect_orb)
                goto alloc_fail;
-       SBP2_DMA_ALLOC("consistent DMA region for reconnect ORB");
 
-       /* Logout ORB DMA */
-       scsi_id->logout_orb =
-               pci_alloc_consistent(hi->host->pdev,
+       lu->logout_orb = dma_alloc_coherent(&hi->host->device,
                                     sizeof(struct sbp2_logout_orb),
-                                    &scsi_id->logout_orb_dma);
-       if (!scsi_id->logout_orb)
+                                    &lu->logout_orb_dma, GFP_KERNEL);
+       if (!lu->logout_orb)
                goto alloc_fail;
-       SBP2_DMA_ALLOC("consistent DMA region for logout ORB");
 
-       /* Login ORB DMA */
-       scsi_id->login_orb =
-               pci_alloc_consistent(hi->host->pdev,
+       lu->login_orb = dma_alloc_coherent(&hi->host->device,
                                     sizeof(struct sbp2_login_orb),
-                                    &scsi_id->login_orb_dma);
-       if (!scsi_id->login_orb)
+                                    &lu->login_orb_dma, GFP_KERNEL);
+       if (!lu->login_orb)
                goto alloc_fail;
-       SBP2_DMA_ALLOC("consistent DMA region for login ORB");
-
-       SBP2_DEBUG("New SBP-2 device inserted, SCSI ID = %x", scsi_id->ud->id);
 
-       /*
-        * Create our command orb pool
-        */
-       if (sbp2util_create_command_orb_pool(scsi_id)) {
+       if (sbp2util_create_command_orb_pool(lu)) {
                SBP2_ERR("sbp2util_create_command_orb_pool failed!");
-               sbp2_remove_device(scsi_id);
+               sbp2_remove_device(lu);
                return -ENOMEM;
        }
 
-       /* Schedule a timeout here. The reason is that we may be so close
-        * to a bus reset, that the device is not available for logins.
-        * This can happen when the bus reset is caused by the host
-        * connected to the sbp2 device being removed. That host would
-        * have a certain amount of time to relogin before the sbp2 device
-        * allows someone else to login instead. One second makes sense. */
+       /* Wait a second before trying to log in. Previously logged in
+        * initiators need a chance to reconnect. */
        if (msleep_interruptible(1000)) {
-               sbp2_remove_device(scsi_id);
+               sbp2_remove_device(lu);
                return -EINTR;
        }
 
-       /*
-        * Login to the sbp-2 device
-        */
-       if (sbp2_login_device(scsi_id)) {
-               /* Login failed, just remove the device. */
-               sbp2_remove_device(scsi_id);
+       if (sbp2_login_device(lu)) {
+               sbp2_remove_device(lu);
                return -EBUSY;
        }
 
-       /*
-        * Set max retries to something large on the device
-        */
-       sbp2_set_busy_timeout(scsi_id);
-
-       /*
-        * Do a SBP-2 fetch agent reset
-        */
-       sbp2_agent_reset(scsi_id, 1);
+       sbp2_set_busy_timeout(lu);
+       sbp2_agent_reset(lu, 1);
+       sbp2_max_speed_and_size(lu);
 
-       /*
-        * Get the max speed and packet size that we can use
-        */
-       sbp2_max_speed_and_size(scsi_id);
-
-       /* Add this device to the scsi layer now */
-       error = scsi_add_device(scsi_id->scsi_host, 0, scsi_id->ud->id, 0);
+       error = scsi_add_device(lu->shost, 0, lu->ud->id, 0);
        if (error) {
                SBP2_ERR("scsi_add_device failed");
-               sbp2_logout_device(scsi_id);
-               sbp2_remove_device(scsi_id);
+               sbp2_logout_device(lu);
+               sbp2_remove_device(lu);
                return error;
        }
 
        return 0;
 
 alloc_fail:
-       SBP2_ERR("Could not allocate memory for scsi_id");
-       sbp2_remove_device(scsi_id);
+       SBP2_ERR("Could not allocate memory for lu");
+       sbp2_remove_device(lu);
        return -ENOMEM;
 }
 
-/*
- * This function removes an sbp2 device from the sbp2scsi_host_info struct.
- */
-static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id)
+static void sbp2_remove_device(struct sbp2_lu *lu)
 {
-       struct sbp2scsi_host_info *hi;
-
-       SBP2_DEBUG_ENTER();
+       struct sbp2_fwhost_info *hi;
 
-       if (!scsi_id)
+       if (!lu)
                return;
 
-       hi = scsi_id->hi;
+       hi = lu->hi;
 
-       /* This will remove our scsi device aswell */
-       if (scsi_id->scsi_host) {
-               scsi_remove_host(scsi_id->scsi_host);
-               scsi_host_put(scsi_id->scsi_host);
+       if (lu->shost) {
+               scsi_remove_host(lu->shost);
+               scsi_host_put(lu->shost);
        }
        flush_scheduled_work();
-       sbp2util_remove_command_orb_pool(scsi_id);
+       sbp2util_remove_command_orb_pool(lu);
 
-       list_del(&scsi_id->scsi_list);
+       list_del(&lu->lu_list);
 
-       if (scsi_id->login_response) {
-               pci_free_consistent(hi->host->pdev,
+       if (lu->login_response)
+               dma_free_coherent(&hi->host->device,
                                    sizeof(struct sbp2_login_response),
-                                   scsi_id->login_response,
-                                   scsi_id->login_response_dma);
-               SBP2_DMA_FREE("single login FIFO");
-       }
-
-       if (scsi_id->login_orb) {
-               pci_free_consistent(hi->host->pdev,
+                                   lu->login_response,
+                                   lu->login_response_dma);
+       if (lu->login_orb)
+               dma_free_coherent(&hi->host->device,
                                    sizeof(struct sbp2_login_orb),
-                                   scsi_id->login_orb,
-                                   scsi_id->login_orb_dma);
-               SBP2_DMA_FREE("single login ORB");
-       }
-
-       if (scsi_id->reconnect_orb) {
-               pci_free_consistent(hi->host->pdev,
+                                   lu->login_orb,
+                                   lu->login_orb_dma);
+       if (lu->reconnect_orb)
+               dma_free_coherent(&hi->host->device,
                                    sizeof(struct sbp2_reconnect_orb),
-                                   scsi_id->reconnect_orb,
-                                   scsi_id->reconnect_orb_dma);
-               SBP2_DMA_FREE("single reconnect orb");
-       }
-
-       if (scsi_id->logout_orb) {
-               pci_free_consistent(hi->host->pdev,
+                                   lu->reconnect_orb,
+                                   lu->reconnect_orb_dma);
+       if (lu->logout_orb)
+               dma_free_coherent(&hi->host->device,
                                    sizeof(struct sbp2_logout_orb),
-                                   scsi_id->logout_orb,
-                                   scsi_id->logout_orb_dma);
-               SBP2_DMA_FREE("single logout orb");
-       }
-
-       if (scsi_id->query_logins_orb) {
-               pci_free_consistent(hi->host->pdev,
+                                   lu->logout_orb,
+                                   lu->logout_orb_dma);
+       if (lu->query_logins_orb)
+               dma_free_coherent(&hi->host->device,
                                    sizeof(struct sbp2_query_logins_orb),
-                                   scsi_id->query_logins_orb,
-                                   scsi_id->query_logins_orb_dma);
-               SBP2_DMA_FREE("single query logins orb");
-       }
-
-       if (scsi_id->query_logins_response) {
-               pci_free_consistent(hi->host->pdev,
+                                   lu->query_logins_orb,
+                                   lu->query_logins_orb_dma);
+       if (lu->query_logins_response)
+               dma_free_coherent(&hi->host->device,
                                    sizeof(struct sbp2_query_logins_response),
-                                   scsi_id->query_logins_response,
-                                   scsi_id->query_logins_response_dma);
-               SBP2_DMA_FREE("single query logins data");
-       }
+                                   lu->query_logins_response,
+                                   lu->query_logins_response_dma);
 
-       if (scsi_id->status_fifo_addr != CSR1212_INVALID_ADDR_SPACE)
+       if (lu->status_fifo_addr != CSR1212_INVALID_ADDR_SPACE)
                hpsb_unregister_addrspace(&sbp2_highlevel, hi->host,
-                                         scsi_id->status_fifo_addr);
+                                         lu->status_fifo_addr);
 
-       scsi_id->ud->device.driver_data = NULL;
+       lu->ud->device.driver_data = NULL;
 
        if (hi)
                module_put(hi->host->driver->owner);
 
-       SBP2_DEBUG("SBP-2 device removed, SCSI ID = %d", scsi_id->ud->id);
-
-       kfree(scsi_id);
+       kfree(lu);
 }
 
 #ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
 /*
- * This function deals with physical dma write requests (for adapters that do not support
- * physical dma in hardware). Mostly just here for debugging...
+ * Deal with write requests on adapters which do not support physical DMA or
+ * have it switched off.
  */
 static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid,
                                     int destid, quadlet_t *data, u64 addr,
                                     size_t length, u16 flags)
 {
-
-       /*
-        * Manually put the data in the right place.
-        */
        memcpy(bus_to_virt((u32) addr), data, length);
-       sbp2util_packet_dump(data, length, "sbp2 phys dma write by device",
-                            (u32) addr);
        return RCODE_COMPLETE;
 }
 
 /*
- * This function deals with physical dma read requests (for adapters that do not support
- * physical dma in hardware). Mostly just here for debugging...
+ * Deal with read requests on adapters which do not support physical DMA or
+ * have it switched off.
  */
 static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid,
                                    quadlet_t *data, u64 addr, size_t length,
                                    u16 flags)
 {
-
-       /*
-        * Grab data from memory and send a read response.
-        */
        memcpy(data, bus_to_virt((u32) addr), length);
-       sbp2util_packet_dump(data, length, "sbp2 phys dma read by device",
-                            (u32) addr);
        return RCODE_COMPLETE;
 }
 #endif
@@ -1197,74 +1001,69 @@ static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid,
  * SBP-2 protocol related section
  **************************************/
 
-/*
- * This function queries the device for the maximum concurrent logins it
- * supports.
- */
-static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
+static int sbp2_query_logins(struct sbp2_lu *lu)
 {
-       struct sbp2scsi_host_info *hi = scsi_id->hi;
+       struct sbp2_fwhost_info *hi = lu->hi;
        quadlet_t data[2];
        int max_logins;
        int active_logins;
 
-       SBP2_DEBUG_ENTER();
-
-       scsi_id->query_logins_orb->reserved1 = 0x0;
-       scsi_id->query_logins_orb->reserved2 = 0x0;
-
-       scsi_id->query_logins_orb->query_response_lo = scsi_id->query_logins_response_dma;
-       scsi_id->query_logins_orb->query_response_hi = ORB_SET_NODE_ID(hi->host->node_id);
+       lu->query_logins_orb->reserved1 = 0x0;
+       lu->query_logins_orb->reserved2 = 0x0;
 
-       scsi_id->query_logins_orb->lun_misc = ORB_SET_FUNCTION(SBP2_QUERY_LOGINS_REQUEST);
-       scsi_id->query_logins_orb->lun_misc |= ORB_SET_NOTIFY(1);
-       scsi_id->query_logins_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_lun);
+       lu->query_logins_orb->query_response_lo = lu->query_logins_response_dma;
+       lu->query_logins_orb->query_response_hi =
+                       ORB_SET_NODE_ID(hi->host->node_id);
+       lu->query_logins_orb->lun_misc =
+                       ORB_SET_FUNCTION(SBP2_QUERY_LOGINS_REQUEST);
+       lu->query_logins_orb->lun_misc |= ORB_SET_NOTIFY(1);
+       lu->query_logins_orb->lun_misc |= ORB_SET_LUN(lu->lun);
 
-       scsi_id->query_logins_orb->reserved_resp_length =
-               ORB_SET_QUERY_LOGINS_RESP_LENGTH(sizeof(struct sbp2_query_logins_response));
+       lu->query_logins_orb->reserved_resp_length =
+               ORB_SET_QUERY_LOGINS_RESP_LENGTH(
+                       sizeof(struct sbp2_query_logins_response));
 
-       scsi_id->query_logins_orb->status_fifo_hi =
-               ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id);
-       scsi_id->query_logins_orb->status_fifo_lo =
-               ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr);
+       lu->query_logins_orb->status_fifo_hi =
+               ORB_SET_STATUS_FIFO_HI(lu->status_fifo_addr, hi->host->node_id);
+       lu->query_logins_orb->status_fifo_lo =
+               ORB_SET_STATUS_FIFO_LO(lu->status_fifo_addr);
 
-       sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_orb, sizeof(struct sbp2_query_logins_orb));
+       sbp2util_cpu_to_be32_buffer(lu->query_logins_orb,
+                                   sizeof(struct sbp2_query_logins_orb));
 
-       sbp2util_packet_dump(scsi_id->query_logins_orb, sizeof(struct sbp2_query_logins_orb),
-                            "sbp2 query logins orb", scsi_id->query_logins_orb_dma);
-
-       memset(scsi_id->query_logins_response, 0, sizeof(struct sbp2_query_logins_response));
+       memset(lu->query_logins_response, 0,
+              sizeof(struct sbp2_query_logins_response));
 
        data[0] = ORB_SET_NODE_ID(hi->host->node_id);
-       data[1] = scsi_id->query_logins_orb_dma;
+       data[1] = lu->query_logins_orb_dma;
        sbp2util_cpu_to_be32_buffer(data, 8);
 
-       hpsb_node_write(scsi_id->ne, scsi_id->sbp2_management_agent_addr, data, 8);
+       hpsb_node_write(lu->ne, lu->management_agent_addr, data, 8);
 
-       if (sbp2util_access_timeout(scsi_id, 2*HZ)) {
+       if (sbp2util_access_timeout(lu, 2*HZ)) {
                SBP2_INFO("Error querying logins to SBP-2 device - timed out");
                return -EIO;
        }
 
-       if (scsi_id->status_block.ORB_offset_lo != scsi_id->query_logins_orb_dma) {
+       if (lu->status_block.ORB_offset_lo != lu->query_logins_orb_dma) {
                SBP2_INFO("Error querying logins to SBP-2 device - timed out");
                return -EIO;
        }
 
-       if (STATUS_TEST_RDS(scsi_id->status_block.ORB_offset_hi_misc)) {
+       if (STATUS_TEST_RDS(lu->status_block.ORB_offset_hi_misc)) {
                SBP2_INFO("Error querying logins to SBP-2 device - failed");
                return -EIO;
        }
 
-       sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_response, sizeof(struct sbp2_query_logins_response));
-
-       SBP2_DEBUG("length_max_logins = %x",
-                  (unsigned int)scsi_id->query_logins_response->length_max_logins);
+       sbp2util_cpu_to_be32_buffer(lu->query_logins_response,
+                                   sizeof(struct sbp2_query_logins_response));
 
-       max_logins = RESPONSE_GET_MAX_LOGINS(scsi_id->query_logins_response->length_max_logins);
+       max_logins = RESPONSE_GET_MAX_LOGINS(
+                       lu->query_logins_response->length_max_logins);
        SBP2_INFO("Maximum concurrent logins supported: %d", max_logins);
 
-       active_logins = RESPONSE_GET_ACTIVE_LOGINS(scsi_id->query_logins_response->length_max_logins);
+       active_logins = RESPONSE_GET_ACTIVE_LOGINS(
+                       lu->query_logins_response->length_max_logins);
        SBP2_INFO("Number of active logins: %d", active_logins);
 
        if (active_logins >= max_logins) {
@@ -1274,332 +1073,231 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
        return 0;
 }
 
-/*
- * This function is called in order to login to a particular SBP-2 device,
- * after a bus reset.
- */
-static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
+static int sbp2_login_device(struct sbp2_lu *lu)
 {
-       struct sbp2scsi_host_info *hi = scsi_id->hi;
+       struct sbp2_fwhost_info *hi = lu->hi;
        quadlet_t data[2];
 
-       SBP2_DEBUG_ENTER();
-
-       if (!scsi_id->login_orb) {
-               SBP2_DEBUG("%s: login_orb not alloc'd!", __FUNCTION__);
+       if (!lu->login_orb)
                return -EIO;
-       }
 
-       if (!exclusive_login) {
-               if (sbp2_query_logins(scsi_id)) {
-                       SBP2_INFO("Device does not support any more concurrent logins");
-                       return -EIO;
-               }
+       if (!sbp2_exclusive_login && sbp2_query_logins(lu)) {
+               SBP2_INFO("Device does not support any more concurrent logins");
+               return -EIO;
        }
 
-       /* Set-up login ORB, assume no password */
-       scsi_id->login_orb->password_hi = 0;
-       scsi_id->login_orb->password_lo = 0;
+       /* assume no password */
+       lu->login_orb->password_hi = 0;
+       lu->login_orb->password_lo = 0;
 
-       scsi_id->login_orb->login_response_lo = scsi_id->login_response_dma;
-       scsi_id->login_orb->login_response_hi = ORB_SET_NODE_ID(hi->host->node_id);
+       lu->login_orb->login_response_lo = lu->login_response_dma;
+       lu->login_orb->login_response_hi = ORB_SET_NODE_ID(hi->host->node_id);
+       lu->login_orb->lun_misc = ORB_SET_FUNCTION(SBP2_LOGIN_REQUEST);
 
-       scsi_id->login_orb->lun_misc = ORB_SET_FUNCTION(SBP2_LOGIN_REQUEST);
-       scsi_id->login_orb->lun_misc |= ORB_SET_RECONNECT(0);   /* One second reconnect time */
-       scsi_id->login_orb->lun_misc |= ORB_SET_EXCLUSIVE(exclusive_login);     /* Exclusive access to device */
-       scsi_id->login_orb->lun_misc |= ORB_SET_NOTIFY(1);      /* Notify us of login complete */
-       scsi_id->login_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_lun);
+       /* one second reconnect time */
+       lu->login_orb->lun_misc |= ORB_SET_RECONNECT(0);
+       lu->login_orb->lun_misc |= ORB_SET_EXCLUSIVE(sbp2_exclusive_login);
+       lu->login_orb->lun_misc |= ORB_SET_NOTIFY(1);
+       lu->login_orb->lun_misc |= ORB_SET_LUN(lu->lun);
 
-       scsi_id->login_orb->passwd_resp_lengths =
+       lu->login_orb->passwd_resp_lengths =
                ORB_SET_LOGIN_RESP_LENGTH(sizeof(struct sbp2_login_response));
 
-       scsi_id->login_orb->status_fifo_hi =
-               ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id);
-       scsi_id->login_orb->status_fifo_lo =
-               ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr);
+       lu->login_orb->status_fifo_hi =
+               ORB_SET_STATUS_FIFO_HI(lu->status_fifo_addr, hi->host->node_id);
+       lu->login_orb->status_fifo_lo =
+               ORB_SET_STATUS_FIFO_LO(lu->status_fifo_addr);
 
-       sbp2util_cpu_to_be32_buffer(scsi_id->login_orb, sizeof(struct sbp2_login_orb));
+       sbp2util_cpu_to_be32_buffer(lu->login_orb,
+                                   sizeof(struct sbp2_login_orb));
 
-       sbp2util_packet_dump(scsi_id->login_orb, sizeof(struct sbp2_login_orb),
-                            "sbp2 login orb", scsi_id->login_orb_dma);
-
-       memset(scsi_id->login_response, 0, sizeof(struct sbp2_login_response));
+       memset(lu->login_response, 0, sizeof(struct sbp2_login_response));
 
        data[0] = ORB_SET_NODE_ID(hi->host->node_id);
-       data[1] = scsi_id->login_orb_dma;
+       data[1] = lu->login_orb_dma;
        sbp2util_cpu_to_be32_buffer(data, 8);
 
-       hpsb_node_write(scsi_id->ne, scsi_id->sbp2_management_agent_addr, data, 8);
+       hpsb_node_write(lu->ne, lu->management_agent_addr, data, 8);
 
-       /*
-        * Wait for login status (up to 20 seconds)...
-        */
-       if (sbp2util_access_timeout(scsi_id, 20*HZ)) {
+       /* wait up to 20 seconds for login status */
+       if (sbp2util_access_timeout(lu, 20*HZ)) {
                SBP2_ERR("Error logging into SBP-2 device - timed out");
                return -EIO;
        }
 
-       /*
-        * Sanity. Make sure status returned matches login orb.
-        */
-       if (scsi_id->status_block.ORB_offset_lo != scsi_id->login_orb_dma) {
+       /* make sure that the returned status matches the login ORB */
+       if (lu->status_block.ORB_offset_lo != lu->login_orb_dma) {
                SBP2_ERR("Error logging into SBP-2 device - timed out");
                return -EIO;
        }
 
-       if (STATUS_TEST_RDS(scsi_id->status_block.ORB_offset_hi_misc)) {
+       if (STATUS_TEST_RDS(lu->status_block.ORB_offset_hi_misc)) {
                SBP2_ERR("Error logging into SBP-2 device - failed");
                return -EIO;
        }
 
-       /*
-        * Byte swap the login response, for use when reconnecting or
-        * logging out.
-        */
-       sbp2util_cpu_to_be32_buffer(scsi_id->login_response, sizeof(struct sbp2_login_response));
-
-       /*
-        * Grab our command block agent address from the login response.
-        */
-       SBP2_DEBUG("command_block_agent_hi = %x",
-                  (unsigned int)scsi_id->login_response->command_block_agent_hi);
-       SBP2_DEBUG("command_block_agent_lo = %x",
-                  (unsigned int)scsi_id->login_response->command_block_agent_lo);
-
-       scsi_id->sbp2_command_block_agent_addr =
-               ((u64)scsi_id->login_response->command_block_agent_hi) << 32;
-       scsi_id->sbp2_command_block_agent_addr |= ((u64)scsi_id->login_response->command_block_agent_lo);
-       scsi_id->sbp2_command_block_agent_addr &= 0x0000ffffffffffffULL;
+       sbp2util_cpu_to_be32_buffer(lu->login_response,
+                                   sizeof(struct sbp2_login_response));
+       lu->command_block_agent_addr =
+                       ((u64)lu->login_response->command_block_agent_hi) << 32;
+       lu->command_block_agent_addr |=
+                       ((u64)lu->login_response->command_block_agent_lo);
+       lu->command_block_agent_addr &= 0x0000ffffffffffffULL;
 
        SBP2_INFO("Logged into SBP-2 device");
        return 0;
 }
 
-/*
- * This function is called in order to logout from a particular SBP-2
- * device, usually called during driver unload.
- */
-static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id)
+static int sbp2_logout_device(struct sbp2_lu *lu)
 {
-       struct sbp2scsi_host_info *hi = scsi_id->hi;
+       struct sbp2_fwhost_info *hi = lu->hi;
        quadlet_t data[2];
        int error;
 
-       SBP2_DEBUG_ENTER();
-
-       /*
-        * Set-up logout ORB
-        */
-       scsi_id->logout_orb->reserved1 = 0x0;
-       scsi_id->logout_orb->reserved2 = 0x0;
-       scsi_id->logout_orb->reserved3 = 0x0;
-       scsi_id->logout_orb->reserved4 = 0x0;
-
-       scsi_id->logout_orb->login_ID_misc = ORB_SET_FUNCTION(SBP2_LOGOUT_REQUEST);
-       scsi_id->logout_orb->login_ID_misc |= ORB_SET_LOGIN_ID(scsi_id->login_response->length_login_ID);
-
-       /* Notify us when complete */
-       scsi_id->logout_orb->login_ID_misc |= ORB_SET_NOTIFY(1);
+       lu->logout_orb->reserved1 = 0x0;
+       lu->logout_orb->reserved2 = 0x0;
+       lu->logout_orb->reserved3 = 0x0;
+       lu->logout_orb->reserved4 = 0x0;
 
-       scsi_id->logout_orb->reserved5 = 0x0;
-       scsi_id->logout_orb->status_fifo_hi =
-               ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id);
-       scsi_id->logout_orb->status_fifo_lo =
-               ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr);
+       lu->logout_orb->login_ID_misc = ORB_SET_FUNCTION(SBP2_LOGOUT_REQUEST);
+       lu->logout_orb->login_ID_misc |=
+                       ORB_SET_LOGIN_ID(lu->login_response->length_login_ID);
+       lu->logout_orb->login_ID_misc |= ORB_SET_NOTIFY(1);
 
-       /*
-        * Byte swap ORB if necessary
-        */
-       sbp2util_cpu_to_be32_buffer(scsi_id->logout_orb, sizeof(struct sbp2_logout_orb));
+       lu->logout_orb->reserved5 = 0x0;
+       lu->logout_orb->status_fifo_hi =
+               ORB_SET_STATUS_FIFO_HI(lu->status_fifo_addr, hi->host->node_id);
+       lu->logout_orb->status_fifo_lo =
+               ORB_SET_STATUS_FIFO_LO(lu->status_fifo_addr);
 
-       sbp2util_packet_dump(scsi_id->logout_orb, sizeof(struct sbp2_logout_orb),
-                            "sbp2 logout orb", scsi_id->logout_orb_dma);
+       sbp2util_cpu_to_be32_buffer(lu->logout_orb,
+                                   sizeof(struct sbp2_logout_orb));
 
-       /*
-        * Ok, let's write to the target's management agent register
-        */
        data[0] = ORB_SET_NODE_ID(hi->host->node_id);
-       data[1] = scsi_id->logout_orb_dma;
+       data[1] = lu->logout_orb_dma;
        sbp2util_cpu_to_be32_buffer(data, 8);
 
-       error = hpsb_node_write(scsi_id->ne,
-                               scsi_id->sbp2_management_agent_addr, data, 8);
+       error = hpsb_node_write(lu->ne, lu->management_agent_addr, data, 8);
        if (error)
                return error;
 
-       /* Wait for device to logout...1 second. */
-       if (sbp2util_access_timeout(scsi_id, HZ))
+       /* wait up to 1 second for the device to complete logout */
+       if (sbp2util_access_timeout(lu, HZ))
                return -EIO;
 
        SBP2_INFO("Logged out of SBP-2 device");
        return 0;
 }
 
-/*
- * This function is called in order to reconnect to a particular SBP-2
- * device, after a bus reset.
- */
-static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
+static int sbp2_reconnect_device(struct sbp2_lu *lu)
 {
-       struct sbp2scsi_host_info *hi = scsi_id->hi;
+       struct sbp2_fwhost_info *hi = lu->hi;
        quadlet_t data[2];
        int error;
 
-       SBP2_DEBUG_ENTER();
+       lu->reconnect_orb->reserved1 = 0x0;
+       lu->reconnect_orb->reserved2 = 0x0;
+       lu->reconnect_orb->reserved3 = 0x0;
+       lu->reconnect_orb->reserved4 = 0x0;
 
-       /*
-        * Set-up reconnect ORB
-        */
-       scsi_id->reconnect_orb->reserved1 = 0x0;
-       scsi_id->reconnect_orb->reserved2 = 0x0;
-       scsi_id->reconnect_orb->reserved3 = 0x0;
-       scsi_id->reconnect_orb->reserved4 = 0x0;
-
-       scsi_id->reconnect_orb->login_ID_misc = ORB_SET_FUNCTION(SBP2_RECONNECT_REQUEST);
-       scsi_id->reconnect_orb->login_ID_misc |=
-               ORB_SET_LOGIN_ID(scsi_id->login_response->length_login_ID);
+       lu->reconnect_orb->login_ID_misc =
+                       ORB_SET_FUNCTION(SBP2_RECONNECT_REQUEST);
+       lu->reconnect_orb->login_ID_misc |=
+                       ORB_SET_LOGIN_ID(lu->login_response->length_login_ID);
+       lu->reconnect_orb->login_ID_misc |= ORB_SET_NOTIFY(1);
 
-       /* Notify us when complete */
-       scsi_id->reconnect_orb->login_ID_misc |= ORB_SET_NOTIFY(1);
+       lu->reconnect_orb->reserved5 = 0x0;
+       lu->reconnect_orb->status_fifo_hi =
+               ORB_SET_STATUS_FIFO_HI(lu->status_fifo_addr, hi->host->node_id);
+       lu->reconnect_orb->status_fifo_lo =
+               ORB_SET_STATUS_FIFO_LO(lu->status_fifo_addr);
 
-       scsi_id->reconnect_orb->reserved5 = 0x0;
-       scsi_id->reconnect_orb->status_fifo_hi =
-               ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id);
-       scsi_id->reconnect_orb->status_fifo_lo =
-               ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr);
-
-       /*
-        * Byte swap ORB if necessary
-        */
-       sbp2util_cpu_to_be32_buffer(scsi_id->reconnect_orb, sizeof(struct sbp2_reconnect_orb));
-
-       sbp2util_packet_dump(scsi_id->reconnect_orb, sizeof(struct sbp2_reconnect_orb),
-                            "sbp2 reconnect orb", scsi_id->reconnect_orb_dma);
+       sbp2util_cpu_to_be32_buffer(lu->reconnect_orb,
+                                   sizeof(struct sbp2_reconnect_orb));
 
        data[0] = ORB_SET_NODE_ID(hi->host->node_id);
-       data[1] = scsi_id->reconnect_orb_dma;
+       data[1] = lu->reconnect_orb_dma;
        sbp2util_cpu_to_be32_buffer(data, 8);
 
-       error = hpsb_node_write(scsi_id->ne,
-                               scsi_id->sbp2_management_agent_addr, data, 8);
+       error = hpsb_node_write(lu->ne, lu->management_agent_addr, data, 8);
        if (error)
                return error;
 
-       /*
-        * Wait for reconnect status (up to 1 second)...
-        */
-       if (sbp2util_access_timeout(scsi_id, HZ)) {
+       /* wait up to 1 second for reconnect status */
+       if (sbp2util_access_timeout(lu, HZ)) {
                SBP2_ERR("Error reconnecting to SBP-2 device - timed out");
                return -EIO;
        }
 
-       /*
-        * Sanity. Make sure status returned matches reconnect orb.
-        */
-       if (scsi_id->status_block.ORB_offset_lo != scsi_id->reconnect_orb_dma) {
+       /* make sure that the returned status matches the reconnect ORB */
+       if (lu->status_block.ORB_offset_lo != lu->reconnect_orb_dma) {
                SBP2_ERR("Error reconnecting to SBP-2 device - timed out");
                return -EIO;
        }
 
-       if (STATUS_TEST_RDS(scsi_id->status_block.ORB_offset_hi_misc)) {
+       if (STATUS_TEST_RDS(lu->status_block.ORB_offset_hi_misc)) {
                SBP2_ERR("Error reconnecting to SBP-2 device - failed");
                return -EIO;
        }
 
-       HPSB_DEBUG("Reconnected to SBP-2 device");
+       SBP2_INFO("Reconnected to SBP-2 device");
        return 0;
 }
 
 /*
- * This function is called in order to set the busy timeout (number of
- * retries to attempt) on the sbp2 device.
+ * Set the target node's Single Phase Retry limit. Affects the target's retry
+ * behaviour if our node is too busy to accept requests.
  */
-static int sbp2_set_busy_timeout(struct scsi_id_instance_data *scsi_id)
+static int sbp2_set_busy_timeout(struct sbp2_lu *lu)
 {
        quadlet_t data;
 
-       SBP2_DEBUG_ENTER();
-
        data = cpu_to_be32(SBP2_BUSY_TIMEOUT_VALUE);
-       if (hpsb_node_write(scsi_id->ne, SBP2_BUSY_TIMEOUT_ADDRESS, &data, 4))
+       if (hpsb_node_write(lu->ne, SBP2_BUSY_TIMEOUT_ADDRESS, &data, 4))
                SBP2_ERR("%s error", __FUNCTION__);
        return 0;
 }
 
-/*
- * This function is called to parse sbp2 device's config rom unit
- * directory. Used to determine things like sbp2 management agent offset,
- * and command set used (SCSI or RBC).
- */
-static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
+static void sbp2_parse_unit_directory(struct sbp2_lu *lu,
                                      struct unit_directory *ud)
 {
        struct csr1212_keyval *kv;
        struct csr1212_dentry *dentry;
        u64 management_agent_addr;
-       u32 command_set_spec_id, command_set, unit_characteristics,
-           firmware_revision;
+       u32 unit_characteristics, firmware_revision;
        unsigned workarounds;
        int i;
 
-       SBP2_DEBUG_ENTER();
+       management_agent_addr = 0;
+       unit_characteristics = 0;
+       firmware_revision = 0;
 
-       management_agent_addr = 0x0;
-       command_set_spec_id = 0x0;
-       command_set = 0x0;
-       unit_characteristics = 0x0;
-       firmware_revision = 0x0;
-
-       /* Handle different fields in the unit directory, based on keys */
        csr1212_for_each_dir_entry(ud->ne->csr, kv, ud->ud_kv, dentry) {
                switch (kv->key.id) {
                case CSR1212_KV_ID_DEPENDENT_INFO:
-                       if (kv->key.type == CSR1212_KV_TYPE_CSR_OFFSET) {
-                               /* Save off the management agent address */
+                       if (kv->key.type == CSR1212_KV_TYPE_CSR_OFFSET)
                                management_agent_addr =
                                    CSR1212_REGISTER_SPACE_BASE +
                                    (kv->value.csr_offset << 2);
 
-                               SBP2_DEBUG("sbp2_management_agent_addr = %x",
-                                          (unsigned int)management_agent_addr);
-                       } else if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) {
-                               scsi_id->sbp2_lun =
-                                   ORB_SET_LUN(kv->value.immediate);
-                       }
-                       break;
-
-               case SBP2_COMMAND_SET_SPEC_ID_KEY:
-                       /* Command spec organization */
-                       command_set_spec_id = kv->value.immediate;
-                       SBP2_DEBUG("sbp2_command_set_spec_id = %x",
-                                  (unsigned int)command_set_spec_id);
-                       break;
-
-               case SBP2_COMMAND_SET_KEY:
-                       /* Command set used by sbp2 device */
-                       command_set = kv->value.immediate;
-                       SBP2_DEBUG("sbp2_command_set = %x",
-                                  (unsigned int)command_set);
+                       else if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE)
+                               lu->lun = ORB_SET_LUN(kv->value.immediate);
                        break;
 
                case SBP2_UNIT_CHARACTERISTICS_KEY:
-                       /*
-                        * Unit characterisitcs (orb related stuff
-                        * that I'm not yet paying attention to)
-                        */
+                       /* FIXME: This is ignored so far.
+                        * See SBP-2 clause 7.4.8. */
                        unit_characteristics = kv->value.immediate;
-                       SBP2_DEBUG("sbp2_unit_characteristics = %x",
-                                  (unsigned int)unit_characteristics);
                        break;
 
                case SBP2_FIRMWARE_REVISION_KEY:
-                       /* Firmware revision */
                        firmware_revision = kv->value.immediate;
-                       SBP2_DEBUG("sbp2_firmware_revision = %x",
-                                  (unsigned int)firmware_revision);
                        break;
 
                default:
+                       /* FIXME: Check for SBP2_DEVICE_TYPE_AND_LUN_KEY.
+                        * Its "ordered" bit has consequences for command ORB
+                        * list handling. See SBP-2 clauses 4.6, 7.4.11, 10.2 */
                        break;
                }
        }
@@ -1631,28 +1329,24 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
        /* We would need one SCSI host template for each target to adjust
         * max_sectors on the fly, therefore warn only. */
        if (workarounds & SBP2_WORKAROUND_128K_MAX_TRANS &&
-           (max_sectors * 512) > (128 * 1024))
-               SBP2_WARN("Node " NODE_BUS_FMT ": Bridge only supports 128KB "
+           (sbp2_max_sectors * 512) > (128 * 1024))
+               SBP2_INFO("Node " NODE_BUS_FMT ": Bridge only supports 128KB "
                          "max transfer size. WARNING: Current max_sectors "
                          "setting is larger than 128KB (%d sectors)",
                          NODE_BUS_ARGS(ud->ne->host, ud->ne->nodeid),
-                         max_sectors);
+                         sbp2_max_sectors);
 
        /* If this is a logical unit directory entry, process the parent
         * to get the values. */
        if (ud->flags & UNIT_DIRECTORY_LUN_DIRECTORY) {
-               struct unit_directory *parent_ud =
-                       container_of(ud->device.parent, struct unit_directory, device);
-               sbp2_parse_unit_directory(scsi_id, parent_ud);
+               struct unit_directory *parent_ud = container_of(
+                       ud->device.parent, struct unit_directory, device);
+               sbp2_parse_unit_directory(lu, parent_ud);
        } else {
-               scsi_id->sbp2_management_agent_addr = management_agent_addr;
-               scsi_id->sbp2_command_set_spec_id = command_set_spec_id;
-               scsi_id->sbp2_command_set = command_set;
-               scsi_id->sbp2_unit_characteristics = unit_characteristics;
-               scsi_id->sbp2_firmware_revision = firmware_revision;
-               scsi_id->workarounds = workarounds;
+               lu->management_agent_addr = management_agent_addr;
+               lu->workarounds = workarounds;
                if (ud->flags & UNIT_DIRECTORY_HAS_LUN)
-                       scsi_id->sbp2_lun = ORB_SET_LUN(ud->lun);
+                       lu->lun = ORB_SET_LUN(ud->lun);
        }
 }
 
@@ -1667,133 +1361,114 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
  * the speed that it needs to use, and the max_rec the host supports, and
  * it takes care of the rest.
  */
-static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id)
+static int sbp2_max_speed_and_size(struct sbp2_lu *lu)
 {
-       struct sbp2scsi_host_info *hi = scsi_id->hi;
+       struct sbp2_fwhost_info *hi = lu->hi;
        u8 payload;
 
-       SBP2_DEBUG_ENTER();
-
-       scsi_id->speed_code =
-           hi->host->speed[NODEID_TO_NODE(scsi_id->ne->nodeid)];
+       lu->speed_code = hi->host->speed[NODEID_TO_NODE(lu->ne->nodeid)];
 
-       /* Bump down our speed if the user requested it */
-       if (scsi_id->speed_code > max_speed) {
-               scsi_id->speed_code = max_speed;
-               SBP2_ERR("Forcing SBP-2 max speed down to %s",
-                        hpsb_speedto_str[scsi_id->speed_code]);
+       if (lu->speed_code > sbp2_max_speed) {
+               lu->speed_code = sbp2_max_speed;
+               SBP2_INFO("Reducing speed to %s",
+                         hpsb_speedto_str[sbp2_max_speed]);
        }
 
        /* Payload size is the lesser of what our speed supports and what
         * our host supports.  */
-       payload = min(sbp2_speedto_max_payload[scsi_id->speed_code],
+       payload = min(sbp2_speedto_max_payload[lu->speed_code],
                      (u8) (hi->host->csr.max_rec - 1));
 
        /* If physical DMA is off, work around limitation in ohci1394:
         * packet size must not exceed PAGE_SIZE */
-       if (scsi_id->ne->host->low_addr_space < (1ULL << 32))
+       if (lu->ne->host->low_addr_space < (1ULL << 32))
                while (SBP2_PAYLOAD_TO_BYTES(payload) + 24 > PAGE_SIZE &&
                       payload)
                        payload--;
 
-       HPSB_DEBUG("Node " NODE_BUS_FMT ": Max speed [%s] - Max payload [%u]",
-                  NODE_BUS_ARGS(hi->host, scsi_id->ne->nodeid),
-                  hpsb_speedto_str[scsi_id->speed_code],
-                  SBP2_PAYLOAD_TO_BYTES(payload));
+       SBP2_INFO("Node " NODE_BUS_FMT ": Max speed [%s] - Max payload [%u]",
+                 NODE_BUS_ARGS(hi->host, lu->ne->nodeid),
+                 hpsb_speedto_str[lu->speed_code],
+                 SBP2_PAYLOAD_TO_BYTES(payload));
 
-       scsi_id->max_payload_size = payload;
+       lu->max_payload_size = payload;
        return 0;
 }
 
-/*
- * This function is called in order to perform a SBP-2 agent reset.
- */
-static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait)
+static int sbp2_agent_reset(struct sbp2_lu *lu, int wait)
 {
        quadlet_t data;
        u64 addr;
        int retval;
        unsigned long flags;
 
-       SBP2_DEBUG_ENTER();
-
-       cancel_delayed_work(&scsi_id->protocol_work);
+       /* flush lu->protocol_work */
        if (wait)
                flush_scheduled_work();
 
        data = ntohl(SBP2_AGENT_RESET_DATA);
-       addr = scsi_id->sbp2_command_block_agent_addr + SBP2_AGENT_RESET_OFFSET;
+       addr = lu->command_block_agent_addr + SBP2_AGENT_RESET_OFFSET;
 
        if (wait)
-               retval = hpsb_node_write(scsi_id->ne, addr, &data, 4);
+               retval = hpsb_node_write(lu->ne, addr, &data, 4);
        else
-               retval = sbp2util_node_write_no_wait(scsi_id->ne, addr, &data, 4);
+               retval = sbp2util_node_write_no_wait(lu->ne, addr, &data, 4);
 
        if (retval < 0) {
                SBP2_ERR("hpsb_node_write failed.\n");
                return -EIO;
        }
 
-       /*
-        * Need to make sure orb pointer is written on next command
-        */
-       spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags);
-       scsi_id->last_orb = NULL;
-       spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
+       /* make sure that the ORB_POINTER is written on next command */
+       spin_lock_irqsave(&lu->cmd_orb_lock, flags);
+       lu->last_orb = NULL;
+       spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
 
        return 0;
 }
 
 static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
-                                    struct sbp2scsi_host_info *hi,
-                                    struct sbp2_command_info *command,
+                                    struct sbp2_fwhost_info *hi,
+                                    struct sbp2_command_info *cmd,
                                     unsigned int scsi_use_sg,
                                     struct scatterlist *sgpnt,
                                     u32 orb_direction,
                                     enum dma_data_direction dma_dir)
 {
-       command->dma_dir = dma_dir;
+       cmd->dma_dir = dma_dir;
        orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id);
        orb->misc |= ORB_SET_DIRECTION(orb_direction);
 
-       /* Special case if only one element (and less than 64KB in size) */
+       /* special case if only one element (and less than 64KB in size) */
        if ((scsi_use_sg == 1) &&
            (sgpnt[0].length <= SBP2_MAX_SG_ELEMENT_LENGTH)) {
 
-               SBP2_DEBUG("Only one s/g element");
-               command->dma_size = sgpnt[0].length;
-               command->dma_type = CMD_DMA_PAGE;
-               command->cmd_dma = pci_map_page(hi->host->pdev,
-                                               sgpnt[0].page,
-                                               sgpnt[0].offset,
-                                               command->dma_size,
-                                               command->dma_dir);
-               SBP2_DMA_ALLOC("single page scatter element");
+               cmd->dma_size = sgpnt[0].length;
+               cmd->dma_type = CMD_DMA_PAGE;
+               cmd->cmd_dma = dma_map_page(&hi->host->device,
+                                           sgpnt[0].page, sgpnt[0].offset,
+                                           cmd->dma_size, cmd->dma_dir);
 
-               orb->data_descriptor_lo = command->cmd_dma;
-               orb->misc |= ORB_SET_DATA_SIZE(command->dma_size);
+               orb->data_descriptor_lo = cmd->cmd_dma;
+               orb->misc |= ORB_SET_DATA_SIZE(cmd->dma_size);
 
        } else {
                struct sbp2_unrestricted_page_table *sg_element =
-                                       &command->scatter_gather_element[0];
+                                               &cmd->scatter_gather_element[0];
                u32 sg_count, sg_len;
                dma_addr_t sg_addr;
-               int i, count = pci_map_sg(hi->host->pdev, sgpnt, scsi_use_sg,
+               int i, count = dma_map_sg(&hi->host->device, sgpnt, scsi_use_sg,
                                          dma_dir);
 
-               SBP2_DMA_ALLOC("scatter list");
-
-               command->dma_size = scsi_use_sg;
-               command->sge_buffer = sgpnt;
+               cmd->dma_size = scsi_use_sg;
+               cmd->sge_buffer = sgpnt;
 
                /* use page tables (s/g) */
                orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1);
-               orb->data_descriptor_lo = command->sge_dma;
+               orb->data_descriptor_lo = cmd->sge_dma;
 
-               /*
-                * Loop through and fill out our sbp-2 page tables
-                * (and split up anything too large)
-                */
+               /* loop through and fill out our SBP-2 page tables
+                * (and split up anything too large) */
                for (i = 0, sg_count = 0 ; i < count; i++, sgpnt++) {
                        sg_len = sg_dma_len(sgpnt);
                        sg_addr = sg_dma_address(sgpnt);
@@ -1813,70 +1488,53 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
                        }
                }
 
-               /* Number of page table (s/g) elements */
                orb->misc |= ORB_SET_DATA_SIZE(sg_count);
 
-               sbp2util_packet_dump(sg_element,
-                                    (sizeof(struct sbp2_unrestricted_page_table)) * sg_count,
-                                    "sbp2 s/g list", command->sge_dma);
-
-               /* Byte swap page tables if necessary */
                sbp2util_cpu_to_be32_buffer(sg_element,
-                                           (sizeof(struct sbp2_unrestricted_page_table)) *
-                                           sg_count);
+                               (sizeof(struct sbp2_unrestricted_page_table)) *
+                               sg_count);
        }
 }
 
 static void sbp2_prep_command_orb_no_sg(struct sbp2_command_orb *orb,
-                                       struct sbp2scsi_host_info *hi,
-                                       struct sbp2_command_info *command,
+                                       struct sbp2_fwhost_info *hi,
+                                       struct sbp2_command_info *cmd,
                                        struct scatterlist *sgpnt,
                                        u32 orb_direction,
                                        unsigned int scsi_request_bufflen,
                                        void *scsi_request_buffer,
                                        enum dma_data_direction dma_dir)
 {
-       command->dma_dir = dma_dir;
-       command->dma_size = scsi_request_bufflen;
-       command->dma_type = CMD_DMA_SINGLE;
-       command->cmd_dma = pci_map_single(hi->host->pdev, scsi_request_buffer,
-                                         command->dma_size, command->dma_dir);
+       cmd->dma_dir = dma_dir;
+       cmd->dma_size = scsi_request_bufflen;
+       cmd->dma_type = CMD_DMA_SINGLE;
+       cmd->cmd_dma = dma_map_single(&hi->host->device, scsi_request_buffer,
+                                     cmd->dma_size, cmd->dma_dir);
        orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id);
        orb->misc |= ORB_SET_DIRECTION(orb_direction);
 
-       SBP2_DMA_ALLOC("single bulk");
-
-       /*
-        * Handle case where we get a command w/o s/g enabled (but
-        * check for transfers larger than 64K)
-        */
+       /* handle case where we get a command w/o s/g enabled
+        * (but check for transfers larger than 64K) */
        if (scsi_request_bufflen <= SBP2_MAX_SG_ELEMENT_LENGTH) {
 
-               orb->data_descriptor_lo = command->cmd_dma;
+               orb->data_descriptor_lo = cmd->cmd_dma;
                orb->misc |= ORB_SET_DATA_SIZE(scsi_request_bufflen);
 
        } else {
+               /* The buffer is too large. Turn this into page tables. */
+
                struct sbp2_unrestricted_page_table *sg_element =
-                       &command->scatter_gather_element[0];
+                                               &cmd->scatter_gather_element[0];
                u32 sg_count, sg_len;
                dma_addr_t sg_addr;
 
-               /*
-                * Need to turn this into page tables, since the
-                * buffer is too large.
-                */
-               orb->data_descriptor_lo = command->sge_dma;
-
-               /* Use page tables (s/g) */
+               orb->data_descriptor_lo = cmd->sge_dma;
                orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1);
 
-               /*
-                * fill out our sbp-2 page tables (and split up
-                * the large buffer)
-                */
+               /* fill out our SBP-2 page tables; split up the large buffer */
                sg_count = 0;
                sg_len = scsi_request_bufflen;
-               sg_addr = command->cmd_dma;
+               sg_addr = cmd->cmd_dma;
                while (sg_len) {
                        sg_element[sg_count].segment_base_lo = sg_addr;
                        if (sg_len > SBP2_MAX_SG_ELEMENT_LENGTH) {
@@ -1892,50 +1550,40 @@ static void sbp2_prep_command_orb_no_sg(struct sbp2_command_orb *orb,
                        sg_count++;
                }
 
-               /* Number of page table (s/g) elements */
                orb->misc |= ORB_SET_DATA_SIZE(sg_count);
 
-               sbp2util_packet_dump(sg_element,
-                                    (sizeof(struct sbp2_unrestricted_page_table)) * sg_count,
-                                    "sbp2 s/g list", command->sge_dma);
-
-               /* Byte swap page tables if necessary */
                sbp2util_cpu_to_be32_buffer(sg_element,
-                                           (sizeof(struct sbp2_unrestricted_page_table)) *
-                                            sg_count);
+                               (sizeof(struct sbp2_unrestricted_page_table)) *
+                               sg_count);
        }
 }
 
-/*
- * This function is called to create the actual command orb and s/g list
- * out of the scsi command itself.
- */
-static void sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
-                                   struct sbp2_command_info *command,
+static void sbp2_create_command_orb(struct sbp2_lu *lu,
+                                   struct sbp2_command_info *cmd,
                                    unchar *scsi_cmd,
                                    unsigned int scsi_use_sg,
                                    unsigned int scsi_request_bufflen,
                                    void *scsi_request_buffer,
                                    enum dma_data_direction dma_dir)
 {
-       struct sbp2scsi_host_info *hi = scsi_id->hi;
+       struct sbp2_fwhost_info *hi = lu->hi;
        struct scatterlist *sgpnt = (struct scatterlist *)scsi_request_buffer;
-       struct sbp2_command_orb *command_orb = &command->command_orb;
+       struct sbp2_command_orb *orb = &cmd->command_orb;
        u32 orb_direction;
 
        /*
-        * Set-up our command ORB..
+        * Set-up our command ORB.
         *
         * NOTE: We're doing unrestricted page tables (s/g), as this is
         * best performance (at least with the devices I have). This means
         * that data_size becomes the number of s/g elements, and
         * page_size should be zero (for unrestricted).
         */
-       command_orb->next_ORB_hi = ORB_SET_NULL_PTR(1);
-       command_orb->next_ORB_lo = 0x0;
-       command_orb->misc = ORB_SET_MAX_PAYLOAD(scsi_id->max_payload_size);
-       command_orb->misc |= ORB_SET_SPEED(scsi_id->speed_code);
-       command_orb->misc |= ORB_SET_NOTIFY(1); /* Notify us when complete */
+       orb->next_ORB_hi = ORB_SET_NULL_PTR(1);
+       orb->next_ORB_lo = 0x0;
+       orb->misc = ORB_SET_MAX_PAYLOAD(lu->max_payload_size);
+       orb->misc |= ORB_SET_SPEED(lu->speed_code);
+       orb->misc |= ORB_SET_NOTIFY(1);
 
        if (dma_dir == DMA_NONE)
                orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER;
@@ -1944,66 +1592,51 @@ static void sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
        else if (dma_dir == DMA_FROM_DEVICE && scsi_request_bufflen)
                orb_direction = ORB_DIRECTION_READ_FROM_MEDIA;
        else {
-               SBP2_WARN("Falling back to DMA_NONE");
+               SBP2_INFO("Falling back to DMA_NONE");
                orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER;
        }
 
-       /* Set-up our pagetable stuff */
+       /* set up our page table stuff */
        if (orb_direction == ORB_DIRECTION_NO_DATA_TRANSFER) {
-               SBP2_DEBUG("No data transfer");
-               command_orb->data_descriptor_hi = 0x0;
-               command_orb->data_descriptor_lo = 0x0;
-               command_orb->misc |= ORB_SET_DIRECTION(1);
-       } else if (scsi_use_sg) {
-               SBP2_DEBUG("Use scatter/gather");
-               sbp2_prep_command_orb_sg(command_orb, hi, command, scsi_use_sg,
-                                        sgpnt, orb_direction, dma_dir);
-       } else {
-               SBP2_DEBUG("No scatter/gather");
-               sbp2_prep_command_orb_no_sg(command_orb, hi, command, sgpnt,
-                                           orb_direction, scsi_request_bufflen,
+               orb->data_descriptor_hi = 0x0;
+               orb->data_descriptor_lo = 0x0;
+               orb->misc |= ORB_SET_DIRECTION(1);
+       } else if (scsi_use_sg)
+               sbp2_prep_command_orb_sg(orb, hi, cmd, scsi_use_sg, sgpnt,
+                                        orb_direction, dma_dir);
+       else
+               sbp2_prep_command_orb_no_sg(orb, hi, cmd, sgpnt, orb_direction,
+                                           scsi_request_bufflen,
                                            scsi_request_buffer, dma_dir);
-       }
 
-       /* Byte swap command ORB if necessary */
-       sbp2util_cpu_to_be32_buffer(command_orb, sizeof(struct sbp2_command_orb));
+       sbp2util_cpu_to_be32_buffer(orb, sizeof(*orb));
 
-       /* Put our scsi command in the command ORB */
-       memset(command_orb->cdb, 0, 12);
-       memcpy(command_orb->cdb, scsi_cmd, COMMAND_SIZE(*scsi_cmd));
+       memset(orb->cdb, 0, 12);
+       memcpy(orb->cdb, scsi_cmd, COMMAND_SIZE(*scsi_cmd));
 }
 
-/*
- * This function is called in order to begin a regular SBP-2 command.
- */
-static void sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
-                                struct sbp2_command_info *command)
+static void sbp2_link_orb_command(struct sbp2_lu *lu,
+                                 struct sbp2_command_info *cmd)
 {
-       struct sbp2scsi_host_info *hi = scsi_id->hi;
-       struct sbp2_command_orb *command_orb = &command->command_orb;
+       struct sbp2_fwhost_info *hi = lu->hi;
        struct sbp2_command_orb *last_orb;
        dma_addr_t last_orb_dma;
-       u64 addr = scsi_id->sbp2_command_block_agent_addr;
+       u64 addr = lu->command_block_agent_addr;
        quadlet_t data[2];
        size_t length;
        unsigned long flags;
 
-       outstanding_orb_incr;
-       SBP2_ORB_DEBUG("sending command orb %p, total orbs = %x",
-                      command_orb, global_outstanding_command_orbs);
-
-       pci_dma_sync_single_for_device(hi->host->pdev, command->command_orb_dma,
-                                      sizeof(struct sbp2_command_orb),
-                                      PCI_DMA_TODEVICE);
-       pci_dma_sync_single_for_device(hi->host->pdev, command->sge_dma,
-                                      sizeof(command->scatter_gather_element),
-                                      PCI_DMA_BIDIRECTIONAL);
-       /*
-        * Check to see if there are any previous orbs to use
-        */
-       spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags);
-       last_orb = scsi_id->last_orb;
-       last_orb_dma = scsi_id->last_orb_dma;
+       dma_sync_single_for_device(&hi->host->device, cmd->command_orb_dma,
+                                  sizeof(struct sbp2_command_orb),
+                                  DMA_TO_DEVICE);
+       dma_sync_single_for_device(&hi->host->device, cmd->sge_dma,
+                                  sizeof(cmd->scatter_gather_element),
+                                  DMA_BIDIRECTIONAL);
+
+       /* check to see if there are any previous orbs to use */
+       spin_lock_irqsave(&lu->cmd_orb_lock, flags);
+       last_orb = lu->last_orb;
+       last_orb_dma = lu->last_orb_dma;
        if (!last_orb) {
                /*
                 * last_orb == NULL means: We know that the target's fetch agent
@@ -2011,7 +1644,7 @@ static void sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
                 */
                addr += SBP2_ORB_POINTER_OFFSET;
                data[0] = ORB_SET_NODE_ID(hi->host->node_id);
-               data[1] = command->command_orb_dma;
+               data[1] = cmd->command_orb_dma;
                sbp2util_cpu_to_be32_buffer(data, 8);
                length = 8;
        } else {
@@ -2022,27 +1655,25 @@ static void sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
                 * The target's fetch agent may or may not have read this
                 * previous ORB yet.
                 */
-               pci_dma_sync_single_for_cpu(hi->host->pdev, last_orb_dma,
-                                           sizeof(struct sbp2_command_orb),
-                                           PCI_DMA_TODEVICE);
-               last_orb->next_ORB_lo = cpu_to_be32(command->command_orb_dma);
+               dma_sync_single_for_cpu(&hi->host->device, last_orb_dma,
+                                       sizeof(struct sbp2_command_orb),
+                                       DMA_TO_DEVICE);
+               last_orb->next_ORB_lo = cpu_to_be32(cmd->command_orb_dma);
                wmb();
                /* Tells hardware that this pointer is valid */
                last_orb->next_ORB_hi = 0;
-               pci_dma_sync_single_for_device(hi->host->pdev, last_orb_dma,
-                                              sizeof(struct sbp2_command_orb),
-                                              PCI_DMA_TODEVICE);
+               dma_sync_single_for_device(&hi->host->device, last_orb_dma,
+                                          sizeof(struct sbp2_command_orb),
+                                          DMA_TO_DEVICE);
                addr += SBP2_DOORBELL_OFFSET;
                data[0] = 0;
                length = 4;
        }
-       scsi_id->last_orb = command_orb;
-       scsi_id->last_orb_dma = command->command_orb_dma;
-       spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
+       lu->last_orb = &cmd->command_orb;
+       lu->last_orb_dma = cmd->command_orb_dma;
+       spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
 
-       SBP2_ORB_DEBUG("write to %s register, command orb %p",
-                       last_orb ? "DOORBELL" : "ORB_POINTER", command_orb);
-       if (sbp2util_node_write_no_wait(scsi_id->ne, addr, data, length)) {
+       if (sbp2util_node_write_no_wait(lu->ne, addr, data, length)) {
                /*
                 * sbp2util_node_write_no_wait failed. We certainly ran out
                 * of transaction labels, perhaps just because there were no
@@ -2051,51 +1682,29 @@ static void sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
                 * the workqueue job will sleep to guaranteedly get a tlabel.
                 * We do not accept new commands until the job is over.
                 */
-               scsi_block_requests(scsi_id->scsi_host);
-               PREPARE_DELAYED_WORK(&scsi_id->protocol_work,
+               scsi_block_requests(lu->shost);
+               PREPARE_WORK(&lu->protocol_work,
                             last_orb ? sbp2util_write_doorbell:
                                        sbp2util_write_orb_pointer);
-               schedule_delayed_work(&scsi_id->protocol_work, 0);
+               schedule_work(&lu->protocol_work);
        }
 }
 
-/*
- * This function is called in order to begin a regular SBP-2 command.
- */
-static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
-                            struct scsi_cmnd *SCpnt,
+static int sbp2_send_command(struct sbp2_lu *lu, struct scsi_cmnd *SCpnt,
                             void (*done)(struct scsi_cmnd *))
 {
-       unchar *cmd = (unchar *) SCpnt->cmnd;
+       unchar *scsi_cmd = (unchar *)SCpnt->cmnd;
        unsigned int request_bufflen = SCpnt->request_bufflen;
-       struct sbp2_command_info *command;
+       struct sbp2_command_info *cmd;
 
-       SBP2_DEBUG_ENTER();
-       SBP2_DEBUG("SCSI transfer size = %x", request_bufflen);
-       SBP2_DEBUG("SCSI s/g elements = %x", (unsigned int)SCpnt->use_sg);
-
-       /*
-        * Allocate a command orb and s/g structure
-        */
-       command = sbp2util_allocate_command_orb(scsi_id, SCpnt, done);
-       if (!command) {
+       cmd = sbp2util_allocate_command_orb(lu, SCpnt, done);
+       if (!cmd)
                return -EIO;
-       }
 
-       /*
-        * Now actually fill in the comamnd orb and sbp2 s/g list
-        */
-       sbp2_create_command_orb(scsi_id, command, cmd, SCpnt->use_sg,
+       sbp2_create_command_orb(lu, cmd, scsi_cmd, SCpnt->use_sg,
                                request_bufflen, SCpnt->request_buffer,
                                SCpnt->sc_data_direction);
-
-       sbp2util_packet_dump(&command->command_orb, sizeof(struct sbp2_command_orb),
-                            "sbp2 command orb", command->command_orb_dma);
-
-       /*
-        * Link up the orb, and ring the doorbell if needed
-        */
-       sbp2_link_orb_command(scsi_id, command);
+       sbp2_link_orb_command(lu, cmd);
 
        return 0;
 }
@@ -2103,13 +1712,10 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
 /*
  * Translates SBP-2 status into SCSI sense data for check conditions
  */
-static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense_data)
+static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status,
+                                             unchar *sense_data)
 {
-       SBP2_DEBUG_ENTER();
-
-       /*
-        * Ok, it's pretty ugly...   ;-)
-        */
+       /* OK, it's pretty ugly... ;-) */
        sense_data[0] = 0x70;
        sense_data[1] = 0x0;
        sense_data[2] = sbp2_status[9];
@@ -2127,28 +1733,21 @@ static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense
        sense_data[14] = sbp2_status[20];
        sense_data[15] = sbp2_status[21];
 
-       return sbp2_status[8] & 0x3f;   /* return scsi status */
+       return sbp2_status[8] & 0x3f;
 }
 
-/*
- * This function deals with status writes from the SBP-2 device
- */
 static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid,
                                    int destid, quadlet_t *data, u64 addr,
                                    size_t length, u16 fl)
 {
-       struct sbp2scsi_host_info *hi;
-       struct scsi_id_instance_data *scsi_id = NULL, *scsi_id_tmp;
+       struct sbp2_fwhost_info *hi;
+       struct sbp2_lu *lu = NULL, *lu_tmp;
        struct scsi_cmnd *SCpnt = NULL;
        struct sbp2_status_block *sb;
        u32 scsi_status = SBP2_SCSI_STATUS_GOOD;
-       struct sbp2_command_info *command;
+       struct sbp2_command_info *cmd;
        unsigned long flags;
 
-       SBP2_DEBUG_ENTER();
-
-       sbp2util_packet_dump(data, length, "sbp2 status write by device", (u32)addr);
-
        if (unlikely(length < 8 || length > sizeof(struct sbp2_status_block))) {
                SBP2_ERR("Wrong size of status block");
                return RCODE_ADDRESS_ERROR;
@@ -2162,131 +1761,97 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid,
                SBP2_ERR("host info is NULL - this is bad!");
                return RCODE_ADDRESS_ERROR;
        }
-       /*
-        * Find our scsi_id structure by looking at the status fifo address
-        * written to by the sbp2 device.
-        */
-       list_for_each_entry(scsi_id_tmp, &hi->scsi_ids, scsi_list) {
-               if (scsi_id_tmp->ne->nodeid == nodeid &&
-                   scsi_id_tmp->status_fifo_addr == addr) {
-                       scsi_id = scsi_id_tmp;
+
+       /* Find the unit which wrote the status. */
+       list_for_each_entry(lu_tmp, &hi->logical_units, lu_list) {
+               if (lu_tmp->ne->nodeid == nodeid &&
+                   lu_tmp->status_fifo_addr == addr) {
+                       lu = lu_tmp;
                        break;
                }
        }
-       if (unlikely(!scsi_id)) {
-               SBP2_ERR("scsi_id is NULL - device is gone?");
+       if (unlikely(!lu)) {
+               SBP2_ERR("lu is NULL - device is gone?");
                return RCODE_ADDRESS_ERROR;
        }
 
-       /*
-        * Put response into scsi_id status fifo buffer. The first two bytes
+       /* Put response into lu status fifo buffer. The first two bytes
         * come in big endian bit order. Often the target writes only a
         * truncated status block, minimally the first two quadlets. The rest
-        * is implied to be zeros.
-        */
-       sb = &scsi_id->status_block;
+        * is implied to be zeros. */
+       sb = &lu->status_block;
        memset(sb->command_set_dependent, 0, sizeof(sb->command_set_dependent));
        memcpy(sb, data, length);
        sbp2util_be32_to_cpu_buffer(sb, 8);
 
-       /*
-        * Ignore unsolicited status. Handle command ORB status.
-        */
+       /* Ignore unsolicited status. Handle command ORB status. */
        if (unlikely(STATUS_GET_SRC(sb->ORB_offset_hi_misc) == 2))
-               command = NULL;
+               cmd = NULL;
        else
-               command = sbp2util_find_command_for_orb(scsi_id,
-                                                       sb->ORB_offset_lo);
-       if (command) {
-               SBP2_DEBUG("Found status for command ORB");
-               pci_dma_sync_single_for_cpu(hi->host->pdev, command->command_orb_dma,
-                                           sizeof(struct sbp2_command_orb),
-                                           PCI_DMA_TODEVICE);
-               pci_dma_sync_single_for_cpu(hi->host->pdev, command->sge_dma,
-                                           sizeof(command->scatter_gather_element),
-                                           PCI_DMA_BIDIRECTIONAL);
-
-               SBP2_ORB_DEBUG("matched command orb %p", &command->command_orb);
-               outstanding_orb_decr;
-
-               /*
-                * Matched status with command, now grab scsi command pointers
-                * and check status.
-                */
+               cmd = sbp2util_find_command_for_orb(lu, sb->ORB_offset_lo);
+       if (cmd) {
+               dma_sync_single_for_cpu(&hi->host->device, cmd->command_orb_dma,
+                                       sizeof(struct sbp2_command_orb),
+                                       DMA_TO_DEVICE);
+               dma_sync_single_for_cpu(&hi->host->device, cmd->sge_dma,
+                                       sizeof(cmd->scatter_gather_element),
+                                       DMA_BIDIRECTIONAL);
+               /* Grab SCSI command pointers and check status. */
                /*
                 * FIXME: If the src field in the status is 1, the ORB DMA must
                 * not be reused until status for a subsequent ORB is received.
                 */
-               SCpnt = command->Current_SCpnt;
-               spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags);
-               sbp2util_mark_command_completed(scsi_id, command);
-               spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
+               SCpnt = cmd->Current_SCpnt;
+               spin_lock_irqsave(&lu->cmd_orb_lock, flags);
+               sbp2util_mark_command_completed(lu, cmd);
+               spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
 
                if (SCpnt) {
                        u32 h = sb->ORB_offset_hi_misc;
                        u32 r = STATUS_GET_RESP(h);
 
                        if (r != RESP_STATUS_REQUEST_COMPLETE) {
-                               SBP2_WARN("resp 0x%x, sbp_status 0x%x",
+                               SBP2_INFO("resp 0x%x, sbp_status 0x%x",
                                          r, STATUS_GET_SBP_STATUS(h));
                                scsi_status =
                                        r == RESP_STATUS_TRANSPORT_FAILURE ?
                                        SBP2_SCSI_STATUS_BUSY :
                                        SBP2_SCSI_STATUS_COMMAND_TERMINATED;
                        }
-                       /*
-                        * See if the target stored any scsi status information.
-                        */
-                       if (STATUS_GET_LEN(h) > 1) {
-                               SBP2_DEBUG("CHECK CONDITION");
+
+                       if (STATUS_GET_LEN(h) > 1)
                                scsi_status = sbp2_status_to_sense_data(
                                        (unchar *)sb, SCpnt->sense_buffer);
-                       }
-                       /*
-                        * Check to see if the dead bit is set. If so, we'll
-                        * have to initiate a fetch agent reset.
-                        */
-                       if (STATUS_TEST_DEAD(h)) {
-                               SBP2_DEBUG("Dead bit set - "
-                                          "initiating fetch agent reset");
-                                sbp2_agent_reset(scsi_id, 0);
-                       }
-                       SBP2_ORB_DEBUG("completing command orb %p", &command->command_orb);
+
+                       if (STATUS_TEST_DEAD(h))
+                                sbp2_agent_reset(lu, 0);
                }
 
-               /*
-                * Check here to see if there are no commands in-use. If there
+               /* Check here to see if there are no commands in-use. If there
                 * are none, we know that the fetch agent left the active state
                 * _and_ that we did not reactivate it yet. Therefore clear
                 * last_orb so that next time we write directly to the
                 * ORB_POINTER register. That way the fetch agent does not need
-                * to refetch the next_ORB.
-                */
-               spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags);
-               if (list_empty(&scsi_id->sbp2_command_orb_inuse))
-                       scsi_id->last_orb = NULL;
-               spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
+                * to refetch the next_ORB. */
+               spin_lock_irqsave(&lu->cmd_orb_lock, flags);
+               if (list_empty(&lu->cmd_orb_inuse))
+                       lu->last_orb = NULL;
+               spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
 
        } else {
-               /*
-                * It's probably a login/logout/reconnect status.
-                */
-               if ((sb->ORB_offset_lo == scsi_id->reconnect_orb_dma) ||
-                   (sb->ORB_offset_lo == scsi_id->login_orb_dma) ||
-                   (sb->ORB_offset_lo == scsi_id->query_logins_orb_dma) ||
-                   (sb->ORB_offset_lo == scsi_id->logout_orb_dma)) {
-                       scsi_id->access_complete = 1;
-                       wake_up_interruptible(&access_wq);
+               /* It's probably status after a management request. */
+               if ((sb->ORB_offset_lo == lu->reconnect_orb_dma) ||
+                   (sb->ORB_offset_lo == lu->login_orb_dma) ||
+                   (sb->ORB_offset_lo == lu->query_logins_orb_dma) ||
+                   (sb->ORB_offset_lo == lu->logout_orb_dma)) {
+                       lu->access_complete = 1;
+                       wake_up_interruptible(&sbp2_access_wq);
                }
        }
 
-       if (SCpnt) {
-               SBP2_DEBUG("Completing SCSI command");
-               sbp2scsi_complete_command(scsi_id, scsi_status, SCpnt,
-                                         command->Current_done);
-               SBP2_ORB_DEBUG("command orb completed");
-       }
-
+       if (SCpnt)
+               sbp2scsi_complete_command(lu, scsi_status, SCpnt,
+                                         cmd->Current_done);
        return RCODE_COMPLETE;
 }
 
@@ -2294,77 +1859,57 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid,
  * SCSI interface related section
  **************************************/
 
-/*
- * This routine is the main request entry routine for doing I/O. It is
- * called from the scsi stack directly.
- */
 static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt,
                                 void (*done)(struct scsi_cmnd *))
 {
-       struct scsi_id_instance_data *scsi_id =
-               (struct scsi_id_instance_data *)SCpnt->device->host->hostdata[0];
-       struct sbp2scsi_host_info *hi;
+       struct sbp2_lu *lu = (struct sbp2_lu *)SCpnt->device->host->hostdata[0];
+       struct sbp2_fwhost_info *hi;
        int result = DID_NO_CONNECT << 16;
 
-       SBP2_DEBUG_ENTER();
-#if (CONFIG_IEEE1394_SBP2_DEBUG >= 2) || defined(CONFIG_IEEE1394_SBP2_PACKET_DUMP)
-       scsi_print_command(SCpnt);
-#endif
-
-       if (!sbp2util_node_is_available(scsi_id))
+       if (unlikely(!sbp2util_node_is_available(lu)))
                goto done;
 
-       hi = scsi_id->hi;
+       hi = lu->hi;
 
-       if (!hi) {
-               SBP2_ERR("sbp2scsi_host_info is NULL - this is bad!");
+       if (unlikely(!hi)) {
+               SBP2_ERR("sbp2_fwhost_info is NULL - this is bad!");
                goto done;
        }
 
-       /*
-        * Until we handle multiple luns, just return selection time-out
-        * to any IO directed at non-zero LUNs
-        */
-       if (SCpnt->device->lun)
+       /* Multiple units are currently represented to the SCSI core as separate
+        * targets, not as one target with multiple LUs. Therefore return
+        * selection time-out to any IO directed at non-zero LUNs. */
+       if (unlikely(SCpnt->device->lun))
                goto done;
 
-       /*
-        * Check for request sense command, and handle it here
-        * (autorequest sense)
-        */
+       /* handle the request sense command here (auto-request sense) */
        if (SCpnt->cmnd[0] == REQUEST_SENSE) {
-               SBP2_DEBUG("REQUEST_SENSE");
-               memcpy(SCpnt->request_buffer, SCpnt->sense_buffer, SCpnt->request_bufflen);
+               memcpy(SCpnt->request_buffer, SCpnt->sense_buffer,
+                      SCpnt->request_bufflen);
                memset(SCpnt->sense_buffer, 0, sizeof(SCpnt->sense_buffer));
-               sbp2scsi_complete_command(scsi_id, SBP2_SCSI_STATUS_GOOD, SCpnt, done);
+               sbp2scsi_complete_command(lu, SBP2_SCSI_STATUS_GOOD, SCpnt,
+                                         done);
                return 0;
        }
 
-       /*
-        * Check to see if we are in the middle of a bus reset.
-        */
-       if (!hpsb_node_entry_valid(scsi_id->ne)) {
+       if (unlikely(!hpsb_node_entry_valid(lu->ne))) {
                SBP2_ERR("Bus reset in progress - rejecting command");
                result = DID_BUS_BUSY << 16;
                goto done;
        }
 
-       /*
-        * Bidirectional commands are not yet implemented,
-        * and unknown transfer direction not handled.
-        */
-       if (SCpnt->sc_data_direction == DMA_BIDIRECTIONAL) {
+       /* Bidirectional commands are not yet implemented,
+        * and unknown transfer direction not handled. */
+       if (unlikely(SCpnt->sc_data_direction == DMA_BIDIRECTIONAL)) {
                SBP2_ERR("Cannot handle DMA_BIDIRECTIONAL - rejecting command");
                result = DID_ERROR << 16;
                goto done;
        }
 
-       /*
-        * Try and send our SCSI command
-        */
-       if (sbp2_send_command(scsi_id, SCpnt, done)) {
+       if (sbp2_send_command(lu, SCpnt, done)) {
                SBP2_ERR("Error sending SCSI command");
-               sbp2scsi_complete_command(scsi_id, SBP2_SCSI_STATUS_SELECTION_TIMEOUT,
+               sbp2scsi_complete_command(lu,
+                                         SBP2_SCSI_STATUS_SELECTION_TIMEOUT,
                                          SCpnt, done);
        }
        return 0;
@@ -2375,75 +1920,46 @@ done:
        return 0;
 }
 
-/*
- * This function is called in order to complete all outstanding SBP-2
- * commands (in case of resets, etc.).
- */
-static void sbp2scsi_complete_all_commands(struct scsi_id_instance_data *scsi_id,
-                                          u32 status)
+static void sbp2scsi_complete_all_commands(struct sbp2_lu *lu, u32 status)
 {
-       struct sbp2scsi_host_info *hi = scsi_id->hi;
+       struct sbp2_fwhost_info *hi = lu->hi;
        struct list_head *lh;
-       struct sbp2_command_info *command;
+       struct sbp2_command_info *cmd;
        unsigned long flags;
 
-       SBP2_DEBUG_ENTER();
-
-       spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags);
-       while (!list_empty(&scsi_id->sbp2_command_orb_inuse)) {
-               SBP2_DEBUG("Found pending command to complete");
-               lh = scsi_id->sbp2_command_orb_inuse.next;
-               command = list_entry(lh, struct sbp2_command_info, list);
-               pci_dma_sync_single_for_cpu(hi->host->pdev, command->command_orb_dma,
-                                           sizeof(struct sbp2_command_orb),
-                                           PCI_DMA_TODEVICE);
-               pci_dma_sync_single_for_cpu(hi->host->pdev, command->sge_dma,
-                                           sizeof(command->scatter_gather_element),
-                                           PCI_DMA_BIDIRECTIONAL);
-               sbp2util_mark_command_completed(scsi_id, command);
-               if (command->Current_SCpnt) {
-                       command->Current_SCpnt->result = status << 16;
-                       command->Current_done(command->Current_SCpnt);
+       spin_lock_irqsave(&lu->cmd_orb_lock, flags);
+       while (!list_empty(&lu->cmd_orb_inuse)) {
+               lh = lu->cmd_orb_inuse.next;
+               cmd = list_entry(lh, struct sbp2_command_info, list);
+               dma_sync_single_for_cpu(&hi->host->device, cmd->command_orb_dma,
+                                       sizeof(struct sbp2_command_orb),
+                                       DMA_TO_DEVICE);
+               dma_sync_single_for_cpu(&hi->host->device, cmd->sge_dma,
+                                       sizeof(cmd->scatter_gather_element),
+                                       DMA_BIDIRECTIONAL);
+               sbp2util_mark_command_completed(lu, cmd);
+               if (cmd->Current_SCpnt) {
+                       cmd->Current_SCpnt->result = status << 16;
+                       cmd->Current_done(cmd->Current_SCpnt);
                }
        }
-       spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
+       spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
 
        return;
 }
 
 /*
- * This function is called in order to complete a regular SBP-2 command.
- *
- * This can be called in interrupt context.
+ * Complete a regular SCSI command. Can be called in atomic context.
  */
-static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
-                                     u32 scsi_status, struct scsi_cmnd *SCpnt,
+static void sbp2scsi_complete_command(struct sbp2_lu *lu, u32 scsi_status,
+                                     struct scsi_cmnd *SCpnt,
                                      void (*done)(struct scsi_cmnd *))
 {
-       SBP2_DEBUG_ENTER();
-
-       /*
-        * Sanity
-        */
        if (!SCpnt) {
                SBP2_ERR("SCpnt is NULL");
                return;
        }
 
-       /*
-        * If a bus reset is in progress and there was an error, don't
-        * complete the command, just let it get retried at the end of the
-        * bus reset.
-        */
-       if (!hpsb_node_entry_valid(scsi_id->ne)
-           && (scsi_status != SBP2_SCSI_STATUS_GOOD)) {
-               SBP2_ERR("Bus reset in progress - retry command later");
-               return;
-       }
-
-       /*
-        * Switch on scsi status
-        */
        switch (scsi_status) {
        case SBP2_SCSI_STATUS_GOOD:
                SCpnt->result = DID_OK << 16;
@@ -2455,12 +1971,7 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
                break;
 
        case SBP2_SCSI_STATUS_CHECK_CONDITION:
-               SBP2_DEBUG("SBP2_SCSI_STATUS_CHECK_CONDITION");
                SCpnt->result = CHECK_CONDITION << 1 | DID_OK << 16;
-#if CONFIG_IEEE1394_SBP2_DEBUG >= 1
-               scsi_print_command(SCpnt);
-               scsi_print_sense(SBP2_DEVICE_NAME, SCpnt);
-#endif
                break;
 
        case SBP2_SCSI_STATUS_SELECTION_TIMEOUT:
@@ -2482,118 +1993,88 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
                SCpnt->result = DID_ERROR << 16;
        }
 
-       /*
-        * If a bus reset is in progress and there was an error, complete
-        * the command as busy so that it will get retried.
-        */
-       if (!hpsb_node_entry_valid(scsi_id->ne)
+       /* If a bus reset is in progress and there was an error, complete
+        * the command as busy so that it will get retried. */
+       if (!hpsb_node_entry_valid(lu->ne)
            && (scsi_status != SBP2_SCSI_STATUS_GOOD)) {
                SBP2_ERR("Completing command with busy (bus reset)");
                SCpnt->result = DID_BUS_BUSY << 16;
        }
 
-       /*
-        * If a unit attention occurs, return busy status so it gets
-        * retried... it could have happened because of a 1394 bus reset
-        * or hot-plug...
-        * XXX  DID_BUS_BUSY is actually a bad idea because it will defy
-        * the scsi layer's retry logic.
-        */
-#if 0
-       if ((scsi_status == SBP2_SCSI_STATUS_CHECK_CONDITION) &&
-           (SCpnt->sense_buffer[2] == UNIT_ATTENTION)) {
-               SBP2_DEBUG("UNIT ATTENTION - return busy");
-               SCpnt->result = DID_BUS_BUSY << 16;
-       }
-#endif
-
-       /*
-        * Tell scsi stack that we're done with this command
-        */
+       /* Tell the SCSI stack that we're done with this command. */
        done(SCpnt);
 }
 
 static int sbp2scsi_slave_alloc(struct scsi_device *sdev)
 {
-       struct scsi_id_instance_data *scsi_id =
-               (struct scsi_id_instance_data *)sdev->host->hostdata[0];
+       struct sbp2_lu *lu = (struct sbp2_lu *)sdev->host->hostdata[0];
 
-       scsi_id->sdev = sdev;
+       lu->sdev = sdev;
        sdev->allow_restart = 1;
 
-       if (scsi_id->workarounds & SBP2_WORKAROUND_INQUIRY_36)
+       if (lu->workarounds & SBP2_WORKAROUND_INQUIRY_36)
                sdev->inquiry_len = 36;
        return 0;
 }
 
 static int sbp2scsi_slave_configure(struct scsi_device *sdev)
 {
-       struct scsi_id_instance_data *scsi_id =
-               (struct scsi_id_instance_data *)sdev->host->hostdata[0];
+       struct sbp2_lu *lu = (struct sbp2_lu *)sdev->host->hostdata[0];
 
        blk_queue_dma_alignment(sdev->request_queue, (512 - 1));
        sdev->use_10_for_rw = 1;
 
        if (sdev->type == TYPE_DISK &&
-           scsi_id->workarounds & SBP2_WORKAROUND_MODE_SENSE_8)
+           lu->workarounds & SBP2_WORKAROUND_MODE_SENSE_8)
                sdev->skip_ms_page_8 = 1;
-       if (scsi_id->workarounds & SBP2_WORKAROUND_FIX_CAPACITY)
+       if (lu->workarounds & SBP2_WORKAROUND_FIX_CAPACITY)
                sdev->fix_capacity = 1;
        return 0;
 }
 
 static void sbp2scsi_slave_destroy(struct scsi_device *sdev)
 {
-       ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = NULL;
+       ((struct sbp2_lu *)sdev->host->hostdata[0])->sdev = NULL;
        return;
 }
 
 /*
- * Called by scsi stack when something has really gone wrong.  Usually
- * called when a command has timed-out for some reason.
+ * Called by scsi stack when something has really gone wrong.
+ * Usually called when a command has timed-out for some reason.
  */
 static int sbp2scsi_abort(struct scsi_cmnd *SCpnt)
 {
-       struct scsi_id_instance_data *scsi_id =
-               (struct scsi_id_instance_data *)SCpnt->device->host->hostdata[0];
-       struct sbp2scsi_host_info *hi = scsi_id->hi;
-       struct sbp2_command_info *command;
+       struct sbp2_lu *lu = (struct sbp2_lu *)SCpnt->device->host->hostdata[0];
+       struct sbp2_fwhost_info *hi = lu->hi;
+       struct sbp2_command_info *cmd;
        unsigned long flags;
 
-       SBP2_ERR("aborting sbp2 command");
+       SBP2_INFO("aborting sbp2 command");
        scsi_print_command(SCpnt);
 
-       if (sbp2util_node_is_available(scsi_id)) {
-
-               /*
-                * Right now, just return any matching command structures
-                * to the free pool.
-                */
-               spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags);
-               command = sbp2util_find_command_for_SCpnt(scsi_id, SCpnt);
-               if (command) {
-                       SBP2_DEBUG("Found command to abort");
-                       pci_dma_sync_single_for_cpu(hi->host->pdev,
-                                                   command->command_orb_dma,
-                                                   sizeof(struct sbp2_command_orb),
-                                                   PCI_DMA_TODEVICE);
-                       pci_dma_sync_single_for_cpu(hi->host->pdev,
-                                                   command->sge_dma,
-                                                   sizeof(command->scatter_gather_element),
-                                                   PCI_DMA_BIDIRECTIONAL);
-                       sbp2util_mark_command_completed(scsi_id, command);
-                       if (command->Current_SCpnt) {
-                               command->Current_SCpnt->result = DID_ABORT << 16;
-                               command->Current_done(command->Current_SCpnt);
+       if (sbp2util_node_is_available(lu)) {
+               sbp2_agent_reset(lu, 1);
+
+               /* Return a matching command structure to the free pool. */
+               spin_lock_irqsave(&lu->cmd_orb_lock, flags);
+               cmd = sbp2util_find_command_for_SCpnt(lu, SCpnt);
+               if (cmd) {
+                       dma_sync_single_for_cpu(&hi->host->device,
+                                       cmd->command_orb_dma,
+                                       sizeof(struct sbp2_command_orb),
+                                       DMA_TO_DEVICE);
+                       dma_sync_single_for_cpu(&hi->host->device, cmd->sge_dma,
+                                       sizeof(cmd->scatter_gather_element),
+                                       DMA_BIDIRECTIONAL);
+                       sbp2util_mark_command_completed(lu, cmd);
+                       if (cmd->Current_SCpnt) {
+                               cmd->Current_SCpnt->result = DID_ABORT << 16;
+                               cmd->Current_done(cmd->Current_SCpnt);
                        }
                }
-               spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
+               spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
 
-               /*
-                * Initiate a fetch agent reset.
-                */
-               sbp2_agent_reset(scsi_id, 1);
-               sbp2scsi_complete_all_commands(scsi_id, DID_BUS_BUSY);
+               sbp2scsi_complete_all_commands(lu, DID_BUS_BUSY);
        }
 
        return SUCCESS;
@@ -2604,14 +2085,13 @@ static int sbp2scsi_abort(struct scsi_cmnd *SCpnt)
  */
 static int sbp2scsi_reset(struct scsi_cmnd *SCpnt)
 {
-       struct scsi_id_instance_data *scsi_id =
-               (struct scsi_id_instance_data *)SCpnt->device->host->hostdata[0];
+       struct sbp2_lu *lu = (struct sbp2_lu *)SCpnt->device->host->hostdata[0];
 
-       SBP2_ERR("reset requested");
+       SBP2_INFO("reset requested");
 
-       if (sbp2util_node_is_available(scsi_id)) {
-               SBP2_ERR("Generating sbp2 fetch agent reset");
-               sbp2_agent_reset(scsi_id, 1);
+       if (sbp2util_node_is_available(lu)) {
+               SBP2_INFO("generating sbp2 fetch agent reset");
+               sbp2_agent_reset(lu, 1);
        }
 
        return SUCCESS;
@@ -2622,90 +2102,50 @@ static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev,
                                           char *buf)
 {
        struct scsi_device *sdev;
-       struct scsi_id_instance_data *scsi_id;
-       int lun;
+       struct sbp2_lu *lu;
 
        if (!(sdev = to_scsi_device(dev)))
                return 0;
 
-       if (!(scsi_id = (struct scsi_id_instance_data *)sdev->host->hostdata[0]))
+       if (!(lu = (struct sbp2_lu *)sdev->host->hostdata[0]))
                return 0;
 
-       lun = ORB_SET_LUN(scsi_id->sbp2_lun);
-
-       return sprintf(buf, "%016Lx:%d:%d\n", (unsigned long long)scsi_id->ne->guid,
-                      scsi_id->ud->id, lun);
+       return sprintf(buf, "%016Lx:%d:%d\n", (unsigned long long)lu->ne->guid,
+                      lu->ud->id, ORB_SET_LUN(lu->lun));
 }
-static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL);
-
-static struct device_attribute *sbp2_sysfs_sdev_attrs[] = {
-       &dev_attr_ieee1394_id,
-       NULL
-};
 
 MODULE_AUTHOR("Ben Collins <bcollins@debian.org>");
 MODULE_DESCRIPTION("IEEE-1394 SBP-2 protocol driver");
 MODULE_SUPPORTED_DEVICE(SBP2_DEVICE_NAME);
 MODULE_LICENSE("GPL");
 
-/* SCSI host template */
-static struct scsi_host_template scsi_driver_template = {
-       .module =                       THIS_MODULE,
-       .name =                         "SBP-2 IEEE-1394",
-       .proc_name =                    SBP2_DEVICE_NAME,
-       .queuecommand =                 sbp2scsi_queuecommand,
-       .eh_abort_handler =             sbp2scsi_abort,
-       .eh_device_reset_handler =      sbp2scsi_reset,
-       .slave_alloc =                  sbp2scsi_slave_alloc,
-       .slave_configure =              sbp2scsi_slave_configure,
-       .slave_destroy =                sbp2scsi_slave_destroy,
-       .this_id =                      -1,
-       .sg_tablesize =                 SG_ALL,
-       .use_clustering =               ENABLE_CLUSTERING,
-       .cmd_per_lun =                  SBP2_MAX_CMDS,
-       .can_queue =                    SBP2_MAX_CMDS,
-       .emulated =                     1,
-       .sdev_attrs =                   sbp2_sysfs_sdev_attrs,
-};
-
 static int sbp2_module_init(void)
 {
        int ret;
 
-       SBP2_DEBUG_ENTER();
-
-       /* Module load debug option to force one command at a time (serializing I/O) */
-       if (serialize_io) {
-               SBP2_INFO("Driver forced to serialize I/O (serialize_io=1)");
-               SBP2_INFO("Try serialize_io=0 for better performance");
-               scsi_driver_template.can_queue = 1;
-               scsi_driver_template.cmd_per_lun = 1;
+       if (sbp2_serialize_io) {
+               sbp2_shost_template.can_queue = 1;
+               sbp2_shost_template.cmd_per_lun = 1;
        }
 
        if (sbp2_default_workarounds & SBP2_WORKAROUND_128K_MAX_TRANS &&
-           (max_sectors * 512) > (128 * 1024))
-               max_sectors = 128 * 1024 / 512;
-       scsi_driver_template.max_sectors = max_sectors;
+           (sbp2_max_sectors * 512) > (128 * 1024))
+               sbp2_max_sectors = 128 * 1024 / 512;
+       sbp2_shost_template.max_sectors = sbp2_max_sectors;
 
-       /* Register our high level driver with 1394 stack */
        hpsb_register_highlevel(&sbp2_highlevel);
-
        ret = hpsb_register_protocol(&sbp2_driver);
        if (ret) {
                SBP2_ERR("Failed to register protocol");
                hpsb_unregister_highlevel(&sbp2_highlevel);
                return ret;
        }
-
        return 0;
 }
 
 static void __exit sbp2_module_exit(void)
 {
-       SBP2_DEBUG_ENTER();
-
        hpsb_unregister_protocol(&sbp2_driver);
-
        hpsb_unregister_highlevel(&sbp2_highlevel);
 }
 
index 1b16d6b9cf11a0f55e291a7bbe064687b8d12ede..9ae842329bf317dfbbb01a18161fee91f37c6255 100644 (file)
 #define SBP2_DEVICE_NAME               "sbp2"
 
 /*
- * SBP2 specific structures and defines
+ * SBP-2 specific definitions
  */
 
-#define ORB_DIRECTION_WRITE_TO_MEDIA    0x0
-#define ORB_DIRECTION_READ_FROM_MEDIA   0x1
-#define ORB_DIRECTION_NO_DATA_TRANSFER  0x2
-
-#define ORB_SET_NULL_PTR(value)                        ((value & 0x1) << 31)
-#define ORB_SET_NOTIFY(value)                  ((value & 0x1) << 31)
-#define ORB_SET_RQ_FMT(value)                  ((value & 0x3) << 29)   /* unused ? */
-#define ORB_SET_NODE_ID(value)                 ((value & 0xffff) << 16)
-#define ORB_SET_STATUS_FIFO_HI(value, id)      (value >> 32 | ORB_SET_NODE_ID(id))
-#define ORB_SET_STATUS_FIFO_LO(value)          (value & 0xffffffff)
-#define ORB_SET_DATA_SIZE(value)               (value & 0xffff)
-#define ORB_SET_PAGE_SIZE(value)               ((value & 0x7) << 16)
-#define ORB_SET_PAGE_TABLE_PRESENT(value)      ((value & 0x1) << 19)
-#define ORB_SET_MAX_PAYLOAD(value)             ((value & 0xf) << 20)
-#define ORB_SET_SPEED(value)                   ((value & 0x7) << 24)
-#define ORB_SET_DIRECTION(value)               ((value & 0x1) << 27)
+#define ORB_DIRECTION_WRITE_TO_MEDIA   0x0
+#define ORB_DIRECTION_READ_FROM_MEDIA  0x1
+#define ORB_DIRECTION_NO_DATA_TRANSFER 0x2
+
+#define ORB_SET_NULL_PTR(v)            (((v) & 0x1) << 31)
+#define ORB_SET_NOTIFY(v)              (((v) & 0x1) << 31)
+#define ORB_SET_RQ_FMT(v)              (((v) & 0x3) << 29)
+#define ORB_SET_NODE_ID(v)             (((v) & 0xffff) << 16)
+#define ORB_SET_STATUS_FIFO_HI(v, id)  ((v) >> 32 | ORB_SET_NODE_ID(id))
+#define ORB_SET_STATUS_FIFO_LO(v)      ((v) & 0xffffffff)
+#define ORB_SET_DATA_SIZE(v)           ((v) & 0xffff)
+#define ORB_SET_PAGE_SIZE(v)           (((v) & 0x7) << 16)
+#define ORB_SET_PAGE_TABLE_PRESENT(v)  (((v) & 0x1) << 19)
+#define ORB_SET_MAX_PAYLOAD(v)         (((v) & 0xf) << 20)
+#define ORB_SET_SPEED(v)               (((v) & 0x7) << 24)
+#define ORB_SET_DIRECTION(v)           (((v) & 0x1) << 27)
 
 struct sbp2_command_orb {
        u32 next_ORB_hi;
@@ -64,12 +64,12 @@ struct sbp2_command_orb {
 #define SBP2_LOGICAL_UNIT_RESET                0xe
 #define SBP2_TARGET_RESET_REQUEST      0xf
 
-#define ORB_SET_LUN(value)                      (value & 0xffff)
-#define ORB_SET_FUNCTION(value)                 ((value & 0xf) << 16)
-#define ORB_SET_RECONNECT(value)                ((value & 0xf) << 20)
-#define ORB_SET_EXCLUSIVE(value)                ((value & 0x1) << 28)
-#define ORB_SET_LOGIN_RESP_LENGTH(value)        (value & 0xffff)
-#define ORB_SET_PASSWD_LENGTH(value)            ((value & 0xffff) << 16)
+#define ORB_SET_LUN(v)                 ((v) & 0xffff)
+#define ORB_SET_FUNCTION(v)            (((v) & 0xf) << 16)
+#define ORB_SET_RECONNECT(v)           (((v) & 0xf) << 20)
+#define ORB_SET_EXCLUSIVE(v)           (((v) & 0x1) << 28)
+#define ORB_SET_LOGIN_RESP_LENGTH(v)   ((v) & 0xffff)
+#define ORB_SET_PASSWD_LENGTH(v)       (((v) & 0xffff) << 16)
 
 struct sbp2_login_orb {
        u32 password_hi;
@@ -82,9 +82,9 @@ struct sbp2_login_orb {
        u32 status_fifo_lo;
 } __attribute__((packed));
 
-#define RESPONSE_GET_LOGIN_ID(value)            (value & 0xffff)
-#define RESPONSE_GET_LENGTH(value)              ((value >> 16) & 0xffff)
-#define RESPONSE_GET_RECONNECT_HOLD(value)      (value & 0xffff)
+#define RESPONSE_GET_LOGIN_ID(v)       ((v) & 0xffff)
+#define RESPONSE_GET_LENGTH(v)         (((v) >> 16) & 0xffff)
+#define RESPONSE_GET_RECONNECT_HOLD(v) ((v) & 0xffff)
 
 struct sbp2_login_response {
        u32 length_login_ID;
@@ -93,9 +93,8 @@ struct sbp2_login_response {
        u32 reconnect_hold;
 } __attribute__((packed));
 
-#define ORB_SET_LOGIN_ID(value)                 (value & 0xffff)
-
-#define ORB_SET_QUERY_LOGINS_RESP_LENGTH(value) (value & 0xffff)
+#define ORB_SET_LOGIN_ID(v)                 ((v) & 0xffff)
+#define ORB_SET_QUERY_LOGINS_RESP_LENGTH(v) ((v) & 0xffff)
 
 struct sbp2_query_logins_orb {
        u32 reserved1;
@@ -108,8 +107,8 @@ struct sbp2_query_logins_orb {
        u32 status_fifo_lo;
 } __attribute__((packed));
 
-#define RESPONSE_GET_MAX_LOGINS(value)          (value & 0xffff)
-#define RESPONSE_GET_ACTIVE_LOGINS(value)       ((RESPONSE_GET_LENGTH(value) - 4) / 12)
+#define RESPONSE_GET_MAX_LOGINS(v)     ((v) & 0xffff)
+#define RESPONSE_GET_ACTIVE_LOGINS(v)  ((RESPONSE_GET_LENGTH((v)) - 4) / 12)
 
 struct sbp2_query_logins_response {
        u32 length_max_logins;
@@ -140,8 +139,8 @@ struct sbp2_logout_orb {
        u32 status_fifo_lo;
 } __attribute__((packed));
 
-#define PAGE_TABLE_SET_SEGMENT_BASE_HI(value)   (value & 0xffff)
-#define PAGE_TABLE_SET_SEGMENT_LENGTH(value)    ((value & 0xffff) << 16)
+#define PAGE_TABLE_SET_SEGMENT_BASE_HI(v)      ((v) & 0xffff)
+#define PAGE_TABLE_SET_SEGMENT_LENGTH(v)       (((v) & 0xffff) << 16)
 
 struct sbp2_unrestricted_page_table {
        u32 length_segment_base_hi;
@@ -171,23 +170,14 @@ struct sbp2_unrestricted_page_table {
 #define SFMT_DEFERRED_ERROR                    0x1
 #define SFMT_VENDOR_DEPENDENT_STATUS           0x3
 
-#define SBP2_SCSI_STATUS_GOOD                  0x0
-#define SBP2_SCSI_STATUS_CHECK_CONDITION       0x2
-#define SBP2_SCSI_STATUS_CONDITION_MET         0x4
-#define SBP2_SCSI_STATUS_BUSY                  0x8
-#define SBP2_SCSI_STATUS_RESERVATION_CONFLICT  0x18
-#define SBP2_SCSI_STATUS_COMMAND_TERMINATED    0x22
-
-#define SBP2_SCSI_STATUS_SELECTION_TIMEOUT     0xff
-
-#define STATUS_GET_SRC(value)                  (((value) >> 30) & 0x3)
-#define STATUS_GET_RESP(value)                 (((value) >> 28) & 0x3)
-#define STATUS_GET_LEN(value)                  (((value) >> 24) & 0x7)
-#define STATUS_GET_SBP_STATUS(value)           (((value) >> 16) & 0xff)
-#define STATUS_GET_ORB_OFFSET_HI(value)                ((value) & 0x0000ffff)
-#define STATUS_TEST_DEAD(value)                        ((value) & 0x08000000)
+#define STATUS_GET_SRC(v)                      (((v) >> 30) & 0x3)
+#define STATUS_GET_RESP(v)                     (((v) >> 28) & 0x3)
+#define STATUS_GET_LEN(v)                      (((v) >> 24) & 0x7)
+#define STATUS_GET_SBP_STATUS(v)               (((v) >> 16) & 0xff)
+#define STATUS_GET_ORB_OFFSET_HI(v)            ((v) & 0x0000ffff)
+#define STATUS_TEST_DEAD(v)                    ((v) & 0x08000000)
 /* test 'resp' | 'dead' | 'sbp2_status' */
-#define STATUS_TEST_RDS(value)                 ((value) & 0x38ff0000)
+#define STATUS_TEST_RDS(v)                     ((v) & 0x38ff0000)
 
 struct sbp2_status_block {
        u32 ORB_offset_hi_misc;
@@ -195,66 +185,70 @@ struct sbp2_status_block {
        u8 command_set_dependent[24];
 } __attribute__((packed));
 
+
 /*
- * Miscellaneous SBP2 related config rom defines
+ * SBP2 related configuration ROM definitions
  */
 
-#define SBP2_UNIT_DIRECTORY_OFFSET_KEY                         0xd1
-#define SBP2_CSR_OFFSET_KEY                                    0x54
-#define SBP2_UNIT_SPEC_ID_KEY                                  0x12
-#define SBP2_UNIT_SW_VERSION_KEY                               0x13
-#define SBP2_COMMAND_SET_SPEC_ID_KEY                           0x38
-#define SBP2_COMMAND_SET_KEY                                   0x39
-#define SBP2_UNIT_CHARACTERISTICS_KEY                          0x3a
-#define SBP2_DEVICE_TYPE_AND_LUN_KEY                           0x14
-#define SBP2_FIRMWARE_REVISION_KEY                             0x3c
+#define SBP2_UNIT_DIRECTORY_OFFSET_KEY         0xd1
+#define SBP2_CSR_OFFSET_KEY                    0x54
+#define SBP2_UNIT_SPEC_ID_KEY                  0x12
+#define SBP2_UNIT_SW_VERSION_KEY               0x13
+#define SBP2_COMMAND_SET_SPEC_ID_KEY           0x38
+#define SBP2_COMMAND_SET_KEY                   0x39
+#define SBP2_UNIT_CHARACTERISTICS_KEY          0x3a
+#define SBP2_DEVICE_TYPE_AND_LUN_KEY           0x14
+#define SBP2_FIRMWARE_REVISION_KEY             0x3c
 
-#define SBP2_AGENT_STATE_OFFSET                                        0x00ULL
-#define SBP2_AGENT_RESET_OFFSET                                        0x04ULL
-#define SBP2_ORB_POINTER_OFFSET                                        0x08ULL
-#define SBP2_DOORBELL_OFFSET                                   0x10ULL
-#define SBP2_UNSOLICITED_STATUS_ENABLE_OFFSET                  0x14ULL
-#define SBP2_UNSOLICITED_STATUS_VALUE                          0xf
+#define SBP2_AGENT_STATE_OFFSET                        0x00ULL
+#define SBP2_AGENT_RESET_OFFSET                        0x04ULL
+#define SBP2_ORB_POINTER_OFFSET                        0x08ULL
+#define SBP2_DOORBELL_OFFSET                   0x10ULL
+#define SBP2_UNSOLICITED_STATUS_ENABLE_OFFSET  0x14ULL
+#define SBP2_UNSOLICITED_STATUS_VALUE          0xf
 
-#define SBP2_BUSY_TIMEOUT_ADDRESS                              0xfffff0000210ULL
-#define SBP2_BUSY_TIMEOUT_VALUE                                        0xf
+#define SBP2_BUSY_TIMEOUT_ADDRESS              0xfffff0000210ULL
+/* biggest possible value for Single Phase Retry count is 0xf */
+#define SBP2_BUSY_TIMEOUT_VALUE                        0xf
 
-#define SBP2_AGENT_RESET_DATA                                  0xf
+#define SBP2_AGENT_RESET_DATA                  0xf
 
-/*
- * Unit spec id and sw version entry for SBP-2 devices
- */
+#define SBP2_UNIT_SPEC_ID_ENTRY                        0x0000609e
+#define SBP2_SW_VERSION_ENTRY                  0x00010483
 
-#define SBP2_UNIT_SPEC_ID_ENTRY                                        0x0000609e
-#define SBP2_SW_VERSION_ENTRY                                  0x00010483
 
 /*
- * SCSI specific stuff
+ * SCSI specific definitions
  */
 
-#define SBP2_MAX_SG_ELEMENT_LENGTH     0xf000
-#define SBP2_MAX_SECTORS               255     /* Max sectors supported */
-#define SBP2_MAX_CMDS                  8       /* This should be safe */
+#define SBP2_MAX_SG_ELEMENT_LENGTH             0xf000
+#define SBP2_MAX_SECTORS                       255
+/* There is no real limitation of the queue depth (i.e. length of the linked
+ * list of command ORBs) at the target. The chosen depth is merely an
+ * implementation detail of the sbp2 driver. */
+#define SBP2_MAX_CMDS                          8
+
+#define SBP2_SCSI_STATUS_GOOD                  0x0
+#define SBP2_SCSI_STATUS_CHECK_CONDITION       0x2
+#define SBP2_SCSI_STATUS_CONDITION_MET         0x4
+#define SBP2_SCSI_STATUS_BUSY                  0x8
+#define SBP2_SCSI_STATUS_RESERVATION_CONFLICT  0x18
+#define SBP2_SCSI_STATUS_COMMAND_TERMINATED    0x22
+#define SBP2_SCSI_STATUS_SELECTION_TIMEOUT     0xff
 
-/* Flags for detected oddities and brokeness */
-#define SBP2_WORKAROUND_128K_MAX_TRANS 0x1
-#define SBP2_WORKAROUND_INQUIRY_36     0x2
-#define SBP2_WORKAROUND_MODE_SENSE_8   0x4
-#define SBP2_WORKAROUND_FIX_CAPACITY   0x8
-#define SBP2_WORKAROUND_OVERRIDE       0x100
 
-/* This is the two dma types we use for cmd_dma below */
-enum cmd_dma_types {
+/*
+ * Representations of commands and devices
+ */
+
+enum sbp2_dma_types {
        CMD_DMA_NONE,
        CMD_DMA_PAGE,
        CMD_DMA_SINGLE
 };
 
-/*
- * Encapsulates all the info necessary for an outstanding command.
- */
+/* Per SCSI command */
 struct sbp2_command_info {
-
        struct list_head list;
        struct sbp2_command_orb command_orb ____cacheline_aligned;
        dma_addr_t command_orb_dma ____cacheline_aligned;
@@ -262,25 +256,25 @@ struct sbp2_command_info {
        void (*Current_done)(struct scsi_cmnd *);
 
        /* Also need s/g structure for each sbp2 command */
-       struct sbp2_unrestricted_page_table scatter_gather_element[SG_ALL] ____cacheline_aligned;
+       struct sbp2_unrestricted_page_table
+                       scatter_gather_element[SG_ALL] ____cacheline_aligned;
        dma_addr_t sge_dma ____cacheline_aligned;
        void *sge_buffer;
        dma_addr_t cmd_dma;
-       enum cmd_dma_types dma_type;
+       enum sbp2_dma_types dma_type;
        unsigned long dma_size;
-       int dma_dir;
-
+       enum dma_data_direction dma_dir;
 };
 
-struct sbp2scsi_host_info;
+/* Per FireWire host */
+struct sbp2_fwhost_info {
+       struct hpsb_host *host;
+       struct list_head logical_units;
+};
 
-/*
- * Information needed on a per scsi id basis (one for each sbp2 device)
- */
-struct scsi_id_instance_data {
-       /*
-        * Various sbp2 specific structures
-        */
+/* Per logical unit */
+struct sbp2_lu {
+       /* Operation request blocks */
        struct sbp2_command_orb *last_orb;
        dma_addr_t last_orb_dma;
        struct sbp2_login_orb *login_orb;
@@ -297,116 +291,59 @@ struct scsi_id_instance_data {
        dma_addr_t logout_orb_dma;
        struct sbp2_status_block status_block;
 
-       /*
-        * Stuff we need to know about the sbp2 device itself
-        */
-       u64 sbp2_management_agent_addr;
-       u64 sbp2_command_block_agent_addr;
+       /* How to talk to the unit */
+       u64 management_agent_addr;
+       u64 command_block_agent_addr;
        u32 speed_code;
        u32 max_payload_size;
+       u16 lun;
 
-       /*
-        * Values pulled from the device's unit directory
-        */
-       u32 sbp2_command_set_spec_id;
-       u32 sbp2_command_set;
-       u32 sbp2_unit_characteristics;
-       u32 sbp2_lun;
-       u32 sbp2_firmware_revision;
-
-       /*
-        * Address for the device to write status blocks to
-        */
+       /* Address for the unit to write status blocks to */
        u64 status_fifo_addr;
 
-       /*
-        * Waitqueue flag for logins, reconnects, logouts, query logins
-        */
-       int access_complete:1;
+       /* Waitqueue flag for logins, reconnects, logouts, query logins */
+       unsigned int access_complete:1;
 
-       /*
-        * Pool of command orbs, so we can have more than overlapped command per id
-        */
-       spinlock_t sbp2_command_orb_lock;
-       struct list_head sbp2_command_orb_inuse;
-       struct list_head sbp2_command_orb_completed;
+       /* Pool of command ORBs for this logical unit */
+       spinlock_t cmd_orb_lock;
+       struct list_head cmd_orb_inuse;
+       struct list_head cmd_orb_completed;
 
-       struct list_head scsi_list;
+       /* Backlink to FireWire host; list of units attached to the host */
+       struct sbp2_fwhost_info *hi;
+       struct list_head lu_list;
 
-       /* Node entry, as retrieved from NodeMgr entries */
+       /* IEEE 1394 core's device representations */
        struct node_entry *ne;
        struct unit_directory *ud;
 
-       /* A backlink to our host_info */
-       struct sbp2scsi_host_info *hi;
-
-       /* SCSI related pointers */
+       /* SCSI core's device representations */
        struct scsi_device *sdev;
-       struct Scsi_Host *scsi_host;
+       struct Scsi_Host *shost;
 
        /* Device specific workarounds/brokeness */
        unsigned workarounds;
 
+       /* Connection state */
        atomic_t state;
-       struct delayed_work protocol_work;
+
+       /* For deferred requests to the fetch agent */
+       struct work_struct protocol_work;
 };
 
-/* For use in scsi_id_instance_data.state */
+/* For use in sbp2_lu.state */
 enum sbp2lu_state_types {
        SBP2LU_STATE_RUNNING,           /* all normal */
        SBP2LU_STATE_IN_RESET,          /* between bus reset and reconnect */
        SBP2LU_STATE_IN_SHUTDOWN        /* when sbp2_remove was called */
 };
 
-/* Sbp2 host data structure (one per IEEE1394 host) */
-struct sbp2scsi_host_info {
-       struct hpsb_host *host;         /* IEEE1394 host */
-       struct list_head scsi_ids;      /* List of scsi ids on this host */
-};
-
-/*
- * Function prototypes
- */
-
-/*
- * Various utility prototypes
- */
-static int sbp2util_create_command_orb_pool(struct scsi_id_instance_data *scsi_id);
-static void sbp2util_remove_command_orb_pool(struct scsi_id_instance_data *scsi_id);
-static struct sbp2_command_info *sbp2util_find_command_for_orb(struct scsi_id_instance_data *scsi_id, dma_addr_t orb);
-static struct sbp2_command_info *sbp2util_find_command_for_SCpnt(struct scsi_id_instance_data *scsi_id, void *SCpnt);
-static struct sbp2_command_info *sbp2util_allocate_command_orb(struct scsi_id_instance_data *scsi_id,
-                                                         struct scsi_cmnd *Current_SCpnt,
-                                                         void (*Current_done)(struct scsi_cmnd *));
-static void sbp2util_mark_command_completed(struct scsi_id_instance_data *scsi_id,
-               struct sbp2_command_info *command);
-
-
-static int sbp2_start_device(struct scsi_id_instance_data *scsi_id);
-static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id);
-
-#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
-static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid, int destid, quadlet_t *data,
-                                     u64 addr, size_t length, u16 flags);
-static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid, quadlet_t *data,
-                                    u64 addr, size_t length, u16 flags);
-#endif
-
-/*
- * SBP-2 protocol related prototypes
- */
-static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id);
-static int sbp2_login_device(struct scsi_id_instance_data *scsi_id);
-static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id);
-static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id);
-static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int destid,
-                                   quadlet_t *data, u64 addr, size_t length, u16 flags);
-static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait);
-static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status,
-                                             unchar *sense_data);
-static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
-                                     struct unit_directory *ud);
-static int sbp2_set_busy_timeout(struct scsi_id_instance_data *scsi_id);
-static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id);
+/* For use in sbp2_lu.workarounds and in the corresponding
+ * module load parameter */
+#define SBP2_WORKAROUND_128K_MAX_TRANS 0x1
+#define SBP2_WORKAROUND_INQUIRY_36     0x2
+#define SBP2_WORKAROUND_MODE_SENSE_8   0x4
+#define SBP2_WORKAROUND_FIX_CAPACITY   0x8
+#define SBP2_WORKAROUND_OVERRIDE       0x100
 
 #endif /* SBP2_H */
index 9bc65059cc6901eba8eb4f3cb09e46ca312f5da0..598b19fc5989da426d87510031cd6e4bb105d5d4 100644 (file)
@@ -714,8 +714,8 @@ static inline unsigned video1394_buffer_state(struct dma_iso_ctx *d,
        return ret;
 }
 
-static int __video1394_ioctl(struct file *file,
-                            unsigned int cmd, unsigned long arg)
+static long video1394_ioctl(struct file *file,
+                           unsigned int cmd, unsigned long arg)
 {
        struct file_ctx *ctx = (struct file_ctx *)file->private_data;
        struct ti_ohci *ohci = ctx->ohci;
@@ -884,13 +884,14 @@ static int __video1394_ioctl(struct file *file,
                struct dma_iso_ctx *d;
                int next_prg;
 
-               if (copy_from_user(&v, argp, sizeof(v)))
+               if (unlikely(copy_from_user(&v, argp, sizeof(v))))
                        return -EFAULT;
 
                d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel);
-               if (d == NULL) return -EFAULT;
+               if (unlikely(d == NULL))
+                       return -EFAULT;
 
-               if ((v.buffer<0) || (v.buffer>=d->num_desc - 1)) {
+               if (unlikely((v.buffer<0) || (v.buffer>=d->num_desc - 1))) {
                        PRINT(KERN_ERR, ohci->host->id,
                              "Buffer %d out of range",v.buffer);
                        return -EINVAL;
@@ -898,7 +899,7 @@ static int __video1394_ioctl(struct file *file,
 
                spin_lock_irqsave(&d->lock,flags);
 
-               if (d->buffer_status[v.buffer]==VIDEO1394_BUFFER_QUEUED) {
+               if (unlikely(d->buffer_status[v.buffer]==VIDEO1394_BUFFER_QUEUED)) {
                        PRINT(KERN_ERR, ohci->host->id,
                              "Buffer %d is already used",v.buffer);
                        spin_unlock_irqrestore(&d->lock,flags);
@@ -949,13 +950,14 @@ static int __video1394_ioctl(struct file *file,
                struct dma_iso_ctx *d;
                int i = 0;
 
-               if (copy_from_user(&v, argp, sizeof(v)))
+               if (unlikely(copy_from_user(&v, argp, sizeof(v))))
                        return -EFAULT;
 
                d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel);
-               if (d == NULL) return -EFAULT;
+               if (unlikely(d == NULL))
+                       return -EFAULT;
 
-               if ((v.buffer<0) || (v.buffer>d->num_desc - 1)) {
+               if (unlikely((v.buffer<0) || (v.buffer>d->num_desc - 1))) {
                        PRINT(KERN_ERR, ohci->host->id,
                              "Buffer %d out of range",v.buffer);
                        return -EINVAL;
@@ -1008,7 +1010,7 @@ static int __video1394_ioctl(struct file *file,
                spin_unlock_irqrestore(&d->lock, flags);
 
                v.buffer=i;
-               if (copy_to_user(argp, &v, sizeof(v)))
+               if (unlikely(copy_to_user(argp, &v, sizeof(v))))
                        return -EFAULT;
 
                return 0;
@@ -1156,15 +1158,6 @@ static int __video1394_ioctl(struct file *file,
        }
 }
 
-static long video1394_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-       int err;
-       lock_kernel();
-       err = __video1394_ioctl(file, cmd, arg);
-       unlock_kernel();
-       return err;
-}
-
 /*
  *     This maps the vmalloced and reserved buffer to user space.
  *
@@ -1177,17 +1170,14 @@ static long video1394_ioctl(struct file *file, unsigned int cmd, unsigned long a
 static int video1394_mmap(struct file *file, struct vm_area_struct *vma)
 {
        struct file_ctx *ctx = (struct file_ctx *)file->private_data;
-       int res = -EINVAL;
 
-       lock_kernel();
        if (ctx->current_ctx == NULL) {
                PRINT(KERN_ERR, ctx->ohci->host->id,
                                "Current iso context not set");
-       } else
-               res = dma_region_mmap(&ctx->current_ctx->dma, file, vma);
-       unlock_kernel();
+               return -EINVAL;
+       }
 
-       return res;
+       return dma_region_mmap(&ctx->current_ctx->dma, file, vma);
 }
 
 static unsigned int video1394_poll(struct file *file, poll_table *pt)
@@ -1198,14 +1188,12 @@ static unsigned int video1394_poll(struct file *file, poll_table *pt)
        struct dma_iso_ctx *d;
        int i;
 
-       lock_kernel();
        ctx = file->private_data;
        d = ctx->current_ctx;
        if (d == NULL) {
                PRINT(KERN_ERR, ctx->ohci->host->id,
                                "Current iso context not set");
-               mask = POLLERR;
-               goto done;
+               return POLLERR;
        }
 
        poll_wait(file, &d->waitq, pt);
@@ -1218,8 +1206,6 @@ static unsigned int video1394_poll(struct file *file, poll_table *pt)
                }
        }
        spin_unlock_irqrestore(&d->lock, flags);
-done:
-       unlock_kernel();
 
        return mask;
 }
@@ -1255,7 +1241,6 @@ static int video1394_release(struct inode *inode, struct file *file)
        struct list_head *lh, *next;
        u64 mask;
 
-       lock_kernel();
        list_for_each_safe(lh, next, &ctx->context_list) {
                struct dma_iso_ctx *d;
                d = list_entry(lh, struct dma_iso_ctx, link);
@@ -1276,7 +1261,6 @@ static int video1394_release(struct inode *inode, struct file *file)
        kfree(ctx);
        file->private_data = NULL;
 
-       unlock_kernel();
        return 0;
 }
 
@@ -1324,12 +1308,8 @@ static struct ieee1394_device_id video1394_id_table[] = {
 MODULE_DEVICE_TABLE(ieee1394, video1394_id_table);
 
 static struct hpsb_protocol_driver video1394_driver = {
-       .name           = "1394 Digital Camera Driver",
+       .name           = VIDEO1394_DRIVER_NAME,
        .id_table       = video1394_id_table,
-       .driver         = {
-               .name   = VIDEO1394_DRIVER_NAME,
-               .bus    = &ieee1394_bus_type,
-       },
 };
 
 
index 4e16314e8e6dd8bec8e9aabb4917a841f441695f..a617ca7b69236d8e2a35bfbec52bc4b0c55dc16e 100644 (file)
@@ -534,9 +534,9 @@ struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
         * module reference.
         */
        filp->f_op         = fops_get(&uverbs_event_fops);
-       filp->f_vfsmnt     = mntget(uverbs_event_mnt);
-       filp->f_dentry     = dget(uverbs_event_mnt->mnt_root);
-       filp->f_mapping    = filp->f_dentry->d_inode->i_mapping;
+       filp->f_path.mnt           = mntget(uverbs_event_mnt);
+       filp->f_path.dentry        = dget(uverbs_event_mnt->mnt_root);
+       filp->f_mapping    = filp->f_path.dentry->d_inode->i_mapping;
        filp->f_flags      = O_RDONLY;
        filp->f_mode       = FMODE_READ;
        filp->private_data = ev_file;
index 40caeb5f41b467ff6c9dee2ffb588e285389c7f0..36620a22413cd1f5f40e99e9f5ee138ad4a0ad85 100644 (file)
@@ -164,7 +164,7 @@ void vq_req_put(struct c2_dev *c2dev, struct c2_vq_req *r)
  */
 void *vq_repbuf_alloc(struct c2_dev *c2dev)
 {
-       return kmem_cache_alloc(c2dev->host_msg_cache, SLAB_ATOMIC);
+       return kmem_cache_alloc(c2dev->host_msg_cache, GFP_ATOMIC);
 }
 
 /*
index 214e2fdddeef0792572aaf0fcd333aa1ae94016b..0d6e2c4bb2451f27f78dfea5aa191c1f66cebe58 100644 (file)
@@ -57,7 +57,7 @@ struct ib_ah *ehca_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
        struct ehca_shca *shca = container_of(pd->device, struct ehca_shca,
                                              ib_device);
 
-       av = kmem_cache_alloc(av_cache, SLAB_KERNEL);
+       av = kmem_cache_alloc(av_cache, GFP_KERNEL);
        if (!av) {
                ehca_err(pd->device, "Out of memory pd=%p ah_attr=%p",
                         pd, ah_attr);
index 458fe19648a10fc7ed8175f6495cf43672465511..93995b658d94a7dedbe816f2927589a63b51dde4 100644 (file)
@@ -134,7 +134,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe,
        if (cqe >= 0xFFFFFFFF - 64 - additional_cqe)
                return ERR_PTR(-EINVAL);
 
-       my_cq = kmem_cache_alloc(cq_cache, SLAB_KERNEL);
+       my_cq = kmem_cache_alloc(cq_cache, GFP_KERNEL);
        if (!my_cq) {
                ehca_err(device, "Out of memory for ehca_cq struct device=%p",
                         device);
index 3d1c1c535038c0ce0460ad1f63a87037e401501b..cc47e4c13a180897fa3aee03a589d197b48367db 100644 (file)
@@ -108,7 +108,7 @@ static struct kmem_cache *ctblk_cache = NULL;
 
 void *ehca_alloc_fw_ctrlblock(void)
 {
-       void *ret = kmem_cache_zalloc(ctblk_cache, SLAB_KERNEL);
+       void *ret = kmem_cache_zalloc(ctblk_cache, GFP_KERNEL);
        if (!ret)
                ehca_gen_err("Out of memory for ctblk");
        return ret;
index abce676c0ae0ec8a6dd8c824e6f75a7130d91fcf..0a5e2214cc5f72b30ed36d0e0e95384fea4d6b0f 100644 (file)
@@ -53,7 +53,7 @@ static struct ehca_mr *ehca_mr_new(void)
 {
        struct ehca_mr *me;
 
-       me = kmem_cache_alloc(mr_cache, SLAB_KERNEL);
+       me = kmem_cache_alloc(mr_cache, GFP_KERNEL);
        if (me) {
                memset(me, 0, sizeof(struct ehca_mr));
                spin_lock_init(&me->mrlock);
@@ -72,7 +72,7 @@ static struct ehca_mw *ehca_mw_new(void)
 {
        struct ehca_mw *me;
 
-       me = kmem_cache_alloc(mw_cache, SLAB_KERNEL);
+       me = kmem_cache_alloc(mw_cache, GFP_KERNEL);
        if (me) {
                memset(me, 0, sizeof(struct ehca_mw));
                spin_lock_init(&me->mwlock);
index 2c3cdc6f7b39ef5982876bf5dfae77108d374888..d5345e5b3cd661a0de94104fb16bd4f1fca33c76 100644 (file)
@@ -50,7 +50,7 @@ struct ib_pd *ehca_alloc_pd(struct ib_device *device,
 {
        struct ehca_pd *pd;
 
-       pd = kmem_cache_alloc(pd_cache, SLAB_KERNEL);
+       pd = kmem_cache_alloc(pd_cache, GFP_KERNEL);
        if (!pd) {
                ehca_err(device, "device=%p context=%p out of memory",
                         device, context);
index 8682aa50c707bf665f9ac3ce59a95cdeedae4867..c6c9cef203e3361fb2868222cb4a405487b84087 100644 (file)
@@ -450,7 +450,7 @@ struct ib_qp *ehca_create_qp(struct ib_pd *pd,
        if (pd->uobject && udata)
                context = pd->uobject->context;
 
-       my_qp = kmem_cache_alloc(qp_cache, SLAB_KERNEL);
+       my_qp = kmem_cache_alloc(qp_cache, GFP_KERNEL);
        if (!my_qp) {
                ehca_err(pd->device, "pd=%p not enough memory to alloc qp", pd);
                return ERR_PTR(-ENOMEM);
index a9ddc6911f66f89478740c9b994f66038236c692..340f27e3ebff50cb33f6834bdd70881dec49a973 100644 (file)
@@ -1745,9 +1745,9 @@ static int ipath_assign_port(struct file *fp,
                goto done;
        }
 
-       i_minor = iminor(fp->f_dentry->d_inode) - IPATH_USER_MINOR_BASE;
+       i_minor = iminor(fp->f_path.dentry->d_inode) - IPATH_USER_MINOR_BASE;
        ipath_cdbg(VERBOSE, "open on dev %lx (minor %d)\n",
-                  (long)fp->f_dentry->d_inode->i_rdev, i_minor);
+                  (long)fp->f_path.dentry->d_inode->i_rdev, i_minor);
 
        if (i_minor)
                ret = find_free_port(i_minor - 1, fp, uinfo);
index d9ff283f725e75dc900e436ebde42dee65e5fa53..79a60f020a21a294938b0b6ca11ae13b532a1aee 100644 (file)
@@ -118,7 +118,7 @@ static ssize_t atomic_counters_read(struct file *file, char __user *buf,
        u16 i;
        struct ipath_devdata *dd;
 
-       dd = file->f_dentry->d_inode->i_private;
+       dd = file->f_path.dentry->d_inode->i_private;
 
        for (i = 0; i < NUM_COUNTERS; i++)
                counters[i] = ipath_snap_cntr(dd, i);
@@ -138,7 +138,7 @@ static ssize_t atomic_node_info_read(struct file *file, char __user *buf,
        struct ipath_devdata *dd;
        u64 guid;
 
-       dd = file->f_dentry->d_inode->i_private;
+       dd = file->f_path.dentry->d_inode->i_private;
 
        guid = be64_to_cpu(dd->ipath_guid);
 
@@ -177,7 +177,7 @@ static ssize_t atomic_port_info_read(struct file *file, char __user *buf,
        u32 tmp, tmp2;
        struct ipath_devdata *dd;
 
-       dd = file->f_dentry->d_inode->i_private;
+       dd = file->f_path.dentry->d_inode->i_private;
 
        /* so we only initialize non-zero fields. */
        memset(portinfo, 0, sizeof portinfo);
@@ -324,7 +324,7 @@ static ssize_t flash_read(struct file *file, char __user *buf,
                goto bail;
        }
 
-       dd = file->f_dentry->d_inode->i_private;
+       dd = file->f_path.dentry->d_inode->i_private;
        if (ipath_eeprom_read(dd, pos, tmp, count)) {
                ipath_dev_err(dd, "failed to read from flash\n");
                ret = -ENXIO;
@@ -377,7 +377,7 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
                goto bail_tmp;
        }
 
-       dd = file->f_dentry->d_inode->i_private;
+       dd = file->f_path.dentry->d_inode->i_private;
        if (ipath_eeprom_write(dd, pos, tmp, count)) {
                ret = -ENXIO;
                ipath_dev_err(dd, "failed to write to flash\n");
index 57cdc1bc5f508d0168ca522b259fbd955919398e..27caf3b0648a64d69944a3bf7fee8c0bfd1f9609 100644 (file)
@@ -189,7 +189,7 @@ int mthca_create_ah(struct mthca_dev *dev,
 on_hca_fail:
        if (ah->type == MTHCA_AH_PCI_POOL) {
                ah->av = pci_pool_alloc(dev->av_table.pool,
-                                       SLAB_ATOMIC, &ah->avdma);
+                                       GFP_ATOMIC, &ah->avdma);
                if (!ah->av)
                        return -ENOMEM;
 
index 21422a3336ad19d4e4f4c522d68d6bd1770a7613..7ec7c4b937f9d82419f2ffab20e9d400590ad9e0 100644 (file)
@@ -124,7 +124,7 @@ static int mthca_query_device(struct ib_device *ibdev,
                props->max_map_per_fmr = 255;
        else
                props->max_map_per_fmr =
-                       (1 << (32 - long_log2(mdev->limits.num_mpts))) - 1;
+                       (1 << (32 - ilog2(mdev->limits.num_mpts))) - 1;
 
        err = 0;
  out:
@@ -816,7 +816,7 @@ static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *uda
                lkey = ucmd.lkey;
        }
 
-       ret = mthca_RESIZE_CQ(dev, cq->cqn, lkey, long_log2(entries), &status);
+       ret = mthca_RESIZE_CQ(dev, cq->cqn, lkey, ilog2(entries), &status);
        if (status)
                ret = -EINVAL;
 
index 33e3ba7937f1950baa4c70bffd21f900b1878068..d844a2569b471f1dcfc5b63ddacbc31b45db22df 100644 (file)
@@ -636,11 +636,11 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
 
        if (mthca_is_memfree(dev)) {
                if (qp->rq.max)
-                       qp_context->rq_size_stride = long_log2(qp->rq.max) << 3;
+                       qp_context->rq_size_stride = ilog2(qp->rq.max) << 3;
                qp_context->rq_size_stride |= qp->rq.wqe_shift - 4;
 
                if (qp->sq.max)
-                       qp_context->sq_size_stride = long_log2(qp->sq.max) << 3;
+                       qp_context->sq_size_stride = ilog2(qp->sq.max) << 3;
                qp_context->sq_size_stride |= qp->sq.wqe_shift - 4;
        }
 
index 34d2c4768962126230e5edc5e5414753daaa0e2d..10684da33d5853e18e0cea25d9b219fbcd2b3b54 100644 (file)
@@ -120,7 +120,7 @@ static void mthca_arbel_init_srq_context(struct mthca_dev *dev,
 
        memset(context, 0, sizeof *context);
 
-       logsize = long_log2(srq->max);
+       logsize = ilog2(srq->max);
        context->state_logsize_srqn = cpu_to_be32(logsize << 24 | srq->srqn);
        context->lkey = cpu_to_be32(srq->mr.ibmr.lkey);
        context->db_index = cpu_to_be32(srq->db_index);
@@ -213,7 +213,7 @@ int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd,
        if (!mthca_is_memfree(dev) && (ds > dev->limits.max_desc_sz))
                return -EINVAL;
 
-       srq->wqe_shift = long_log2(ds);
+       srq->wqe_shift = ilog2(ds);
 
        srq->srqn = mthca_alloc(&dev->srq_table.alloc);
        if (srq->srqn == -1)
index 5e122501fd80bdf35c1ba6608c2fe15b74c1202e..3aedd59b8a847edf20ecf2f75dece524f1e837da 100644 (file)
@@ -114,7 +114,7 @@ int iser_start_rdma_unaligned_sg(struct iscsi_iser_cmd_task  *iser_ctask,
 
        if (cmd_data_len > ISER_KMALLOC_THRESHOLD)
                mem = (void *)__get_free_pages(GFP_NOIO,
-                     long_log2(roundup_pow_of_two(cmd_data_len)) - PAGE_SHIFT);
+                     ilog2(roundup_pow_of_two(cmd_data_len)) - PAGE_SHIFT);
        else
                mem = kmalloc(cmd_data_len, GFP_NOIO);
 
@@ -211,7 +211,7 @@ void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask,
 
        if (cmd_data_len > ISER_KMALLOC_THRESHOLD)
                free_pages((unsigned long)mem_copy->copy_buf,
-                          long_log2(roundup_pow_of_two(cmd_data_len)) - PAGE_SHIFT);
+                          ilog2(roundup_pow_of_two(cmd_data_len)) - PAGE_SHIFT);
        else
                kfree(mem_copy->copy_buf);
 
index a005b1df5f1a57ddc32be556f8c503d8f4f7a4fa..da575deb3c7a690872f61a239070e5424ee74a19 100644 (file)
@@ -21,3 +21,4 @@ obj-$(CONFIG_INPUT_MOUSE)     += mouse/
 obj-$(CONFIG_INPUT_JOYSTICK)   += joystick/
 obj-$(CONFIG_INPUT_TOUCHSCREEN)        += touchscreen/
 obj-$(CONFIG_INPUT_MISC)       += misc/
+
index 35656cadc914555024bdac8b20f0b2ffc806d48f..783b3412ceadad32b77430c483ce3375faafc481 100644 (file)
@@ -203,7 +203,7 @@ static int erase_effect(struct input_dev *dev, int effect_id,
 }
 
 /**
- * input_ff_erase - erase an effect from device
+ * input_ff_erase - erase a force-feedback effect from device
  * @dev: input device to erase effect from
  * @effect_id: id of the ffect to be erased
  * @file: purported owner of the request
@@ -347,7 +347,7 @@ EXPORT_SYMBOL_GPL(input_ff_create);
 
 /**
  * input_ff_free() - frees force feedback portion of input device
- * @dev: input device supporintg force feedback
+ * @dev: input device supporting force feedback
  *
  * This function is only needed in error path as input core will
  * automatically free force feedback structures when device is
index cd8b7297e6df212a09c760e417d7c55dc6a8b436..eba18b6ac5e4dc3afe012436f62441f04675eaf9 100644 (file)
@@ -460,7 +460,7 @@ static void ml_ff_destroy(struct ff_device *ff)
 }
 
 /**
- * input_ff_create_memless() - create memoryless FF device
+ * input_ff_create_memless() - create memoryless force-feedback device
  * @dev: input device supporting force-feedback
  * @data: driver-specific data to be passed into @play_effect
  * @play_effect: driver-specific method for playing FF effect
index a0af97efe6ac0e23fd440cc1608db170890a005d..a00fe470a8292847f3607df00973440a98d43d45 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/kthread.h>
 #include <linux/sched.h>       /* HZ */
 #include <linux/mutex.h>
+#include <linux/freezer.h>
 
 /*#include <asm/io.h>*/
 
@@ -730,12 +731,6 @@ static int gameport_driver_remove(struct device *dev)
        return 0;
 }
 
-static struct bus_type gameport_bus = {
-       .name   = "gameport",
-       .probe  = gameport_driver_probe,
-       .remove = gameport_driver_remove,
-};
-
 static void gameport_add_driver(struct gameport_driver *drv)
 {
        int error;
@@ -781,6 +776,15 @@ static int gameport_bus_match(struct device *dev, struct device_driver *drv)
        return !gameport_drv->ignore;
 }
 
+static struct bus_type gameport_bus = {
+       .name           = "gameport",
+       .dev_attrs      = gameport_device_attrs,
+       .drv_attrs      = gameport_driver_attrs,
+       .match          = gameport_bus_match,
+       .probe          = gameport_driver_probe,
+       .remove         = gameport_driver_remove,
+};
+
 static void gameport_set_drv(struct gameport *gameport, struct gameport_driver *drv)
 {
        mutex_lock(&gameport->drv_mutex);
@@ -790,7 +794,6 @@ static void gameport_set_drv(struct gameport *gameport, struct gameport_driver *
 
 int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mode)
 {
-
        if (gameport->open) {
                if (gameport->open(gameport, mode)) {
                        return -1;
@@ -818,9 +821,6 @@ static int __init gameport_init(void)
 {
        int error;
 
-       gameport_bus.dev_attrs = gameport_device_attrs;
-       gameport_bus.drv_attrs = gameport_driver_attrs;
-       gameport_bus.match = gameport_bus_match;
        error = bus_register(&gameport_bus);
        if (error) {
                printk(KERN_ERR "gameport: failed to register gameport bus, error: %d\n", error);
index d65d81080257ef6355a913d49fe39f8b9075d8a6..6b4d4561d465bb133cb33d688c5fc4a4036f0de3 100644 (file)
@@ -309,7 +309,7 @@ static int __init l4_init(void)
        int i, cards = 0;
 
        if (!request_region(L4_PORT, 1, "lightning"))
-               return -1;
+               return -EBUSY;
 
        for (i = 0; i < 2; i++)
                if (l4_add_card(i) == 0)
@@ -319,7 +319,7 @@ static int __init l4_init(void)
 
        if (!cards) {
                release_region(L4_PORT, 1);
-               return -1;
+               return -ENODEV;
        }
 
        return 0;
index 1c8c8a5bc4a91c0076c9af4539ef3a768102afed..7cf2b4f603a36c278736b7e257e8318285ab2948 100644 (file)
@@ -37,7 +37,7 @@ static struct input_handler *input_table[8];
 
 /**
  * input_event() - report new input event
- * @handle: device that generated the event
+ * @dev: device that generated the event
  * @type: type of the event
  * @code: event code
  * @value: value of the event
@@ -900,6 +900,15 @@ struct class input_class = {
 };
 EXPORT_SYMBOL_GPL(input_class);
 
+/**
+ * input_allocate_device - allocate memory for new input device
+ *
+ * Returns prepared struct input_dev or NULL.
+ *
+ * NOTE: Use input_free_device() to free devices that have not been
+ * registered; input_unregister_device() should be used for already
+ * registered devices.
+ */
 struct input_dev *input_allocate_device(void)
 {
        struct input_dev *dev;
@@ -919,6 +928,20 @@ struct input_dev *input_allocate_device(void)
 }
 EXPORT_SYMBOL(input_allocate_device);
 
+/**
+ * input_free_device - free memory occupied by input_dev structure
+ * @dev: input device to free
+ *
+ * This function should only be used if input_register_device()
+ * was not called yet or if it failed. Once device was registered
+ * use input_unregister_device() and memory will be freed once last
+ * refrence to the device is dropped.
+ *
+ * Device should be allocated by input_allocate_device().
+ *
+ * NOTE: If there are references to the input device then memory
+ * will not be freed until last reference is dropped.
+ */
 void input_free_device(struct input_dev *dev)
 {
        if (dev) {
index 704bf70f1db739b7860b0a3b4c67b10e867c06ab..6279ced8a35b61d07bf9f27ec8c97ead8a7306f1 100644 (file)
@@ -521,11 +521,19 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv)
        for (i = 0; i < 2; i++)
                if (port->adi[i].length > 0) {
                        adi_init_center(port->adi + i);
-                       input_register_device(port->adi[i].dev);
+                       err = input_register_device(port->adi[i].dev);
+                       if (err)
+                               goto fail3;
                }
 
        return 0;
 
+ fail3: while (--i >= 0) {
+               if (port->adi[i].length > 0) {
+                       input_unregister_device(port->adi[i].dev);
+                       port->adi[i].dev = NULL;
+               }
+       }
  fail2:        for (i = 0; i < 2; i++)
                if (port->adi[i].dev)
                        input_free_device(port->adi[i].dev);
index 650acf3a30b70878b8075e58c8ac9d265600ee1d..e608691b5a61963b1928f9185e6c8f317af2a612 100644 (file)
@@ -147,7 +147,11 @@ static int __init amijoy_init(void)
                        amijoy_dev[i]->absmax[ABS_X + j] = 1;
                }
 
-               input_register_device(amijoy_dev[i]);
+               err = input_register_device(amijoy_dev[i]);
+               if (err) {
+                       input_free_device(amijoy_dev[i]);
+                       goto fail;
+               }
        }
        return 0;
 
index e9a02db36eccc3b0d431f1276f94fe090d4f2923..7ef68456d7d65c3cddc339a9018c828de48b3dcd 100644 (file)
@@ -434,6 +434,7 @@ static int analog_init_device(struct analog_port *port, struct analog *analog, i
 {
        struct input_dev *input_dev;
        int i, j, t, v, w, x, y, z;
+       int error;
 
        analog_name(analog);
        snprintf(analog->phys, sizeof(analog->phys),
@@ -505,7 +506,11 @@ static int analog_init_device(struct analog_port *port, struct analog *analog, i
 
        analog_decode(analog, port->axes, port->initial, port->buttons);
 
-       input_register_device(analog->dev);
+       error = input_register_device(analog->dev);
+       if (error) {
+               input_free_device(analog->dev);
+               return error;
+       }
 
        return 0;
 }
@@ -668,7 +673,8 @@ static int analog_connect(struct gameport *gameport, struct gameport_driver *drv
        return 0;
 
  fail3: while (--i >= 0)
-               input_unregister_device(port->analog[i].dev);
+               if (port->analog[i].mask)
+                       input_unregister_device(port->analog[i].dev);
  fail2:        gameport_close(gameport);
  fail1:        gameport_set_drvdata(gameport, NULL);
        kfree(port);
index d5e42eb88a207a610d7addab264a9c9fe58659fb..034ec39c251d3e732fe5f1f2913f9bfdd2b5ed01 100644 (file)
@@ -223,12 +223,15 @@ static int cobra_connect(struct gameport *gameport, struct gameport_driver *drv)
                for (j = 0; cobra_btn[j]; j++)
                        set_bit(cobra_btn[j], input_dev->keybit);
 
-               input_register_device(cobra->dev[i]);
+               err = input_register_device(cobra->dev[i]);
+               if (err)
+                       goto fail4;
        }
 
        return 0;
 
- fail3:        for (i = 0; i < 2; i++)
+ fail4:        input_free_device(cobra->dev[i]);
+ fail3:        while (--i >= 0)
                if (cobra->dev[i])
                        input_unregister_device(cobra->dev[i]);
  fail2:        gameport_close(gameport);
index e4a699f6ec87603d9f9e840f3353419cded537a4..bacbab5d1b6f5655d26fedb2e23e4d7f6fccd228 100644 (file)
@@ -341,7 +341,9 @@ static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv)
                input_dev->absflat[gf2k_abs[i]] = (i < 2) ? 24 : 0;
        }
 
-       input_register_device(gf2k->dev);
+       err = input_register_device(gf2k->dev);
+       if (err)
+               goto fail2;
 
        return 0;
 
index 62438944a69a558c8e7d0e1eb5b808a11d65464e..8120a9c40773ecc41c8d73837a50bfd287e0c65a 100644 (file)
@@ -423,7 +423,10 @@ static int get_and_decode_packet(struct grip_mp *grip, int flags)
 
                if (!port->registered) {
                        dbg("New Grip pad in multiport slot %d.\n", slot);
-                       register_slot(slot, grip);
+                       if (register_slot(slot, grip)) {
+                               port->mode = GRIP_MODE_RESET;
+                               port->dirty = 0;
+                       }
                }
                return flags;
        }
@@ -585,6 +588,7 @@ static int register_slot(int slot, struct grip_mp *grip)
        struct grip_port *port = grip->port[slot];
        struct input_dev *input_dev;
        int j, t;
+       int err;
 
        port->dev = input_dev = input_allocate_device();
        if (!input_dev)
@@ -610,7 +614,12 @@ static int register_slot(int slot, struct grip_mp *grip)
                if (t > 0)
                        set_bit(t, input_dev->keybit);
 
-       input_register_device(port->dev);
+       err = input_register_device(port->dev);
+       if (err) {
+               input_free_device(port->dev);
+               return err;
+       }
+
        port->registered = 1;
 
        if (port->dirty)                    /* report initial state, if any */
index 840ed9b512b26b5695e530545ba585741b1e9555..dbc5d92858b82f885e3c3758f4af9f1d624282ce 100644 (file)
@@ -250,7 +250,9 @@ static int guillemot_connect(struct gameport *gameport, struct gameport_driver *
        for (i = 0; (t = guillemot->type->btn[i]) >= 0; i++)
                set_bit(t, input_dev->keybit);
 
-       input_register_device(guillemot->dev);
+       err = input_register_device(guillemot->dev);
+       if (err)
+               goto fail2;
 
        return 0;
 
index 24c684bc63375917e44a06b3eae67947a501497d..3393a37fec399593ad4dd0f264e401157f80300d 100644 (file)
@@ -325,8 +325,8 @@ int iforce_init_device(struct iforce *iforce)
 
        if (i == 20) { /* 5 seconds */
                printk(KERN_ERR "iforce-main.c: Timeout waiting for response from device.\n");
-               input_free_device(input_dev);
-               return -ENODEV;
+               error = -ENODEV;
+               goto fail;
        }
 
 /*
@@ -439,10 +439,8 @@ int iforce_init_device(struct iforce *iforce)
                        set_bit(iforce->type->ff[i], input_dev->ffbit);
 
                error = input_ff_create(input_dev, ff_effects);
-               if (error) {
-                       input_free_device(input_dev);
-                       return error;
-               }
+               if (error)
+                       goto fail;
 
                ff = input_dev->ff;
                ff->upload = iforce_upload_effect;
@@ -455,22 +453,35 @@ int iforce_init_device(struct iforce *iforce)
  * Register input device.
  */
 
-       input_register_device(iforce->dev);
+       error = input_register_device(iforce->dev);
+       if (error)
+               goto fail;
 
        printk(KERN_DEBUG "iforce->dev->open = %p\n", iforce->dev->open);
 
        return 0;
+
+ fail: input_free_device(input_dev);
+       return error;
 }
 
 static int __init iforce_init(void)
 {
+       int err = 0;
+
 #ifdef CONFIG_JOYSTICK_IFORCE_USB
-       usb_register(&iforce_usb_driver);
+       err = usb_register(&iforce_usb_driver);
+       if (err)
+               return err;
 #endif
 #ifdef CONFIG_JOYSTICK_IFORCE_232
-       serio_register_driver(&iforce_serio_drv);
+       err = serio_register_driver(&iforce_serio_drv);
+#ifdef CONFIG_JOYSTICK_IFORCE_USB
+       if (err)
+               usb_deregister(&iforce_usb_driver);
 #endif
-       return 0;
+#endif
+       return err;
 }
 
 static void __exit iforce_exit(void)
index ca08f45c2040a5338e7987bd177a490c42eeac72..ec4be535f48391fc38c01dacc236d9ad3196cbe2 100644 (file)
@@ -141,21 +141,19 @@ static int iforce_serio_connect(struct serio *serio, struct serio_driver *drv)
        serio_set_drvdata(serio, iforce);
 
        err = serio_open(serio, drv);
-       if (err) {
-               serio_set_drvdata(serio, NULL);
-               kfree(iforce);
-               return err;
-       }
+       if (err)
+               goto fail1;
 
        err = iforce_init_device(iforce);
-       if (err) {
-               serio_close(serio);
-               serio_set_drvdata(serio, NULL);
-               kfree(iforce);
-               return -ENODEV;
-       }
+       if (err)
+               goto fail2;
 
        return 0;
+
+ fail2:        serio_close(serio);
+ fail1:        serio_set_drvdata(serio, NULL);
+       kfree(iforce);
+       return err;
 }
 
 static void iforce_serio_disconnect(struct serio *serio)
index bbfeb9c59b874c763158a1e458ce35e8a4844ebc..fec8b3d0967d937fdbee3f166937f0c5ea638bac 100644 (file)
@@ -283,7 +283,9 @@ static int interact_connect(struct gameport *gameport, struct gameport_driver *d
        for (i = 0; (t = interact_type[interact->type].btn[i]) >= 0; i++)
                set_bit(t, input_dev->keybit);
 
-       input_register_device(interact->dev);
+       err = input_register_device(interact->dev);
+       if (err)
+               goto fail2;
 
        return 0;
 
index e3d19444ba2e42300c38ceacf7a5b336fea838bd..4112789f11966a2433e4c570da06962915161e1d 100644 (file)
@@ -157,7 +157,7 @@ static int magellan_connect(struct serio *serio, struct serio_driver *drv)
        magellan = kzalloc(sizeof(struct magellan), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!magellan || !input_dev)
-               goto fail;
+               goto fail1;
 
        magellan->dev = input_dev;
        snprintf(magellan->phys, sizeof(magellan->phys), "%s/input0", serio->phys);
@@ -183,13 +183,17 @@ static int magellan_connect(struct serio *serio, struct serio_driver *drv)
 
        err = serio_open(serio, drv);
        if (err)
-               goto fail;
+               goto fail2;
+
+       err = input_register_device(magellan->dev);
+       if (err)
+               goto fail3;
 
-       input_register_device(magellan->dev);
        return 0;
 
- fail: serio_set_drvdata(serio, NULL);
-       input_free_device(input_dev);
+ fail3:        serio_close(serio);
+ fail2:        serio_set_drvdata(serio, NULL);
+ fail1:        input_free_device(input_dev);
        kfree(magellan);
        return err;
 }
@@ -227,8 +231,7 @@ static struct serio_driver magellan_drv = {
 
 static int __init magellan_init(void)
 {
-       serio_register_driver(&magellan_drv);
-       return 0;
+       return serio_register_driver(&magellan_drv);
 }
 
 static void __exit magellan_exit(void)
index 2a9808cf826f146182e8e4e9bc33e9883c08610e..08bf113e62ebd0d32e6a3fbfe42a4f8868a5d5ad 100644 (file)
@@ -215,7 +215,7 @@ static int spaceball_connect(struct serio *serio, struct serio_driver *drv)
        spaceball = kmalloc(sizeof(struct spaceball), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!spaceball || !input_dev)
-               goto fail;
+               goto fail1;
 
        spaceball->dev = input_dev;
        snprintf(spaceball->phys, sizeof(spaceball->phys), "%s/input0", serio->phys);
@@ -252,13 +252,17 @@ static int spaceball_connect(struct serio *serio, struct serio_driver *drv)
 
        err = serio_open(serio, drv);
        if (err)
-               goto fail;
+               goto fail2;
+
+       err = input_register_device(spaceball->dev);
+       if (err)
+               goto fail3;
 
-       input_register_device(spaceball->dev);
        return 0;
 
- fail: serio_set_drvdata(serio, NULL);
-       input_free_device(input_dev);
+ fail3:        serio_close(serio);
+ fail2:        serio_set_drvdata(serio, NULL);
+ fail1:        input_free_device(input_dev);
        kfree(spaceball);
        return err;
 }
@@ -296,8 +300,7 @@ static struct serio_driver spaceball_drv = {
 
 static int __init spaceball_init(void)
 {
-       serio_register_driver(&spaceball_drv);
-       return 0;
+       return serio_register_driver(&spaceball_drv);
 }
 
 static void __exit spaceball_exit(void)
index c4db0247c5fb13b8a4c1ba499665307ae874c46f..c9c79211af711c3b9a5631331612749b352b350f 100644 (file)
@@ -172,7 +172,7 @@ static int spaceorb_connect(struct serio *serio, struct serio_driver *drv)
        spaceorb = kzalloc(sizeof(struct spaceorb), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!spaceorb || !input_dev)
-               goto fail;
+               goto fail1;
 
        spaceorb->dev = input_dev;
        snprintf(spaceorb->phys, sizeof(spaceorb->phys), "%s/input0", serio->phys);
@@ -198,13 +198,17 @@ static int spaceorb_connect(struct serio *serio, struct serio_driver *drv)
 
        err = serio_open(serio, drv);
        if (err)
-               goto fail;
+               goto fail2;
+
+       err = input_register_device(spaceorb->dev);
+       if (err)
+               goto fail3;
 
-       input_register_device(spaceorb->dev);
        return 0;
 
- fail: serio_set_drvdata(serio, NULL);
-       input_free_device(input_dev);
+ fail3:        serio_close(serio);
+ fail2:        serio_set_drvdata(serio, NULL);
+ fail1:        input_free_device(input_dev);
        kfree(spaceorb);
        return err;
 }
@@ -242,8 +246,7 @@ static struct serio_driver spaceorb_drv = {
 
 static int __init spaceorb_init(void)
 {
-       serio_register_driver(&spaceorb_drv);
-       return 0;
+       return serio_register_driver(&spaceorb_drv);
 }
 
 static void __exit spaceorb_exit(void)
index 1ffb0322331112cf4f38126aef36fb1600c64270..ecb0916215fa05d3943e7a548e70d16fb1ea557e 100644 (file)
@@ -143,7 +143,7 @@ static int stinger_connect(struct serio *serio, struct serio_driver *drv)
        stinger = kmalloc(sizeof(struct stinger), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!stinger || !input_dev)
-               goto fail;
+               goto fail1;
 
        stinger->dev = input_dev;
        snprintf(stinger->phys, sizeof(stinger->phys), "%s/serio0", serio->phys);
@@ -168,13 +168,17 @@ static int stinger_connect(struct serio *serio, struct serio_driver *drv)
 
        err = serio_open(serio, drv);
        if (err)
-               goto fail;
+               goto fail2;
+
+       err = input_register_device(stinger->dev);
+       if (err)
+               goto fail3;
 
-       input_register_device(stinger->dev);
        return 0;
 
- fail: serio_set_drvdata(serio, NULL);
-       input_free_device(input_dev);
+ fail3:        serio_close(serio);
+ fail2:        serio_set_drvdata(serio, NULL);
+ fail1:        input_free_device(input_dev);
        kfree(stinger);
        return err;
 }
@@ -212,8 +216,7 @@ static struct serio_driver stinger_drv = {
 
 static int __init stinger_init(void)
 {
-       serio_register_driver(&stinger_drv);
-       return 0;
+       return serio_register_driver(&stinger_drv);
 }
 
 static void __exit stinger_exit(void)
index 49085df2d63156eded4d4388ba94230a6a9e7d0b..9cf17d6ced820ca2c891669674bea3813078404e 100644 (file)
@@ -194,7 +194,7 @@ static int twidjoy_connect(struct serio *serio, struct serio_driver *drv)
        twidjoy = kzalloc(sizeof(struct twidjoy), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!twidjoy || !input_dev)
-               goto fail;
+               goto fail1;
 
        twidjoy->dev = input_dev;
        snprintf(twidjoy->phys, sizeof(twidjoy->phys), "%s/input0", serio->phys);
@@ -221,13 +221,17 @@ static int twidjoy_connect(struct serio *serio, struct serio_driver *drv)
 
        err = serio_open(serio, drv);
        if (err)
-               goto fail;
+               goto fail2;
+
+       err = input_register_device(twidjoy->dev);
+       if (err)
+               goto fail3;
 
-       input_register_device(twidjoy->dev);
        return 0;
 
- fail: serio_set_drvdata(serio, NULL);
-       input_free_device(input_dev);
+ fail3:        serio_close(serio);
+ fail2:        serio_set_drvdata(serio, NULL);
+ fail1:        input_free_device(input_dev);
        kfree(twidjoy);
        return err;
 }
@@ -265,8 +269,7 @@ static struct serio_driver twidjoy_drv = {
 
 static int __init twidjoy_init(void)
 {
-       serio_register_driver(&twidjoy_drv);
-       return 0;
+       return serio_register_driver(&twidjoy_drv);
 }
 
 static void __exit twidjoy_exit(void)
index 35edea1ab955cd81688cccd17a2de87195e6c69d..29d339acf4307b451087c2b93831adee544648f1 100644 (file)
@@ -149,7 +149,7 @@ static int warrior_connect(struct serio *serio, struct serio_driver *drv)
        warrior = kzalloc(sizeof(struct warrior), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!warrior || !input_dev)
-               goto fail;
+               goto fail1;
 
        warrior->dev = input_dev;
        snprintf(warrior->phys, sizeof(warrior->phys), "%s/input0", serio->phys);
@@ -176,13 +176,17 @@ static int warrior_connect(struct serio *serio, struct serio_driver *drv)
 
        err = serio_open(serio, drv);
        if (err)
-               goto fail;
+               goto fail2;
+
+       err = input_register_device(warrior->dev);
+       if (err)
+               goto fail3;
 
-       input_register_device(warrior->dev);
        return 0;
 
- fail: serio_set_drvdata(serio, NULL);
-       input_free_device(input_dev);
+ fail3:        serio_close(serio);
+ fail2:        serio_set_drvdata(serio, NULL);
+ fail1:        input_free_device(input_dev);
        kfree(warrior);
        return err;
 }
@@ -220,8 +224,7 @@ static struct serio_driver warrior_drv = {
 
 static int __init warrior_init(void)
 {
-       serio_register_driver(&warrior_drv);
-       return 0;
+       return serio_register_driver(&warrior_drv);
 }
 
 static void __exit warrior_exit(void)
index 81a333f7301052590c0c82b94b41dcd3939a0b7c..049f2f544e75e94a9d40aee991df4cf8d45510f4 100644 (file)
@@ -203,4 +203,15 @@ config KEYBOARD_OMAP
          To compile this driver as a module, choose M here: the
          module will be called omap-keypad.
 
+config KEYBOARD_AAED2000
+       tristate "AAED-2000 keyboard"
+       depends on MACH_AAED2000
+       default y
+       help
+         Say Y here to enable the keyboard on the Agilent AAED-2000
+         development board.
+
+         To compile this driver as a module, choose M here: the
+         module will be called aaed2000_kbd.
+
 endif
index 4c79e7bc9d06df25bfd98a71a1acd480ab98201e..568797907347b9e0ace4898ab425e8a9ba16683d 100644 (file)
@@ -17,4 +17,5 @@ obj-$(CONFIG_KEYBOARD_SPITZ)          += spitzkbd.o
 obj-$(CONFIG_KEYBOARD_HIL)             += hil_kbd.o
 obj-$(CONFIG_KEYBOARD_HIL_OLD)         += hilkbd.o
 obj-$(CONFIG_KEYBOARD_OMAP)             += omap-keypad.o
+obj-$(CONFIG_KEYBOARD_AAED2000)         += aaed2000_kbd.o
 
diff --git a/drivers/input/keyboard/aaed2000_kbd.c b/drivers/input/keyboard/aaed2000_kbd.c
new file mode 100644 (file)
index 0000000..65fcb6a
--- /dev/null
@@ -0,0 +1,203 @@
+/*
+ *  Keyboard driver for the AAED-2000 dev board
+ *
+ *  Copyright (c) 2006 Nicolas Bellido Y Ortega
+ *
+ *  Based on corgikbd.c
+ *
+ *  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/delay.h>
+#include <linux/platform_device.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/jiffies.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/workqueue.h>
+
+#include <asm/arch/hardware.h>
+#include <asm/arch/aaed2000.h>
+
+#define KB_ROWS                        12
+#define KB_COLS                        8
+#define KB_ROWMASK(r)          (1 << (r))
+#define SCANCODE(r,c)          (((c) * KB_ROWS) + (r))
+#define NR_SCANCODES           (KB_COLS * KB_ROWS)
+
+#define SCAN_INTERVAL          (50) /* ms */
+#define KB_ACTIVATE_DELAY      (20) /* us */
+
+static unsigned char aaedkbd_keycode[NR_SCANCODES] = {
+       KEY_9, KEY_0, KEY_MINUS, KEY_EQUAL, KEY_BACKSPACE, 0, KEY_SPACE, KEY_KP6, 0, KEY_KPDOT, 0, 0,
+       KEY_K, KEY_M, KEY_O, KEY_DOT, KEY_SLASH, 0, KEY_F, 0, 0, 0, KEY_LEFTSHIFT, 0,
+       KEY_I, KEY_P, KEY_LEFTBRACE, KEY_RIGHTBRACE, KEY_BACKSLASH, 0, 0, 0, 0, 0, KEY_RIGHTSHIFT, 0,
+       KEY_8, KEY_L, KEY_SEMICOLON, KEY_APOSTROPHE, KEY_ENTER, 0, 0, 0, 0, 0, 0, 0,
+       KEY_J, KEY_H, KEY_B, KEY_KP8, KEY_KP4, 0, KEY_C, KEY_D, KEY_S, KEY_A, 0, KEY_CAPSLOCK,
+       KEY_Y, KEY_U, KEY_N, KEY_T, 0, 0, KEY_R, KEY_E, KEY_W, KEY_Q, 0, KEY_TAB,
+       KEY_7, KEY_6, KEY_G, 0, KEY_5, 0, KEY_4, KEY_3, KEY_2, KEY_1, 0, KEY_GRAVE,
+       0, 0, KEY_COMMA, 0, KEY_KP2, 0, KEY_V, KEY_LEFTALT, KEY_X, KEY_Z, 0, KEY_LEFTCTRL
+};
+
+struct aaedkbd {
+       unsigned char keycode[ARRAY_SIZE(aaedkbd_keycode)];
+       struct input_dev *input;
+       struct work_struct workq;
+       int kbdscan_state[KB_COLS];
+       int kbdscan_count[KB_COLS];
+};
+
+#define KBDSCAN_STABLE_COUNT 2
+
+static void aaedkbd_report_col(struct aaedkbd *aaedkbd,
+                               unsigned int col, unsigned int rowd)
+{
+       unsigned int scancode, pressed;
+       unsigned int row;
+
+       for (row = 0; row < KB_ROWS; row++) {
+               scancode = SCANCODE(row, col);
+               pressed = rowd & KB_ROWMASK(row);
+
+               input_report_key(aaedkbd->input, aaedkbd->keycode[scancode], pressed);
+       }
+}
+
+/* Scan the hardware keyboard and push any changes up through the input layer */
+static void aaedkbd_work(void *data)
+{
+       struct aaedkbd *aaedkbd = data;
+       unsigned int col, rowd;
+
+       col = 0;
+       do {
+               AAEC_GPIO_KSCAN = col + 8;
+               udelay(KB_ACTIVATE_DELAY);
+               rowd = AAED_EXT_GPIO & AAED_EGPIO_KBD_SCAN;
+
+               if (rowd != aaedkbd->kbdscan_state[col]) {
+                       aaedkbd->kbdscan_count[col] = 0;
+                       aaedkbd->kbdscan_state[col] = rowd;
+               } else if (++aaedkbd->kbdscan_count[col] >= KBDSCAN_STABLE_COUNT) {
+                       aaedkbd_report_col(aaedkbd, col, rowd);
+                       col++;
+               }
+       } while (col < KB_COLS);
+
+       AAEC_GPIO_KSCAN = 0x07;
+       input_sync(aaedkbd->input);
+
+       schedule_delayed_work(&aaedkbd->workq, msecs_to_jiffies(SCAN_INTERVAL));
+}
+
+static int aaedkbd_open(struct input_dev *indev)
+{
+       struct aaedkbd *aaedkbd = indev->private;
+
+       schedule_delayed_work(&aaedkbd->workq, msecs_to_jiffies(SCAN_INTERVAL));
+
+       return 0;
+}
+
+static void aaedkbd_close(struct input_dev *indev)
+{
+       struct aaedkbd *aaedkbd = indev->private;
+
+       cancel_delayed_work(&aaedkbd->workq);
+       flush_scheduled_work();
+}
+
+static int __devinit aaedkbd_probe(struct platform_device *pdev)
+{
+       struct aaedkbd *aaedkbd;
+       struct input_dev *input_dev;
+       int i;
+       int error;
+
+       aaedkbd = kzalloc(sizeof(struct aaedkbd), GFP_KERNEL);
+       input_dev = input_allocate_device();
+       if (!aaedkbd || !input_dev) {
+               error = -ENOMEM;
+               goto fail;
+       }
+
+       platform_set_drvdata(pdev, aaedkbd);
+
+       aaedkbd->input = input_dev;
+
+       /* Init keyboard rescan workqueue */
+       INIT_WORK(&aaedkbd->workq, aaedkbd_work, aaedkbd);
+
+       memcpy(aaedkbd->keycode, aaedkbd_keycode, sizeof(aaedkbd->keycode));
+
+       input_dev->name = "AAED-2000 Keyboard";
+       input_dev->phys = "aaedkbd/input0";
+       input_dev->id.bustype = BUS_HOST;
+       input_dev->id.vendor = 0x0001;
+       input_dev->id.product = 0x0001;
+       input_dev->id.version = 0x0100;
+       input_dev->cdev.dev = &pdev->dev;
+       input_dev->private = aaedkbd;
+
+       input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
+       input_dev->keycode = aaedkbd->keycode;
+       input_dev->keycodesize = sizeof(unsigned char);
+       input_dev->keycodemax = ARRAY_SIZE(aaedkbd_keycode);
+
+       for (i = 0; i < ARRAY_SIZE(aaedkbd_keycode); i++)
+               set_bit(aaedkbd->keycode[i], input_dev->keybit);
+       clear_bit(0, input_dev->keybit);
+
+       input_dev->open = aaedkbd_open;
+       input_dev->close = aaedkbd_close;
+
+       error = input_register_device(aaedkbd->input);
+       if (error)
+               goto fail;
+
+       return 0;
+
+ fail: kfree(aaedkbd);
+       input_free_device(input_dev);
+       return error;
+}
+
+static int __devexit aaedkbd_remove(struct platform_device *pdev)
+{
+       struct aaedkbd *aaedkbd = platform_get_drvdata(pdev);
+
+       input_unregister_device(aaedkbd->input);
+       kfree(aaedkbd);
+
+       return 0;
+}
+
+static struct platform_driver aaedkbd_driver = {
+       .probe          = aaedkbd_probe,
+       .remove         = __devexit_p(aaedkbd_remove),
+       .driver         = {
+               .name   = "aaed2000-keyboard",
+       },
+};
+
+static int __init aaedkbd_init(void)
+{
+       return platform_driver_register(&aaedkbd_driver);
+}
+
+static void __exit aaedkbd_exit(void)
+{
+       platform_driver_unregister(&aaedkbd_driver);
+}
+
+module_init(aaedkbd_init);
+module_exit(aaedkbd_exit);
+
+MODULE_AUTHOR("Nicolas Bellido Y Ortega");
+MODULE_DESCRIPTION("AAED-2000 Keyboard Driver");
+MODULE_LICENSE("GPLv2");
index 8abdbd0ee8f9cfca5da18e959e5c3b3e75e9de45..16583d71753b9ec8faca41a4e2eb5584105719cd 100644 (file)
@@ -190,7 +190,7 @@ static int __init amikbd_init(void)
        int i, j;
 
        if (!AMIGAHW_PRESENT(AMI_KEYBOARD))
-               return -EIO;
+               return -ENODEV;
 
        if (!request_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100, "amikeyb"))
                return -EBUSY;
@@ -198,8 +198,8 @@ static int __init amikbd_init(void)
        amikbd_dev = input_allocate_device();
        if (!amikbd_dev) {
                printk(KERN_ERR "amikbd: not enough memory for input device\n");
-               release_mem_region(CIAA_PHYSADDR - 1 + 0xb00, 0x100);
-               return -ENOMEM;
+               err = -ENOMEM;
+               goto fail1;
        }
 
        amikbd_dev->name = "Amiga Keyboard";
@@ -231,10 +231,22 @@ static int __init amikbd_init(void)
                memcpy(key_maps[i], temp_map, sizeof(temp_map));
        }
        ciaa.cra &= ~0x41;       /* serial data in, turn off TA */
-       request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", amikbd_interrupt);
+       if (request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd",
+                       amikbd_interrupt)) {
+               err = -EBUSY;
+               goto fail2;
+       }
+
+       err = input_register_device(amikbd_dev);
+       if (err)
+               goto fail3;
 
-       input_register_device(amikbd_dev);
        return 0;
+
+ fail3:        free_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt);
+ fail2:        input_free_device(amikbd_dev);
+ fail1:        release_mem_region(CIAA_PHYSADDR - 1 + 0xb00, 0x100);
+       return err;
 }
 
 static void __exit amikbd_exit(void)
index 8451b29a3db534ff1b1d746b35e88d334b7b07dc..c621a9177a565353c424b610d2901a4c4ff87834 100644 (file)
@@ -939,7 +939,7 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
        atkbd = kzalloc(sizeof(struct atkbd), GFP_KERNEL);
        dev = input_allocate_device();
        if (!atkbd || !dev)
-               goto fail;
+               goto fail1;
 
        atkbd->dev = dev;
        ps2_init(&atkbd->ps2dev, serio);
@@ -967,14 +967,13 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
 
        err = serio_open(serio, drv);
        if (err)
-               goto fail;
+               goto fail2;
 
        if (atkbd->write) {
 
                if (atkbd_probe(atkbd)) {
-                       serio_close(serio);
                        err = -ENODEV;
-                       goto fail;
+                       goto fail3;
                }
 
                atkbd->set = atkbd_select_set(atkbd, atkbd_set, atkbd_extra);
@@ -988,16 +987,22 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
        atkbd_set_keycode_table(atkbd);
        atkbd_set_device_attrs(atkbd);
 
-       sysfs_create_group(&serio->dev.kobj, &atkbd_attribute_group);
+       err = sysfs_create_group(&serio->dev.kobj, &atkbd_attribute_group);
+       if (err)
+               goto fail3;
 
        atkbd_enable(atkbd);
 
-       input_register_device(atkbd->dev);
+       err = input_register_device(atkbd->dev);
+       if (err)
+               goto fail4;
 
        return 0;
 
- fail: serio_set_drvdata(serio, NULL);
-       input_free_device(dev);
+ fail4: sysfs_remove_group(&serio->dev.kobj, &atkbd_attribute_group);
+ fail3:        serio_close(serio);
+ fail2:        serio_set_drvdata(serio, NULL);
+ fail1:        input_free_device(dev);
        kfree(atkbd);
        return err;
 }
@@ -1133,9 +1138,11 @@ static ssize_t atkbd_show_extra(struct atkbd *atkbd, char *buf)
 
 static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t count)
 {
-       struct input_dev *new_dev;
+       struct input_dev *old_dev, *new_dev;
        unsigned long value;
        char *rest;
+       int err;
+       unsigned char old_extra, old_set;
 
        if (!atkbd->write)
                return -EIO;
@@ -1147,17 +1154,36 @@ static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun
        if (atkbd->extra != value) {
                /*
                 * Since device's properties will change we need to
-                * unregister old device. But allocate new one first
-                * to make sure we have it.
+                * unregister old device. But allocate and register
+                * new one first to make sure we have it.
                 */
-               if (!(new_dev = input_allocate_device()))
+               old_dev = atkbd->dev;
+               old_extra = atkbd->extra;
+               old_set = atkbd->set;
+
+               new_dev = input_allocate_device();
+               if (!new_dev)
                        return -ENOMEM;
-               input_unregister_device(atkbd->dev);
+
                atkbd->dev = new_dev;
                atkbd->set = atkbd_select_set(atkbd, atkbd->set, value);
                atkbd_activate(atkbd);
+               atkbd_set_keycode_table(atkbd);
                atkbd_set_device_attrs(atkbd);
-               input_register_device(atkbd->dev);
+
+               err = input_register_device(atkbd->dev);
+               if (err) {
+                       input_free_device(new_dev);
+
+                       atkbd->dev = old_dev;
+                       atkbd->set = atkbd_select_set(atkbd, old_set, old_extra);
+                       atkbd_set_keycode_table(atkbd);
+                       atkbd_set_device_attrs(atkbd);
+
+                       return err;
+               }
+               input_unregister_device(old_dev);
+
        }
        return count;
 }
@@ -1169,23 +1195,41 @@ static ssize_t atkbd_show_scroll(struct atkbd *atkbd, char *buf)
 
 static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t count)
 {
-       struct input_dev *new_dev;
+       struct input_dev *old_dev, *new_dev;
        unsigned long value;
        char *rest;
+       int err;
+       unsigned char old_scroll;
 
        value = simple_strtoul(buf, &rest, 10);
        if (*rest || value > 1)
                return -EINVAL;
 
        if (atkbd->scroll != value) {
-               if (!(new_dev = input_allocate_device()))
+               old_dev = atkbd->dev;
+               old_scroll = atkbd->scroll;
+
+               new_dev = input_allocate_device();
+               if (!new_dev)
                        return -ENOMEM;
-               input_unregister_device(atkbd->dev);
+
                atkbd->dev = new_dev;
                atkbd->scroll = value;
                atkbd_set_keycode_table(atkbd);
                atkbd_set_device_attrs(atkbd);
-               input_register_device(atkbd->dev);
+
+               err = input_register_device(atkbd->dev);
+               if (err) {
+                       input_free_device(new_dev);
+
+                       atkbd->scroll = old_scroll;
+                       atkbd->dev = old_dev;
+                       atkbd_set_keycode_table(atkbd);
+                       atkbd_set_device_attrs(atkbd);
+
+                       return err;
+               }
+               input_unregister_device(old_dev);
        }
        return count;
 }
@@ -1197,9 +1241,11 @@ static ssize_t atkbd_show_set(struct atkbd *atkbd, char *buf)
 
 static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count)
 {
-       struct input_dev *new_dev;
+       struct input_dev *old_dev, *new_dev;
        unsigned long value;
        char *rest;
+       int err;
+       unsigned char old_set, old_extra;
 
        if (!atkbd->write)
                return -EIO;
@@ -1209,15 +1255,32 @@ static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count)
                return -EINVAL;
 
        if (atkbd->set != value) {
-               if (!(new_dev = input_allocate_device()))
+               old_dev = atkbd->dev;
+               old_extra = atkbd->extra;
+               old_set = atkbd->set;
+
+               new_dev = input_allocate_device();
+               if (!new_dev)
                        return -ENOMEM;
-               input_unregister_device(atkbd->dev);
+
                atkbd->dev = new_dev;
                atkbd->set = atkbd_select_set(atkbd, value, atkbd->extra);
                atkbd_activate(atkbd);
                atkbd_set_keycode_table(atkbd);
                atkbd_set_device_attrs(atkbd);
-               input_register_device(atkbd->dev);
+
+               err = input_register_device(atkbd->dev);
+               if (err) {
+                       input_free_device(new_dev);
+
+                       atkbd->dev = old_dev;
+                       atkbd->set = atkbd_select_set(atkbd, old_set, old_extra);
+                       atkbd_set_keycode_table(atkbd);
+                       atkbd_set_device_attrs(atkbd);
+
+                       return err;
+               }
+               input_unregister_device(old_dev);
        }
        return count;
 }
@@ -1229,9 +1292,11 @@ static ssize_t atkbd_show_softrepeat(struct atkbd *atkbd, char *buf)
 
 static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t count)
 {
-       struct input_dev *new_dev;
+       struct input_dev *old_dev, *new_dev;
        unsigned long value;
        char *rest;
+       int err;
+       unsigned char old_softrepeat, old_softraw;
 
        if (!atkbd->write)
                return -EIO;
@@ -1241,15 +1306,32 @@ static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t
                return -EINVAL;
 
        if (atkbd->softrepeat != value) {
-               if (!(new_dev = input_allocate_device()))
+               old_dev = atkbd->dev;
+               old_softrepeat = atkbd->softrepeat;
+               old_softraw = atkbd->softraw;
+
+               new_dev = input_allocate_device();
+               if (!new_dev)
                        return -ENOMEM;
-               input_unregister_device(atkbd->dev);
+
                atkbd->dev = new_dev;
                atkbd->softrepeat = value;
                if (atkbd->softrepeat)
                        atkbd->softraw = 1;
                atkbd_set_device_attrs(atkbd);
-               input_register_device(atkbd->dev);
+
+               err = input_register_device(atkbd->dev);
+               if (err) {
+                       input_free_device(new_dev);
+
+                       atkbd->dev = old_dev;
+                       atkbd->softrepeat = old_softrepeat;
+                       atkbd->softraw = old_softraw;
+                       atkbd_set_device_attrs(atkbd);
+
+                       return err;
+               }
+               input_unregister_device(old_dev);
        }
        return count;
 }
@@ -1262,22 +1344,39 @@ static ssize_t atkbd_show_softraw(struct atkbd *atkbd, char *buf)
 
 static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t count)
 {
-       struct input_dev *new_dev;
+       struct input_dev *old_dev, *new_dev;
        unsigned long value;
        char *rest;
+       int err;
+       unsigned char old_softraw;
 
        value = simple_strtoul(buf, &rest, 10);
        if (*rest || value > 1)
                return -EINVAL;
 
        if (atkbd->softraw != value) {
-               if (!(new_dev = input_allocate_device()))
+               old_dev = atkbd->dev;
+               old_softraw = atkbd->softraw;
+
+               new_dev = input_allocate_device();
+               if (!new_dev)
                        return -ENOMEM;
-               input_unregister_device(atkbd->dev);
+
                atkbd->dev = new_dev;
                atkbd->softraw = value;
                atkbd_set_device_attrs(atkbd);
-               input_register_device(atkbd->dev);
+
+               err = input_register_device(atkbd->dev);
+               if (err) {
+                       input_free_device(new_dev);
+
+                       atkbd->dev = old_dev;
+                       atkbd->softraw = old_softraw;
+                       atkbd_set_device_attrs(atkbd);
+
+                       return err;
+               }
+               input_unregister_device(old_dev);
        }
        return count;
 }
@@ -1290,8 +1389,7 @@ static ssize_t atkbd_show_err_count(struct atkbd *atkbd, char *buf)
 
 static int __init atkbd_init(void)
 {
-       serio_register_driver(&atkbd_drv);
-       return 0;
+       return serio_register_driver(&atkbd_drv);
 }
 
 static void __exit atkbd_exit(void)
index befdd6006b500d093be9036386b491da39496c9b..1016c94e65db684c9a84cfdc33478b42dc581640 100644 (file)
@@ -291,15 +291,12 @@ static int __init corgikbd_probe(struct platform_device *pdev)
 {
        struct corgikbd *corgikbd;
        struct input_dev *input_dev;
-       int i;
+       int i, err = -ENOMEM;
 
        corgikbd = kzalloc(sizeof(struct corgikbd), GFP_KERNEL);
        input_dev = input_allocate_device();
-       if (!corgikbd || !input_dev) {
-               kfree(corgikbd);
-               input_free_device(input_dev);
-               return -ENOMEM;
-       }
+       if (!corgikbd || !input_dev)
+               goto fail;
 
        platform_set_drvdata(pdev, corgikbd);
 
@@ -341,7 +338,9 @@ static int __init corgikbd_probe(struct platform_device *pdev)
        set_bit(SW_TABLET_MODE, input_dev->swbit);
        set_bit(SW_HEADPHONE_INSERT, input_dev->swbit);
 
-       input_register_device(corgikbd->input);
+       err = input_register_device(corgikbd->input);
+       if (err)
+               goto fail;
 
        mod_timer(&corgikbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
 
@@ -362,6 +361,10 @@ static int __init corgikbd_probe(struct platform_device *pdev)
        pxa_gpio_mode(CORGI_GPIO_AK_INT | GPIO_IN);
 
        return 0;
+
+ fail: input_free_device(input_dev);
+       kfree(corgikbd);
+       return err;
 }
 
 static int corgikbd_remove(struct platform_device *pdev)
index e774dd31e99b7bf2ca7d2503f5d84decb08b1daa..7cc9728b04df5559b65f71cd8d7131e0d12d88bc 100644 (file)
@@ -381,8 +381,7 @@ struct serio_driver hil_kbd_serio_drv = {
 
 static int __init hil_kbd_init(void)
 {
-       serio_register_driver(&hil_kbd_serio_drv);
-        return 0;
+       return serio_register_driver(&hil_kbd_serio_drv);
 }
                 
 static void __exit hil_kbd_exit(void)
index b7f049b45b6bffc7fb0230a86afe23b2cf8953dc..3d4d0a0ede28333bb3bc7b12ae24bcd7bd116e2e 100644 (file)
@@ -646,7 +646,7 @@ lkkbd_connect (struct serio *serio, struct serio_driver *drv)
        input_dev = input_allocate_device ();
        if (!lk || !input_dev) {
                err = -ENOMEM;
-               goto fail;
+               goto fail1;
        }
 
        lk->serio = serio;
@@ -691,15 +691,19 @@ lkkbd_connect (struct serio *serio, struct serio_driver *drv)
 
        err = serio_open (serio, drv);
        if (err)
-               goto fail;
+               goto fail2;
+
+       err = input_register_device (lk->dev);
+       if (err)
+               goto fail3;
 
-       input_register_device (lk->dev);
        lk->serio->write (lk->serio, LK_CMD_POWERCYCLE_RESET);
 
        return 0;
 
- fail: serio_set_drvdata (serio, NULL);
-       input_free_device (input_dev);
+ fail3:        serio_close (serio);
+ fail2:        serio_set_drvdata (serio, NULL);
+ fail1:        input_free_device (input_dev);
        kfree (lk);
        return err;
 }
@@ -749,8 +753,7 @@ static struct serio_driver lkkbd_drv = {
 static int __init
 lkkbd_init (void)
 {
-       serio_register_driver(&lkkbd_drv);
-       return 0;
+       return serio_register_driver(&lkkbd_drv);
 }
 
 static void __exit
index 5788dbc317bba3226266b28e78dc0890fe7125e7..2ade5186cc418dab9bfb831ce610b77a44c5ece7 100644 (file)
@@ -193,22 +193,22 @@ static int locomokbd_probe(struct locomo_dev *dev)
 {
        struct locomokbd *locomokbd;
        struct input_dev *input_dev;
-       int i, ret;
+       int i, err;
 
        locomokbd = kzalloc(sizeof(struct locomokbd), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!locomokbd || !input_dev) {
-               ret = -ENOMEM;
-               goto free;
+               err = -ENOMEM;
+               goto err_free_mem;
        }
 
        /* try and claim memory region */
        if (!request_mem_region((unsigned long) dev->mapbase,
                                dev->length,
                                LOCOMO_DRIVER_NAME(dev))) {
-               ret = -EBUSY;
+               err = -EBUSY;
                printk(KERN_ERR "locomokbd: Can't acquire access to io memory for keyboard\n");
-               goto free;
+               goto err_free_mem;
        }
 
        locomokbd->ldev = dev;
@@ -244,24 +244,28 @@ static int locomokbd_probe(struct locomo_dev *dev)
        clear_bit(0, input_dev->keybit);
 
        /* attempt to get the interrupt */
-       ret = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd);
-       if (ret) {
+       err = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd);
+       if (err) {
                printk(KERN_ERR "locomokbd: Can't get irq for keyboard\n");
-               goto out;
+               goto err_release_region;
        }
 
-       input_register_device(locomokbd->input);
+       err = input_register_device(locomokbd->input);
+       if (err)
+               goto err_free_irq;
 
        return 0;
 
-out:
+ err_free_irq:
+       free_irq(dev->irq[0], locomokbd);
+ err_release_region:
        release_mem_region((unsigned long) dev->mapbase, dev->length);
        locomo_set_drvdata(dev, NULL);
-free:
+ err_free_mem:
        input_free_device(input_dev);
        kfree(locomokbd);
 
-       return ret;
+       return err;
 }
 
 static int locomokbd_remove(struct locomo_dev *dev)
diff --git a/drivers/input/keyboard/maple_keyb.c b/drivers/input/keyboard/maple_keyb.c
deleted file mode 100644 (file)
index cc6aaf9..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- *     $Id: maple_keyb.c,v 1.4 2004/03/22 01:18:15 lethal Exp $
- *     SEGA Dreamcast keyboard driver
- *     Based on drivers/usb/usbkbd.c
- */
-
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/input.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/timer.h>
-#include <linux/maple.h>
-
-MODULE_AUTHOR("YAEGASHI Takeshi <t@keshi.org>");
-MODULE_DESCRIPTION("SEGA Dreamcast keyboard driver");
-MODULE_LICENSE("GPL");
-
-static unsigned char dc_kbd_keycode[256] = {
-         0,  0,  0,  0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38,
-        50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44,  2,  3,
-         4,  5,  6,  7,  8,  9, 10, 11, 28,  1, 14, 15, 57, 12, 13, 26,
-        27, 43, 43, 39, 40, 41, 51, 52, 53, 58, 59, 60, 61, 62, 63, 64,
-        65, 66, 67, 68, 87, 88, 99, 70,119,110,102,104,111,107,109,106,
-       105,108,103, 69, 98, 55, 74, 78, 96, 79, 80, 81, 75, 76, 77, 71,
-        72, 73, 82, 83, 86,127,116,117,183,184,185,186,187,188,189,190,
-       191,192,193,194,134,138,130,132,128,129,131,137,133,135,136,113,
-       115,114,  0,  0,  0,121,  0, 89, 93,124, 92, 94, 95,  0,  0,  0,
-       122,123, 90, 91, 85,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-        29, 42, 56,125, 97, 54,100,126,164,166,165,163,161,115,114,113,
-       150,158,159,128,136,177,178,176,142,152,173,140
-};
-
-
-struct dc_kbd {
-       struct input_dev *dev;
-       unsigned char new[8];
-       unsigned char old[8];
-};
-
-
-static void dc_scan_kbd(struct dc_kbd *kbd)
-{
-       int i;
-       struct input_dev *dev = kbd->dev;
-
-       for (i = 0; i < 8; i++)
-               input_report_key(dev, dc_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1);
-
-       for (i = 2; i < 8; i++) {
-
-               if (kbd->old[i] > 3 && memscan(kbd->new + 2, kbd->old[i], 6) == NULL) {
-                       if (dc_kbd_keycode[kbd->old[i]])
-                               input_report_key(dev, dc_kbd_keycode[kbd->old[i]], 0);
-                       else
-                               printk("Unknown key (scancode %#x) released.",
-                                      kbd->old[i]);
-               }
-
-               if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) != NULL) {
-                       if(dc_kbd_keycode[kbd->new[i]])
-                               input_report_key(dev, dc_kbd_keycode[kbd->new[i]], 1);
-                       else
-                               printk("Unknown key (scancode %#x) pressed.",
-                                      kbd->new[i]);
-               }
-       }
-
-       input_sync(dev);
-
-       memcpy(kbd->old, kbd->new, 8);
-}
-
-
-static void dc_kbd_callback(struct mapleq *mq)
-{
-       struct maple_device *mapledev = mq->dev;
-       struct dc_kbd *kbd = mapledev->private_data;
-       unsigned long *buf = mq->recvbuf;
-
-       if (buf[1] == mapledev->function) {
-               memcpy(kbd->new, buf + 2, 8);
-               dc_scan_kbd(kbd);
-       }
-}
-
-static int dc_kbd_connect(struct maple_device *dev)
-{
-       struct dc_kbd *kbd;
-       struct input_dev *input_dev;
-       unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]);
-       int i;
-
-       dev->private_data = kbd = kzalloc(sizeof(struct dc_kbd), GFP_KERNEL);
-       input_dev = input_allocate_device();
-       if (!kbd || !input_dev) {
-               kfree(kbd);
-               input_free_device(input_dev);
-               return -ENOMEM;
-       }
-
-       kbd->dev = input_dev;
-
-       input_dev->name = dev->product_name;
-       input_dev->id.bustype = BUS_MAPLE;
-       input_dev->private = kbd;
-       input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
-       for (i = 0; i < 255; i++)
-               set_bit(dc_kbd_keycode[i], input_dev->keybit);
-       clear_bit(0, input_dev->keybit);
-
-       input_register_device(kbd->dev);
-
-       maple_getcond_callback(dev, dc_kbd_callback, 1, MAPLE_FUNC_KEYBOARD);
-       return 0;
-}
-
-
-static void dc_kbd_disconnect(struct maple_device *dev)
-{
-       struct dc_kbd *kbd = dev->private_data;
-
-       input_unregister_device(kbd->dev);
-       kfree(kbd);
-}
-
-
-static struct maple_driver dc_kbd_driver = {
-       .function =     MAPLE_FUNC_KEYBOARD,
-       .name =         "Dreamcast keyboard",
-       .connect =      dc_kbd_connect,
-       .disconnect =   dc_kbd_disconnect,
-};
-
-
-static int __init dc_kbd_init(void)
-{
-       maple_register_driver(&dc_kbd_driver);
-       return 0;
-}
-
-
-static void __exit dc_kbd_exit(void)
-{
-       maple_unregister_driver(&dc_kbd_driver);
-}
-
-
-module_init(dc_kbd_init);
-module_exit(dc_kbd_exit);
-
-/*
- * Local variables:
- * c-basic-offset: 8
- * End:
- */
index 9282e4e082bd10ad8fb499d8dc5f47b3909f85af..aa29b50765c942af946d0ef79730a8ff0872cb81 100644 (file)
@@ -91,7 +91,7 @@ static int nkbd_connect(struct serio *serio, struct serio_driver *drv)
        nkbd = kzalloc(sizeof(struct nkbd), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!nkbd || !input_dev)
-               goto fail;
+               goto fail1;
 
        nkbd->serio = serio;
        nkbd->dev = input_dev;
@@ -119,13 +119,17 @@ static int nkbd_connect(struct serio *serio, struct serio_driver *drv)
 
        err = serio_open(serio, drv);
        if (err)
-               goto fail;
+               goto fail2;
+
+       err = input_register_device(nkbd->dev);
+       if (err)
+               goto fail3;
 
-       input_register_device(nkbd->dev);
        return 0;
 
- fail: serio_set_drvdata(serio, NULL);
-       input_free_device(input_dev);
+ fail3:        serio_close(serio);
+ fail2:        serio_set_drvdata(serio, NULL);
+ fail1:        input_free_device(input_dev);
        kfree(nkbd);
        return err;
 }
@@ -165,8 +169,7 @@ static struct serio_driver nkbd_drv = {
 
 static int __init nkbd_init(void)
 {
-       serio_register_driver(&nkbd_drv);
-       return 0;
+       return serio_register_driver(&nkbd_drv);
 }
 
 static void __exit nkbd_exit(void)
index 28b2748e82d087bf4255d40c9ecca17f779811d6..8a2166c77ff4ea9514b49a1c5ea9aa136f9fda21 100644 (file)
@@ -346,17 +346,12 @@ static int __init spitzkbd_probe(struct platform_device *dev)
 {
        struct spitzkbd *spitzkbd;
        struct input_dev *input_dev;
-       int i;
+       int i, err = -ENOMEM;
 
        spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL);
-       if (!spitzkbd)
-               return -ENOMEM;
-
        input_dev = input_allocate_device();
-       if (!input_dev) {
-               kfree(spitzkbd);
-               return -ENOMEM;
-       }
+       if (!spitzkbd || !input_dev)
+               goto fail;
 
        platform_set_drvdata(dev, spitzkbd);
        strcpy(spitzkbd->phys, "spitzkbd/input0");
@@ -400,7 +395,9 @@ static int __init spitzkbd_probe(struct platform_device *dev)
        set_bit(SW_TABLET_MODE, input_dev->swbit);
        set_bit(SW_HEADPHONE_INSERT, input_dev->swbit);
 
-       input_register_device(input_dev);
+       err = input_register_device(input_dev);
+       if (err)
+               goto fail;
 
        mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
 
@@ -434,13 +431,15 @@ static int __init spitzkbd_probe(struct platform_device *dev)
        request_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd_hinge_isr,
                    IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
                    "Spitzkbd SWB", spitzkbd);
-       request_irq(SPITZ_IRQ_GPIO_AK_INT, spitzkbd_hinge_isr,
+       request_irq(SPITZ_IRQ_GPIO_AK_INT, spitzkbd_hinge_isr,
                    IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
                    "Spitzkbd HP", spitzkbd);
 
-       printk(KERN_INFO "input: Spitz Keyboard Registered\n");
-
        return 0;
+
+ fail: input_free_device(input_dev);
+       kfree(spitzkbd);
+       return err;
 }
 
 static int spitzkbd_remove(struct platform_device *dev)
@@ -474,6 +473,7 @@ static struct platform_driver spitzkbd_driver = {
        .resume         = spitzkbd_resume,
        .driver         = {
                .name   = "spitz-keyboard",
+               .owner  = THIS_MODULE,
        },
 };
 
index e60937d17b1c286a6341b0d3adf3b0645352a079..f7b5c5b8145162c654bd8a5c783d43e4c0abbdaa 100644 (file)
@@ -173,8 +173,7 @@ static struct serio_driver skbd_drv = {
 
 static int __init skbd_init(void)
 {
-       serio_register_driver(&skbd_drv);
-       return 0;
+       return serio_register_driver(&skbd_drv);
 }
 
 static void __exit skbd_exit(void)
index 6cd887c5eb0a1082560d61172e1dc9bef1b7f0e9..3826db9403e633950c941fda8517bfc6b4c009e9 100644 (file)
@@ -243,7 +243,7 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv)
        sunkbd = kzalloc(sizeof(struct sunkbd), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!sunkbd || !input_dev)
-               goto fail;
+               goto fail1;
 
        sunkbd->serio = serio;
        sunkbd->dev = input_dev;
@@ -255,11 +255,11 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv)
 
        err = serio_open(serio, drv);
        if (err)
-               goto fail;
+               goto fail2;
 
        if (sunkbd_initialize(sunkbd) < 0) {
-               serio_close(serio);
-               goto fail;
+               err = -ENODEV;
+               goto fail3;
        }
 
        snprintf(sunkbd->name, sizeof(sunkbd->name), "Sun Type %d keyboard", sunkbd->type);
@@ -287,11 +287,17 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv)
        clear_bit(0, input_dev->keybit);
 
        sunkbd_enable(sunkbd, 1);
-       input_register_device(sunkbd->dev);
+
+       err = input_register_device(sunkbd->dev);
+       if (err)
+               goto fail4;
+
        return 0;
 
- fail: serio_set_drvdata(serio, NULL);
-       input_free_device(input_dev);
+ fail4:        sunkbd_enable(sunkbd, 0);
+ fail3:        serio_close(serio);
+ fail2:        serio_set_drvdata(serio, NULL);
+ fail1:        input_free_device(input_dev);
        kfree(sunkbd);
        return err;
 }
@@ -346,8 +352,7 @@ static struct serio_driver sunkbd_drv = {
 
 static int __init sunkbd_init(void)
 {
-       serio_register_driver(&sunkbd_drv);
-       return 0;
+       return serio_register_driver(&sunkbd_drv);
 }
 
 static void __exit sunkbd_exit(void)
index 8c11dc935454bba0b02758e4f2045f5f104823fc..a8209343213860bf96157bb401aa4cc0a9e02b6e 100644 (file)
@@ -95,7 +95,7 @@ static int xtkbd_connect(struct serio *serio, struct serio_driver *drv)
        xtkbd = kmalloc(sizeof(struct xtkbd), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!xtkbd || !input_dev)
-               goto fail;
+               goto fail1;
 
        xtkbd->serio = serio;
        xtkbd->dev = input_dev;
@@ -124,13 +124,17 @@ static int xtkbd_connect(struct serio *serio, struct serio_driver *drv)
 
        err = serio_open(serio, drv);
        if (err)
-               goto fail;
+               goto fail2;
+
+       err = input_register_device(xtkbd->dev);
+       if (err)
+               goto fail3;
 
-       input_register_device(xtkbd->dev);
        return 0;
 
- fail: serio_set_drvdata(serio, NULL);
-       input_free_device(input_dev);
+ fail3:        serio_close(serio);
+ fail2:        serio_set_drvdata(serio, NULL);
+ fail1:        input_free_device(input_dev);
        kfree(xtkbd);
        return err;
 }
@@ -170,8 +174,7 @@ static struct serio_driver xtkbd_drv = {
 
 static int __init xtkbd_init(void)
 {
-       serio_register_driver(&xtkbd_drv);
-       return 0;
+       return serio_register_driver(&xtkbd_drv);
 }
 
 static void __exit xtkbd_exit(void)
index ab4da79ee560d9279afc989d129715c45dd1593c..31d5a13bfd6bb3a534b11918676fda5fb06112fe 100644 (file)
@@ -695,7 +695,9 @@ static int __init hp_sdc_rtc_init(void)
 
        if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr)))
                return ret;
-       misc_register(&hp_sdc_rtc_dev);
+       if (misc_register(&hp_sdc_rtc_dev) != 0)
+               printk(KERN_INFO "Could not register misc. dev for i8042 rtc\n");
+
         create_proc_read_entry ("driver/rtc", 0, NULL,
                                hp_sdc_rtc_read_proc, NULL);
 
index 599a7b2dc5191f7f057f0b4a2996a32c1c162d10..239a0e16d91abf215904584e72b3985c746e770b 100644 (file)
@@ -95,10 +95,13 @@ static void amimouse_close(struct input_dev *dev)
 
 static int __init amimouse_init(void)
 {
+       int err;
+
        if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_MOUSE))
                return -ENODEV;
 
-       if (!(amimouse_dev = input_allocate_device()))
+       amimouse_dev = input_allocate_device();
+       if (!amimouse_dev)
                return -ENOMEM;
 
        amimouse_dev->name = "Amiga mouse";
@@ -114,7 +117,11 @@ static int __init amimouse_init(void)
        amimouse_dev->open = amimouse_open;
        amimouse_dev->close = amimouse_close;
 
-       input_register_device(amimouse_dev);
+       err = input_register_device(amimouse_dev);
+       if (err) {
+               input_free_device(amimouse_dev);
+               return err;
+       }
 
        return 0;
 }
index 4f2b503c1ac72ee1d05ab2533f97f46d1193a3e2..bfb174fe32305ab315411da0b2df21e4127e03c3 100644 (file)
@@ -417,8 +417,7 @@ static struct serio_driver hil_ptr_serio_driver = {
 
 static int __init hil_ptr_init(void)
 {
-       serio_register_driver(&hil_ptr_serio_driver);
-        return 0;
+       return serio_register_driver(&hil_ptr_serio_driver);
 }
                 
 static void __exit hil_ptr_exit(void)
index e1252fa9a10788b88f38005b0eb78ebd3cfa41c3..13dd96785e397bf81d632993512e9457ae3e0053 100644 (file)
@@ -135,6 +135,7 @@ static void inport_close(struct input_dev *dev)
 static int __init inport_init(void)
 {
        unsigned char a, b, c;
+       int err;
 
        if (!request_region(INPORT_BASE, INPORT_EXTENT, "inport")) {
                printk(KERN_ERR "inport.c: Can't allocate ports at %#x\n", INPORT_BASE);
@@ -145,15 +146,16 @@ static int __init inport_init(void)
        b = inb(INPORT_SIGNATURE_PORT);
        c = inb(INPORT_SIGNATURE_PORT);
        if (a == b || a != c) {
-               release_region(INPORT_BASE, INPORT_EXTENT);
                printk(KERN_ERR "inport.c: Didn't find InPort mouse at %#x\n", INPORT_BASE);
-               return -ENODEV;
+               err = -ENODEV;
+               goto err_release_region;
        }
 
-       if (!(inport_dev = input_allocate_device())) {
+       inport_dev = input_allocate_device();
+       if (!inport_dev) {
                printk(KERN_ERR "inport.c: Not enough memory for input device\n");
-               release_region(INPORT_BASE, INPORT_EXTENT);
-               return -ENOMEM;
+               err = -ENOMEM;
+               goto err_release_region;
        }
 
        inport_dev->name = INPORT_NAME;
@@ -174,9 +176,18 @@ static int __init inport_init(void)
        outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
        outb(INPORT_MODE_BASE, INPORT_DATA_PORT);
 
-       input_register_device(inport_dev);
+       err = input_register_device(inport_dev);
+       if (err)
+               goto err_free_dev;
 
        return 0;
+
+ err_free_dev:
+       input_free_device(inport_dev);
+ err_release_region:
+       release_region(INPORT_BASE, INPORT_EXTENT);
+
+       return err;
 }
 
 static void __exit inport_exit(void)
index c57e8853b94900a42d795ddaf4af86f38aa59f7e..29542f0631cbba2e01516c693185e5d9180be8e6 100644 (file)
 #include "lifebook.h"
 
 static struct dmi_system_id lifebook_dmi_table[] = {
-       {
-               .ident = "LifeBook B",
-               .matches = {
-                       DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B Series"),
-               },
-       },
-       {
-               .ident = "Lifebook B",
-               .matches = {
-                       DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK B Series"),
-               },
-       },
-       {
-               .ident = "Lifebook B213x/B2150",
-               .matches = {
-                       DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B2131/B2133/B2150"),
-               },
-       },
-       {
-               .ident = "Zephyr",
-               .matches = {
-                       DMI_MATCH(DMI_PRODUCT_NAME, "ZEPHYR"),
-               },
-       },
-       {
-               .ident = "CF-18",
-               .matches = {
-                       DMI_MATCH(DMI_PRODUCT_NAME, "CF-18"),
-               },
-       },
-       {
-               .ident = "Lifebook B142",
-               .matches = {
-                       DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B142"),
-               },
-
-       },
-       { }
+       {
+               .ident = "FLORA-ie 55mi",
+               .matches = {
+                       DMI_MATCH(DMI_PRODUCT_NAME, "FLORA-ie 55mi"),
+               },
+       },
+       {
+               .ident = "LifeBook B",
+               .matches = {
+                       DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B Series"),
+               },
+       },
+       {
+               .ident = "Lifebook B",
+               .matches = {
+                       DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK B Series"),
+               },
+       },
+       {
+               .ident = "Lifebook B213x/B2150",
+               .matches = {
+                       DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B2131/B2133/B2150"),
+               },
+       },
+       {
+               .ident = "Zephyr",
+               .matches = {
+                       DMI_MATCH(DMI_PRODUCT_NAME, "ZEPHYR"),
+               },
+       },
+       {
+               .ident = "CF-18",
+               .matches = {
+                       DMI_MATCH(DMI_PRODUCT_NAME, "CF-18"),
+               },
+       },
+       {
+               .ident = "Lifebook B142",
+               .matches = {
+                       DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B142"),
+               },
+       },
+       { }
 };
 
-
 static psmouse_ret_t lifebook_process_byte(struct psmouse *psmouse)
 {
        unsigned char *packet = psmouse->packet;
index 8e9c2f3d69a860a7017e4459881043327bb174c3..db205995bffd08baf589ab5457c71ee8f640efe8 100644 (file)
@@ -124,6 +124,8 @@ static void logibm_close(struct input_dev *dev)
 
 static int __init logibm_init(void)
 {
+       int err;
+
        if (!request_region(LOGIBM_BASE, LOGIBM_EXTENT, "logibm")) {
                printk(KERN_ERR "logibm.c: Can't allocate ports at %#x\n", LOGIBM_BASE);
                return -EBUSY;
@@ -134,18 +136,19 @@ static int __init logibm_init(void)
        udelay(100);
 
        if (inb(LOGIBM_SIGNATURE_PORT) != LOGIBM_SIGNATURE_BYTE) {
-               release_region(LOGIBM_BASE, LOGIBM_EXTENT);
                printk(KERN_ERR "logibm.c: Didn't find Logitech busmouse at %#x\n", LOGIBM_BASE);
-               return -ENODEV;
+               err = -ENODEV;
+               goto err_release_region;
        }
 
        outb(LOGIBM_DEFAULT_MODE, LOGIBM_CONFIG_PORT);
        outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT);
 
-       if (!(logibm_dev = input_allocate_device())) {
+       logibm_dev = input_allocate_device();
+       if (!logibm_dev) {
                printk(KERN_ERR "logibm.c: Not enough memory for input device\n");
-               release_region(LOGIBM_BASE, LOGIBM_EXTENT);
-               return -ENOMEM;
+               err = -ENOMEM;
+               goto err_release_region;
        }
 
        logibm_dev->name = "Logitech bus mouse";
@@ -162,9 +165,18 @@ static int __init logibm_init(void)
        logibm_dev->open  = logibm_open;
        logibm_dev->close = logibm_close;
 
-       input_register_device(logibm_dev);
+       err = input_register_device(logibm_dev);
+       if (err)
+               goto err_free_dev;
 
        return 0;
+
+ err_free_dev:
+       input_free_device(logibm_dev);
+ err_release_region:
+       release_region(LOGIBM_BASE, LOGIBM_EXTENT);
+
+       return err;
 }
 
 static void __exit logibm_exit(void)
index 8a4f862709e7490c33cdeba1a3d2adb3ac8737d5..d3ddea26b8ca65fec6f714032425d50e801bda3a 100644 (file)
@@ -328,6 +328,7 @@ int ps2pp_init(struct psmouse *psmouse, int set_properties)
        unsigned char model, buttons;
        const struct ps2pp_info *model_info;
        int use_ps2pp = 0;
+       int error;
 
        param[0] = 0;
        ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
@@ -393,8 +394,14 @@ int ps2pp_init(struct psmouse *psmouse, int set_properties)
                                psmouse->set_resolution = ps2pp_set_resolution;
                                psmouse->disconnect = ps2pp_disconnect;
 
-                               device_create_file(&psmouse->ps2dev.serio->dev,
-                                                  &psmouse_attr_smartscroll.dattr);
+                               error = device_create_file(&psmouse->ps2dev.serio->dev,
+                                                          &psmouse_attr_smartscroll.dattr);
+                               if (error) {
+                                       printk(KERN_ERR
+                                               "logips2pp.c: failed to create smartscroll "
+                                               "sysfs attribute, error: %d\n", error);
+                                       return -1;
+                               }
                        }
                }
 
index 8c075aa7223b58978f61bd7924cb77b17f1f7237..f155c1fea04e3bd2e3181106886782011f3d64e7 100644 (file)
@@ -108,6 +108,7 @@ static int pc110pad_open(struct input_dev *dev)
 static int __init pc110pad_init(void)
 {
        struct pci_dev *dev;
+       int err;
 
        dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
        if (dev) {
@@ -124,16 +125,16 @@ static int __init pc110pad_init(void)
        outb(PC110PAD_OFF, pc110pad_io + 2);
 
        if (request_irq(pc110pad_irq, pc110pad_interrupt, 0, "pc110pad", NULL)) {
-               release_region(pc110pad_io, 4);
                printk(KERN_ERR "pc110pad: Unable to get irq %d.\n", pc110pad_irq);
-               return -EBUSY;
+               err = -EBUSY;
+               goto err_release_region;
        }
 
-       if (!(pc110pad_dev = input_allocate_device())) {
-               free_irq(pc110pad_irq, NULL);
-               release_region(pc110pad_io, 4);
+       pc110pad_dev = input_allocate_device();
+       if (!pc110pad_dev) {
                printk(KERN_ERR "pc110pad: Not enough memory.\n");
-               return -ENOMEM;
+               err = -ENOMEM;
+               goto err_free_irq;
        }
 
        pc110pad_dev->name = "IBM PC110 TouchPad";
@@ -153,9 +154,20 @@ static int __init pc110pad_init(void)
        pc110pad_dev->open = pc110pad_open;
        pc110pad_dev->close = pc110pad_close;
 
-       input_register_device(pc110pad_dev);
+       err = input_register_device(pc110pad_dev);
+       if (err)
+               goto err_free_dev;
 
        return 0;
+
+ err_free_dev:
+       input_free_device(pc110pad_dev);
+ err_free_irq:
+       free_irq(pc110pad_irq, NULL);
+ err_release_region:
+       release_region(pc110pad_io, 4);
+
+       return err;
 }
 
 static void __exit pc110pad_exit(void)
index 52bb2226ce2fb9ac816018da35a0a232d050a692..a0e4a033e2db553346e646044a8bf25c298735fb 100644 (file)
@@ -1103,7 +1103,7 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
 {
        struct psmouse *psmouse, *parent = NULL;
        struct input_dev *input_dev;
-       int retval = -ENOMEM;
+       int retval = 0, error = -ENOMEM;
 
        mutex_lock(&psmouse_mutex);
 
@@ -1119,7 +1119,7 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
        psmouse = kzalloc(sizeof(struct psmouse), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!psmouse || !input_dev)
-               goto out;
+               goto err_free;
 
        ps2_init(&psmouse->ps2dev, serio);
        INIT_WORK(&psmouse->resync_work, psmouse_resync);
@@ -1130,14 +1130,13 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
 
        serio_set_drvdata(serio, psmouse);
 
-       retval = serio_open(serio, drv);
-       if (retval)
-               goto out;
+       error = serio_open(serio, drv);
+       if (error)
+               goto err_clear_drvdata;
 
        if (psmouse_probe(psmouse) < 0) {
-               serio_close(serio);
-               retval = -ENODEV;
-               goto out;
+               error = -ENODEV;
+               goto err_close_serio;
        }
 
        psmouse->rate = psmouse_rate;
@@ -1151,30 +1150,44 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
        psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
        psmouse_initialize(psmouse);
 
-       input_register_device(psmouse->dev);
+       error = input_register_device(psmouse->dev);
+       if (error)
+               goto err_protocol_disconnect;
 
        if (parent && parent->pt_activate)
                parent->pt_activate(parent);
 
-       sysfs_create_group(&serio->dev.kobj, &psmouse_attribute_group);
+       error = sysfs_create_group(&serio->dev.kobj, &psmouse_attribute_group);
+       if (error)
+               goto err_pt_deactivate;
 
        psmouse_activate(psmouse);
 
-       retval = 0;
-
-out:
-       if (retval) {
-               serio_set_drvdata(serio, NULL);
-               input_free_device(input_dev);
-               kfree(psmouse);
-       }
-
+ out:
        /* If this is a pass-through port the parent needs to be re-activated */
        if (parent)
                psmouse_activate(parent);
 
        mutex_unlock(&psmouse_mutex);
        return retval;
+
+ err_pt_deactivate:
+       if (parent && parent->pt_deactivate)
+               parent->pt_deactivate(parent);
+ err_protocol_disconnect:
+       if (psmouse->disconnect)
+               psmouse->disconnect(psmouse);
+       psmouse_set_state(psmouse, PSMOUSE_IGNORE);
+ err_close_serio:
+       serio_close(serio);
+ err_clear_drvdata:
+       serio_set_drvdata(serio, NULL);
+ err_free:
+       input_free_device(input_dev);
+       kfree(psmouse);
+
+       retval = error;
+       goto out;
 }
 
 
@@ -1337,14 +1350,14 @@ ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *dev
 
 static ssize_t psmouse_show_int_attr(struct psmouse *psmouse, void *offset, char *buf)
 {
-       unsigned long *field = (unsigned long *)((char *)psmouse + (size_t)offset);
+       unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset);
 
-       return sprintf(buf, "%lu\n", *field);
+       return sprintf(buf, "%u\n", *field);
 }
 
 static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count)
 {
-       unsigned long *field = (unsigned long *)((char *)psmouse + (size_t)offset);
+       unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset);
        unsigned long value;
        char *rest;
 
@@ -1352,6 +1365,9 @@ static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const
        if (*rest)
                return -EINVAL;
 
+       if ((unsigned int)value != value)
+               return -EINVAL;
+
        *field = value;
 
        return count;
@@ -1366,17 +1382,20 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
 {
        struct serio *serio = psmouse->ps2dev.serio;
        struct psmouse *parent = NULL;
-       struct input_dev *new_dev;
-       const struct psmouse_protocol *proto;
+       struct input_dev *old_dev, *new_dev;
+       const struct psmouse_protocol *proto, *old_proto;
+       int error;
        int retry = 0;
 
-       if (!(proto = psmouse_protocol_by_name(buf, count)))
+       proto = psmouse_protocol_by_name(buf, count);
+       if (!proto)
                return -EINVAL;
 
        if (psmouse->type == proto->type)
                return count;
 
-       if (!(new_dev = input_allocate_device()))
+       new_dev = input_allocate_device();
+       if (!new_dev)
                return -ENOMEM;
 
        while (serio->child) {
@@ -1409,11 +1428,13 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
                        parent->pt_deactivate(parent);
        }
 
+       old_dev = psmouse->dev;
+       old_proto = psmouse_protocol_by_type(psmouse->type);
+
        if (psmouse->disconnect)
                psmouse->disconnect(psmouse);
 
        psmouse_set_state(psmouse, PSMOUSE_IGNORE);
-       input_unregister_device(psmouse->dev);
 
        psmouse->dev = new_dev;
        psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
@@ -1427,7 +1448,23 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
        psmouse_initialize(psmouse);
        psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
 
-       input_register_device(psmouse->dev);
+       error = input_register_device(psmouse->dev);
+       if (error) {
+               if (psmouse->disconnect)
+                       psmouse->disconnect(psmouse);
+
+               psmouse_set_state(psmouse, PSMOUSE_IGNORE);
+               input_free_device(new_dev);
+               psmouse->dev = old_dev;
+               psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
+               psmouse_switch_protocol(psmouse, old_proto);
+               psmouse_initialize(psmouse);
+               psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
+
+               return error;
+       }
+
+       input_unregister_device(old_dev);
 
        if (parent && parent->pt_activate)
                parent->pt_activate(parent);
@@ -1488,15 +1525,19 @@ static int psmouse_get_maxproto(char *buffer, struct kernel_param *kp)
 
 static int __init psmouse_init(void)
 {
+       int err;
+
        kpsmoused_wq = create_singlethread_workqueue("kpsmoused");
        if (!kpsmoused_wq) {
                printk(KERN_ERR "psmouse: failed to create kpsmoused workqueue\n");
                return -ENOMEM;
        }
 
-       serio_register_driver(&psmouse_drv);
+       err = serio_register_driver(&psmouse_drv);
+       if (err)
+               destroy_workqueue(kpsmoused_wq);
 
-       return 0;
+       return err;
 }
 
 static void __exit psmouse_exit(void)
index ea0468569610a13065e432283612903dc582fd15..fbdcfd8eb4e9d9860a2f190d98dcbfb32e175c3d 100644 (file)
@@ -66,7 +66,10 @@ static irqreturn_t rpcmouse_irq(int irq, void *dev_id)
 
 static int __init rpcmouse_init(void)
 {
-       if (!(rpcmouse_dev = input_allocate_device()))
+       int err;
+
+       rpcmouse_dev = input_allocate_device();
+       if (!rpcmouse_dev)
                return -ENOMEM;
 
        rpcmouse_dev->name = "Acorn RiscPC Mouse";
@@ -85,13 +88,22 @@ static int __init rpcmouse_init(void)
 
        if (request_irq(IRQ_VSYNCPULSE, rpcmouse_irq, IRQF_SHARED, "rpcmouse", rpcmouse_dev)) {
                printk(KERN_ERR "rpcmouse: unable to allocate VSYNC interrupt\n");
-               input_free_device(rpcmouse_dev);
-               return -EBUSY;
+               err = -EBUSY;
+               goto err_free_dev;
        }
 
-       input_register_device(rpcmouse_dev);
+       err = input_register_device(rpcmouse_dev);
+       if (err)
+               goto err_free_irq;
 
        return 0;
+
+ err_free_irq:
+       free_irq(IRQ_VSYNCPULSE, rpcmouse_dev);
+ err_free_dev:
+       input_free_device(rpcmouse_dev);
+
+       return err;
 }
 
 static void __exit rpcmouse_exit(void)
index 2a272c5daf08b2284f4a6f24f10e70813c38c822..a85d74710b44cd3d474ba79562e698005420880b 100644 (file)
@@ -246,7 +246,7 @@ static int sermouse_connect(struct serio *serio, struct serio_driver *drv)
        sermouse = kzalloc(sizeof(struct sermouse), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!sermouse || !input_dev)
-               goto fail;
+               goto fail1;
 
        sermouse->dev = input_dev;
        snprintf(sermouse->phys, sizeof(sermouse->phys), "%s/input0", serio->phys);
@@ -275,14 +275,17 @@ static int sermouse_connect(struct serio *serio, struct serio_driver *drv)
 
        err = serio_open(serio, drv);
        if (err)
-               goto fail;
+               goto fail2;
 
-       input_register_device(sermouse->dev);
+       err = input_register_device(sermouse->dev);
+       if (err)
+               goto fail3;
 
        return 0;
 
- fail: serio_set_drvdata(serio, NULL);
-       input_free_device(input_dev);
+ fail3:        serio_close(serio);
+ fail2:        serio_set_drvdata(serio, NULL);
+ fail1:        input_free_device(input_dev);
        kfree(sermouse);
        return err;
 }
@@ -348,8 +351,7 @@ static struct serio_driver sermouse_drv = {
 
 static int __init sermouse_init(void)
 {
-       serio_register_driver(&sermouse_drv);
-       return 0;
+       return serio_register_driver(&sermouse_drv);
 }
 
 static void __exit sermouse_exit(void)
index ae5871a0e060fac36f5899436dc9bea9037b53d0..9ab5b5ea809d1a9c00820dd4937d6419be1e9733 100644 (file)
@@ -293,6 +293,7 @@ int trackpoint_detect(struct psmouse *psmouse, int set_properties)
        struct ps2dev *ps2dev = &psmouse->ps2dev;
        unsigned char firmware_id;
        unsigned char button_info;
+       int error;
 
        if (trackpoint_start_protocol(psmouse, &firmware_id))
                return -1;
@@ -305,7 +306,7 @@ int trackpoint_detect(struct psmouse *psmouse, int set_properties)
                button_info = 0;
        }
 
-       psmouse->private = priv = kcalloc(1, sizeof(struct trackpoint_data), GFP_KERNEL);
+       psmouse->private = priv = kzalloc(sizeof(struct trackpoint_data), GFP_KERNEL);
        if (!priv)
                return -1;
 
@@ -318,7 +319,14 @@ int trackpoint_detect(struct psmouse *psmouse, int set_properties)
        trackpoint_defaults(priv);
        trackpoint_sync(psmouse);
 
-       sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group);
+       error = sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group);
+       if (error) {
+               printk(KERN_ERR
+                       "trackpoint.c: failed to create sysfs attributes, error: %d\n",
+                       error);
+               kfree(priv);
+               return -1;
+       }
 
        printk(KERN_INFO "IBM TrackPoint firmware: 0x%02x, buttons: %d/%d\n",
                firmware_id, (button_info & 0xf0) >> 4, button_info & 0x0f);
index ffdb50eee93d6df28f0df7e7ac27fd4dca21dde0..c3d64fcc858d26f0e3104d2c23328d6aa0d60c5a 100644 (file)
@@ -497,7 +497,7 @@ vsxxxaa_connect (struct serio *serio, struct serio_driver *drv)
        mouse = kzalloc (sizeof (struct vsxxxaa), GFP_KERNEL);
        input_dev = input_allocate_device ();
        if (!mouse || !input_dev)
-               goto fail;
+               goto fail1;
 
        mouse->dev = input_dev;
        mouse->serio = serio;
@@ -527,7 +527,7 @@ vsxxxaa_connect (struct serio *serio, struct serio_driver *drv)
 
        err = serio_open (serio, drv);
        if (err)
-               goto fail;
+               goto fail2;
 
        /*
         * Request selftest. Standard packet format and differential
@@ -535,12 +535,15 @@ vsxxxaa_connect (struct serio *serio, struct serio_driver *drv)
         */
        serio->write (serio, 'T'); /* Test */
 
-       input_register_device (input_dev);
+       err = input_register_device (input_dev);
+       if (err)
+               goto fail3;
 
        return 0;
 
- fail: serio_set_drvdata (serio, NULL);
-       input_free_device (input_dev);
+ fail3:        serio_close (serio);
+ fail2:        serio_set_drvdata (serio, NULL);
+ fail1:        input_free_device (input_dev);
        kfree (mouse);
        return err;
 }
@@ -571,8 +574,7 @@ static struct serio_driver vsxxxaa_drv = {
 static int __init
 vsxxxaa_init (void)
 {
-       serio_register_driver(&vsxxxaa_drv);
-       return 0;
+       return serio_register_driver(&vsxxxaa_drv);
 }
 
 static void __exit
index a22a74a2a3dcc6e781b79609360830b95208c026..664bcc8116fc7676d159b2e035015f212ad5f357 100644 (file)
@@ -196,12 +196,12 @@ static void mousedev_key_event(struct mousedev *mousedev, unsigned int code, int
        switch (code) {
                case BTN_TOUCH:
                case BTN_0:
-               case BTN_FORWARD:
                case BTN_LEFT:          index = 0; break;
                case BTN_STYLUS:
                case BTN_1:
                case BTN_RIGHT:         index = 1; break;
                case BTN_2:
+               case BTN_FORWARD:
                case BTN_STYLUS2:
                case BTN_MIDDLE:        index = 2; break;
                case BTN_3:
index 8738edda661001236e0db92c0607ec98fa0496b7..d36bd5475b6d2b89cd2c402c99266780fb48fec0 100644 (file)
@@ -110,6 +110,13 @@ static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
                        DMI_MATCH(DMI_PRODUCT_NAME, "P7010"),
                },
        },
+       {
+               .ident = "Fujitsu Lifebook P7010",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "0000000000"),
+               },
+       },
        {
                .ident = "Fujitsu Lifebook P5020D",
                .matches = {
index 7e3141f37e32a7907fa2d00b15266652b2b6bb9e..debe9445488c0cfefc221823da9fe205a5515d9f 100644 (file)
@@ -255,25 +255,10 @@ static int i8042_kbd_write(struct serio *port, unsigned char c)
 static int i8042_aux_write(struct serio *serio, unsigned char c)
 {
        struct i8042_port *port = serio->port_data;
-       int retval;
-
-/*
- * Send the byte out.
- */
-
-       if (port->mux == -1)
-               retval = i8042_command(&c, I8042_CMD_AUX_SEND);
-       else
-               retval = i8042_command(&c, I8042_CMD_MUX_SEND + port->mux);
-
-/*
- * Make sure the interrupt happens and the character is received even
- * in the case the IRQ isn't wired, so that we can receive further
- * characters later.
- */
 
-       i8042_interrupt(0, NULL);
-       return retval;
+       return i8042_command(&c, port->mux == -1 ?
+                                       I8042_CMD_AUX_SEND :
+                                       I8042_CMD_MUX_SEND + port->mux);
 }
 
 /*
@@ -337,23 +322,27 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id)
                dfl = 0;
                if (str & I8042_STR_MUXERR) {
                        dbg("MUX error, status is %02x, data is %02x", str, data);
-                       switch (data) {
-                               default:
 /*
  * When MUXERR condition is signalled the data register can only contain
  * 0xfd, 0xfe or 0xff if implementation follows the spec. Unfortunately
- * it is not always the case. Some KBC just get confused which port the
- * data came from and signal error leaving the data intact. They _do not_
- * revert to legacy mode (actually I've never seen KBC reverting to legacy
- * mode yet, when we see one we'll add proper handling).
- * Anyway, we will assume that the data came from the same serio last byte
+ * it is not always the case. Some KBCs also report 0xfc when there is
+ * nothing connected to the port while others sometimes get confused which
+ * port the data came from and signal error leaving the data intact. They
+ * _do not_ revert to legacy mode (actually I've never seen KBC reverting
+ * to legacy mode yet, when we see one we'll add proper handling).
+ * Anyway, we process 0xfc, 0xfd, 0xfe and 0xff as timeouts, and for the
+ * rest assume that the data came from the same serio last byte
  * was transmitted (if transmission happened not too long ago).
  */
+
+                       switch (data) {
+                               default:
                                        if (time_before(jiffies, last_transmit + HZ/10)) {
                                                str = last_str;
                                                break;
                                        }
                                        /* fall through - report timeout */
+                               case 0xfc:
                                case 0xfd:
                                case 0xfe: dfl = SERIO_TIMEOUT; data = 0xfe; break;
                                case 0xff: dfl = SERIO_PARITY;  data = 0xfe; break;
index 211943f85cb66e1dee2b77aac5c3e30ce3d6c07a..f0ce822c1028741efabecf0cef37e1e356754eb5 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/slab.h>
 #include <linux/kthread.h>
 #include <linux/mutex.h>
+#include <linux/freezer.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
 MODULE_DESCRIPTION("Serio abstraction core");
@@ -44,8 +45,7 @@ EXPORT_SYMBOL(serio_interrupt);
 EXPORT_SYMBOL(__serio_register_port);
 EXPORT_SYMBOL(serio_unregister_port);
 EXPORT_SYMBOL(serio_unregister_child_port);
-EXPORT_SYMBOL(__serio_unregister_port_delayed);
-EXPORT_SYMBOL(__serio_register_driver);
+EXPORT_SYMBOL(serio_register_driver);
 EXPORT_SYMBOL(serio_unregister_driver);
 EXPORT_SYMBOL(serio_open);
 EXPORT_SYMBOL(serio_close);
@@ -62,11 +62,10 @@ static LIST_HEAD(serio_list);
 
 static struct bus_type serio_bus;
 
-static void serio_add_driver(struct serio_driver *drv);
 static void serio_add_port(struct serio *serio);
-static void serio_destroy_port(struct serio *serio);
 static void serio_reconnect_port(struct serio *serio);
 static void serio_disconnect_port(struct serio *serio);
+static void serio_attach_driver(struct serio_driver *drv);
 
 static int serio_connect_driver(struct serio *serio, struct serio_driver *drv)
 {
@@ -170,11 +169,10 @@ static void serio_find_driver(struct serio *serio)
  */
 
 enum serio_event_type {
-       SERIO_RESCAN,
-       SERIO_RECONNECT,
+       SERIO_RESCAN_PORT,
+       SERIO_RECONNECT_PORT,
        SERIO_REGISTER_PORT,
-       SERIO_UNREGISTER_PORT,
-       SERIO_REGISTER_DRIVER,
+       SERIO_ATTACH_DRIVER,
 };
 
 struct serio_event {
@@ -189,11 +187,12 @@ static LIST_HEAD(serio_event_list);
 static DECLARE_WAIT_QUEUE_HEAD(serio_wait);
 static struct task_struct *serio_task;
 
-static void serio_queue_event(void *object, struct module *owner,
-                             enum serio_event_type event_type)
+static int serio_queue_event(void *object, struct module *owner,
+                            enum serio_event_type event_type)
 {
        unsigned long flags;
        struct serio_event *event;
+       int retval = 0;
 
        spin_lock_irqsave(&serio_event_lock, flags);
 
@@ -212,24 +211,34 @@ static void serio_queue_event(void *object, struct module *owner,
                }
        }
 
-       if ((event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC))) {
-               if (!try_module_get(owner)) {
-                       printk(KERN_WARNING "serio: Can't get module reference, dropping event %d\n", event_type);
-                       kfree(event);
-                       goto out;
-               }
-
-               event->type = event_type;
-               event->object = object;
-               event->owner = owner;
+       event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC);
+       if (!event) {
+               printk(KERN_ERR
+                       "serio: Not enough memory to queue event %d\n",
+                       event_type);
+               retval = -ENOMEM;
+               goto out;
+       }
 
-               list_add_tail(&event->node, &serio_event_list);
-               wake_up(&serio_wait);
-       } else {
-               printk(KERN_ERR "serio: Not enough memory to queue event %d\n", event_type);
+       if (!try_module_get(owner)) {
+               printk(KERN_WARNING
+                       "serio: Can't get module reference, dropping event %d\n",
+                       event_type);
+               kfree(event);
+               retval = -EINVAL;
+               goto out;
        }
+
+       event->type = event_type;
+       event->object = object;
+       event->owner = owner;
+
+       list_add_tail(&event->node, &serio_event_list);
+       wake_up(&serio_wait);
+
 out:
        spin_unlock_irqrestore(&serio_event_lock, flags);
+       return retval;
 }
 
 static void serio_free_event(struct serio_event *event)
@@ -307,22 +316,17 @@ static void serio_handle_event(void)
                                serio_add_port(event->object);
                                break;
 
-                       case SERIO_UNREGISTER_PORT:
-                               serio_disconnect_port(event->object);
-                               serio_destroy_port(event->object);
-                               break;
-
-                       case SERIO_RECONNECT:
+                       case SERIO_RECONNECT_PORT:
                                serio_reconnect_port(event->object);
                                break;
 
-                       case SERIO_RESCAN:
+                       case SERIO_RESCAN_PORT:
                                serio_disconnect_port(event->object);
                                serio_find_driver(event->object);
                                break;
 
-                       case SERIO_REGISTER_DRIVER:
-                               serio_add_driver(event->object);
+                       case SERIO_ATTACH_DRIVER:
+                               serio_attach_driver(event->object);
                                break;
 
                        default:
@@ -674,12 +678,12 @@ static void serio_disconnect_port(struct serio *serio)
 
 void serio_rescan(struct serio *serio)
 {
-       serio_queue_event(serio, NULL, SERIO_RESCAN);
+       serio_queue_event(serio, NULL, SERIO_RESCAN_PORT);
 }
 
 void serio_reconnect(struct serio *serio)
 {
-       serio_queue_event(serio, NULL, SERIO_RECONNECT);
+       serio_queue_event(serio, NULL, SERIO_RECONNECT_PORT);
 }
 
 /*
@@ -716,16 +720,6 @@ void serio_unregister_child_port(struct serio *serio)
        mutex_unlock(&serio_mutex);
 }
 
-/*
- * Submits register request to kseriod for subsequent execution.
- * Can be used when it is not obvious whether the serio_mutex is
- * taken or not and when delayed execution is feasible.
- */
-void __serio_unregister_port_delayed(struct serio *serio, struct module *owner)
-{
-       serio_queue_event(serio, owner, SERIO_UNREGISTER_PORT);
-}
-
 
 /*
  * Serio driver operations
@@ -784,28 +778,52 @@ static int serio_driver_remove(struct device *dev)
        return 0;
 }
 
-static struct bus_type serio_bus = {
-       .name = "serio",
-       .probe = serio_driver_probe,
-       .remove = serio_driver_remove,
-};
-
-static void serio_add_driver(struct serio_driver *drv)
+static void serio_attach_driver(struct serio_driver *drv)
 {
        int error;
 
-       error = driver_register(&drv->driver);
+       error = driver_attach(&drv->driver);
        if (error)
-               printk(KERN_ERR
-                       "serio: driver_register() failed for %s, error: %d\n",
+               printk(KERN_WARNING
+                       "serio: driver_attach() failed for %s with error %d\n",
                        drv->driver.name, error);
 }
 
-void __serio_register_driver(struct serio_driver *drv, struct module *owner)
+int serio_register_driver(struct serio_driver *drv)
 {
+       int manual_bind = drv->manual_bind;
+       int error;
+
        drv->driver.bus = &serio_bus;
 
-       serio_queue_event(drv, owner, SERIO_REGISTER_DRIVER);
+       /*
+        * Temporarily disable automatic binding because probing
+        * takes long time and we are better off doing it in kseriod
+        */
+       drv->manual_bind = 1;
+
+       error = driver_register(&drv->driver);
+       if (error) {
+               printk(KERN_ERR
+                       "serio: driver_register() failed for %s, error: %d\n",
+                       drv->driver.name, error);
+               return error;
+       }
+
+       /*
+        * Restore original bind mode and let kseriod bind the
+        * driver to free ports
+        */
+       if (!manual_bind) {
+               drv->manual_bind = 0;
+               error = serio_queue_event(drv, NULL, SERIO_ATTACH_DRIVER);
+               if (error) {
+                       driver_unregister(&drv->driver);
+                       return error;
+               }
+       }
+
+       return 0;
 }
 
 void serio_unregister_driver(struct serio_driver *drv)
@@ -946,15 +964,21 @@ irqreturn_t serio_interrupt(struct serio *serio,
        return ret;
 }
 
+static struct bus_type serio_bus = {
+       .name           = "serio",
+       .dev_attrs      = serio_device_attrs,
+       .drv_attrs      = serio_driver_attrs,
+       .match          = serio_bus_match,
+       .uevent         = serio_uevent,
+       .probe          = serio_driver_probe,
+       .remove         = serio_driver_remove,
+       .resume         = serio_resume,
+};
+
 static int __init serio_init(void)
 {
        int error;
 
-       serio_bus.dev_attrs = serio_device_attrs;
-       serio_bus.drv_attrs = serio_driver_attrs;
-       serio_bus.match = serio_bus_match;
-       serio_bus.uevent = serio_uevent;
-       serio_bus.resume = serio_resume;
        error = bus_register(&serio_bus);
        if (error) {
                printk(KERN_ERR "serio: failed to register serio bus, error: %d\n", error);
index 7c8d0399ae820ae6996f888f07910126bc3607f6..088ebc348ba31da45ddefa6b10a51aabf168185f 100644 (file)
@@ -389,8 +389,7 @@ static struct serio_driver serio_raw_drv = {
 
 static int __init serio_raw_init(void)
 {
-       serio_register_driver(&serio_raw_drv);
-       return 0;
+       return serio_register_driver(&serio_raw_drv);
 }
 
 static void __exit serio_raw_exit(void)
index 9418bbe4707298bc1d605fca696c7e03790b8f5d..29ca0ab0acb8a20de784853dd528b08ba9626756 100644 (file)
@@ -144,4 +144,19 @@ config TOUCHSCREEN_TOUCHWIN
          To compile this driver as a module, choose M here: the
          module will be called touchwin.
 
+config TOUCHSCREEN_UCB1400
+       tristate "Philips UCB1400 touchscreen"
+       select SND_AC97_BUS
+       help
+         This enables support for the Philips UCB1400 touchscreen interface.
+         The UCB1400 is an AC97 audio codec.  The touchscreen interface
+         will be initialized only after the ALSA subsystem has been
+         brought up and the UCB1400 detected.  You therefore have to
+         configure ALSA support as well (either built-in or modular,
+         independently of whether this driver is itself built-in or
+         modular) for this driver to work.
+
+         To compile this driver as a module, choose M here: the
+         module will be called ucb1400_ts.
+
 endif
index 1abb8f10d608809f5ecb57d4b0b1563cb3744bec..30e6e2217a15d86d72f153ca2fa3af9086f7ca70 100644 (file)
@@ -15,3 +15,4 @@ obj-$(CONFIG_TOUCHSCREEN_HP600)       += hp680_ts_input.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT)     += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT)   += touchright.o
 obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN)     += touchwin.o
+obj-$(CONFIG_TOUCHSCREEN_UCB1400)      += ucb1400_ts.o
index f56d6a0f0624ad06c602e52e52e39833959d0e17..c6164b6f476a3ecb5fde27af07ddd05c38557d01 100644 (file)
@@ -76,6 +76,7 @@ struct ads7846 {
        char                    phys[32];
 
        struct spi_device       *spi;
+       struct attribute_group  *attr_group;
        u16                     model;
        u16                     vref_delay_usecs;
        u16                     x_plate_ohms;
@@ -189,7 +190,7 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
 {
        struct spi_device       *spi = to_spi_device(dev);
        struct ads7846          *ts = dev_get_drvdata(dev);
-       struct ser_req          *req = kzalloc(sizeof *req, SLAB_KERNEL);
+       struct ser_req          *req = kzalloc(sizeof *req, GFP_KERNEL);
        int                     status;
        int                     sample;
        int                     i;
@@ -317,6 +318,48 @@ static ssize_t ads7846_disable_store(struct device *dev,
 
 static DEVICE_ATTR(disable, 0664, ads7846_disable_show, ads7846_disable_store);
 
+static struct attribute *ads7846_attributes[] = {
+       &dev_attr_temp0.attr,
+       &dev_attr_temp1.attr,
+       &dev_attr_vbatt.attr,
+       &dev_attr_vaux.attr,
+       &dev_attr_pen_down.attr,
+       &dev_attr_disable.attr,
+       NULL,
+};
+
+static struct attribute_group ads7846_attr_group = {
+       .attrs = ads7846_attributes,
+};
+
+/*
+ * ads7843/7845 don't have temperature sensors, and
+ * use the other sensors a bit differently too
+ */
+
+static struct attribute *ads7843_attributes[] = {
+       &dev_attr_vbatt.attr,
+       &dev_attr_vaux.attr,
+       &dev_attr_pen_down.attr,
+       &dev_attr_disable.attr,
+       NULL,
+};
+
+static struct attribute_group ads7843_attr_group = {
+       .attrs = ads7843_attributes,
+};
+
+static struct attribute *ads7845_attributes[] = {
+       &dev_attr_vaux.attr,
+       &dev_attr_pen_down.attr,
+       &dev_attr_disable.attr,
+       NULL,
+};
+
+static struct attribute_group ads7845_attr_group = {
+       .attrs = ads7845_attributes,
+};
+
 /*--------------------------------------------------------------------------*/
 
 /*
@@ -788,38 +831,30 @@ static int __devinit ads7846_probe(struct spi_device *spi)
        (void) ads7846_read12_ser(&spi->dev,
                          READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON);
 
-       /* ads7843/7845 don't have temperature sensors, and
-        * use the other sensors a bit differently too
-        */
-       if (ts->model == 7846) {
-               device_create_file(&spi->dev, &dev_attr_temp0);
-               device_create_file(&spi->dev, &dev_attr_temp1);
+       switch (ts->model) {
+       case 7846:
+               ts->attr_group = &ads7846_attr_group;
+               break;
+       case 7845:
+               ts->attr_group = &ads7845_attr_group;
+               break;
+       default:
+               ts->attr_group = &ads7843_attr_group;
+               break;
        }
-       if (ts->model != 7845)
-               device_create_file(&spi->dev, &dev_attr_vbatt);
-       device_create_file(&spi->dev, &dev_attr_vaux);
-
-       device_create_file(&spi->dev, &dev_attr_pen_down);
-
-       device_create_file(&spi->dev, &dev_attr_disable);
+       err = sysfs_create_group(&spi->dev.kobj, ts->attr_group);
+       if (err)
+               goto err_free_irq;
 
        err = input_register_device(input_dev);
        if (err)
-               goto err_remove_attr;
+               goto err_remove_attr_group;
 
        return 0;
 
- err_remove_attr:
-       device_remove_file(&spi->dev, &dev_attr_disable);
-       device_remove_file(&spi->dev, &dev_attr_pen_down);
-       if (ts->model == 7846) {
-               device_remove_file(&spi->dev, &dev_attr_temp1);
-               device_remove_file(&spi->dev, &dev_attr_temp0);
-       }
-       if (ts->model != 7845)
-               device_remove_file(&spi->dev, &dev_attr_vbatt);
-       device_remove_file(&spi->dev, &dev_attr_vaux);
-
+ err_remove_attr_group:
+       sysfs_remove_group(&spi->dev.kobj, ts->attr_group);
+ err_free_irq:
        free_irq(spi->irq, ts);
  err_free_mem:
        input_free_device(input_dev);
@@ -835,15 +870,7 @@ static int __devexit ads7846_remove(struct spi_device *spi)
 
        ads7846_suspend(spi, PMSG_SUSPEND);
 
-       device_remove_file(&spi->dev, &dev_attr_disable);
-       device_remove_file(&spi->dev, &dev_attr_pen_down);
-       if (ts->model == 7846) {
-               device_remove_file(&spi->dev, &dev_attr_temp1);
-               device_remove_file(&spi->dev, &dev_attr_temp0);
-       }
-       if (ts->model != 7845)
-               device_remove_file(&spi->dev, &dev_attr_vbatt);
-       device_remove_file(&spi->dev, &dev_attr_vaux);
+       sysfs_remove_group(&spi->dev.kobj, ts->attr_group);
 
        free_irq(ts->spi->irq, ts);
        /* suspend left the IRQ disabled */
index 66121f6a89ad1969ad54dab4e9233b9e275d3a0e..e2945582828e2436c0094e438828d58672523c4f 100644 (file)
@@ -175,17 +175,19 @@ static int read_xydata(struct corgi_ts *corgi_ts)
 
 static void new_data(struct corgi_ts *corgi_ts)
 {
+       struct input_dev *dev = corgi_ts->input;
+
        if (corgi_ts->power_mode != PWR_MODE_ACTIVE)
                return;
 
        if (!corgi_ts->tc.pressure && corgi_ts->pendown == 0)
                return;
 
-       input_report_abs(corgi_ts->input, ABS_X, corgi_ts->tc.x);
-       input_report_abs(corgi_ts->input, ABS_Y, corgi_ts->tc.y);
-       input_report_abs(corgi_ts->input, ABS_PRESSURE, corgi_ts->tc.pressure);
-       input_report_key(corgi_ts->input, BTN_TOUCH, (corgi_ts->pendown != 0));
-       input_sync(corgi_ts->input);
+       input_report_abs(dev, ABS_X, corgi_ts->tc.x);
+       input_report_abs(dev, ABS_Y, corgi_ts->tc.y);
+       input_report_abs(dev, ABS_PRESSURE, corgi_ts->tc.pressure);
+       input_report_key(dev, BTN_TOUCH, corgi_ts->pendown);
+       input_sync(dev);
 }
 
 static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer)
@@ -219,12 +221,14 @@ static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer)
 static void corgi_ts_timer(unsigned long data)
 {
        struct corgi_ts *corgits_data = (struct corgi_ts *) data;
+
        ts_interrupt_main(corgits_data, 1);
 }
 
 static irqreturn_t ts_interrupt(int irq, void *dev_id)
 {
        struct corgi_ts *corgits_data = dev_id;
+
        ts_interrupt_main(corgits_data, 0);
        return IRQ_HANDLED;
 }
@@ -272,7 +276,7 @@ static int __init corgits_probe(struct platform_device *pdev)
        corgi_ts = kzalloc(sizeof(struct corgi_ts), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!corgi_ts || !input_dev)
-               goto fail;
+               goto fail1;
 
        platform_set_drvdata(pdev, corgi_ts);
 
@@ -281,7 +285,7 @@ static int __init corgits_probe(struct platform_device *pdev)
 
        if (corgi_ts->irq_gpio < 0) {
                err = -ENODEV;
-               goto fail;
+               goto fail1;
        }
 
        corgi_ts->input = input_dev;
@@ -319,10 +323,12 @@ static int __init corgits_probe(struct platform_device *pdev)
 
        if (request_irq(corgi_ts->irq_gpio, ts_interrupt, IRQF_DISABLED, "ts", corgi_ts)) {
                err = -EBUSY;
-               goto fail;
+               goto fail1;
        }
 
-       input_register_device(corgi_ts->input);
+       err = input_register_device(corgi_ts->input);
+       if (err)
+               goto fail2;
 
        corgi_ts->power_mode = PWR_MODE_ACTIVE;
 
@@ -331,17 +337,17 @@ static int __init corgits_probe(struct platform_device *pdev)
 
        return 0;
 
- fail: input_free_device(input_dev);
+ fail2:        free_irq(corgi_ts->irq_gpio, corgi_ts);
+ fail1:        input_free_device(input_dev);
        kfree(corgi_ts);
        return err;
-
 }
 
 static int corgits_remove(struct platform_device *pdev)
 {
        struct corgi_ts *corgi_ts = platform_get_drvdata(pdev);
 
-       free_irq(corgi_ts->irq_gpio, NULL);
+       free_irq(corgi_ts->irq_gpio, corgi_ts);
        del_timer_sync(&corgi_ts->timer);
        corgi_ts->machinfo->put_hsync();
        input_unregister_device(corgi_ts->input);
index 913e1b73bb0e6780b44a57dcfd16f5b6d06b6a51..9d61cd133d0179305f796a668768ce2ab37d3061 100644 (file)
@@ -397,8 +397,7 @@ static struct serio_driver elo_drv = {
 
 static int __init elo_init(void)
 {
-       serio_register_driver(&elo_drv);
-       return 0;
+       return serio_register_driver(&elo_drv);
 }
 
 static void __exit elo_exit(void)
index 817c2198933dbe6f31b4a854f478402d5a1fabae..9157eb148e84cb784130652bb0c50a4a9649a6b3 100644 (file)
@@ -123,7 +123,7 @@ static int gunze_connect(struct serio *serio, struct serio_driver *drv)
        input_dev = input_allocate_device();
        if (!gunze || !input_dev) {
                err = -ENOMEM;
-               goto fail;
+               goto fail1;
        }
 
        gunze->serio = serio;
@@ -146,13 +146,17 @@ static int gunze_connect(struct serio *serio, struct serio_driver *drv)
 
        err = serio_open(serio, drv);
        if (err)
-               goto fail;
+               goto fail2;
+
+       err = input_register_device(gunze->dev);
+       if (err)
+               goto fail3;
 
-       input_register_device(gunze->dev);
        return 0;
 
- fail: serio_set_drvdata(serio, NULL);
-       input_free_device(input_dev);
+ fail3:        serio_close(serio);
+ fail2:        serio_set_drvdata(serio, NULL);
+ fail1:        input_free_device(input_dev);
        kfree(gunze);
        return err;
 }
@@ -190,8 +194,7 @@ static struct serio_driver gunze_drv = {
 
 static int __init gunze_init(void)
 {
-       serio_register_driver(&gunze_drv);
-       return 0;
+       return serio_register_driver(&gunze_drv);
 }
 
 static void __exit gunze_exit(void)
index d9e61ee05ea94dfdf35e9307bb2de1f4808545fd..c4116d4f64e7ae5d85424dfa0cb02c450b758b84 100644 (file)
@@ -478,8 +478,7 @@ static struct serio_driver h3600ts_drv = {
 
 static int __init h3600ts_init(void)
 {
-       serio_register_driver(&h3600ts_drv);
-       return 0;
+       return serio_register_driver(&h3600ts_drv);
 }
 
 static void __exit h3600ts_exit(void)
index 58fca316786c274a8d5ef473abd7ad12414b4642..249087472740133b4bd359db9255eacd134b784a 100644 (file)
@@ -76,38 +76,47 @@ static irqreturn_t hp680_ts_interrupt(int irq, void *dev)
 
 static int __init hp680_ts_init(void)
 {
+       int err;
+
        hp680_ts_dev = input_allocate_device();
        if (!hp680_ts_dev)
                return -ENOMEM;
 
        hp680_ts_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY);
-       hp680_ts_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
        hp680_ts_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
 
-       hp680_ts_dev->absmin[ABS_X] = HP680_TS_ABS_X_MIN;
-       hp680_ts_dev->absmin[ABS_Y] = HP680_TS_ABS_Y_MIN;
-       hp680_ts_dev->absmax[ABS_X] = HP680_TS_ABS_X_MAX;
-       hp680_ts_dev->absmax[ABS_Y] = HP680_TS_ABS_Y_MAX;
+       input_set_abs_params(hp680_ts_dev, ABS_X,
+               HP680_TS_ABS_X_MIN, HP680_TS_ABS_X_MAX, 0, 0);
+       input_set_abs_params(hp680_ts_dev, ABS_Y,
+               HP680_TS_ABS_Y_MIN, HP680_TS_ABS_Y_MAX, 0, 0);
 
        hp680_ts_dev->name = "HP Jornada touchscreen";
        hp680_ts_dev->phys = "hp680_ts/input0";
 
-       input_register_device(hp680_ts_dev);
-
        if (request_irq(HP680_TS_IRQ, hp680_ts_interrupt,
                        IRQF_DISABLED, MODNAME, 0) < 0) {
                printk(KERN_ERR "hp680_touchscreen.c: Can't allocate irq %d\n",
                       HP680_TS_IRQ);
-               input_unregister_device(hp680_ts_dev);
-               return -EBUSY;
+               err = -EBUSY;
+               goto fail1;
        }
 
+       err = input_register_device(hp680_ts_dev);
+       if (err)
+               goto fail2;
+
        return 0;
+
+ fail2:        free_irq(HP680_TS_IRQ, NULL);
+       cancel_delayed_work(&work);
+       flush_scheduled_work();
+ fail1:        input_free_device(hp680_ts_dev);
+       return err;
 }
 
 static void __exit hp680_ts_exit(void)
 {
-       free_irq(HP680_TS_IRQ, 0);
+       free_irq(HP680_TS_IRQ, NULL);
        cancel_delayed_work(&work);
        flush_scheduled_work();
        input_unregister_device(hp680_ts_dev);
index 4cbcaa6a71e5d0d72c157e4430feb5fff53ec588..44140feeffc503428a54399b591f1628f3842010 100644 (file)
@@ -96,15 +96,13 @@ static irqreturn_t mk712_interrupt(int irq, void *dev_id)
                goto end;
        }
 
-       if (~status & MK712_STATUS_TOUCH)
-       {
+       if (~status & MK712_STATUS_TOUCH) {
                debounce = 1;
                input_report_key(mk712_dev, BTN_TOUCH, 0);
                goto end;
        }
 
-       if (debounce)
-       {
+       if (debounce) {
                debounce = 0;
                goto end;
        }
@@ -113,8 +111,7 @@ static irqreturn_t mk712_interrupt(int irq, void *dev_id)
        input_report_abs(mk712_dev, ABS_X, last_x);
        input_report_abs(mk712_dev, ABS_Y, last_y);
 
-end:
-
+ end:
        last_x = inw(mk712_io + MK712_X) & 0x0fff;
        last_y = inw(mk712_io + MK712_Y) & 0x0fff;
        input_sync(mk712_dev);
@@ -169,13 +166,14 @@ static int __init mk712_init(void)
            (inw(mk712_io + MK712_STATUS) & 0xf333)) {
                printk(KERN_WARNING "mk712: device not present\n");
                err = -ENODEV;
-               goto fail;
+               goto fail1;
        }
 
-       if (!(mk712_dev = input_allocate_device())) {
+       mk712_dev = input_allocate_device();
+       if (!mk712_dev) {
                printk(KERN_ERR "mk712: not enough memory\n");
                err = -ENOMEM;
-               goto fail;
+               goto fail1;
        }
 
        mk712_dev->name = "ICS MicroClock MK712 TouchScreen";
@@ -196,13 +194,17 @@ static int __init mk712_init(void)
        if (request_irq(mk712_irq, mk712_interrupt, 0, "mk712", mk712_dev)) {
                printk(KERN_WARNING "mk712: unable to get IRQ\n");
                err = -EBUSY;
-               goto fail;
+               goto fail1;
        }
 
-       input_register_device(mk712_dev);
+       err = input_register_device(mk712_dev);
+       if (err)
+               goto fail2;
+
        return 0;
 
- fail: input_free_device(mk712_dev);
+ fail2:        free_irq(mk712_irq, mk712_dev);
+ fail1:        input_free_device(mk712_dev);
        release_region(mk712_io, 8);
        return err;
 }
index 3b4c61664b631f6eba87b016acc051690a7e835c..c3c2d735d0ec70c4f7a06d7e6bbe8db418767e0e 100644 (file)
@@ -137,7 +137,7 @@ static int mtouch_connect(struct serio *serio, struct serio_driver *drv)
        input_dev = input_allocate_device();
        if (!mtouch || !input_dev) {
                err = -ENOMEM;
-               goto fail;
+               goto fail1;
        }
 
        mtouch->serio = serio;
@@ -160,14 +160,17 @@ static int mtouch_connect(struct serio *serio, struct serio_driver *drv)
 
        err = serio_open(serio, drv);
        if (err)
-               goto fail;
+               goto fail2;
 
-       input_register_device(mtouch->dev);
+       err = input_register_device(mtouch->dev);
+       if (err)
+               goto fail3;
 
        return 0;
 
- fail: serio_set_drvdata(serio, NULL);
-       input_free_device(input_dev);
+ fail3:        serio_close(serio);
+ fail2:        serio_set_drvdata(serio, NULL);
+ fail1:        input_free_device(input_dev);
        kfree(mtouch);
        return err;
 }
@@ -205,8 +208,7 @@ static struct serio_driver mtouch_drv = {
 
 static int __init mtouch_init(void)
 {
-       serio_register_driver(&mtouch_drv);
-       return 0;
+       return serio_register_driver(&mtouch_drv);
 }
 
 static void __exit mtouch_exit(void)
index 6c7d0c2c76ccd79e976bee8e260ae43a6eda098e..bd2767991ae9b89cc1646d7061b5b3b0c207909a 100644 (file)
@@ -171,8 +171,7 @@ static struct serio_driver pm_drv = {
 
 static int __init pm_init(void)
 {
-       serio_register_driver(&pm_drv);
-       return 0;
+       return serio_register_driver(&pm_drv);
 }
 
 static void __exit pm_exit(void)
index c74f74e57af02fb1678880a236de82529b80e1da..35ba46c6ad2d3f77530da62710d6ffacf72792aa 100644 (file)
@@ -182,8 +182,7 @@ static struct serio_driver tr_drv = {
 
 static int __init tr_init(void)
 {
-       serio_register_driver(&tr_drv);
-       return 0;
+       return serio_register_driver(&tr_drv);
 }
 
 static void __exit tr_exit(void)
index 9911820fa2fe9f67123f6eb580101abad77d5629..4dc073dacabbdbb2080d71fe15106422d5557342 100644 (file)
@@ -189,8 +189,7 @@ static struct serio_driver tw_drv = {
 
 static int __init tw_init(void)
 {
-       serio_register_driver(&tw_drv);
-       return 0;
+       return serio_register_driver(&tw_drv);
 }
 
 static void __exit tw_exit(void)
diff --git a/drivers/input/touchscreen/ucb1400_ts.c b/drivers/input/touchscreen/ucb1400_ts.c
new file mode 100644 (file)
index 0000000..4358a0a
--- /dev/null
@@ -0,0 +1,579 @@
+/*
+ *  Philips UCB1400 touchscreen driver
+ *
+ *  Author:    Nicolas Pitre
+ *  Created:   September 25, 2006
+ *  Copyright: 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.
+ *
+ * This code is heavily based on ucb1x00-*.c copyrighted by Russell King
+ * covering the UCB1100, UCB1200 and UCB1300..  Support for the UCB1400 has
+ * been made separate from ucb1x00-core/ucb1x00-ts on Russell's request.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/completion.h>
+#include <linux/delay.h>
+#include <linux/input.h>
+#include <linux/device.h>
+#include <linux/interrupt.h>
+#include <linux/suspend.h>
+#include <linux/slab.h>
+#include <linux/kthread.h>
+#include <linux/freezer.h>
+
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/ac97_codec.h>
+
+
+/*
+ * Interesting UCB1400 AC-link registers
+ */
+
+#define UCB_IE_RIS             0x5e
+#define UCB_IE_FAL             0x60
+#define UCB_IE_STATUS          0x62
+#define UCB_IE_CLEAR           0x62
+#define UCB_IE_ADC             (1 << 11)
+#define UCB_IE_TSPX            (1 << 12)
+
+#define UCB_TS_CR              0x64
+#define UCB_TS_CR_TSMX_POW     (1 << 0)
+#define UCB_TS_CR_TSPX_POW     (1 << 1)
+#define UCB_TS_CR_TSMY_POW     (1 << 2)
+#define UCB_TS_CR_TSPY_POW     (1 << 3)
+#define UCB_TS_CR_TSMX_GND     (1 << 4)
+#define UCB_TS_CR_TSPX_GND     (1 << 5)
+#define UCB_TS_CR_TSMY_GND     (1 << 6)
+#define UCB_TS_CR_TSPY_GND     (1 << 7)
+#define UCB_TS_CR_MODE_INT     (0 << 8)
+#define UCB_TS_CR_MODE_PRES    (1 << 8)
+#define UCB_TS_CR_MODE_POS     (2 << 8)
+#define UCB_TS_CR_BIAS_ENA     (1 << 11)
+#define UCB_TS_CR_TSPX_LOW     (1 << 12)
+#define UCB_TS_CR_TSMX_LOW     (1 << 13)
+
+#define UCB_ADC_CR             0x66
+#define UCB_ADC_SYNC_ENA       (1 << 0)
+#define UCB_ADC_VREFBYP_CON    (1 << 1)
+#define UCB_ADC_INP_TSPX       (0 << 2)
+#define UCB_ADC_INP_TSMX       (1 << 2)
+#define UCB_ADC_INP_TSPY       (2 << 2)
+#define UCB_ADC_INP_TSMY       (3 << 2)
+#define UCB_ADC_INP_AD0                (4 << 2)
+#define UCB_ADC_INP_AD1                (5 << 2)
+#define UCB_ADC_INP_AD2                (6 << 2)
+#define UCB_ADC_INP_AD3                (7 << 2)
+#define UCB_ADC_EXT_REF                (1 << 5)
+#define UCB_ADC_START          (1 << 7)
+#define UCB_ADC_ENA            (1 << 15)
+
+#define UCB_ADC_DATA           0x68
+#define UCB_ADC_DAT_VALID      (1 << 15)
+#define UCB_ADC_DAT_VALUE(x)   ((x) & 0x3ff)
+
+#define UCB_ID                 0x7e
+#define UCB_ID_1400             0x4304
+
+
+struct ucb1400 {
+       ac97_t                  *ac97;
+       struct input_dev        *ts_idev;
+
+       int                     irq;
+
+       wait_queue_head_t       ts_wait;
+       struct task_struct      *ts_task;
+
+       unsigned int            irq_pending;    /* not bit field shared */
+       unsigned int            ts_restart:1;
+       unsigned int            adcsync:1;
+};
+
+static int adcsync;
+
+static inline u16 ucb1400_reg_read(struct ucb1400 *ucb, u16 reg)
+{
+       return ucb->ac97->bus->ops->read(ucb->ac97, reg);
+}
+
+static inline void ucb1400_reg_write(struct ucb1400 *ucb, u16 reg, u16 val)
+{
+       ucb->ac97->bus->ops->write(ucb->ac97, reg, val);
+}
+
+static inline void ucb1400_adc_enable(struct ucb1400 *ucb)
+{
+       ucb1400_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA);
+}
+
+static unsigned int ucb1400_adc_read(struct ucb1400 *ucb, u16 adc_channel)
+{
+       unsigned int val;
+
+       if (ucb->adcsync)
+               adc_channel |= UCB_ADC_SYNC_ENA;
+
+       ucb1400_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA | adc_channel);
+       ucb1400_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA | adc_channel | UCB_ADC_START);
+
+       for (;;) {
+               val = ucb1400_reg_read(ucb, UCB_ADC_DATA);
+               if (val & UCB_ADC_DAT_VALID)
+                       break;
+               /* yield to other processes */
+               set_current_state(TASK_INTERRUPTIBLE);
+               schedule_timeout(1);
+       }
+
+       return UCB_ADC_DAT_VALUE(val);
+}
+
+static inline void ucb1400_adc_disable(struct ucb1400 *ucb)
+{
+       ucb1400_reg_write(ucb, UCB_ADC_CR, 0);
+}
+
+/* Switch to interrupt mode. */
+static inline void ucb1400_ts_mode_int(struct ucb1400 *ucb)
+{
+       ucb1400_reg_write(ucb, UCB_TS_CR,
+                       UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW |
+                       UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND |
+                       UCB_TS_CR_MODE_INT);
+}
+
+/*
+ * Switch to pressure mode, and read pressure.  We don't need to wait
+ * here, since both plates are being driven.
+ */
+static inline unsigned int ucb1400_ts_read_pressure(struct ucb1400 *ucb)
+{
+       ucb1400_reg_write(ucb, UCB_TS_CR,
+                       UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW |
+                       UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND |
+                       UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
+       return ucb1400_adc_read(ucb, UCB_ADC_INP_TSPY);
+}
+
+/*
+ * Switch to X position mode and measure Y plate.  We switch the plate
+ * configuration in pressure mode, then switch to position mode.  This
+ * gives a faster response time.  Even so, we need to wait about 55us
+ * for things to stabilise.
+ */
+static inline unsigned int ucb1400_ts_read_xpos(struct ucb1400 *ucb)
+{
+       ucb1400_reg_write(ucb, UCB_TS_CR,
+                       UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW |
+                       UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
+       ucb1400_reg_write(ucb, UCB_TS_CR,
+                       UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW |
+                       UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
+       ucb1400_reg_write(ucb, UCB_TS_CR,
+                       UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW |
+                       UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA);
+
+       udelay(55);
+
+       return ucb1400_adc_read(ucb, UCB_ADC_INP_TSPY);
+}
+
+/*
+ * Switch to Y position mode and measure X plate.  We switch the plate
+ * configuration in pressure mode, then switch to position mode.  This
+ * gives a faster response time.  Even so, we need to wait about 55us
+ * for things to stabilise.
+ */
+static inline unsigned int ucb1400_ts_read_ypos(struct ucb1400 *ucb)
+{
+       ucb1400_reg_write(ucb, UCB_TS_CR,
+                       UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW |
+                       UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
+       ucb1400_reg_write(ucb, UCB_TS_CR,
+                       UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW |
+                       UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
+       ucb1400_reg_write(ucb, UCB_TS_CR,
+                       UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW |
+                       UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA);
+
+       udelay(55);
+
+       return ucb1400_adc_read(ucb, UCB_ADC_INP_TSPX);
+}
+
+/*
+ * Switch to X plate resistance mode.  Set MX to ground, PX to
+ * supply.  Measure current.
+ */
+static inline unsigned int ucb1400_ts_read_xres(struct ucb1400 *ucb)
+{
+       ucb1400_reg_write(ucb, UCB_TS_CR,
+                       UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW |
+                       UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
+       return ucb1400_adc_read(ucb, 0);
+}
+
+/*
+ * Switch to Y plate resistance mode.  Set MY to ground, PY to
+ * supply.  Measure current.
+ */
+static inline unsigned int ucb1400_ts_read_yres(struct ucb1400 *ucb)
+{
+       ucb1400_reg_write(ucb, UCB_TS_CR,
+                       UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW |
+                       UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
+       return ucb1400_adc_read(ucb, 0);
+}
+
+static inline int ucb1400_ts_pen_down(struct ucb1400 *ucb)
+{
+       unsigned short val = ucb1400_reg_read(ucb, UCB_TS_CR);
+       return (val & (UCB_TS_CR_TSPX_LOW | UCB_TS_CR_TSMX_LOW));
+}
+
+static inline void ucb1400_ts_irq_enable(struct ucb1400 *ucb)
+{
+       ucb1400_reg_write(ucb, UCB_IE_CLEAR, UCB_IE_TSPX);
+       ucb1400_reg_write(ucb, UCB_IE_CLEAR, 0);
+       ucb1400_reg_write(ucb, UCB_IE_FAL, UCB_IE_TSPX);
+}
+
+static inline void ucb1400_ts_irq_disable(struct ucb1400 *ucb)
+{
+       ucb1400_reg_write(ucb, UCB_IE_FAL, 0);
+}
+
+static void ucb1400_ts_evt_add(struct input_dev *idev, u16 pressure, u16 x, u16 y)
+{
+       input_report_abs(idev, ABS_X, x);
+       input_report_abs(idev, ABS_Y, y);
+       input_report_abs(idev, ABS_PRESSURE, pressure);
+       input_sync(idev);
+}
+
+static void ucb1400_ts_event_release(struct input_dev *idev)
+{
+       input_report_abs(idev, ABS_PRESSURE, 0);
+       input_sync(idev);
+}
+
+static void ucb1400_handle_pending_irq(struct ucb1400 *ucb)
+{
+       unsigned int isr;
+
+       isr = ucb1400_reg_read(ucb, UCB_IE_STATUS);
+       ucb1400_reg_write(ucb, UCB_IE_CLEAR, isr);
+       ucb1400_reg_write(ucb, UCB_IE_CLEAR, 0);
+
+       if (isr & UCB_IE_TSPX)
+               ucb1400_ts_irq_disable(ucb);
+       else
+               printk(KERN_ERR "ucb1400: unexpected IE_STATUS = %#x\n", isr);
+
+       enable_irq(ucb->irq);
+}
+
+static int ucb1400_ts_thread(void *_ucb)
+{
+       struct ucb1400 *ucb = _ucb;
+       struct task_struct *tsk = current;
+       int valid = 0;
+
+       tsk->policy = SCHED_FIFO;
+       tsk->rt_priority = 1;
+
+       while (!kthread_should_stop()) {
+               unsigned int x, y, p;
+               long timeout;
+
+               ucb->ts_restart = 0;
+
+               if (ucb->irq_pending) {
+                       ucb->irq_pending = 0;
+                       ucb1400_handle_pending_irq(ucb);
+               }
+
+               ucb1400_adc_enable(ucb);
+               x = ucb1400_ts_read_xpos(ucb);
+               y = ucb1400_ts_read_ypos(ucb);
+               p = ucb1400_ts_read_pressure(ucb);
+               ucb1400_adc_disable(ucb);
+
+               /* Switch back to interrupt mode. */
+               ucb1400_ts_mode_int(ucb);
+
+               msleep(10);
+
+               if (ucb1400_ts_pen_down(ucb)) {
+                       ucb1400_ts_irq_enable(ucb);
+
+                       /*
+                        * If we spat out a valid sample set last time,
+                        * spit out a "pen off" sample here.
+                        */
+                       if (valid) {
+                               ucb1400_ts_event_release(ucb->ts_idev);
+                               valid = 0;
+                       }
+
+                       timeout = MAX_SCHEDULE_TIMEOUT;
+               } else {
+                       valid = 1;
+                       ucb1400_ts_evt_add(ucb->ts_idev, p, x, y);
+                       timeout = msecs_to_jiffies(10);
+               }
+
+               wait_event_interruptible_timeout(ucb->ts_wait,
+                       ucb->irq_pending || ucb->ts_restart || kthread_should_stop(),
+                       timeout);
+               try_to_freeze();
+       }
+
+       /* Send the "pen off" if we are stopping with the pen still active */
+       if (valid)
+               ucb1400_ts_event_release(ucb->ts_idev);
+
+       ucb->ts_task = NULL;
+       return 0;
+}
+
+/*
+ * A restriction with interrupts exists when using the ucb1400, as
+ * the codec read/write routines may sleep while waiting for codec
+ * access completion and uses semaphores for access control to the
+ * AC97 bus.  A complete codec read cycle could take  anywhere from
+ * 60 to 100uSec so we *definitely* don't want to spin inside the
+ * interrupt handler waiting for codec access.  So, we handle the
+ * interrupt by scheduling a RT kernel thread to run in process
+ * context instead of interrupt context.
+ */
+static irqreturn_t ucb1400_hard_irq(int irqnr, void *devid)
+{
+       struct ucb1400 *ucb = devid;
+
+       if (irqnr == ucb->irq) {
+               disable_irq(ucb->irq);
+               ucb->irq_pending = 1;
+               wake_up(&ucb->ts_wait);
+               return IRQ_HANDLED;
+       }
+       return IRQ_NONE;
+}
+
+static int ucb1400_ts_open(struct input_dev *idev)
+{
+       struct ucb1400 *ucb = idev->private;
+       int ret = 0;
+
+       BUG_ON(ucb->ts_task);
+
+       ucb->ts_task = kthread_run(ucb1400_ts_thread, ucb, "UCB1400_ts");
+       if (IS_ERR(ucb->ts_task)) {
+               ret = PTR_ERR(ucb->ts_task);
+               ucb->ts_task = NULL;
+       }
+
+       return ret;
+}
+
+static void ucb1400_ts_close(struct input_dev *idev)
+{
+       struct ucb1400 *ucb = idev->private;
+
+       if (ucb->ts_task)
+               kthread_stop(ucb->ts_task);
+
+       ucb1400_ts_irq_disable(ucb);
+       ucb1400_reg_write(ucb, UCB_TS_CR, 0);
+}
+
+#ifdef CONFIG_PM
+static int ucb1400_ts_resume(struct device *dev)
+{
+       struct ucb1400 *ucb = dev_get_drvdata(dev);
+
+       if (ucb->ts_task) {
+               /*
+                * Restart the TS thread to ensure the
+                * TS interrupt mode is set up again
+                * after sleep.
+                */
+               ucb->ts_restart = 1;
+               wake_up(&ucb->ts_wait);
+       }
+       return 0;
+}
+#else
+#define ucb1400_ts_resume NULL
+#endif
+
+#ifndef NO_IRQ
+#define NO_IRQ 0
+#endif
+
+/*
+ * Try to probe our interrupt, rather than relying on lots of
+ * hard-coded machine dependencies.
+ */
+static int ucb1400_detect_irq(struct ucb1400 *ucb)
+{
+       unsigned long mask, timeout;
+
+       mask = probe_irq_on();
+       if (!mask) {
+               probe_irq_off(mask);
+               return -EBUSY;
+       }
+
+       /* Enable the ADC interrupt. */
+       ucb1400_reg_write(ucb, UCB_IE_RIS, UCB_IE_ADC);
+       ucb1400_reg_write(ucb, UCB_IE_FAL, UCB_IE_ADC);
+       ucb1400_reg_write(ucb, UCB_IE_CLEAR, 0xffff);
+       ucb1400_reg_write(ucb, UCB_IE_CLEAR, 0);
+
+       /* Cause an ADC interrupt. */
+       ucb1400_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA);
+       ucb1400_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA | UCB_ADC_START);
+
+       /* Wait for the conversion to complete. */
+       timeout = jiffies + HZ/2;
+       while (!(ucb1400_reg_read(ucb, UCB_ADC_DATA) & UCB_ADC_DAT_VALID)) {
+               cpu_relax();
+               if (time_after(jiffies, timeout)) {
+                       printk(KERN_ERR "ucb1400: timed out in IRQ probe\n");
+                       probe_irq_off(mask);
+                       return -ENODEV;
+               }
+       }
+       ucb1400_reg_write(ucb, UCB_ADC_CR, 0);
+
+       /* Disable and clear interrupt. */
+       ucb1400_reg_write(ucb, UCB_IE_RIS, 0);
+       ucb1400_reg_write(ucb, UCB_IE_FAL, 0);
+       ucb1400_reg_write(ucb, UCB_IE_CLEAR, 0xffff);
+       ucb1400_reg_write(ucb, UCB_IE_CLEAR, 0);
+
+       /* Read triggered interrupt. */
+       ucb->irq = probe_irq_off(mask);
+       if (ucb->irq < 0 || ucb->irq == NO_IRQ)
+               return -ENODEV;
+
+       return 0;
+}
+
+static int ucb1400_ts_probe(struct device *dev)
+{
+       struct ucb1400 *ucb;
+       struct input_dev *idev;
+       int error, id, x_res, y_res;
+
+       ucb = kzalloc(sizeof(struct ucb1400), GFP_KERNEL);
+       idev = input_allocate_device();
+       if (!ucb || !idev) {
+               error = -ENOMEM;
+               goto err_free_devs;
+       }
+
+       ucb->ts_idev = idev;
+       ucb->adcsync = adcsync;
+       ucb->ac97 = to_ac97_t(dev);
+       init_waitqueue_head(&ucb->ts_wait);
+
+       id = ucb1400_reg_read(ucb, UCB_ID);
+       if (id != UCB_ID_1400) {
+               error = -ENODEV;
+               goto err_free_devs;
+       }
+
+       error = ucb1400_detect_irq(ucb);
+       if (error) {
+               printk(KERN_ERR "UCB1400: IRQ probe failed\n");
+               goto err_free_devs;
+       }
+
+       error = request_irq(ucb->irq, ucb1400_hard_irq, IRQF_TRIGGER_RISING,
+                               "UCB1400", ucb);
+       if (error) {
+               printk(KERN_ERR "ucb1400: unable to grab irq%d: %d\n",
+                               ucb->irq, error);
+               goto err_free_devs;
+       }
+       printk(KERN_DEBUG "UCB1400: found IRQ %d\n", ucb->irq);
+
+       idev->private           = ucb;
+       idev->cdev.dev          = dev;
+       idev->name              = "UCB1400 touchscreen interface";
+       idev->id.vendor         = ucb1400_reg_read(ucb, AC97_VENDOR_ID1);
+       idev->id.product        = id;
+       idev->open              = ucb1400_ts_open;
+       idev->close             = ucb1400_ts_close;
+       idev->evbit[0]          = BIT(EV_ABS);
+
+       ucb1400_adc_enable(ucb);
+       x_res = ucb1400_ts_read_xres(ucb);
+       y_res = ucb1400_ts_read_yres(ucb);
+       ucb1400_adc_disable(ucb);
+       printk(KERN_DEBUG "UCB1400: x/y = %d/%d\n", x_res, y_res);
+
+       input_set_abs_params(idev, ABS_X, 0, x_res, 0, 0);
+       input_set_abs_params(idev, ABS_Y, 0, y_res, 0, 0);
+       input_set_abs_params(idev, ABS_PRESSURE, 0, 0, 0, 0);
+
+       error = input_register_device(idev);
+       if (error)
+               goto err_free_irq;
+
+       dev_set_drvdata(dev, ucb);
+       return 0;
+
+ err_free_irq:
+       free_irq(ucb->irq, ucb);
+ err_free_devs:
+       input_free_device(idev);
+       kfree(ucb);
+       return error;
+}
+
+static int ucb1400_ts_remove(struct device *dev)
+{
+       struct ucb1400 *ucb = dev_get_drvdata(dev);
+
+       free_irq(ucb->irq, ucb);
+       input_unregister_device(ucb->ts_idev);
+       dev_set_drvdata(dev, NULL);
+       kfree(ucb);
+       return 0;
+}
+
+static struct device_driver ucb1400_ts_driver = {
+       .owner          = THIS_MODULE,
+       .bus            = &ac97_bus_type,
+       .probe          = ucb1400_ts_probe,
+       .remove         = ucb1400_ts_remove,
+       .resume         = ucb1400_ts_resume,
+};
+
+static int __init ucb1400_ts_init(void)
+{
+       return driver_register(&ucb1400_ts_driver);
+}
+
+static void __exit ucb1400_ts_exit(void)
+{
+       driver_unregister(&ucb1400_ts_driver);
+}
+
+module_param(adcsync, int, 0444);
+
+module_init(ucb1400_ts_init);
+module_exit(ucb1400_ts_exit);
+
+MODULE_DESCRIPTION("Philips UCB1400 touchscreen driver");
+MODULE_LICENSE("GPL");
index 90593e2ef87209dbb36261e30947ea283a660d04..e3e5c139907632d8417bbfbd247cbb1f431803f9 100644 (file)
@@ -573,12 +573,11 @@ act2000_alloccard(int bus, int port, int irq, char *id)
 {
        int i;
         act2000_card *card;
-        if (!(card = (act2000_card *) kmalloc(sizeof(act2000_card), GFP_KERNEL))) {
+        if (!(card = kzalloc(sizeof(act2000_card), GFP_KERNEL))) {
                 printk(KERN_WARNING
                       "act2000: (%s) Could not allocate card-struct.\n", id);
                 return;
         }
-        memset((char *) card, 0, sizeof(act2000_card));
         spin_lock_init(&card->lock);
         spin_lock_init(&card->mnlock);
        skb_queue_head_init(&card->sndq);
index 11844bbfe9339d3db64fc401347149edae459a69..d22c0224fde6505e9695e9c702ab42c4e3d7aaf4 100644 (file)
@@ -215,13 +215,12 @@ static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci)
        unsigned int minor = 0;
        unsigned long flags;
 
-       mp = kmalloc(sizeof(*mp), GFP_ATOMIC);
+       mp = kzalloc(sizeof(*mp), GFP_ATOMIC);
        if (!mp) {
                printk(KERN_ERR "capi: can't alloc capiminor\n");
                return NULL;
        }
 
-       memset(mp, 0, sizeof(struct capiminor));
        mp->ap = ap;
        mp->ncci = ncci;
        mp->msgid = 0;
@@ -304,10 +303,9 @@ static struct capincci *capincci_alloc(struct capidev *cdev, u32 ncci)
        struct capiminor *mp = NULL;
 #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */
 
-       np = kmalloc(sizeof(*np), GFP_ATOMIC);
+       np = kzalloc(sizeof(*np), GFP_ATOMIC);
        if (!np)
                return NULL;
-       memset(np, 0, sizeof(struct capincci));
        np->ncci = ncci;
        np->cdev = cdev;
 #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
@@ -384,10 +382,9 @@ static struct capidev *capidev_alloc(void)
        struct capidev *cdev;
        unsigned long flags;
 
-       cdev = kmalloc(sizeof(*cdev), GFP_KERNEL);
+       cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
        if (!cdev)
                return NULL;
-       memset(cdev, 0, sizeof(struct capidev));
 
        init_MUTEX(&cdev->ncci_list_sem);
        skb_queue_head_init(&cdev->recvqueue);
@@ -1010,7 +1007,7 @@ static int capinc_tty_open(struct tty_struct * tty, struct file * file)
 {
        struct capiminor *mp;
 
-       if ((mp = capiminor_find(iminor(file->f_dentry->d_inode))) == 0)
+       if ((mp = capiminor_find(iminor(file->f_path.dentry->d_inode))) == 0)
                return -ENXIO;
        if (mp->nccip == 0)
                return -ENXIO;
@@ -1203,7 +1200,7 @@ static int capinc_tty_ioctl(struct tty_struct *tty, struct file * file,
        return error;
 }
 
-static void capinc_tty_set_termios(struct tty_struct *tty, struct termios * old)
+static void capinc_tty_set_termios(struct tty_struct *tty, struct ktermios * old)
 {
 #ifdef _DEBUG_TTYFUNCS
        printk(KERN_DEBUG "capinc_tty_set_termios\n");
index b6f9476c0501d75abd98916098726d070c1436be..097bfa7bc323ad1738893ea00adfab252a4abd19 100644 (file)
@@ -334,12 +334,11 @@ static capidrv_plci *new_plci(capidrv_contr * card, int chan)
 {
        capidrv_plci *plcip;
 
-       plcip = (capidrv_plci *) kmalloc(sizeof(capidrv_plci), GFP_ATOMIC);
+       plcip = kzalloc(sizeof(capidrv_plci), GFP_ATOMIC);
 
        if (plcip == 0)
                return NULL;
 
-       memset(plcip, 0, sizeof(capidrv_plci));
        plcip->state = ST_PLCI_NONE;
        plcip->plci = 0;
        plcip->msgid = 0;
@@ -404,12 +403,11 @@ static inline capidrv_ncci *new_ncci(capidrv_contr * card,
 {
        capidrv_ncci *nccip;
 
-       nccip = (capidrv_ncci *) kmalloc(sizeof(capidrv_ncci), GFP_ATOMIC);
+       nccip = kzalloc(sizeof(capidrv_ncci), GFP_ATOMIC);
 
        if (nccip == 0)
                return NULL;
 
-       memset(nccip, 0, sizeof(capidrv_ncci));
        nccip->ncci = ncci;
        nccip->state = ST_NCCI_NONE;
        nccip->plcip = plcip;
@@ -2005,12 +2003,11 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp)
                printk(KERN_WARNING "capidrv: (%s) Could not reserve module\n", id);
                return -1;
        }
-       if (!(card = (capidrv_contr *) kmalloc(sizeof(capidrv_contr), GFP_ATOMIC))) {
+       if (!(card = kzalloc(sizeof(capidrv_contr), GFP_ATOMIC))) {
                printk(KERN_WARNING
                 "capidrv: (%s) Could not allocate contr-struct.\n", id);
                return -1;
        }
-       memset(card, 0, sizeof(capidrv_contr));
        card->owner = THIS_MODULE;
        init_timer(&card->listentimer);
        strcpy(card->name, id);
index 5b203fe21dcd5033c5e6edcedc90daeb619b2bd4..708d47a6484b1bc451bee2c3c90aa4007cb08360 100644 (file)
@@ -5,6 +5,7 @@ config ISDN_DRV_GIGASET
        tristate "Siemens Gigaset support (isdn)"
        depends on ISDN_I4L
        select CRC_CCITT
+       select BITREVERSE
        help
          Say m here if you have a Gigaset or Sinus isdn device.
 
index ce3cd77094b334f8e362ca67404c8ab1baa2ffbd..88e958f176d29f1e493ee463fc29ccdac990718f 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "gigaset.h"
 #include <linux/crc-ccitt.h>
+#include <linux/bitrev.h>
 
 //#define GIG_M10x_STUFF_VOICE_DATA
 
@@ -302,7 +303,7 @@ static inline int iraw_loop(unsigned char c, unsigned char *src, int numbytes,
                                inputstate |= INS_skip_frame;
                                break;
                        }
-                       *__skb_put(skb, 1) = gigaset_invtab[c];
+                       *__skb_put(skb, 1) = bitrev8(c);
                }
 
                if (unlikely(!numbytes))
@@ -543,7 +544,7 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int head, int tail)
        cp = skb->data;
        len = skb->len;
        while (len--) {
-               c = gigaset_invtab[*cp++];
+               c = bitrev8(*cp++);
                if (c == DLE_FLAG)
                        *(skb_put(iraw_skb, 1)) = c;
                *(skb_put(iraw_skb, 1)) = c;
index 0c937325a1b36ce937d8ca99ea20d2587da1dcbe..63b629b1cdb2be0c1e79ac5d7d56f100914a5c11 100644 (file)
@@ -572,7 +572,7 @@ static int atread_submit(struct cardstate *cs, int timeout)
                             ucs->rcvbuf, ucs->rcvbuf_size,
                             read_ctrl_callback, cs->inbuf);
 
-       if ((ret = usb_submit_urb(ucs->urb_cmd_in, SLAB_ATOMIC)) != 0) {
+       if ((ret = usb_submit_urb(ucs->urb_cmd_in, GFP_ATOMIC)) != 0) {
                update_basstate(ucs, 0, BS_ATRDPEND);
                dev_err(cs->dev, "could not submit HD_READ_ATMESSAGE: %s\n",
                        get_usb_rcmsg(ret));
@@ -747,7 +747,7 @@ static void read_int_callback(struct urb *urb)
        check_pending(ucs);
 
 resubmit:
-       rc = usb_submit_urb(urb, SLAB_ATOMIC);
+       rc = usb_submit_urb(urb, GFP_ATOMIC);
        if (unlikely(rc != 0 && rc != -ENODEV)) {
                dev_err(cs->dev, "could not resubmit interrupt URB: %s\n",
                        get_usb_rcmsg(rc));
@@ -807,7 +807,7 @@ static void read_iso_callback(struct urb *urb)
                        urb->number_of_packets = BAS_NUMFRAMES;
                        gig_dbg(DEBUG_ISO, "%s: isoc read overrun/resubmit",
                                __func__);
-                       rc = usb_submit_urb(urb, SLAB_ATOMIC);
+                       rc = usb_submit_urb(urb, GFP_ATOMIC);
                        if (unlikely(rc != 0 && rc != -ENODEV)) {
                                dev_err(bcs->cs->dev,
                                        "could not resubmit isochronous read "
@@ -900,7 +900,7 @@ static int starturbs(struct bc_state *bcs)
                }
 
                dump_urb(DEBUG_ISO, "Initial isoc read", urb);
-               if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0)
+               if ((rc = usb_submit_urb(urb, GFP_ATOMIC)) != 0)
                        goto error;
        }
 
@@ -935,7 +935,7 @@ static int starturbs(struct bc_state *bcs)
        /* submit two URBs, keep third one */
        for (k = 0; k < 2; ++k) {
                dump_urb(DEBUG_ISO, "Initial isoc write", urb);
-               rc = usb_submit_urb(ubc->isoouturbs[k].urb, SLAB_ATOMIC);
+               rc = usb_submit_urb(ubc->isoouturbs[k].urb, GFP_ATOMIC);
                if (rc != 0)
                        goto error;
        }
@@ -1042,7 +1042,7 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
                return 0;       /* no data to send */
        urb->number_of_packets = nframe;
 
-       rc = usb_submit_urb(urb, SLAB_ATOMIC);
+       rc = usb_submit_urb(urb, GFP_ATOMIC);
        if (unlikely(rc)) {
                if (rc == -ENODEV)
                        /* device removed - give up silently */
@@ -1341,7 +1341,7 @@ static void read_iso_tasklet(unsigned long data)
                urb->dev = bcs->cs->hw.bas->udev;
                urb->transfer_flags = URB_ISO_ASAP;
                urb->number_of_packets = BAS_NUMFRAMES;
-               rc = usb_submit_urb(urb, SLAB_ATOMIC);
+               rc = usb_submit_urb(urb, GFP_ATOMIC);
                if (unlikely(rc != 0 && rc != -ENODEV)) {
                        dev_err(cs->dev,
                                "could not resubmit isochronous read URB: %s\n",
@@ -1458,7 +1458,7 @@ static void write_ctrl_callback(struct urb *urb)
                           ucs->retry_ctrl);
                /* urb->dev is clobbered by USB subsystem */
                urb->dev = ucs->udev;
-               rc = usb_submit_urb(urb, SLAB_ATOMIC);
+               rc = usb_submit_urb(urb, GFP_ATOMIC);
                if (unlikely(rc)) {
                        dev_err(&ucs->interface->dev,
                                "could not resubmit request 0x%02x: %s\n",
@@ -1517,7 +1517,7 @@ static int req_submit(struct bc_state *bcs, int req, int val, int timeout)
                             (unsigned char*) &ucs->dr_ctrl, NULL, 0,
                             write_ctrl_callback, ucs);
        ucs->retry_ctrl = 0;
-       ret = usb_submit_urb(ucs->urb_ctrl, SLAB_ATOMIC);
+       ret = usb_submit_urb(ucs->urb_ctrl, GFP_ATOMIC);
        if (unlikely(ret)) {
                dev_err(bcs->cs->dev, "could not submit request 0x%02x: %s\n",
                        req, get_usb_rcmsg(ret));
@@ -1763,7 +1763,7 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len)
                             usb_sndctrlpipe(ucs->udev, 0),
                             (unsigned char*) &ucs->dr_cmd_out, buf, len,
                             write_command_callback, cs);
-       rc = usb_submit_urb(ucs->urb_cmd_out, SLAB_ATOMIC);
+       rc = usb_submit_urb(ucs->urb_cmd_out, GFP_ATOMIC);
        if (unlikely(rc)) {
                update_basstate(ucs, 0, BS_ATWRPEND);
                dev_err(cs->dev, "could not submit HD_WRITE_ATMESSAGE: %s\n",
@@ -2218,21 +2218,21 @@ static int gigaset_probe(struct usb_interface *interface,
         * - three for the different uses of the default control pipe
         * - three for each isochronous pipe
         */
-       if (!(ucs->urb_int_in = usb_alloc_urb(0, SLAB_KERNEL)) ||
-           !(ucs->urb_cmd_in = usb_alloc_urb(0, SLAB_KERNEL)) ||
-           !(ucs->urb_cmd_out = usb_alloc_urb(0, SLAB_KERNEL)) ||
-           !(ucs->urb_ctrl = usb_alloc_urb(0, SLAB_KERNEL)))
+       if (!(ucs->urb_int_in = usb_alloc_urb(0, GFP_KERNEL)) ||
+           !(ucs->urb_cmd_in = usb_alloc_urb(0, GFP_KERNEL)) ||
+           !(ucs->urb_cmd_out = usb_alloc_urb(0, GFP_KERNEL)) ||
+           !(ucs->urb_ctrl = usb_alloc_urb(0, GFP_KERNEL)))
                goto allocerr;
 
        for (j = 0; j < 2; ++j) {
                ubc = cs->bcs[j].hw.bas;
                for (i = 0; i < BAS_OUTURBS; ++i)
                        if (!(ubc->isoouturbs[i].urb =
-                             usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL)))
+                             usb_alloc_urb(BAS_NUMFRAMES, GFP_KERNEL)))
                                goto allocerr;
                for (i = 0; i < BAS_INURBS; ++i)
                        if (!(ubc->isoinurbs[i] =
-                             usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL)))
+                             usb_alloc_urb(BAS_NUMFRAMES, GFP_KERNEL)))
                                goto allocerr;
        }
 
@@ -2246,7 +2246,7 @@ static int gigaset_probe(struct usb_interface *interface,
                                        (endpoint->bEndpointAddress) & 0x0f),
                         ucs->int_in_buf, 3, read_int_callback, cs,
                         endpoint->bInterval);
-       if ((rc = usb_submit_urb(ucs->urb_int_in, SLAB_KERNEL)) != 0) {
+       if ((rc = usb_submit_urb(ucs->urb_int_in, GFP_KERNEL)) != 0) {
                dev_err(cs->dev, "could not submit interrupt URB: %s\n",
                        get_usb_rcmsg(rc));
                goto error;
index defd5743dba6c7d0626cb4e165159f2ffe2756ed..95eff3b2917ae868b8717f153eb94a1022991673 100644 (file)
@@ -33,43 +33,6 @@ MODULE_PARM_DESC(debug, "debug level");
 #define VALID_ID       0x02
 #define ASSIGNED       0x04
 
-/* bitwise byte inversion table */
-__u8 gigaset_invtab[256] = {
-       0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
-       0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
-       0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
-       0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
-       0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
-       0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
-       0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
-       0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
-       0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
-       0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
-       0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
-       0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
-       0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
-       0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
-       0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
-       0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
-       0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
-       0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
-       0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
-       0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
-       0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
-       0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
-       0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
-       0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
-       0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
-       0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
-       0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
-       0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
-       0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
-       0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
-       0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
-       0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
-};
-EXPORT_SYMBOL_GPL(gigaset_invtab);
-
 void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
                        size_t len, const unsigned char *buf)
 {
index 06298cc52bf5bd7e52caaa9c503be27d3137f767..a0317abaeb111fc9ced966f62c11afbd3491bc35 100644 (file)
@@ -876,10 +876,6 @@ static inline void gigaset_rcv_error(struct sk_buff *procskb,
        }
 }
 
-
-/* bitwise byte inversion table */
-extern __u8 gigaset_invtab[];  /* in common.c */
-
 /* append received bytes to inbuf */
 int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src,
                       unsigned numbytes);
index 7edea015867e8c7cd1ccca220d3549372dc67977..458b6462f93779c489440ecce018ead677145d5c 100644 (file)
@@ -127,7 +127,7 @@ static int  if_write_room(struct tty_struct *tty);
 static int  if_chars_in_buffer(struct tty_struct *tty);
 static void if_throttle(struct tty_struct *tty);
 static void if_unthrottle(struct tty_struct *tty);
-static void if_set_termios(struct tty_struct *tty, struct termios *old);
+static void if_set_termios(struct tty_struct *tty, struct ktermios *old);
 static int  if_tiocmget(struct tty_struct *tty, struct file *file);
 static int  if_tiocmset(struct tty_struct *tty, struct file *file,
                        unsigned int set, unsigned int clear);
@@ -490,7 +490,7 @@ static void if_unthrottle(struct tty_struct *tty)
        mutex_unlock(&cs->mutex);
 }
 
-static void if_set_termios(struct tty_struct *tty, struct termios *old)
+static void if_set_termios(struct tty_struct *tty, struct ktermios *old)
 {
        struct cardstate *cs;
        unsigned int iflag;
index 8667daaa1a82e74eb74af3704ea4021e283c50e6..df988eb0e36fdd2bf6da36bba74cafd93f3cf6c8 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "gigaset.h"
 #include <linux/crc-ccitt.h>
+#include <linux/bitrev.h>
 
 /* access methods for isowbuf_t */
 /* ============================ */
@@ -487,7 +488,7 @@ static inline int trans_buildframe(struct isowbuf_t *iwb,
        gig_dbg(DEBUG_STREAM, "put %d bytes", count);
        write = atomic_read(&iwb->write);
        do {
-               c = gigaset_invtab[*in++];
+               c = bitrev8(*in++);
                iwb->data[write++] = c;
                write %= BAS_OUTBUFSIZE;
        } while (--count > 0);
@@ -876,7 +877,7 @@ static inline void trans_receive(unsigned char *src, unsigned count,
        while (count > 0) {
                dst = skb_put(skb, count < dobytes ? count : dobytes);
                while (count > 0 && dobytes > 0) {
-                       *dst++ = gigaset_invtab[*src++];
+                       *dst++ = bitrev8(*src++);
                        count--;
                        dobytes--;
                }
index 5ebf49ac9b2302b89abc26a2fe99c83cb523c398..04f2ad7ba8b04590ae927591096d95e0fc783a1b 100644 (file)
@@ -410,7 +410,7 @@ static void gigaset_read_int_callback(struct urb *urb)
 
        if (resubmit) {
                spin_lock_irqsave(&cs->lock, flags);
-               r = cs->connected ? usb_submit_urb(urb, SLAB_ATOMIC) : -ENODEV;
+               r = cs->connected ? usb_submit_urb(urb, GFP_ATOMIC) : -ENODEV;
                spin_unlock_irqrestore(&cs->lock, flags);
                if (r)
                        dev_err(cs->dev, "error %d when resubmitting urb.\n",
@@ -486,7 +486,7 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb)
                        atomic_set(&ucs->busy, 1);
 
                        spin_lock_irqsave(&cs->lock, flags);
-                       status = cs->connected ? usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC) : -ENODEV;
+                       status = cs->connected ? usb_submit_urb(ucs->bulk_out_urb, GFP_ATOMIC) : -ENODEV;
                        spin_unlock_irqrestore(&cs->lock, flags);
 
                        if (status) {
@@ -664,7 +664,7 @@ static int write_modem(struct cardstate *cs)
                                                  ucs->bulk_out_endpointAddr & 0x0f),
                                  ucs->bulk_out_buffer, count,
                                  gigaset_write_bulk_callback, cs);
-               ret = usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC);
+               ret = usb_submit_urb(ucs->bulk_out_urb, GFP_ATOMIC);
        } else {
                ret = -ENODEV;
        }
@@ -763,7 +763,7 @@ static int gigaset_probe(struct usb_interface *interface,
                goto error;
        }
 
-       ucs->bulk_out_urb = usb_alloc_urb(0, SLAB_KERNEL);
+       ucs->bulk_out_urb = usb_alloc_urb(0, GFP_KERNEL);
        if (!ucs->bulk_out_urb) {
                dev_err(cs->dev, "Couldn't allocate bulk_out_urb\n");
                retval = -ENOMEM;
@@ -774,7 +774,7 @@ static int gigaset_probe(struct usb_interface *interface,
 
        atomic_set(&ucs->busy, 0);
 
-       ucs->read_urb = usb_alloc_urb(0, SLAB_KERNEL);
+       ucs->read_urb = usb_alloc_urb(0, GFP_KERNEL);
        if (!ucs->read_urb) {
                dev_err(cs->dev, "No free urbs available\n");
                retval = -ENOMEM;
@@ -797,7 +797,7 @@ static int gigaset_probe(struct usb_interface *interface,
                         gigaset_read_int_callback,
                         cs->inbuf + 0, endpoint->bInterval);
 
-       retval = usb_submit_urb(ucs->read_urb, SLAB_KERNEL);
+       retval = usb_submit_urb(ucs->read_urb, GFP_KERNEL);
        if (retval) {
                dev_err(cs->dev, "Could not submit URB (error %d)\n", -retval);
                goto error;
index fd5d7364a48725374cf599b4fa94aecfde53d1c6..eba10466ccc61fd58eddd1b230629c7d84058781 100644 (file)
@@ -121,10 +121,9 @@ static int avmcs_probe(struct pcmcia_device *p_dev)
     p_dev->conf.Present = PRESENT_OPTION;
 
     /* Allocate space for private device-specific data */
-    local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
+    local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
     if (!local)
         goto err;
-    memset(local, 0, sizeof(local_info_t));
     p_dev->priv = local;
 
     return avmcs_config(p_dev);
index da2729247713b2d2d2bbdc2683e3b06e41105d93..7a69a18d07e245f4a15cc10631262a37c568d67c 100644 (file)
@@ -65,18 +65,15 @@ avmcard *b1_alloc_card(int nr_controllers)
        avmctrl_info *cinfo;
        int i;
 
-       card = kmalloc(sizeof(*card), GFP_KERNEL);
+       card = kzalloc(sizeof(*card), GFP_KERNEL);
        if (!card)
                return NULL;
 
-       memset(card, 0, sizeof(*card));
-
-        cinfo = kmalloc(sizeof(*cinfo) * nr_controllers, GFP_KERNEL);
+       cinfo = kzalloc(sizeof(*cinfo) * nr_controllers, GFP_KERNEL);
        if (!cinfo) {
                kfree(card);
                return NULL;
        }
-       memset(cinfo, 0, sizeof(*cinfo) * nr_controllers);
 
        card->ctrlinfo = cinfo;
        for (i = 0; i < nr_controllers; i++) {
@@ -718,12 +715,11 @@ avmcard_dma_alloc(char *name, struct pci_dev *pdev, long rsize, long ssize)
        avmcard_dmainfo *p;
        void *buf;
 
-       p = kmalloc(sizeof(avmcard_dmainfo), GFP_KERNEL);
+       p = kzalloc(sizeof(avmcard_dmainfo), GFP_KERNEL);
        if (!p) {
                printk(KERN_WARNING "%s: no memory.\n", name);
                goto err;
        }
-       memset(p, 0, sizeof(avmcard_dmainfo));
 
        p->recvbuf.size = rsize;
        buf = pci_alloc_consistent(pdev, rsize, &p->recvbuf.dmaaddr);
index e47c60b0a8ec6b9d80fe16cbfba08a1052e9a582..c925020fe9b7874732383d8605994d30096f3c10 100644 (file)
@@ -584,6 +584,7 @@ static void __exit t1isa_exit(void)
 {
        int i;
 
+       unregister_capi_driver(&capi_driver_t1isa);
        for (i = 0; i < MAX_CARDS; i++) {
                if (!io[i])
                        break;
index 6851c6270ce87870132af4c8b46f277c6eae0a6f..d835e74ecf186e9ac424e77da54e554c94dc7218 100644 (file)
@@ -756,14 +756,14 @@ int diva_get_driver_info (dword id, byte* data, int data_length) {
 
     data_length -= 9;
 
-    if ((to_copy = MIN(strlen(clients[id].drvName), data_length-1))) {
+    if ((to_copy = min(strlen(clients[id].drvName), (size_t)(data_length-1)))) {
       memcpy (p, clients[id].drvName, to_copy);
       p += to_copy;
       data_length -= to_copy;
       if ((data_length >= 4) && clients[id].hDbg->drvTag[0]) {
         *p++ = '(';
         data_length -= 1;
-        if ((to_copy = MIN(strlen(clients[id].hDbg->drvTag), data_length-2))) {
+        if ((to_copy = min(strlen(clients[id].hDbg->drvTag), (size_t)(data_length-2)))) {
           memcpy (p, clients[id].hDbg->drvTag, to_copy);
           p += to_copy;
           data_length -= to_copy;
index 0617d7cabf063b103e4ddea78b9a9e504a2fa4dc..e1df8d98c311cfb32ba39df84f108edca35898c6 100644 (file)
@@ -133,7 +133,7 @@ void pr_out(ADAPTER * a)
     i = this->XCurrent;
     X = PTR_X(a,this);
     while(i<this->XNum && length<270) {
-      clength = MIN((word)(270-length),X[i].PLength-this->XOffset);
+      clength = min((word)(270-length),(word)(X[i].PLength-this->XOffset));
       a->ram_out_buffer(a,
                         &ReqOut->XBuffer.P[length],
                         PTR_P(a,this,&X[i].P[this->XOffset]),
@@ -622,7 +622,7 @@ byte isdn_ind(ADAPTER * a,
                                                      sizeof(a->stream_buffer),
                                                      &final, NULL, NULL);
         }
-        IoAdapter->RBuffer.length = MIN(MLength, 270);
+        IoAdapter->RBuffer.length = min(MLength, (word)270);
         if (IoAdapter->RBuffer.length != MLength) {
           this->complete = 0;
         } else {
@@ -676,9 +676,9 @@ byte isdn_ind(ADAPTER * a,
         this->RCurrent++;
       }
       if (cma) {
-        clength = MIN(MLength, R[this->RCurrent].PLength-this->ROffset);
+        clength = min(MLength, (word)(R[this->RCurrent].PLength-this->ROffset));
       } else {
-        clength = MIN(a->ram_inw(a, &RBuffer->length)-offset,
+        clength = min(a->ram_inw(a, &RBuffer->length)-offset,
                       R[this->RCurrent].PLength-this->ROffset);
       }
       if(R[this->RCurrent].P) {
index dae2e83dd5e86604a819c39f2b897467f5396f2f..91fc92c01afe84930dc5bd5838a9db52ebb1c6d5 100644 (file)
@@ -185,7 +185,7 @@ void diva_log_info(unsigned char *format, ...)
        unsigned char line[160];
 
        va_start(args, format);
-       vsprintf(line, format, args);
+       vsnprintf(line, sizeof(line), format, args);
        va_end(args);
 
        printk(KERN_INFO "%s: %s\n", DRIVERLNAME, line);
index 4a27e230b0a5c581ba9903426d5adfd0256740a0..6fd9b007417dfd640eeabbe2e39f77e141feb35e 100644 (file)
@@ -262,7 +262,7 @@ void request(PISDN_ADAPTER IoAdapter, ENTITY * e)
     case IDI_SYNC_REQ_XDI_GET_CAPI_PARAMS: {
        diva_xdi_get_capi_parameters_t prms, *pI = &syncReq->xdi_capi_prms.info;
        memset (&prms, 0x00, sizeof(prms));
-       prms.structure_length = MIN(sizeof(prms), pI->structure_length);
+       prms.structure_length = min_t(size_t, sizeof(prms), pI->structure_length);
        memset (pI, 0x00, pI->structure_length);
        prms.flag_dynamic_l1_down    = (IoAdapter->capi_cfg.cfg_1 & \
          DIVA_XDI_CAPI_CFG_1_DYNAMIC_L1_ON) ? 1 : 0;
index 23139668d9b1d7faa103f8fae3c6385fc3cf67f0..18f8798442fa53ac8a7d91d2684a81e678970642 100644 (file)
@@ -92,7 +92,7 @@ int diva_istream_write (void* context,
     return (-1); /* was not able to write       */
    break;     /* only part of message was written */
   }
-  to_write = MIN(length, DIVA_DFIFO_DATA_SZ);
+  to_write = min(length, DIVA_DFIFO_DATA_SZ);
   if (to_write) {
    a->ram_out_buffer (a,
 #ifdef PLATFORM_GT_32BIT
@@ -176,7 +176,7 @@ int diva_istream_read (void* context,
     return (-1); /* was not able to read */
    break;
   }
-  to_read = MIN(max_length, tmp[1]);
+  to_read = min(max_length, (int)tmp[1]);
   if (to_read) {
    a->ram_in_buffer(a,
 #ifdef PLATFORM_GT_32BIT
index a66836cf756cfcf33df528579795d22ce0dd8bc6..2444811e0b3806058c0f3ac57e6cfc898db118e5 100644 (file)
 #define        NULL    ((void *) 0)
 #endif
 
-#ifndef        MIN
-#define MIN(a,b)       ((a)>(b) ? (b) : (a))
-#endif
-
-#ifndef        MAX
-#define MAX(a,b)       ((a)>(b) ? (a) : (b))
-#endif
-
 #ifndef        far
 #define far
 #endif
index cfd2718a490d35ed710f595976d6ba72eea1b97b..6fa12cc8e4ff858af4904f304a5ca4c1b56068ba 100644 (file)
@@ -349,13 +349,6 @@ config HISAX_ENTERNOW_PCI
          This enables HiSax support for the Formula-n enter:now PCI
          ISDN card.
 
-config HISAX_AMD7930
-       bool "Am7930 (EXPERIMENTAL)"
-       depends on EXPERIMENTAL && SPARC && BROKEN
-       help
-         This enables HiSax support for the AMD7930 chips on some SPARCs.
-         This code is not finished yet.
-
 endif
 
 if ISDN_DRV_HISAX
@@ -402,6 +395,7 @@ config HISAX_ST5481
        tristate "ST5481 USB ISDN modem (EXPERIMENTAL)"
        depends on USB && EXPERIMENTAL
        select CRC_CCITT
+       select BITREVERSE
        help
          This enables the driver for ST5481 based USB ISDN adapters,
          e.g. the BeWan Gazel 128 USB
index 876fec6c6be82528fae97f9b95ca320fa6543318..9e70c206779e4619a0af7c811a354d526480eb91 100644 (file)
@@ -123,11 +123,10 @@ static int avma1cs_probe(struct pcmcia_device *p_dev)
     DEBUG(0, "avma1cs_attach()\n");
 
     /* Allocate space for private device-specific data */
-    local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
+    local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
     if (!local)
        return -ENOMEM;
 
-    memset(local, 0, sizeof(local_info_t));
     p_dev->priv = local;
 
     /* The io structure describes IO port mapping */
index cede72cdbb319ab2eb51f322a15a54e0a95a24b9..17ec0b70ba1d0a9a598770e63284202f797a30b0 100644 (file)
@@ -227,14 +227,6 @@ const char *CardType[] = {
 #define DEFAULT_CFG {5,0x2E0,0,0}
 #endif
 
-
-#ifdef CONFIG_HISAX_AMD7930
-#undef DEFAULT_CARD
-#undef DEFAULT_CFG
-#define DEFAULT_CARD ISDN_CTYPE_AMD7930
-#define DEFAULT_CFG {12,0x3e0,0,0}
-#endif
-
 #ifdef CONFIG_HISAX_NICCY
 #undef DEFAULT_CARD
 #undef DEFAULT_CFG
@@ -545,10 +537,6 @@ extern int setup_hfcpci(struct IsdnCard *card);
 extern int setup_hfcsx(struct IsdnCard *card);
 #endif
 
-#if CARD_AMD7930
-extern int setup_amd7930(struct IsdnCard *card);
-#endif
-
 #if CARD_NICCY
 extern int setup_niccy(struct IsdnCard *card);
 #endif
@@ -869,14 +857,13 @@ static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockow
        struct IsdnCard *card = cards + cardnr;
        struct IsdnCardState *cs;
 
-       cs = kmalloc(sizeof(struct IsdnCardState), GFP_ATOMIC);
+       cs = kzalloc(sizeof(struct IsdnCardState), GFP_ATOMIC);
        if (!cs) {
                printk(KERN_WARNING
                       "HiSax: No memory for IsdnCardState(card %d)\n",
                       cardnr + 1);
                goto out;
        }
-       memset(cs, 0, sizeof(struct IsdnCardState));
        card->cs = cs;
        spin_lock_init(&cs->statlock);
        spin_lock_init(&cs->lock);
@@ -1064,11 +1051,6 @@ static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockow
                ret = setup_niccy(card);
                break;
 #endif
-#if CARD_AMD7930
-       case ISDN_CTYPE_AMD7930:
-               ret = setup_amd7930(card);
-               break;
-#endif
 #if CARD_ISURF
        case ISDN_CTYPE_ISURF:
                ret = setup_isurf(card);
@@ -1437,7 +1419,6 @@ static int __init HiSax_init(void)
                        break;
                case ISDN_CTYPE_ELSA_PCI:
                case ISDN_CTYPE_NETJET_S:
-               case ISDN_CTYPE_AMD7930:
                case ISDN_CTYPE_TELESPCI:
                case ISDN_CTYPE_W6692:
                case ISDN_CTYPE_NETJET_U:
index 3dacfff93f5fb6c51ff0c873278f800bfed9c8e6..6eebeb441bfd1ec7482a9b42bbdfd198c65acf86 100644 (file)
@@ -1121,7 +1121,11 @@ setup_diva(struct IsdnCard *card)
                        bytecnt = 32;
                }
        }
+
+#ifdef __ISAPNP__
 ready:
+#endif
+
        printk(KERN_INFO
                "Diva: %s card configured at %#lx IRQ %d\n",
                (cs->subtyp == DIVA_PCI) ? "PCI" :
index 4e180d210faa31ca0101c39e6304a1ef6ffc5874..79ab9dda7d08984650dd6c980ed2d1ec12acdb08 100644 (file)
@@ -146,9 +146,8 @@ static int elsa_cs_probe(struct pcmcia_device *link)
     DEBUG(0, "elsa_cs_attach()\n");
 
     /* Allocate space for private device-specific data */
-    local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
+    local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
     if (!local) return -ENOMEM;
-    memset(local, 0, sizeof(local_info_t));
 
     local->p_dev = link;
     link->priv = local;
index 0d44a3f480ac6327808b866aef7597f254b8234d..34fade96a581248834c27c6aa9ebf4f0c11ff840 100644 (file)
@@ -26,12 +26,10 @@ FsmNew(struct Fsm *fsm, struct FsmNode *fnlist, int fncount)
        int i;
 
        fsm->jumpmatrix = (FSMFNPTR *)
-               kmalloc(sizeof (FSMFNPTR) * fsm->state_count * fsm->event_count, GFP_KERNEL);
+               kzalloc(sizeof (FSMFNPTR) * fsm->state_count * fsm->event_count, GFP_KERNEL);
        if (!fsm->jumpmatrix)
                return -ENOMEM;
 
-       memset(fsm->jumpmatrix, 0, sizeof (FSMFNPTR) * fsm->state_count * fsm->event_count);
-
        for (i = 0; i < fncount; i++) 
                if ((fnlist[i].state>=fsm->state_count) || (fnlist[i].event>=fsm->event_count)) {
                        printk(KERN_ERR "FsmNew Error line %d st(%ld/%ld) ev(%ld/%ld)\n",
index de9b1a4d6bac56bfb98d9892aee31bd24d11d8cd..a2fa4ecb8c883e20fad1f389c3e862022f000a66 100644 (file)
@@ -1591,11 +1591,10 @@ hfc4s8s_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        hfc4s8s_param *driver_data = (hfc4s8s_param *) ent->driver_data;
        hfc4s8s_hw *hw;
 
-       if (!(hw = kmalloc(sizeof(hfc4s8s_hw), GFP_ATOMIC))) {
+       if (!(hw = kzalloc(sizeof(hfc4s8s_hw), GFP_ATOMIC))) {
                printk(KERN_ERR "No kmem for HFC-4S/8S card\n");
                return (err);
        }
-       memset(hw, 0, sizeof(hfc4s8s_hw));
 
        hw->pdev = pdev;
        err = pci_enable_device(pdev);
index 5db0a85b827fb8009b5324b91ffeace21c035dfb..8a48a3ce0a55a39204945b2acedb15463bae607a 100644 (file)
@@ -1211,7 +1211,7 @@ HFCPCI_l1hw(struct PStack *st, int pr, void *arg)
                        break;
                case (HW_TESTLOOP | REQUEST):
                        spin_lock_irqsave(&cs->lock, flags);
-                       switch ((int) arg) {
+                       switch ((long) arg) {
                                case (1):
                                        Write_hfc(cs, HFCPCI_B1_SSL, 0x80);     /* tx slot */
                                        Write_hfc(cs, HFCPCI_B1_RSL, 0x80);     /* rx slot */
@@ -1229,7 +1229,7 @@ HFCPCI_l1hw(struct PStack *st, int pr, void *arg)
                                default:
                                        spin_unlock_irqrestore(&cs->lock, flags);
                                        if (cs->debug & L1_DEB_WARN)
-                                               debugl1(cs, "hfcpci_l1hw loop invalid %4x", (int) arg);
+                                               debugl1(cs, "hfcpci_l1hw loop invalid %4lx", (long) arg);
                                        return;
                        }
                        cs->hw.hfcpci.trm |= 0x80;      /* enable IOM-loop */
@@ -1711,9 +1711,9 @@ setup_hfcpci(struct IsdnCard *card)
                pci_write_config_dword(cs->hw.hfcpci.dev, 0x80, (u_int) virt_to_bus(cs->hw.hfcpci.fifos));
                cs->hw.hfcpci.pci_io = ioremap((ulong) cs->hw.hfcpci.pci_io, 256);
                printk(KERN_INFO
-                      "HFC-PCI: defined at mem %#x fifo %#x(%#x) IRQ %d HZ %d\n",
-                      (u_int) cs->hw.hfcpci.pci_io,
-                      (u_int) cs->hw.hfcpci.fifos,
+                      "HFC-PCI: defined at mem %p fifo %p(%#x) IRQ %d HZ %d\n",
+                      cs->hw.hfcpci.pci_io,
+                      cs->hw.hfcpci.fifos,
                       (u_int) virt_to_bus(cs->hw.hfcpci.fifos),
                       cs->irq, HZ);
                spin_lock_irqsave(&cs->lock, flags);
index 7105b043add8b66f9e02d5cd0e2808381a331955..5a6989f23fcf6daa289f6a8ef9e834f6e8262620 100644 (file)
@@ -1481,9 +1481,8 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
                        iface = iface_used;
                        if (!
                            (context =
-                            kmalloc(sizeof(hfcusb_data), GFP_KERNEL)))
+                            kzalloc(sizeof(hfcusb_data), GFP_KERNEL)))
                                return (-ENOMEM);       /* got no mem */
-                       memset(context, 0, sizeof(hfcusb_data));
 
                        ep = iface->endpoint;
                        vcf = validconf[small_match];
index 159c5896061eb6b4ea456e0b12ea344460d26fea..3f1137e34678f60cfe1a8d7f3102c1de349d9cac 100644 (file)
@@ -1139,12 +1139,6 @@ struct IsdnCardState {
 #define  CARD_HFC_SX 0
 #endif
 
-#ifdef  CONFIG_HISAX_AMD7930
-#define CARD_AMD7930 1
-#else
-#define CARD_AMD7930 0
-#endif
-
 #ifdef CONFIG_HISAX_NICCY
 #define        CARD_NICCY 1
 #ifndef ISDN_CHIP_ISAC
index f6db55a752c4e6deb2395be3259d1400234bc70a..9e088fce8c3afb8d032a30e715ff08d6fec89066 100644 (file)
@@ -841,12 +841,10 @@ new_adapter(void)
        struct hisax_b_if *b_if[2];
        int i;
 
-       adapter = kmalloc(sizeof(struct fritz_adapter), GFP_KERNEL);
+       adapter = kzalloc(sizeof(struct fritz_adapter), GFP_KERNEL);
        if (!adapter)
                return NULL;
 
-       memset(adapter, 0, sizeof(struct fritz_adapter));
-
        adapter->isac.hisax_d_if.owner = THIS_MODULE;
        adapter->isac.hisax_d_if.ifc.priv = &adapter->isac;
        adapter->isac.hisax_d_if.ifc.l2l1 = isac_d_l2l1;
index 81eac344bb0325fcf615a5808e52fb87401eb640..d0fefcf999cb7226b89e81c50021cfc1be263ee9 100644 (file)
@@ -433,7 +433,7 @@ static void l1m_debug(struct FsmInst *fi, char *fmt, ...)
        char buf[256];
        
        va_start(args, fmt);
-       vsprintf(buf, fmt, args);
+       vsnprintf(buf, sizeof(buf), fmt, args);
        DBG(DBG_L1M, "%s", buf);
        va_end(args);
 }
index cbdf54c5af84521f7925565513452e5caed81523..268dced6c34a9e33c24bf508ce2b083c9414f6c1 100644 (file)
@@ -35,30 +35,6 @@ MODULE_LICENSE("GPL");
 
 /*-------------------------------------------------------------------*/
 
-/* bit swap table.
- * Very handy for devices with different bit order,
- * and neccessary for each transparent B-channel access for all
- * devices which works with this HDLC decoder without bit reversal.
- */
-const unsigned char isdnhdlc_bit_rev_tab[256] = {
-       0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0,
-       0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,
-       0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4,
-       0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC,
-       0x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2,
-       0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA,
-       0x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6,
-       0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE,
-       0x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1,
-       0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9,
-       0x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5,
-       0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD,
-       0x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3,
-       0x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB,
-       0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7,
-       0x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF
-};
-
 enum {
        HDLC_FAST_IDLE,HDLC_GET_FLAG_B0,HDLC_GETFLAG_B1A6,HDLC_GETFLAG_B7,
        HDLC_GET_DATA,HDLC_FAST_FLAG
@@ -621,7 +597,6 @@ int isdnhdlc_encode(struct isdnhdlc_vars *hdlc, const unsigned char *src,
        return len;
 }
 
-EXPORT_SYMBOL(isdnhdlc_bit_rev_tab);
 EXPORT_SYMBOL(isdnhdlc_rcv_init);
 EXPORT_SYMBOL(isdnhdlc_decode);
 EXPORT_SYMBOL(isdnhdlc_out_init);
index 269315988dc8eb3d177700b98f83dd4e9daeb44f..45167d2f8fb0a303aacdcf9ada1eb36352ca168a 100644 (file)
@@ -41,10 +41,10 @@ struct isdnhdlc_vars {
        unsigned char shift_reg;
        unsigned char ffvalue;
 
-       int data_received:1;    // set if transferring data
-       int dchannel:1;         // set if D channel (send idle instead of flags)
-       int do_adapt56:1;       // set if 56K adaptation
-        int do_closing:1;      // set if in closing phase (need to send CRC + flag
+       unsigned int data_received:1;   // set if transferring data
+       unsigned int dchannel:1;        // set if D channel (send idle instead of flags)
+       unsigned int do_adapt56:1;      // set if 56K adaptation
+       unsigned int do_closing:1;      // set if in closing phase (need to send CRC + flag
 };
 
 
@@ -57,8 +57,6 @@ struct isdnhdlc_vars {
 #define HDLC_CRC_ERROR         2
 #define HDLC_LENGTH_ERROR      3
 
-extern const unsigned char isdnhdlc_bit_rev_tab[256];
-
 extern void isdnhdlc_rcv_init (struct isdnhdlc_vars *hdlc, int do_adapt56);
 
 extern int isdnhdlc_decode (struct isdnhdlc_vars *hdlc, const unsigned char *src, int slen,int *count,
index 9522141f435147bee8dc6d449fecac5b273a8ba0..030d1625c5c6d78c88cc2db80974c86ffd6c5ed9 100644 (file)
@@ -677,7 +677,11 @@ setup_sedlbauer(struct IsdnCard *card)
                return (0);
 #endif /* CONFIG_PCI */
        }       
+
+#ifdef __ISAPNP__
 ready: 
+#endif
+
        /* In case of the sedlbauer pcmcia card, this region is in use,
         * reserved for us by the card manager. So we do not check it
         * here, it would fail.
index 46ed65334c51d8465bffdb2829b34024ed55e151..45debde05fbd111ab2db7cad15e5fefd63cde6d7 100644 (file)
@@ -155,9 +155,8 @@ static int sedlbauer_probe(struct pcmcia_device *link)
     DEBUG(0, "sedlbauer_attach()\n");
 
     /* Allocate space for private device-specific data */
-    local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
+    local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
     if (!local) return -ENOMEM;
-    memset(local, 0, sizeof(local_info_t));
     local->cardnr = -1;
 
     local->p_dev = link;
index 75d0f248e4eeb231ada591529771904c3565cf43..fa64115cd7c7570267a2adec29c19392d9dcf448 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/usb.h>
 #include <linux/slab.h>
 #include <linux/netdevice.h>
+#include <linux/bitrev.h>
 #include "st5481.h"
 
 static inline void B_L1L2(struct st5481_bcs *bcs, int pr, void *arg)
@@ -72,7 +73,7 @@ static void usb_b_out(struct st5481_bcs *bcs,int buf_nr)
                                        register unsigned char *dest = urb->transfer_buffer+len;
                                        register unsigned int count;
                                        for (count = 0; count < bytes_sent; count++)
-                                               *dest++ = isdnhdlc_bit_rev_tab[*src++];
+                                               *dest++ = bitrev8(*src++);
                                }
                                len += bytes_sent;
                        } else {
index 1d8c2618366c385c4ea285765922aae12603a09c..b8c4855cc8894c700169184e3b04ae5500dcf86c 100644 (file)
@@ -173,7 +173,7 @@ static void l1m_debug(struct FsmInst *fi, char *fmt, ...)
        char buf[256];
        
        va_start(args, fmt);
-       vsprintf(buf, fmt, args);
+       vsnprintf(buf, sizeof(buf), fmt, args);
        DBG(8, "%s", buf);
        va_end(args);
 }
@@ -275,7 +275,7 @@ static void dout_debug(struct FsmInst *fi, char *fmt, ...)
        char buf[256];
        
        va_start(args, fmt);
-       vsprintf(buf, fmt, args);
+       vsnprintf(buf, sizeof(buf), fmt, args);
        DBG(0x2, "%s", buf);
        va_end(args);
 }
index 2716aa5c60f7008b1c2df0742af1f722e35a2655..bb3a28a53ff4de2536b06095a54f2516832cef25 100644 (file)
@@ -69,12 +69,10 @@ static int probe_st5481(struct usb_interface *intf,
             le16_to_cpu(dev->descriptor.idProduct),
             number_of_leds);
 
-       adapter = kmalloc(sizeof(struct st5481_adapter), GFP_KERNEL);
+       adapter = kzalloc(sizeof(struct st5481_adapter), GFP_KERNEL);
        if (!adapter)
                return -ENOMEM;
 
-       memset(adapter, 0, sizeof(struct st5481_adapter));
-
        adapter->number_of_leds = number_of_leds;
        adapter->usb_dev = dev;
 
index 6b754f183796318a6d7fb88bb18388f3169aff9b..3e3e18239ec77fa0bbb30e96ae744d6451d1bc2c 100644 (file)
@@ -137,9 +137,8 @@ static int teles_probe(struct pcmcia_device *link)
     DEBUG(0, "teles_attach()\n");
 
     /* Allocate space for private device-specific data */
-    local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
+    local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
     if (!local) return -ENOMEM;
-    memset(local, 0, sizeof(local_info_t));
     local->cardnr = -1;
 
     local->p_dev = link;
index 6bac43cc91bdb2b9284c6613c9a35a3cf96acb63..b2ae4ec1e49e1c1566b4bd5b723608d81c3a361a 100644 (file)
@@ -745,12 +745,11 @@ hycapi_capi_create(hysdn_card *card)
                return 1;
        }
        if (!card->hyctrlinfo) {
-               cinfo = (hycapictrl_info *) kmalloc(sizeof(hycapictrl_info), GFP_ATOMIC);
+               cinfo = kzalloc(sizeof(hycapictrl_info), GFP_ATOMIC);
                if (!cinfo) {
                        printk(KERN_WARNING "HYSDN: no memory for capi-ctrl.\n");
                        return -ENOMEM;
                }
-               memset(cinfo, 0, sizeof(hycapictrl_info));
                card->hyctrlinfo = cinfo;
                cinfo->card = card;
                spin_lock_init(&cinfo->lock);
index 6d0eb0f42fcacce1048231e25dee4ba59a763ca6..be787e16bb79b99b7e501aca2e395b09e235fa86 100644 (file)
@@ -278,14 +278,13 @@ pof_write_open(hysdn_card * card, unsigned char **bufp)
                return (-ERR_ALREADY_BOOT);     /* boot already active */
        }
        /* error no mem available */
-       if (!(boot = kmalloc(sizeof(struct boot_data), GFP_KERNEL))) {
+       if (!(boot = kzalloc(sizeof(struct boot_data), GFP_KERNEL))) {
                if (card->debug_flags & LOG_MEM_ERR)
                        hysdn_addlog(card, "POF open: unable to allocate mem");
                return (-EFAULT);
        }
        card->boot = boot;
        card->state = CARD_STATE_BOOTING;
-       memset(boot, 0, sizeof(struct boot_data));
 
        card->stopcard(card);   /* first stop the card */
        if (card->testram(card)) {
index b702ed27252bd2ab0054d5c4431fdb9d31ca98db..9e01748a176e95c2726c2842ff102bca5fd3c4eb 100644 (file)
@@ -81,11 +81,10 @@ search_cards(void)
                if (pci_enable_device(akt_pcidev))
                        continue;
 
-               if (!(card = kmalloc(sizeof(hysdn_card), GFP_KERNEL))) {
+               if (!(card = kzalloc(sizeof(hysdn_card), GFP_KERNEL))) {
                        printk(KERN_ERR "HYSDN: unable to alloc device mem \n");
                        return;
                }
-               memset(card, 0, sizeof(hysdn_card));
                card->myid = cardmax;   /* set own id */
                card->bus = akt_pcidev->bus->number;
                card->devfn = akt_pcidev->devfn;        /* slot + function */
index d205249a1242bb5d30fce1416bda6df69c2c3613..557d96c78a623d03d4e78e80c81a86280ee2f2ce 100644 (file)
@@ -278,11 +278,10 @@ hysdn_net_create(hysdn_card * card)
                return (-ENOMEM);
        }
        hysdn_net_release(card);        /* release an existing net device */
-       if ((dev = kmalloc(sizeof(struct net_local), GFP_KERNEL)) == NULL) {
+       if ((dev = kzalloc(sizeof(struct net_local), GFP_KERNEL)) == NULL) {
                printk(KERN_WARNING "HYSDN: unable to allocate mem\n");
                return (-ENOMEM);
        }
-       memset(dev, 0, sizeof(struct net_local));       /* clean the structure */
 
        spin_lock_init(&((struct net_local *) dev)->lock);
 
index fcd49920b2203ab9d33359a204e1c35f082337bd..f241f5e551cbf9a803d70fea08beac008b7b99d9 100644 (file)
@@ -204,7 +204,7 @@ hysdn_log_read(struct file *file, char __user *buf, size_t count, loff_t * off)
 {
        struct log_data *inf;
        int len;
-       struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
        struct procdata *pd = NULL;
        hysdn_card *card;
 
@@ -354,7 +354,7 @@ static unsigned int
 hysdn_log_poll(struct file *file, poll_table * wait)
 {
        unsigned int mask = 0;
-       struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
        hysdn_card *card;
        struct procdata *pd = NULL;
 
@@ -405,8 +405,7 @@ hysdn_proclog_init(hysdn_card * card)
 
        /* create a cardlog proc entry */
 
-       if ((pd = (struct procdata *) kmalloc(sizeof(struct procdata), GFP_KERNEL)) != NULL) {
-               memset(pd, 0, sizeof(struct procdata));
+       if ((pd = kzalloc(sizeof(struct procdata), GFP_KERNEL)) != NULL) {
                sprintf(pd->log_name, "%s%d", PROC_LOG_BASENAME, card->myid);
                if ((pd->log = create_proc_entry(pd->log_name, S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry)) != NULL) {
                        pd->log->proc_fops = &log_fops; 
index 0afe442db3b0011568fc96f5f5c2d2baae591342..a20f33b4a220f4399dd635dd3af6344f62bb8304 100644 (file)
@@ -331,12 +331,10 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data)
         * Allocate the main control structure for this instance.
         */
        maxmaxcode = MAXCODE(bits);
-       db = (struct bsd_db *) kmalloc (sizeof (struct bsd_db),GFP_KERNEL);
+       db = kzalloc (sizeof (struct bsd_db),GFP_KERNEL);
        if (!db)
                return NULL;
 
-       memset (db, 0, sizeof(struct bsd_db));
-
        db->xmit = data->flags & IPPP_COMP_FLAG_XMIT;
        decomp = db->xmit ? 0 : 1;
 
index 69aee2602aa62aac22a3c6e41442a4d1810a7ee5..6a2ef0a87ed9a5143ba61a396cd35bdfd4908f68 100644 (file)
@@ -1059,7 +1059,7 @@ isdn_info_update(void)
 static ssize_t
 isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off)
 {
-       uint minor = iminor(file->f_dentry->d_inode);
+       uint minor = iminor(file->f_path.dentry->d_inode);
        int len = 0;
        int drvidx;
        int chidx;
@@ -1166,7 +1166,7 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off)
 static ssize_t
 isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off)
 {
-       uint minor = iminor(file->f_dentry->d_inode);
+       uint minor = iminor(file->f_path.dentry->d_inode);
        int drvidx;
        int chidx;
        int retval;
@@ -1228,7 +1228,7 @@ static unsigned int
 isdn_poll(struct file *file, poll_table * wait)
 {
        unsigned int mask = 0;
-       unsigned int minor = iminor(file->f_dentry->d_inode);
+       unsigned int minor = iminor(file->f_path.dentry->d_inode);
        int drvidx = isdn_minor2drv(minor - ISDN_MINOR_CTRL);
 
        lock_kernel();
@@ -2072,21 +2072,19 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding)
 
        if ((adding) && (d->rcverr))
                kfree(d->rcverr);
-       if (!(d->rcverr = kmalloc(sizeof(int) * m, GFP_ATOMIC))) {
+       if (!(d->rcverr = kzalloc(sizeof(int) * m, GFP_ATOMIC))) {
                printk(KERN_WARNING "register_isdn: Could not alloc rcverr\n");
                return -1;
        }
-       memset((char *) d->rcverr, 0, sizeof(int) * m);
 
        if ((adding) && (d->rcvcount))
                kfree(d->rcvcount);
-       if (!(d->rcvcount = kmalloc(sizeof(int) * m, GFP_ATOMIC))) {
+       if (!(d->rcvcount = kzalloc(sizeof(int) * m, GFP_ATOMIC))) {
                printk(KERN_WARNING "register_isdn: Could not alloc rcvcount\n");
                if (!adding)
                        kfree(d->rcverr);
                return -1;
        }
-       memset((char *) d->rcvcount, 0, sizeof(int) * m);
 
        if ((adding) && (d->rpqueue)) {
                for (j = 0; j < d->channels; j++)
@@ -2226,11 +2224,10 @@ register_isdn(isdn_if * i)
                printk(KERN_WARNING "register_isdn: No write routine given.\n");
                return 0;
        }
-       if (!(d = kmalloc(sizeof(isdn_driver_t), GFP_KERNEL))) {
+       if (!(d = kzalloc(sizeof(isdn_driver_t), GFP_KERNEL))) {
                printk(KERN_WARNING "register_isdn: Could not alloc driver-struct\n");
                return 0;
        }
-       memset((char *) d, 0, sizeof(isdn_driver_t));
 
        d->maxbufsize = i->maxbufsize;
        d->pktcount = 0;
index 2e4daebfb7e0ab0df1a944d50da6b4418f589dea..c36c817578cbe65608b745da7b48c1338c6814f5 100644 (file)
@@ -2542,17 +2542,15 @@ isdn_net_new(char *name, struct net_device *master)
                printk(KERN_WARNING "isdn_net: interface %s already exists\n", name);
                return NULL;
        }
-       if (!(netdev = (isdn_net_dev *) kmalloc(sizeof(isdn_net_dev), GFP_KERNEL))) {
+       if (!(netdev = kzalloc(sizeof(isdn_net_dev), GFP_KERNEL))) {
                printk(KERN_WARNING "isdn_net: Could not allocate net-device\n");
                return NULL;
        }
-       memset(netdev, 0, sizeof(isdn_net_dev));
-       if (!(netdev->local = (isdn_net_local *) kmalloc(sizeof(isdn_net_local), GFP_KERNEL))) {
+       if (!(netdev->local = kzalloc(sizeof(isdn_net_local), GFP_KERNEL))) {
                printk(KERN_WARNING "isdn_net: Could not allocate device locals\n");
                kfree(netdev);
                return NULL;
        }
-       memset(netdev->local, 0, sizeof(isdn_net_local));
        if (name == NULL)
                strcpy(netdev->local->name, "         ");
        else
index 119412d6bd15d05d253504bada35acbde7b3fc54..43811795b46bfb31bdd947e7998e73a487588234 100644 (file)
@@ -667,7 +667,7 @@ isdn_ppp_poll(struct file *file, poll_table * wait)
 
        if (is->debug & 0x2)
                printk(KERN_DEBUG "isdn_ppp_poll: minor: %d\n",
-                               iminor(file->f_dentry->d_inode));
+                               iminor(file->f_path.dentry->d_inode));
 
        /* just registers wait_queue hook. This doesn't really wait. */
        poll_wait(file, &is->wq, wait);
@@ -876,14 +876,12 @@ isdn_ppp_init(void)
 #endif /* CONFIG_ISDN_MPP */
 
        for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
-               if (!(ippp_table[i] = (struct ippp_struct *)
-                     kmalloc(sizeof(struct ippp_struct), GFP_KERNEL))) {
+               if (!(ippp_table[i] = kzalloc(sizeof(struct ippp_struct), GFP_KERNEL))) {
                        printk(KERN_WARNING "isdn_ppp_init: Could not alloc ippp_table\n");
                        for (j = 0; j < i; j++)
                                kfree(ippp_table[j]);
                        return -1;
                }
-               memset((char *) ippp_table[i], 0, sizeof(struct ippp_struct));
                spin_lock_init(&ippp_table[i]->buflock);
                ippp_table[i]->state = 0;
                ippp_table[i]->first = ippp_table[i]->rq + NUM_RCV_BUFFS - 1;
@@ -1529,10 +1527,8 @@ static int isdn_ppp_mp_bundle_array_init(void)
 {
        int i;
        int sz = ISDN_MAX_CHANNELS*sizeof(ippp_bundle);
-       if( (isdn_ppp_bundle_arr = (ippp_bundle*)kmalloc(sz, 
-                                                       GFP_KERNEL)) == NULL )
+       if( (isdn_ppp_bundle_arr = kzalloc(sz, GFP_KERNEL)) == NULL )
                return -ENOMEM;
-       memset(isdn_ppp_bundle_arr, 0, sz);
        for( i = 0; i < ISDN_MAX_CHANNELS; i++ )
                spin_lock_init(&isdn_ppp_bundle_arr[i].lock);
        return 0;
@@ -2246,13 +2242,12 @@ static void isdn_ppp_ccp_xmit_reset(struct ippp_struct *is, int proto,
 static struct ippp_ccp_reset *isdn_ppp_ccp_reset_alloc(struct ippp_struct *is)
 {
        struct ippp_ccp_reset *r;
-       r = kmalloc(sizeof(struct ippp_ccp_reset), GFP_KERNEL);
+       r = kzalloc(sizeof(struct ippp_ccp_reset), GFP_KERNEL);
        if(!r) {
                printk(KERN_ERR "ippp_ccp: failed to allocate reset data"
                       " structure - no mem\n");
                return NULL;
        }
-       memset(r, 0, sizeof(struct ippp_ccp_reset));
        printk(KERN_DEBUG "ippp_ccp: allocated reset data structure %p\n", r);
        is->reset = r;
        return r;
@@ -2338,10 +2333,9 @@ static struct ippp_ccp_reset_state *isdn_ppp_ccp_reset_alloc_state(struct ippp_s
                       id);
                return NULL;
        } else {
-               rs = kmalloc(sizeof(struct ippp_ccp_reset_state), GFP_KERNEL);
+               rs = kzalloc(sizeof(struct ippp_ccp_reset_state), GFP_KERNEL);
                if(!rs)
                        return NULL;
-               memset(rs, 0, sizeof(struct ippp_ccp_reset_state));
                rs->state = CCPResetIdle;
                rs->is = is;
                rs->id = id;
@@ -2536,6 +2530,11 @@ static struct sk_buff *isdn_ppp_decompress(struct sk_buff *skb,struct ippp_struc
                rsparm.maxdlen = IPPP_RESET_MAXDATABYTES;
   
                skb_out = dev_alloc_skb(is->mru + PPP_HDRLEN);
+               if (!skb_out) {
+                       kfree_skb(skb);
+                       printk(KERN_ERR "ippp: decomp memory allocation failure\n");
+                       return NULL;
+               }
                len = ipc->decompress(stat, skb, skb_out, &rsparm);
                kfree_skb(skb);
                if (len <= 0) {
index 2b91bb07fc7f2ab087b80d501f772deca3f426ca..fc80afe555b9e9063229dca25739aa5b33afe29a 100644 (file)
@@ -1464,7 +1464,7 @@ isdn_tty_ioctl(struct tty_struct *tty, struct file *file,
 }
 
 static void
-isdn_tty_set_termios(struct tty_struct *tty, struct termios *old_termios)
+isdn_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
        modem_info *info = (modem_info *) tty->driver_data;
 
index 38619e8cd8230b4c9d893fbb85976a6a9055df2e..5484d3c38a5761b76ab888d146cab65719add51b 100644 (file)
@@ -92,9 +92,8 @@ isdn_v110_open(unsigned char key, int hdrlen, int maxsize)
        int i;
        isdn_v110_stream *v;
 
-       if ((v = kmalloc(sizeof(isdn_v110_stream), GFP_ATOMIC)) == NULL)
+       if ((v = kzalloc(sizeof(isdn_v110_stream), GFP_ATOMIC)) == NULL)
                return NULL;
-       memset(v, 0, sizeof(isdn_v110_stream));
        v->key = key;
        v->nbits = 0;
        for (i = 0; key & (1 << i); i++)
index 730bbd07ebc7ca2e842e5cde6080fdd466203027..1e699bcaba0fde6e03e5091a6061c5ce9882a15c 100644 (file)
@@ -1519,12 +1519,11 @@ icn_initcard(int port, char *id)
        icn_card *card;
        int i;
 
-       if (!(card = (icn_card *) kmalloc(sizeof(icn_card), GFP_KERNEL))) {
+       if (!(card = kzalloc(sizeof(icn_card), GFP_KERNEL))) {
                printk(KERN_WARNING
                       "icn: (%s) Could not allocate card-struct.\n", id);
                return (icn_card *) 0;
        }
-       memset((char *) card, 0, sizeof(icn_card));
        spin_lock_init(&card->lock);
        card->port = port;
        card->interface.owner = THIS_MODULE;
index c3ae2edaf6fa5812cf039ef00ef8e7b467aed901..e3add27dd0e1926c1f70cbb114e08ae06dc6e1d4 100644 (file)
@@ -1430,12 +1430,11 @@ isdnloop_initcard(char *id)
        isdnloop_card *card;
        int i;
 
-       if (!(card = (isdnloop_card *) kmalloc(sizeof(isdnloop_card), GFP_KERNEL))) {
+       if (!(card = kzalloc(sizeof(isdnloop_card), GFP_KERNEL))) {
                printk(KERN_WARNING
                 "isdnloop: (%s) Could not allocate card-struct.\n", id);
                return (isdnloop_card *) 0;
        }
-       memset((char *) card, 0, sizeof(isdnloop_card));
        card->interface.owner = THIS_MODULE;
        card->interface.channels = ISDNLOOP_BCH;
        card->interface.hl_hdrlen  = 1; /* scratch area for storing ack flag*/ 
index 1966f3410a13e600f91b6c776a50b5d1534b11e1..11c1b0b6e390c1e6f0fd919eb5f4a06706cd2c79 100644 (file)
@@ -73,14 +73,13 @@ int pcbit_init_dev(int board, int mem_base, int irq)
        struct pcbit_dev *dev;
        isdn_if *dev_if;
 
-       if ((dev=kmalloc(sizeof(struct pcbit_dev), GFP_KERNEL)) == NULL)
+       if ((dev=kzalloc(sizeof(struct pcbit_dev), GFP_KERNEL)) == NULL)
        {
                printk("pcbit_init: couldn't malloc pcbit_dev struct\n");
                return -ENOMEM;
        }
 
        dev_pcbit[board] = dev;
-       memset(dev, 0, sizeof(struct pcbit_dev));
        init_waitqueue_head(&dev->set_running_wq);
        spin_lock_init(&dev->lock);
 
@@ -104,7 +103,7 @@ int pcbit_init_dev(int board, int mem_base, int irq)
                return -EACCES;
        }
 
-       dev->b1 = kmalloc(sizeof(struct pcbit_chan), GFP_KERNEL);
+       dev->b1 = kzalloc(sizeof(struct pcbit_chan), GFP_KERNEL);
        if (!dev->b1) {
                printk("pcbit_init: couldn't malloc pcbit_chan struct\n");
                iounmap(dev->sh_mem);
@@ -113,7 +112,7 @@ int pcbit_init_dev(int board, int mem_base, int irq)
                return -ENOMEM;
        }
     
-       dev->b2 = kmalloc(sizeof(struct pcbit_chan), GFP_KERNEL);
+       dev->b2 = kzalloc(sizeof(struct pcbit_chan), GFP_KERNEL);
        if (!dev->b2) {
                printk("pcbit_init: couldn't malloc pcbit_chan struct\n");
                kfree(dev->b1);
@@ -123,8 +122,6 @@ int pcbit_init_dev(int board, int mem_base, int irq)
                return -ENOMEM;
        }
 
-       memset(dev->b1, 0, sizeof(struct pcbit_chan));
-       memset(dev->b2, 0, sizeof(struct pcbit_chan));
        dev->b2->id = 1;
 
        INIT_WORK(&dev->qdelivery, pcbit_deliver);
index 0c9f6df873fc55b63732922b40c3f7567faf8dc5..6ff85574e941ff5ee6b27549a43f45248cd6319f 100644 (file)
@@ -369,13 +369,12 @@ pcbit_receive(struct pcbit_dev *dev)
                        kfree(dev->read_frame);
                        dev->read_frame = NULL;
                }
-               frame = kmalloc(sizeof(struct frame_buf), GFP_ATOMIC);
+               frame = kzalloc(sizeof(struct frame_buf), GFP_ATOMIC);
 
                if (frame == NULL) {
                        printk(KERN_WARNING "kmalloc failed\n");
                        return;
                }
-               memset(frame, 0, sizeof(struct frame_buf));
 
                cpu = pcbit_readb(dev);
                proc = pcbit_readb(dev);
index 06c9872e8c6a5c5b503117d86fdd05dbd3286e65..150759a5cddf9a97f621ed495b1194399abce666 100644 (file)
@@ -271,14 +271,13 @@ static int __init sc_init(void)
                 * Horray! We found a board, Make sure we can register
                 * it with ISDN4Linux
                 */
-               interface = kmalloc(sizeof(isdn_if), GFP_KERNEL);
+               interface = kzalloc(sizeof(isdn_if), GFP_KERNEL);
                if (interface == NULL) {
                        /*
                         * Oops, can't malloc isdn_if
                         */
                        continue;
                }
-               memset(interface, 0, sizeof(isdn_if));
 
                interface->owner = THIS_MODULE;
                interface->hl_hdrlen = 0;
@@ -294,7 +293,7 @@ static int __init sc_init(void)
                /*
                 * Allocate the board structure
                 */
-               sc_adapter[cinst] = kmalloc(sizeof(board), GFP_KERNEL);
+               sc_adapter[cinst] = kzalloc(sizeof(board), GFP_KERNEL);
                if (sc_adapter[cinst] == NULL) {
                        /*
                         * Oops, can't alloc memory for the board
@@ -302,7 +301,6 @@ static int __init sc_init(void)
                        kfree(interface);
                        continue;
                }
-               memset(sc_adapter[cinst], 0, sizeof(board));
                spin_lock_init(&sc_adapter[cinst]->lock);
 
                if(!register_isdn(interface)) {
@@ -326,7 +324,7 @@ static int __init sc_init(void)
                /*
                 * Allocate channels status structures
                 */
-               sc_adapter[cinst]->channel = kmalloc(sizeof(bchan) * channels, GFP_KERNEL);
+               sc_adapter[cinst]->channel = kzalloc(sizeof(bchan) * channels, GFP_KERNEL);
                if (sc_adapter[cinst]->channel == NULL) {
                        /*
                         * Oops, can't alloc memory for the channels
@@ -336,7 +334,6 @@ static int __init sc_init(void)
                        kfree(sc_adapter[cinst]);
                        continue;
                }
-               memset(sc_adapter[cinst]->channel, 0, sizeof(bchan) * channels);
 
                /*
                 * Lock down the hardware resources
index 9c39b98d5a5b2a6f2689e1fbb0a04c8395e874db..176142c61492c99c1f31a16c7f3572a381e1e006 100644 (file)
@@ -76,6 +76,12 @@ config LEDS_NET48XX
          This option enables support for the Soekris net4801 and net4826 error
          LED.
 
+config LEDS_WRAP
+       tristate "LED Support for the WRAP series LEDs"
+       depends on LEDS_CLASS && SCx200_GPIO
+       help
+         This option enables support for the PCEngines WRAP programmable LEDs.
+
 comment "LED Triggers"
 
 config LEDS_TRIGGERS
index 6aa2aed7539de65135000203e46dab3c0e28a454..500de3dc962adedcb2576e543754f6d54d439988 100644 (file)
@@ -13,6 +13,7 @@ obj-$(CONFIG_LEDS_TOSA)                       += leds-tosa.o
 obj-$(CONFIG_LEDS_S3C24XX)             += leds-s3c24xx.o
 obj-$(CONFIG_LEDS_AMS_DELTA)           += leds-ams-delta.o
 obj-$(CONFIG_LEDS_NET48XX)             += leds-net48xx.o
+obj-$(CONFIG_LEDS_WRAP)                        += leds-wrap.o
 
 # LED Triggers
 obj-$(CONFIG_LEDS_TRIGGER_TIMER)       += ledtrig-timer.o
diff --git a/drivers/leds/leds-wrap.c b/drivers/leds/leds-wrap.c
new file mode 100644 (file)
index 0000000..27fb2d8
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * LEDs driver for PCEngines WRAP
+ *
+ * Copyright (C) 2006 Kristian Kielhofner <kris@krisk.org>
+ *
+ * Based on leds-net48xx.c
+ *
+ * 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/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/leds.h>
+#include <linux/err.h>
+#include <asm/io.h>
+#include <linux/scx200_gpio.h>
+
+#define DRVNAME "wrap-led"
+#define WRAP_ERROR_LED_GPIO    3
+#define        WRAP_EXTRA_LED_GPIO     18
+
+static struct platform_device *pdev;
+
+static void wrap_error_led_set(struct led_classdev *led_cdev,
+               enum led_brightness value)
+{
+       if (value)
+               scx200_gpio_set_low(WRAP_ERROR_LED_GPIO);
+       else
+               scx200_gpio_set_high(WRAP_ERROR_LED_GPIO);
+}
+
+static void wrap_extra_led_set(struct led_classdev *led_cdev,
+               enum led_brightness value)
+{
+       if (value)
+               scx200_gpio_set_low(WRAP_EXTRA_LED_GPIO);
+       else
+               scx200_gpio_set_high(WRAP_EXTRA_LED_GPIO);
+}
+
+static struct led_classdev wrap_error_led = {
+       .name           = "wrap:error",
+       .brightness_set = wrap_error_led_set,
+};
+
+static struct led_classdev wrap_extra_led = {
+       .name           = "wrap:extra",
+       .brightness_set = wrap_extra_led_set,
+};
+
+#ifdef CONFIG_PM
+static int wrap_led_suspend(struct platform_device *dev,
+               pm_message_t state)
+{
+       led_classdev_suspend(&wrap_error_led);
+       led_classdev_suspend(&wrap_extra_led);
+       return 0;
+}
+
+static int wrap_led_resume(struct platform_device *dev)
+{
+       led_classdev_resume(&wrap_error_led);
+       led_classdev_resume(&wrap_extra_led);
+       return 0;
+}
+#else
+#define wrap_led_suspend NULL
+#define wrap_led_resume NULL
+#endif
+
+static int wrap_led_probe(struct platform_device *pdev)
+{
+       int ret;
+
+       ret = led_classdev_register(&pdev->dev, &wrap_error_led);
+       if (ret == 0) {
+               ret = led_classdev_register(&pdev->dev, &wrap_extra_led);
+               if (ret < 0)
+                       led_classdev_unregister(&wrap_error_led);
+       }
+       return ret;
+}
+
+static int wrap_led_remove(struct platform_device *pdev)
+{
+       led_classdev_unregister(&wrap_error_led);
+       led_classdev_unregister(&wrap_extra_led);
+       return 0;
+}
+
+static struct platform_driver wrap_led_driver = {
+       .probe          = wrap_led_probe,
+       .remove         = wrap_led_remove,
+       .suspend        = wrap_led_suspend,
+       .resume         = wrap_led_resume,
+       .driver         = {
+               .name           = DRVNAME,
+               .owner          = THIS_MODULE,
+       },
+};
+
+static int __init wrap_led_init(void)
+{
+       int ret;
+
+       if (!scx200_gpio_present()) {
+               ret = -ENODEV;
+               goto out;
+       }
+
+       ret = platform_driver_register(&wrap_led_driver);
+       if (ret < 0)
+               goto out;
+
+       pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
+       if (IS_ERR(pdev)) {
+               ret = PTR_ERR(pdev);
+               platform_driver_unregister(&wrap_led_driver);
+               goto out;
+       }
+
+out:
+       return ret;
+}
+
+static void __exit wrap_led_exit(void)
+{
+       platform_device_unregister(pdev);
+       platform_driver_unregister(&wrap_led_driver);
+}
+
+module_init(wrap_led_init);
+module_exit(wrap_led_exit);
+
+MODULE_AUTHOR("Kristian Kielhofner <kris@krisk.org>");
+MODULE_DESCRIPTION("PCEngines WRAP LED driver");
+MODULE_LICENSE("GPL");
+
index 92ccee85e2a20fe30ab9fbe20ed64c8217ddccf9..a9e747c3979131179d6304755c693c815a2661f0 100644 (file)
@@ -162,7 +162,6 @@ config INPUT_ADBHID
 
 config MAC_EMUMOUSEBTN
        bool "Support for mouse button 2+3 emulation"
-       depends on INPUT_ADBHID
        help
          This provides generic support for emulating the 2nd and 3rd mouse
          button with keypresses.  If you say Y here, the emulation is still
index 5066e7a8ea9cd1ca10cb7978516f3c656007a4f5..1c7d6f221b557bfad36b42d4014c2fb7dc6ba4bd 100644 (file)
@@ -689,7 +689,6 @@ adbhid_input_register(int id, int default_id, int original_handler_id,
        if (!hid || !input_dev) {
                err = -ENOMEM;
                goto fail;
-
        }
 
        sprintf(hid->phys, "adb%d:%d.%02x/input", id, default_id, original_handler_id);
@@ -807,7 +806,9 @@ adbhid_input_register(int id, int default_id, int original_handler_id,
 
        input_dev->keycode = hid->keycode;
 
-       input_register_device(input_dev);
+       err = input_register_device(input_dev);
+       if (err)
+               goto fail;
 
        if (default_id == ADB_KEYBOARD) {
                /* HACK WARNING!! This should go away as soon there is an utility
@@ -820,7 +821,10 @@ adbhid_input_register(int id, int default_id, int original_handler_id,
        return 0;
 
  fail: input_free_device(input_dev);
-       kfree(hid);
+       if (hid) {
+               kfree(hid->keycode);
+               kfree(hid);
+       }
        adbhid[id] = NULL;
        return err;
 }
index 1293876a2ebd3c60244ae12c7ceb05bf630b315f..8862a83b8d8480451453fc7e6625350ce7f46cb2 100644 (file)
@@ -529,7 +529,8 @@ static int __init apm_emu_init(void)
        if (apm_proc)
                apm_proc->owner = THIS_MODULE;
 
-       misc_register(&apm_device);
+       if (misc_register(&apm_device) != 0)
+               printk(KERN_INFO "Could not create misc. device for apm\n");
 
        pmu_register_sleep_notifier(&apm_sleep_notifier);
 
index 6b129eef7987cac903620a44109e8b63ce213871..ee6b4ca691308e4724bf395564b234780bc8f124 100644 (file)
@@ -106,6 +106,8 @@ EXPORT_SYMBOL(mac_hid_mouse_emulate_buttons);
 
 static int emumousebtn_input_register(void)
 {
+       int ret;
+
        emumousebtn = input_allocate_device();
        if (!emumousebtn)
                return -ENOMEM;
@@ -120,9 +122,11 @@ static int emumousebtn_input_register(void)
        emumousebtn->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
        emumousebtn->relbit[0] = BIT(REL_X) | BIT(REL_Y);
 
-       input_register_device(emumousebtn);
+       ret = input_register_device(emumousebtn);
+       if (ret)
+               input_free_device(emumousebtn);
 
-       return 0;
+       return ret;
 }
 
 int __init mac_hid_init(void)
index 13b953ae8ebc3d27da0f31fc7c5003fa4af38754..3d3bf1643e73ff98fc863cdd5d2ec6b8b5965291 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/suspend.h>
 #include <linux/kthread.h>
 #include <linux/moduleparam.h>
+#include <linux/freezer.h>
 
 #include <asm/prom.h>
 #include <asm/machdep.h>
index e63ea1c1f3c1de9833ac155d8e3e7587d5ff8693..c8558d4ed5064416e88b69d7a8d0a8e655939ee4 100644 (file)
@@ -42,7 +42,7 @@
 #include <linux/interrupt.h>
 #include <linux/device.h>
 #include <linux/sysdev.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 #include <linux/syscalls.h>
 #include <linux/cpu.h>
 #include <asm/prom.h>
index ab3faa702d58b0d70da4a6d9053dc37f9ff44acf..e947af982f93503b0e20bd321247e4c6770b3abe 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/device.h>
 #include <linux/platform_device.h>
 #include <linux/mutex.h>
+#include <linux/freezer.h>
 
 #include <asm/prom.h>
 
index d6f614738bbd732e24cd039af3a05ffb01e01373..5432d07c074dd08b959cb3ffe9de5a910b084fda 100644 (file)
@@ -212,8 +212,8 @@ char *file_path(struct file *file, char *buf, int count)
        if (!buf)
                return NULL;
 
-       d = file->f_dentry;
-       v = file->f_vfsmnt;
+       d = file->f_path.dentry;
+       v = file->f_path.mnt;
 
        buf = d_path(d, v, buf, count);
 
@@ -349,7 +349,7 @@ static struct page *read_page(struct file *file, unsigned long index,
                              unsigned long count)
 {
        struct page *page = NULL;
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct buffer_head *bh;
        sector_t block;
 
@@ -662,7 +662,7 @@ static void bitmap_file_put(struct bitmap *bitmap)
        bitmap_file_unmap(bitmap);
 
        if (file) {
-               struct inode *inode = file->f_dentry->d_inode;
+               struct inode *inode = file->f_path.dentry->d_inode;
                invalidate_inode_pages(inode->i_mapping);
                fput(file);
        }
index bbf4615f0e30d792990208325fa9fa48580ce879..da4349649f7f2cd5c7c6d628f40d8bf1a1463b84 100644 (file)
@@ -44,6 +44,20 @@ static inline void bio_list_merge(struct bio_list *bl, struct bio_list *bl2)
        bl->tail = bl2->tail;
 }
 
+static inline void bio_list_merge_head(struct bio_list *bl,
+                                      struct bio_list *bl2)
+{
+       if (!bl2->head)
+               return;
+
+       if (bl->head)
+               bl2->tail->bi_next = bl->head;
+       else
+               bl->tail = bl2->tail;
+
+       bl->head = bl2->head;
+}
+
 static inline struct bio *bio_list_pop(struct bio_list *bl)
 {
        struct bio *bio = bl->head;
index ed2d4ef27fd84f4ac62928389605e0eaed96934c..4c2471ee054aa099a8777de111e7b219fe6c6eb9 100644 (file)
@@ -20,6 +20,7 @@
 #include <asm/atomic.h>
 #include <linux/scatterlist.h>
 #include <asm/page.h>
+#include <asm/unaligned.h>
 
 #include "dm.h"
 
@@ -85,7 +86,10 @@ struct crypt_config {
         */
        struct crypt_iv_operations *iv_gen_ops;
        char *iv_mode;
-       struct crypto_cipher *iv_gen_private;
+       union {
+               struct crypto_cipher *essiv_tfm;
+               int benbi_shift;
+       } iv_gen_private;
        sector_t iv_offset;
        unsigned int iv_size;
 
@@ -101,7 +105,7 @@ struct crypt_config {
 #define MIN_POOL_PAGES 32
 #define MIN_BIO_PAGES  8
 
-static kmem_cache_t *_crypt_io_pool;
+static struct kmem_cache *_crypt_io_pool;
 
 /*
  * Different IV generation algorithms:
@@ -113,6 +117,9 @@ static kmem_cache_t *_crypt_io_pool;
  *        encrypted with the bulk cipher using a salt as key. The salt
  *        should be derived from the bulk cipher's key via hashing.
  *
+ * benbi: the 64-bit "big-endian 'narrow block'-count", starting at 1
+ *        (needed for LRW-32-AES and possible other narrow block modes)
+ *
  * plumb: unimplemented, see:
  * http://article.gmane.org/gmane.linux.kernel.device-mapper.dm-crypt/454
  */
@@ -191,21 +198,61 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
        }
        kfree(salt);
 
-       cc->iv_gen_private = essiv_tfm;
+       cc->iv_gen_private.essiv_tfm = essiv_tfm;
        return 0;
 }
 
 static void crypt_iv_essiv_dtr(struct crypt_config *cc)
 {
-       crypto_free_cipher(cc->iv_gen_private);
-       cc->iv_gen_private = NULL;
+       crypto_free_cipher(cc->iv_gen_private.essiv_tfm);
+       cc->iv_gen_private.essiv_tfm = NULL;
 }
 
 static int crypt_iv_essiv_gen(struct crypt_config *cc, u8 *iv, sector_t sector)
 {
        memset(iv, 0, cc->iv_size);
        *(u64 *)iv = cpu_to_le64(sector);
-       crypto_cipher_encrypt_one(cc->iv_gen_private, iv, iv);
+       crypto_cipher_encrypt_one(cc->iv_gen_private.essiv_tfm, iv, iv);
+       return 0;
+}
+
+static int crypt_iv_benbi_ctr(struct crypt_config *cc, struct dm_target *ti,
+                             const char *opts)
+{
+       unsigned int bs = crypto_blkcipher_blocksize(cc->tfm);
+       int log = ilog2(bs);
+
+       /* we need to calculate how far we must shift the sector count
+        * to get the cipher block count, we use this shift in _gen */
+
+       if (1 << log != bs) {
+               ti->error = "cypher blocksize is not a power of 2";
+               return -EINVAL;
+       }
+
+       if (log > 9) {
+               ti->error = "cypher blocksize is > 512";
+               return -EINVAL;
+       }
+
+       cc->iv_gen_private.benbi_shift = 9 - log;
+
+       return 0;
+}
+
+static void crypt_iv_benbi_dtr(struct crypt_config *cc)
+{
+}
+
+static int crypt_iv_benbi_gen(struct crypt_config *cc, u8 *iv, sector_t sector)
+{
+       __be64 val;
+
+       memset(iv, 0, cc->iv_size - sizeof(u64)); /* rest is cleared below */
+
+       val = cpu_to_be64(((u64)sector << cc->iv_gen_private.benbi_shift) + 1);
+       put_unaligned(val, (__be64 *)(iv + cc->iv_size - sizeof(u64)));
+
        return 0;
 }
 
@@ -219,13 +266,18 @@ static struct crypt_iv_operations crypt_iv_essiv_ops = {
        .generator = crypt_iv_essiv_gen
 };
 
+static struct crypt_iv_operations crypt_iv_benbi_ops = {
+       .ctr       = crypt_iv_benbi_ctr,
+       .dtr       = crypt_iv_benbi_dtr,
+       .generator = crypt_iv_benbi_gen
+};
 
 static int
 crypt_convert_scatterlist(struct crypt_config *cc, struct scatterlist *out,
                           struct scatterlist *in, unsigned int length,
                           int write, sector_t sector)
 {
-       u8 iv[cc->iv_size];
+       u8 iv[cc->iv_size] __attribute__ ((aligned(__alignof__(u64))));
        struct blkcipher_desc desc = {
                .tfm = cc->tfm,
                .info = iv,
@@ -768,7 +820,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
        cc->tfm = tfm;
 
        /*
-        * Choose ivmode. Valid modes: "plain", "essiv:<esshash>".
+        * Choose ivmode. Valid modes: "plain", "essiv:<esshash>", "benbi".
         * See comments at iv code
         */
 
@@ -778,6 +830,8 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
                cc->iv_gen_ops = &crypt_iv_plain_ops;
        else if (strcmp(ivmode, "essiv") == 0)
                cc->iv_gen_ops = &crypt_iv_essiv_ops;
+       else if (strcmp(ivmode, "benbi") == 0)
+               cc->iv_gen_ops = &crypt_iv_benbi_ops;
        else {
                ti->error = "Invalid IV mode";
                goto bad2;
@@ -908,7 +962,7 @@ static int crypt_map(struct dm_target *ti, struct bio *bio,
        atomic_set(&io->pending, 0);
        kcryptd_queue_io(io);
 
-       return 0;
+       return DM_MAPIO_SUBMITTED;
 }
 
 static int crypt_status(struct dm_target *ti, status_type_t type,
index 2b2d45d7baaaaf55f9cfb45ff9b755587fc83d61..265c467854da7eccc62c7d5c09ec1495c2c65065 100644 (file)
@@ -40,7 +40,7 @@ static inline void free_bio(struct bio *bio)
 
 static int emc_endio(struct bio *bio, unsigned int bytes_done, int error)
 {
-       struct path *path = bio->bi_private;
+       struct dm_path *path = bio->bi_private;
 
        if (bio->bi_size)
                return 1;
@@ -61,7 +61,7 @@ static int emc_endio(struct bio *bio, unsigned int bytes_done, int error)
        return 0;
 }
 
-static struct bio *get_failover_bio(struct path *path, unsigned data_size)
+static struct bio *get_failover_bio(struct dm_path *path, unsigned data_size)
 {
        struct bio *bio;
        struct page *page;
@@ -96,7 +96,7 @@ static struct bio *get_failover_bio(struct path *path, unsigned data_size)
 }
 
 static struct request *get_failover_req(struct emc_handler *h,
-                                       struct bio *bio, struct path *path)
+                                       struct bio *bio, struct dm_path *path)
 {
        struct request *rq;
        struct block_device *bdev = bio->bi_bdev;
@@ -133,7 +133,7 @@ static struct request *get_failover_req(struct emc_handler *h,
 }
 
 static struct request *emc_trespass_get(struct emc_handler *h,
-                                       struct path *path)
+                                       struct dm_path *path)
 {
        struct bio *bio;
        struct request *rq;
@@ -191,7 +191,7 @@ static struct request *emc_trespass_get(struct emc_handler *h,
 }
 
 static void emc_pg_init(struct hw_handler *hwh, unsigned bypassed,
-                       struct path *path)
+                       struct dm_path *path)
 {
        struct request *rq;
        struct request_queue *q = bdev_get_queue(path->dev->bdev);
index 15f5629e231ad93fbab9424815c1495655b242fc..32eff28e4adc889f339ae7e75345c2aea42af5cf 100644 (file)
@@ -32,7 +32,7 @@ struct hw_handler_type {
        void (*destroy) (struct hw_handler *hwh);
 
        void (*pg_init) (struct hw_handler *hwh, unsigned bypassed,
-                        struct path *path);
+                        struct dm_path *path);
        unsigned (*error) (struct hw_handler *hwh, struct bio *bio);
        int (*status) (struct hw_handler *hwh, status_type_t type,
                       char *result, unsigned int maxlen);
index da663d2ff552b4b3a4d44bec0c4ec84e4e904365..4eb73d3952130898e60db2cf3d98371706562110 100644 (file)
@@ -92,12 +92,12 @@ void dm_io_put(unsigned int num_pages)
  *---------------------------------------------------------------*/
 static inline void bio_set_region(struct bio *bio, unsigned region)
 {
-       bio->bi_io_vec[bio->bi_max_vecs - 1].bv_len = region;
+       bio->bi_io_vec[bio->bi_max_vecs].bv_len = region;
 }
 
 static inline unsigned bio_get_region(struct bio *bio)
 {
-       return bio->bi_io_vec[bio->bi_max_vecs - 1].bv_len;
+       return bio->bi_io_vec[bio->bi_max_vecs].bv_len;
 }
 
 /*-----------------------------------------------------------------
@@ -136,6 +136,7 @@ static int endio(struct bio *bio, unsigned int done, int error)
                zero_fill_bio(bio);
 
        dec_count(io, bio_get_region(bio), error);
+       bio->bi_max_vecs++;
        bio_put(bio);
 
        return 0;
@@ -250,16 +251,18 @@ static void do_region(int rw, unsigned int region, struct io_region *where,
 
        while (remaining) {
                /*
-                * Allocate a suitably sized bio, we add an extra
-                * bvec for bio_get/set_region().
+                * Allocate a suitably sized-bio: we add an extra
+                * bvec for bio_get/set_region() and decrement bi_max_vecs
+                * to hide it from bio_add_page().
                 */
-               num_bvecs = (remaining / (PAGE_SIZE >> 9)) + 2;
+               num_bvecs = (remaining / (PAGE_SIZE >> SECTOR_SHIFT)) + 2;
                bio = bio_alloc_bioset(GFP_NOIO, num_bvecs, _bios);
                bio->bi_sector = where->sector + (where->count - remaining);
                bio->bi_bdev = where->bdev;
                bio->bi_end_io = endio;
                bio->bi_private = io;
                bio->bi_destructor = dm_bio_destructor;
+               bio->bi_max_vecs--;
                bio_set_region(bio, region);
 
                /*
@@ -302,7 +305,7 @@ static void dispatch_io(int rw, unsigned int num_regions,
        }
 
        /*
-        * Drop the extra refence that we were holding to avoid
+        * Drop the extra reference that we were holding to avoid
         * the io being completed too early.
         */
        dec_count(io, 0, 0);
index 4510ad8f971c366f4979403f4b0e13075f9d944b..cd6a184536a1c3ec6ca35bd3d912fe25e7d0f804 100644 (file)
@@ -765,7 +765,7 @@ out:
 static int do_suspend(struct dm_ioctl *param)
 {
        int r = 0;
-       int do_lockfs = 1;
+       unsigned suspend_flags = DM_SUSPEND_LOCKFS_FLAG;
        struct mapped_device *md;
 
        md = find_device(param);
@@ -773,10 +773,12 @@ static int do_suspend(struct dm_ioctl *param)
                return -ENXIO;
 
        if (param->flags & DM_SKIP_LOCKFS_FLAG)
-               do_lockfs = 0;
+               suspend_flags &= ~DM_SUSPEND_LOCKFS_FLAG;
+       if (param->flags & DM_NOFLUSH_FLAG)
+               suspend_flags |= DM_SUSPEND_NOFLUSH_FLAG;
 
        if (!dm_suspended(md))
-               r = dm_suspend(md, do_lockfs);
+               r = dm_suspend(md, suspend_flags);
 
        if (!r)
                r = __dev_status(md, param);
@@ -788,7 +790,7 @@ static int do_suspend(struct dm_ioctl *param)
 static int do_resume(struct dm_ioctl *param)
 {
        int r = 0;
-       int do_lockfs = 1;
+       unsigned suspend_flags = DM_SUSPEND_LOCKFS_FLAG;
        struct hash_cell *hc;
        struct mapped_device *md;
        struct dm_table *new_map;
@@ -814,9 +816,11 @@ static int do_resume(struct dm_ioctl *param)
        if (new_map) {
                /* Suspend if it isn't already suspended */
                if (param->flags & DM_SKIP_LOCKFS_FLAG)
-                       do_lockfs = 0;
+                       suspend_flags &= ~DM_SUSPEND_LOCKFS_FLAG;
+               if (param->flags & DM_NOFLUSH_FLAG)
+                       suspend_flags |= DM_SUSPEND_NOFLUSH_FLAG;
                if (!dm_suspended(md))
-                       dm_suspend(md, do_lockfs);
+                       dm_suspend(md, suspend_flags);
 
                r = dm_swap_table(md, new_map);
                if (r) {
index 00234909b3db02b8b55e146b09fe27f57a20cdcc..17753d80ad228022b2575e46ee28f867cfd93d6f 100644 (file)
@@ -77,7 +77,7 @@ static int linear_map(struct dm_target *ti, struct bio *bio,
        bio->bi_bdev = lc->dev->bdev;
        bio->bi_sector = lc->start + (bio->bi_sector - ti->begin);
 
-       return 1;
+       return DM_MAPIO_REMAPPED;
 }
 
 static int linear_status(struct dm_target *ti, status_type_t type,
@@ -108,7 +108,7 @@ static int linear_ioctl(struct dm_target *ti, struct inode *inode,
        struct dentry fake_dentry = {};
 
        fake_file.f_mode = lc->dev->mode;
-       fake_file.f_dentry = &fake_dentry;
+       fake_file.f_path.dentry = &fake_dentry;
        fake_dentry.d_inode = bdev->bd_inode;
 
        return blkdev_driver_ioctl(bdev->bd_inode, &fake_file, bdev->bd_disk, cmd, arg);
index 64b764bd02cc3e1ff15d9aa26df40f536d34f22b..6a9261351848ba7e3272de48a51d100345a45a7f 100644 (file)
@@ -466,6 +466,7 @@ static int disk_resume(struct dirty_log *log)
        /* copy clean across to sync */
        memcpy(lc->sync_bits, lc->clean_bits, size);
        lc->sync_count = count_bits32(lc->clean_bits, lc->bitset_uint32_count);
+       lc->sync_search = 0;
 
        /* set the correct number of regions in the header */
        lc->header.nr_regions = lc->region_count;
@@ -480,6 +481,13 @@ static uint32_t core_get_region_size(struct dirty_log *log)
        return lc->region_size;
 }
 
+static int core_resume(struct dirty_log *log)
+{
+       struct log_c *lc = (struct log_c *) log->context;
+       lc->sync_search = 0;
+       return 0;
+}
+
 static int core_is_clean(struct dirty_log *log, region_t region)
 {
        struct log_c *lc = (struct log_c *) log->context;
@@ -549,16 +557,19 @@ static int core_get_resync_work(struct dirty_log *log, region_t *region)
        return 1;
 }
 
-static void core_complete_resync_work(struct dirty_log *log, region_t region,
-                                     int success)
+static void core_set_region_sync(struct dirty_log *log, region_t region,
+                                int in_sync)
 {
        struct log_c *lc = (struct log_c *) log->context;
 
        log_clear_bit(lc, lc->recovering_bits, region);
-       if (success) {
+       if (in_sync) {
                log_set_bit(lc, lc->sync_bits, region);
                 lc->sync_count++;
-        }
+        } else if (log_test_bit(lc->sync_bits, region)) {
+               lc->sync_count--;
+               log_clear_bit(lc, lc->sync_bits, region);
+       }
 }
 
 static region_t core_get_sync_count(struct dirty_log *log)
@@ -618,6 +629,7 @@ static struct dirty_log_type _core_type = {
        .module = THIS_MODULE,
        .ctr = core_ctr,
        .dtr = core_dtr,
+       .resume = core_resume,
        .get_region_size = core_get_region_size,
        .is_clean = core_is_clean,
        .in_sync = core_in_sync,
@@ -625,7 +637,7 @@ static struct dirty_log_type _core_type = {
        .mark_region = core_mark_region,
        .clear_region = core_clear_region,
        .get_resync_work = core_get_resync_work,
-       .complete_resync_work = core_complete_resync_work,
+       .set_region_sync = core_set_region_sync,
        .get_sync_count = core_get_sync_count,
        .status = core_status,
 };
@@ -644,7 +656,7 @@ static struct dirty_log_type _disk_type = {
        .mark_region = core_mark_region,
        .clear_region = core_clear_region,
        .get_resync_work = core_get_resync_work,
-       .complete_resync_work = core_complete_resync_work,
+       .set_region_sync = core_set_region_sync,
        .get_sync_count = core_get_sync_count,
        .status = disk_status,
 };
index 5ae5309ebf2808dea579d2cb0b9e0d7fa8beda48..86a301c8daf15d5962afe2ca8ed6eee39e58d24e 100644 (file)
@@ -90,12 +90,12 @@ struct dirty_log_type {
        int (*get_resync_work)(struct dirty_log *log, region_t *region);
 
        /*
-        * This notifies the log that the resync of an area has
-        * been completed.  The log should then mark this region
-        * as CLEAN.
+        * This notifies the log that the resync status of a region
+        * has changed.  It also clears the region from the recovering
+        * list (if present).
         */
-       void (*complete_resync_work)(struct dirty_log *log,
-                                    region_t region, int success);
+       void (*set_region_sync)(struct dirty_log *log,
+                               region_t region, int in_sync);
 
         /*
         * Returns the number of regions that are in sync.
index e77ee6fd104472475216f9002b0f67a66f5da379..3aa0135069672d8fe7f3ed4c6e743d969478c95f 100644 (file)
@@ -31,7 +31,7 @@ struct pgpath {
        struct priority_group *pg;      /* Owning PG */
        unsigned fail_count;            /* Cumulative failure count */
 
-       struct path path;
+       struct dm_path path;
 };
 
 #define path_to_pgpath(__pgp) container_of((__pgp), struct pgpath, path)
@@ -101,7 +101,7 @@ typedef int (*action_fn) (struct pgpath *pgpath);
 
 #define MIN_IOS 256    /* Mempool size */
 
-static kmem_cache_t *_mpio_cache;
+static struct kmem_cache *_mpio_cache;
 
 struct workqueue_struct *kmultipathd;
 static void process_queued_ios(struct work_struct *work);
@@ -229,7 +229,7 @@ static void __switch_pg(struct multipath *m, struct pgpath *pgpath)
 
 static int __choose_path_in_pg(struct multipath *m, struct priority_group *pg)
 {
-       struct path *path;
+       struct dm_path *path;
 
        path = pg->ps.type->select_path(&pg->ps, &m->repeat_count);
        if (!path)
@@ -282,10 +282,27 @@ failed:
        m->current_pg = NULL;
 }
 
+/*
+ * Check whether bios must be queued in the device-mapper core rather
+ * than here in the target.
+ *
+ * m->lock must be held on entry.
+ *
+ * If m->queue_if_no_path and m->saved_queue_if_no_path hold the
+ * same value then we are not between multipath_presuspend()
+ * and multipath_resume() calls and we have no need to check
+ * for the DMF_NOFLUSH_SUSPENDING flag.
+ */
+static int __must_push_back(struct multipath *m)
+{
+       return (m->queue_if_no_path != m->saved_queue_if_no_path &&
+               dm_noflush_suspending(m->ti));
+}
+
 static int map_io(struct multipath *m, struct bio *bio, struct mpath_io *mpio,
                  unsigned was_queued)
 {
-       int r = 1;
+       int r = DM_MAPIO_REMAPPED;
        unsigned long flags;
        struct pgpath *pgpath;
 
@@ -310,11 +327,13 @@ static int map_io(struct multipath *m, struct bio *bio, struct mpath_io *mpio,
                    !m->queue_io)
                        queue_work(kmultipathd, &m->process_queued_ios);
                pgpath = NULL;
-               r = 0;
-       } else if (!pgpath)
-               r = -EIO;               /* Failed */
-       else
+               r = DM_MAPIO_SUBMITTED;
+       } else if (pgpath)
                bio->bi_bdev = pgpath->path.dev->bdev;
+       else if (__must_push_back(m))
+               r = DM_MAPIO_REQUEUE;
+       else
+               r = -EIO;       /* Failed */
 
        mpio->pgpath = pgpath;
 
@@ -372,8 +391,10 @@ static void dispatch_queued_ios(struct multipath *m)
                r = map_io(m, bio, mpio, 1);
                if (r < 0)
                        bio_endio(bio, bio->bi_size, r);
-               else if (r == 1)
+               else if (r == DM_MAPIO_REMAPPED)
                        generic_make_request(bio);
+               else if (r == DM_MAPIO_REQUEUE)
+                       bio_endio(bio, bio->bi_size, -EIO);
 
                bio = next;
        }
@@ -783,7 +804,7 @@ static int multipath_map(struct dm_target *ti, struct bio *bio,
        map_context->ptr = mpio;
        bio->bi_rw |= (1 << BIO_RW_FAILFAST);
        r = map_io(m, bio, mpio, 0);
-       if (r < 0)
+       if (r < 0 || r == DM_MAPIO_REQUEUE)
                mempool_free(mpio, m->mpio_pool);
 
        return r;
@@ -957,7 +978,7 @@ static int bypass_pg_num(struct multipath *m, const char *pgstr, int bypassed)
 /*
  * pg_init must call this when it has completed its initialisation
  */
-void dm_pg_init_complete(struct path *path, unsigned err_flags)
+void dm_pg_init_complete(struct dm_path *path, unsigned err_flags)
 {
        struct pgpath *pgpath = path_to_pgpath(path);
        struct priority_group *pg = pgpath->pg;
@@ -1007,7 +1028,10 @@ static int do_end_io(struct multipath *m, struct bio *bio,
 
        spin_lock_irqsave(&m->lock, flags);
        if (!m->nr_valid_paths) {
-               if (!m->queue_if_no_path) {
+               if (__must_push_back(m)) {
+                       spin_unlock_irqrestore(&m->lock, flags);
+                       return DM_ENDIO_REQUEUE;
+               } else if (!m->queue_if_no_path) {
                        spin_unlock_irqrestore(&m->lock, flags);
                        return -EIO;
                } else {
@@ -1042,7 +1066,7 @@ static int do_end_io(struct multipath *m, struct bio *bio,
                queue_work(kmultipathd, &m->process_queued_ios);
        spin_unlock_irqrestore(&m->lock, flags);
 
-       return 1;       /* io not complete */
+       return DM_ENDIO_INCOMPLETE;     /* io not complete */
 }
 
 static int multipath_end_io(struct dm_target *ti, struct bio *bio,
@@ -1060,7 +1084,7 @@ static int multipath_end_io(struct dm_target *ti, struct bio *bio,
                if (ps->type->end_io)
                        ps->type->end_io(ps, &pgpath->path);
        }
-       if (r <= 0)
+       if (r != DM_ENDIO_INCOMPLETE)
                mempool_free(mpio, m->mpio_pool);
 
        return r;
@@ -1272,7 +1296,7 @@ static int multipath_ioctl(struct dm_target *ti, struct inode *inode,
        struct dentry fake_dentry = {};
        int r = 0;
 
-       fake_file.f_dentry = &fake_dentry;
+       fake_file.f_path.dentry = &fake_dentry;
 
        spin_lock_irqsave(&m->lock, flags);
 
index 8a4bf2b6d52e0ebe35e738048cdde3abb997292f..b9cdcbb3ed598bbcdcc833df923026dd07243642 100644 (file)
@@ -11,7 +11,7 @@
 
 struct dm_dev;
 
-struct path {
+struct dm_path {
        struct dm_dev *dev;     /* Read-only */
        unsigned is_active;     /* Read-only */
 
@@ -20,6 +20,6 @@ struct path {
 };
 
 /* Callback for hwh_pg_init_fn to use when complete */
-void dm_pg_init_complete(struct path *path, unsigned err_flags);
+void dm_pg_init_complete(struct dm_path *path, unsigned err_flags);
 
 #endif
index 732d06a84f8505f6084976036c688bac67980fd8..27357b85d73d7495cbcb2d61e8522ac942317901 100644 (file)
@@ -44,7 +44,7 @@ struct path_selector_type {
         * Add an opaque path object, along with some selector specific
         * path args (eg, path priority).
         */
-       int (*add_path) (struct path_selector *ps, struct path *path,
+       int (*add_path) (struct path_selector *ps, struct dm_path *path,
                         int argc, char **argv, char **error);
 
        /*
@@ -55,27 +55,27 @@ struct path_selector_type {
         * calling the function again.  0 means don't call it again unless
         * the path fails.
         */
-       struct path *(*select_path) (struct path_selector *ps,
+       struct dm_path *(*select_path) (struct path_selector *ps,
                                     unsigned *repeat_count);
 
        /*
         * Notify the selector that a path has failed.
         */
-       void (*fail_path) (struct path_selector *ps, struct path *p);
+       void (*fail_path) (struct path_selector *ps, struct dm_path *p);
 
        /*
         * Ask selector to reinstate a path.
         */
-       int (*reinstate_path) (struct path_selector *ps, struct path *p);
+       int (*reinstate_path) (struct path_selector *ps, struct dm_path *p);
 
        /*
         * Table content based on parameters added in ps_add_path_fn
         * or path selector status
         */
-       int (*status) (struct path_selector *ps, struct path *path,
+       int (*status) (struct path_selector *ps, struct dm_path *path,
                       status_type_t type, char *result, unsigned int maxlen);
 
-       int (*end_io) (struct path_selector *ps, struct path *path);
+       int (*end_io) (struct path_selector *ps, struct dm_path *path);
 };
 
 /* Register a path selector */
index fc8cbb168e3ed2d5f8ae53bcec7762d0cc53008b..23a642619bedfbbe76137f2d1e8d174782622f4e 100644 (file)
@@ -344,6 +344,17 @@ static void dispatch_bios(struct mirror_set *ms, struct bio_list *bio_list)
        }
 }
 
+static void complete_resync_work(struct region *reg, int success)
+{
+       struct region_hash *rh = reg->rh;
+
+       rh->log->type->set_region_sync(rh->log, reg->key, success);
+       dispatch_bios(rh->ms, &reg->delayed_bios);
+       if (atomic_dec_and_test(&rh->recovery_in_flight))
+               wake_up_all(&_kmirrord_recovery_stopped);
+       up(&rh->recovery_count);
+}
+
 static void rh_update_states(struct region_hash *rh)
 {
        struct region *reg, *next;
@@ -383,11 +394,7 @@ static void rh_update_states(struct region_hash *rh)
         */
        list_for_each_entry_safe (reg, next, &recovered, list) {
                rh->log->type->clear_region(rh->log, reg->key);
-               rh->log->type->complete_resync_work(rh->log, reg->key, 1);
-               dispatch_bios(rh->ms, &reg->delayed_bios);
-               if (atomic_dec_and_test(&rh->recovery_in_flight))
-                       wake_up_all(&_kmirrord_recovery_stopped);
-               up(&rh->recovery_count);
+               complete_resync_work(reg, 1);
                mempool_free(reg, rh->region_pool);
        }
 
@@ -1137,7 +1144,7 @@ static int mirror_map(struct dm_target *ti, struct bio *bio,
 
        if (rw == WRITE) {
                queue_bio(ms, bio, rw);
-               return 0;
+               return DM_MAPIO_SUBMITTED;
        }
 
        r = ms->rh.log->type->in_sync(ms->rh.log,
@@ -1146,7 +1153,7 @@ static int mirror_map(struct dm_target *ti, struct bio *bio,
                return r;
 
        if (r == -EWOULDBLOCK)  /* FIXME: ugly */
-               r = 0;
+               r = DM_MAPIO_SUBMITTED;
 
        /*
         * We don't want to fast track a recovery just for a read
@@ -1159,7 +1166,7 @@ static int mirror_map(struct dm_target *ti, struct bio *bio,
        if (!r) {
                /* Pass this io over to the daemon */
                queue_bio(ms, bio, rw);
-               return 0;
+               return DM_MAPIO_SUBMITTED;
        }
 
        m = choose_mirror(ms, bio->bi_sector);
@@ -1167,7 +1174,7 @@ static int mirror_map(struct dm_target *ti, struct bio *bio,
                return -EIO;
 
        map_bio(ms, m, bio);
-       return 1;
+       return DM_MAPIO_REMAPPED;
 }
 
 static int mirror_end_io(struct dm_target *ti, struct bio *bio,
index 6f9fcd4db9b553fde5e1af06ab8d728e9c25cb7f..a348a97b65af3f243e2a8b11433e612df2d0856b 100644 (file)
@@ -21,7 +21,7 @@
  *---------------------------------------------------------------*/
 struct path_info {
        struct list_head list;
-       struct path *path;
+       struct dm_path *path;
        unsigned repeat_count;
 };
 
@@ -80,7 +80,7 @@ static void rr_destroy(struct path_selector *ps)
        ps->context = NULL;
 }
 
-static int rr_status(struct path_selector *ps, struct path *path,
+static int rr_status(struct path_selector *ps, struct dm_path *path,
                     status_type_t type, char *result, unsigned int maxlen)
 {
        struct path_info *pi;
@@ -106,7 +106,7 @@ static int rr_status(struct path_selector *ps, struct path *path,
  * Called during initialisation to register each path with an
  * optional repeat_count.
  */
-static int rr_add_path(struct path_selector *ps, struct path *path,
+static int rr_add_path(struct path_selector *ps, struct dm_path *path,
                       int argc, char **argv, char **error)
 {
        struct selector *s = (struct selector *) ps->context;
@@ -141,7 +141,7 @@ static int rr_add_path(struct path_selector *ps, struct path *path,
        return 0;
 }
 
-static void rr_fail_path(struct path_selector *ps, struct path *p)
+static void rr_fail_path(struct path_selector *ps, struct dm_path *p)
 {
        struct selector *s = (struct selector *) ps->context;
        struct path_info *pi = p->pscontext;
@@ -149,7 +149,7 @@ static void rr_fail_path(struct path_selector *ps, struct path *p)
        list_move(&pi->list, &s->invalid_paths);
 }
 
-static int rr_reinstate_path(struct path_selector *ps, struct path *p)
+static int rr_reinstate_path(struct path_selector *ps, struct dm_path *p)
 {
        struct selector *s = (struct selector *) ps->context;
        struct path_info *pi = p->pscontext;
@@ -159,7 +159,7 @@ static int rr_reinstate_path(struct path_selector *ps, struct path *p)
        return 0;
 }
 
-static struct path *rr_select_path(struct path_selector *ps,
+static struct dm_path *rr_select_path(struct path_selector *ps,
                                   unsigned *repeat_count)
 {
        struct selector *s = (struct selector *) ps->context;
index 91c7aa1fed0e0d2284b59dad8e8d8463ee62eeeb..0821a2b68a73a98719cb931c82196a74bfe471d4 100644 (file)
@@ -39,7 +39,7 @@
  */
 #define SNAPSHOT_PAGES 256
 
-struct workqueue_struct *ksnapd;
+static struct workqueue_struct *ksnapd;
 static void flush_queued_bios(struct work_struct *work);
 
 struct pending_exception {
@@ -88,8 +88,8 @@ struct pending_exception {
  * Hash table mapping origin volumes to lists of snapshots and
  * a lock to protect it
  */
-static kmem_cache_t *exception_cache;
-static kmem_cache_t *pending_cache;
+static struct kmem_cache *exception_cache;
+static struct kmem_cache *pending_cache;
 static mempool_t *pending_pool;
 
 /*
@@ -228,7 +228,7 @@ static int init_exception_table(struct exception_table *et, uint32_t size)
        return 0;
 }
 
-static void exit_exception_table(struct exception_table *et, kmem_cache_t *mem)
+static void exit_exception_table(struct exception_table *et, struct kmem_cache *mem)
 {
        struct list_head *slot;
        struct exception *ex, *next;
@@ -564,6 +564,17 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
        return r;
 }
 
+static void __free_exceptions(struct dm_snapshot *s)
+{
+       kcopyd_client_destroy(s->kcopyd_client);
+       s->kcopyd_client = NULL;
+
+       exit_exception_table(&s->pending, pending_cache);
+       exit_exception_table(&s->complete, exception_cache);
+
+       s->store.destroy(&s->store);
+}
+
 static void snapshot_dtr(struct dm_target *ti)
 {
        struct dm_snapshot *s = (struct dm_snapshot *) ti->private;
@@ -574,13 +585,7 @@ static void snapshot_dtr(struct dm_target *ti)
        /* After this returns there can be no new kcopyd jobs. */
        unregister_snapshot(s);
 
-       kcopyd_client_destroy(s->kcopyd_client);
-
-       exit_exception_table(&s->pending, pending_cache);
-       exit_exception_table(&s->complete, exception_cache);
-
-       /* Deallocate memory used */
-       s->store.destroy(&s->store);
+       __free_exceptions(s);
 
        dm_put_device(ti, s->origin);
        dm_put_device(ti, s->cow);
@@ -868,7 +873,7 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio,
 {
        struct exception *e;
        struct dm_snapshot *s = (struct dm_snapshot *) ti->private;
-       int r = 1;
+       int r = DM_MAPIO_REMAPPED;
        chunk_t chunk;
        struct pending_exception *pe = NULL;
 
@@ -914,7 +919,7 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio,
                remap_exception(s, &pe->e, bio);
                bio_list_add(&pe->snapshot_bios, bio);
 
-               r = 0;
+               r = DM_MAPIO_SUBMITTED;
 
                if (!pe->started) {
                        /* this is protected by snap->lock */
@@ -992,7 +997,7 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
  *---------------------------------------------------------------*/
 static int __origin_write(struct list_head *snapshots, struct bio *bio)
 {
-       int r = 1, first = 0;
+       int r = DM_MAPIO_REMAPPED, first = 0;
        struct dm_snapshot *snap;
        struct exception *e;
        struct pending_exception *pe, *next_pe, *primary_pe = NULL;
@@ -1050,7 +1055,7 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
 
                        bio_list_add(&primary_pe->origin_bios, bio);
 
-                       r = 0;
+                       r = DM_MAPIO_SUBMITTED;
                }
 
                if (!pe->primary_pe) {
@@ -1099,7 +1104,7 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
 static int do_origin(struct dm_dev *origin, struct bio *bio)
 {
        struct origin *o;
-       int r = 1;
+       int r = DM_MAPIO_REMAPPED;
 
        down_read(&_origins_lock);
        o = __lookup_origin(origin->bdev);
@@ -1156,7 +1161,7 @@ static int origin_map(struct dm_target *ti, struct bio *bio,
                return -EOPNOTSUPP;
 
        /* Only tell snapshots if this is a write */
-       return (bio_rw(bio) == WRITE) ? do_origin(dev, bio) : 1;
+       return (bio_rw(bio) == WRITE) ? do_origin(dev, bio) : DM_MAPIO_REMAPPED;
 }
 
 #define min_not_zero(l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r))
index 6c29fcecd8921d46503d51d23bf1f8be619c7ead..51f5e0760012dd76c35d939bb18862a20e2ee435 100644 (file)
@@ -186,7 +186,7 @@ static int stripe_map(struct dm_target *ti, struct bio *bio,
        bio->bi_bdev = sc->stripe[stripe].dev->bdev;
        bio->bi_sector = sc->stripe[stripe].physical_start +
            (chunk << sc->chunk_shift) + (offset & sc->chunk_mask);
-       return 1;
+       return DM_MAPIO_REMAPPED;
 }
 
 static int stripe_status(struct dm_target *ti,
index ea569f7348d2a284b983d766614d1ff8d8fb82ac..f314d7dc9c26cae52123b38c6422e375aba600c3 100644 (file)
@@ -46,7 +46,7 @@ static int zero_map(struct dm_target *ti, struct bio *bio,
        bio_endio(bio, bio->bi_size, 0);
 
        /* accepted bio, don't make new request */
-       return 0;
+       return DM_MAPIO_SUBMITTED;
 }
 
 static struct target_type zero_target = {
index fc4f743f3b531e72bdb9c937d6cb2bf09d9ede1d..fe7c56e104359ce95ce8b34143542535d030c78c 100644 (file)
@@ -68,10 +68,12 @@ union map_info *dm_get_mapinfo(struct bio *bio)
 #define DMF_FROZEN 2
 #define DMF_FREEING 3
 #define DMF_DELETING 4
+#define DMF_NOFLUSH_SUSPENDING 5
 
 struct mapped_device {
        struct rw_semaphore io_lock;
        struct semaphore suspend_lock;
+       spinlock_t pushback_lock;
        rwlock_t map_lock;
        atomic_t holders;
        atomic_t open_count;
@@ -89,7 +91,8 @@ struct mapped_device {
         */
        atomic_t pending;
        wait_queue_head_t wait;
-       struct bio_list deferred;
+       struct bio_list deferred;
+       struct bio_list pushback;
 
        /*
         * The current mapping.
@@ -121,8 +124,8 @@ struct mapped_device {
 };
 
 #define MIN_IOS 256
-static kmem_cache_t *_io_cache;
-static kmem_cache_t *_tio_cache;
+static struct kmem_cache *_io_cache;
+static struct kmem_cache *_tio_cache;
 
 static int __init local_init(void)
 {
@@ -444,23 +447,50 @@ int dm_set_geometry(struct mapped_device *md, struct hd_geometry *geo)
  *   you this clearly demarcated crap.
  *---------------------------------------------------------------*/
 
+static int __noflush_suspending(struct mapped_device *md)
+{
+       return test_bit(DMF_NOFLUSH_SUSPENDING, &md->flags);
+}
+
 /*
  * Decrements the number of outstanding ios that a bio has been
  * cloned into, completing the original io if necc.
  */
 static void dec_pending(struct dm_io *io, int error)
 {
-       if (error)
+       unsigned long flags;
+
+       /* Push-back supersedes any I/O errors */
+       if (error && !(io->error > 0 && __noflush_suspending(io->md)))
                io->error = error;
 
        if (atomic_dec_and_test(&io->io_count)) {
+               if (io->error == DM_ENDIO_REQUEUE) {
+                       /*
+                        * Target requested pushing back the I/O.
+                        * This must be handled before the sleeper on
+                        * suspend queue merges the pushback list.
+                        */
+                       spin_lock_irqsave(&io->md->pushback_lock, flags);
+                       if (__noflush_suspending(io->md))
+                               bio_list_add(&io->md->pushback, io->bio);
+                       else
+                               /* noflush suspend was interrupted. */
+                               io->error = -EIO;
+                       spin_unlock_irqrestore(&io->md->pushback_lock, flags);
+               }
+
                if (end_io_acct(io))
                        /* nudge anyone waiting on suspend queue */
                        wake_up(&io->md->wait);
 
-               blk_add_trace_bio(io->md->queue, io->bio, BLK_TA_COMPLETE);
+               if (io->error != DM_ENDIO_REQUEUE) {
+                       blk_add_trace_bio(io->md->queue, io->bio,
+                                         BLK_TA_COMPLETE);
+
+                       bio_endio(io->bio, io->bio->bi_size, io->error);
+               }
 
-               bio_endio(io->bio, io->bio->bi_size, io->error);
                free_io(io->md, io);
        }
 }
@@ -480,12 +510,19 @@ static int clone_endio(struct bio *bio, unsigned int done, int error)
 
        if (endio) {
                r = endio(tio->ti, bio, error, &tio->info);
-               if (r < 0)
+               if (r < 0 || r == DM_ENDIO_REQUEUE)
+                       /*
+                        * error and requeue request are handled
+                        * in dec_pending().
+                        */
                        error = r;
-
-               else if (r > 0)
-                       /* the target wants another shot at the io */
+               else if (r == DM_ENDIO_INCOMPLETE)
+                       /* The target will handle the io */
                        return 1;
+               else if (r) {
+                       DMWARN("unimplemented target endio return value: %d", r);
+                       BUG();
+               }
        }
 
        dec_pending(tio->io, error);
@@ -543,7 +580,7 @@ static void __map_bio(struct dm_target *ti, struct bio *clone,
        atomic_inc(&tio->io->io_count);
        sector = clone->bi_sector;
        r = ti->type->map(ti, clone, &tio->info);
-       if (r > 0) {
+       if (r == DM_MAPIO_REMAPPED) {
                /* the bio has been remapped so dispatch it */
 
                blk_add_trace_remap(bdev_get_queue(clone->bi_bdev), clone,
@@ -551,10 +588,8 @@ static void __map_bio(struct dm_target *ti, struct bio *clone,
                                    clone->bi_sector);
 
                generic_make_request(clone);
-       }
-
-       else if (r < 0) {
-               /* error the io and bail out */
+       } else if (r < 0 || r == DM_MAPIO_REQUEUE) {
+               /* error the io and bail out, or requeue it if needed */
                md = tio->io->md;
                dec_pending(tio->io, r);
                /*
@@ -563,6 +598,9 @@ static void __map_bio(struct dm_target *ti, struct bio *clone,
                clone->bi_private = md->bs;
                bio_put(clone);
                free_tio(md, tio);
+       } else if (r) {
+               DMWARN("unimplemented target map return value: %d", r);
+               BUG();
        }
 }
 
@@ -948,6 +986,7 @@ static struct mapped_device *alloc_dev(int minor)
        memset(md, 0, sizeof(*md));
        init_rwsem(&md->io_lock);
        init_MUTEX(&md->suspend_lock);
+       spin_lock_init(&md->pushback_lock);
        rwlock_init(&md->map_lock);
        atomic_set(&md->holders, 1);
        atomic_set(&md->open_count, 0);
@@ -966,8 +1005,8 @@ static struct mapped_device *alloc_dev(int minor)
        md->queue->issue_flush_fn = dm_flush_all;
 
        md->io_pool = mempool_create_slab_pool(MIN_IOS, _io_cache);
-       if (!md->io_pool)
-               goto bad2;
+       if (!md->io_pool)
+               goto bad2;
 
        md->tio_pool = mempool_create_slab_pool(MIN_IOS, _tio_cache);
        if (!md->tio_pool)
@@ -1275,12 +1314,15 @@ static void unlock_fs(struct mapped_device *md)
  * dm_bind_table, dm_suspend must be called to flush any in
  * flight bios and ensure that any further io gets deferred.
  */
-int dm_suspend(struct mapped_device *md, int do_lockfs)
+int dm_suspend(struct mapped_device *md, unsigned suspend_flags)
 {
        struct dm_table *map = NULL;
+       unsigned long flags;
        DECLARE_WAITQUEUE(wait, current);
        struct bio *def;
        int r = -EINVAL;
+       int do_lockfs = suspend_flags & DM_SUSPEND_LOCKFS_FLAG ? 1 : 0;
+       int noflush = suspend_flags & DM_SUSPEND_NOFLUSH_FLAG ? 1 : 0;
 
        down(&md->suspend_lock);
 
@@ -1289,6 +1331,13 @@ int dm_suspend(struct mapped_device *md, int do_lockfs)
 
        map = dm_get_table(md);
 
+       /*
+        * DMF_NOFLUSH_SUSPENDING must be set before presuspend.
+        * This flag is cleared before dm_suspend returns.
+        */
+       if (noflush)
+               set_bit(DMF_NOFLUSH_SUSPENDING, &md->flags);
+
        /* This does not get reverted if there's an error later. */
        dm_table_presuspend_targets(map);
 
@@ -1296,11 +1345,14 @@ int dm_suspend(struct mapped_device *md, int do_lockfs)
        if (!md->suspended_bdev) {
                DMWARN("bdget failed in dm_suspend");
                r = -ENOMEM;
-               goto out;
+               goto flush_and_out;
        }
 
-       /* Flush I/O to the device. */
-       if (do_lockfs) {
+       /*
+        * Flush I/O to the device.
+        * noflush supersedes do_lockfs, because lock_fs() needs to flush I/Os.
+        */
+       if (do_lockfs && !noflush) {
                r = lock_fs(md);
                if (r)
                        goto out;
@@ -1336,6 +1388,14 @@ int dm_suspend(struct mapped_device *md, int do_lockfs)
        down_write(&md->io_lock);
        remove_wait_queue(&md->wait, &wait);
 
+       if (noflush) {
+               spin_lock_irqsave(&md->pushback_lock, flags);
+               clear_bit(DMF_NOFLUSH_SUSPENDING, &md->flags);
+               bio_list_merge_head(&md->deferred, &md->pushback);
+               bio_list_init(&md->pushback);
+               spin_unlock_irqrestore(&md->pushback_lock, flags);
+       }
+
        /* were we interrupted ? */
        r = -EINTR;
        if (atomic_read(&md->pending)) {
@@ -1344,7 +1404,7 @@ int dm_suspend(struct mapped_device *md, int do_lockfs)
                __flush_deferred_io(md, def);
                up_write(&md->io_lock);
                unlock_fs(md);
-               goto out;
+               goto out; /* pushback list is already flushed, so skip flush */
        }
        up_write(&md->io_lock);
 
@@ -1354,6 +1414,25 @@ int dm_suspend(struct mapped_device *md, int do_lockfs)
 
        r = 0;
 
+flush_and_out:
+       if (r && noflush) {
+               /*
+                * Because there may be already I/Os in the pushback list,
+                * flush them before return.
+                */
+               down_write(&md->io_lock);
+
+               spin_lock_irqsave(&md->pushback_lock, flags);
+               clear_bit(DMF_NOFLUSH_SUSPENDING, &md->flags);
+               bio_list_merge_head(&md->deferred, &md->pushback);
+               bio_list_init(&md->pushback);
+               spin_unlock_irqrestore(&md->pushback_lock, flags);
+
+               def = bio_list_get(&md->deferred);
+               __flush_deferred_io(md, def);
+               up_write(&md->io_lock);
+       }
+
 out:
        if (r && md->suspended_bdev) {
                bdput(md->suspended_bdev);
@@ -1440,6 +1519,17 @@ int dm_suspended(struct mapped_device *md)
        return test_bit(DMF_SUSPENDED, &md->flags);
 }
 
+int dm_noflush_suspending(struct dm_target *ti)
+{
+       struct mapped_device *md = dm_table_get_md(ti->table);
+       int r = __noflush_suspending(md);
+
+       dm_put(md);
+
+       return r;
+}
+EXPORT_SYMBOL_GPL(dm_noflush_suspending);
+
 static struct block_device_operations dm_blk_dops = {
        .open = dm_blk_open,
        .release = dm_blk_close,
index a48ec5e3c1f478ea9523424f87b0db21fc8ab06d..2f796b1436b2a6f898fac79f05cf4bee036d04f0 100644 (file)
 
 #define SECTOR_SHIFT 9
 
+/*
+ * Definitions of return values from target end_io function.
+ */
+#define DM_ENDIO_INCOMPLETE    1
+#define DM_ENDIO_REQUEUE       2
+
+/*
+ * Definitions of return values from target map function.
+ */
+#define DM_MAPIO_SUBMITTED     0
+#define DM_MAPIO_REMAPPED      1
+#define DM_MAPIO_REQUEUE       DM_ENDIO_REQUEUE
+
+/*
+ * Suspend feature flags
+ */
+#define DM_SUSPEND_LOCKFS_FLAG         (1 << 0)
+#define DM_SUSPEND_NOFLUSH_FLAG                (1 << 1)
+
 /*
  * List of devices that a metadevice uses and should open/close.
  */
index b3c01496c737950a07683105e91d88176a32be9f..b46f6c575f7ebd5ee79dbe543525ed5459e173d6 100644 (file)
@@ -203,7 +203,7 @@ struct kcopyd_job {
 /* FIXME: this should scale with the number of pages */
 #define MIN_JOBS 512
 
-static kmem_cache_t *_job_cache;
+static struct kmem_cache *_job_cache;
 static mempool_t *_job_pool;
 
 /*
index 8cbf9c9df1c3915ce109ba8daae07e5187ea7b21..53bd46dba0cbe69d5da6f1affbcfc008145f0dd9 100644 (file)
 #include <linux/raid/bitmap.h>
 #include <linux/sysctl.h>
 #include <linux/buffer_head.h> /* for invalidate_bdev */
-#include <linux/suspend.h>
 #include <linux/poll.h>
 #include <linux/mutex.h>
 #include <linux/ctype.h>
+#include <linux/freezer.h>
 
 #include <linux/init.h>
 
@@ -1413,7 +1413,7 @@ static int lock_rdev(mdk_rdev_t *rdev, dev_t dev)
        struct block_device *bdev;
        char b[BDEVNAME_SIZE];
 
-       bdev = open_partition_by_devnum(dev, FMODE_READ|FMODE_WRITE);
+       bdev = open_by_devnum(dev, FMODE_READ|FMODE_WRITE);
        if (IS_ERR(bdev)) {
                printk(KERN_ERR "md: could not open %s.\n",
                        __bdevname(dev, b));
@@ -1423,7 +1423,7 @@ static int lock_rdev(mdk_rdev_t *rdev, dev_t dev)
        if (err) {
                printk(KERN_ERR "md: could not bd_claim %s.\n",
                        bdevname(bdev, b));
-               blkdev_put_partition(bdev);
+               blkdev_put(bdev);
                return err;
        }
        rdev->bdev = bdev;
@@ -1437,7 +1437,7 @@ static void unlock_rdev(mdk_rdev_t *rdev)
        if (!bdev)
                MD_BUG();
        bd_release(bdev);
-       blkdev_put_partition(bdev);
+       blkdev_put(bdev);
 }
 
 void md_autodetect_dev(dev_t dev);
@@ -4423,7 +4423,7 @@ static int md_open(struct inode *inode, struct file *file)
        mddev_t *mddev = inode->i_bdev->bd_disk->private_data;
        int err;
 
-       if ((err = mddev_lock(mddev)))
+       if ((err = mutex_lock_interruptible_nested(&mddev->reconfig_mutex, 1)))
                goto out;
 
        err = 0;
@@ -4846,8 +4846,8 @@ static int md_seq_show(struct seq_file *seq, void *v)
                                chunk_kb ? "KB" : "B");
                        if (bitmap->file) {
                                seq_printf(seq, ", file: ");
-                               seq_path(seq, bitmap->file->f_vfsmnt,
-                                        bitmap->file->f_dentry," \t\n");
+                               seq_path(seq, bitmap->file->f_path.mnt,
+                                        bitmap->file->f_path.dentry," \t\n");
                        }
 
                        seq_printf(seq, "\n");
index 69c3e201fa3bf0ee1ea51378fd172d4d4461e612..52914d5cec76ce1ded14a0fc37a9d2b98b1afe64 100644 (file)
@@ -348,7 +348,7 @@ static int grow_one_stripe(raid5_conf_t *conf)
 
 static int grow_stripes(raid5_conf_t *conf, int num)
 {
-       kmem_cache_t *sc;
+       struct kmem_cache *sc;
        int devs = conf->raid_disks;
 
        sprintf(conf->cache_name[0], "raid5/%s", mdname(conf->mddev));
@@ -397,7 +397,7 @@ static int resize_stripes(raid5_conf_t *conf, int newsize)
        LIST_HEAD(newstripes);
        struct disk_info *ndisks;
        int err = 0;
-       kmem_cache_t *sc;
+       struct kmem_cache *sc;
        int i;
 
        if (newsize <= conf->pool_size)
index 206c13e47a06c28fef0f03ac6ad8a237fd64d878..9123147e376f56c930c02b74e9bbb4d449b4090a 100644 (file)
@@ -287,7 +287,7 @@ static int cinergyt2_alloc_stream_urbs (struct cinergyt2 *cinergyt2)
        int i;
 
        cinergyt2->streambuf = usb_buffer_alloc(cinergyt2->udev, STREAM_URB_COUNT*STREAM_BUF_SIZE,
-                                             SLAB_KERNEL, &cinergyt2->streambuf_dmahandle);
+                                             GFP_KERNEL, &cinergyt2->streambuf_dmahandle);
        if (!cinergyt2->streambuf) {
                dprintk(1, "failed to alloc consistent stream memory area, bailing out!\n");
                return -ENOMEM;
index a2ab2eebfc685322a640d3c920ddefd1531b1033..e85972222ab42d1f01593941517d810f5cf13c37 100644 (file)
@@ -34,7 +34,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/list.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 #include <linux/jiffies.h>
 #include <asm/processor.h>
 
index 78035ee824caf59e26fc50eefaf9fcc899e63da8..397f51a7b2ada50abe6078540f6f37ae25edef85 100644 (file)
@@ -116,7 +116,7 @@ static int usb_allocate_stream_buffers(struct usb_data_stream *stream, int num,
        for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) {
                deb_mem("allocating buffer %d\n",stream->buf_num);
                if (( stream->buf_list[stream->buf_num] =
-                                       usb_buffer_alloc(stream->udev, size, SLAB_ATOMIC,
+                                       usb_buffer_alloc(stream->udev, size, GFP_ATOMIC,
                                        &stream->dma_addr[stream->buf_num]) ) == NULL) {
                        deb_mem("not enough memory for urb-buffer allocation.\n");
                        usb_free_stream_buffers(stream);
index f3bc82e44a288b2381066c61683d2be93e55039d..1aeacb1c4af7b034ba17c2bd46f43af9fac47bc6 100644 (file)
@@ -36,7 +36,7 @@ struct l64781_state {
        struct dvb_frontend frontend;
 
        /* private demodulator data */
-       int first:1;
+       unsigned int first:1;
 };
 
 #define dprintk(args...) \
index 8135f3e76aeb3e1537e461061c1c014d646d81a4..10b121ada833b403b0ff4ef5140f5698f729532a 100644 (file)
@@ -1244,7 +1244,7 @@ static int ttusb_dec_init_usb(struct ttusb_dec *dec)
                        return -ENOMEM;
                }
                dec->irq_buffer = usb_buffer_alloc(dec->udev,IRQ_PACKET_SIZE,
-                                       SLAB_ATOMIC, &dec->irq_dma_handle);
+                                       GFP_ATOMIC, &dec->irq_dma_handle);
                if(!dec->irq_buffer) {
                        return -ENOMEM;
                }
index 6d96b17a7f818b018daacf163f8c8c38dbc26310..920b63f8cf051274d8459d2b828a2dd49263d759 100644 (file)
@@ -173,38 +173,6 @@ config RADIO_MAESTRO
          To compile this driver as a module, choose M here: the
          module will be called radio-maestro.
 
-config RADIO_MIROPCM20
-       tristate "miroSOUND PCM20 radio"
-       depends on ISA && VIDEO_V4L1 && SOUND_ACI_MIXER
-       ---help---
-         Choose Y here if you have this FM radio card. You also need to say Y
-         to "ACI mixer (miroSOUND PCM1-pro/PCM12/PCM20 radio)" (in "Sound")
-         for this to work.
-
-         In order to control your radio card, you will need to use programs
-         that are compatible with the Video For Linux API.  Information on
-         this API and pointers to "v4l" programs may be found at
-         <file:Documentation/video4linux/API.html>.
-
-         To compile this driver as a module, choose M here: the
-         module will be called miropcm20.
-
-config RADIO_MIROPCM20_RDS
-       tristate "miroSOUND PCM20 radio RDS user interface (EXPERIMENTAL)"
-       depends on RADIO_MIROPCM20 && EXPERIMENTAL
-       ---help---
-         Choose Y here if you want to see RDS/RBDS information like
-         RadioText, Programme Service name, Clock Time and date, Programme
-         Type and Traffic Announcement/Programme identification.
-
-         It's not possible to read the raw RDS packets from the device, so
-         the driver cant provide an V4L interface for this.  But the
-         availability of RDS is reported over V4L by the basic driver
-         already.  Here RDS can be read from files in /dev/v4l/rds.
-
-         To compile this driver as a module, choose M here: the
-         module will be called miropcm20-rds.
-
 config RADIO_SF16FMI
        tristate "SF16FMI Radio"
        depends on ISA && VIDEO_V4L2
index d82a488f12a6a5214ff15bdea70a6b4fdde51102..f065ad12cc6119c3ca69db39d74e74ff827a612d 100644 (file)
@@ -118,7 +118,7 @@ static int native_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                ret = file->f_op->unlocked_ioctl(file, cmd, arg);
        else if (file->f_op->ioctl) {
                lock_kernel();
-               ret = file->f_op->ioctl(file->f_dentry->d_inode, file, cmd, arg);
+               ret = file->f_op->ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
                unlock_kernel();
        }
 
index cf43df3fe708c8eeba0fb4da03ab61b2fe5f7f7d..e1b56dc13c3f4c5f4dfa382d0c5036c54640db63 100644 (file)
@@ -56,7 +56,7 @@
 #include <media/tvaudio.h>
 #include <media/msp3400.h>
 #include <linux/kthread.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 #include "msp3400-driver.h"
 
 /* ---------------------------------------------------------------------- */
index fcaef4bf82896da5e5c20d463fca436835cc75b1..d506dfaa45a991c4c895d23625c68ef7281b0778 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/init.h>
 #include <linux/smp_lock.h>
 #include <linux/kthread.h>
+#include <linux/freezer.h>
 
 #include <media/tvaudio.h>
 #include <media/v4l2-common.h>
index f53edf1923b7de3fa558c2adf4c42980f97ad608..fcc5467e76364f982168b6d3d49077707a8edbde 100644 (file)
@@ -20,7 +20,7 @@
 #include <linux/fs.h>
 #include <linux/kthread.h>
 #include <linux/file.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 
 #include <media/video-buf.h>
 #include <media/video-buf-dvb.h>
index d424a4129d69ba188772282ec9f29a95374218c9..41ec0c4b35a2a00989ec39d318d1390f628d9624 100644 (file)
@@ -105,7 +105,7 @@ static DEFINE_MUTEX(videodev_lock);
 
 struct video_device* video_devdata(struct file *file)
 {
-       return video_device[iminor(file->f_dentry->d_inode)];
+       return video_device[iminor(file->f_path.dentry->d_inode)];
 }
 
 /*
index 3c8dc72dc8e971662b7267d545ee71e8e98a22b9..9986de5cb3d6d46860ee9ad6e12fdf6e498683fe 100644 (file)
@@ -36,6 +36,7 @@
 #include <media/v4l2-common.h>
 #include <linux/kthread.h>
 #include <linux/highmem.h>
+#include <linux/freezer.h>
 
 /* Wake up at about 30 fps */
 #define WAKE_NUMERATOR 30
index c7f6f6488360a191c8fa1eb713c76fd0c79ee88d..c374c76b37531efcf3b18f5124cf1e7106f7d8a9 100644 (file)
@@ -144,7 +144,7 @@ static int zoran_open(struct inode *inode, struct file *file)
 static ssize_t zoran_write(struct file *file, const char __user *buffer,
                        size_t count, loff_t *ppos)
 {
-       struct zoran *zr = PDE(file->f_dentry->d_inode)->data;
+       struct zoran *zr = PDE(file->f_path.dentry->d_inode)->data;
        char *string, *sp;
        char *line, *ldelim, *varname, *svar, *tdelim;
 
@@ -165,7 +165,7 @@ static ssize_t zoran_write(struct file *file, const char __user *buffer,
        }
        string[count] = 0;
        dprintk(4, KERN_INFO "%s: write_proc: name=%s count=%zu zr=%p\n",
-               ZR_DEVNAME(zr), file->f_dentry->d_name.name, count, zr);
+               ZR_DEVNAME(zr), file->f_path.dentry->d_name.name, count, zr);
        ldelim = " \t\n";
        tdelim = "=";
        line = strpbrk(sp, ldelim);
index 051b7c5b8f03a6da69bef8edde3488f841638b46..6e068cf1049beed6ef94ff42d79e88c5a8809831 100644 (file)
@@ -347,7 +347,7 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     mpt_interrupt - MPT adapter (IOC) specific interrupt handler.
  *     @irq: irq number (not used)
  *     @bus_id: bus identifier cookie == pointer to MPT_ADAPTER structure
@@ -387,14 +387,16 @@ mpt_interrupt(int irq, void *bus_id)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
- *     mpt_base_reply - MPT base driver's callback routine; all base driver
- *     "internal" request/reply processing is routed here.
- *     Currently used for EventNotification and EventAck handling.
+/**
+ *     mpt_base_reply - MPT base driver's callback routine
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @mf: Pointer to original MPT request frame
  *     @reply: Pointer to MPT reply frame (NULL if TurboReply)
  *
+ *     MPT base driver's callback routine; all base driver
+ *     "internal" request/reply processing is routed here.
+ *     Currently used for EventNotification and EventAck handling.
+ *
  *     Returns 1 indicating original alloc'd request frame ptr
  *     should be freed, or 0 if it shouldn't.
  */
@@ -530,7 +532,7 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply)
  *     @dclass: Protocol driver's class (%MPT_DRIVER_CLASS enum value)
  *
  *     This routine is called by a protocol-specific driver (SCSI host,
- *     LAN, SCSI target) to register it's reply callback routine.  Each
+ *     LAN, SCSI target) to register its reply callback routine.  Each
  *     protocol-specific driver must do this before it will be able to
  *     use any IOC resources, such as obtaining request frames.
  *
@@ -572,7 +574,7 @@ mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass)
  *     mpt_deregister - Deregister a protocol drivers resources.
  *     @cb_idx: previously registered callback handle
  *
- *     Each protocol-specific driver should call this routine when it's
+ *     Each protocol-specific driver should call this routine when its
  *     module is unloaded.
  */
 void
@@ -617,7 +619,7 @@ mpt_event_register(int cb_idx, MPT_EVHANDLER ev_cbfunc)
  *
  *     Each protocol-specific driver should call this routine
  *     when it does not (or can no longer) handle events,
- *     or when it's module is unloaded.
+ *     or when its module is unloaded.
  */
 void
 mpt_event_deregister(int cb_idx)
@@ -656,7 +658,7 @@ mpt_reset_register(int cb_idx, MPT_RESETHANDLER reset_func)
  *
  *     Each protocol-specific driver should call this routine
  *     when it does not (or can no longer) handle IOC reset handling,
- *     or when it's module is unloaded.
+ *     or when its module is unloaded.
  */
 void
 mpt_reset_deregister(int cb_idx)
@@ -670,6 +672,8 @@ mpt_reset_deregister(int cb_idx)
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
  *     mpt_device_driver_register - Register device driver hooks
+ *     @dd_cbfunc: driver callbacks struct
+ *     @cb_idx: MPT protocol driver index
  */
 int
 mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx)
@@ -696,6 +700,7 @@ mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx)
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
  *     mpt_device_driver_deregister - DeRegister device driver hooks
+ *     @cb_idx: MPT protocol driver index
  */
 void
 mpt_device_driver_deregister(int cb_idx)
@@ -887,8 +892,7 @@ mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr)
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
- *     mpt_send_handshake_request - Send MPT request via doorbell
- *     handshake method.
+ *     mpt_send_handshake_request - Send MPT request via doorbell handshake method.
  *     @handle: Handle of registered MPT protocol driver
  *     @ioc: Pointer to MPT adapter structure
  *     @reqBytes: Size of the request in bytes
@@ -981,10 +985,13 @@ mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req,
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
- * mpt_host_page_access_control - provides mechanism for the host
- * driver to control the IOC's Host Page Buffer access.
+ * mpt_host_page_access_control - control the IOC's Host Page Buffer access
  * @ioc: Pointer to MPT adapter structure
  * @access_control_value: define bits below
+ * @sleepFlag: Specifies whether the process can sleep
+ *
+ * Provides mechanism for the host driver to control the IOC's
+ * Host Page Buffer access.
  *
  * Access Control Value - bits[15:12]
  * 0h Reserved
@@ -1022,10 +1029,10 @@ mpt_host_page_access_control(MPT_ADAPTER *ioc, u8 access_control_value, int slee
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
  *     mpt_host_page_alloc - allocate system memory for the fw
- *     If we already allocated memory in past, then resend the same pointer.
- *     ioc@: Pointer to pointer to IOC adapter
- *     ioc_init@: Pointer to ioc init config page
+ *     @ioc: Pointer to pointer to IOC adapter
+ *     @ioc_init: Pointer to ioc init config page
  *
+ *     If we already allocated memory in past, then resend the same pointer.
  *     Returns 0 for success, non-zero for failure.
  */
 static int
@@ -1091,12 +1098,15 @@ return 0;
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
- *     mpt_verify_adapter - Given a unique IOC identifier, set pointer to
- *     the associated MPT adapter structure.
+ *     mpt_verify_adapter - Given IOC identifier, set pointer to its adapter structure.
  *     @iocid: IOC unique identifier (integer)
  *     @iocpp: Pointer to pointer to IOC adapter
  *
- *     Returns iocid and sets iocpp.
+ *     Given a unique IOC identifier, set pointer to the associated MPT
+ *     adapter structure.
+ *
+ *     Returns iocid and sets iocpp if iocid is found.
+ *     Returns -1 if iocid is not found.
  */
 int
 mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp)
@@ -1115,9 +1125,10 @@ mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     mpt_attach - Install a PCI intelligent MPT adapter.
  *     @pdev: Pointer to pci_dev structure
+ *     @id: PCI device ID information
  *
  *     This routine performs all the steps necessary to bring the IOC of
  *     a MPT adapter to a OPERATIONAL state.  This includes registering
@@ -1417,10 +1428,9 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     mpt_detach - Remove a PCI intelligent MPT adapter.
  *     @pdev: Pointer to pci_dev structure
- *
  */
 
 void
@@ -1466,10 +1476,10 @@ mpt_detach(struct pci_dev *pdev)
  */
 #ifdef CONFIG_PM
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     mpt_suspend - Fusion MPT base driver suspend routine.
- *
- *
+ *     @pdev: Pointer to pci_dev structure
+ *     @state: new state to enter
  */
 int
 mpt_suspend(struct pci_dev *pdev, pm_message_t state)
@@ -1505,10 +1515,9 @@ mpt_suspend(struct pci_dev *pdev, pm_message_t state)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     mpt_resume - Fusion MPT base driver resume routine.
- *
- *
+ *     @pdev: Pointer to pci_dev structure
  */
 int
 mpt_resume(struct pci_dev *pdev)
@@ -1566,7 +1575,7 @@ mpt_signal_reset(int index, MPT_ADAPTER *ioc, int reset_phase)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     mpt_do_ioc_recovery - Initialize or recover MPT adapter.
  *     @ioc: Pointer to MPT adapter structure
  *     @reason: Event word / reason
@@ -1892,13 +1901,15 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
- *     mpt_detect_bound_ports - Search for PCI bus/dev_function
- *     which matches PCI bus/dev_function (+/-1) for newly discovered 929,
- *     929X, 1030 or 1035.
+/**
+ *     mpt_detect_bound_ports - Search for matching PCI bus/dev_function
  *     @ioc: Pointer to MPT adapter structure
  *     @pdev: Pointer to (struct pci_dev) structure
  *
+ *     Search for PCI bus/dev_function which matches
+ *     PCI bus/dev_function (+/-1) for newly discovered 929,
+ *     929X, 1030 or 1035.
+ *
  *     If match on PCI dev_function +/-1 is found, bind the two MPT adapters
  *     using alt_ioc pointer fields in their %MPT_ADAPTER structures.
  */
@@ -1945,9 +1956,9 @@ mpt_detect_bound_ports(MPT_ADAPTER *ioc, struct pci_dev *pdev)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     mpt_adapter_disable - Disable misbehaving MPT adapter.
- *     @this: Pointer to MPT adapter structure
+ *     @ioc: Pointer to MPT adapter structure
  */
 static void
 mpt_adapter_disable(MPT_ADAPTER *ioc)
@@ -2046,9 +2057,8 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
- *     mpt_adapter_dispose - Free all resources associated with a MPT
- *     adapter.
+/**
+ *     mpt_adapter_dispose - Free all resources associated with an MPT adapter
  *     @ioc: Pointer to MPT adapter structure
  *
  *     This routine unregisters h/w resources and frees all alloc'd memory
@@ -2099,8 +2109,8 @@ mpt_adapter_dispose(MPT_ADAPTER *ioc)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
- *     MptDisplayIocCapabilities - Disply IOC's capacilities.
+/**
+ *     MptDisplayIocCapabilities - Disply IOC's capabilities.
  *     @ioc: Pointer to MPT adapter structure
  */
 static void
@@ -2142,7 +2152,7 @@ MptDisplayIocCapabilities(MPT_ADAPTER *ioc)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     MakeIocReady - Get IOC to a READY state, using KickStart if needed.
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @force: Force hard KickStart of IOC
@@ -2279,7 +2289,7 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     mpt_GetIocState - Get the current state of a MPT adapter.
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @cooked: Request raw or cooked IOC state
@@ -2304,7 +2314,7 @@ mpt_GetIocState(MPT_ADAPTER *ioc, int cooked)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     GetIocFacts - Send IOCFacts request to MPT adapter.
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @sleepFlag: Specifies whether the process can sleep
@@ -2478,7 +2488,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     GetPortFacts - Send PortFacts request to MPT adapter.
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @portnum: Port number
@@ -2545,7 +2555,7 @@ GetPortFacts(MPT_ADAPTER *ioc, int portnum, int sleepFlag)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     SendIocInit - Send IOCInit request to MPT adapter.
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @sleepFlag: Specifies whether the process can sleep
@@ -2630,7 +2640,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
        }
 
        /* No need to byte swap the multibyte fields in the reply
-        * since we don't even look at it's contents.
+        * since we don't even look at its contents.
         */
 
        dhsprintk((MYIOC_s_INFO_FMT "Sending PortEnable (req @ %p)\n",
@@ -2672,7 +2682,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     SendPortEnable - Send PortEnable request to MPT adapter port.
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @portnum: Port number to enable
@@ -2723,9 +2733,13 @@ SendPortEnable(MPT_ADAPTER *ioc, int portnum, int sleepFlag)
        return rc;
 }
 
-/*
- *     ioc: Pointer to MPT_ADAPTER structure
- *      size - total FW bytes
+/**
+ *     mpt_alloc_fw_memory - allocate firmware memory
+ *     @ioc: Pointer to MPT_ADAPTER structure
+ *      @size: total FW bytes
+ *
+ *     If memory has already been allocated, the same (cached) value
+ *     is returned.
  */
 void
 mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size)
@@ -2742,9 +2756,12 @@ mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size)
                        ioc->alloc_total += size;
        }
 }
-/*
- * If alt_img is NULL, delete from ioc structure.
- * Else, delete a secondary image in same format.
+/**
+ *     mpt_free_fw_memory - free firmware memory
+ *     @ioc: Pointer to MPT_ADAPTER structure
+ *
+ *     If alt_img is NULL, delete from ioc structure.
+ *     Else, delete a secondary image in same format.
  */
 void
 mpt_free_fw_memory(MPT_ADAPTER *ioc)
@@ -2763,7 +2780,7 @@ mpt_free_fw_memory(MPT_ADAPTER *ioc)
 
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     mpt_do_upload - Construct and Send FWUpload request to MPT adapter port.
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @sleepFlag: Specifies whether the process can sleep
@@ -2865,10 +2882,10 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     mpt_downloadboot - DownloadBoot code
  *     @ioc: Pointer to MPT_ADAPTER structure
- *     @flag: Specify which part of IOC memory is to be uploaded.
+ *     @pFwHeader: Pointer to firmware header info
  *     @sleepFlag: Specifies whether the process can sleep
  *
  *     FwDownloadBoot requires Programmed IO access.
@@ -3071,7 +3088,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     KickStart - Perform hard reset of MPT adapter.
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @force: Force hard reset
@@ -3145,12 +3162,12 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     mpt_diag_reset - Perform hard reset of the adapter.
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @ignore: Set if to honor and clear to ignore
  *             the reset history bit
- *     @sleepflag: CAN_SLEEP if called in a non-interrupt thread,
+ *     @sleepFlag: CAN_SLEEP if called in a non-interrupt thread,
  *             else set to NO_SLEEP (use mdelay instead)
  *
  *     This routine places the adapter in diagnostic mode via the
@@ -3436,11 +3453,12 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     SendIocReset - Send IOCReset request to MPT adapter.
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @reset_type: reset type, expected values are
  *     %MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET or %MPI_FUNCTION_IO_UNIT_RESET
+ *     @sleepFlag: Specifies whether the process can sleep
  *
  *     Send IOCReset request to the MPT adapter.
  *
@@ -3494,11 +3512,12 @@ SendIocReset(MPT_ADAPTER *ioc, u8 reset_type, int sleepFlag)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
- *     initChainBuffers - Allocate memory for and initialize
- *     chain buffers, chain buffer control arrays and spinlock.
- *     @hd: Pointer to MPT_SCSI_HOST structure
- *     @init: If set, initialize the spin lock.
+/**
+ *     initChainBuffers - Allocate memory for and initialize chain buffers
+ *     @ioc: Pointer to MPT_ADAPTER structure
+ *
+ *     Allocates memory for and initializes chain buffers,
+ *     chain buffer control arrays and spinlock.
  */
 static int
 initChainBuffers(MPT_ADAPTER *ioc)
@@ -3594,7 +3613,7 @@ initChainBuffers(MPT_ADAPTER *ioc)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     PrimeIocFifos - Initialize IOC request and reply FIFOs.
  *     @ioc: Pointer to MPT_ADAPTER structure
  *
@@ -3891,15 +3910,15 @@ mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req,
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
- *     WaitForDoorbellAck - Wait for IOC to clear the IOP_DOORBELL_STATUS bit
- *     in it's IntStatus register.
+/**
+ *     WaitForDoorbellAck - Wait for IOC doorbell handshake acknowledge
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @howlong: How long to wait (in seconds)
  *     @sleepFlag: Specifies whether the process can sleep
  *
  *     This routine waits (up to ~2 seconds max) for IOC doorbell
- *     handshake ACKnowledge.
+ *     handshake ACKnowledge, indicated by the IOP_DOORBELL_STATUS
+ *     bit in its IntStatus register being clear.
  *
  *     Returns a negative value on failure, else wait loop count.
  */
@@ -3942,14 +3961,14 @@ WaitForDoorbellAck(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
- *     WaitForDoorbellInt - Wait for IOC to set the HIS_DOORBELL_INTERRUPT bit
- *     in it's IntStatus register.
+/**
+ *     WaitForDoorbellInt - Wait for IOC to set its doorbell interrupt bit
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @howlong: How long to wait (in seconds)
  *     @sleepFlag: Specifies whether the process can sleep
  *
- *     This routine waits (up to ~2 seconds max) for IOC doorbell interrupt.
+ *     This routine waits (up to ~2 seconds max) for IOC doorbell interrupt
+ *     (MPI_HIS_DOORBELL_INTERRUPT) to be set in the IntStatus register.
  *
  *     Returns a negative value on failure, else wait loop count.
  */
@@ -3991,8 +4010,8 @@ WaitForDoorbellInt(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
- *     WaitForDoorbellReply - Wait for and capture a IOC handshake reply.
+/**
+ *     WaitForDoorbellReply - Wait for and capture an IOC handshake reply.
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @howlong: How long to wait (in seconds)
  *     @sleepFlag: Specifies whether the process can sleep
@@ -4077,7 +4096,7 @@ WaitForDoorbellReply(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     GetLanConfigPages - Fetch LANConfig pages.
  *     @ioc: Pointer to MPT_ADAPTER structure
  *
@@ -4188,12 +4207,9 @@ GetLanConfigPages(MPT_ADAPTER *ioc)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
- *     mptbase_sas_persist_operation - Perform operation on SAS Persitent Table
+/**
+ *     mptbase_sas_persist_operation - Perform operation on SAS Persistent Table
  *     @ioc: Pointer to MPT_ADAPTER structure
- *     @sas_address: 64bit SAS Address for operation.
- *     @target_id: specified target for operation
- *     @bus: specified bus for operation
  *     @persist_opcode: see below
  *
  *     MPI_SAS_OP_CLEAR_NOT_PRESENT - Free all persist TargetID mappings for
@@ -4202,7 +4218,7 @@ GetLanConfigPages(MPT_ADAPTER *ioc)
  *
  *     NOTE: Don't use not this function during interrupt time.
  *
- *     Returns: 0 for success, non-zero error
+ *     Returns 0 for success, non-zero error
  */
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -4399,7 +4415,7 @@ mptbase_raid_process_event_data(MPT_ADAPTER *ioc,
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     GetIoUnitPage2 - Retrieve BIOS version and boot order information.
  *     @ioc: Pointer to MPT_ADAPTER structure
  *
@@ -4457,7 +4473,8 @@ GetIoUnitPage2(MPT_ADAPTER *ioc)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*     mpt_GetScsiPortSettings - read SCSI Port Page 0 and 2
+/**
+ *     mpt_GetScsiPortSettings - read SCSI Port Page 0 and 2
  *     @ioc: Pointer to a Adapter Strucutre
  *     @portnum: IOC port number
  *
@@ -4644,7 +4661,8 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*     mpt_readScsiDevicePageHeaders - save version and length of SDP1
+/**
+ *     mpt_readScsiDevicePageHeaders - save version and length of SDP1
  *     @ioc: Pointer to a Adapter Strucutre
  *     @portnum: IOC port number
  *
@@ -4996,9 +5014,8 @@ mpt_read_ioc_pg_1(MPT_ADAPTER *ioc)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
- *     SendEventNotification - Send EventNotification (on or off) request
- *     to MPT adapter.
+/**
+ *     SendEventNotification - Send EventNotification (on or off) request to adapter
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @EvSwitch: Event switch flags
  */
@@ -5062,8 +5079,8 @@ SendEventAck(MPT_ADAPTER *ioc, EventNotificationReply_t *evnp)
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
  *     mpt_config - Generic function to issue config message
- *     @ioc - Pointer to an adapter structure
- *     @cfg - Pointer to a configuration structure. Struct contains
+ *     @ioc:   Pointer to an adapter structure
+ *     @pCfg:  Pointer to a configuration structure. Struct contains
  *             action, page address, direction, physical address
  *             and pointer to a configuration page header
  *             Page header is updated.
@@ -5188,8 +5205,8 @@ mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *pCfg)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
- *     mpt_timer_expired - Call back for timer process.
+/**
+ *     mpt_timer_expired - Callback for timer process.
  *     Used only internal config functionality.
  *     @data: Pointer to MPT_SCSI_HOST recast as an unsigned long
  */
@@ -5214,12 +5231,12 @@ mpt_timer_expired(unsigned long data)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     mpt_ioc_reset - Base cleanup for hard reset
  *     @ioc: Pointer to the adapter structure
  *     @reset_phase: Indicates pre- or post-reset functionality
  *
- *     Remark: Free's resources with internally generated commands.
+ *     Remark: Frees resources with internally generated commands.
  */
 static int
 mpt_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
@@ -5271,7 +5288,7 @@ mpt_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
  *     procfs (%MPT_PROCFS_MPTBASEDIR/...) support stuff...
  */
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     procmpt_create - Create %MPT_PROCFS_MPTBASEDIR entries.
  *
  *     Returns 0 for success, non-zero for failure.
@@ -5297,7 +5314,7 @@ procmpt_create(void)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     procmpt_destroy - Tear down %MPT_PROCFS_MPTBASEDIR entries.
  *
  *     Returns 0 for success, non-zero for failure.
@@ -5311,16 +5328,16 @@ procmpt_destroy(void)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
- *     procmpt_summary_read - Handle read request from /proc/mpt/summary
- *     or from /proc/mpt/iocN/summary.
+/**
+ *     procmpt_summary_read - Handle read request of a summary file
  *     @buf: Pointer to area to write information
  *     @start: Pointer to start pointer
  *     @offset: Offset to start writing
- *     @request:
+ *     @request: Amount of read data requested
  *     @eof: Pointer to EOF integer
  *     @data: Pointer
  *
+ *     Handles read request from /proc/mpt/summary or /proc/mpt/iocN/summary.
  *     Returns number of characters written to process performing the read.
  */
 static int
@@ -5355,12 +5372,12 @@ procmpt_summary_read(char *buf, char **start, off_t offset, int request, int *eo
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     procmpt_version_read - Handle read request from /proc/mpt/version.
  *     @buf: Pointer to area to write information
  *     @start: Pointer to start pointer
  *     @offset: Offset to start writing
- *     @request:
+ *     @request: Amount of read data requested
  *     @eof: Pointer to EOF integer
  *     @data: Pointer
  *
@@ -5411,12 +5428,12 @@ procmpt_version_read(char *buf, char **start, off_t offset, int request, int *eo
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     procmpt_iocinfo_read - Handle read request from /proc/mpt/iocN/info.
  *     @buf: Pointer to area to write information
  *     @start: Pointer to start pointer
  *     @offset: Offset to start writing
- *     @request:
+ *     @request: Amount of read data requested
  *     @eof: Pointer to EOF integer
  *     @data: Pointer
  *
@@ -5577,16 +5594,17 @@ mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buffer, int *size, int len, int sh
  */
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
- *     mpt_HardResetHandler - Generic reset handler, issue SCSI Task
- *     Management call based on input arg values.  If TaskMgmt fails,
- *     return associated SCSI request.
+ *     mpt_HardResetHandler - Generic reset handler
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @sleepFlag: Indicates if sleep or schedule must be called.
  *
+ *     Issues SCSI Task Management call based on input arg values.
+ *     If TaskMgmt fails, returns associated SCSI request.
+ *
  *     Remark: _HardResetHandler can be invoked from an interrupt thread (timer)
  *     or a non-interrupt thread.  In the former, must not call schedule().
  *
- *     Remark: A return of -1 is a FATAL error case, as it means a
+ *     Note: A return of -1 is a FATAL error case, as it means a
  *     FW reload/initialization failed.
  *
  *     Returns 0 for SUCCESS or -1 if FAILED.
@@ -5935,13 +5953,14 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
- *     ProcessEventNotification - Route a received EventNotificationReply to
- *     all currently regeistered event handlers.
+/**
+ *     ProcessEventNotification - Route EventNotificationReply to all event handlers
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @pEventReply: Pointer to EventNotification reply frame
  *     @evHandlers: Pointer to integer, number of event handlers
  *
+ *     Routes a received EventNotificationReply to all currently registered
+ *     event handlers.
  *     Returns sum of event handlers return values.
  */
 static int
@@ -6056,7 +6075,7 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     mpt_fc_log_info - Log information returned from Fibre Channel IOC.
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @log_info: U32 LogInfo reply word from the IOC
@@ -6077,7 +6096,7 @@ mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     mpt_spi_log_info - Log information returned from SCSI Parallel IOC.
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @mr: Pointer to MPT reply frame
@@ -6200,7 +6219,7 @@ mpt_spi_log_info(MPT_ADAPTER *ioc, u32 log_info)
        };
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     mpt_sas_log_info - Log information returned from SAS IOC.
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @log_info: U32 LogInfo reply word from the IOC
@@ -6255,7 +6274,7 @@ union loginfo_type {
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     mpt_sp_ioc_info - IOC information returned from SCSI Parallel IOC.
  *     @ioc: Pointer to MPT_ADAPTER structure
  *     @ioc_status: U32 IOCStatus word from IOC
@@ -6416,7 +6435,7 @@ EXPORT_SYMBOL(mpt_free_fw_memory);
 EXPORT_SYMBOL(mptbase_sas_persist_operation);
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     fusion_init - Fusion MPT base driver initialization routine.
  *
  *     Returns 0 for success, non-zero for failure.
@@ -6456,7 +6475,7 @@ fusion_init(void)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
+/**
  *     fusion_exit - Perform driver unload cleanup.
  *
  *     This routine frees all resources associated with each MPT adapter
index ef2b55e199105458bb8351d3ccfd118423feed18..ca2f9107f1459ff465b6ea7244d7ce24d5038117 100644 (file)
@@ -1395,8 +1395,7 @@ mptfc_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
- *     mptfc_init - Register MPT adapter(s) as SCSI host(s) with
- *     linux scsi mid-layer.
+ *     mptfc_init - Register MPT adapter(s) as SCSI host(s) with SCSI mid-layer.
  *
  *     Returns 0 for success, non-zero for failure.
  */
@@ -1440,7 +1439,7 @@ mptfc_init(void)
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
- *     mptfc_remove - Removed fc infrastructure for devices
+ *     mptfc_remove - Remove fc infrastructure for devices
  *     @pdev: Pointer to pci_dev structure
  *
  */
index 30524dc54b16b720dea158f45c5f477ff446cf19..2c72c36b8171cd67f26114c9c2f97b4d70b0b2d6 100644 (file)
@@ -1230,15 +1230,15 @@ mptscsih_host_info(MPT_ADAPTER *ioc, char *pbuf, off_t offset, int len)
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
  *     mptscsih_proc_info - Return information about MPT adapter
+ *     @host:   scsi host struct
+ *     @buffer: if write, user data; if read, buffer for user
+ *     @start: returns the buffer address
+ *     @offset: if write, 0; if read, the current offset into the buffer from
+ *              the previous read.
+ *     @length: if write, return length;
+ *     @func:   write = 1; read = 0
  *
  *     (linux scsi_host_template.info routine)
- *
- *     buffer: if write, user data; if read, buffer for user
- *     length: if write, return length;
- *     offset: if write, 0; if read, the current offset into the buffer from
- *             the previous read.
- *     hostno: scsi host number
- *     func:   if write = 1; if read = 0
  */
 int
 mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
@@ -1902,8 +1902,7 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
- *     mptscsih_host_reset - Perform a SCSI host adapter RESET!
- *     new_eh variant
+ *     mptscsih_host_reset - Perform a SCSI host adapter RESET (new_eh variant)
  *     @SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to
  *
  *     (linux scsi_host_template.eh_host_reset_handler routine)
@@ -1949,8 +1948,7 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
- *     mptscsih_tm_pending_wait - wait for pending task management request to
- *             complete.
+ *     mptscsih_tm_pending_wait - wait for pending task management request to complete
  *     @hd: Pointer to MPT host structure.
  *
  *     Returns {SUCCESS,FAILED}.
@@ -1982,6 +1980,7 @@ mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd)
 /**
  *     mptscsih_tm_wait_for_completion - wait for completion of TM task
  *     @hd: Pointer to MPT host structure.
+ *     @timeout: timeout in seconds
  *
  *     Returns {SUCCESS,FAILED}.
  */
@@ -3429,8 +3428,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
 /**
  *     mptscsih_synchronize_cache - Send SYNCHRONIZE_CACHE to all disks.
  *     @hd: Pointer to a SCSI HOST structure
- *     @vtarget: per device private data
- *     @lun: lun
+ *     @vdevice: virtual target device
  *
  *     Uses the ISR, but with special processing.
  *     MUST be single-threaded.
index f422c0d0621c9d95274f98e61cad0e44e9dd21a1..36641da59289eea7a4468892d1a85a48503737b5 100644 (file)
@@ -1100,8 +1100,7 @@ static struct pci_driver mptspi_driver = {
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
- *     mptspi_init - Register MPT adapter(s) as SCSI host(s) with
- *     linux scsi mid-layer.
+ *     mptspi_init - Register MPT adapter(s) as SCSI host(s) with SCSI mid-layer.
  *
  *     Returns 0 for success, non-zero for failure.
  */
@@ -1135,7 +1134,6 @@ mptspi_init(void)
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
  *     mptspi_exit - Unregisters MPT adapter(s)
- *
  */
 static void __exit
 mptspi_exit(void)
index d96c687aee9373fe7638fa61bb88e335b58b65ea..c463dc2efc09490b26bdc6e2d0e46fdd694dce74 100644 (file)
@@ -56,6 +56,9 @@ static int i2o_bus_scan(struct i2o_device *dev)
 /**
  *     i2o_bus_store_scan - Scan the I2O Bus Adapter
  *     @d: device which should be scanned
+ *     @attr: device_attribute
+ *     @buf: output buffer
+ *     @count: buffer size
  *
  *     Returns count.
  */
index ee183053fa23a54d23785446b4ba7585e3beb7ed..b9df143e4ff1962cb049ba11e8166425ffdd8b9f 100644 (file)
@@ -54,8 +54,8 @@ static inline int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd,
  *     @dev: I2O device to claim
  *     @drv: I2O driver which wants to claim the device
  *
- *     Do the leg work to assign a device to a given OSM. If the claim succeed
- *     the owner of the rimary. If the attempt fails a negative errno code
+ *     Do the leg work to assign a device to a given OSM. If the claim succeeds,
+ *     the owner is the primary. If the attempt fails a negative errno code
  *     is returned. On success zero is returned.
  */
 int i2o_device_claim(struct i2o_device *dev)
@@ -208,24 +208,23 @@ static struct i2o_device *i2o_device_alloc(void)
 
 /**
  *     i2o_device_add - allocate a new I2O device and add it to the IOP
- *     @iop: I2O controller where the device is on
+ *     @c: I2O controller that the device is on
  *     @entry: LCT entry of the I2O device
  *
  *     Allocate a new I2O device and initialize it with the LCT entry. The
  *     device is appended to the device list of the controller.
  *
- *     Returns a pointer to the I2O device on success or negative error code
- *     on failure.
+ *     Returns zero on success, or a -ve errno.
  */
-static struct i2o_device *i2o_device_add(struct i2o_controller *c,
-                                        i2o_lct_entry * entry)
+static int i2o_device_add(struct i2o_controller *c, i2o_lct_entry *entry)
 {
        struct i2o_device *i2o_dev, *tmp;
+       int rc;
 
        i2o_dev = i2o_device_alloc();
        if (IS_ERR(i2o_dev)) {
                printk(KERN_ERR "i2o: unable to allocate i2o device\n");
-               return i2o_dev;
+               return PTR_ERR(i2o_dev);
        }
 
        i2o_dev->lct_data = *entry;
@@ -236,7 +235,9 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c,
        i2o_dev->iop = c;
        i2o_dev->device.parent = &c->device;
 
-       device_register(&i2o_dev->device);
+       rc = device_register(&i2o_dev->device);
+       if (rc)
+               goto err;
 
        list_add_tail(&i2o_dev->list, &c->devices);
 
@@ -270,12 +271,16 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c,
 
        pr_debug("i2o: device %s added\n", i2o_dev->device.bus_id);
 
-       return i2o_dev;
+       return 0;
+
+err:
+       kfree(i2o_dev);
+       return rc;
 }
 
 /**
  *     i2o_device_remove - remove an I2O device from the I2O core
- *     @dev: I2O device which should be released
+ *     @i2o_dev: I2O device which should be released
  *
  *     Is used on I2O controller removal or LCT modification, when the device
  *     is removed from the system. Note that the device could still hang
index 7fc7399bd2ec05e4b785293d306165c39bb07d71..9104b65ff70f0e85de7522deddd017313159edf6 100644 (file)
@@ -34,9 +34,7 @@ static spinlock_t i2o_drivers_lock;
 static struct i2o_driver **i2o_drivers;
 
 /**
- *     i2o_bus_match - Tell if a I2O device class id match the class ids of
- *                     the I2O driver (OSM)
- *
+ *     i2o_bus_match - Tell if I2O device class id matches the class ids of the I2O driver (OSM)
  *     @dev: device which should be verified
  *     @drv: the driver to match against
  *
@@ -248,7 +246,7 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
 
 /**
  *     i2o_driver_notify_controller_add_all - Send notify of added controller
- *                                            to all I2O drivers
+ *     @c: newly added controller
  *
  *     Send notifications to all registered drivers that a new controller was
  *     added.
@@ -267,8 +265,8 @@ void i2o_driver_notify_controller_add_all(struct i2o_controller *c)
 }
 
 /**
- *     i2o_driver_notify_controller_remove_all - Send notify of removed
- *                                               controller to all I2O drivers
+ *     i2o_driver_notify_controller_remove_all - Send notify of removed controller
+ *     @c: controller that is being removed
  *
  *     Send notifications to all registered drivers that a controller was
  *     removed.
@@ -287,8 +285,8 @@ void i2o_driver_notify_controller_remove_all(struct i2o_controller *c)
 }
 
 /**
- *     i2o_driver_notify_device_add_all - Send notify of added device to all
- *                                        I2O drivers
+ *     i2o_driver_notify_device_add_all - Send notify of added device
+ *     @i2o_dev: newly added I2O device
  *
  *     Send notifications to all registered drivers that a device was added.
  */
@@ -306,8 +304,8 @@ void i2o_driver_notify_device_add_all(struct i2o_device *i2o_dev)
 }
 
 /**
- *     i2o_driver_notify_device_remove_all - Send notify of removed device to
- *                                           all I2O drivers
+ *     i2o_driver_notify_device_remove_all - Send notify of removed device
+ *     @i2o_dev: device that is being removed
  *
  *     Send notifications to all registered drivers that a device was removed.
  */
@@ -362,7 +360,7 @@ int __init i2o_driver_init(void)
 /**
  *     i2o_driver_exit - clean up I2O drivers (OSMs)
  *
- *     Unregisters the I2O bus and free driver array.
+ *     Unregisters the I2O bus and frees driver array.
  */
 void __exit i2o_driver_exit(void)
 {
index 9e529d8dd5cbb8d140bca1453144bc85fb27fbd6..902753b2c66101858fe295e7bc97c24cff674389 100644 (file)
@@ -94,8 +94,8 @@ static struct i2o_exec_wait *i2o_exec_wait_alloc(void)
 };
 
 /**
- *     i2o_exec_wait_free - Free a i2o_exec_wait struct
- *     @i2o_exec_wait: I2O wait data which should be cleaned up
+ *     i2o_exec_wait_free - Free an i2o_exec_wait struct
+ *     @wait: I2O wait data which should be cleaned up
  */
 static void i2o_exec_wait_free(struct i2o_exec_wait *wait)
 {
@@ -105,7 +105,7 @@ static void i2o_exec_wait_free(struct i2o_exec_wait *wait)
 /**
  *     i2o_msg_post_wait_mem - Post and wait a message with DMA buffers
  *     @c: controller
- *     @m: message to post
+ *     @msg: message to post
  *     @timeout: time in seconds to wait
  *     @dma: i2o_dma struct of the DMA buffer to free on failure
  *
@@ -269,6 +269,7 @@ static int i2o_msg_post_wait_complete(struct i2o_controller *c, u32 m,
 /**
  *     i2o_exec_show_vendor_id - Displays Vendor ID of controller
  *     @d: device of which the Vendor ID should be displayed
+ *     @attr: device_attribute to display
  *     @buf: buffer into which the Vendor ID should be printed
  *
  *     Returns number of bytes printed into buffer.
@@ -290,6 +291,7 @@ static ssize_t i2o_exec_show_vendor_id(struct device *d,
 /**
  *     i2o_exec_show_product_id - Displays Product ID of controller
  *     @d: device of which the Product ID should be displayed
+ *     @attr: device_attribute to display
  *     @buf: buffer into which the Product ID should be printed
  *
  *     Returns number of bytes printed into buffer.
@@ -365,7 +367,7 @@ static int i2o_exec_remove(struct device *dev)
 
 /**
  *     i2o_exec_lct_modified - Called on LCT NOTIFY reply
- *     @c: I2O controller on which the LCT has modified
+ *     @work: work struct for a specific controller
  *
  *     This function handles asynchronus LCT NOTIFY replies. It parses the
  *     new LCT and if the buffer for the LCT was to small sends a LCT NOTIFY
index 70ae0025332120b0070f8e7b5fd409a9651b2217..da9859f2caf2b3e083ebbc665d7e67a1268e5cca 100644 (file)
@@ -259,7 +259,7 @@ static int i2o_block_device_unlock(struct i2o_device *dev, u32 media_id)
 /**
  *     i2o_block_device_power - Power management for device dev
  *     @dev: I2O device which should receive the power management request
- *     @operation: Operation which should be send
+ *     @op: Operation to send
  *
  *     Send a power management request to the device dev.
  *
@@ -315,7 +315,7 @@ static inline struct i2o_block_request *i2o_block_request_alloc(void)
  *     i2o_block_request_free - Frees a I2O block request
  *     @ireq: I2O block request which should be freed
  *
- *     Fres the allocated memory (give it back to the request mempool).
+ *     Frees the allocated memory (give it back to the request mempool).
  */
 static inline void i2o_block_request_free(struct i2o_block_request *ireq)
 {
@@ -326,6 +326,7 @@ static inline void i2o_block_request_free(struct i2o_block_request *ireq)
  *     i2o_block_sglist_alloc - Allocate the SG list and map it
  *     @c: I2O controller to which the request belongs
  *     @ireq: I2O block request
+ *     @mptr: message body pointer
  *
  *     Builds the SG list and map it to be accessable by the controller.
  *
@@ -490,7 +491,7 @@ static void i2o_block_end_request(struct request *req, int uptodate,
  *     i2o_block_reply - Block OSM reply handler.
  *     @c: I2O controller from which the message arrives
  *     @m: message id of reply
- *     qmsg: the actuall I2O message reply
+ *     @msg: the actual I2O message reply
  *
  *     This function gets all the message replies.
  *
@@ -602,6 +603,8 @@ static void i2o_block_biosparam(unsigned long capacity, unsigned short *cyls,
 
 /**
  *     i2o_block_open - Open the block device
+ *     @inode: inode for block device being opened
+ *     @file: file to open
  *
  *     Power up the device, mount and lock the media. This function is called,
  *     if the block device is opened for access.
@@ -629,6 +632,8 @@ static int i2o_block_open(struct inode *inode, struct file *file)
 
 /**
  *     i2o_block_release - Release the I2O block device
+ *     @inode: inode for block device being released
+ *     @file: file to close
  *
  *     Unlock and unmount the media, and power down the device. Gets called if
  *     the block device is closed.
@@ -675,6 +680,8 @@ static int i2o_block_getgeo(struct block_device *bdev, struct hd_geometry *geo)
 
 /**
  *     i2o_block_ioctl - Issue device specific ioctl calls.
+ *     @inode: inode for block device ioctl
+ *     @file: file for ioctl
  *     @cmd: ioctl command
  *     @arg: arg
  *
@@ -902,7 +909,7 @@ static int i2o_block_transfer(struct request *req)
 
 /**
  *     i2o_block_request_fn - request queue handling function
- *     q: request queue from which the request could be fetched
+ *     @q: request queue from which the request could be fetched
  *
  *     Takes the next request from the queue, transfers it and if no error
  *     occurs dequeue it from the queue. On arrival of the reply the message
index d9fdc95b440da73e1001b6380e4b7a31ff6b8f41..67f921b4419b687b898e9655a52e70a08c289f30 100644 (file)
@@ -64,7 +64,7 @@
 
 /* I2O Block OSM mempool struct */
 struct i2o_block_mempool {
-       kmem_cache_t *slab;
+       struct kmem_cache *slab;
        mempool_t *pool;
 };
 
index 7d23e082bf26712ef886e401ed89ed2fd56c0f50..1de30d711671ce91ae354027fe36f9b2e2e508fb 100644 (file)
@@ -265,7 +265,11 @@ static int i2o_cfg_swdl(unsigned long arg)
                return -ENOMEM;
        }
 
-       __copy_from_user(buffer.virt, kxfer.buf, fragsize);
+       if (__copy_from_user(buffer.virt, kxfer.buf, fragsize)) {
+               i2o_msg_nop(c, msg);
+               i2o_dma_free(&c->pdev->dev, &buffer);
+               return -EFAULT;
+       }
 
        msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_7);
        msg->u.head[1] =
@@ -516,7 +520,6 @@ static int i2o_cfg_evt_get(unsigned long arg, struct file *fp)
        return 0;
 }
 
-#ifdef CONFIG_I2O_EXT_ADAPTEC
 #ifdef CONFIG_COMPAT
 static int i2o_cfg_passthru32(struct file *file, unsigned cmnd,
                              unsigned long arg)
@@ -759,6 +762,7 @@ static long i2o_cfg_compat_ioctl(struct file *file, unsigned cmd,
 
 #endif
 
+#ifdef CONFIG_I2O_EXT_ADAPTEC
 static int i2o_cfg_passthru(unsigned long arg)
 {
        struct i2o_cmd_passthru __user *cmd =
index 3d2e76eea93e9d8fb0779bd66462bc497d1237a2..a61cb17c5c12646cab01c5e0dc6026b5d76b6b05 100644 (file)
@@ -163,7 +163,7 @@ static int print_serial_number(struct seq_file *seq, u8 * serialno, int max_len)
  *     i2o_get_class_name -    do i2o class name lookup
  *     @class: class number
  *
- *     Return a descriptive string for an i2o class
+ *     Return a descriptive string for an i2o class.
  */
 static const char *i2o_get_class_name(int class)
 {
index 6ebf38213f9f87f336e77ce65134c9371ce612d6..1045c8a518bbbdb453ba9e40a951646b48e26bf2 100644 (file)
@@ -220,7 +220,7 @@ static int i2o_scsi_probe(struct device *dev)
        u32 id = -1;
        u64 lun = -1;
        int channel = -1;
-       int i;
+       int i, rc;
 
        i2o_shost = i2o_scsi_get_host(c);
        if (!i2o_shost)
@@ -304,14 +304,20 @@ static int i2o_scsi_probe(struct device *dev)
                return PTR_ERR(scsi_dev);
        }
 
-       sysfs_create_link(&i2o_dev->device.kobj, &scsi_dev->sdev_gendev.kobj,
-                         "scsi");
+       rc = sysfs_create_link(&i2o_dev->device.kobj,
+                              &scsi_dev->sdev_gendev.kobj, "scsi");
+       if (rc)
+               goto err;
 
        osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %ld\n",
                 i2o_dev->lct_data.tid, channel, le32_to_cpu(id),
                 (long unsigned int)le64_to_cpu(lun));
 
        return 0;
+
+err:
+       scsi_remove_device(scsi_dev);
+       return rc;
 };
 
 static const char *i2o_scsi_info(struct Scsi_Host *SChost)
@@ -405,8 +411,7 @@ static void i2o_scsi_notify_device_add(struct i2o_device *i2o_dev)
 };
 
 /**
- *     i2o_scsi_notify_device_remove - Retrieve notifications of removed
- *                                     devices
+ *     i2o_scsi_notify_device_remove - Retrieve notifications of removed devices
  *     @i2o_dev: the I2O device which was removed
  *
  *     If a I2O device is removed, we catch the notification to remove the
@@ -426,8 +431,7 @@ static void i2o_scsi_notify_device_remove(struct i2o_device *i2o_dev)
 };
 
 /**
- *     i2o_scsi_notify_controller_add - Retrieve notifications of added
- *                                      controllers
+ *     i2o_scsi_notify_controller_add - Retrieve notifications of added controllers
  *     @c: the controller which was added
  *
  *     If a I2O controller is added, we catch the notification to add a
@@ -457,8 +461,7 @@ static void i2o_scsi_notify_controller_add(struct i2o_controller *c)
 };
 
 /**
- *     i2o_scsi_notify_controller_remove - Retrieve notifications of removed
- *                                         controllers
+ *     i2o_scsi_notify_controller_remove - Retrieve notifications of removed controllers
  *     @c: the controller which was removed
  *
  *     If a I2O controller is removed, we catch the notification to remove the
@@ -745,7 +748,7 @@ static int i2o_scsi_abort(struct scsi_cmnd *SCpnt)
  *     @capacity: size in sectors
  *     @ip: geometry array
  *
- *     This is anyones guess quite frankly. We use the same rules everyone
+ *     This is anyone's guess quite frankly. We use the same rules everyone
  *     else appears to and hope. It seems to work.
  */
 
index 8287f95c8c422d85d6107c162c158fe22165e117..3661e6e065d27c705c86d0e5d215b24523939adc 100644 (file)
@@ -259,6 +259,7 @@ static irqreturn_t i2o_pci_interrupt(int irq, void *dev_id)
 
 /**
  *     i2o_pci_irq_enable - Allocate interrupt for I2O controller
+ *     @c: i2o_controller that the request is for
  *
  *     Allocate an interrupt for the I2O controller, and activate interrupts
  *     on the I2O controller.
@@ -305,7 +306,7 @@ static void i2o_pci_irq_disable(struct i2o_controller *c)
 
 /**
  *     i2o_pci_probe - Probe the PCI device for an I2O controller
- *     @dev: PCI device to test
+ *     @pdev: PCI device to test
  *     @id: id which matched with the PCI device id table
  *
  *     Probe the PCI device for any device which is a memory of the
@@ -447,7 +448,7 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
 
 /**
  *     i2o_pci_remove - Removes a I2O controller from the system
- *     pdev: I2O controller which should be removed
+ *     @pdev: I2O controller which should be removed
  *
  *     Reset the I2O controller, disable interrupts and remove all allocated
  *     resources.
index 82938ad6ddbd8282752af18c91dcdf37e33b392a..ce1a48108210d38f645d34caa1273ad4d0acd60d 100644 (file)
@@ -28,7 +28,7 @@
 #include <linux/string.h>
 #include <linux/input.h>
 #include <linux/device.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 #include <linux/slab.h>
 #include <linux/kthread.h>
 
index ee326136d03bf409d5604229255a9a9591396792..d61df5c3ac367cd8e38650c1c44c19db99f3785d 100644 (file)
@@ -219,8 +219,9 @@ static int tifm_device_remove(struct device *dev)
        struct tifm_driver *drv = fm_dev->drv;
 
        if (drv) {
-               if (drv->remove) drv->remove(fm_dev);
-               fm_dev->drv = 0;
+               if (drv->remove)
+                       drv->remove(fm_dev);
+               fm_dev->drv = NULL;
        }
 
        put_device(dev);
index f4f8ccaf5455c789bb723fb956fb08639225825f..4224686fdf2a16b73b8e531fc795e867dcc71c51 100644 (file)
@@ -91,11 +91,11 @@ config MMC_AU1X
 
          If unsure, say N.
 
-config MMC_AT91RM9200
-       tristate "AT91RM9200 SD/MMC Card Interface support"
-       depends on ARCH_AT91RM9200 && MMC
+config MMC_AT91
+       tristate "AT91 SD/MMC Card Interface support"
+       depends on ARCH_AT91 && MMC
        help
-         This selects the AT91RM9200 MCI controller.
+         This selects the AT91 MCI controller.
 
          If unsure, say N.
 
index acfd4de0aba526f5bc220ef33c0c50643bcbc896..83ffb9326a547498826a8ce576689eae0a74582e 100644 (file)
@@ -22,7 +22,7 @@ obj-$(CONFIG_MMC_SDHCI)               += sdhci.o
 obj-$(CONFIG_MMC_WBSD)         += wbsd.o
 obj-$(CONFIG_MMC_AU1X)         += au1xmmc.o
 obj-$(CONFIG_MMC_OMAP)         += omap.o
-obj-$(CONFIG_MMC_AT91RM9200)   += at91_mci.o
+obj-$(CONFIG_MMC_AT91)         += at91_mci.o
 obj-$(CONFIG_MMC_TIFM_SD)      += tifm_sd.o
 
 mmc_core-y := mmc.o mmc_sysfs.o
index 6495cd8a9306687478d9e03d6d471edf0973242c..4633dbc9a90fe38f9f7883ba66c3ce2e0990c1f5 100644 (file)
@@ -73,8 +73,8 @@
 #include <asm/mach/mmc.h>
 #include <asm/arch/board.h>
 #include <asm/arch/gpio.h>
-#include <asm/arch/at91rm9200_mci.h>
-#include <asm/arch/at91rm9200_pdc.h>
+#include <asm/arch/at91_mci.h>
+#include <asm/arch/at91_pdc.h>
 
 #define DRIVER_NAME "at91_mci"
 
index 447fba5825fd10854484452004455419fa1cd3a2..800527cf40d5c58be4792a2001ca7ed1daa383e9 100644 (file)
@@ -875,7 +875,7 @@ static void au1xmmc_init_dma(struct au1xmmc_host *host)
        host->rx_chan = rxchan;
 }
 
-struct const mmc_host_ops au1xmmc_ops = {
+static const struct mmc_host_ops au1xmmc_ops = {
        .request        = au1xmmc_request,
        .set_ios        = au1xmmc_set_ios,
 };
index 471e9f4e05306e7574469d87af2fcdfabe84ce3c..45a9283ce4988784cc231c069350488f3b693d21 100644 (file)
@@ -355,7 +355,7 @@ static int pxamci_get_ro(struct mmc_host *mmc)
        struct pxamci_host *host = mmc_priv(mmc);
 
        if (host->pdata && host->pdata->get_ro)
-               return host->pdata->get_ro(mmc->dev);
+               return host->pdata->get_ro(mmc_dev(mmc));
        /* Host doesn't support read only detection so assume writeable */
        return 0;
 }
@@ -383,7 +383,7 @@ static void pxamci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
                host->power_mode = ios->power_mode;
 
                if (host->pdata && host->pdata->setpower)
-                       host->pdata->setpower(mmc->dev, ios->vdd);
+                       host->pdata->setpower(mmc_dev(mmc), ios->vdd);
 
                if (ios->power_mode == MMC_POWER_ON)
                        host->cmdat |= CMDAT_INIT;
index e846499a004c676751659b40dc03e5c3e6ed509d..f18ad998b3cb05bf85925b83802c608dbfc899a1 100644 (file)
@@ -387,7 +387,7 @@ static void tifm_sd_prepare_data(struct tifm_sd *card, struct mmc_command *cmd)
 
        writel(TIFM_FIFO_INT_SETALL,
                sock->addr + SOCK_DMA_FIFO_INT_ENABLE_CLEAR);
-       writel(long_log2(cmd->data->blksz) - 2,
+       writel(ilog2(cmd->data->blksz) - 2,
                        sock->addr + SOCK_FIFO_PAGE_SIZE);
        writel(TIFM_FIFO_ENABLE, sock->addr + SOCK_FIFO_CONTROL);
        writel(TIFM_FIFO_INTMASK, sock->addr + SOCK_DMA_FIFO_INT_ENABLE_SET);
index ef4a731ca5c2d455468dbeb328eb93d661e6e67d..334e078ffafffcd07b0453a6b3458eea0e56f484 100644 (file)
@@ -451,7 +451,7 @@ static int __devinit m25p_probe(struct spi_device *spi)
                return -ENODEV;
        }
 
-       flash = kzalloc(sizeof *flash, SLAB_KERNEL);
+       flash = kzalloc(sizeof *flash, GFP_KERNEL);
        if (!flash)
                return -ENOMEM;
 
index 11d170afa9c398de778eb643a84ae6db843f700c..06e33786078d3ed937801a430fee1c6277e6bb26 100644 (file)
@@ -922,7 +922,7 @@ int __init init_module(void)
  * and then free up the resources we took when the card was found.
  */
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        struct net_device *dev = dev_3c501;
        unregister_netdev(dev);
index a34b2206132d2fb6d716419eddc0b20ee50b8a8f..7e34c4f07b70723668d27a4baa2c48d1a1c8a011 100644 (file)
@@ -726,7 +726,7 @@ static void cleanup_card(struct net_device *dev)
                iounmap(ei_status.mem);
 }
 
-void
+void __exit
 cleanup_module(void)
 {
        int this_dev;
index 458cb9cbe9157dcda0d458b920e1e6622446bf1f..702bfb2a5e99d047f82e6d2b80e46c48396108e2 100644 (file)
@@ -1670,7 +1670,7 @@ int __init init_module(void)
        return 0;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        int this_dev;
 
index aa43563610ae552df0cc25ea6051d9f1d44faf71..54e1d5aebed3af51a0ade5eedd3c032a3377428f 100644 (file)
@@ -940,7 +940,7 @@ int __init init_module(void)
        return IS_ERR(dev_3c507) ? PTR_ERR(dev_3c507) : 0;
 }
 
-void
+void __exit
 cleanup_module(void)
 {
        struct net_device *dev = dev_3c507;
index 91849469b4f49f0118f935b33c4caeb0c1afb683..17d61eb0a7e5f1bfbf11580f43f40edc6caebe76 100644 (file)
@@ -1302,7 +1302,7 @@ int __init init_module(void)
        } else return 0;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        int this_dev;
        for (this_dev=0; this_dev<MAX_3C523_CARDS; this_dev++) {
index f4aca5386add1c94238d23205e408ef19e8b12e1..6c7437e60bd212e72486d42b16fc6c4e72396580 100644 (file)
@@ -1659,7 +1659,7 @@ int __init init_module(void)
  *     transmit operations are allowed to start scribbling into memory.
  */
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        unregister_netdev(this_device);
        cleanup_card(this_device);
index 7733697f7776e9e689186b58dc467d08a4d6fe6f..2d5ba076471c29d3b62a43c3765780711eb5d4af 100644 (file)
@@ -500,7 +500,7 @@ int lance_open (struct net_device *dev)
        int res;
 
         /* Install the Interrupt handler. Or we could shunt this out to specific drivers? */
-        if (request_irq(lp->irq, lance_interrupt, 0, lp->name, dev))
+        if (request_irq(lp->irq, lance_interrupt, SA_SHIRQ, lp->name, dev))
                 return -EAGAIN;
 
         res = lance_reset(dev);
index 0dca8bb9d2c724254947964abd642bc39647fc17..c01f87f5bed77b4f6d93cb5cf013a73f6f9e7122 100644 (file)
@@ -405,7 +405,7 @@ static void cleanup_card(struct net_device *dev)
        iounmap(ei_status.mem);
 }
 
-void
+void __exit
 cleanup_module(void)
 {
        int this_dev;
index 9164d8cd670e4cb6e6054abb9add4cf3e30c38f7..954191119d35ceef89331927950e08465cf2b42a 100644 (file)
@@ -311,9 +311,10 @@ static int __init apne_probe1(struct net_device *dev, int ioaddr)
 #endif
 
     dev->base_addr = ioaddr;
+    dev->irq = IRQ_AMIGA_PORTS;
 
     /* Install the Interrupt handler */
-    i = request_irq(IRQ_AMIGA_PORTS, apne_interrupt, IRQF_SHARED, DRV_NAME, dev);
+    i = request_irq(dev->irq, apne_interrupt, IRQF_SHARED, DRV_NAME, dev);
     if (i) return i;
 
     for(i = 0; i < ETHER_ADDR_LEN; i++) {
@@ -568,7 +569,7 @@ static irqreturn_t apne_interrupt(int irq, void *dev_id)
 #ifdef MODULE
 static struct net_device *apne_dev;
 
-int init_module(void)
+int __init init_module(void)
 {
        apne_dev = apne_probe(-1);
        if (IS_ERR(apne_dev))
@@ -576,7 +577,7 @@ int init_module(void)
        return 0;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        unregister_netdev(apne_dev);
 
index cc1a27ed197fd93f0b360f0545e40610fb823557..dba5e5165452ba6a72bd250b4bd3d63b8bb7f250 100644 (file)
@@ -1041,7 +1041,7 @@ int __init init_module(void)
         return 0;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        unregister_netdev(cops_dev);
        cleanup_card(cops_dev);
index b54b857e357e5318d7656b7b581ad5e1cd827111..fada15d959dec6fd6a7e8f72c8c32ed50afdb3df 100644 (file)
@@ -41,9 +41,6 @@
 #define DRV_NAME       "at91_ether"
 #define DRV_VERSION    "1.0"
 
-static struct net_device *at91_dev;
-
-static struct timer_list check_timer;
 #define LINK_POLL_INTERVAL     (HZ)
 
 /* ..................................................................... */
@@ -146,7 +143,7 @@ static void read_phy(unsigned char phy_addr, unsigned char address, unsigned int
  */
 static void update_linkspeed(struct net_device *dev, int silent)
 {
-       struct at91_private *lp = (struct at91_private *) dev->priv;
+       struct at91_private *lp = netdev_priv(dev);
        unsigned int bmsr, bmcr, lpa, mac_cfg;
        unsigned int speed, duplex;
 
@@ -199,7 +196,7 @@ static void update_linkspeed(struct net_device *dev, int silent)
 static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id)
 {
        struct net_device *dev = (struct net_device *) dev_id;
-       struct at91_private *lp = (struct at91_private *) dev->priv;
+       struct at91_private *lp = netdev_priv(dev);
        unsigned int phy;
 
        /*
@@ -242,7 +239,7 @@ done:
  */
 static void enable_phyirq(struct net_device *dev)
 {
-       struct at91_private *lp = (struct at91_private *) dev->priv;
+       struct at91_private *lp = netdev_priv(dev);
        unsigned int dsintr, irq_number;
        int status;
 
@@ -252,8 +249,7 @@ static void enable_phyirq(struct net_device *dev)
                 * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L),
                 * or board does not have it connected.
                 */
-               check_timer.expires = jiffies + LINK_POLL_INTERVAL;
-               add_timer(&check_timer);
+               mod_timer(&lp->check_timer, jiffies + LINK_POLL_INTERVAL);
                return;
        }
 
@@ -294,13 +290,13 @@ static void enable_phyirq(struct net_device *dev)
  */
 static void disable_phyirq(struct net_device *dev)
 {
-       struct at91_private *lp = (struct at91_private *) dev->priv;
+       struct at91_private *lp = netdev_priv(dev);
        unsigned int dsintr;
        unsigned int irq_number;
 
        irq_number = lp->board_data.phy_irq_pin;
        if (!irq_number) {
-               del_timer_sync(&check_timer);
+               del_timer_sync(&lp->check_timer);
                return;
        }
 
@@ -340,7 +336,7 @@ static void disable_phyirq(struct net_device *dev)
 #if 0
 static void reset_phy(struct net_device *dev)
 {
-       struct at91_private *lp = (struct at91_private *) dev->priv;
+       struct at91_private *lp = netdev_priv(dev);
        unsigned int bmcr;
 
        spin_lock_irq(&lp->lock);
@@ -362,13 +358,13 @@ static void reset_phy(struct net_device *dev)
 static void at91ether_check_link(unsigned long dev_id)
 {
        struct net_device *dev = (struct net_device *) dev_id;
+       struct at91_private *lp = netdev_priv(dev);
 
        enable_mdi();
        update_linkspeed(dev, 1);
        disable_mdi();
 
-       check_timer.expires = jiffies + LINK_POLL_INTERVAL;
-       add_timer(&check_timer);
+       mod_timer(&lp->check_timer, jiffies + LINK_POLL_INTERVAL);
 }
 
 /* ......................... ADDRESS MANAGEMENT ........................ */
@@ -590,7 +586,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int location, int val
 
 static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
-       struct at91_private *lp = (struct at91_private *) dev->priv;
+       struct at91_private *lp = netdev_priv(dev);
        int ret;
 
        spin_lock_irq(&lp->lock);
@@ -611,7 +607,7 @@ static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cm
 
 static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
-       struct at91_private *lp = (struct at91_private *) dev->priv;
+       struct at91_private *lp = netdev_priv(dev);
        int ret;
 
        spin_lock_irq(&lp->lock);
@@ -627,7 +623,7 @@ static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cm
 
 static int at91ether_nwayreset(struct net_device *dev)
 {
-       struct at91_private *lp = (struct at91_private *) dev->priv;
+       struct at91_private *lp = netdev_priv(dev);
        int ret;
 
        spin_lock_irq(&lp->lock);
@@ -658,7 +654,7 @@ static const struct ethtool_ops at91ether_ethtool_ops = {
 
 static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-       struct at91_private *lp = (struct at91_private *) dev->priv;
+       struct at91_private *lp = netdev_priv(dev);
        int res;
 
        if (!netif_running(dev))
@@ -680,7 +676,7 @@ static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
  */
 static void at91ether_start(struct net_device *dev)
 {
-       struct at91_private *lp = (struct at91_private *) dev->priv;
+       struct at91_private *lp = netdev_priv(dev);
        struct recv_desc_bufs *dlist, *dlist_phys;
        int i;
        unsigned long ctl;
@@ -712,7 +708,7 @@ static void at91ether_start(struct net_device *dev)
  */
 static int at91ether_open(struct net_device *dev)
 {
-       struct at91_private *lp = (struct at91_private *) dev->priv;
+       struct at91_private *lp = netdev_priv(dev);
        unsigned long ctl;
 
        if (!is_valid_ether_addr(dev->dev_addr))
@@ -752,7 +748,7 @@ static int at91ether_open(struct net_device *dev)
  */
 static int at91ether_close(struct net_device *dev)
 {
-       struct at91_private *lp = (struct at91_private *) dev->priv;
+       struct at91_private *lp = netdev_priv(dev);
        unsigned long ctl;
 
        /* Disable Receiver and Transmitter */
@@ -779,7 +775,7 @@ static int at91ether_close(struct net_device *dev)
  */
 static int at91ether_tx(struct sk_buff *skb, struct net_device *dev)
 {
-       struct at91_private *lp = (struct at91_private *) dev->priv;
+       struct at91_private *lp = netdev_priv(dev);
 
        if (at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ) {
                netif_stop_queue(dev);
@@ -811,7 +807,7 @@ static int at91ether_tx(struct sk_buff *skb, struct net_device *dev)
  */
 static struct net_device_stats *at91ether_stats(struct net_device *dev)
 {
-       struct at91_private *lp = (struct at91_private *) dev->priv;
+       struct at91_private *lp = netdev_priv(dev);
        int ale, lenerr, seqe, lcol, ecol;
 
        if (netif_running(dev)) {
@@ -847,7 +843,7 @@ static struct net_device_stats *at91ether_stats(struct net_device *dev)
  */
 static void at91ether_rx(struct net_device *dev)
 {
-       struct at91_private *lp = (struct at91_private *) dev->priv;
+       struct at91_private *lp = netdev_priv(dev);
        struct recv_desc_bufs *dlist;
        unsigned char *p_recv;
        struct sk_buff *skb;
@@ -857,14 +853,13 @@ static void at91ether_rx(struct net_device *dev)
        while (dlist->descriptors[lp->rxBuffIndex].addr & EMAC_DESC_DONE) {
                p_recv = dlist->recv_buf[lp->rxBuffIndex];
                pktlen = dlist->descriptors[lp->rxBuffIndex].size & 0x7ff;      /* Length of frame including FCS */
-               skb = alloc_skb(pktlen + 2, GFP_ATOMIC);
+               skb = dev_alloc_skb(pktlen + 2);
                if (skb != NULL) {
                        skb_reserve(skb, 2);
                        memcpy(skb_put(skb, pktlen), p_recv, pktlen);
 
                        skb->dev = dev;
                        skb->protocol = eth_type_trans(skb, dev);
-                       skb->len = pktlen;
                        dev->last_rx = jiffies;
                        lp->stats.rx_bytes += pktlen;
                        netif_rx(skb);
@@ -891,7 +886,7 @@ static void at91ether_rx(struct net_device *dev)
 static irqreturn_t at91ether_interrupt(int irq, void *dev_id)
 {
        struct net_device *dev = (struct net_device *) dev_id;
-       struct at91_private *lp = (struct at91_private *) dev->priv;
+       struct at91_private *lp = netdev_priv(dev);
        unsigned long intstatus, ctl;
 
        /* MAC Interrupt Status register indicates what interrupts are pending.
@@ -927,6 +922,17 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void at91ether_poll_controller(struct net_device *dev)
+{
+       unsigned long flags;
+
+       local_irq_save(flags);
+       at91ether_interrupt(dev->irq, dev);
+       local_irq_restore(flags);
+}
+#endif
+
 /*
  * Initialize the ethernet interface
  */
@@ -939,9 +945,6 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
        unsigned int val;
        int res;
 
-       if (at91_dev)                   /* already initialized */
-               return 0;
-
        dev = alloc_etherdev(sizeof(struct at91_private));
        if (!dev)
                return -ENOMEM;
@@ -957,7 +960,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
        }
 
        /* Allocate memory for DMA Receive descriptors */
-       lp = (struct at91_private *)dev->priv;
+       lp = netdev_priv(dev);
        lp->dlist = (struct recv_desc_bufs *) dma_alloc_coherent(NULL, sizeof(struct recv_desc_bufs), (dma_addr_t *) &lp->dlist_phys, GFP_KERNEL);
        if (lp->dlist == NULL) {
                free_irq(dev->irq, dev);
@@ -979,6 +982,9 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
        dev->set_mac_address = set_mac_address;
        dev->ethtool_ops = &at91ether_ethtool_ops;
        dev->do_ioctl = at91ether_ioctl;
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       dev->poll_controller = at91ether_poll_controller;
+#endif
 
        SET_NETDEV_DEV(dev, &pdev->dev);
 
@@ -1024,7 +1030,6 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
                dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
                return res;
        }
-       at91_dev = dev;
 
        /* Determine current link speed */
        spin_lock_irq(&lp->lock);
@@ -1036,9 +1041,9 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
 
        /* If board has no PHY IRQ, use a timer to poll the PHY */
        if (!lp->board_data.phy_irq_pin) {
-               init_timer(&check_timer);
-               check_timer.data = (unsigned long)dev;
-               check_timer.function = at91ether_check_link;
+               init_timer(&lp->check_timer);
+               lp->check_timer.data = (unsigned long)dev;
+               lp->check_timer.function = at91ether_check_link;
        }
 
        /* Display ethernet banner */
@@ -1115,15 +1120,16 @@ static int __init at91ether_probe(struct platform_device *pdev)
 
 static int __devexit at91ether_remove(struct platform_device *pdev)
 {
-       struct at91_private *lp = (struct at91_private *) at91_dev->priv;
+       struct net_device *dev = platform_get_drvdata(pdev);
+       struct at91_private *lp = netdev_priv(dev);
 
-       unregister_netdev(at91_dev);
-       free_irq(at91_dev->irq, at91_dev);
+       unregister_netdev(dev);
+       free_irq(dev->irq, dev);
        dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
        clk_put(lp->ether_clk);
 
-       free_netdev(at91_dev);
-       at91_dev = NULL;
+       platform_set_drvdata(pdev, NULL);
+       free_netdev(dev);
        return 0;
 }
 
@@ -1131,8 +1137,8 @@ static int __devexit at91ether_remove(struct platform_device *pdev)
 
 static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
 {
-       struct at91_private *lp = (struct at91_private *) at91_dev->priv;
        struct net_device *net_dev = platform_get_drvdata(pdev);
+       struct at91_private *lp = netdev_priv(net_dev);
        int phy_irq = lp->board_data.phy_irq_pin;
 
        if (netif_running(net_dev)) {
@@ -1149,8 +1155,8 @@ static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
 
 static int at91ether_resume(struct platform_device *pdev)
 {
-       struct at91_private *lp = (struct at91_private *) at91_dev->priv;
        struct net_device *net_dev = platform_get_drvdata(pdev);
+       struct at91_private *lp = netdev_priv(net_dev);
        int phy_irq = lp->board_data.phy_irq_pin;
 
        if (netif_running(net_dev)) {
index d1e72e02be3adb05082ab17e4b079062abdbb844..b6b665de2ea0c28ac56e4ba30a23044fe0b29b36 100644 (file)
@@ -87,6 +87,7 @@ struct at91_private
        spinlock_t lock;                        /* lock for MDI interface */
        short phy_media;                        /* media interface type */
        unsigned short phy_address;             /* 5-bit MDI address of PHY (0..31) */
+       struct timer_list check_timer;          /* Poll link status */
 
        /* Transmit */
        struct sk_buff *skb;                    /* holds skb until xmit interrupt completes */
index f3478a30e7787ea7375db5af7c0c9d2aae8d6bf2..d6da3ce9ad7967776716827d5e8474fe7a2599f1 100644 (file)
@@ -254,7 +254,7 @@ ether1_readbuffer (struct net_device *dev, void *data, unsigned int start, unsig
        } while (thislen);
 }
 
-static int __init
+static int __devinit
 ether1_ramtest(struct net_device *dev, unsigned char byte)
 {
        unsigned char *buffer = kmalloc (BUFFER_SIZE, GFP_KERNEL);
@@ -308,7 +308,7 @@ ether1_reset (struct net_device *dev)
        return BUS_16;
 }
 
-static int __init
+static int __devinit
 ether1_init_2(struct net_device *dev)
 {
        int i;
@@ -986,7 +986,7 @@ ether1_setmulticastlist (struct net_device *dev)
 
 /* ------------------------------------------------------------------------- */
 
-static void __init ether1_banner(void)
+static void __devinit ether1_banner(void)
 {
        static unsigned int version_printed = 0;
 
index 84686c8a5bc271aa706a985770c5e70708995043..4fc234785d56069b47ce25261a0c8c8a148f29de 100644 (file)
@@ -198,7 +198,7 @@ static inline void ether3_ledon(struct net_device *dev)
  * Read the ethernet address string from the on board rom.
  * This is an ascii string!!!
  */
-static int __init
+static int __devinit
 ether3_addr(char *addr, struct expansion_card *ec)
 {
        struct in_chunk_dir cd;
@@ -223,7 +223,7 @@ ether3_addr(char *addr, struct expansion_card *ec)
 
 /* --------------------------------------------------------------------------- */
 
-static int __init
+static int __devinit
 ether3_ramtest(struct net_device *dev, unsigned char byte)
 {
        unsigned char *buffer = kmalloc(RX_END, GFP_KERNEL);
@@ -272,7 +272,7 @@ ether3_ramtest(struct net_device *dev, unsigned char byte)
 
 /* ------------------------------------------------------------------------------- */
 
-static int __init ether3_init_2(struct net_device *dev)
+static int __devinit ether3_init_2(struct net_device *dev)
 {
        int i;
 
@@ -765,7 +765,7 @@ static void ether3_tx(struct net_device *dev)
        }
 }
 
-static void __init ether3_banner(void)
+static void __devinit ether3_banner(void)
 {
        static unsigned version_printed = 0;
 
index 8620a5b470f55fbd16bbb4156be98622388247db..56ae8babd919d3d302c332fa783c9072d9d93e7a 100644 (file)
@@ -908,7 +908,7 @@ int __init init_module(void)
        return 0;
 }
 
-void
+void __exit
 cleanup_module(void)
 {
        unregister_netdev(dev_at1700);
index d79489e462499bf1ecd9bf700171747caccd9a2e..7e37ac86a69ab9660f44ddc7ab1687d5d0d478a1 100644 (file)
@@ -1179,7 +1179,7 @@ static int lance_set_mac_address( struct net_device *dev, void *addr )
 #ifdef MODULE
 static struct net_device *atarilance_dev;
 
-int init_module(void)
+int __init init_module(void)
 {
        atarilance_dev = atarilance_probe(-1);
        if (IS_ERR(atarilance_dev))
@@ -1187,7 +1187,7 @@ int init_module(void)
        return 0;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        unregister_netdev(atarilance_dev);
        free_irq(atarilance_dev->irq, atarilance_dev);
index 5bacb7587df41b77cdc414b278e85750279f4477..7d824cf8ee2d3e6893b00c70aad0d71a61e4ca3c 100644 (file)
@@ -2510,7 +2510,7 @@ bnx2_init_cpus(struct bnx2 *bp)
        if (CHIP_NUM(bp) == CHIP_NUM_5709) {
                fw = &bnx2_cp_fw_09;
 
-               load_cpu_fw(bp, &cpu_reg, fw);
+               rc = load_cpu_fw(bp, &cpu_reg, fw);
                if (rc)
                        goto init_cpu_err;
        }
index 488d8ed9e740b93a01aed6192dc2d31e76955af7..6482aed4bb7cddec1c6879e47a3a26a495332359 100644 (file)
@@ -3684,7 +3684,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
                        mii->val_out = 0;
                        read_lock_bh(&bond->lock);
                        read_lock(&bond->curr_slave_lock);
-                       if (bond->curr_active_slave) {
+                       if (netif_carrier_ok(bond->dev)) {
                                mii->val_out = BMSR_LSTATUS;
                        }
                        read_unlock(&bond->curr_slave_lock);
index dec70c2b374a775bb94f27c234948d15b57e6128..4612f71a7106dd45bc43db582c7be5177f39cad0 100644 (file)
@@ -1974,7 +1974,7 @@ out:
        return ret;
 }
 
-void
+void __exit
 cleanup_module(void)
 {
        unregister_netdev(dev_cs89x0);
index 690bb40b353dacedf8a6979998ca4f7cc3b1d39d..8396e411f1ce7b59088e2b8f5667ca5d01a789c4 100644 (file)
@@ -43,7 +43,6 @@ static const char version[] = "de600.c: $Revision: 1.41-2.5 $,  Bjorn Ekwall (bj
  * modify the following "#define": (see <asm/io.h> for more info)
 #define REALLY_SLOW_IO
  */
-#define SLOW_IO_BY_JUMPING /* Looks "better" than dummy write to port 0x80 :-) */
 
 /* use 0 for production, 1 for verification, >2 for debug */
 #ifdef DE600_DEBUG
index 00e2a8a134d7a2993530e29f97ac86d4458bf924..4ae0fed7122e7abbf5498137d26f799cb5976f16 100644 (file)
  *
  *      v0.009: Module support fixes, multiple interfaces support, various
  *              bits. macro
+ *
+ *      v0.010: Fixes for the PMAD mapping of the LANCE buffer and for the
+ *              PMAX requirement to only use halfword accesses to the
+ *              buffer. macro
  */
 
 #include <linux/crc32.h>
@@ -54,6 +58,7 @@
 #include <linux/spinlock.h>
 #include <linux/stddef.h>
 #include <linux/string.h>
+#include <linux/types.h>
 
 #include <asm/addrspace.h>
 #include <asm/system.h>
@@ -67,7 +72,7 @@
 #include <asm/dec/tc.h>
 
 static char version[] __devinitdata =
-"declance.c: v0.009 by Linux MIPS DECstation task force\n";
+"declance.c: v0.010 by Linux MIPS DECstation task force\n";
 
 MODULE_AUTHOR("Linux MIPS DECstation task force");
 MODULE_DESCRIPTION("DEC LANCE (DECstation onboard, PMAD-xx) driver");
@@ -110,24 +115,25 @@ MODULE_LICENSE("GPL");
 #define        LE_C3_BCON      0x1     /* Byte control */
 
 /* Receive message descriptor 1 */
-#define LE_R1_OWN       0x80   /* Who owns the entry */
-#define LE_R1_ERR       0x40   /* Error: if FRA, OFL, CRC or BUF is set */
-#define LE_R1_FRA       0x20   /* FRA: Frame error */
-#define LE_R1_OFL       0x10   /* OFL: Frame overflow */
-#define LE_R1_CRC       0x08   /* CRC error */
-#define LE_R1_BUF       0x04   /* BUF: Buffer error */
-#define LE_R1_SOP       0x02   /* Start of packet */
-#define LE_R1_EOP       0x01   /* End of packet */
-#define LE_R1_POK       0x03   /* Packet is complete: SOP + EOP */
-
-#define LE_T1_OWN       0x80   /* Lance owns the packet */
-#define LE_T1_ERR       0x40   /* Error summary */
-#define LE_T1_EMORE     0x10   /* Error: more than one retry needed */
-#define LE_T1_EONE      0x08   /* Error: one retry needed */
-#define LE_T1_EDEF      0x04   /* Error: deferred */
-#define LE_T1_SOP       0x02   /* Start of packet */
-#define LE_T1_EOP       0x01   /* End of packet */
-#define LE_T1_POK      0x03    /* Packet is complete: SOP + EOP */
+#define LE_R1_OWN      0x8000  /* Who owns the entry */
+#define LE_R1_ERR      0x4000  /* Error: if FRA, OFL, CRC or BUF is set */
+#define LE_R1_FRA      0x2000  /* FRA: Frame error */
+#define LE_R1_OFL      0x1000  /* OFL: Frame overflow */
+#define LE_R1_CRC      0x0800  /* CRC error */
+#define LE_R1_BUF      0x0400  /* BUF: Buffer error */
+#define LE_R1_SOP      0x0200  /* Start of packet */
+#define LE_R1_EOP      0x0100  /* End of packet */
+#define LE_R1_POK      0x0300  /* Packet is complete: SOP + EOP */
+
+/* Transmit message descriptor 1 */
+#define LE_T1_OWN      0x8000  /* Lance owns the packet */
+#define LE_T1_ERR      0x4000  /* Error summary */
+#define LE_T1_EMORE    0x1000  /* Error: more than one retry needed */
+#define LE_T1_EONE     0x0800  /* Error: one retry needed */
+#define LE_T1_EDEF     0x0400  /* Error: deferred */
+#define LE_T1_SOP      0x0200  /* Start of packet */
+#define LE_T1_EOP      0x0100  /* End of packet */
+#define LE_T1_POK      0x0300  /* Packet is complete: SOP + EOP */
 
 #define LE_T3_BUF       0x8000 /* Buffer error */
 #define LE_T3_UFL       0x4000 /* Error underflow */
@@ -156,69 +162,57 @@ MODULE_LICENSE("GPL");
 #undef TEST_HITS
 #define ZERO 0
 
-/* The DS2000/3000 have a linear 64 KB buffer.
-
- * The PMAD-AA has 128 kb buffer on-board.
+/*
+ * The DS2100/3100 have a linear 64 kB buffer which supports halfword
+ * accesses only.  Each halfword of the buffer is word-aligned in the
+ * CPU address space.
  *
- * The IOASIC LANCE devices use a shared memory region. This region as seen
- * from the CPU is (max) 128 KB long and has to be on an 128 KB boundary.
- * The LANCE sees this as a 64 KB long continuous memory region.
+ * The PMAD-AA has a 128 kB buffer on-board.
  *
- * The LANCE's DMA address is used as an index in this buffer and DMA takes
- * place in bursts of eight 16-Bit words which are packed into four 32-Bit words
- * by the IOASIC. This leads to a strange padding: 16 bytes of valid data followed
- * by a 16 byte gap :-(.
+ * The IOASIC LANCE devices use a shared memory region.  This region
+ * as seen from the CPU is (max) 128 kB long and has to be on an 128 kB
+ * boundary.  The LANCE sees this as a 64 kB long continuous memory
+ * region.
+ *
+ * The LANCE's DMA address is used as an index in this buffer and DMA
+ * takes place in bursts of eight 16-bit words which are packed into
+ * four 32-bit words by the IOASIC.  This leads to a strange padding:
+ * 16 bytes of valid data followed by a 16 byte gap :-(.
  */
 
 struct lance_rx_desc {
        unsigned short rmd0;            /* low address of packet */
-       short gap0;
-       unsigned char rmd1_hadr;        /* high address of packet */
-       unsigned char rmd1_bits;        /* descriptor bits */
-       short gap1;
+       unsigned short rmd1;            /* high address of packet
+                                          and descriptor bits */
        short length;                   /* 2s complement (negative!)
                                           of buffer length */
-       short gap2;
        unsigned short mblength;        /* actual number of bytes received */
-       short gap3;
 };
 
 struct lance_tx_desc {
        unsigned short tmd0;            /* low address of packet */
-       short gap0;
-       unsigned char tmd1_hadr;        /* high address of packet */
-       unsigned char tmd1_bits;        /* descriptor bits */
-       short gap1;
+       unsigned short tmd1;            /* high address of packet
+                                          and descriptor bits */
        short length;                   /* 2s complement (negative!)
                                           of buffer length */
-       short gap2;
        unsigned short misc;
-       short gap3;
 };
 
 
 /* First part of the LANCE initialization block, described in databook. */
 struct lance_init_block {
        unsigned short mode;            /* pre-set mode (reg. 15) */
-       short gap0;
 
-       unsigned char phys_addr[12];    /* physical ethernet address
-                                          only 0, 1, 4, 5, 8, 9 are valid
-                                          2, 3, 6, 7, 10, 11 are gaps */
-       unsigned short filter[8];       /* multicast filter
-                                          only 0, 2, 4, 6 are valid
-                                          1, 3, 5, 7 are gaps */
+       unsigned short phys_addr[3];    /* physical ethernet address */
+       unsigned short filter[4];       /* multicast filter */
 
        /* Receive and transmit ring base, along with extra bits. */
        unsigned short rx_ptr;          /* receive descriptor addr */
-       short gap1;
        unsigned short rx_len;          /* receive len and high addr */
-       short gap2;
        unsigned short tx_ptr;          /* transmit descriptor addr */
-       short gap3;
        unsigned short tx_len;          /* transmit len and high addr */
-       short gap4;
-       short gap5[8];
+
+       short gap[4];
 
        /* The buffer descriptors */
        struct lance_rx_desc brx_ring[RX_RING_SIZE];
@@ -226,15 +220,28 @@ struct lance_init_block {
 };
 
 #define BUF_OFFSET_CPU sizeof(struct lance_init_block)
-#define BUF_OFFSET_LNC (sizeof(struct lance_init_block)>>1)
+#define BUF_OFFSET_LNC sizeof(struct lance_init_block)
 
-#define libdesc_offset(rt, elem) \
-((__u32)(((unsigned long)(&(((struct lance_init_block *)0)->rt[elem])))))
+#define shift_off(off, type)                                           \
+       (type == ASIC_LANCE || type == PMAX_LANCE ? off << 1 : off)
 
-/*
- * This works *only* for the ring descriptors
- */
-#define LANCE_ADDR(x) (CPHYSADDR(x) >> 1)
+#define lib_off(rt, type)                                              \
+       shift_off(offsetof(struct lance_init_block, rt), type)
+
+#define lib_ptr(ib, rt, type)                                          \
+       ((volatile u16 *)((u8 *)(ib) + lib_off(rt, type)))
+
+#define rds_off(rt, type)                                              \
+       shift_off(offsetof(struct lance_rx_desc, rt), type)
+
+#define rds_ptr(rd, rt, type)                                          \
+       ((volatile u16 *)((u8 *)(rd) + rds_off(rt, type)))
+
+#define tds_off(rt, type)                                              \
+       shift_off(offsetof(struct lance_tx_desc, rt), type)
+
+#define tds_ptr(td, rt, type)                                          \
+       ((volatile u16 *)((u8 *)(td) + tds_off(rt, type)))
 
 struct lance_private {
        struct net_device *next;
@@ -242,7 +249,6 @@ struct lance_private {
        int slot;
        int dma_irq;
        volatile struct lance_regs *ll;
-       volatile struct lance_init_block *init_block;
 
        spinlock_t      lock;
 
@@ -260,8 +266,8 @@ struct lance_private {
        char *tx_buf_ptr_cpu[TX_RING_SIZE];
 
        /* Pointers to the ring buffers as seen from the LANCE */
-       char *rx_buf_ptr_lnc[RX_RING_SIZE];
-       char *tx_buf_ptr_lnc[TX_RING_SIZE];
+       uint rx_buf_ptr_lnc[RX_RING_SIZE];
+       uint tx_buf_ptr_lnc[TX_RING_SIZE];
 };
 
 #define TX_BUFFS_AVAIL ((lp->tx_old<=lp->tx_new)?\
@@ -294,7 +300,7 @@ static inline void writereg(volatile unsigned short *regptr, short value)
 static void load_csrs(struct lance_private *lp)
 {
        volatile struct lance_regs *ll = lp->ll;
-       int leptr;
+       uint leptr;
 
        /* The address space as seen from the LANCE
         * begins at address 0. HK
@@ -316,12 +322,14 @@ static void load_csrs(struct lance_private *lp)
  * Our specialized copy routines
  *
  */
-void cp_to_buf(const int type, void *to, const void *from, int len)
+static void cp_to_buf(const int type, void *to, const void *from, int len)
 {
        unsigned short *tp, *fp, clen;
        unsigned char *rtp, *rfp;
 
-       if (type == PMAX_LANCE) {
+       if (type == PMAD_LANCE) {
+               memcpy(to, from, len);
+       } else if (type == PMAX_LANCE) {
                clen = len >> 1;
                tp = (unsigned short *) to;
                fp = (unsigned short *) from;
@@ -370,12 +378,14 @@ void cp_to_buf(const int type, void *to, const void *from, int len)
        iob();
 }
 
-void cp_from_buf(const int type, void *to, const void *from, int len)
+static void cp_from_buf(const int type, void *to, const void *from, int len)
 {
        unsigned short *tp, *fp, clen;
        unsigned char *rtp, *rfp;
 
-       if (type == PMAX_LANCE) {
+       if (type == PMAD_LANCE) {
+               memcpy(to, from, len);
+       } else if (type == PMAX_LANCE) {
                clen = len >> 1;
                tp = (unsigned short *) to;
                fp = (unsigned short *) from;
@@ -431,12 +441,10 @@ void cp_from_buf(const int type, void *to, const void *from, int len)
 static void lance_init_ring(struct net_device *dev)
 {
        struct lance_private *lp = netdev_priv(dev);
-       volatile struct lance_init_block *ib;
-       int leptr;
+       volatile u16 *ib = (volatile u16 *)dev->mem_start;
+       uint leptr;
        int i;
 
-       ib = (struct lance_init_block *) (dev->mem_start);
-
        /* Lock out other processes while setting up hardware */
        netif_stop_queue(dev);
        lp->rx_new = lp->tx_new = 0;
@@ -445,55 +453,64 @@ static void lance_init_ring(struct net_device *dev)
        /* Copy the ethernet address to the lance init block.
         * XXX bit 0 of the physical address registers has to be zero
         */
-       ib->phys_addr[0] = dev->dev_addr[0];
-       ib->phys_addr[1] = dev->dev_addr[1];
-       ib->phys_addr[4] = dev->dev_addr[2];
-       ib->phys_addr[5] = dev->dev_addr[3];
-       ib->phys_addr[8] = dev->dev_addr[4];
-       ib->phys_addr[9] = dev->dev_addr[5];
+       *lib_ptr(ib, phys_addr[0], lp->type) = (dev->dev_addr[1] << 8) |
+                                    dev->dev_addr[0];
+       *lib_ptr(ib, phys_addr[1], lp->type) = (dev->dev_addr[3] << 8) |
+                                    dev->dev_addr[2];
+       *lib_ptr(ib, phys_addr[2], lp->type) = (dev->dev_addr[5] << 8) |
+                                    dev->dev_addr[4];
        /* Setup the initialization block */
 
        /* Setup rx descriptor pointer */
-       leptr = LANCE_ADDR(libdesc_offset(brx_ring, 0));
-       ib->rx_len = (LANCE_LOG_RX_BUFFERS << 13) | (leptr >> 16);
-       ib->rx_ptr = leptr;
+       leptr = offsetof(struct lance_init_block, brx_ring);
+       *lib_ptr(ib, rx_len, lp->type) = (LANCE_LOG_RX_BUFFERS << 13) |
+                                        (leptr >> 16);
+       *lib_ptr(ib, rx_ptr, lp->type) = leptr;
        if (ZERO)
-               printk("RX ptr: %8.8x(%8.8x)\n", leptr, libdesc_offset(brx_ring, 0));
+               printk("RX ptr: %8.8x(%8.8x)\n",
+                      leptr, lib_off(brx_ring, lp->type));
 
        /* Setup tx descriptor pointer */
-       leptr = LANCE_ADDR(libdesc_offset(btx_ring, 0));
-       ib->tx_len = (LANCE_LOG_TX_BUFFERS << 13) | (leptr >> 16);
-       ib->tx_ptr = leptr;
+       leptr = offsetof(struct lance_init_block, btx_ring);
+       *lib_ptr(ib, tx_len, lp->type) = (LANCE_LOG_TX_BUFFERS << 13) |
+                                        (leptr >> 16);
+       *lib_ptr(ib, tx_ptr, lp->type) = leptr;
        if (ZERO)
-               printk("TX ptr: %8.8x(%8.8x)\n", leptr, libdesc_offset(btx_ring, 0));
+               printk("TX ptr: %8.8x(%8.8x)\n",
+                      leptr, lib_off(btx_ring, lp->type));
 
        if (ZERO)
                printk("TX rings:\n");
 
        /* Setup the Tx ring entries */
        for (i = 0; i < TX_RING_SIZE; i++) {
-               leptr = (int) lp->tx_buf_ptr_lnc[i];
-               ib->btx_ring[i].tmd0 = leptr;
-               ib->btx_ring[i].tmd1_hadr = leptr >> 16;
-               ib->btx_ring[i].tmd1_bits = 0;
-               ib->btx_ring[i].length = 0xf000;        /* The ones required by tmd2 */
-               ib->btx_ring[i].misc = 0;
+               leptr = lp->tx_buf_ptr_lnc[i];
+               *lib_ptr(ib, btx_ring[i].tmd0, lp->type) = leptr;
+               *lib_ptr(ib, btx_ring[i].tmd1, lp->type) = (leptr >> 16) &
+                                                          0xff;
+               *lib_ptr(ib, btx_ring[i].length, lp->type) = 0xf000;
+                                               /* The ones required by tmd2 */
+               *lib_ptr(ib, btx_ring[i].misc, lp->type) = 0;
                if (i < 3 && ZERO)
-                       printk("%d: 0x%8.8x(0x%8.8x)\n", i, leptr, (int) lp->tx_buf_ptr_cpu[i]);
+                       printk("%d: 0x%8.8x(0x%8.8x)\n",
+                              i, leptr, (uint)lp->tx_buf_ptr_cpu[i]);
        }
 
        /* Setup the Rx ring entries */
        if (ZERO)
                printk("RX rings:\n");
        for (i = 0; i < RX_RING_SIZE; i++) {
-               leptr = (int) lp->rx_buf_ptr_lnc[i];
-               ib->brx_ring[i].rmd0 = leptr;
-               ib->brx_ring[i].rmd1_hadr = leptr >> 16;
-               ib->brx_ring[i].rmd1_bits = LE_R1_OWN;
-               ib->brx_ring[i].length = -RX_BUFF_SIZE | 0xf000;
-               ib->brx_ring[i].mblength = 0;
+               leptr = lp->rx_buf_ptr_lnc[i];
+               *lib_ptr(ib, brx_ring[i].rmd0, lp->type) = leptr;
+               *lib_ptr(ib, brx_ring[i].rmd1, lp->type) = ((leptr >> 16) &
+                                                           0xff) |
+                                                          LE_R1_OWN;
+               *lib_ptr(ib, brx_ring[i].length, lp->type) = -RX_BUFF_SIZE |
+                                                            0xf000;
+               *lib_ptr(ib, brx_ring[i].mblength, lp->type) = 0;
                if (i < 3 && ZERO)
-                       printk("%d: 0x%8.8x(0x%8.8x)\n", i, leptr, (int) lp->rx_buf_ptr_cpu[i]);
+                       printk("%d: 0x%8.8x(0x%8.8x)\n",
+                              i, leptr, (uint)lp->rx_buf_ptr_cpu[i]);
        }
        iob();
 }
@@ -511,11 +528,13 @@ static int init_restart_lance(struct lance_private *lp)
                udelay(10);
        }
        if ((i == 100) || (ll->rdp & LE_C0_ERR)) {
-               printk("LANCE unopened after %d ticks, csr0=%4.4x.\n", i, ll->rdp);
+               printk("LANCE unopened after %d ticks, csr0=%4.4x.\n",
+                      i, ll->rdp);
                return -1;
        }
        if ((ll->rdp & LE_C0_ERR)) {
-               printk("LANCE unopened after %d ticks, csr0=%4.4x.\n", i, ll->rdp);
+               printk("LANCE unopened after %d ticks, csr0=%4.4x.\n",
+                      i, ll->rdp);
                return -1;
        }
        writereg(&ll->rdp, LE_C0_IDON);
@@ -528,12 +547,11 @@ static int init_restart_lance(struct lance_private *lp)
 static int lance_rx(struct net_device *dev)
 {
        struct lance_private *lp = netdev_priv(dev);
-       volatile struct lance_init_block *ib;
-       volatile struct lance_rx_desc *rd = 0;
-       unsigned char bits;
-       int len = 0;
-       struct sk_buff *skb = 0;
-       ib = (struct lance_init_block *) (dev->mem_start);
+       volatile u16 *ib = (volatile u16 *)dev->mem_start;
+       volatile u16 *rd;
+       unsigned short bits;
+       int entry, len;
+       struct sk_buff *skb;
 
 #ifdef TEST_HITS
        {
@@ -542,19 +560,22 @@ static int lance_rx(struct net_device *dev)
                printk("[");
                for (i = 0; i < RX_RING_SIZE; i++) {
                        if (i == lp->rx_new)
-                               printk("%s", ib->brx_ring[i].rmd1_bits &
+                               printk("%s", *lib_ptr(ib, brx_ring[i].rmd1,
+                                                     lp->type) &
                                             LE_R1_OWN ? "_" : "X");
                        else
-                               printk("%s", ib->brx_ring[i].rmd1_bits &
+                               printk("%s", *lib_ptr(ib, brx_ring[i].rmd1,
+                                                     lp->type) &
                                             LE_R1_OWN ? "." : "1");
                }
                printk("]");
        }
 #endif
 
-       for (rd = &ib->brx_ring[lp->rx_new];
-            !((bits = rd->rmd1_bits) & LE_R1_OWN);
-            rd = &ib->brx_ring[lp->rx_new]) {
+       for (rd = lib_ptr(ib, brx_ring[lp->rx_new], lp->type);
+            !((bits = *rds_ptr(rd, rmd1, lp->type)) & LE_R1_OWN);
+            rd = lib_ptr(ib, brx_ring[lp->rx_new], lp->type)) {
+               entry = lp->rx_new;
 
                /* We got an incomplete frame? */
                if ((bits & LE_R1_POK) != LE_R1_POK) {
@@ -575,16 +596,18 @@ static int lance_rx(struct net_device *dev)
                        if (bits & LE_R1_EOP)
                                lp->stats.rx_errors++;
                } else {
-                       len = (rd->mblength & 0xfff) - 4;
+                       len = (*rds_ptr(rd, mblength, lp->type) & 0xfff) - 4;
                        skb = dev_alloc_skb(len + 2);
 
                        if (skb == 0) {
                                printk("%s: Memory squeeze, deferring packet.\n",
                                       dev->name);
                                lp->stats.rx_dropped++;
-                               rd->mblength = 0;
-                               rd->rmd1_bits = LE_R1_OWN;
-                               lp->rx_new = (lp->rx_new + 1) & RX_RING_MOD_MASK;
+                               *rds_ptr(rd, mblength, lp->type) = 0;
+                               *rds_ptr(rd, rmd1, lp->type) =
+                                       ((lp->rx_buf_ptr_lnc[entry] >> 16) &
+                                        0xff) | LE_R1_OWN;
+                               lp->rx_new = (entry + 1) & RX_RING_MOD_MASK;
                                return 0;
                        }
                        lp->stats.rx_bytes += len;
@@ -594,8 +617,7 @@ static int lance_rx(struct net_device *dev)
                        skb_put(skb, len);      /* make room */
 
                        cp_from_buf(lp->type, skb->data,
-                                   (char *)lp->rx_buf_ptr_cpu[lp->rx_new],
-                                   len);
+                                   (char *)lp->rx_buf_ptr_cpu[entry], len);
 
                        skb->protocol = eth_type_trans(skb, dev);
                        netif_rx(skb);
@@ -604,10 +626,11 @@ static int lance_rx(struct net_device *dev)
                }
 
                /* Return the packet to the pool */
-               rd->mblength = 0;
-               rd->length = -RX_BUFF_SIZE | 0xf000;
-               rd->rmd1_bits = LE_R1_OWN;
-               lp->rx_new = (lp->rx_new + 1) & RX_RING_MOD_MASK;
+               *rds_ptr(rd, mblength, lp->type) = 0;
+               *rds_ptr(rd, length, lp->type) = -RX_BUFF_SIZE | 0xf000;
+               *rds_ptr(rd, rmd1, lp->type) =
+                       ((lp->rx_buf_ptr_lnc[entry] >> 16) & 0xff) | LE_R1_OWN;
+               lp->rx_new = (entry + 1) & RX_RING_MOD_MASK;
        }
        return 0;
 }
@@ -615,24 +638,24 @@ static int lance_rx(struct net_device *dev)
 static void lance_tx(struct net_device *dev)
 {
        struct lance_private *lp = netdev_priv(dev);
-       volatile struct lance_init_block *ib;
+       volatile u16 *ib = (volatile u16 *)dev->mem_start;
        volatile struct lance_regs *ll = lp->ll;
-       volatile struct lance_tx_desc *td;
+       volatile u16 *td;
        int i, j;
        int status;
-       ib = (struct lance_init_block *) (dev->mem_start);
+
        j = lp->tx_old;
 
        spin_lock(&lp->lock);
 
        for (i = j; i != lp->tx_new; i = j) {
-               td = &ib->btx_ring[i];
+               td = lib_ptr(ib, btx_ring[i], lp->type);
                /* If we hit a packet not owned by us, stop */
-               if (td->tmd1_bits & LE_T1_OWN)
+               if (*tds_ptr(td, tmd1, lp->type) & LE_T1_OWN)
                        break;
 
-               if (td->tmd1_bits & LE_T1_ERR) {
-                       status = td->misc;
+               if (*tds_ptr(td, tmd1, lp->type) & LE_T1_ERR) {
+                       status = *tds_ptr(td, misc, lp->type);
 
                        lp->stats.tx_errors++;
                        if (status & LE_T3_RTY)
@@ -667,18 +690,19 @@ static void lance_tx(struct net_device *dev)
                                init_restart_lance(lp);
                                goto out;
                        }
-               } else if ((td->tmd1_bits & LE_T1_POK) == LE_T1_POK) {
+               } else if ((*tds_ptr(td, tmd1, lp->type) & LE_T1_POK) ==
+                          LE_T1_POK) {
                        /*
                         * So we don't count the packet more than once.
                         */
-                       td->tmd1_bits &= ~(LE_T1_POK);
+                       *tds_ptr(td, tmd1, lp->type) &= ~(LE_T1_POK);
 
                        /* One collision before packet was sent. */
-                       if (td->tmd1_bits & LE_T1_EONE)
+                       if (*tds_ptr(td, tmd1, lp->type) & LE_T1_EONE)
                                lp->stats.collisions++;
 
                        /* More than one collision, be optimistic. */
-                       if (td->tmd1_bits & LE_T1_EMORE)
+                       if (*tds_ptr(td, tmd1, lp->type) & LE_T1_EMORE)
                                lp->stats.collisions += 2;
 
                        lp->stats.tx_packets++;
@@ -752,7 +776,7 @@ struct net_device *last_dev = 0;
 
 static int lance_open(struct net_device *dev)
 {
-       volatile struct lance_init_block *ib = (struct lance_init_block *) (dev->mem_start);
+       volatile u16 *ib = (volatile u16 *)dev->mem_start;
        struct lance_private *lp = netdev_priv(dev);
        volatile struct lance_regs *ll = lp->ll;
        int status = 0;
@@ -769,11 +793,11 @@ static int lance_open(struct net_device *dev)
         *
         * BTW it is common bug in all lance drivers! --ANK
         */
-       ib->mode = 0;
-       ib->filter [0] = 0;
-       ib->filter [2] = 0;
-       ib->filter [4] = 0;
-       ib->filter [6] = 0;
+       *lib_ptr(ib, mode, lp->type) = 0;
+       *lib_ptr(ib, filter[0], lp->type) = 0;
+       *lib_ptr(ib, filter[1], lp->type) = 0;
+       *lib_ptr(ib, filter[2], lp->type) = 0;
+       *lib_ptr(ib, filter[3], lp->type) = 0;
 
        lance_init_ring(dev);
        load_csrs(lp);
@@ -874,12 +898,10 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct lance_private *lp = netdev_priv(dev);
        volatile struct lance_regs *ll = lp->ll;
-       volatile struct lance_init_block *ib = (struct lance_init_block *) (dev->mem_start);
-       int entry, skblen, len;
+       volatile u16 *ib = (volatile u16 *)dev->mem_start;
+       int entry, len;
 
-       skblen = skb->len;
-
-       len = skblen;
+       len = skb->len;
 
        if (len < ETH_ZLEN) {
                if (skb_padto(skb, ETH_ZLEN))
@@ -889,23 +911,17 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        lp->stats.tx_bytes += len;
 
-       entry = lp->tx_new & TX_RING_MOD_MASK;
-       ib->btx_ring[entry].length = (-len);
-       ib->btx_ring[entry].misc = 0;
-
-       cp_to_buf(lp->type, (char *)lp->tx_buf_ptr_cpu[entry], skb->data,
-                 skblen);
+       entry = lp->tx_new;
+       *lib_ptr(ib, btx_ring[entry].length, lp->type) = (-len);
+       *lib_ptr(ib, btx_ring[entry].misc, lp->type) = 0;
 
-       /* Clear the slack of the packet, do I need this? */
-       /* For a firewall it's a good idea - AC */
-/*
-   if (len != skblen)
-   memset ((char *) &ib->tx_buf [entry][skblen], 0, (len - skblen) << 1);
- */
+       cp_to_buf(lp->type, (char *)lp->tx_buf_ptr_cpu[entry], skb->data, len);
 
        /* Now, give the packet to the lance */
-       ib->btx_ring[entry].tmd1_bits = (LE_T1_POK | LE_T1_OWN);
-       lp->tx_new = (lp->tx_new + 1) & TX_RING_MOD_MASK;
+       *lib_ptr(ib, btx_ring[entry].tmd1, lp->type) =
+               ((lp->tx_buf_ptr_lnc[entry] >> 16) & 0xff) |
+               (LE_T1_POK | LE_T1_OWN);
+       lp->tx_new = (entry + 1) & TX_RING_MOD_MASK;
 
        if (TX_BUFFS_AVAIL <= 0)
                netif_stop_queue(dev);
@@ -930,8 +946,8 @@ static struct net_device_stats *lance_get_stats(struct net_device *dev)
 
 static void lance_load_multicast(struct net_device *dev)
 {
-       volatile struct lance_init_block *ib = (struct lance_init_block *) (dev->mem_start);
-       volatile u16 *mcast_table = (u16 *) & ib->filter;
+       struct lance_private *lp = netdev_priv(dev);
+       volatile u16 *ib = (volatile u16 *)dev->mem_start;
        struct dev_mc_list *dmi = dev->mc_list;
        char *addrs;
        int i;
@@ -939,17 +955,17 @@ static void lance_load_multicast(struct net_device *dev)
 
        /* set all multicast bits */
        if (dev->flags & IFF_ALLMULTI) {
-               ib->filter[0] = 0xffff;
-               ib->filter[2] = 0xffff;
-               ib->filter[4] = 0xffff;
-               ib->filter[6] = 0xffff;
+               *lib_ptr(ib, filter[0], lp->type) = 0xffff;
+               *lib_ptr(ib, filter[1], lp->type) = 0xffff;
+               *lib_ptr(ib, filter[2], lp->type) = 0xffff;
+               *lib_ptr(ib, filter[3], lp->type) = 0xffff;
                return;
        }
        /* clear the multicast filter */
-       ib->filter[0] = 0;
-       ib->filter[2] = 0;
-       ib->filter[4] = 0;
-       ib->filter[6] = 0;
+       *lib_ptr(ib, filter[0], lp->type) = 0;
+       *lib_ptr(ib, filter[1], lp->type) = 0;
+       *lib_ptr(ib, filter[2], lp->type) = 0;
+       *lib_ptr(ib, filter[3], lp->type) = 0;
 
        /* Add addresses */
        for (i = 0; i < dev->mc_count; i++) {
@@ -962,7 +978,7 @@ static void lance_load_multicast(struct net_device *dev)
 
                crc = ether_crc_le(ETH_ALEN, addrs);
                crc = crc >> 26;
-               mcast_table[2 * (crc >> 4)] |= 1 << (crc & 0xf);
+               *lib_ptr(ib, filter[crc >> 4], lp->type) |= 1 << (crc & 0xf);
        }
        return;
 }
@@ -970,11 +986,9 @@ static void lance_load_multicast(struct net_device *dev)
 static void lance_set_multicast(struct net_device *dev)
 {
        struct lance_private *lp = netdev_priv(dev);
-       volatile struct lance_init_block *ib;
+       volatile u16 *ib = (volatile u16 *)dev->mem_start;
        volatile struct lance_regs *ll = lp->ll;
 
-       ib = (struct lance_init_block *) (dev->mem_start);
-
        if (!netif_running(dev))
                return;
 
@@ -992,9 +1006,9 @@ static void lance_set_multicast(struct net_device *dev)
        lance_init_ring(dev);
 
        if (dev->flags & IFF_PROMISC) {
-               ib->mode |= LE_MO_PROM;
+               *lib_ptr(ib, mode, lp->type) |= LE_MO_PROM;
        } else {
-               ib->mode &= ~LE_MO_PROM;
+               *lib_ptr(ib, mode, lp->type) &= ~LE_MO_PROM;
                lance_load_multicast(dev);
        }
        load_csrs(lp);
@@ -1051,7 +1065,6 @@ static int __init dec_lance_init(const int type, const int slot)
        lp->type = type;
        lp->slot = slot;
        switch (type) {
-#ifdef CONFIG_TC
        case ASIC_LANCE:
                dev->base_addr = CKSEG1ADDR(dec_kn_slot_base + IOASIC_LANCE);
 
@@ -1073,20 +1086,20 @@ static int __init dec_lance_init(const int type, const int slot)
                 */
                for (i = 0; i < RX_RING_SIZE; i++) {
                        lp->rx_buf_ptr_cpu[i] =
-                               (char *)(dev->mem_start + BUF_OFFSET_CPU +
+                               (char *)(dev->mem_start + 2 * BUF_OFFSET_CPU +
                                         2 * i * RX_BUFF_SIZE);
                        lp->rx_buf_ptr_lnc[i] =
-                               (char *)(BUF_OFFSET_LNC + i * RX_BUFF_SIZE);
+                               (BUF_OFFSET_LNC + i * RX_BUFF_SIZE);
                }
                for (i = 0; i < TX_RING_SIZE; i++) {
                        lp->tx_buf_ptr_cpu[i] =
-                               (char *)(dev->mem_start + BUF_OFFSET_CPU +
+                               (char *)(dev->mem_start + 2 * BUF_OFFSET_CPU +
                                         2 * RX_RING_SIZE * RX_BUFF_SIZE +
                                         2 * i * TX_BUFF_SIZE);
                        lp->tx_buf_ptr_lnc[i] =
-                               (char *)(BUF_OFFSET_LNC +
-                                        RX_RING_SIZE * RX_BUFF_SIZE +
-                                        i * TX_BUFF_SIZE);
+                               (BUF_OFFSET_LNC +
+                                RX_RING_SIZE * RX_BUFF_SIZE +
+                                i * TX_BUFF_SIZE);
                }
 
                /* Setup I/O ASIC LANCE DMA.  */
@@ -1095,11 +1108,12 @@ static int __init dec_lance_init(const int type, const int slot)
                             CPHYSADDR(dev->mem_start) << 3);
 
                break;
-
+#ifdef CONFIG_TC
        case PMAD_LANCE:
                claim_tc_card(slot);
 
                dev->mem_start = CKSEG1ADDR(get_tc_base_addr(slot));
+               dev->mem_end = dev->mem_start + 0x100000;
                dev->base_addr = dev->mem_start + 0x100000;
                dev->irq = get_tc_irq_nr(slot);
                esar_base = dev->mem_start + 0x1c0002;
@@ -1110,7 +1124,7 @@ static int __init dec_lance_init(const int type, const int slot)
                                (char *)(dev->mem_start + BUF_OFFSET_CPU +
                                         i * RX_BUFF_SIZE);
                        lp->rx_buf_ptr_lnc[i] =
-                               (char *)(BUF_OFFSET_LNC + i * RX_BUFF_SIZE);
+                               (BUF_OFFSET_LNC + i * RX_BUFF_SIZE);
                }
                for (i = 0; i < TX_RING_SIZE; i++) {
                        lp->tx_buf_ptr_cpu[i] =
@@ -1118,18 +1132,18 @@ static int __init dec_lance_init(const int type, const int slot)
                                         RX_RING_SIZE * RX_BUFF_SIZE +
                                         i * TX_BUFF_SIZE);
                        lp->tx_buf_ptr_lnc[i] =
-                               (char *)(BUF_OFFSET_LNC +
-                                        RX_RING_SIZE * RX_BUFF_SIZE +
-                                        i * TX_BUFF_SIZE);
+                               (BUF_OFFSET_LNC +
+                                RX_RING_SIZE * RX_BUFF_SIZE +
+                                i * TX_BUFF_SIZE);
                }
 
                break;
 #endif
-
        case PMAX_LANCE:
                dev->irq = dec_interrupt[DEC_IRQ_LANCE];
                dev->base_addr = CKSEG1ADDR(KN01_SLOT_BASE + KN01_LANCE);
                dev->mem_start = CKSEG1ADDR(KN01_SLOT_BASE + KN01_LANCE_MEM);
+               dev->mem_end = dev->mem_start + KN01_SLOT_SIZE;
                esar_base = CKSEG1ADDR(KN01_SLOT_BASE + KN01_ESAR + 1);
                lp->dma_irq = -1;
 
@@ -1138,20 +1152,20 @@ static int __init dec_lance_init(const int type, const int slot)
                 */
                for (i = 0; i < RX_RING_SIZE; i++) {
                        lp->rx_buf_ptr_cpu[i] =
-                               (char *)(dev->mem_start + BUF_OFFSET_CPU +
+                               (char *)(dev->mem_start + 2 * BUF_OFFSET_CPU +
                                         2 * i * RX_BUFF_SIZE);
                        lp->rx_buf_ptr_lnc[i] =
-                               (char *)(BUF_OFFSET_LNC + i * RX_BUFF_SIZE);
+                               (BUF_OFFSET_LNC + i * RX_BUFF_SIZE);
                }
                for (i = 0; i < TX_RING_SIZE; i++) {
                        lp->tx_buf_ptr_cpu[i] =
-                               (char *)(dev->mem_start + BUF_OFFSET_CPU +
+                               (char *)(dev->mem_start + 2 * BUF_OFFSET_CPU +
                                         2 * RX_RING_SIZE * RX_BUFF_SIZE +
                                         2 * i * TX_BUFF_SIZE);
                        lp->tx_buf_ptr_lnc[i] =
-                               (char *)(BUF_OFFSET_LNC +
-                                        RX_RING_SIZE * RX_BUFF_SIZE +
-                                        i * TX_BUFF_SIZE);
+                               (BUF_OFFSET_LNC +
+                                RX_RING_SIZE * RX_BUFF_SIZE +
+                                i * TX_BUFF_SIZE);
                }
 
                break;
@@ -1279,10 +1293,8 @@ static int __init dec_lance_probe(void)
        /* Then handle onboard devices. */
        if (dec_interrupt[DEC_IRQ_LANCE] >= 0) {
                if (dec_interrupt[DEC_IRQ_LANCE_MERR] >= 0) {
-#ifdef CONFIG_TC
                        if (dec_lance_init(ASIC_LANCE, -1) >= 0)
                                count++;
-#endif
                } else if (!TURBOCHANNEL) {
                        if (dec_lance_init(PMAX_LANCE, -1) >= 0)
                                count++;
index d39e8480ca5652537fd68da4c526eb20ca92e236..c62d9c6363c60c94093ee2a1a0cac86ec8ed02b1 100644 (file)
@@ -463,7 +463,7 @@ static void cleanup_card(struct net_device *dev)
        release_region(dev->base_addr, E21_IO_EXTENT);
 }
 
-void
+void __exit
 cleanup_module(void)
 {
        int this_dev;
index a4eb0dc99ecffe42c92b87a1bacac5c72234caa1..b4463094c93abe8e04a8dd4313170279d1877057 100644 (file)
@@ -1827,7 +1827,7 @@ int __init init_module(void)
        return n_eepro ? 0 : -ENODEV;
 }
 
-void
+void __exit
 cleanup_module(void)
 {
        int i;
index e14be020e5624b2f5f999b1d90a0771cb0004f69..4a50fcb5ad6b6538b62fb58530182ecc2051e17c 100644 (file)
@@ -1719,7 +1719,7 @@ int __init init_module(void)
        return -ENXIO;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        int this_dev;
 
index fd7b32a24ea4f33d9cf1461daff5433b2fcc5a36..2d2ea94a00bb72cd7568d4a4f2d185be068aec8b 100644 (file)
@@ -455,7 +455,7 @@ static void cleanup_card(struct net_device *dev)
        iounmap(ei_status.mem);
 }
 
-void
+void __exit
 cleanup_module(void)
 {
        int this_dev;
index b7b8bc2a6307ef7215df4d4390ff4c53f8fc9934..93283e386f3a71d44bf6d987cade944146992753 100644 (file)
@@ -1475,7 +1475,7 @@ int __init init_module(void)
        return -ENXIO;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        int this_dev;
 
index 92420f007b97ebc79bf5c07b212a1985a50d9e3f..760d04a671f937269789411fd3141b18eb637de5 100644 (file)
@@ -325,11 +325,6 @@ static int sp_rebuild_header(struct sk_buff *skb)
 
 static void sp_setup(struct net_device *dev)
 {
-       static char ax25_bcast[AX25_ADDR_LEN] =
-               {'Q'<<1,'S'<<1,'T'<<1,' '<<1,' '<<1,' '<<1,'0'<<1};
-       static char ax25_test[AX25_ADDR_LEN] =
-               {'L'<<1,'I'<<1,'N'<<1,'U'<<1,'X'<<1,' '<<1,'1'<<1};
-
        /* Finish setting up the DEVICE info. */
        dev->mtu                = SIXP_MTU;
        dev->hard_start_xmit    = sp_xmit;
@@ -347,8 +342,8 @@ static void sp_setup(struct net_device *dev)
        dev->tx_timeout         = NULL;
 
        /* Only activated in AX.25 mode */
-       memcpy(dev->broadcast, ax25_bcast, AX25_ADDR_LEN);
-       memcpy(dev->dev_addr, ax25_test, AX25_ADDR_LEN);
+       memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
+       memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN);
 
        SET_MODULE_OWNER(dev);
 
index 3c33d6f6a6a662cb6563d144c87cab1e51c39b2c..8a83db0fb3b75c6be9232aed06153e08897c543c 100644 (file)
@@ -1141,12 +1141,6 @@ static int baycom_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
  */
 static void baycom_probe(struct net_device *dev)
 {
-       static char ax25_bcast[AX25_ADDR_LEN] = {
-               'Q' << 1, 'S' << 1, 'T' << 1, ' ' << 1, ' ' << 1, ' ' << 1, '0' << 1
-       };
-       static char ax25_nocall[AX25_ADDR_LEN] = {
-               'L' << 1, 'I' << 1, 'N' << 1, 'U' << 1, 'X' << 1, ' ' << 1, '1' << 1
-       };
        const struct hdlcdrv_channel_params dflt_ch_params = { 
                20, 2, 10, 40, 0 
        };
@@ -1182,8 +1176,8 @@ static void baycom_probe(struct net_device *dev)
        dev->hard_header_len = AX25_MAX_HEADER_LEN + AX25_BPQ_HEADER_LEN;
        dev->mtu = AX25_DEF_PACLEN;        /* eth_mtu is the default */
        dev->addr_len = AX25_ADDR_LEN;     /* sizeof an ax.25 address */
-       memcpy(dev->broadcast, ax25_bcast, AX25_ADDR_LEN);
-       memcpy(dev->dev_addr, ax25_nocall, AX25_ADDR_LEN);
+       memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
+       memcpy(dev->dev_addr, &ax25_nocall, AX25_ADDR_LEN);
        dev->tx_queue_len = 16;
 
        /* New style flags */
index 889f338132fa2aef212d5aa1434682a0b33bb99c..5b788d84011fc0ba06c204fca5ac21312f2ead9d 100644 (file)
 
 static char banner[] __initdata = KERN_INFO "AX.25: bpqether driver version 004\n";
 
-static unsigned char ax25_bcast[AX25_ADDR_LEN] =
-       {'Q' << 1, 'S' << 1, 'T' << 1, ' ' << 1, ' ' << 1, ' ' << 1, '0' << 1};
-static unsigned char ax25_defaddr[AX25_ADDR_LEN] =
-       {'L' << 1, 'I' << 1, 'N' << 1, 'U' << 1, 'X' << 1, ' ' << 1, '1' << 1};
-
 static char bcast_addr[6]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
 
 static char bpq_eth_addr[6];
@@ -487,8 +482,8 @@ static void bpq_setup(struct net_device *dev)
        dev->do_ioctl        = bpq_ioctl;
        dev->destructor      = free_netdev;
 
-       memcpy(dev->broadcast, ax25_bcast, AX25_ADDR_LEN);
-       memcpy(dev->dev_addr,  ax25_defaddr, AX25_ADDR_LEN);
+       memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
+       memcpy(dev->dev_addr,  &ax25_defaddr, AX25_ADDR_LEN);
 
        dev->flags      = 0;
 
index e6e721aff6f688baa925754b1df54ef8d12cce41..0fbb414b5a4ddba69f5a93be26148ea578f5fb1b 100644 (file)
@@ -264,12 +264,6 @@ static int io[MAX_NUM_DEVS] __initdata = { 0, };
 
 /* Beware! hw[] is also used in cleanup_module(). */
 static struct scc_hardware hw[NUM_TYPES] __initdata_or_module = HARDWARE;
-static char ax25_broadcast[7] __initdata =
-    { 'Q' << 1, 'S' << 1, 'T' << 1, ' ' << 1, ' ' << 1, ' ' << 1,
-'0' << 1 };
-static char ax25_test[7] __initdata =
-    { 'L' << 1, 'I' << 1, 'N' << 1, 'U' << 1, 'X' << 1, ' ' << 1,
-'1' << 1 };
 
 
 /* Global variables */
@@ -443,8 +437,8 @@ static void __init dev_setup(struct net_device *dev)
        dev->mtu = 1500;
        dev->addr_len = AX25_ADDR_LEN;
        dev->tx_queue_len = 64;
-       memcpy(dev->broadcast, ax25_broadcast, AX25_ADDR_LEN);
-       memcpy(dev->dev_addr, ax25_test, AX25_ADDR_LEN);
+       memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
+       memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN);
 }
 
 static int __init setup_adapter(int card_base, int type, int n)
index dacc7687b97f8b2bfe3290ede1cd6137c5ed08d9..452873e7c68f5d358c2bac2c6274e58f7a868a03 100644 (file)
 
 /* --------------------------------------------------------------------- */
 
-/*
- * The name of the card. Is used for messages and in the requests for
- * io regions, irqs and dma channels
- */
-
-static char ax25_bcast[AX25_ADDR_LEN] =
-{'Q' << 1, 'S' << 1, 'T' << 1, ' ' << 1, ' ' << 1, ' ' << 1, '0' << 1};
-static char ax25_nocall[AX25_ADDR_LEN] =
-{'L' << 1, 'I' << 1, 'N' << 1, 'U' << 1, 'X' << 1, ' ' << 1, '1' << 1};
-
-/* --------------------------------------------------------------------- */
-
 #define KISS_VERBOSE
 
 /* --------------------------------------------------------------------- */
@@ -709,8 +697,8 @@ static void hdlcdrv_setup(struct net_device *dev)
        dev->hard_header_len = AX25_MAX_HEADER_LEN + AX25_BPQ_HEADER_LEN;
        dev->mtu = AX25_DEF_PACLEN;        /* eth_mtu is the default */
        dev->addr_len = AX25_ADDR_LEN;     /* sizeof an ax.25 address */
-       memcpy(dev->broadcast, ax25_bcast, AX25_ADDR_LEN);
-       memcpy(dev->dev_addr, ax25_nocall, AX25_ADDR_LEN);
+       memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
+       memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN);
        dev->tx_queue_len = 16;
 }
 
index d8715b200c17bfcdef02ee8aa5c8f2358a4bcecb..d08fbc3966481fd40c6d790efbf6b455abc2e56a 100644 (file)
@@ -672,11 +672,6 @@ static struct net_device_stats *ax_get_stats(struct net_device *dev)
 
 static void ax_setup(struct net_device *dev)
 {
-       static char ax25_bcast[AX25_ADDR_LEN] =
-               {'Q'<<1,'S'<<1,'T'<<1,' '<<1,' '<<1,' '<<1,'0'<<1};
-       static char ax25_test[AX25_ADDR_LEN] =
-               {'L'<<1,'I'<<1,'N'<<1,'U'<<1,'X'<<1,' '<<1,'1'<<1};
-
        /* Finish setting up the DEVICE info. */
        dev->mtu             = AX_MTU;
        dev->hard_start_xmit = ax_xmit;
@@ -691,8 +686,8 @@ static void ax_setup(struct net_device *dev)
        dev->hard_header     = ax_header;
        dev->rebuild_header  = ax_rebuild_header;
 
-       memcpy(dev->broadcast, ax25_bcast, AX25_ADDR_LEN);
-       memcpy(dev->dev_addr,  ax25_test,  AX25_ADDR_LEN);
+       memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
+       memcpy(dev->dev_addr,  &ax25_defaddr,  AX25_ADDR_LEN);
 
        dev->flags      = IFF_BROADCAST | IFF_MULTICAST;
 }
index ec9b6d9b6f05d2465e9bd6c1e6f10d49e1520912..2ce047e9d2625455331a76092dcb60c186b9cbec 100644 (file)
@@ -1540,11 +1540,6 @@ static int scc_net_alloc(const char *name, struct scc_channel *scc)
 /* *                       Network driver methods                    * */
 /* ******************************************************************** */
 
-static unsigned char ax25_bcast[AX25_ADDR_LEN] =
-{'Q' << 1, 'S' << 1, 'T' << 1, ' ' << 1, ' ' << 1, ' ' << 1, '0' << 1};
-static unsigned char ax25_nocall[AX25_ADDR_LEN] =
-{'L' << 1, 'I' << 1, 'N' << 1, 'U' << 1, 'X' << 1, ' ' << 1, '1' << 1};
-
 /* ----> Initialize device <----- */
 
 static void scc_net_setup(struct net_device *dev)
@@ -1562,8 +1557,8 @@ static void scc_net_setup(struct net_device *dev)
        dev->do_ioctl        = scc_net_ioctl;
        dev->tx_timeout      = NULL;
 
-       memcpy(dev->broadcast, ax25_bcast,  AX25_ADDR_LEN);
-       memcpy(dev->dev_addr,  ax25_nocall, AX25_ADDR_LEN);
+       memcpy(dev->broadcast, &ax25_bcast,  AX25_ADDR_LEN);
+       memcpy(dev->dev_addr,  &ax25_defaddr, AX25_ADDR_LEN);
  
        dev->flags      = 0;
 
index 3c4455bd466d1984779fe6cc33eb9096eea34170..6d74f08720d5cf0e53656dfb5a00dfa03579f235 100644 (file)
@@ -156,11 +156,6 @@ static struct net_device *yam_devs[NR_PORTS];
 
 static struct yam_mcs *yam_data;
 
-static char ax25_bcast[7] =
-{'Q' << 1, 'S' << 1, 'T' << 1, ' ' << 1, ' ' << 1, ' ' << 1, '0' << 1};
-static char ax25_test[7] =
-{'L' << 1, 'I' << 1, 'N' << 1, 'U' << 1, 'X' << 1, ' ' << 1, '1' << 1};
-
 static DEFINE_TIMER(yam_timer, NULL, 0, 0);
 
 /* --------------------------------------------------------------------- */
@@ -1115,8 +1110,8 @@ static void yam_setup(struct net_device *dev)
        dev->hard_header_len = AX25_MAX_HEADER_LEN;
        dev->mtu = AX25_MTU;
        dev->addr_len = AX25_ADDR_LEN;
-       memcpy(dev->broadcast, ax25_bcast, AX25_ADDR_LEN);
-       memcpy(dev->dev_addr, ax25_test, AX25_ADDR_LEN);
+       memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
+       memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN);
 }
 
 static int __init yam_init_driver(void)
index 6abcfd2a4b2805825e92736eab16c97e26b5b29c..99a36cc3f8df4dddcba0d4f5e70c7847628e6bcb 100644 (file)
@@ -482,7 +482,7 @@ static void cleanup_card(struct net_device *dev)
        release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT);
 }
 
-void
+void __exit
 cleanup_module(void)
 {
        int this_dev;
index 29470970aa2707e3a7286358be76750f0bed6cc5..635b13c2e2aac856f786253f07a6cd95a48a9edf 100644 (file)
@@ -444,7 +444,7 @@ static void cleanup_card(struct net_device *dev)
        release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT);
 }
 
-void
+void __exit
 cleanup_module(void)
 {
        int this_dev;
index 9c643f2a8d54b21e3496de6216014dbc19996e0c..c991cb82ff22bc8cf53c84dbf608c75af0ca83b5 100644 (file)
@@ -77,6 +77,7 @@ static int __devinit hplance_init_one(struct dio_dev *d,
 {
        struct net_device *dev;
        int err = -ENOMEM;
+       int i;
 
        dev = alloc_etherdev(sizeof(struct hplance_private));
        if (!dev)
@@ -93,6 +94,15 @@ static int __devinit hplance_init_one(struct dio_dev *d,
                goto out_release_mem_region;
 
        dio_set_drvdata(d, dev);
+
+       printk(KERN_INFO "%s: %s; select code %d, addr %2.2x", dev->name, d->name, d->scode, dev->dev_addr[0]);
+
+       for (i=1; i<6; i++) {
+               printk(":%2.2x", dev->dev_addr[i]);
+       }
+
+       printk(", irq %d\n", d->ipl);
+
        return 0;
 
  out_release_mem_region:
@@ -119,8 +129,6 @@ static void __init hplance_init(struct net_device *dev, struct dio_dev *d)
         struct hplance_private *lp;
         int i;
 
-        printk(KERN_INFO "%s: %s; select code %d, addr", dev->name, d->name, d->scode);
-
         /* reset the board */
         out_8(va+DIO_IDOFF, 0xff);
         udelay(100);                              /* ariba! ariba! udelay! udelay! */
@@ -143,7 +151,6 @@ static void __init hplance_init(struct net_device *dev, struct dio_dev *d)
                  */
                 dev->dev_addr[i] = ((in_8(va + HPLANCE_NVRAMOFF + i*4 + 1) & 0xF) << 4)
                         | (in_8(va + HPLANCE_NVRAMOFF + i*4 + 3) & 0xF);
-                printk("%c%2.2x", i == 0 ? ' ' : ':', dev->dev_addr[i]);
         }
 
         lp = netdev_priv(dev);
@@ -160,7 +167,6 @@ static void __init hplance_init(struct net_device *dev, struct dio_dev *d)
         lp->lance.lance_log_tx_bufs = LANCE_LOG_TX_BUFFERS;
         lp->lance.rx_ring_mod_mask = RX_RING_MOD_MASK;
         lp->lance.tx_ring_mod_mask = TX_RING_MOD_MASK;
-       printk(", irq %d\n", lp->lance.irq);
 }
 
 /* This is disgusting. We have to check the DIO status register for ack every
index 6a98b7ae4975d9066e840707e8d095e183075b46..ad1857364d51c42ff3a23ce610fc8083ac059754 100644 (file)
@@ -117,7 +117,7 @@ static int irtty_change_speed(struct sir_dev *dev, unsigned speed)
 {
        struct sirtty_cb *priv = dev->priv;
        struct tty_struct *tty;
-        struct termios old_termios;
+        struct ktermios old_termios;
        int cflag;
 
        IRDA_ASSERT(priv != NULL, return -1;);
@@ -318,7 +318,7 @@ static void irtty_write_wakeup(struct tty_struct *tty)
 
 static inline void irtty_stop_receiver(struct tty_struct *tty, int stop)
 {
-       struct termios old_termios;
+       struct ktermios old_termios;
        int cflag;
 
        lock_kernel();
index f9a1c88a42831c542d59931b55ce6c74397d60e5..9137e239fac2e55120fed2520db2dccbe5bfcbe9 100644 (file)
@@ -704,9 +704,9 @@ static int pxa_irda_stop(struct net_device *dev)
        return 0;
 }
 
-static int pxa_irda_suspend(struct device *_dev, pm_message_t state)
+static int pxa_irda_suspend(struct platform_device *_dev, pm_message_t state)
 {
-       struct net_device *dev = dev_get_drvdata(_dev);
+       struct net_device *dev = platform_get_drvdata(_dev);
        struct pxa_irda *si;
 
        if (dev && netif_running(dev)) {
@@ -718,9 +718,9 @@ static int pxa_irda_suspend(struct device *_dev, pm_message_t state)
        return 0;
 }
 
-static int pxa_irda_resume(struct device *_dev)
+static int pxa_irda_resume(struct platform_device *_dev)
 {
-       struct net_device *dev = dev_get_drvdata(_dev);
+       struct net_device *dev = platform_get_drvdata(_dev);
        struct pxa_irda *si;
 
        if (dev && netif_running(dev)) {
@@ -746,9 +746,8 @@ static int pxa_irda_init_iobuf(iobuff_t *io, int size)
        return io->head ? 0 : -ENOMEM;
 }
 
-static int pxa_irda_probe(struct device *_dev)
+static int pxa_irda_probe(struct platform_device *pdev)
 {
-       struct platform_device *pdev = to_platform_device(_dev);
        struct net_device *dev;
        struct pxa_irda *si;
        unsigned int baudrate_mask;
@@ -822,9 +821,9 @@ err_mem_1:
        return err;
 }
 
-static int pxa_irda_remove(struct device *_dev)
+static int pxa_irda_remove(struct platform_device *_dev)
 {
-       struct net_device *dev = dev_get_drvdata(_dev);
+       struct net_device *dev = platform_get_drvdata(_dev);
 
        if (dev) {
                struct pxa_irda *si = netdev_priv(dev);
@@ -840,9 +839,10 @@ static int pxa_irda_remove(struct device *_dev)
        return 0;
 }
 
-static struct device_driver pxa_ir_driver = {
-       .name           = "pxa2xx-ir",
-       .bus            = &platform_bus_type,
+static struct platform_driver pxa_ir_driver = {
+       .driver         = {
+               .name   = "pxa2xx-ir",
+       },
        .probe          = pxa_irda_probe,
        .remove         = pxa_irda_remove,
        .suspend        = pxa_irda_suspend,
@@ -851,12 +851,12 @@ static struct device_driver pxa_ir_driver = {
 
 static int __init pxa_irda_init(void)
 {
-       return driver_register(&pxa_ir_driver);
+       return platform_driver_register(&pxa_ir_driver);
 }
 
 static void __exit pxa_irda_exit(void)
 {
-       driver_unregister(&pxa_ir_driver);
+       platform_driver_unregister(&pxa_ir_driver);
 }
 
 module_init(pxa_irda_init);
index 3b4c478759356fa9f7b8af473385520fa1c023c2..c14a74634fd50a67f866cc9d2621a5772ede8f35 100644 (file)
@@ -50,6 +50,7 @@
 #include <linux/usb.h>
 #include <linux/crc32.h>
 #include <linux/kthread.h>
+#include <linux/freezer.h>
 #include <net/irda/irda.h>
 #include <net/irda/irlap.h>
 #include <net/irda/irda_device.h>
index 4256c13c73c290d8a70e7e12114b2882a4ed467f..a3843320dbe1df8efdebf7aef1d12e77e197a280 100644 (file)
@@ -368,7 +368,7 @@ static void cleanup_card(struct net_device *dev)
        kfree(lp);
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        int this_dev;
 
index f4d815bca643e878a93eb1a9cfb1fe4d091d0923..ea392f2a5aa26aeb9c9f7670fbb6303e2c9c1672 100644 (file)
 #define DEB(x,y)       if (i596_debug & (x)) { y; }
 
 
-#define  CHECK_WBACK(addr,len) \
-       do { dma_cache_sync((void *)addr, len, DMA_TO_DEVICE); } while (0)
+#define  CHECK_WBACK(priv, addr,len) \
+       do { dma_cache_sync((priv)->dev, (void *)addr, len, DMA_TO_DEVICE); } while (0)
 
-#define  CHECK_INV(addr,len) \
-       do { dma_cache_sync((void *)addr, len, DMA_FROM_DEVICE); } while(0)
+#define  CHECK_INV(priv, addr,len) \
+       do { dma_cache_sync((priv)->dev, (void *)addr, len, DMA_FROM_DEVICE); } while(0)
 
-#define  CHECK_WBACK_INV(addr,len) \
-       do { dma_cache_sync((void *)addr, len, DMA_BIDIRECTIONAL); } while (0)
+#define  CHECK_WBACK_INV(priv, addr,len) \
+       do { dma_cache_sync((priv)->dev, (void *)addr, len, DMA_BIDIRECTIONAL); } while (0)
 
 
 #define PA_I82596_RESET                0       /* Offsets relative to LASI-LAN-Addr.*/
@@ -449,10 +449,10 @@ static inline void MPU_PORT(struct net_device *dev, int c, dma_addr_t x)
 
 static inline int wait_istat(struct net_device *dev, struct i596_private *lp, int delcnt, char *str)
 {
-       CHECK_INV(&(lp->iscp), sizeof(struct i596_iscp));
+       CHECK_INV(lp, &(lp->iscp), sizeof(struct i596_iscp));
        while (--delcnt && lp->iscp.stat) {
                udelay(10);
-               CHECK_INV(&(lp->iscp), sizeof(struct i596_iscp));
+               CHECK_INV(lp, &(lp->iscp), sizeof(struct i596_iscp));
        }
        if (!delcnt) {
                printk("%s: %s, iscp.stat %04x, didn't clear\n",
@@ -466,10 +466,10 @@ static inline int wait_istat(struct net_device *dev, struct i596_private *lp, in
 
 static inline int wait_cmd(struct net_device *dev, struct i596_private *lp, int delcnt, char *str)
 {
-       CHECK_INV(&(lp->scb), sizeof(struct i596_scb));
+       CHECK_INV(lp, &(lp->scb), sizeof(struct i596_scb));
        while (--delcnt && lp->scb.command) {
                udelay(10);
-               CHECK_INV(&(lp->scb), sizeof(struct i596_scb));
+               CHECK_INV(lp, &(lp->scb), sizeof(struct i596_scb));
        }
        if (!delcnt) {
                printk("%s: %s, status %4.4x, cmd %4.4x.\n",
@@ -522,7 +522,7 @@ static void i596_display_data(struct net_device *dev)
                        rbd, rbd->count, rbd->b_next, rbd->b_data, rbd->size);
                rbd = rbd->v_next;
        } while (rbd != lp->rbd_head);
-       CHECK_INV(lp, sizeof(struct i596_private));
+       CHECK_INV(lp, lp, sizeof(struct i596_private));
 }
 
 
@@ -592,7 +592,7 @@ static inline void init_rx_bufs(struct net_device *dev)
        rfd->b_next = WSWAPrfd(virt_to_dma(lp,lp->rfds));
        rfd->cmd = CMD_EOL|CMD_FLEX;
 
-       CHECK_WBACK_INV(lp, sizeof(struct i596_private));
+       CHECK_WBACK_INV(lp, lp, sizeof(struct i596_private));
 }
 
 static inline void remove_rx_bufs(struct net_device *dev)
@@ -629,7 +629,7 @@ static void rebuild_rx_bufs(struct net_device *dev)
        lp->rbd_head = lp->rbds;
        lp->rfds[0].rbd = WSWAPrbd(virt_to_dma(lp,lp->rbds));
 
-       CHECK_WBACK_INV(lp, sizeof(struct i596_private));
+       CHECK_WBACK_INV(lp, lp, sizeof(struct i596_private));
 }
 
 
@@ -663,8 +663,8 @@ static int init_i596_mem(struct net_device *dev)
 
        DEB(DEB_INIT, printk("%s: starting i82596.\n", dev->name));
 
-       CHECK_WBACK(&(lp->scp), sizeof(struct i596_scp));
-       CHECK_WBACK(&(lp->iscp), sizeof(struct i596_iscp));
+       CHECK_WBACK(lp, &(lp->scp), sizeof(struct i596_scp));
+       CHECK_WBACK(lp, &(lp->iscp), sizeof(struct i596_iscp));
 
        MPU_PORT(dev, PORT_ALTSCP, virt_to_dma(lp,&lp->scp));
 
@@ -678,25 +678,25 @@ static int init_i596_mem(struct net_device *dev)
        rebuild_rx_bufs(dev);
 
        lp->scb.command = 0;
-       CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb));
+       CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
 
        enable_irq(dev->irq);   /* enable IRQs from LAN */
 
        DEB(DEB_INIT, printk("%s: queuing CmdConfigure\n", dev->name));
        memcpy(lp->cf_cmd.i596_config, init_setup, 14);
        lp->cf_cmd.cmd.command = CmdConfigure;
-       CHECK_WBACK(&(lp->cf_cmd), sizeof(struct cf_cmd));
+       CHECK_WBACK(lp, &(lp->cf_cmd), sizeof(struct cf_cmd));
        i596_add_cmd(dev, &lp->cf_cmd.cmd);
 
        DEB(DEB_INIT, printk("%s: queuing CmdSASetup\n", dev->name));
        memcpy(lp->sa_cmd.eth_addr, dev->dev_addr, 6);
        lp->sa_cmd.cmd.command = CmdSASetup;
-       CHECK_WBACK(&(lp->sa_cmd), sizeof(struct sa_cmd));
+       CHECK_WBACK(lp, &(lp->sa_cmd), sizeof(struct sa_cmd));
        i596_add_cmd(dev, &lp->sa_cmd.cmd);
 
        DEB(DEB_INIT, printk("%s: queuing CmdTDR\n", dev->name));
        lp->tdr_cmd.cmd.command = CmdTDR;
-       CHECK_WBACK(&(lp->tdr_cmd), sizeof(struct tdr_cmd));
+       CHECK_WBACK(lp, &(lp->tdr_cmd), sizeof(struct tdr_cmd));
        i596_add_cmd(dev, &lp->tdr_cmd.cmd);
 
        spin_lock_irqsave (&lp->lock, flags);
@@ -708,7 +708,7 @@ static int init_i596_mem(struct net_device *dev)
        DEB(DEB_INIT, printk("%s: Issuing RX_START\n", dev->name));
        lp->scb.command = RX_START;
        lp->scb.rfd = WSWAPrfd(virt_to_dma(lp,lp->rfds));
-       CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb));
+       CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
 
        CA(dev);
 
@@ -740,13 +740,13 @@ static inline int i596_rx(struct net_device *dev)
 
        rfd = lp->rfd_head;             /* Ref next frame to check */
 
-       CHECK_INV(rfd, sizeof(struct i596_rfd));
+       CHECK_INV(lp, rfd, sizeof(struct i596_rfd));
        while ((rfd->stat) & STAT_C) {  /* Loop while complete frames */
                if (rfd->rbd == I596_NULL)
                        rbd = NULL;
                else if (rfd->rbd == lp->rbd_head->b_addr) {
                        rbd = lp->rbd_head;
-                       CHECK_INV(rbd, sizeof(struct i596_rbd));
+                       CHECK_INV(lp, rbd, sizeof(struct i596_rbd));
                }
                else {
                        printk("%s: rbd chain broken!\n", dev->name);
@@ -790,7 +790,7 @@ static inline int i596_rx(struct net_device *dev)
                                dma_addr = dma_map_single(lp->dev, newskb->data, PKT_BUF_SZ, DMA_FROM_DEVICE);
                                rbd->v_data = newskb->data;
                                rbd->b_data = WSWAPchar(dma_addr);
-                               CHECK_WBACK_INV(rbd, sizeof(struct i596_rbd));
+                               CHECK_WBACK_INV(lp, rbd, sizeof(struct i596_rbd));
                        }
                        else
                                skb = dev_alloc_skb(pkt_len + 2);
@@ -842,7 +842,7 @@ memory_squeeze:
                if (rbd != NULL && (rbd->count & 0x4000)) {
                        rbd->count = 0;
                        lp->rbd_head = rbd->v_next;
-                       CHECK_WBACK_INV(rbd, sizeof(struct i596_rbd));
+                       CHECK_WBACK_INV(lp, rbd, sizeof(struct i596_rbd));
                }
 
                /* Tidy the frame descriptor, marking it as end of list */
@@ -860,10 +860,10 @@ memory_squeeze:
 
                lp->scb.rfd = rfd->b_next;
                lp->rfd_head = rfd->v_next;
-               CHECK_WBACK_INV(rfd->v_prev, sizeof(struct i596_rfd));
-               CHECK_WBACK_INV(rfd, sizeof(struct i596_rfd));
+               CHECK_WBACK_INV(lp, rfd->v_prev, sizeof(struct i596_rfd));
+               CHECK_WBACK_INV(lp, rfd, sizeof(struct i596_rfd));
                rfd = lp->rfd_head;
-               CHECK_INV(rfd, sizeof(struct i596_rfd));
+               CHECK_INV(lp, rfd, sizeof(struct i596_rfd));
        }
 
        DEB(DEB_RXFRAME, printk("frames %d\n", frames));
@@ -902,12 +902,12 @@ static inline void i596_cleanup_cmd(struct net_device *dev, struct i596_private
                        ptr->v_next = NULL;
                        ptr->b_next = I596_NULL;
                }
-               CHECK_WBACK_INV(ptr, sizeof(struct i596_cmd));
+               CHECK_WBACK_INV(lp, ptr, sizeof(struct i596_cmd));
        }
 
        wait_cmd(dev, lp, 100, "i596_cleanup_cmd timed out");
        lp->scb.cmd = I596_NULL;
-       CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb));
+       CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
 }
 
 
@@ -925,7 +925,7 @@ static inline void i596_reset(struct net_device *dev, struct i596_private *lp)
 
        /* FIXME: this command might cause an lpmc */
        lp->scb.command = CUC_ABORT | RX_ABORT;
-       CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb));
+       CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
        CA(dev);
 
        /* wait for shutdown */
@@ -951,20 +951,20 @@ static void i596_add_cmd(struct net_device *dev, struct i596_cmd *cmd)
        cmd->command |= (CMD_EOL | CMD_INTR);
        cmd->v_next = NULL;
        cmd->b_next = I596_NULL;
-       CHECK_WBACK(cmd, sizeof(struct i596_cmd));
+       CHECK_WBACK(lp, cmd, sizeof(struct i596_cmd));
 
        spin_lock_irqsave (&lp->lock, flags);
 
        if (lp->cmd_head != NULL) {
                lp->cmd_tail->v_next = cmd;
                lp->cmd_tail->b_next = WSWAPcmd(virt_to_dma(lp,&cmd->status));
-               CHECK_WBACK(lp->cmd_tail, sizeof(struct i596_cmd));
+               CHECK_WBACK(lp, lp->cmd_tail, sizeof(struct i596_cmd));
        } else {
                lp->cmd_head = cmd;
                wait_cmd(dev, lp, 100, "i596_add_cmd timed out");
                lp->scb.cmd = WSWAPcmd(virt_to_dma(lp,&cmd->status));
                lp->scb.command = CUC_START;
-               CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb));
+               CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
                CA(dev);
        }
        lp->cmd_tail = cmd;
@@ -998,12 +998,12 @@ static int i596_test(struct net_device *dev)
        data = virt_to_dma(lp,tint);
 
        tint[1] = -1;
-       CHECK_WBACK(tint,PAGE_SIZE);
+       CHECK_WBACK(lp, tint, PAGE_SIZE);
 
        MPU_PORT(dev, 1, data);
 
        for(data = 1000000; data; data--) {
-               CHECK_INV(tint,PAGE_SIZE);
+               CHECK_INV(lp, tint, PAGE_SIZE);
                if(tint[1] != -1)
                        break;
 
@@ -1061,7 +1061,7 @@ static void i596_tx_timeout (struct net_device *dev)
                /* Issue a channel attention signal */
                DEB(DEB_ERRORS, printk("Kicking board.\n"));
                lp->scb.command = CUC_START | RX_START;
-               CHECK_WBACK_INV(&(lp->scb), sizeof(struct i596_scb));
+               CHECK_WBACK_INV(lp, &(lp->scb), sizeof(struct i596_scb));
                CA (dev);
                lp->last_restart = lp->stats.tx_packets;
        }
@@ -1118,8 +1118,8 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev)
                tbd->data = WSWAPchar(tx_cmd->dma_addr);
 
                DEB(DEB_TXADDR,print_eth(skb->data, "tx-queued"));
-               CHECK_WBACK_INV(tx_cmd, sizeof(struct tx_cmd));
-               CHECK_WBACK_INV(tbd, sizeof(struct i596_tbd));
+               CHECK_WBACK_INV(lp, tx_cmd, sizeof(struct tx_cmd));
+               CHECK_WBACK_INV(lp, tbd, sizeof(struct i596_tbd));
                i596_add_cmd(dev, &tx_cmd->cmd);
 
                lp->stats.tx_packets++;
@@ -1228,7 +1228,7 @@ static int __devinit i82596_probe(struct net_device *dev,
        lp->dma_addr = dma_addr;
        lp->dev = gen_dev;
 
-       CHECK_WBACK_INV(dev->mem_start, sizeof(struct i596_private));
+       CHECK_WBACK_INV(lp, dev->mem_start, sizeof(struct i596_private));
 
        i = register_netdev(dev);
        if (i) {
@@ -1295,7 +1295,7 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id)
                        DEB(DEB_INTS, printk("%s: i596 interrupt command unit inactive %x.\n", dev->name, status & 0x0700));
 
                while (lp->cmd_head != NULL) {
-                       CHECK_INV(lp->cmd_head, sizeof(struct i596_cmd));
+                       CHECK_INV(lp, lp->cmd_head, sizeof(struct i596_cmd));
                        if (!(lp->cmd_head->status & STAT_C))
                                break;
 
@@ -1358,7 +1358,7 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id)
                        }
                        ptr->v_next = NULL;
                        ptr->b_next = I596_NULL;
-                       CHECK_WBACK(ptr, sizeof(struct i596_cmd));
+                       CHECK_WBACK(lp, ptr, sizeof(struct i596_cmd));
                        lp->last_cmd = jiffies;
                }
 
@@ -1372,13 +1372,13 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id)
 
                        ptr->command &= 0x1fff;
                        ptr = ptr->v_next;
-                       CHECK_WBACK_INV(prev, sizeof(struct i596_cmd));
+                       CHECK_WBACK_INV(lp, prev, sizeof(struct i596_cmd));
                }
 
                if ((lp->cmd_head != NULL))
                        ack_cmd |= CUC_START;
                lp->scb.cmd = WSWAPcmd(virt_to_dma(lp,&lp->cmd_head->status));
-               CHECK_WBACK_INV(&lp->scb, sizeof(struct i596_scb));
+               CHECK_WBACK_INV(lp, &lp->scb, sizeof(struct i596_scb));
        }
        if ((status & 0x1000) || (status & 0x4000)) {
                if ((status & 0x4000))
@@ -1397,7 +1397,7 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id)
        }
        wait_cmd(dev, lp, 100, "i596 interrupt, timeout");
        lp->scb.command = ack_cmd;
-       CHECK_WBACK(&lp->scb, sizeof(struct i596_scb));
+       CHECK_WBACK(lp, &lp->scb, sizeof(struct i596_scb));
 
        /* DANGER: I suspect that some kind of interrupt
         acknowledgement aside from acking the 82596 might be needed
@@ -1426,7 +1426,7 @@ static int i596_close(struct net_device *dev)
 
        wait_cmd(dev, lp, 100, "close1 timed out");
        lp->scb.command = CUC_ABORT | RX_ABORT;
-       CHECK_WBACK(&lp->scb, sizeof(struct i596_scb));
+       CHECK_WBACK(lp, &lp->scb, sizeof(struct i596_scb));
 
        CA(dev);
 
@@ -1486,7 +1486,7 @@ static void set_multicast_list(struct net_device *dev)
                               dev->name);
                else {
                        lp->cf_cmd.cmd.command = CmdConfigure;
-                       CHECK_WBACK_INV(&lp->cf_cmd, sizeof(struct cf_cmd));
+                       CHECK_WBACK_INV(lp, &lp->cf_cmd, sizeof(struct cf_cmd));
                        i596_add_cmd(dev, &lp->cf_cmd.cmd);
                }
        }
@@ -1514,7 +1514,7 @@ static void set_multicast_list(struct net_device *dev)
                                DEB(DEB_MULTI, printk("%s: Adding address %02x:%02x:%02x:%02x:%02x:%02x\n",
                                                dev->name, cp[0],cp[1],cp[2],cp[3],cp[4],cp[5]));
                }
-               CHECK_WBACK_INV(&lp->mc_cmd, sizeof(struct mc_cmd));
+               CHECK_WBACK_INV(lp, &lp->mc_cmd, sizeof(struct mc_cmd));
                i596_add_cmd(dev, &cmd->cmd);
        }
 }
index 5795ee1162054a5701076f1d2092528de95ff119..0a08d0c4e7b4b1063d76c7d46ee1a0d85f6f6724 100644 (file)
@@ -440,7 +440,7 @@ static void cleanup_card(struct net_device *dev)
        iounmap(ei_status.mem);
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        int this_dev;
 
index d9f48bb04b0544af17f8f2d47ad40052d9ca6027..c41ae4286eeae76daba0ee77bf24d08a3cbf1963 100644 (file)
@@ -1100,7 +1100,7 @@ static void eth_tx_fill_frag_descs(struct mv643xx_private *mp,
                                         ETH_TX_ENABLE_INTERRUPT;
                        mp->tx_skb[tx_index] = skb;
                } else
-                       mp->tx_skb[tx_index] = 0;
+                       mp->tx_skb[tx_index] = NULL;
 
                desc = &mp->p_tx_desc_area[tx_index];
                desc->l4i_chk = 0;
@@ -1136,7 +1136,7 @@ static void eth_tx_submit_descs_for_skb(struct mv643xx_private *mp,
                eth_tx_fill_frag_descs(mp, skb);
 
                length = skb_headlen(skb);
-               mp->tx_skb[tx_index] = 0;
+               mp->tx_skb[tx_index] = NULL;
        } else {
                cmd_sts |= ETH_ZERO_PADDING |
                           ETH_TX_LAST_DESC |
index 56a82d8ee8f52c4a88c4f8bfa257b2f7122d5cb2..e246d00bba6d0467a851d642984894cbd021ee22 100644 (file)
@@ -184,7 +184,7 @@ static int m147lance_close(struct net_device *dev)
 MODULE_LICENSE("GPL");
 
 static struct net_device *dev_mvme147_lance;
-int init_module(void)
+int __init init_module(void)
 {
        dev_mvme147_lance = mvme147lance_probe(-1);
        if (IS_ERR(dev_mvme147_lance))
@@ -192,7 +192,7 @@ int init_module(void)
        return 0;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        struct m147lance_private *lp = dev_mvme147_lance->priv;
        unregister_netdev(dev_mvme147_lance);
index 38df428023863f899e6680a9ae5972ba51b7d999..81f127a78afae71206afde2a32ec4295c068aa20 100644 (file)
@@ -89,7 +89,7 @@ MODULE_LICENSE("Dual BSD/GPL");
 #define MYRI10GE_EEPROM_STRINGS_SIZE 256
 #define MYRI10GE_MAX_SEND_DESC_TSO ((65536 / 2048) * 2)
 
-#define MYRI10GE_NO_CONFIRM_DATA 0xffffffff
+#define MYRI10GE_NO_CONFIRM_DATA htonl(0xffffffff)
 #define MYRI10GE_NO_RESPONSE_RESULT 0xffffffff
 
 struct myri10ge_rx_buffer_state {
@@ -156,8 +156,8 @@ struct myri10ge_priv {
        int sram_size;
        unsigned long board_span;
        unsigned long iomem_base;
-       u32 __iomem *irq_claim;
-       u32 __iomem *irq_deassert;
+       __be32 __iomem *irq_claim;
+       __be32 __iomem *irq_deassert;
        char *mac_addr_string;
        struct mcp_cmd_response *cmd;
        dma_addr_t cmd_bus;
@@ -165,10 +165,10 @@ struct myri10ge_priv {
        dma_addr_t fw_stats_bus;
        struct pci_dev *pdev;
        int msi_enabled;
-       unsigned int link_state;
+       __be32 link_state;
        unsigned int rdma_tags_available;
        int intr_coal_delay;
-       u32 __iomem *intr_coal_delay_ptr;
+       __be32 __iomem *intr_coal_delay_ptr;
        int mtrr;
        int wake_queue;
        int stop_queue;
@@ -273,6 +273,11 @@ MODULE_PARM_DESC(myri10ge_debug, "Debug level (0=none,...,16=all)");
 
 #define myri10ge_pio_copy(to,from,size) __iowrite64_copy(to,from,size/8)
 
+static inline void put_be32(__be32 val, __be32 __iomem *p)
+{
+       __raw_writel((__force __u32)val, (__force void __iomem *)p);
+}
+
 static int
 myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
                  struct myri10ge_cmd *data, int atomic)
@@ -296,7 +301,7 @@ myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
 
        buf->response_addr.low = htonl(dma_low);
        buf->response_addr.high = htonl(dma_high);
-       response->result = MYRI10GE_NO_RESPONSE_RESULT;
+       response->result = htonl(MYRI10GE_NO_RESPONSE_RESULT);
        mb();
        myri10ge_pio_copy(cmd_addr, buf, sizeof(*buf));
 
@@ -311,14 +316,14 @@ myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
                 * (1ms will be enough for those commands) */
                for (sleep_total = 0;
                     sleep_total < 1000
-                    && response->result == MYRI10GE_NO_RESPONSE_RESULT;
+                    && response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT);
                     sleep_total += 10)
                        udelay(10);
        } else {
                /* use msleep for most command */
                for (sleep_total = 0;
                     sleep_total < 15
-                    && response->result == MYRI10GE_NO_RESPONSE_RESULT;
+                    && response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT);
                     sleep_total++)
                        msleep(1);
        }
@@ -393,7 +398,7 @@ abort:
 static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable)
 {
        char __iomem *submit;
-       u32 buf[16];
+       __be32 buf[16];
        u32 dma_low, dma_high;
        int i;
 
@@ -410,7 +415,7 @@ static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable)
 
        buf[0] = htonl(dma_high);       /* confirm addr MSW */
        buf[1] = htonl(dma_low);        /* confirm addr LSW */
-       buf[2] = htonl(MYRI10GE_NO_CONFIRM_DATA);       /* confirm data */
+       buf[2] = MYRI10GE_NO_CONFIRM_DATA;      /* confirm data */
        buf[3] = htonl(dma_high);       /* dummy addr MSW */
        buf[4] = htonl(dma_low);        /* dummy addr LSW */
        buf[5] = htonl(enable); /* enable? */
@@ -479,7 +484,7 @@ static int myri10ge_load_hotplug_firmware(struct myri10ge_priv *mgp, u32 * size)
        }
 
        /* check id */
-       hdr_offset = ntohl(*(u32 *) (fw->data + MCP_HEADER_PTR_OFFSET));
+       hdr_offset = ntohl(*(__be32 *) (fw->data + MCP_HEADER_PTR_OFFSET));
        if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > fw->size) {
                dev_err(dev, "Bad firmware file\n");
                status = -EINVAL;
@@ -550,7 +555,7 @@ static int myri10ge_adopt_running_firmware(struct myri10ge_priv *mgp)
 static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
 {
        char __iomem *submit;
-       u32 buf[16];
+       __be32 buf[16];
        u32 dma_low, dma_high, size;
        int status, i;
 
@@ -600,7 +605,7 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
 
        buf[0] = htonl(dma_high);       /* confirm addr MSW */
        buf[1] = htonl(dma_low);        /* confirm addr LSW */
-       buf[2] = htonl(MYRI10GE_NO_CONFIRM_DATA);       /* confirm data */
+       buf[2] = MYRI10GE_NO_CONFIRM_DATA;      /* confirm data */
 
        /* FIX: All newest firmware should un-protect the bottom of
         * the sram before handoff. However, the very first interfaces
@@ -705,21 +710,21 @@ static int myri10ge_reset(struct myri10ge_priv *mgp)
 
        status |=
            myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_ACK_OFFSET, &cmd, 0);
-       mgp->irq_claim = (__iomem u32 *) (mgp->sram + cmd.data0);
+       mgp->irq_claim = (__iomem __be32 *) (mgp->sram + cmd.data0);
        if (!mgp->msi_enabled) {
                status |= myri10ge_send_cmd
                    (mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, &cmd, 0);
-               mgp->irq_deassert = (__iomem u32 *) (mgp->sram + cmd.data0);
+               mgp->irq_deassert = (__iomem __be32 *) (mgp->sram + cmd.data0);
 
        }
        status |= myri10ge_send_cmd
            (mgp, MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET, &cmd, 0);
-       mgp->intr_coal_delay_ptr = (__iomem u32 *) (mgp->sram + cmd.data0);
+       mgp->intr_coal_delay_ptr = (__iomem __be32 *) (mgp->sram + cmd.data0);
        if (status != 0) {
                dev_err(&mgp->pdev->dev, "failed set interrupt parameters\n");
                return status;
        }
-       __raw_writel(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
+       put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
 
        /* Run a small DMA test.
         * The magic multipliers to the length tell the firmware
@@ -786,14 +791,16 @@ static inline void
 myri10ge_submit_8rx(struct mcp_kreq_ether_recv __iomem * dst,
                    struct mcp_kreq_ether_recv *src)
 {
-       u32 low;
+       __be32 low;
 
        low = src->addr_low;
-       src->addr_low = DMA_32BIT_MASK;
-       myri10ge_pio_copy(dst, src, 8 * sizeof(*src));
+       src->addr_low = htonl(DMA_32BIT_MASK);
+       myri10ge_pio_copy(dst, src, 4 * sizeof(*src));
+       mb();
+       myri10ge_pio_copy(dst + 4, src + 4, 4 * sizeof(*src));
        mb();
        src->addr_low = low;
-       __raw_writel(low, &dst->addr_low);
+       put_be32(low, &dst->addr_low);
        mb();
 }
 
@@ -939,11 +946,11 @@ done:
        return retval;
 }
 
-static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, u16 hw_csum)
+static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, __wsum hw_csum)
 {
        struct vlan_hdr *vh = (struct vlan_hdr *)(skb->data);
 
-       if ((skb->protocol == ntohs(ETH_P_8021Q)) &&
+       if ((skb->protocol == htons(ETH_P_8021Q)) &&
            (vh->h_vlan_encapsulated_proto == htons(ETH_P_IP) ||
             vh->h_vlan_encapsulated_proto == htons(ETH_P_IPV6))) {
                skb->csum = hw_csum;
@@ -953,7 +960,7 @@ static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, u16 hw_csum)
 
 static inline unsigned long
 myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
-                int bytes, int len, int csum)
+                int bytes, int len, __wsum csum)
 {
        dma_addr_t bus;
        struct sk_buff *skb;
@@ -986,12 +993,12 @@ myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
 
        skb->protocol = eth_type_trans(skb, mgp->dev);
        if (mgp->csum_flag) {
-               if ((skb->protocol == ntohs(ETH_P_IP)) ||
-                   (skb->protocol == ntohs(ETH_P_IPV6))) {
-                       skb->csum = ntohs((u16) csum);
+               if ((skb->protocol == htons(ETH_P_IP)) ||
+                   (skb->protocol == htons(ETH_P_IPV6))) {
+                       skb->csum = csum;
                        skb->ip_summed = CHECKSUM_COMPLETE;
                } else
-                       myri10ge_vlan_ip_csum(skb, ntohs((u16) csum));
+                       myri10ge_vlan_ip_csum(skb, csum);
        }
 
        netif_receive_skb(skb);
@@ -1060,12 +1067,12 @@ static inline void myri10ge_clean_rx_done(struct myri10ge_priv *mgp, int *limit)
        int idx = rx_done->idx;
        int cnt = rx_done->cnt;
        u16 length;
-       u16 checksum;
+       __wsum checksum;
 
        while (rx_done->entry[idx].length != 0 && *limit != 0) {
                length = ntohs(rx_done->entry[idx].length);
                rx_done->entry[idx].length = 0;
-               checksum = ntohs(rx_done->entry[idx].checksum);
+               checksum = csum_unfold(rx_done->entry[idx].checksum);
                if (length <= mgp->small_bytes)
                        rx_ok = myri10ge_rx_done(mgp, &mgp->rx_small,
                                                 mgp->small_bytes,
@@ -1142,7 +1149,7 @@ static int myri10ge_poll(struct net_device *netdev, int *budget)
 
        if (rx_done->entry[rx_done->idx].length == 0 || !netif_running(netdev)) {
                netif_rx_complete(netdev);
-               __raw_writel(htonl(3), mgp->irq_claim);
+               put_be32(htonl(3), mgp->irq_claim);
                return 0;
        }
        return 1;
@@ -1166,7 +1173,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg)
                netif_rx_schedule(mgp->dev);
 
        if (!mgp->msi_enabled) {
-               __raw_writel(0, mgp->irq_deassert);
+               put_be32(0, mgp->irq_deassert);
                if (!myri10ge_deassert_wait)
                        stats->valid = 0;
                mb();
@@ -1195,7 +1202,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg)
 
        myri10ge_check_statblock(mgp);
 
-       __raw_writel(htonl(3), mgp->irq_claim + 1);
+       put_be32(htonl(3), mgp->irq_claim + 1);
        return (IRQ_HANDLED);
 }
 
@@ -1233,7 +1240,7 @@ myri10ge_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coal)
        struct myri10ge_priv *mgp = netdev_priv(netdev);
 
        mgp->intr_coal_delay = coal->rx_coalesce_usecs;
-       __raw_writel(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
+       put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
        return 0;
 }
 
@@ -1748,7 +1755,7 @@ static int myri10ge_open(struct net_device *dev)
                goto abort_with_rings;
        }
 
-       mgp->link_state = -1;
+       mgp->link_state = htonl(~0U);
        mgp->rdma_tags_available = 15;
 
        netif_poll_enable(mgp->dev);    /* must happen prior to any irq */
@@ -1876,7 +1883,7 @@ myri10ge_submit_req(struct myri10ge_tx_buf *tx, struct mcp_kreq_ether_send *src,
 
        /* re-write the last 32-bits with the valid flags */
        src->flags = last_flags;
-       __raw_writel(*((u32 *) src + 3), (u32 __iomem *) dst + 3);
+       put_be32(*((__be32 *) src + 3), (__be32 __iomem *) dst + 3);
        tx->req += cnt;
        mb();
 }
@@ -1919,7 +1926,8 @@ static int myri10ge_xmit(struct sk_buff *skb, struct net_device *dev)
        struct myri10ge_tx_buf *tx = &mgp->tx;
        struct skb_frag_struct *frag;
        dma_addr_t bus;
-       u32 low, high_swapped;
+       u32 low;
+       __be32 high_swapped;
        unsigned int len;
        int idx, last_idx, avail, frag_cnt, frag_idx, count, mss, max_segments;
        u16 pseudo_hdr_offset, cksum_offset;
@@ -1964,7 +1972,6 @@ again:
                        cksum_offset = 0;
                        pseudo_hdr_offset = 0;
                } else {
-                       pseudo_hdr_offset = htons(pseudo_hdr_offset);
                        odd_flag = MXGEFW_FLAGS_ALIGN_ODD;
                        flags |= MXGEFW_FLAGS_CKSUM;
                }
@@ -1986,7 +1993,7 @@ again:
                /* for TSO, pseudo_hdr_offset holds mss.
                 * The firmware figures out where to put
                 * the checksum by parsing the header. */
-               pseudo_hdr_offset = htons(mss);
+               pseudo_hdr_offset = mss;
        } else
 #endif                         /*NETIF_F_TSO */
                /* Mark small packets, and pad out tiny packets */
@@ -2086,7 +2093,7 @@ again:
 #endif                         /* NETIF_F_TSO */
                        req->addr_high = high_swapped;
                        req->addr_low = htonl(low);
-                       req->pseudo_hdr_offset = pseudo_hdr_offset;
+                       req->pseudo_hdr_offset = htons(pseudo_hdr_offset);
                        req->pad = 0;   /* complete solid 16-byte block; does this matter? */
                        req->rdma_count = 1;
                        req->length = htons(seglen);
@@ -2199,6 +2206,7 @@ static void myri10ge_set_multicast_list(struct net_device *dev)
        struct myri10ge_cmd cmd;
        struct myri10ge_priv *mgp;
        struct dev_mc_list *mc_list;
+       __be32 data[2] = {0, 0};
        int err;
 
        mgp = netdev_priv(dev);
@@ -2237,10 +2245,9 @@ static void myri10ge_set_multicast_list(struct net_device *dev)
 
        /* Walk the multicast list, and add each address */
        for (mc_list = dev->mc_list; mc_list != NULL; mc_list = mc_list->next) {
-               memcpy(&cmd.data0, &mc_list->dmi_addr, 4);
-               memcpy(&cmd.data1, ((char *)&mc_list->dmi_addr) + 4, 2);
-               cmd.data0 = htonl(cmd.data0);
-               cmd.data1 = htonl(cmd.data1);
+               memcpy(data, &mc_list->dmi_addr, 6);
+               cmd.data0 = ntohl(data[0]);
+               cmd.data1 = ntohl(data[1]);
                err = myri10ge_send_cmd(mgp, MXGEFW_JOIN_MULTICAST_GROUP,
                                        &cmd, 1);
 
index 9519ae7cd5ec74f0dc9e64fca428b7b515c03ebe..29463b301a84f5a1eb9614bb01fab4bd021d2d57 100644 (file)
@@ -6,23 +6,23 @@
 
 /* 8 Bytes */
 struct mcp_dma_addr {
-       u32 high;
-       u32 low;
+       __be32 high;
+       __be32 low;
 };
 
 /* 4 Bytes */
 struct mcp_slot {
-       u16 checksum;
-       u16 length;
+       __sum16 checksum;
+       __be16 length;
 };
 
 /* 64 Bytes */
 struct mcp_cmd {
-       u32 cmd;
-       u32 data0;              /* will be low portion if data > 32 bits */
+       __be32 cmd;
+       __be32 data0;           /* will be low portion if data > 32 bits */
        /* 8 */
-       u32 data1;              /* will be high portion if data > 32 bits */
-       u32 data2;              /* currently unused.. */
+       __be32 data1;           /* will be high portion if data > 32 bits */
+       __be32 data2;           /* currently unused.. */
        /* 16 */
        struct mcp_dma_addr response_addr;
        /* 24 */
@@ -31,8 +31,8 @@ struct mcp_cmd {
 
 /* 8 Bytes */
 struct mcp_cmd_response {
-       u32 data;
-       u32 result;
+       __be32 data;
+       __be32 result;
 };
 
 /*
@@ -73,10 +73,10 @@ union mcp_pso_or_cumlen {
 
 /* 16 Bytes */
 struct mcp_kreq_ether_send {
-       u32 addr_high;
-       u32 addr_low;
-       u16 pseudo_hdr_offset;
-       u16 length;
+       __be32 addr_high;
+       __be32 addr_low;
+       __be16 pseudo_hdr_offset;
+       __be16 length;
        u8 pad;
        u8 rdma_count;
        u8 cksum_offset;        /* where to start computing cksum */
@@ -85,8 +85,8 @@ struct mcp_kreq_ether_send {
 
 /* 8 Bytes */
 struct mcp_kreq_ether_recv {
-       u32 addr_high;
-       u32 addr_low;
+       __be32 addr_high;
+       __be32 addr_low;
 };
 
 /* Commands */
@@ -219,19 +219,19 @@ enum myri10ge_mcp_cmd_status {
 
 struct mcp_irq_data {
        /* add new counters at the beginning */
-       u32 future_use[5];
-       u32 dropped_multicast_filtered;
+       __be32 future_use[5];
+       __be32 dropped_multicast_filtered;
        /* 40 Bytes */
-       u32 send_done_count;
-
-       u32 link_up;
-       u32 dropped_link_overflow;
-       u32 dropped_link_error_or_filtered;
-       u32 dropped_runt;
-       u32 dropped_overrun;
-       u32 dropped_no_small_buffer;
-       u32 dropped_no_big_buffer;
-       u32 rdma_tags_available;
+       __be32 send_done_count;
+
+       __be32 link_up;
+       __be32 dropped_link_overflow;
+       __be32 dropped_link_error_or_filtered;
+       __be32 dropped_runt;
+       __be32 dropped_overrun;
+       __be32 dropped_no_small_buffer;
+       __be32 dropped_no_big_buffer;
+       __be32 rdma_tags_available;
 
        u8 tx_stopped;
        u8 link_down;
index 487f7792fd469bfb871a258690fa92e74d0167d2..16a810dd6d515d4ed7a6f61ceb7b443131c34b9e 100644 (file)
@@ -36,7 +36,7 @@
 struct mcp_gen_header {
        /* the first 4 fields are filled at compile time */
        unsigned header_length;
-       unsigned mcp_type;
+       __be32 mcp_type;
        char version[128];
        unsigned mcp_globals;   /* pointer to mcp-type specific structure */
 
index 787aa4221528cb4f47ad038d7ee6b29d3e86354f..a5c4199e2754cff0abc74303afd443e684386bce 100644 (file)
@@ -867,7 +867,7 @@ static void cleanup_card(struct net_device *dev)
        release_region(dev->base_addr, NE_IO_EXTENT);
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        int this_dev;
 
index 5fccfea66d8751cd66f300f383b3d95ba1e444c3..089b5bb702fcbccbc5dd6072fe5f5c315e11123b 100644 (file)
@@ -813,7 +813,7 @@ static void cleanup_card(struct net_device *dev)
        release_region(dev->base_addr, NE_IO_EXTENT);
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        int this_dev;
 
index 9c588af8ab749217fb10f9181f65d3f4fa5a26f2..b5410bee5f21dc962bca2508ad4a9a88dd47da35 100644 (file)
@@ -1,25 +1,25 @@
 /*
  * Copyright (C) 2003 - 2006 NetXen, Inc.
  * 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:
  *    info@netxen.com
  * NetXen,
 
 #include "netxen_nic_hw.h"
 
-#define NETXEN_NIC_BUILD_NO     "5"
-#define _NETXEN_NIC_LINUX_MAJOR 2
+#define NETXEN_NIC_BUILD_NO     "1"
+#define _NETXEN_NIC_LINUX_MAJOR 3
 #define _NETXEN_NIC_LINUX_MINOR 3
-#define _NETXEN_NIC_LINUX_SUBVERSION 59
-#define NETXEN_NIC_LINUX_VERSIONID  "2.3.59" "-" NETXEN_NIC_BUILD_NO
-#define NETXEN_NIC_FW_VERSIONID "2.3.59"
+#define _NETXEN_NIC_LINUX_SUBVERSION 2
+#define NETXEN_NIC_LINUX_VERSIONID  "3.3.2" "-" NETXEN_NIC_BUILD_NO
+#define NETXEN_NIC_FW_VERSIONID "3.3.2"
 
 #define RCV_DESC_RINGSIZE      \
        (sizeof(struct rcv_desc) * adapter->max_rx_desc_count)
 #define STATUS_DESC_RINGSIZE   \
        (sizeof(struct status_desc)* adapter->max_rx_desc_count)
+#define LRO_DESC_RINGSIZE      \
+       (sizeof(rcvDesc_t) * adapter->max_lro_rx_desc_count)
 #define TX_RINGSIZE    \
        (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count)
 #define RCV_BUFFSIZE   \
        (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count)
 #define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a)))
 
-#define NETXEN_NETDEV_STATUS 0x1
+#define NETXEN_NETDEV_STATUS           0x1
+#define NETXEN_RCV_PRODUCER_OFFSET     0
+#define NETXEN_RCV_PEG_DB_ID           2
+#define NETXEN_HOST_DUMMY_DMA_SIZE 1024
 
 #define ADDR_IN_WINDOW1(off)   \
        ((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0
+/*
+ * In netxen_nic_down(), we must wait for any pending callback requests into
+ * netxen_watchdog_task() to complete; eg otherwise the watchdog_timer could be
+ * reenabled right after it is deleted in netxen_nic_down(). FLUSH_SCHEDULED_WORK()
+ * does this synchronization.
+ *
+ * Normally, schedule_work()/flush_scheduled_work() could have worked, but
+ * netxen_nic_close() is invoked with kernel rtnl lock held. netif_carrier_off()
+ * call in netxen_nic_close() triggers a schedule_work(&linkwatch_work), and a
+ * subsequent call to flush_scheduled_work() in netxen_nic_down() would cause
+ * linkwatch_event() to be executed which also attempts to acquire the rtnl
+ * lock thus causing a deadlock.
+ */
+
+#define SCHEDULE_WORK(tp)      queue_work(netxen_workq, tp)
+#define FLUSH_SCHEDULED_WORK() flush_workqueue(netxen_workq)
+extern struct workqueue_struct *netxen_workq;
 
 /* 
  * normalize a 64MB crb address to 32MB PCI window 
  * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1
  */
-#define NETXEN_CRB_NORMAL(reg)        \
-       (reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST
+#define NETXEN_CRB_NORMAL(reg) \
+       ((reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST)
 
 #define NETXEN_CRB_NORMALIZE(adapter, reg) \
        pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg))
 
+#define DB_NORMALIZE(adapter, off) \
+       (adapter->ahw.db_base + (off))
+
+#define NX_P2_C0               0x24
+#define NX_P2_C1               0x25
+
 #define FIRST_PAGE_GROUP_START 0
-#define FIRST_PAGE_GROUP_END   0x400000
+#define FIRST_PAGE_GROUP_END   0x100000
 
 #define SECOND_PAGE_GROUP_START        0x4000000
 #define SECOND_PAGE_GROUP_END  0x66BC000
 #define SECOND_PAGE_GROUP_SIZE SECOND_PAGE_GROUP_END - SECOND_PAGE_GROUP_START
 #define THIRD_PAGE_GROUP_SIZE  THIRD_PAGE_GROUP_END - THIRD_PAGE_GROUP_START
 
-#define MAX_RX_BUFFER_LENGTH           2000
+#define MAX_RX_BUFFER_LENGTH           1760
 #define MAX_RX_JUMBO_BUFFER_LENGTH     9046
-#define RX_DMA_MAP_LEN                 (MAX_RX_BUFFER_LENGTH - NET_IP_ALIGN)
+#define MAX_RX_LRO_BUFFER_LENGTH       ((48*1024)-512)
+#define RX_DMA_MAP_LEN                 (MAX_RX_BUFFER_LENGTH - 2)
 #define RX_JUMBO_DMA_MAP_LEN   \
-       (MAX_RX_JUMBO_BUFFER_LENGTH - NET_IP_ALIGN)
+       (MAX_RX_JUMBO_BUFFER_LENGTH - 2)
+#define RX_LRO_DMA_MAP_LEN             (MAX_RX_LRO_BUFFER_LENGTH - 2)
 #define NETXEN_ROM_ROUNDUP             0x80000000ULL
 
 /*
@@ -151,30 +181,38 @@ enum {
 /* Host writes the following to notify that it has done the init-handshake */
 #define PHAN_INITIALIZE_ACK    0xf00f
 
-#define NUM_RCV_DESC_RINGS     2       /* No of Rcv Descriptor contexts */
+#define NUM_RCV_DESC_RINGS     3       /* No of Rcv Descriptor contexts */
 
 /* descriptor types */
 #define RCV_DESC_NORMAL                0x01
 #define RCV_DESC_JUMBO         0x02
+#define RCV_DESC_LRO           0x04
 #define RCV_DESC_NORMAL_CTXID  0
 #define RCV_DESC_JUMBO_CTXID   1
+#define RCV_DESC_LRO_CTXID     2
 
 #define RCV_DESC_TYPE(ID) \
-       ((ID == RCV_DESC_JUMBO_CTXID) ? RCV_DESC_JUMBO : RCV_DESC_NORMAL)
+       ((ID == RCV_DESC_JUMBO_CTXID)   \
+               ? RCV_DESC_JUMBO        \
+               : ((ID == RCV_DESC_LRO_CTXID)   \
+                       ? RCV_DESC_LRO :        \
+                       (RCV_DESC_NORMAL)))
 
 #define MAX_CMD_DESCRIPTORS            1024
 #define MAX_RCV_DESCRIPTORS            32768
-#define MAX_JUMBO_RCV_DESCRIPTORS      1024
+#define MAX_JUMBO_RCV_DESCRIPTORS      4096
+#define MAX_LRO_RCV_DESCRIPTORS                2048
 #define MAX_RCVSTATUS_DESCRIPTORS      MAX_RCV_DESCRIPTORS
 #define MAX_JUMBO_RCV_DESC     MAX_JUMBO_RCV_DESCRIPTORS
 #define MAX_RCV_DESC           MAX_RCV_DESCRIPTORS
 #define MAX_RCVSTATUS_DESC     MAX_RCV_DESCRIPTORS
-#define NUM_RCV_DESC           (MAX_RCV_DESC + MAX_JUMBO_RCV_DESCRIPTORS)
 #define MAX_EPG_DESCRIPTORS    (MAX_CMD_DESCRIPTORS * 8)
-
+#define NUM_RCV_DESC           (MAX_RCV_DESC + MAX_JUMBO_RCV_DESCRIPTORS + \
+                                MAX_LRO_RCV_DESCRIPTORS)
 #define MIN_TX_COUNT   4096
 #define MIN_RX_COUNT   4096
-
+#define NETXEN_CTX_SIGNATURE   0xdee0
+#define NETXEN_RCV_PRODUCER(ringid)    (ringid)
 #define MAX_FRAME_SIZE 0x10000 /* 64K MAX size for LSO */
 
 #define PHAN_PEG_RCV_INITIALIZED       0xff01
@@ -186,6 +224,67 @@ enum {
 #define get_index_range(index,length,count)    \
        (((index) + (count)) & ((length) - 1))
 
+#define MPORT_SINGLE_FUNCTION_MODE 0x1111
+
+extern unsigned long long netxen_dma_mask;
+
+/*
+ * NetXen host-peg signal message structure
+ *
+ *     Bit 0-1         : peg_id => 0x2 for tx and 01 for rx
+ *     Bit 2           : priv_id => must be 1
+ *     Bit 3-17        : count => for doorbell
+ *     Bit 18-27       : ctx_id => Context id
+ *     Bit 28-31       : opcode
+ */
+
+typedef u32 netxen_ctx_msg;
+
+#define _netxen_set_bits(config_word, start, bits, val)        {\
+       unsigned long long mask = (((1ULL << (bits)) - 1) << (start));  \
+       unsigned long long value = (val);       \
+       (config_word) &= ~mask; \
+       (config_word) |= (((value) << (start)) & mask); \
+}
+
+#define netxen_set_msg_peg_id(config_word, val)        \
+       _netxen_set_bits(config_word, 0, 2, val)
+#define netxen_set_msg_privid(config_word)     \
+       set_bit(2, (unsigned long*)&config_word)
+#define netxen_set_msg_count(config_word, val) \
+       _netxen_set_bits(config_word, 3, 15, val)
+#define netxen_set_msg_ctxid(config_word, val) \
+       _netxen_set_bits(config_word, 18, 10, val)
+#define netxen_set_msg_opcode(config_word, val)        \
+       _netxen_set_bits(config_word, 28, 4, val)
+
+struct netxen_rcv_context {
+       u32 rcv_ring_addr_lo;
+       u32 rcv_ring_addr_hi;
+       u32 rcv_ring_size;
+       u32 rsrvd;
+};
+
+struct netxen_ring_ctx {
+
+       /* one command ring */
+       u64 cmd_consumer_offset;
+       u32 cmd_ring_addr_lo;
+       u32 cmd_ring_addr_hi;
+       u32 cmd_ring_size;
+       u32 rsrvd;
+
+       /* three receive rings */
+       struct netxen_rcv_context rcv_ctx[3];
+
+       /* one status ring */
+       u32 sts_ring_addr_lo;
+       u32 sts_ring_addr_hi;
+       u32 sts_ring_size;
+
+       u32 ctx_id;
+} __attribute__ ((aligned(64)));
+
 /*
  * Following data structures describe the descriptors that will be used.
  * Added fileds of tcpHdrSize and ipHdrSize, The driver needs to do it only when
@@ -203,22 +302,32 @@ enum {
 #define FLAGS_IPSEC_SA_DELETE  0x08
 #define FLAGS_VLAN_TAGGED      0x10
 
-#define CMD_DESC_TOTAL_LENGTH(cmd_desc)        \
-               ((cmd_desc)->length_tcp_hdr & 0x00FFFFFF)
-#define CMD_DESC_TCP_HDR_OFFSET(cmd_desc)      \
-               (((cmd_desc)->length_tcp_hdr >> 24) & 0x0FF)
-#define CMD_DESC_PORT(cmd_desc)                ((cmd_desc)->port_ctxid & 0x0F)
-#define CMD_DESC_CTX_ID(cmd_desc)      (((cmd_desc)->port_ctxid >> 4) & 0x0F)
+#define netxen_set_cmd_desc_port(cmd_desc, var)        \
+       ((cmd_desc)->port_ctxid |= ((var) & 0x0F))
 
-#define CMD_DESC_TOTAL_LENGTH_WRT(cmd_desc, var)       \
-               ((cmd_desc)->length_tcp_hdr |= ((var) & 0x00FFFFFF))
-#define CMD_DESC_TCP_HDR_OFFSET_WRT(cmd_desc, var)     \
-               ((cmd_desc)->length_tcp_hdr |= (((var) << 24) & 0xFF000000))
-#define CMD_DESC_PORT_WRT(cmd_desc, var)       \
-               ((cmd_desc)->port_ctxid |= ((var) & 0x0F))
+#define netxen_set_cmd_desc_flags(cmd_desc, val)       \
+       _netxen_set_bits((cmd_desc)->flags_opcode, 0, 7, val)
+#define netxen_set_cmd_desc_opcode(cmd_desc, val)      \
+       _netxen_set_bits((cmd_desc)->flags_opcode, 7, 6, val)
+
+#define netxen_set_cmd_desc_num_of_buff(cmd_desc, val) \
+       _netxen_set_bits((cmd_desc)->num_of_buffers_total_length, 0, 8, val);
+#define netxen_set_cmd_desc_totallength(cmd_desc, val) \
+       _netxen_set_bits((cmd_desc)->num_of_buffers_total_length, 8, 24, val);
+
+#define netxen_get_cmd_desc_opcode(cmd_desc)   \
+       (((cmd_desc)->flags_opcode >> 7) & 0x003F)
+#define netxen_get_cmd_desc_totallength(cmd_desc)      \
+       (((cmd_desc)->num_of_buffers_total_length >> 8) & 0x0FFFFFF)
 
 struct cmd_desc_type0 {
-       u64 netxen_next;        /* for fragments handled by Phantom */
+       u8 tcp_hdr_offset;      /* For LSO only */
+       u8 ip_hdr_offset;       /* For LSO only */
+       /* Bit pattern: 0-6 flags, 7-12 opcode, 13-15 unused */
+       u16 flags_opcode;
+       /* Bit pattern: 0-7 total number of segments,
+          8-31 Total size of the packet */
+       u32 num_of_buffers_total_length;
        union {
                struct {
                        u32 addr_low_part2;
@@ -227,13 +336,6 @@ struct cmd_desc_type0 {
                u64 addr_buffer2;
        };
 
-       /* Bit pattern: 0-23 total length, 24-32 tcp header offset */
-       u32 length_tcp_hdr;
-       u8 ip_hdr_offset;       /* For LSO only */
-       u8 num_of_buffers;      /* total number of segments */
-       u8 flags;               /* as defined above */
-       u8 opcode;
-
        u16 reference_handle;   /* changed to u16 to add mss */
        u16 mss;                /* passed by NDIS_PACKET for LSO */
        /* Bit pattern 0-3 port, 0-3 ctx id */
@@ -248,7 +350,6 @@ struct cmd_desc_type0 {
                };
                u64 addr_buffer3;
        };
-
        union {
                struct {
                        u32 addr_low_part1;
@@ -270,6 +371,8 @@ struct cmd_desc_type0 {
                u64 addr_buffer4;
        };
 
+       u64 unused;
+
 } __attribute__ ((aligned(64)));
 
 /* Note: sizeof(rcv_desc) should always be a mutliple of 2 */
@@ -296,22 +399,49 @@ struct rcv_desc {
 #define NETXEN_PROT_UNKNOWN    (0)
 
 /* Note: sizeof(status_desc) should always be a mutliple of 2 */
-#define STATUS_DESC_PORT(status_desc)  \
-               ((status_desc)->port_status_type_op & 0x0F)
-#define STATUS_DESC_STATUS(status_desc)        \
-               (((status_desc)->port_status_type_op >> 4) & 0x0F)
-#define STATUS_DESC_TYPE(status_desc)  \
-               (((status_desc)->port_status_type_op >> 8) & 0x0F)
-#define STATUS_DESC_OPCODE(status_desc)        \
-               (((status_desc)->port_status_type_op >> 12) & 0x0F)
+
+#define netxen_get_sts_desc_lro_cnt(status_desc)       \
+       ((status_desc)->lro & 0x7F)
+#define netxen_get_sts_desc_lro_last_frag(status_desc) \
+       (((status_desc)->lro & 0x80) >> 7)
+
+#define netxen_get_sts_port(status_desc)       \
+       ((status_desc)->status_desc_data & 0x0F)
+#define netxen_get_sts_status(status_desc)     \
+       (((status_desc)->status_desc_data >> 4) & 0x0F)
+#define netxen_get_sts_type(status_desc)       \
+       (((status_desc)->status_desc_data >> 8) & 0x0F)
+#define netxen_get_sts_totallength(status_desc)        \
+       (((status_desc)->status_desc_data >> 12) & 0xFFFF)
+#define netxen_get_sts_refhandle(status_desc)  \
+       (((status_desc)->status_desc_data >> 28) & 0xFFFF)
+#define netxen_get_sts_prot(status_desc)       \
+       (((status_desc)->status_desc_data >> 44) & 0x0F)
+#define netxen_get_sts_owner(status_desc)      \
+       (((status_desc)->status_desc_data >> 56) & 0x03)
+#define netxen_get_sts_opcode(status_desc)     \
+       (((status_desc)->status_desc_data >> 58) & 0x03F)
+
+#define netxen_clear_sts_owner(status_desc)    \
+       ((status_desc)->status_desc_data &=     \
+       ~(((unsigned long long)3) << 56 ))
+#define netxen_set_sts_owner(status_desc, val) \
+       ((status_desc)->status_desc_data |=     \
+       (((unsigned long long)((val) & 0x3)) << 56 ))
 
 struct status_desc {
-       /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-15 opcode */
-       u16 port_status_type_op;
-       u16 total_length;       /* NIC mode */
-       u16 reference_handle;   /* handle for the associated packet */
-       /* Bit pattern: 0-1 owner, 2-5 protocol */
-       u16 owner;              /* Owner of the descriptor */
+       /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length
+          28-43 reference_handle, 44-47 protocol, 48-52 unused
+          53-55 desc_cnt, 56-57 owner, 58-63 opcode
+        */
+       u64 status_desc_data;
+       u32 hash_value;
+       u8 hash_type;
+       u8 msg_type;
+       u8 unused;
+       /* Bit pattern: 0-6 lro_count indicates frag sequence,
+          7 last_frag indicates last frag */
+       u8 lro;
 } __attribute__ ((aligned(8)));
 
 enum {
@@ -559,11 +689,12 @@ typedef enum {
 #define PRIMARY_START          (BOOTLD_START)
 #define FLASH_CRBINIT_SIZE     (0x4000)
 #define FLASH_BRDCFG_SIZE      (sizeof(struct netxen_board_info))
-#define FLASH_USER_SIZE                (sizeof(netxen_user_info)/sizeof(u32))
+#define FLASH_USER_SIZE                (sizeof(struct netxen_user_info)/sizeof(u32))
 #define FLASH_SECONDARY_SIZE   (USER_START-SECONDARY_START)
 #define NUM_PRIMARY_SECTORS    (0x20)
 #define NUM_CONFIG_SECTORS     (1)
-#define PFX "netxen: "
+#define PFX "NetXen: "
+extern char netxen_nic_driver_name[];
 
 /* Note: Make sure to not call this before adapter->port is valid */
 #if !defined(NETXEN_DEBUG)
@@ -572,7 +703,7 @@ typedef enum {
 #else
 #define DPRINTK(klevel, fmt, args...)  do { \
        printk(KERN_##klevel PFX "%s: %s: " fmt, __FUNCTION__,\
-               (adapter != NULL && adapter->port != NULL && \
+               (adapter != NULL && \
                adapter->port[0] != NULL && \
                adapter->port[0]->netdev != NULL) ? \
                adapter->port[0]->netdev->name : NULL, \
@@ -609,7 +740,6 @@ struct netxen_cmd_buffer {
        u8 frag_count;
        unsigned long time_stamp;
        u32 state;
-       u32 no_of_descriptors;
 };
 
 /* In rx_buffer, we do not need multiple fragments as is a single buffer */
@@ -618,6 +748,9 @@ struct netxen_rx_buffer {
        u64 dma;
        u16 ref_handle;
        u16 state;
+       u32 lro_expected_frags;
+       u32 lro_current_frags;
+       u32 lro_length;
 };
 
 /* Board types */
@@ -633,6 +766,8 @@ struct netxen_hardware_context {
        void __iomem *pci_base0;
        void __iomem *pci_base1;
        void __iomem *pci_base2;
+       void __iomem *db_base;
+       unsigned long db_len;
 
        u8 revision_id;
        u16 board_type;
@@ -642,14 +777,13 @@ struct netxen_hardware_context {
        u32 qg_linksup;
        /* Address of cmd ring in Phantom */
        struct cmd_desc_type0 *cmd_desc_head;
-       char *pauseaddr;
        struct pci_dev *cmd_desc_pdev;
        dma_addr_t cmd_desc_phys_addr;
-       dma_addr_t pause_physaddr;
-       struct pci_dev *pause_pdev;
        struct netxen_adapter *adapter;
 };
 
+#define RCV_RING_LRO   RCV_DESC_LRO
+
 #define MINIMUM_ETHERNET_FRAME_SIZE    64      /* With FCS */
 #define ETHERNET_FCS_SIZE              4
 
@@ -702,8 +836,13 @@ struct netxen_recv_context {
 };
 
 #define NETXEN_NIC_MSI_ENABLED 0x02
+#define NETXEN_DMA_MASK        0xfffffffe
+#define NETXEN_DB_MAPSIZE_BYTES    0x1000
 
-struct netxen_drvops;
+struct netxen_dummy_dma {
+       void *addr;
+       dma_addr_t phys_addr;
+};
 
 struct netxen_adapter {
        struct netxen_hardware_context ahw;
@@ -720,12 +859,13 @@ struct netxen_adapter {
        u32 curr_window;
 
        u32 cmd_producer;
-       u32 cmd_consumer;
+       u32 *cmd_consumer;
 
        u32 last_cmd_consumer;
        u32 max_tx_desc_count;
        u32 max_rx_desc_count;
        u32 max_jumbo_rx_desc_count;
+       u32 max_lro_rx_desc_count;
        /* Num of instances active on cmd buffer ring */
        u32 proc_cmd_buf_counter;
 
@@ -747,8 +887,27 @@ struct netxen_adapter {
        struct netxen_recv_context recv_ctx[MAX_RCV_CTX];
 
        int is_up;
-       int work_done;
-       struct netxen_drvops *ops;
+       int number;
+       struct netxen_dummy_dma dummy_dma;
+
+       /* Context interface shared between card and host */
+       struct netxen_ring_ctx *ctx_desc;
+       struct pci_dev *ctx_desc_pdev;
+       dma_addr_t ctx_desc_phys_addr;
+       int (*enable_phy_interrupts) (struct netxen_adapter *, int);
+       int (*disable_phy_interrupts) (struct netxen_adapter *, int);
+       void (*handle_phy_intr) (struct netxen_adapter *);
+       int (*macaddr_set) (struct netxen_port *, netxen_ethernet_macaddr_t);
+       int (*set_mtu) (struct netxen_port *, int);
+       int (*set_promisc) (struct netxen_adapter *, int,
+                           netxen_niu_prom_mode_t);
+       int (*unset_promisc) (struct netxen_adapter *, int,
+                             netxen_niu_prom_mode_t);
+       int (*phy_read) (struct netxen_adapter *, long phy, long reg, u32 *);
+       int (*phy_write) (struct netxen_adapter *, long phy, long reg, u32 val);
+       int (*init_port) (struct netxen_adapter *, int);
+       void (*init_niu) (struct netxen_adapter *);
+       int (*stop_port) (struct netxen_adapter *, int);
 };                             /* netxen_adapter structure */
 
 /* Max number of xmit producer threads that can run simultaneously */
@@ -830,25 +989,6 @@ static inline void __iomem *pci_base(struct netxen_adapter *adapter,
        return NULL;
 }
 
-struct netxen_drvops {
-       int (*enable_phy_interrupts) (struct netxen_adapter *, int);
-       int (*disable_phy_interrupts) (struct netxen_adapter *, int);
-       void (*handle_phy_intr) (struct netxen_adapter *);
-       int (*macaddr_set) (struct netxen_port *, netxen_ethernet_macaddr_t);
-       int (*set_mtu) (struct netxen_port *, int);
-       int (*set_promisc) (struct netxen_adapter *, int,
-                           netxen_niu_prom_mode_t);
-       int (*unset_promisc) (struct netxen_adapter *, int,
-                             netxen_niu_prom_mode_t);
-       int (*phy_read) (struct netxen_adapter *, long phy, long reg, u32 *);
-       int (*phy_write) (struct netxen_adapter *, long phy, long reg, u32 val);
-       int (*init_port) (struct netxen_adapter *, int);
-       void (*init_niu) (struct netxen_adapter *);
-       int (*stop_port) (struct netxen_adapter *, int);
-};
-
-extern char netxen_nic_driver_name[];
-
 int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter,
                                          int port);
 int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter,
@@ -887,10 +1027,20 @@ int netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off, void *data,
                          int len);
 int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data,
                           int len);
+int netxen_nic_hw_read_ioctl(struct netxen_adapter *adapter, u64 off,
+                            void *data, int len);
+int netxen_nic_hw_write_ioctl(struct netxen_adapter *adapter, u64 off,
+                             void *data, int len);
+int netxen_nic_pci_mem_write_ioctl(struct netxen_adapter *adapter,
+                                  u64 off, void *data, int size);
+int netxen_nic_pci_mem_read_ioctl(struct netxen_adapter *adapter,
+                                 u64 off, void *data, int size);
 void netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
                                 unsigned long off, int data);
 
 /* Functions from netxen_nic_init.c */
+void netxen_free_adapter_offload(struct netxen_adapter *adapter);
+int netxen_initialize_adapter_offload(struct netxen_adapter *adapter);
 void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
 void netxen_load_firmware(struct netxen_adapter *adapter);
 int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose);
@@ -925,7 +1075,9 @@ int netxen_nic_tx_has_work(struct netxen_adapter *adapter);
 void netxen_watchdog_task(struct work_struct *work);
 void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx,
                            u32 ringid);
-void netxen_process_cmd_ring(unsigned long data);
+void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, u32 ctx,
+                                u32 ringid);
+int netxen_process_cmd_ring(unsigned long data);
 u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max);
 void netxen_nic_set_multi(struct net_device *netdev);
 int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu);
@@ -1019,7 +1171,6 @@ static inline void get_brd_name_by_type(u32 type, char *name)
 
 int netxen_is_flash_supported(struct netxen_adapter *adapter);
 int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]);
-
 extern void netxen_change_ringparam(struct netxen_adapter *adapter);
 extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr,
                                int *valp);
index 9a914aeba5bcd360c57ee2807dd37debbd329cc9..2ab4885cc950aa85eeb29dab1798da1bcbe26eef 100644 (file)
@@ -1,25 +1,25 @@
 /*
  * Copyright (C) 2003 - 2006 NetXen, Inc.
  * 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:
  *    info@netxen.com
  * NetXen,
@@ -118,7 +118,7 @@ netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo)
        u32 fw_minor = 0;
        u32 fw_build = 0;
 
-       strncpy(drvinfo->driver, "netxen_nic", 32);
+       strncpy(drvinfo->driver, netxen_nic_driver_name, 32);
        strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32);
        fw_major = readl(NETXEN_CRB_NORMALIZE(adapter,
                                              NETXEN_FW_VERSION_MAJOR));
@@ -210,7 +210,6 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
                printk(KERN_ERR "netxen-nic: Unsupported board model %d\n",
                       (netxen_brdtype_t) boardinfo->board_type);
                return -EIO;
-
        }
 
        return 0;
@@ -226,18 +225,18 @@ netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
        /* read which mode */
        if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
                /* autonegotiation */
-               if (adapter->ops->phy_write
-                   && adapter->ops->phy_write(adapter, port->portnum,
-                                              NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
-                                              (__le32) ecmd->autoneg) != 0)
+               if (adapter->phy_write
+                   && adapter->phy_write(adapter, port->portnum,
+                                         NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
+                                         (__le32) ecmd->autoneg) != 0)
                        return -EIO;
                else
                        port->link_autoneg = ecmd->autoneg;
 
-               if (adapter->ops->phy_read
-                   && adapter->ops->phy_read(adapter, port->portnum,
-                                             NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
-                                             &status) != 0)
+               if (adapter->phy_read
+                   && adapter->phy_read(adapter, port->portnum,
+                                        NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
+                                        &status) != 0)
                        return -EIO;
 
                /* speed */
@@ -257,10 +256,10 @@ netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
                        netxen_clear_phy_duplex(status);
                if (ecmd->duplex == DUPLEX_FULL)
                        netxen_set_phy_duplex(status);
-               if (adapter->ops->phy_write
-                   && adapter->ops->phy_write(adapter, port->portnum,
-                                              NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
-                                              *((int *)&status)) != 0)
+               if (adapter->phy_write
+                   && adapter->phy_write(adapter, port->portnum,
+                                         NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
+                                         *((int *)&status)) != 0)
                        return -EIO;
                else {
                        port->link_speed = ecmd->speed;
@@ -422,10 +421,10 @@ static u32 netxen_nic_get_link(struct net_device *dev)
 
        /* read which mode */
        if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
-               if (adapter->ops->phy_read
-                   && adapter->ops->phy_read(adapter, port->portnum,
-                                             NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
-                                             &status) != 0)
+               if (adapter->phy_read
+                   && adapter->phy_read(adapter, port->portnum,
+                                        NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
+                                        &status) != 0)
                        return -EIO;
                else
                        return (netxen_get_phy_link(status));
@@ -460,20 +459,22 @@ netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
 {
        struct netxen_port *port = netdev_priv(dev);
        struct netxen_adapter *adapter = port->adapter;
-       int i, j;
+       int i;
 
        ring->rx_pending = 0;
+       ring->rx_jumbo_pending = 0;
        for (i = 0; i < MAX_RCV_CTX; ++i) {
-               for (j = 0; j < NUM_RCV_DESC_RINGS; j++)
-                       ring->rx_pending +=
-                           adapter->recv_ctx[i].rcv_desc[j].rcv_pending;
+               ring->rx_pending += adapter->recv_ctx[i].
+                   rcv_desc[RCV_DESC_NORMAL_CTXID].rcv_pending;
+               ring->rx_jumbo_pending += adapter->recv_ctx[i].
+                   rcv_desc[RCV_DESC_JUMBO_CTXID].rcv_pending;
        }
 
        ring->rx_max_pending = adapter->max_rx_desc_count;
        ring->tx_max_pending = adapter->max_tx_desc_count;
+       ring->rx_jumbo_max_pending = adapter->max_jumbo_rx_desc_count;
        ring->rx_mini_max_pending = 0;
        ring->rx_mini_pending = 0;
-       ring->rx_jumbo_max_pending = 0;
        ring->rx_jumbo_pending = 0;
 }
 
@@ -526,10 +527,10 @@ netxen_nic_set_pauseparam(struct net_device *dev,
                                    *(u32 *) (&val));
                /* set autoneg */
                autoneg = pause->autoneg;
-               if (adapter->ops->phy_write
-                   && adapter->ops->phy_write(adapter, port->portnum,
-                                              NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
-                                              (__le32) autoneg) != 0)
+               if (adapter->phy_write
+                   && adapter->phy_write(adapter, port->portnum,
+                                         NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
+                                         (__le32) autoneg) != 0)
                        return -EIO;
                else {
                        port->link_autoneg = pause->autoneg;
index 72c6ec4ee2a06d876841f0e4a79c18fd1e69a253..fe8b675f9e72c69deefc464af835b91f1ae6cfaf 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2003 - 2006 NetXen, Inc.
  * 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
  * 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:
  *    info@netxen.com
  * NetXen,
index 105c24f0ad4c75249f683b2c893600bbfcabc7d2..9147b6048dfb772be99f911a09d474cc484ebf06 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2003 - 2006 NetXen, Inc.
  * 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
  * 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:
  *    info@netxen.com
  * NetXen,
@@ -42,7 +42,7 @@
 
 #define NETXEN_FLASH_BASE      (BOOTLD_START)
 #define NETXEN_PHANTOM_MEM_BASE        (NETXEN_FLASH_BASE)
-#define NETXEN_MAX_MTU         8000
+#define NETXEN_MAX_MTU         8000 + NETXEN_ENET_HEADER_SIZE + NETXEN_ETH_FCS_SIZE
 #define NETXEN_MIN_MTU         64
 #define NETXEN_ETH_FCS_SIZE     4
 #define NETXEN_ENET_HEADER_SIZE 14
@@ -81,8 +81,8 @@ int netxen_nic_set_mac(struct net_device *netdev, void *p)
        DPRINTK(INFO, "valid ether addr\n");
        memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
 
-       if (adapter->ops->macaddr_set)
-               adapter->ops->macaddr_set(port, addr->sa_data);
+       if (adapter->macaddr_set)
+               adapter->macaddr_set(port, addr->sa_data);
 
        return 0;
 }
@@ -99,17 +99,17 @@ void netxen_nic_set_multi(struct net_device *netdev)
 
        mc_ptr = netdev->mc_list;
        if (netdev->flags & IFF_PROMISC) {
-               if (adapter->ops->set_promisc)
-                       adapter->ops->set_promisc(adapter,
-                                                 port->portnum,
-                                                 NETXEN_NIU_PROMISC_MODE);
+               if (adapter->set_promisc)
+                       adapter->set_promisc(adapter,
+                                            port->portnum,
+                                            NETXEN_NIU_PROMISC_MODE);
        } else {
-               if (adapter->ops->unset_promisc &&
+               if (adapter->unset_promisc &&
                    adapter->ahw.boardcfg.board_type
                    != NETXEN_BRDTYPE_P2_SB31_10G_IMEZ)
-                       adapter->ops->unset_promisc(adapter,
-                                                   port->portnum,
-                                                   NETXEN_NIU_NON_PROMISC_MODE);
+                       adapter->unset_promisc(adapter,
+                                              port->portnum,
+                                              NETXEN_NIU_NON_PROMISC_MODE);
        }
        if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
                netxen_nic_mcr_set_mode_select(netxen_mac_addr_cntl_data, 0x03);
@@ -160,8 +160,8 @@ int netxen_nic_change_mtu(struct net_device *netdev, int mtu)
                return -EINVAL;
        }
 
-       if (adapter->ops->set_mtu)
-               adapter->ops->set_mtu(port, mtu);
+       if (adapter->set_mtu)
+               adapter->set_mtu(port, mtu);
        netdev->mtu = mtu;
 
        return 0;
@@ -176,22 +176,18 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
        struct netxen_hardware_context *hw = &adapter->ahw;
        u32 state = 0;
        void *addr;
-       void *pause_addr;
        int loops = 0, err = 0;
        int ctx, ring;
        u32 card_cmdring = 0;
-       struct netxen_rcv_desc_crb *rcv_desc_crb = NULL;
        struct netxen_recv_context *recv_ctx;
        struct netxen_rcv_desc_ctx *rcv_desc;
 
-       DPRINTK(INFO, "crb_base: %lx %lx", NETXEN_PCI_CRBSPACE,
+       DPRINTK(INFO, "crb_base: %lx %x", NETXEN_PCI_CRBSPACE,
                PCI_OFFSET_SECOND_RANGE(adapter, NETXEN_PCI_CRBSPACE));
-       DPRINTK(INFO, "cam base: %lx %lx", NETXEN_CRB_CAM,
+       DPRINTK(INFO, "cam base: %lx %x", NETXEN_CRB_CAM,
                pci_base_offset(adapter, NETXEN_CRB_CAM));
-       DPRINTK(INFO, "cam RAM: %lx %lx", NETXEN_CAM_RAM_BASE,
+       DPRINTK(INFO, "cam RAM: %lx %x", NETXEN_CAM_RAM_BASE,
                pci_base_offset(adapter, NETXEN_CAM_RAM_BASE));
-       DPRINTK(INFO, "NIC base:%lx %lx\n", NIC_CRB_BASE_PORT1,
-               pci_base_offset(adapter, NIC_CRB_BASE_PORT1));
 
        /* Window 1 call */
        card_cmdring = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_CMDRING));
@@ -226,33 +222,42 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
        DPRINTK(INFO, "Recieve Peg ready too. starting stuff\n");
 
        addr = netxen_alloc(adapter->ahw.pdev,
-                           sizeof(struct cmd_desc_type0) *
-                           adapter->max_tx_desc_count,
-                           &hw->cmd_desc_phys_addr, &hw->cmd_desc_pdev);
+                           sizeof(struct netxen_ring_ctx) +
+                           sizeof(uint32_t),
+                           (dma_addr_t *) & adapter->ctx_desc_phys_addr,
+                           &adapter->ctx_desc_pdev);
 
+       printk("ctx_desc_phys_addr: 0x%llx\n",
+              (u64) adapter->ctx_desc_phys_addr);
        if (addr == NULL) {
                DPRINTK(ERR, "bad return from pci_alloc_consistent\n");
-               return -ENOMEM;
+               err = -ENOMEM;
+               return err;
        }
+       memset(addr, 0, sizeof(struct netxen_ring_ctx));
+       adapter->ctx_desc = (struct netxen_ring_ctx *)addr;
+       adapter->ctx_desc->cmd_consumer_offset = adapter->ctx_desc_phys_addr
+           + sizeof(struct netxen_ring_ctx);
+       adapter->cmd_consumer = (uint32_t *) (((char *)addr) +
+                                             sizeof(struct netxen_ring_ctx));
+
+       addr = pci_alloc_consistent(adapter->ahw.pdev,
+                                   sizeof(struct cmd_desc_type0) *
+                                   adapter->max_tx_desc_count,
+                                   (dma_addr_t *) & hw->cmd_desc_phys_addr);
+       printk("cmd_desc_phys_addr: 0x%llx\n", (u64) hw->cmd_desc_phys_addr);
 
-       pause_addr = netxen_alloc(adapter->ahw.pdev, 512,
-                                 (dma_addr_t *) & hw->pause_physaddr,
-                                 &hw->pause_pdev);
-       if (pause_addr == NULL) {
-               DPRINTK(1, ERR, "bad return from pci_alloc_consistent\n");
+       if (addr == NULL) {
+               DPRINTK(ERR, "bad return from pci_alloc_consistent\n");
+               netxen_free_hw_resources(adapter);
                return -ENOMEM;
        }
 
-       hw->pauseaddr = (char *)pause_addr;
-       {
-               u64 *ptr = (u64 *) pause_addr;
-               *ptr++ = NETXEN_NIC_ZERO_PAUSE_ADDR;
-               *ptr++ = NETXEN_NIC_ZERO_PAUSE_ADDR;
-               *ptr++ = NETXEN_NIC_UNIT_PAUSE_ADDR;
-               *ptr++ = NETXEN_NIC_ZERO_PAUSE_ADDR;
-               *ptr++ = NETXEN_NIC_EPG_PAUSE_ADDR1;
-               *ptr++ = NETXEN_NIC_EPG_PAUSE_ADDR2;
-       }
+       adapter->ctx_desc->cmd_ring_addr_lo =
+           hw->cmd_desc_phys_addr & 0xffffffffUL;
+       adapter->ctx_desc->cmd_ring_addr_hi =
+           ((u64) hw->cmd_desc_phys_addr >> 32);
+       adapter->ctx_desc->cmd_ring_size = adapter->max_tx_desc_count;
 
        hw->cmd_desc_head = (struct cmd_desc_type0 *)addr;
 
@@ -273,6 +278,12 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
                                return err;
                        }
                        rcv_desc->desc_head = (struct rcv_desc *)addr;
+                       adapter->ctx_desc->rcv_ctx[ring].rcv_ring_addr_lo =
+                           rcv_desc->phys_addr & 0xffffffffUL;
+                       adapter->ctx_desc->rcv_ctx[ring].rcv_ring_addr_hi =
+                           ((u64) rcv_desc->phys_addr >> 32);
+                       adapter->ctx_desc->rcv_ctx[ring].rcv_ring_size =
+                           rcv_desc->max_rx_desc_count;
                }
 
                addr = netxen_alloc(adapter->ahw.pdev, STATUS_DESC_RINGSIZE,
@@ -286,47 +297,21 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
                        return err;
                }
                recv_ctx->rcv_status_desc_head = (struct status_desc *)addr;
-               for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
-                       rcv_desc = &recv_ctx->rcv_desc[ring];
-                       rcv_desc_crb =
-                           &recv_crb_registers[ctx].rcv_desc_crb[ring];
-                       DPRINTK(INFO, "ring #%d crb global ring reg 0x%x\n",
-                               ring, rcv_desc_crb->crb_globalrcv_ring);
-                       /* Window = 1 */
-                       writel(lower32(rcv_desc->phys_addr),
-                              NETXEN_CRB_NORMALIZE(adapter,
-                                                   rcv_desc_crb->
-                                                   crb_globalrcv_ring));
-                       DPRINTK(INFO, "GLOBAL_RCV_RING ctx %d, addr 0x%x"
-                               " val 0x%llx,"
-                               " virt %p\n", ctx,
-                               rcv_desc_crb->crb_globalrcv_ring,
-                               (unsigned long long)rcv_desc->phys_addr,
-                               +rcv_desc->desc_head);
-               }
+               adapter->ctx_desc->sts_ring_addr_lo =
+                   recv_ctx->rcv_status_desc_phys_addr & 0xffffffffUL;
+               adapter->ctx_desc->sts_ring_addr_hi =
+                   ((u64) recv_ctx->rcv_status_desc_phys_addr >> 32);
+               adapter->ctx_desc->sts_ring_size = adapter->max_rx_desc_count;
 
-               /* Window = 1 */
-               writel(lower32(recv_ctx->rcv_status_desc_phys_addr),
-                      NETXEN_CRB_NORMALIZE(adapter,
-                                           recv_crb_registers[ctx].
-                                           crb_rcvstatus_ring));
-               DPRINTK(INFO, "RCVSTATUS_RING, ctx %d, addr 0x%x,"
-                       " val 0x%x,virt%p\n",
-                       ctx,
-                       recv_crb_registers[ctx].crb_rcvstatus_ring,
-                       (unsigned long long)recv_ctx->rcv_status_desc_phys_addr,
-                       recv_ctx->rcv_status_desc_head);
        }
        /* Window = 1 */
-       writel(lower32(hw->pause_physaddr),
-              NETXEN_CRB_NORMALIZE(adapter, CRB_PAUSE_ADDR_LO));
-       writel(upper32(hw->pause_physaddr),
-              NETXEN_CRB_NORMALIZE(adapter, CRB_PAUSE_ADDR_HI));
-
-       writel(lower32(hw->cmd_desc_phys_addr),
-              NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO));
-       writel(upper32(hw->cmd_desc_phys_addr),
-              NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_HI));
+
+       writel(lower32(adapter->ctx_desc_phys_addr),
+              NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_ADDR_REG_LO));
+       writel(upper32(adapter->ctx_desc_phys_addr),
+              NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_ADDR_REG_HI));
+       writel(NETXEN_CTX_SIGNATURE,
+              NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_SIGNATURE_REG));
        return err;
 }
 
@@ -336,6 +321,15 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter)
        struct netxen_rcv_desc_ctx *rcv_desc;
        int ctx, ring;
 
+       if (adapter->ctx_desc != NULL) {
+               pci_free_consistent(adapter->ctx_desc_pdev,
+                                   sizeof(struct netxen_ring_ctx) +
+                                   sizeof(uint32_t),
+                                   adapter->ctx_desc,
+                                   adapter->ctx_desc_phys_addr);
+               adapter->ctx_desc = NULL;
+       }
+
        if (adapter->ahw.cmd_desc_head != NULL) {
                pci_free_consistent(adapter->ahw.cmd_desc_pdev,
                                    sizeof(struct cmd_desc_type0) *
@@ -344,11 +338,9 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter)
                                    adapter->ahw.cmd_desc_phys_addr);
                adapter->ahw.cmd_desc_head = NULL;
        }
-       if (adapter->ahw.pauseaddr != NULL) {
-               pci_free_consistent(adapter->ahw.pause_pdev, 512,
-                                   adapter->ahw.pauseaddr,
-                                   adapter->ahw.pause_physaddr);
-               adapter->ahw.pauseaddr = NULL;
+       /* Special handling: there are 2 ports on this board */
+       if (adapter->ahw.boardcfg.board_type == NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) {
+               adapter->ahw.max_ports = 2;
        }
 
        for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
@@ -383,19 +375,22 @@ void netxen_tso_check(struct netxen_adapter *adapter,
                desc->total_hdr_length = sizeof(struct ethhdr) +
                    ((skb->nh.iph)->ihl * sizeof(u32)) +
                    ((skb->h.th)->doff * sizeof(u32));
-               desc->opcode = TX_TCP_LSO;
+               netxen_set_cmd_desc_opcode(desc, TX_TCP_LSO);
        } else if (skb->ip_summed == CHECKSUM_COMPLETE) {
                if (skb->nh.iph->protocol == IPPROTO_TCP) {
-                       desc->opcode = TX_TCP_PKT;
+                       netxen_set_cmd_desc_opcode(desc, TX_TCP_PKT);
                } else if (skb->nh.iph->protocol == IPPROTO_UDP) {
-                       desc->opcode = TX_UDP_PKT;
+                       netxen_set_cmd_desc_opcode(desc, TX_UDP_PKT);
                } else {
                        return;
                }
        }
        adapter->stats.xmitcsummed++;
-       CMD_DESC_TCP_HDR_OFFSET_WRT(desc, skb->h.raw - skb->data);
-       desc->length_tcp_hdr = cpu_to_le32(desc->length_tcp_hdr);
+       desc->tcp_hdr_offset = skb->h.raw - skb->data;
+       netxen_set_cmd_desc_totallength(desc,
+                                       cpu_to_le32
+                                       (netxen_get_cmd_desc_totallength
+                                        (desc)));
        desc->ip_hdr_offset = skb->nh.raw - skb->data;
 }
 
@@ -648,7 +643,7 @@ void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val)
 
        addr = NETXEN_CRB_NORMALIZE(adapter, off);
        DPRINTK(INFO, "writing to base %lx offset %llx addr %p data %x\n",
-               pci_base(adapter, off), off, addr);
+               pci_base(adapter, off), off, addr, val);
        writel(val, addr);
 
 }
@@ -660,7 +655,7 @@ int netxen_nic_reg_read(struct netxen_adapter *adapter, u64 off)
 
        addr = NETXEN_CRB_NORMALIZE(adapter, off);
        DPRINTK(INFO, "reading from base %lx offset %llx addr %p\n",
-               adapter->ahw.pci_base, off, addr);
+               pci_base(adapter, off), off, addr);
        val = readl(addr);
        writel(val, addr);
 
@@ -848,8 +843,8 @@ void netxen_nic_stop_all_ports(struct netxen_adapter *adapter)
 
        for (port_nr = 0; port_nr < adapter->ahw.max_ports; port_nr++) {
                port = adapter->port[port_nr];
-               if (adapter->ops->stop_port)
-                       adapter->ops->stop_port(adapter, port->portnum);
+               if (adapter->stop_port)
+                       adapter->stop_port(adapter, port->portnum);
        }
 }
 
@@ -873,13 +868,13 @@ void netxen_nic_set_link_parameters(struct netxen_port *port)
 {
        struct netxen_adapter *adapter = port->adapter;
        __le32 status;
-       u16 autoneg;
+       __le32 autoneg;
        __le32 mode;
 
        netxen_nic_read_w0(adapter, NETXEN_NIU_MODE, &mode);
        if (netxen_get_niu_enable_ge(mode)) {   /* Gb 10/100/1000 Mbps mode */
-               if (adapter->ops->phy_read
-                   && adapter->ops->
+               if (adapter->phy_read
+                   && adapter->
                    phy_read(adapter, port->portnum,
                             NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
                             &status) == 0) {
@@ -909,11 +904,11 @@ void netxen_nic_set_link_parameters(struct netxen_port *port)
                                        port->link_duplex = -1;
                                        break;
                                }
-                               if (adapter->ops->phy_read
-                                   && adapter->ops->
+                               if (adapter->phy_read
+                                   && adapter->
                                    phy_read(adapter, port->portnum,
                                             NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
-                                            (__le32 *) & autoneg) != 0)
+                                            &autoneg) != 0)
                                        port->link_autoneg = autoneg;
                        } else
                                goto link_down;
@@ -1008,3 +1003,291 @@ int netxen_crb_read_val(struct netxen_adapter *adapter, unsigned long off)
        netxen_nic_hw_read_wx(adapter, off, &data, 4);
        return data;
 }
+
+int netxen_nic_hw_write_ioctl(struct netxen_adapter *adapter, u64 off,
+                             void *data, int len)
+{
+       void *addr;
+       u64 offset = off;
+       u8 *mem_ptr = NULL;
+       unsigned long mem_base;
+       unsigned long mem_page;
+
+       if (ADDR_IN_WINDOW1(off)) {
+               addr = NETXEN_CRB_NORMALIZE(adapter, off);
+               if (!addr) {
+                       mem_base = pci_resource_start(adapter->ahw.pdev, 0);
+                       offset = NETXEN_CRB_NORMAL(off);
+                       mem_page = offset & PAGE_MASK;
+                       if (mem_page != ((offset + len - 1) & PAGE_MASK))
+                               mem_ptr =
+                                   ioremap(mem_base + mem_page, PAGE_SIZE * 2);
+                       else
+                               mem_ptr =
+                                   ioremap(mem_base + mem_page, PAGE_SIZE);
+                       if (mem_ptr == 0UL) {
+                               return 1;
+                       }
+                       addr = mem_ptr;
+                       addr += offset & (PAGE_SIZE - 1);
+               }
+       } else {
+               addr = pci_base_offset(adapter, off);
+               if (!addr) {
+                       mem_base = pci_resource_start(adapter->ahw.pdev, 0);
+                       mem_page = off & PAGE_MASK;
+                       if (mem_page != ((off + len - 1) & PAGE_MASK))
+                               mem_ptr =
+                                   ioremap(mem_base + mem_page, PAGE_SIZE * 2);
+                       else
+                               mem_ptr =
+                                   ioremap(mem_base + mem_page, PAGE_SIZE);
+                       if (mem_ptr == 0UL) {
+                               return 1;
+                       }
+                       addr = mem_ptr;
+                       addr += off & (PAGE_SIZE - 1);
+               }
+               netxen_nic_pci_change_crbwindow(adapter, 0);
+       }
+       switch (len) {
+       case 1:
+               writeb(*(u8 *) data, addr);
+               break;
+       case 2:
+               writew(*(u16 *) data, addr);
+               break;
+       case 4:
+               writel(*(u32 *) data, addr);
+               break;
+       case 8:
+               writeq(*(u64 *) data, addr);
+               break;
+       default:
+               DPRINTK(INFO,
+                       "writing data %lx to offset %llx, num words=%d\n",
+                       *(unsigned long *)data, off, (len >> 3));
+
+               netxen_nic_hw_block_write64((u64 __iomem *) data, addr,
+                                           (len >> 3));
+               break;
+       }
+
+       if (!ADDR_IN_WINDOW1(off))
+               netxen_nic_pci_change_crbwindow(adapter, 1);
+       if (mem_ptr)
+               iounmap(mem_ptr);
+       return 0;
+}
+
+int netxen_nic_hw_read_ioctl(struct netxen_adapter *adapter, u64 off,
+                            void *data, int len)
+{
+       void *addr;
+       u64 offset;
+       u8 *mem_ptr = NULL;
+       unsigned long mem_base;
+       unsigned long mem_page;
+
+       if (ADDR_IN_WINDOW1(off)) {
+               addr = NETXEN_CRB_NORMALIZE(adapter, off);
+               if (!addr) {
+                       mem_base = pci_resource_start(adapter->ahw.pdev, 0);
+                       offset = NETXEN_CRB_NORMAL(off);
+                       mem_page = offset & PAGE_MASK;
+                       if (mem_page != ((offset + len - 1) & PAGE_MASK))
+                               mem_ptr =
+                                   ioremap(mem_base + mem_page, PAGE_SIZE * 2);
+                       else
+                               mem_ptr =
+                                   ioremap(mem_base + mem_page, PAGE_SIZE);
+                       if (mem_ptr == 0UL) {
+                               *(u8 *) data = 0;
+                               return 1;
+                       }
+                       addr = mem_ptr;
+                       addr += offset & (PAGE_SIZE - 1);
+               }
+       } else {
+               addr = pci_base_offset(adapter, off);
+               if (!addr) {
+                       mem_base = pci_resource_start(adapter->ahw.pdev, 0);
+                       mem_page = off & PAGE_MASK;
+                       if (mem_page != ((off + len - 1) & PAGE_MASK))
+                               mem_ptr =
+                                   ioremap(mem_base + mem_page, PAGE_SIZE * 2);
+                       else
+                               mem_ptr =
+                                   ioremap(mem_base + mem_page, PAGE_SIZE);
+                       if (mem_ptr == 0UL)
+                               return 1;
+                       addr = mem_ptr;
+                       addr += off & (PAGE_SIZE - 1);
+               }
+               netxen_nic_pci_change_crbwindow(adapter, 0);
+       }
+       switch (len) {
+       case 1:
+               *(u8 *) data = readb(addr);
+               break;
+       case 2:
+               *(u16 *) data = readw(addr);
+               break;
+       case 4:
+               *(u32 *) data = readl(addr);
+               break;
+       case 8:
+               *(u64 *) data = readq(addr);
+               break;
+       default:
+               netxen_nic_hw_block_read64((u64 __iomem *) data, addr,
+                                          (len >> 3));
+               break;
+       }
+       if (!ADDR_IN_WINDOW1(off))
+               netxen_nic_pci_change_crbwindow(adapter, 1);
+       if (mem_ptr)
+               iounmap(mem_ptr);
+       return 0;
+}
+
+int netxen_nic_pci_mem_write_ioctl(struct netxen_adapter *adapter, u64 off,
+                                  void *data, int size)
+{
+       void *addr;
+       int ret = 0;
+       u8 *mem_ptr = NULL;
+       unsigned long mem_base;
+       unsigned long mem_page;
+
+       if (data == NULL || off > (128 * 1024 * 1024)) {
+               printk(KERN_ERR "%s: data: %p off:%llx\n",
+                      netxen_nic_driver_name, data, off);
+               return 1;
+       }
+       off = netxen_nic_pci_set_window(adapter, off);
+       /* Corner case : Malicious user tried to break the driver by reading
+          last few bytes in ranges and tries to read further addresses.
+        */
+       if (!pci_base(adapter, off + size - 1) && pci_base(adapter, off)) {
+               printk(KERN_ERR "%s: Invalid access to memory address range"
+                      " 0x%llx - 0x%llx\n", netxen_nic_driver_name, off,
+                      off + size);
+               return 1;
+       }
+       addr = pci_base_offset(adapter, off);
+       DPRINTK(INFO, "writing data %llx to offset %llx\n",
+               *(unsigned long long *)data, off);
+       if (!addr) {
+               mem_base = pci_resource_start(adapter->ahw.pdev, 0);
+               mem_page = off & PAGE_MASK;
+               /* Map two pages whenever user tries to access addresses in two
+                  consecutive pages.
+                */
+               if (mem_page != ((off + size - 1) & PAGE_MASK))
+                       mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE * 2);
+               else
+                       mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE);
+               if (mem_ptr == 0UL) {
+                       return 1;
+               }
+               addr = mem_ptr;
+               addr += off & (PAGE_SIZE - 1);
+       }
+       switch (size) {
+       case 1:
+               writeb(*(u8 *) data, addr);
+               break;
+       case 2:
+               writew(*(u16 *) data, addr);
+               break;
+       case 4:
+               writel(*(u32 *) data, addr);
+               break;
+       case 8:
+               writeq(*(u64 *) data, addr);
+               break;
+       default:
+               DPRINTK(INFO,
+                       "writing data %lx to offset %llx, num words=%d\n",
+                       *(unsigned long *)data, off, (size >> 3));
+
+               netxen_nic_hw_block_write64((u64 __iomem *) data, addr,
+                                           (size >> 3));
+               break;
+       }
+
+       if (mem_ptr)
+               iounmap(mem_ptr);
+       DPRINTK(INFO, "wrote %llx\n", *(unsigned long long *)data);
+
+       return ret;
+}
+
+int netxen_nic_pci_mem_read_ioctl(struct netxen_adapter *adapter,
+                                 u64 off, void *data, int size)
+{
+       void *addr;
+       int ret = 0;
+       u8 *mem_ptr = NULL;
+       unsigned long mem_base;
+       unsigned long mem_page;
+
+       if (data == NULL || off > (128 * 1024 * 1024)) {
+               printk(KERN_ERR "%s: data: %p off:%llx\n",
+                      netxen_nic_driver_name, data, off);
+               return 1;
+       }
+       off = netxen_nic_pci_set_window(adapter, off);
+       /* Corner case : Malicious user tried to break the driver by reading
+          last few bytes in ranges and tries to read further addresses.
+        */
+       if (!pci_base(adapter, off + size - 1) && pci_base(adapter, off)) {
+               printk(KERN_ERR "%s: Invalid access to memory address range"
+                      " 0x%llx - 0x%llx\n", netxen_nic_driver_name, off,
+                      off + size);
+               return 1;
+       }
+       addr = pci_base_offset(adapter, off);
+       if (!addr) {
+               mem_base = pci_resource_start(adapter->ahw.pdev, 0);
+               mem_page = off & PAGE_MASK;
+               /* Map two pages whenever user tries to access addresses in two
+                  consecutive pages.
+                */
+               if (mem_page != ((off + size - 1) & PAGE_MASK))
+                       mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE * 2);
+               else
+                       mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE);
+               if (mem_ptr == 0UL) {
+                       *(u8 *) data = 0;
+                       return 1;
+               }
+               addr = mem_ptr;
+               addr += off & (PAGE_SIZE - 1);
+       }
+       switch (size) {
+       case 1:
+               *(u8 *) data = readb(addr);
+               break;
+       case 2:
+               *(u16 *) data = readw(addr);
+               break;
+       case 4:
+               *(u32 *) data = readl(addr);
+               break;
+       case 8:
+               *(u64 *) data = readq(addr);
+               break;
+       default:
+               netxen_nic_hw_block_read64((u64 __iomem *) data, addr,
+                                          (size >> 3));
+               break;
+       }
+
+       if (mem_ptr)
+               iounmap(mem_ptr);
+       DPRINTK(INFO, "read %llx\n", *(unsigned long long *)data);
+
+       return ret;
+}
index 201a636b7ab8b199e3f668f31bd30e2317b3a90d..0685633a9c1ea9e4626339246fcd1779fe2ebe0e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2003 - 2006 NetXen, Inc.
  * 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
  * 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:
  *    info@netxen.com
  * NetXen,
@@ -83,8 +83,8 @@ struct netxen_adapter;
 #define NETXEN_PCI_MAPSIZE_BYTES  (NETXEN_PCI_MAPSIZE << 20)
 
 #define NETXEN_NIC_LOCKED_READ_REG(X, Y)       \
-       addr = pci_base_offset(adapter, (X));   \
-       *(u32 *)Y = readl(addr);
+       addr = pci_base_offset(adapter, X);     \
+       *(u32 *)Y = readl((void __iomem*) addr);
 
 struct netxen_port;
 void netxen_nic_set_link_parameters(struct netxen_port *port);
index eae18236aefa2ef6fbe61e445f15a45642cc7d9f..869725f0bb1861cda3e726664c7e3c23f9e7b507 100644 (file)
@@ -1,25 +1,25 @@
 /*
  * Copyright (C) 2003 - 2006 NetXen, Inc.
  * 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:
  *    info@netxen.com
  * NetXen,
@@ -137,6 +137,8 @@ int netxen_init_firmware(struct netxen_adapter *adapter)
                return err;
        }
        /* Window 1 call */
+       writel(MPORT_SINGLE_FUNCTION_MODE,
+              NETXEN_CRB_NORMALIZE(adapter, CRB_MPORT_MODE));
        writel(PHAN_INITIALIZE_ACK,
               NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
 
@@ -184,15 +186,12 @@ void netxen_initialize_adapter_sw(struct netxen_adapter *adapter)
                        for (i = 0; i < num_rx_bufs; i++) {
                                rx_buf->ref_handle = i;
                                rx_buf->state = NETXEN_BUFFER_FREE;
-
                                DPRINTK(INFO, "Rx buf:ctx%d i(%d) rx_buf:"
                                        "%p\n", ctxid, i, rx_buf);
                                rx_buf++;
                        }
                }
        }
-       DPRINTK(INFO, "initialized buffers for %s and %s\n",
-               "adapter->free_cmd_buf_list", "adapter->free_rxbuf");
 }
 
 void netxen_initialize_adapter_hw(struct netxen_adapter *adapter)
@@ -212,37 +211,36 @@ void netxen_initialize_adapter_hw(struct netxen_adapter *adapter)
 
 void netxen_initialize_adapter_ops(struct netxen_adapter *adapter)
 {
-       struct netxen_drvops *ops = adapter->ops;
        switch (adapter->ahw.board_type) {
        case NETXEN_NIC_GBE:
-               ops->enable_phy_interrupts =
+               adapter->enable_phy_interrupts =
                    netxen_niu_gbe_enable_phy_interrupts;
-               ops->disable_phy_interrupts =
+               adapter->disable_phy_interrupts =
                    netxen_niu_gbe_disable_phy_interrupts;
-               ops->handle_phy_intr = netxen_nic_gbe_handle_phy_intr;
-               ops->macaddr_set = netxen_niu_macaddr_set;
-               ops->set_mtu = netxen_nic_set_mtu_gb;
-               ops->set_promisc = netxen_niu_set_promiscuous_mode;
-               ops->unset_promisc = netxen_niu_set_promiscuous_mode;
-               ops->phy_read = netxen_niu_gbe_phy_read;
-               ops->phy_write = netxen_niu_gbe_phy_write;
-               ops->init_port = netxen_niu_gbe_init_port;
-               ops->init_niu = netxen_nic_init_niu_gb;
-               ops->stop_port = netxen_niu_disable_gbe_port;
+               adapter->handle_phy_intr = netxen_nic_gbe_handle_phy_intr;
+               adapter->macaddr_set = netxen_niu_macaddr_set;
+               adapter->set_mtu = netxen_nic_set_mtu_gb;
+               adapter->set_promisc = netxen_niu_set_promiscuous_mode;
+               adapter->unset_promisc = netxen_niu_set_promiscuous_mode;
+               adapter->phy_read = netxen_niu_gbe_phy_read;
+               adapter->phy_write = netxen_niu_gbe_phy_write;
+               adapter->init_port = netxen_niu_gbe_init_port;
+               adapter->init_niu = netxen_nic_init_niu_gb;
+               adapter->stop_port = netxen_niu_disable_gbe_port;
                break;
 
        case NETXEN_NIC_XGBE:
-               ops->enable_phy_interrupts =
+               adapter->enable_phy_interrupts =
                    netxen_niu_xgbe_enable_phy_interrupts;
-               ops->disable_phy_interrupts =
+               adapter->disable_phy_interrupts =
                    netxen_niu_xgbe_disable_phy_interrupts;
-               ops->handle_phy_intr = netxen_nic_xgbe_handle_phy_intr;
-               ops->macaddr_set = netxen_niu_xg_macaddr_set;
-               ops->set_mtu = netxen_nic_set_mtu_xgb;
-               ops->init_port = netxen_niu_xg_init_port;
-               ops->set_promisc = netxen_niu_xg_set_promiscuous_mode;
-               ops->unset_promisc = netxen_niu_xg_set_promiscuous_mode;
-               ops->stop_port = netxen_niu_disable_xg_port;
+               adapter->handle_phy_intr = netxen_nic_xgbe_handle_phy_intr;
+               adapter->macaddr_set = netxen_niu_xg_macaddr_set;
+               adapter->set_mtu = netxen_nic_set_mtu_xgb;
+               adapter->init_port = netxen_niu_xg_init_port;
+               adapter->set_promisc = netxen_niu_xg_set_promiscuous_mode;
+               adapter->unset_promisc = netxen_niu_xg_set_promiscuous_mode;
+               adapter->stop_port = netxen_niu_disable_xg_port;
                break;
 
        default:
@@ -383,8 +381,8 @@ int netxen_rom_wip_poll(struct netxen_adapter *adapter)
        return 0;
 }
 
-static inline int do_rom_fast_write(struct netxen_adapter *adapter,
-                                   int addr, int data)
+static inline int do_rom_fast_write(struct netxen_adapter *adapter, int addr,
+                                   int data)
 {
        if (netxen_rom_wren(adapter)) {
                return -1;
@@ -622,6 +620,43 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
        return 0;
 }
 
+int netxen_initialize_adapter_offload(struct netxen_adapter *adapter)
+{
+       uint64_t addr;
+       uint32_t hi;
+       uint32_t lo;
+
+       adapter->dummy_dma.addr =
+           pci_alloc_consistent(adapter->ahw.pdev,
+                                NETXEN_HOST_DUMMY_DMA_SIZE,
+                                &adapter->dummy_dma.phys_addr);
+       if (adapter->dummy_dma.addr == NULL) {
+               printk("%s: ERROR: Could not allocate dummy DMA memory\n",
+                      __FUNCTION__);
+               return -ENOMEM;
+       }
+
+       addr = (uint64_t) adapter->dummy_dma.phys_addr;
+       hi = (addr >> 32) & 0xffffffff;
+       lo = addr & 0xffffffff;
+
+       writel(hi, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_DUMMY_BUF_ADDR_HI));
+       writel(lo, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_DUMMY_BUF_ADDR_LO));
+
+       return 0;
+}
+
+void netxen_free_adapter_offload(struct netxen_adapter *adapter)
+{
+       if (adapter->dummy_dma.addr) {
+               pci_free_consistent(adapter->ahw.pdev,
+                                   NETXEN_HOST_DUMMY_DMA_SIZE,
+                                   adapter->dummy_dma.addr,
+                                   adapter->dummy_dma.phys_addr);
+               adapter->dummy_dma.addr = NULL;
+       }
+}
+
 void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
 {
        u32 val = 0;
@@ -656,7 +691,8 @@ int netxen_nic_rx_has_work(struct netxen_adapter *adapter)
                desc_head = recv_ctx->rcv_status_desc_head;
                desc = &desc_head[consumer];
 
-               if (((le16_to_cpu(desc->owner)) & STATUS_OWNER_HOST))
+               if (((le16_to_cpu(netxen_get_sts_owner(desc)))
+                    & STATUS_OWNER_HOST))
                        return 1;
        }
 
@@ -735,8 +771,8 @@ void netxen_watchdog_task(struct work_struct *work)
                        netif_wake_queue(netdev);
        }
 
-       if (adapter->ops->handle_phy_intr)
-               adapter->ops->handle_phy_intr(adapter);
+       if (adapter->handle_phy_intr)
+               adapter->handle_phy_intr(adapter);
        mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
 }
 
@@ -749,19 +785,19 @@ void
 netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
                   struct status_desc *desc)
 {
-       struct netxen_port *port = adapter->port[STATUS_DESC_PORT(desc)];
+       struct netxen_port *port = adapter->port[netxen_get_sts_port(desc)];
        struct pci_dev *pdev = port->pdev;
        struct net_device *netdev = port->netdev;
-       int index = le16_to_cpu(desc->reference_handle);
+       int index = le16_to_cpu(netxen_get_sts_refhandle(desc));
        struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]);
        struct netxen_rx_buffer *buffer;
        struct sk_buff *skb;
-       u32 length = le16_to_cpu(desc->total_length);
+       u32 length = le16_to_cpu(netxen_get_sts_totallength(desc));
        u32 desc_ctx;
        struct netxen_rcv_desc_ctx *rcv_desc;
        int ret;
 
-       desc_ctx = STATUS_DESC_TYPE(desc);
+       desc_ctx = netxen_get_sts_type(desc);
        if (unlikely(desc_ctx >= NUM_RCV_DESC_RINGS)) {
                printk("%s: %s Bad Rcv descriptor ring\n",
                       netxen_nic_driver_name, netdev->name);
@@ -769,20 +805,49 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
        }
 
        rcv_desc = &recv_ctx->rcv_desc[desc_ctx];
+       if (unlikely(index > rcv_desc->max_rx_desc_count)) {
+               DPRINTK(ERR, "Got a buffer index:%x Max is %x\n",
+                       index, rcv_desc->max_rx_desc_count);
+               return;
+       }
        buffer = &rcv_desc->rx_buf_arr[index];
+       if (desc_ctx == RCV_DESC_LRO_CTXID) {
+               buffer->lro_current_frags++;
+               if (netxen_get_sts_desc_lro_last_frag(desc)) {
+                       buffer->lro_expected_frags =
+                           netxen_get_sts_desc_lro_cnt(desc);
+                       buffer->lro_length = length;
+               }
+               if (buffer->lro_current_frags != buffer->lro_expected_frags) {
+                       if (buffer->lro_expected_frags != 0) {
+                               printk("LRO: (refhandle:%x) recv frag."
+                                      "wait for last. flags: %x expected:%d"
+                                      "have:%d\n", index,
+                                      netxen_get_sts_desc_lro_last_frag(desc),
+                                      buffer->lro_expected_frags,
+                                      buffer->lro_current_frags);
+                       }
+                       return;
+               }
+       }
 
        pci_unmap_single(pdev, buffer->dma, rcv_desc->dma_size,
                         PCI_DMA_FROMDEVICE);
 
        skb = (struct sk_buff *)buffer->skb;
 
-       if (likely(STATUS_DESC_STATUS(desc) == STATUS_CKSUM_OK)) {
+       if (likely(netxen_get_sts_status(desc) == STATUS_CKSUM_OK)) {
                port->stats.csummed++;
                skb->ip_summed = CHECKSUM_UNNECESSARY;
-       } else
-               skb->ip_summed = CHECKSUM_NONE;
+       }
        skb->dev = netdev;
-       skb_put(skb, length);
+       if (desc_ctx == RCV_DESC_LRO_CTXID) {
+               /* True length was only available on the last pkt */
+               skb_put(skb, buffer->lro_length);
+       } else {
+               skb_put(skb, length);
+       }
+
        skb->protocol = eth_type_trans(skb, netdev);
 
        ret = netif_receive_skb(skb);
@@ -828,6 +893,8 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
        adapter->stats.post_called++;
        buffer->skb = NULL;
        buffer->state = NETXEN_BUFFER_FREE;
+       buffer->lro_current_frags = 0;
+       buffer->lro_expected_frags = 0;
 
        port->stats.no_rcv++;
        port->stats.rxbytes += length;
@@ -840,6 +907,7 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
        struct status_desc *desc_head = recv_ctx->rcv_status_desc_head;
        struct status_desc *desc;       /* used to read status desc here */
        u32 consumer = recv_ctx->status_rx_consumer;
+       u32 producer = 0;
        int count = 0, ring;
 
        DPRINTK(INFO, "procesing receive\n");
@@ -851,18 +919,22 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
         */
        while (count < max) {
                desc = &desc_head[consumer];
-               if (!((le16_to_cpu(desc->owner)) & STATUS_OWNER_HOST)) {
-                       DPRINTK(ERR, "desc %p ownedby %x\n", desc, desc->owner);
+               if (!
+                   (le16_to_cpu(netxen_get_sts_owner(desc)) &
+                    STATUS_OWNER_HOST)) {
+                       DPRINTK(ERR, "desc %p ownedby %x\n", desc,
+                               netxen_get_sts_owner(desc));
                        break;
                }
                netxen_process_rcv(adapter, ctxid, desc);
-               desc->owner = STATUS_OWNER_PHANTOM;
+               netxen_clear_sts_owner(desc);
+               netxen_set_sts_owner(desc, STATUS_OWNER_PHANTOM);
                consumer = (consumer + 1) & (adapter->max_rx_desc_count - 1);
                count++;
        }
        if (count) {
                for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
-                       netxen_post_rx_buffers(adapter, ctxid, ring);
+                       netxen_post_rx_buffers_nodb(adapter, ctxid, ring);
                }
        }
 
@@ -870,6 +942,7 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
        if (count) {
                adapter->stats.process_rcv++;
                recv_ctx->status_rx_consumer = consumer;
+               recv_ctx->status_rx_producer = producer;
 
                /* Window = 1 */
                writel(consumer,
@@ -882,12 +955,13 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
 }
 
 /* Process Command status ring */
-void netxen_process_cmd_ring(unsigned long data)
+int netxen_process_cmd_ring(unsigned long data)
 {
        u32 last_consumer;
        u32 consumer;
        struct netxen_adapter *adapter = (struct netxen_adapter *)data;
-       int count = 0;
+       int count1 = 0;
+       int count2 = 0;
        struct netxen_cmd_buffer *buffer;
        struct netxen_port *port;       /* port #1 */
        struct netxen_port *nport;
@@ -896,6 +970,7 @@ void netxen_process_cmd_ring(unsigned long data)
        u32 i;
        struct sk_buff *skb = NULL;
        int p;
+       int done;
 
        spin_lock(&adapter->tx_lock);
        last_consumer = adapter->last_cmd_consumer;
@@ -905,14 +980,13 @@ void netxen_process_cmd_ring(unsigned long data)
         * number as part of the descriptor. This way we will be able to get
         * the netdev which is associated with that device.
         */
-       consumer =
-           readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET));
 
+       consumer = *(adapter->cmd_consumer);
        if (last_consumer == consumer) {        /* Ring is empty    */
                DPRINTK(INFO, "last_consumer %d == consumer %d\n",
                        last_consumer, consumer);
                spin_unlock(&adapter->tx_lock);
-               return;
+               return 1;
        }
 
        adapter->proc_cmd_buf_counter++;
@@ -923,7 +997,7 @@ void netxen_process_cmd_ring(unsigned long data)
         */
        spin_unlock(&adapter->tx_lock);
 
-       while ((last_consumer != consumer) && (count < MAX_STATUS_HANDLE)) {
+       while ((last_consumer != consumer) && (count1 < MAX_STATUS_HANDLE)) {
                buffer = &adapter->cmd_buf_arr[last_consumer];
                port = adapter->port[buffer->port];
                pdev = port->pdev;
@@ -949,24 +1023,24 @@ void netxen_process_cmd_ring(unsigned long data)
                             && netif_carrier_ok(port->netdev))
                    && ((jiffies - port->netdev->trans_start) >
                        port->netdev->watchdog_timeo)) {
-                       schedule_work(&port->adapter->tx_timeout_task);
+                       SCHEDULE_WORK(&port->adapter->tx_timeout_task);
                }
 
                last_consumer = get_next_index(last_consumer,
                                               adapter->max_tx_desc_count);
-               count++;
+               count1++;
        }
-       adapter->stats.noxmitdone += count;
+       adapter->stats.noxmitdone += count1;
 
-       count = 0;
+       count2 = 0;
        spin_lock(&adapter->tx_lock);
        if ((--adapter->proc_cmd_buf_counter) == 0) {
                adapter->last_cmd_consumer = last_consumer;
                while ((adapter->last_cmd_consumer != consumer)
-                      && (count < MAX_STATUS_HANDLE)) {
+                      && (count2 < MAX_STATUS_HANDLE)) {
                        buffer =
                            &adapter->cmd_buf_arr[adapter->last_cmd_consumer];
-                       count++;
+                       count2++;
                        if (buffer->skb)
                                break;
                        else
@@ -975,7 +1049,7 @@ void netxen_process_cmd_ring(unsigned long data)
                                                   adapter->max_tx_desc_count);
                }
        }
-       if (count) {
+       if (count1 || count2) {
                for (p = 0; p < adapter->ahw.max_ports; p++) {
                        nport = adapter->port[p];
                        if (netif_queue_stopped(nport->netdev)
@@ -985,10 +1059,30 @@ void netxen_process_cmd_ring(unsigned long data)
                        }
                }
        }
+       /*
+        * If everything is freed up to consumer then check if the ring is full
+        * If the ring is full then check if more needs to be freed and
+        * schedule the call back again.
+        *
+        * This happens when there are 2 CPUs. One could be freeing and the
+        * other filling it. If the ring is full when we get out of here and
+        * the card has already interrupted the host then the host can miss the
+        * interrupt.
+        *
+        * There is still a possible race condition and the host could miss an
+        * interrupt. The card has to take care of this.
+        */
+       if (adapter->last_cmd_consumer == consumer &&
+           (((adapter->cmd_producer + 1) %
+             adapter->max_tx_desc_count) == adapter->last_cmd_consumer)) {
+               consumer = *(adapter->cmd_consumer);
+       }
+       done = (adapter->last_cmd_consumer == consumer);
 
        spin_unlock(&adapter->tx_lock);
        DPRINTK(INFO, "last consumer is %d in %s\n", last_consumer,
                __FUNCTION__);
+       return (done);
 }
 
 /*
@@ -1000,17 +1094,16 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
        struct sk_buff *skb;
        struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]);
        struct netxen_rcv_desc_ctx *rcv_desc = NULL;
-       struct netxen_recv_crb *crbarea = &recv_crb_registers[ctx];
-       struct netxen_rcv_desc_crb *rcv_desc_crb = NULL;
-       u32 producer;
+       uint producer;
        struct rcv_desc *pdesc;
        struct netxen_rx_buffer *buffer;
        int count = 0;
        int index = 0;
+       netxen_ctx_msg msg = 0;
+       dma_addr_t dma;
 
        adapter->stats.post_called++;
        rcv_desc = &recv_ctx->rcv_desc[ringid];
-       rcv_desc_crb = &crbarea->rcv_desc_crb[ringid];
 
        producer = rcv_desc->producer;
        index = rcv_desc->begin_alloc;
@@ -1020,6 +1113,7 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
                skb = dev_alloc_skb(rcv_desc->skb_size);
                if (unlikely(!skb)) {
                        /*
+                        * TODO
                         * We need to schedule the posting of buffers to the pegs.
                         */
                        rcv_desc->begin_alloc = index;
@@ -1027,9 +1121,105 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
                                " allocated only %d buffers\n", count);
                        break;
                }
+
                count++;        /* now there should be no failure */
                pdesc = &rcv_desc->desc_head[producer];
-               skb_reserve(skb, NET_IP_ALIGN);
+
+#if defined(XGB_DEBUG)
+               *(unsigned long *)(skb->head) = 0xc0debabe;
+               if (skb_is_nonlinear(skb)) {
+                       printk("Allocated SKB @%p is nonlinear\n");
+               }
+#endif
+               skb_reserve(skb, 2);
+               /* This will be setup when we receive the
+                * buffer after it has been filled  FSL  TBD TBD
+                * skb->dev = netdev;
+                */
+               dma = pci_map_single(pdev, skb->data, rcv_desc->dma_size,
+                                    PCI_DMA_FROMDEVICE);
+               pdesc->addr_buffer = dma;
+               buffer->skb = skb;
+               buffer->state = NETXEN_BUFFER_BUSY;
+               buffer->dma = dma;
+               /* make a rcv descriptor  */
+               pdesc->reference_handle = buffer->ref_handle;
+               pdesc->buffer_length = rcv_desc->dma_size;
+               DPRINTK(INFO, "done writing descripter\n");
+               producer =
+                   get_next_index(producer, rcv_desc->max_rx_desc_count);
+               index = get_next_index(index, rcv_desc->max_rx_desc_count);
+               buffer = &rcv_desc->rx_buf_arr[index];
+       }
+       /* if we did allocate buffers, then write the count to Phantom */
+       if (count) {
+               rcv_desc->begin_alloc = index;
+               rcv_desc->rcv_pending += count;
+               adapter->stats.lastposted = count;
+               adapter->stats.posted += count;
+               rcv_desc->producer = producer;
+               if (rcv_desc->rcv_free >= 32) {
+                       rcv_desc->rcv_free = 0;
+                       /* Window = 1 */
+                       writel((producer - 1) &
+                              (rcv_desc->max_rx_desc_count - 1),
+                              NETXEN_CRB_NORMALIZE(adapter,
+                                                   recv_crb_registers[0].
+                                                   rcv_desc_crb[ringid].
+                                                   crb_rcv_producer_offset));
+                       /*
+                        * Write a doorbell msg to tell phanmon of change in
+                        * receive ring producer
+                        */
+                       netxen_set_msg_peg_id(msg, NETXEN_RCV_PEG_DB_ID);
+                       netxen_set_msg_privid(msg);
+                       netxen_set_msg_count(msg,
+                                            ((producer -
+                                              1) & (rcv_desc->
+                                                    max_rx_desc_count - 1)));
+                       netxen_set_msg_ctxid(msg, 0);
+                       netxen_set_msg_opcode(msg, NETXEN_RCV_PRODUCER(ringid));
+                       writel(msg,
+                              DB_NORMALIZE(adapter,
+                                           NETXEN_RCV_PRODUCER_OFFSET));
+               }
+       }
+}
+
+void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ctx,
+                                uint32_t ringid)
+{
+       struct pci_dev *pdev = adapter->ahw.pdev;
+       struct sk_buff *skb;
+       struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]);
+       struct netxen_rcv_desc_ctx *rcv_desc = NULL;
+       u32 producer;
+       struct rcv_desc *pdesc;
+       struct netxen_rx_buffer *buffer;
+       int count = 0;
+       int index = 0;
+
+       adapter->stats.post_called++;
+       rcv_desc = &recv_ctx->rcv_desc[ringid];
+
+       producer = rcv_desc->producer;
+       index = rcv_desc->begin_alloc;
+       buffer = &rcv_desc->rx_buf_arr[index];
+       /* We can start writing rx descriptors into the phantom memory. */
+       while (buffer->state == NETXEN_BUFFER_FREE) {
+               skb = dev_alloc_skb(rcv_desc->skb_size);
+               if (unlikely(!skb)) {
+                       /*
+                        * We need to schedule the posting of buffers to the pegs.
+                        */
+                       rcv_desc->begin_alloc = index;
+                       DPRINTK(ERR, "netxen_post_rx_buffers_nodb: "
+                               " allocated only %d buffers\n", count);
+                       break;
+               }
+               count++;        /* now there should be no failure */
+               pdesc = &rcv_desc->desc_head[producer];
+               skb_reserve(skb, 2);
                /* 
                 * This will be setup when we receive the
                 * buffer after it has been filled
@@ -1040,6 +1230,7 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
                buffer->dma = pci_map_single(pdev, skb->data,
                                             rcv_desc->dma_size,
                                             PCI_DMA_FROMDEVICE);
+
                /* make a rcv descriptor  */
                pdesc->reference_handle = le16_to_cpu(buffer->ref_handle);
                pdesc->buffer_length = le16_to_cpu(rcv_desc->dma_size);
@@ -1064,7 +1255,8 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
                        writel((producer - 1) &
                               (rcv_desc->max_rx_desc_count - 1),
                               NETXEN_CRB_NORMALIZE(adapter,
-                                                   rcv_desc_crb->
+                                                   recv_crb_registers[0].
+                                                   rcv_desc_crb[ringid].
                                                    crb_rcv_producer_offset));
                        wmb();
                }
@@ -1197,8 +1389,8 @@ netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data,
 
        switch (data.cmd) {
        case netxen_nic_cmd_pci_read:
-               if ((retval = netxen_nic_hw_read_wx(adapter, data.off,
-                                                   &(data.u), data.size)))
+               if ((retval = netxen_nic_hw_read_ioctl(adapter, data.off,
+                                                      &(data.u), data.size)))
                        goto error_out;
                if (copy_to_user
                    ((void __user *)&(up_data->u), &(data.u), data.size)) {
@@ -1211,8 +1403,35 @@ netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data,
                break;
 
        case netxen_nic_cmd_pci_write:
-               data.rv = netxen_nic_hw_write_wx(adapter, data.off, &(data.u),
-                                                data.size);
+               if ((retval = netxen_nic_hw_write_ioctl(adapter, data.off,
+                                                       &(data.u), data.size)))
+                       goto error_out;
+               data.rv = 0;
+               break;
+
+       case netxen_nic_cmd_pci_mem_read:
+               if (netxen_nic_pci_mem_read_ioctl(adapter, data.off, &(data.u),
+                                                 data.size)) {
+                       DPRINTK(ERR, "Failed to read the data.\n");
+                       retval = -EFAULT;
+                       goto error_out;
+               }
+               if (copy_to_user
+                   ((void __user *)&(up_data->u), &(data.u), data.size)) {
+                       DPRINTK(ERR, "bad copy to userland: %d\n",
+                               (int)sizeof(data));
+                       retval = -EFAULT;
+                       goto error_out;
+               }
+               data.rv = 0;
+               break;
+
+       case netxen_nic_cmd_pci_mem_write:
+               if ((retval = netxen_nic_pci_mem_write_ioctl(adapter, data.off,
+                                                            &(data.u),
+                                                            data.size)))
+                       goto error_out;
+               data.rv = 0;
                break;
 
        case netxen_nic_cmd_pci_config_read:
@@ -1297,7 +1516,7 @@ netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data,
                retval = -EOPNOTSUPP;
                goto error_out;
        }
-       put_user(data.rv, (u16 __user *) (&(up_data->rv)));
+       put_user(data.rv, (&(up_data->rv)));
        DPRINTK(INFO, "done ioctl for %p well.\n", adapter);
 
       error_out:
index 23e53adbf123f3dcb6fb471ec2f3daabe88b377d..1221fa527552621cb76ed60837457436a6ed1aa3 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2003 - 2006 NetXen, Inc.
  * 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
  * 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:
  *    info@netxen.com
  * NetXen,
@@ -36,7 +36,7 @@
 #define NETXEN_NIC_CMD         (NETXEN_CMD_START + 1)
 #define NETXEN_NIC_NAME                (NETXEN_CMD_START + 2)
 #define NETXEN_NIC_NAME_LEN    16
-#define NETXEN_NIC_NAME_RSP    "NETXEN"
+#define NETXEN_NIC_NAME_RSP    "NETXEN-UNM"
 
 typedef enum {
        netxen_nic_cmd_none = 0,
index ae180fee800812be971239e7ec72729285494766..1b45f50fa6aa50687846b26c23bad5679b16ee0e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2003 - 2006 NetXen, Inc.
  * 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
  * 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:
  *    info@netxen.com
  * NetXen,
@@ -68,8 +68,7 @@ struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev)
 void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 portno,
                                 u32 link)
 {
-       struct netxen_port *pport = adapter->port[portno];
-       struct net_device *netdev = pport->netdev;
+       struct net_device *netdev = (adapter->port[portno])->netdev;
 
        if (link)
                netif_carrier_on(netdev);
@@ -84,46 +83,41 @@ void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno,
        struct netxen_port *port;
 
        /*  This should clear the interrupt source */
-       if (adapter->ops->phy_read)
-               adapter->ops->phy_read(adapter, portno,
-                                      NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS,
-                                      &int_src);
+       if (adapter->phy_read)
+               adapter->phy_read(adapter, portno,
+                                 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS,
+                                 &int_src);
        if (int_src == 0) {
                DPRINTK(INFO, "No phy interrupts for port #%d\n", portno);
                return;
        }
-       if (adapter->ops->disable_phy_interrupts)
-               adapter->ops->disable_phy_interrupts(adapter, portno);
+       if (adapter->disable_phy_interrupts)
+               adapter->disable_phy_interrupts(adapter, portno);
 
        port = adapter->port[portno];
 
        if (netxen_get_phy_int_jabber(int_src))
-               DPRINTK(INFO, "NetXen: %s Jabber interrupt \n",
-                       port->netdev->name);
+               DPRINTK(INFO, "Jabber interrupt \n");
 
        if (netxen_get_phy_int_polarity_changed(int_src))
-               DPRINTK(INFO, "NetXen: %s POLARITY CHANGED int \n",
-                       port->netdev->name);
+               DPRINTK(INFO, "POLARITY CHANGED int \n");
 
        if (netxen_get_phy_int_energy_detect(int_src))
-               DPRINTK(INFO, "NetXen: %s ENERGY DETECT INT \n",
-                       port->netdev->name);
+               DPRINTK(INFO, "ENERGY DETECT INT \n");
 
        if (netxen_get_phy_int_downshift(int_src))
-               DPRINTK(INFO, "NetXen: %s DOWNSHIFT INT \n",
-                       port->netdev->name);
+               DPRINTK(INFO, "DOWNSHIFT INT \n");
        /* write it down later.. */
        if ((netxen_get_phy_int_speed_changed(int_src))
            || (netxen_get_phy_int_link_status_changed(int_src))) {
                __le32 status;
 
-               DPRINTK(INFO, "NetXen: %s SPEED CHANGED OR"
-                       " LINK STATUS CHANGED \n", port->netdev->name);
+               DPRINTK(INFO, "SPEED CHANGED OR LINK STATUS CHANGED \n");
 
-               if (adapter->ops->phy_read
-                   && adapter->ops->phy_read(adapter, portno,
-                                             NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
-                                             &status) == 0) {
+               if (adapter->phy_read
+                   && adapter->phy_read(adapter, portno,
+                                        NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
+                                        &status) == 0) {
                        if (netxen_get_phy_int_link_status_changed(int_src)) {
                                if (netxen_get_phy_link(status)) {
                                        netxen_niu_gbe_init_port(adapter,
@@ -143,8 +137,8 @@ void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno,
                        }
                }
        }
-       if (adapter->ops->enable_phy_interrupts)
-               adapter->ops->enable_phy_interrupts(adapter, portno);
+       if (adapter->enable_phy_interrupts)
+               adapter->enable_phy_interrupts(adapter, portno);
 }
 
 void netxen_nic_isr_other(struct netxen_adapter *adapter)
@@ -159,8 +153,7 @@ void netxen_nic_isr_other(struct netxen_adapter *adapter)
 
        qg_linksup = adapter->ahw.qg_linksup;
        adapter->ahw.qg_linksup = val;
-       DPRINTK(1, INFO, "%s: link update 0x%08x\n", netxen_nic_driver_name,
-               val);
+       DPRINTK(INFO, "link update 0x%08x\n", val);
        for (portno = 0; portno < NETXEN_NIU_MAX_GBE_PORTS; portno++) {
                linkup = val & 1;
                if (linkup != (qg_linksup & 1)) {
index df0bb36a1cfbe22c685139849b8db1ba7b224376..575b71b672028e4896cc347efe76cbb2a3ef7103 100644 (file)
@@ -1,25 +1,25 @@
 /*
  * Copyright (C) 2003 - 2006 NetXen, Inc.
  * 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:
  *    info@netxen.com
  * NetXen,
@@ -32,6 +32,7 @@
  */
 
 #include <linux/vmalloc.h>
+#include <linux/highmem.h>
 #include "netxen_nic_hw.h"
 
 #include "netxen_nic.h"
@@ -48,14 +49,21 @@ MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID);
 
-char netxen_nic_driver_name[] = "netxen";
+char netxen_nic_driver_name[] = "netxen-nic";
 static char netxen_nic_driver_string[] = "NetXen Network Driver version "
     NETXEN_NIC_LINUX_VERSIONID;
 
+struct netxen_adapter *g_adapter = NULL;
+
 #define NETXEN_NETDEV_WEIGHT 120
 #define NETXEN_ADAPTER_UP_MAGIC 777
 #define NETXEN_NIC_PEG_TUNE 0
 
+u8 nx_p2_id = NX_P2_C0;
+
+#define DMA_32BIT_MASK 0x00000000ffffffffULL
+#define DMA_35BIT_MASK 0x00000007ffffffffULL
+
 /* Local functions to NetXen NIC driver */
 static int __devinit netxen_nic_probe(struct pci_dev *pdev,
                                      const struct pci_device_id *ent);
@@ -87,6 +95,9 @@ static struct pci_device_id netxen_pci_tbl[] __devinitdata = {
 
 MODULE_DEVICE_TABLE(pci, netxen_pci_tbl);
 
+struct workqueue_struct *netxen_workq;
+static void netxen_watchdog(unsigned long);
+
 /*
  * netxen_nic_probe()
  *
@@ -105,20 +116,28 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        struct net_device *netdev = NULL;
        struct netxen_adapter *adapter = NULL;
        struct netxen_port *port = NULL;
-       u8 *mem_ptr0 = NULL;
-       u8 *mem_ptr1 = NULL;
-       u8 *mem_ptr2 = NULL;
+       void __iomem *mem_ptr0 = NULL;
+       void __iomem *mem_ptr1 = NULL;
+       void __iomem *mem_ptr2 = NULL;
 
-       unsigned long mem_base, mem_len;
+       u8 *db_ptr = NULL;
+       unsigned long mem_base, mem_len, db_base, db_len;
        int pci_using_dac, i, err;
        int ring;
        struct netxen_recv_context *recv_ctx = NULL;
        struct netxen_rcv_desc_ctx *rcv_desc = NULL;
        struct netxen_cmd_buffer *cmd_buf_arr = NULL;
        u64 mac_addr[FLASH_NUM_PORTS + 1];
-       int valid_mac;
+       int valid_mac = 0;
+       static int netxen_cards_found = 0;
 
        printk(KERN_INFO "%s \n", netxen_nic_driver_string);
+       /* In current scheme, we use only PCI function 0 */
+       if (PCI_FUNC(pdev->devfn) != 0) {
+               DPRINTK(ERR, "NetXen function %d will not be enabled.\n",
+                       PCI_FUNC(pdev->devfn));
+               return -ENODEV;
+       }
        if ((err = pci_enable_device(pdev)))
                return err;
        if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
@@ -130,10 +149,12 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                goto err_out_disable_pdev;
 
        pci_set_master(pdev);
-       if ((pci_set_dma_mask(pdev, DMA_64BIT_MASK) == 0) &&
-           (pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK) == 0))
+       pci_read_config_byte(pdev, PCI_REVISION_ID, &nx_p2_id);
+       if (nx_p2_id == NX_P2_C1 &&
+           (pci_set_dma_mask(pdev, DMA_35BIT_MASK) == 0) &&
+           (pci_set_consistent_dma_mask(pdev, DMA_35BIT_MASK) == 0)) {
                pci_using_dac = 1;
-       else {
+       else {
                if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) ||
                    (err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK)))
                        goto err_out_free_res;
@@ -153,21 +174,34 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
            ioremap(mem_base + THIRD_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE);
 
        if ((mem_ptr0 == 0UL) || (mem_ptr1 == 0UL) || (mem_ptr2 == 0UL)) {
-               DPRINTK(1, ERR,
+               DPRINTK(ERR,
                        "Cannot remap adapter memory aborting.:"
                        "0 -> %p, 1 -> %p, 2 -> %p\n",
                        mem_ptr0, mem_ptr1, mem_ptr2);
 
                err = -EIO;
-               if (mem_ptr0)
-                       iounmap(mem_ptr0);
-               if (mem_ptr1)
-                       iounmap(mem_ptr1);
-               if (mem_ptr2)
-                       iounmap(mem_ptr2);
-
-               goto err_out_free_res;
+               goto err_out_iounmap;
+       }
+       db_base = pci_resource_start(pdev, 4);  /* doorbell is on bar 4 */
+       db_len = pci_resource_len(pdev, 4);
+
+       if (db_len == 0) {
+               printk(KERN_ERR "%s: doorbell is disabled\n",
+                      netxen_nic_driver_name);
+               err = -EIO;
+               goto err_out_iounmap;
+       }
+       DPRINTK(INFO, "doorbell ioremap from %lx a size of %lx\n", db_base,
+               db_len);
+
+       db_ptr = ioremap(db_base, NETXEN_DB_MAPSIZE_BYTES);
+       if (db_ptr == 0UL) {
+               printk(KERN_ERR "%s: Failed to allocate doorbell map.",
+                      netxen_nic_driver_name);
+               err = -EIO;
+               goto err_out_iounmap;
        }
+       DPRINTK(INFO, "doorbell ioremaped at %p\n", db_ptr);
 
 /*
  *      Allocate a adapter structure which will manage all the initialization
@@ -183,17 +217,24 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                       netxen_nic_driver_name,
                       (int)sizeof(struct netxen_adapter));
                err = -ENOMEM;
-               goto err_out_iounmap;
+               goto err_out_dbunmap;
        }
 
+       if (netxen_cards_found == 0) {
+               g_adapter = adapter;
+       }
        adapter->max_tx_desc_count = MAX_CMD_DESCRIPTORS;
        adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS;
        adapter->max_jumbo_rx_desc_count = MAX_JUMBO_RCV_DESCRIPTORS;
+       adapter->max_lro_rx_desc_count = MAX_LRO_RCV_DESCRIPTORS;
 
        pci_set_drvdata(pdev, adapter);
 
        cmd_buf_arr = (struct netxen_cmd_buffer *)vmalloc(TX_RINGSIZE);
        if (cmd_buf_arr == NULL) {
+               printk(KERN_ERR
+                      "%s: Could not allocate cmd_buf_arr memory:%d\n",
+                      netxen_nic_driver_name, (int)TX_RINGSIZE);
                err = -ENOMEM;
                goto err_out_free_adapter;
        }
@@ -220,11 +261,23 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                                rcv_desc->skb_size = MAX_RX_JUMBO_BUFFER_LENGTH;
                                break;
 
+                       case RCV_RING_LRO:
+                               rcv_desc->max_rx_desc_count =
+                                   adapter->max_lro_rx_desc_count;
+                               rcv_desc->flags = RCV_DESC_LRO;
+                               rcv_desc->dma_size = RX_LRO_DMA_MAP_LEN;
+                               rcv_desc->skb_size = MAX_RX_LRO_BUFFER_LENGTH;
+                               break;
+
                        }
                        rcv_desc->rx_buf_arr = (struct netxen_rx_buffer *)
                            vmalloc(RCV_BUFFSIZE);
 
                        if (rcv_desc->rx_buf_arr == NULL) {
+                               printk(KERN_ERR "%s: Could not allocate"
+                                      "rcv_desc->rx_buf_arr memory:%d\n",
+                                      netxen_nic_driver_name,
+                                      (int)RCV_BUFFSIZE);
                                err = -ENOMEM;
                                goto err_out_free_rx_buffer;
                        }
@@ -233,30 +286,21 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        }
 
-       adapter->ops = kzalloc(sizeof(struct netxen_drvops), GFP_KERNEL);
-       if (adapter->ops == NULL) {
-               printk(KERN_ERR
-                      "%s: Could not allocate memory for adapter->ops:%d\n",
-                      netxen_nic_driver_name,
-                      (int)sizeof(struct netxen_adapter));
-               err = -ENOMEM;
-               goto err_out_free_rx_buffer;
-       }
-
        adapter->cmd_buf_arr = cmd_buf_arr;
        adapter->ahw.pci_base0 = mem_ptr0;
        adapter->ahw.pci_base1 = mem_ptr1;
        adapter->ahw.pci_base2 = mem_ptr2;
+       adapter->ahw.db_base = db_ptr;
+       adapter->ahw.db_len = db_len;
        spin_lock_init(&adapter->tx_lock);
        spin_lock_init(&adapter->lock);
+       netxen_initialize_adapter_sw(adapter);  /* initialize the buffers in adapter */
 #ifdef CONFIG_IA64
        netxen_pinit_from_rom(adapter, 0);
        udelay(500);
        netxen_load_firmware(adapter);
 #endif
 
-       /* initialize the buffers in adapter */
-       netxen_initialize_adapter_sw(adapter);
        /*
         * Set the CRB window to invalid. If any register in window 0 is
         * accessed it should set the window to 0 and then reset it to 1.
@@ -277,7 +321,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        INIT_WORK(&adapter->watchdog_task, netxen_watchdog_task);
        adapter->ahw.pdev = pdev;
        adapter->proc_cmd_buf_counter = 0;
-       pci_read_config_byte(pdev, PCI_REVISION_ID, &adapter->ahw.revision_id);
+       adapter->ahw.revision_id = nx_p2_id;
 
        if (pci_enable_msi(pdev)) {
                adapter->flags &= ~NETXEN_NIC_MSI_ENABLED;
@@ -299,6 +343,12 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET));
        writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO));
 
+       /* do this before waking up pegs so that we have valid dummy dma addr */
+       err = netxen_initialize_adapter_offload(adapter);
+       if (err) {
+               goto err_out_free_dev;
+       }
+
        /* Unlock the HW, prompting the boot sequence */
        writel(1,
               NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE));
@@ -307,6 +357,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
 
        /* initialize the all the ports */
+       adapter->active_ports = 0;
 
        for (i = 0; i < adapter->ahw.max_ports; i++) {
                netdev = alloc_etherdev(sizeof(struct netxen_port));
@@ -372,10 +423,9 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                                       netdev->dev_addr[4],
                                       netdev->dev_addr[5]);
                        } else {
-                               if (adapter->ops->macaddr_set)
-                                       adapter->ops->macaddr_set(port,
-                                                                 netdev->
-                                                                 dev_addr);
+                               if (adapter->macaddr_set)
+                                       adapter->macaddr_set(port,
+                                                            netdev->dev_addr);
                        }
                }
                adapter->netdev = netdev;
@@ -391,7 +441,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                        goto err_out_free_dev;
                }
                adapter->port_count++;
-               adapter->active_ports = 0;
                adapter->port[i] = port;
        }
 
@@ -412,6 +461,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                break;
        }
 
+       adapter->number = netxen_cards_found;
        adapter->driver_mismatch = 0;
 
        return 0;
@@ -426,7 +476,8 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                        free_netdev(port->netdev);
                }
        }
-       kfree(adapter->ops);
+
+       netxen_free_adapter_offload(adapter);
 
       err_out_free_rx_buffer:
        for (i = 0; i < MAX_RCV_CTX; ++i) {
@@ -439,19 +490,23 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                        }
                }
        }
-
        vfree(cmd_buf_arr);
 
-       kfree(adapter->port);
-
       err_out_free_adapter:
        pci_set_drvdata(pdev, NULL);
        kfree(adapter);
 
+      err_out_dbunmap:
+       if (db_ptr)
+               iounmap(db_ptr);
+
       err_out_iounmap:
-       iounmap(mem_ptr0);
-       iounmap(mem_ptr1);
-       iounmap(mem_ptr2);
+       if (mem_ptr0)
+               iounmap(mem_ptr0);
+       if (mem_ptr1)
+               iounmap(mem_ptr1);
+       if (mem_ptr2)
+               iounmap(mem_ptr2);
 
       err_out_free_res:
        pci_release_regions(pdev);
@@ -476,12 +531,8 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
 
        netxen_nic_stop_all_ports(adapter);
        /* leave the hw in the same state as reboot */
-       netxen_pinit_from_rom(adapter, 0);
-       udelay(500);
        netxen_load_firmware(adapter);
-
-       if ((adapter->flags & NETXEN_NIC_MSI_ENABLED))
-               netxen_nic_disable_int(adapter);
+       netxen_free_adapter_offload(adapter);
 
        udelay(500);            /* Delay for a while to drain the DMA engines */
        for (i = 0; i < adapter->port_count; i++) {
@@ -498,6 +549,7 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
        if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC)
                netxen_free_hw_resources(adapter);
 
+       iounmap(adapter->ahw.db_base);
        iounmap(adapter->ahw.pci_base0);
        iounmap(adapter->ahw.pci_base1);
        iounmap(adapter->ahw.pci_base2);
@@ -524,7 +576,6 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
        }
 
        vfree(adapter->cmd_buf_arr);
-       kfree(adapter->ops);
        kfree(adapter);
 }
 
@@ -546,6 +597,8 @@ static int netxen_nic_open(struct net_device *netdev)
                        return -EIO;
                }
                netxen_nic_flash_print(adapter);
+               if (adapter->init_niu)
+                       adapter->init_niu(adapter);
 
                /* setup all the resources for the Phantom... */
                /* this include the descriptors for rcv, tx, and status */
@@ -556,32 +609,31 @@ static int netxen_nic_open(struct net_device *netdev)
                               err);
                        return err;
                }
-               if (adapter->ops->init_port
-                   && adapter->ops->init_port(adapter, port->portnum) != 0) {
+               if (adapter->init_port
+                   && adapter->init_port(adapter, port->portnum) != 0) {
                        printk(KERN_ERR "%s: Failed to initialize port %d\n",
                               netxen_nic_driver_name, port->portnum);
                        netxen_free_hw_resources(adapter);
                        return -EIO;
                }
-               if (adapter->ops->init_niu)
-                       adapter->ops->init_niu(adapter);
                for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
                        for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++)
                                netxen_post_rx_buffers(adapter, ctx, ring);
                }
-               adapter->is_up = NETXEN_ADAPTER_UP_MAGIC;
-       }
-       adapter->active_ports++;
-       if (adapter->active_ports == 1) {
+               adapter->irq = adapter->ahw.pdev->irq;
                err = request_irq(adapter->ahw.pdev->irq, &netxen_intr,
                                  SA_SHIRQ | SA_SAMPLE_RANDOM, netdev->name,
                                  adapter);
                if (err) {
                        printk(KERN_ERR "request_irq failed with: %d\n", err);
-                       adapter->active_ports--;
+                       netxen_free_hw_resources(adapter);
                        return err;
                }
-               adapter->irq = adapter->ahw.pdev->irq;
+
+               adapter->is_up = NETXEN_ADAPTER_UP_MAGIC;
+       }
+       adapter->active_ports++;
+       if (adapter->active_ports == 1) {
                if (!adapter->driver_mismatch)
                        mod_timer(&adapter->watchdog_timer, jiffies);
 
@@ -590,11 +642,14 @@ static int netxen_nic_open(struct net_device *netdev)
 
        /* Done here again so that even if phantom sw overwrote it,
         * we set it */
-       if (adapter->ops->macaddr_set)
-               adapter->ops->macaddr_set(port, netdev->dev_addr);
+       if (adapter->macaddr_set)
+               adapter->macaddr_set(port, netdev->dev_addr);
        netxen_nic_set_link_parameters(port);
 
        netxen_nic_set_multi(netdev);
+       if (adapter->set_mtu)
+               adapter->set_mtu(port, netdev->mtu);
+
        if (!adapter->driver_mismatch)
                netif_start_queue(netdev);
 
@@ -647,6 +702,7 @@ static int netxen_nic_close(struct net_device *netdev)
                        }
                        cmd_buff++;
                }
+               FLUSH_SCHEDULED_WORK();
                del_timer_sync(&adapter->watchdog_timer);
        }
 
@@ -667,7 +723,6 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
        struct cmd_desc_type0 *hwdesc;
        int k;
        struct netxen_cmd_buffer *pbuf = NULL;
-       unsigned int tries = 0;
        static int dropped_packet = 0;
        int frag_count;
        u32 local_producer = 0;
@@ -729,7 +784,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
                        if (((skb->nh.iph)->ihl * sizeof(u32)) +
                            ((skb->h.th)->doff * sizeof(u32)) +
                            sizeof(struct ethhdr) >
-                           (sizeof(struct cmd_desc_type0) - NET_IP_ALIGN)) {
+                           (sizeof(struct cmd_desc_type0) - 2)) {
                                no_of_desc++;
                        }
                }
@@ -740,27 +795,17 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
        if ((k + no_of_desc) >=
            ((last_cmd_consumer <= k) ? last_cmd_consumer + max_tx_desc_count :
             last_cmd_consumer)) {
+               port->stats.nocmddescriptor++;
+               DPRINTK(ERR, "No command descriptors available,"
+                       " producer = %d, consumer = %d count=%llu,"
+                       " dropping packet\n", producer,
+                       adapter->last_cmd_consumer,
+                       port->stats.nocmddescriptor);
+
+               netif_stop_queue(netdev);
+               port->flags |= NETXEN_NETDEV_STATUS;
                spin_unlock_bh(&adapter->tx_lock);
-               if (tries == 0) {
-                       local_bh_disable();
-                       netxen_process_cmd_ring((unsigned long)adapter);
-                       local_bh_enable();
-                       ++tries;
-                       goto retry_getting_window;
-               } else {
-                       port->stats.nocmddescriptor++;
-                       DPRINTK(ERR, "No command descriptors available,"
-                               " producer = %d, consumer = %d count=%llu,"
-                               " dropping packet\n", producer,
-                               adapter->last_cmd_consumer,
-                               port->stats.nocmddescriptor);
-
-                       spin_lock_bh(&adapter->tx_lock);
-                       netif_stop_queue(netdev);
-                       port->flags |= NETXEN_NETDEV_STATUS;
-                       spin_unlock_bh(&adapter->tx_lock);
-                       return NETDEV_TX_BUSY;
-               }
+               return NETDEV_TX_BUSY;
        }
        k = get_index_range(k, max_tx_desc_count, no_of_desc);
        adapter->cmd_producer = k;
@@ -782,7 +827,6 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
                pbuf->mss = 0;
                hwdesc->mss = 0;
        }
-       pbuf->no_of_descriptors = no_of_desc;
        pbuf->total_length = skb->len;
        pbuf->skb = skb;
        pbuf->cmd = TX_ETHER_PKT;
@@ -792,11 +836,11 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
        buffrag->dma = pci_map_single(port->pdev, skb->data, first_seg_len,
                                      PCI_DMA_TODEVICE);
        buffrag->length = first_seg_len;
-       CMD_DESC_TOTAL_LENGTH_WRT(hwdesc, skb->len);
-       hwdesc->num_of_buffers = frag_count;
-       hwdesc->opcode = TX_ETHER_PKT;
+       netxen_set_cmd_desc_totallength(hwdesc, skb->len);
+       netxen_set_cmd_desc_num_of_buff(hwdesc, frag_count);
+       netxen_set_cmd_desc_opcode(hwdesc, TX_ETHER_PKT);
 
-       CMD_DESC_PORT_WRT(hwdesc, port->portnum);
+       netxen_set_cmd_desc_port(hwdesc, port->portnum);
        hwdesc->buffer1_length = cpu_to_le16(first_seg_len);
        hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma);
 
@@ -855,12 +899,12 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
        /* For LSO, we need to copy the MAC/IP/TCP headers into
         * the descriptor ring
         */
-       if (hw->cmd_desc_head[saved_producer].opcode == TX_TCP_LSO) {
+       if (netxen_get_cmd_desc_opcode(&hw->cmd_desc_head[saved_producer])
+           == TX_TCP_LSO) {
                int hdr_len, first_hdr_len, more_hdr;
                hdr_len = hw->cmd_desc_head[saved_producer].total_hdr_length;
-               if (hdr_len > (sizeof(struct cmd_desc_type0) - NET_IP_ALIGN)) {
-                       first_hdr_len =
-                           sizeof(struct cmd_desc_type0) - NET_IP_ALIGN;
+               if (hdr_len > (sizeof(struct cmd_desc_type0) - 2)) {
+                       first_hdr_len = sizeof(struct cmd_desc_type0) - 2;
                        more_hdr = 1;
                } else {
                        first_hdr_len = hdr_len;
@@ -870,7 +914,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
                hwdesc = &hw->cmd_desc_head[producer];
 
                /* copy the first 64 bytes */
-               memcpy(((void *)hwdesc) + NET_IP_ALIGN,
+               memcpy(((void *)hwdesc) + 2,
                       (void *)(skb->data), first_hdr_len);
                producer = get_next_index(producer, max_tx_desc_count);
 
@@ -886,7 +930,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
        }
        spin_lock_bh(&adapter->tx_lock);
        port->stats.txbytes +=
-           CMD_DESC_TOTAL_LENGTH(&hw->cmd_desc_head[saved_producer]);
+           netxen_get_cmd_desc_totallength(&hw->cmd_desc_head[saved_producer]);
        /* Code to update the adapter considering how many producer threads
           are currently working */
        if ((--adapter->num_threads) == 0) {
@@ -896,20 +940,6 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
                       NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_PRODUCER_OFFSET));
                wmb();
                adapter->total_threads = 0;
-       } else {
-               u32 crb_producer = 0;
-               crb_producer =
-                   readl(NETXEN_CRB_NORMALIZE
-                         (adapter, CRB_CMD_PRODUCER_OFFSET));
-               if (crb_producer == local_producer) {
-                       crb_producer = get_index_range(crb_producer,
-                                                      max_tx_desc_count,
-                                                      no_of_desc);
-                       writel(crb_producer,
-                              NETXEN_CRB_NORMALIZE(adapter,
-                                                   CRB_CMD_PRODUCER_OFFSET));
-                       wmb();
-               }
        }
 
        port->stats.xmitfinished++;
@@ -926,15 +956,20 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 static void netxen_watchdog(unsigned long v)
 {
        struct netxen_adapter *adapter = (struct netxen_adapter *)v;
-       schedule_work(&adapter->watchdog_task);
+       if (adapter != g_adapter) {
+               printk("%s: ***BUG*** adapter[%p] != g_adapter[%p]\n",
+                      __FUNCTION__, adapter, g_adapter);
+               return;
+       }
+
+       SCHEDULE_WORK(&adapter->watchdog_task);
 }
 
 static void netxen_tx_timeout(struct net_device *netdev)
 {
        struct netxen_port *port = (struct netxen_port *)netdev_priv(netdev);
-       struct netxen_adapter *adapter = port->adapter;
 
-       schedule_work(&adapter->tx_timeout_task);
+       SCHEDULE_WORK(&port->adapter->tx_timeout_task);
 }
 
 static void netxen_tx_timeout_task(struct work_struct *work)
@@ -967,6 +1002,11 @@ netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev)
        if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
                int count = 0;
                u32 mask;
+               mask = readl(pci_base_offset(adapter, ISR_INT_VECTOR));
+               if ((mask & 0x80) == 0) {
+                       /* not our interrupt */
+                       return ret;
+               }
                netxen_nic_disable_int(adapter);
                /* Window = 0 or 1 */
                do {
@@ -1026,7 +1066,10 @@ irqreturn_t netxen_intr(int irq, void *data)
                netdev = port->netdev;
 
                /* process our status queue (for all 4 ports) */
-               netxen_handle_int(adapter, netdev);
+               if (netif_running(netdev)) {
+                       netxen_handle_int(adapter, netdev);
+                       break;
+               }
        }
 
        return IRQ_HANDLED;
@@ -1040,11 +1083,12 @@ static int netxen_nic_poll(struct net_device *netdev, int *budget)
        int done = 1;
        int ctx;
        int this_work_done;
+       int work_done = 0;
 
        DPRINTK(INFO, "polling for %d descriptors\n", *budget);
        port->stats.polled++;
 
-       adapter->work_done = 0;
+       work_done = 0;
        for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
                /*
                 * Fairness issue. This will give undue weight to the
@@ -1061,20 +1105,20 @@ static int netxen_nic_poll(struct net_device *netdev, int *budget)
                this_work_done = netxen_process_rcv_ring(adapter, ctx,
                                                         work_to_do /
                                                         MAX_RCV_CTX);
-               adapter->work_done += this_work_done;
+               work_done += this_work_done;
        }
 
-       netdev->quota -= adapter->work_done;
-       *budget -= adapter->work_done;
+       netdev->quota -= work_done;
+       *budget -= work_done;
 
-       if (adapter->work_done >= work_to_do
-           && netxen_nic_rx_has_work(adapter) != 0)
+       if (work_done >= work_to_do && netxen_nic_rx_has_work(adapter) != 0)
                done = 0;
 
-       netxen_process_cmd_ring((unsigned long)adapter);
+       if (netxen_process_cmd_ring((unsigned long)adapter) == 0)
+               done = 0;
 
        DPRINTK(INFO, "new work_done: %d work_to_do: %d\n",
-               adapter->work_done, work_to_do);
+               work_done, work_to_do);
        if (done) {
                netif_rx_complete(netdev);
                netxen_nic_enable_int(adapter);
@@ -1117,8 +1161,9 @@ netxen_nic_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
                if (ifr->ifr_data) {
                        sprintf(dev_name, "%s-%d", NETXEN_NIC_NAME_RSP,
                                port->portnum);
-                       nr_bytes = copy_to_user((char *)ifr->ifr_data, dev_name,
-                                               NETXEN_NIC_NAME_LEN);
+                       nr_bytes =
+                           copy_to_user((char __user *)ifr->ifr_data, dev_name,
+                                        NETXEN_NIC_NAME_LEN);
                        if (nr_bytes)
                                err = -EIO;
 
@@ -1145,6 +1190,9 @@ static struct pci_driver netxen_driver = {
 
 static int __init netxen_init_module(void)
 {
+       if ((netxen_workq = create_singlethread_workqueue("netxen")) == 0)
+               return -ENOMEM;
+
        return pci_module_init(&netxen_driver);
 }
 
@@ -1155,7 +1203,7 @@ static void __exit netxen_exit_module(void)
        /*
         * Wait for some time to allow the dma to drain, if any.
         */
-       mdelay(5);
+       destroy_workqueue(netxen_workq);
        pci_unregister_driver(&netxen_driver);
 }
 
index 7950a04532e6603e69a0190f6df90593ae4e7226..4987dc765d99017391a0f29f0612a61e46fa874c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2003 - 2006 NetXen, Inc.
  * 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
  * 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:
  *    info@netxen.com
  * NetXen,
 
 static long phy_lock_timeout = 100000000;
 
-static inline int phy_lock(void)
+static inline int phy_lock(struct netxen_adapter *adapter)
 {
        int i;
        int done = 0, timeout = 0;
 
        while (!done) {
-               done = readl((void __iomem *)NETXEN_PCIE_REG(PCIE_SEM3_LOCK));
+               done =
+                   readl(pci_base_offset
+                         (adapter, NETXEN_PCIE_REG(PCIE_SEM3_LOCK)));
                if (done == 1)
                        break;
                if (timeout >= phy_lock_timeout) {
@@ -61,13 +63,15 @@ static inline int phy_lock(void)
                }
        }
 
-       writel(NETXEN_PHY_LOCK_ID, (void __iomem *)PHY_LOCK_DRIVER);
+       writel(PHY_LOCK_DRIVER,
+              NETXEN_CRB_NORMALIZE(adapter, NETXEN_PHY_LOCK_ID));
        return 0;
 }
 
-static inline int phy_unlock(void)
+static inline int phy_unlock(struct netxen_adapter *adapter)
 {
-       readl((void __iomem *)NETXEN_PCIE_REG(PCIE_SEM3_UNLOCK));
+       readl(pci_base_offset(adapter, NETXEN_PCIE_REG(PCIE_SEM3_UNLOCK)));
+
        return 0;
 }
 
@@ -95,7 +99,7 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy,
        __le32 status;
        __le32 mac_cfg0;
 
-       if (phy_lock() != 0) {
+       if (phy_lock(adapter) != 0) {
                return -1;
        }
 
@@ -162,7 +166,7 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy,
                                           NETXEN_NIU_GB_MAC_CONFIG_0(0),
                                           &mac_cfg0, 4))
                        return -EIO;
-       phy_unlock();
+       phy_unlock(adapter);
        return result;
 }
 
@@ -399,8 +403,8 @@ int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port)
 {
        int result = 0;
        __le32 status;
-       if (adapter->ops->disable_phy_interrupts)
-               adapter->ops->disable_phy_interrupts(adapter, port);
+       if (adapter->disable_phy_interrupts)
+               adapter->disable_phy_interrupts(adapter, port);
        mdelay(2);
 
        if (0 ==
@@ -612,7 +616,7 @@ int netxen_niu_macaddr_set(struct netxen_port *port,
        __le32 temp = 0;
        struct netxen_adapter *adapter = port->adapter;
        int phy = port->portnum;
-       unsigned char mac_addr[MAX_ADDR_LEN];
+       unsigned char mac_addr[6];
        int i;
 
        for (i = 0; i < 10; i++) {
@@ -631,7 +635,7 @@ int netxen_niu_macaddr_set(struct netxen_port *port,
 
                netxen_niu_macaddr_get(adapter, phy,
                                       (netxen_ethernet_macaddr_t *) mac_addr);
-               if (memcmp(mac_addr, addr, MAX_ADDR_LEN == 0))
+               if (memcmp(mac_addr, addr, 6) == 0)
                        break;
        }
 
index 8181d436783f0a2d582f3b2ae55372b2e50ae695..7879f855af0b27786414d0b06a914a6cb9c3011a 100644 (file)
 /* 
  * CRB Registers or queue message done only at initialization time.
  */
+#define NIC_CRB_BASE               NETXEN_CAM_RAM(0x200)
+#define NETXEN_NIC_REG(X)             (NIC_CRB_BASE+(X))
 
-/*
- * The following 2 are the base adresses for the CRB registers and their
- * offsets will be added to get addresses for the index addresses.
- */
-#define NIC_CRB_BASE_PORT1     NETXEN_CAM_RAM(0x200)
-#define NIC_CRB_BASE_PORT2     NETXEN_CAM_RAM(0x250)
+#define CRB_PHAN_CNTRL_LO_OFFSET    NETXEN_NIC_REG(0x00)
+#define CRB_PHAN_CNTRL_HI_OFFSET    NETXEN_NIC_REG(0x04)
+#define CRB_CMD_PRODUCER_OFFSET     NETXEN_NIC_REG(0x08)
+#define CRB_CMD_CONSUMER_OFFSET     NETXEN_NIC_REG(0x0c)
+#define CRB_PAUSE_ADDR_LO           NETXEN_NIC_REG(0x10)       /* C0 EPG BUG  */
+#define CRB_PAUSE_ADDR_HI           NETXEN_NIC_REG(0x14)
+#define CRB_HOST_CMD_ADDR_HI        NETXEN_NIC_REG(0x18)       /* host add:cmd ring */
+#define CRB_HOST_CMD_ADDR_LO        NETXEN_NIC_REG(0x1c)
+#define CRB_CMD_INTR_LOOP           NETXEN_NIC_REG(0x20)       /* 4 regs for perf */
+#define CRB_CMD_DMA_LOOP            NETXEN_NIC_REG(0x24)
+#define CRB_RCV_INTR_LOOP           NETXEN_NIC_REG(0x28)
+#define CRB_RCV_DMA_LOOP            NETXEN_NIC_REG(0x2c)
+#define CRB_ENABLE_TX_INTR          NETXEN_NIC_REG(0x30)       /* phantom init status */
+#define CRB_MMAP_ADDR_3             NETXEN_NIC_REG(0x34)
+#define CRB_CMDPEG_CMDRING          NETXEN_NIC_REG(0x38)
+#define CRB_HOST_DUMMY_BUF_ADDR_HI  NETXEN_NIC_REG(0x3c)
+#define CRB_HOST_DUMMY_BUF_ADDR_LO  NETXEN_NIC_REG(0x40)
+#define CRB_MMAP_ADDR_0             NETXEN_NIC_REG(0x44)
+#define CRB_MMAP_ADDR_1             NETXEN_NIC_REG(0x48)
+#define CRB_MMAP_ADDR_2             NETXEN_NIC_REG(0x4c)
+#define CRB_CMDPEG_STATE            NETXEN_NIC_REG(0x50)
+#define CRB_MMAP_SIZE_0             NETXEN_NIC_REG(0x54)
+#define CRB_MMAP_SIZE_1             NETXEN_NIC_REG(0x58)
+#define CRB_MMAP_SIZE_2             NETXEN_NIC_REG(0x5c)
+#define CRB_MMAP_SIZE_3             NETXEN_NIC_REG(0x60)
+#define CRB_GLOBAL_INT_COAL         NETXEN_NIC_REG(0x64)       /* interrupt coalescing */
+#define CRB_INT_COAL_MODE           NETXEN_NIC_REG(0x68)
+#define CRB_MAX_RCV_BUFS            NETXEN_NIC_REG(0x6c)
+#define CRB_TX_INT_THRESHOLD        NETXEN_NIC_REG(0x70)
+#define CRB_RX_PKT_TIMER            NETXEN_NIC_REG(0x74)
+#define CRB_TX_PKT_TIMER            NETXEN_NIC_REG(0x78)
+#define CRB_RX_PKT_CNT              NETXEN_NIC_REG(0x7c)
+#define CRB_RX_TMR_CNT              NETXEN_NIC_REG(0x80)
+#define CRB_RX_LRO_TIMER            NETXEN_NIC_REG(0x84)
+#define CRB_RX_LRO_MID_TIMER        NETXEN_NIC_REG(0x88)
+#define CRB_DMA_MAX_RCV_BUFS        NETXEN_NIC_REG(0x8c)
+#define CRB_MAX_DMA_ENTRIES         NETXEN_NIC_REG(0x90)
+#define CRB_XG_STATE                NETXEN_NIC_REG(0x94)       /* XG Link status */
+#define CRB_AGENT_GO                NETXEN_NIC_REG(0x98)       /* NIC pkt gen agent */
+#define CRB_AGENT_TX_SIZE           NETXEN_NIC_REG(0x9c)
+#define CRB_AGENT_TX_TYPE           NETXEN_NIC_REG(0xa0)
+#define CRB_AGENT_TX_ADDR           NETXEN_NIC_REG(0xa4)
+#define CRB_AGENT_TX_MSS            NETXEN_NIC_REG(0xa8)
+#define CRB_TX_STATE                NETXEN_NIC_REG(0xac)       /* Debug -performance */
+#define CRB_TX_COUNT                NETXEN_NIC_REG(0xb0)
+#define CRB_RX_STATE                NETXEN_NIC_REG(0xb4)
+#define CRB_RX_PERF_DEBUG_1         NETXEN_NIC_REG(0xb8)
+#define CRB_RX_LRO_CONTROL          NETXEN_NIC_REG(0xbc)       /* LRO On/OFF */
+#define CRB_RX_LRO_START_NUM        NETXEN_NIC_REG(0xc0)
+#define CRB_MPORT_MODE              NETXEN_NIC_REG(0xc4)       /* Multiport Mode */
+#define CRB_CMD_RING_SIZE           NETXEN_NIC_REG(0xc8)
+#define CRB_INT_VECTOR              NETXEN_NIC_REG(0xd4)
+#define CRB_CTX_RESET               NETXEN_NIC_REG(0xd8)
+#define CRB_HOST_STS_PROD           NETXEN_NIC_REG(0xdc)
+#define CRB_HOST_STS_CONS           NETXEN_NIC_REG(0xe0)
+#define CRB_PEG_CMD_PROD            NETXEN_NIC_REG(0xe4)
+#define CRB_PEG_CMD_CONS            NETXEN_NIC_REG(0xe8)
+#define CRB_HOST_BUFFER_PROD        NETXEN_NIC_REG(0xec)
+#define CRB_HOST_BUFFER_CONS        NETXEN_NIC_REG(0xf0)
+#define CRB_JUMBO_BUFFER_PROD       NETXEN_NIC_REG(0xf4)
+#define CRB_JUMBO_BUFFER_CONS       NETXEN_NIC_REG(0xf8)
 
-#define NETXEN_NIC_REG(X)      (NIC_CRB_BASE_PORT1+(X))
+#define CRB_CMD_PRODUCER_OFFSET_1   NETXEN_NIC_REG(0x1ac)
+#define CRB_CMD_CONSUMER_OFFSET_1   NETXEN_NIC_REG(0x1b0)
+#define CRB_TEMP_STATE              NETXEN_NIC_REG(0x1b4)
 
 /*
  * CrbPortPhanCntrHi/Lo is used to pass the address of HostPhantomIndex address
  * on the Phantom.
  */
 
-#define CRB_PHAN_CNTRL_LO_OFFSET       NETXEN_NIC_REG(0x00)
-#define CRB_PHAN_CNTRL_HI_OFFSET       NETXEN_NIC_REG(0x04)
-
-/* point to the indexes */
-#define CRB_CMD_PRODUCER_OFFSET                NETXEN_NIC_REG(0x08)
-#define CRB_CMD_CONSUMER_OFFSET                NETXEN_NIC_REG(0x0c)
-
-#define CRB_PAUSE_ADDR_LO              NETXEN_NIC_REG(0x10)
-#define CRB_PAUSE_ADDR_HI              NETXEN_NIC_REG(0x14)
-
-/* address of command descriptors in the host memory */
-#define CRB_HOST_CMD_ADDR_HI           NETXEN_NIC_REG(0x30)
-#define CRB_HOST_CMD_ADDR_LO           NETXEN_NIC_REG(0x34)
-
-/* The following 4 CRB registers are for doing performance coal */
-#define CRB_CMD_INTR_LOOP              NETXEN_NIC_REG(0x38)
-#define CRB_CMD_DMA_LOOP               NETXEN_NIC_REG(0x3c)
-#define CRB_RCV_INTR_LOOP              NETXEN_NIC_REG(0x40)
-#define CRB_RCV_DMA_LOOP               NETXEN_NIC_REG(0x44)
-
-/* Needed by the host to find out the state of Phantom's initialization */
-#define CRB_ENABLE_TX_INTR             NETXEN_NIC_REG(0x4c)
-#define CRB_CMDPEG_STATE               NETXEN_NIC_REG(0x50)
-#define CRB_CMDPEG_CMDRING             NETXEN_NIC_REG(0x54)
-
-/* Interrupt coalescing parameters */
-#define CRB_GLOBAL_INT_COAL            NETXEN_NIC_REG(0x80)
-#define CRB_INT_COAL_MODE              NETXEN_NIC_REG(0x84)
-#define CRB_MAX_RCV_BUFS               NETXEN_NIC_REG(0x88)
-#define CRB_TX_INT_THRESHOLD           NETXEN_NIC_REG(0x8c)
-#define CRB_RX_PKT_TIMER               NETXEN_NIC_REG(0x90)
-#define CRB_TX_PKT_TIMER               NETXEN_NIC_REG(0x94)
-#define CRB_RX_PKT_CNT                 NETXEN_NIC_REG(0x98)
-#define CRB_RX_TMR_CNT                 NETXEN_NIC_REG(0x9c)
-#define CRB_INT_THRESH          NETXEN_NIC_REG(0xa4)
-
-/* Register for communicating XG link status */
-#define CRB_XG_STATE                   NETXEN_NIC_REG(0xa0)
-
-/* Register for communicating card temperature */
-/* Upper 16 bits are temperature value. Lower 16 bits are the state */
-#define CRB_TEMP_STATE          NETXEN_NIC_REG(0xa8)
-#define nx_get_temp_val(x)          ((x) >> 16)
-#define nx_get_temp_state(x)      ((x) & 0xffff)
-#define nx_encode_temp(val, state)     (((val) << 16) | (state))
-
-/* Debug registers for controlling NIC pkt gen agent */
-#define CRB_AGENT_GO                   NETXEN_NIC_REG(0xb0)
-#define CRB_AGENT_TX_SIZE              NETXEN_NIC_REG(0xb4)
-#define CRB_AGENT_TX_TYPE              NETXEN_NIC_REG(0xb8)
-#define CRB_AGENT_TX_ADDR              NETXEN_NIC_REG(0xbc)
-#define CRB_AGENT_TX_MSS               NETXEN_NIC_REG(0xc0)
-
-/* Debug registers for observing NIC performance */
-#define CRB_TX_STATE                   NETXEN_NIC_REG(0xd0)
-#define CRB_TX_COUNT                   NETXEN_NIC_REG(0xd4)
-#define CRB_RX_STATE                   NETXEN_NIC_REG(0xd8)
+#define nx_get_temp_val(x)             ((x) >> 16)
+#define nx_get_temp_state(x)           ((x) & 0xffff)
+#define nx_encode_temp(val, state)     (((val) << 16) | (state))
 
 /* CRB registers per Rcv Descriptor ring */
 struct netxen_rcv_desc_crb {
        u32 crb_rcv_producer_offset __attribute__ ((aligned(512)));
        u32 crb_rcv_consumer_offset;
        u32 crb_globalrcv_ring;
+       u32 crb_rcv_ring_size;
 };
 
 /*
- * CRB registers used by the receive peg logic. One instance of these
- * needs to be instantiated per instance of the receive peg.
+ * CRB registers used by the receive peg logic.
  */
 
 struct netxen_recv_crb {
@@ -127,6 +132,7 @@ struct netxen_recv_crb {
        u32 crb_rcv_status_producer;
        u32 crb_rcv_status_consumer;
        u32 crb_rcvpeg_state;
+       u32 crb_status_ring_size;
 };
 
 #if defined(DEFINE_GLOBAL_RECV_CRB)
@@ -139,30 +145,48 @@ struct netxen_recv_crb recv_crb_registers[] = {
         {
          {
           /* crb_rcv_producer_offset: */
-          NETXEN_NIC_REG(0x18),
+          NETXEN_NIC_REG(0x100),
           /* crb_rcv_consumer_offset: */
-          NETXEN_NIC_REG(0x1c),
+          NETXEN_NIC_REG(0x104),
           /* crb_gloablrcv_ring: */
-          NETXEN_NIC_REG(0x20),
+          NETXEN_NIC_REG(0x108),
+          /* crb_rcv_ring_size */
+          NETXEN_NIC_REG(0x10c),
+
           },
          /* Jumbo frames */
          {
           /* crb_rcv_producer_offset: */
-          NETXEN_NIC_REG(0x100),
+          NETXEN_NIC_REG(0x110),
           /* crb_rcv_consumer_offset: */
-          NETXEN_NIC_REG(0x104),
+          NETXEN_NIC_REG(0x114),
           /* crb_gloablrcv_ring: */
-          NETXEN_NIC_REG(0x108),
+          NETXEN_NIC_REG(0x118),
+          /* crb_rcv_ring_size */
+          NETXEN_NIC_REG(0x11c),
+          },
+         /* LRO */
+         {
+          /* crb_rcv_producer_offset: */
+          NETXEN_NIC_REG(0x120),
+          /* crb_rcv_consumer_offset: */
+          NETXEN_NIC_REG(0x124),
+          /* crb_gloablrcv_ring: */
+          NETXEN_NIC_REG(0x128),
+          /* crb_rcv_ring_size */
+          NETXEN_NIC_REG(0x12c),
           }
          },
         /* crb_rcvstatus_ring: */
-        NETXEN_NIC_REG(0x24),
+        NETXEN_NIC_REG(0x130),
         /* crb_rcv_status_producer: */
-        NETXEN_NIC_REG(0x28),
+        NETXEN_NIC_REG(0x134),
         /* crb_rcv_status_consumer: */
-        NETXEN_NIC_REG(0x2c),
+        NETXEN_NIC_REG(0x138),
         /* crb_rcvpeg_state: */
-        NETXEN_NIC_REG(0x48),
+        NETXEN_NIC_REG(0x13c),
+        /* crb_status_ring_size */
+        NETXEN_NIC_REG(0x140),
 
         },
        /*
@@ -173,34 +197,66 @@ struct netxen_recv_crb recv_crb_registers[] = {
         {
          {
           /* crb_rcv_producer_offset: */
-          NETXEN_NIC_REG(0x80),
+          NETXEN_NIC_REG(0x144),
           /* crb_rcv_consumer_offset: */
-          NETXEN_NIC_REG(0x84),
+          NETXEN_NIC_REG(0x148),
           /* crb_globalrcv_ring: */
-          NETXEN_NIC_REG(0x88),
+          NETXEN_NIC_REG(0x14c),
+          /* crb_rcv_ring_size */
+          NETXEN_NIC_REG(0x150),
+
           },
          /* Jumbo frames */
          {
           /* crb_rcv_producer_offset: */
-          NETXEN_NIC_REG(0x10C),
+          NETXEN_NIC_REG(0x154),
           /* crb_rcv_consumer_offset: */
-          NETXEN_NIC_REG(0x110),
+          NETXEN_NIC_REG(0x158),
           /* crb_globalrcv_ring: */
-          NETXEN_NIC_REG(0x114),
+          NETXEN_NIC_REG(0x15c),
+          /* crb_rcv_ring_size */
+          NETXEN_NIC_REG(0x160),
+          },
+         /* LRO */
+         {
+          /* crb_rcv_producer_offset: */
+          NETXEN_NIC_REG(0x164),
+          /* crb_rcv_consumer_offset: */
+          NETXEN_NIC_REG(0x168),
+          /* crb_globalrcv_ring: */
+          NETXEN_NIC_REG(0x16c),
+          /* crb_rcv_ring_size */
+          NETXEN_NIC_REG(0x170),
           }
+
          },
         /* crb_rcvstatus_ring: */
-        NETXEN_NIC_REG(0x8c),
+        NETXEN_NIC_REG(0x174),
         /* crb_rcv_status_producer: */
-        NETXEN_NIC_REG(0x90),
+        NETXEN_NIC_REG(0x178),
         /* crb_rcv_status_consumer: */
-        NETXEN_NIC_REG(0x94),
+        NETXEN_NIC_REG(0x17c),
         /* crb_rcvpeg_state: */
-        NETXEN_NIC_REG(0x98),
+        NETXEN_NIC_REG(0x180),
+        /* crb_status_ring_size */
+        NETXEN_NIC_REG(0x184),
+
         },
 };
+
+u64 ctx_addr_sig_regs[][3] = {
+       {NETXEN_NIC_REG(0x188), NETXEN_NIC_REG(0x18c), NETXEN_NIC_REG(0x1c0)},
+       {NETXEN_NIC_REG(0x190), NETXEN_NIC_REG(0x194), NETXEN_NIC_REG(0x1c4)},
+       {NETXEN_NIC_REG(0x198), NETXEN_NIC_REG(0x19c), NETXEN_NIC_REG(0x1c8)},
+       {NETXEN_NIC_REG(0x1a0), NETXEN_NIC_REG(0x1a4), NETXEN_NIC_REG(0x1cc)}
+};
+
 #else
 extern struct netxen_recv_crb recv_crb_registers[];
+extern u64 ctx_addr_sig_regs[][3];
+#define CRB_CTX_ADDR_REG_LO            (ctx_addr_sig_regs[0][0])
+#define CRB_CTX_ADDR_REG_HI            (ctx_addr_sig_regs[0][2])
+#define CRB_CTX_SIGNATURE_REG       (ctx_addr_sig_regs[0][1])
 #endif                         /* DEFINE_GLOBAL_RECEIVE_CRB */
 
 /*
index 26e42f6e9fb10323ec9dcb492b6b1af86ebda147..196993a29b09d2f020d6606eb72f0a4aa8bb5263 100644 (file)
@@ -1335,7 +1335,7 @@ int __init init_module(void)
        return 0;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        unregister_netdev(dev_ni52);
        release_region(dev_ni52->base_addr, NI52_TOTAL_SIZE);
index 340ad0d5388aa9ff20fd98f9d526793f8b68611e..1578f4d984987eed6dfd0320b961721df4fe8068 100644 (file)
@@ -1259,7 +1259,7 @@ int __init init_module(void)
        return IS_ERR(dev_ni65) ? PTR_ERR(dev_ni65) : 0;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        unregister_netdev(dev_ni65);
        cleanup_card(dev_ni65);
index 312e0e331712d37abd10e549e891d093f5fd9618..568daeb3e9d8f56ac0e4b37249c5d2b9507dc66f 100644 (file)
@@ -414,10 +414,10 @@ struct rx_info {
 
        struct sk_buff  *skbs[NR_RX_DESC];
 
-       u32             *next_rx_desc;
+       __le32          *next_rx_desc;
        u16             next_rx, next_empty;
 
-       u32             *descs;
+       __le32          *descs;
        dma_addr_t      phy_descs;
 };
 
@@ -460,7 +460,7 @@ struct ns83820 {
        struct sk_buff  *tx_skbs[NR_TX_DESC];
 
        char            pad[16] __attribute__((aligned(16)));
-       u32             *tx_descs;
+       __le32          *tx_descs;
        dma_addr_t      tx_phy_descs;
 
        struct timer_list       tx_watchdog;
@@ -534,7 +534,7 @@ static void ns83820_vlan_rx_kill_vid(struct net_device *ndev, unsigned short vid
  * conditions, still route realtime traffic with as low jitter as
  * possible.
  */
-static inline void build_rx_desc(struct ns83820 *dev, u32 *desc, dma_addr_t link, dma_addr_t buf, u32 cmdsts, u32 extsts)
+static inline void build_rx_desc(struct ns83820 *dev, __le32 *desc, dma_addr_t link, dma_addr_t buf, u32 cmdsts, u32 extsts)
 {
        desc_addr_set(desc + DESC_LINK, link);
        desc_addr_set(desc + DESC_BUFPTR, buf);
@@ -548,7 +548,7 @@ static inline int ns83820_add_rx_skb(struct ns83820 *dev, struct sk_buff *skb)
 {
        unsigned next_empty;
        u32 cmdsts;
-       u32 *sg;
+       __le32 *sg;
        dma_addr_t buf;
 
        next_empty = dev->rx_info.next_empty;
@@ -875,7 +875,8 @@ static void fastcall rx_irq(struct net_device *ndev)
        struct rx_info *info = &dev->rx_info;
        unsigned next_rx;
        int rx_rc, len;
-       u32 cmdsts, *desc;
+       u32 cmdsts;
+       __le32 *desc;
        unsigned long flags;
        int nr = 0;
 
@@ -1011,7 +1012,8 @@ static inline void kick_tx(struct ns83820 *dev)
 static void do_tx_done(struct net_device *ndev)
 {
        struct ns83820 *dev = PRIV(ndev);
-       u32 cmdsts, tx_done_idx, *desc;
+       u32 cmdsts, tx_done_idx;
+       __le32 *desc;
 
        dprintk("do_tx_done(%p)\n", ndev);
        tx_done_idx = dev->tx_done_idx;
@@ -1078,7 +1080,7 @@ static void ns83820_cleanup_tx(struct ns83820 *dev)
                struct sk_buff *skb = dev->tx_skbs[i];
                dev->tx_skbs[i] = NULL;
                if (skb) {
-                       u32 *desc = dev->tx_descs + (i * DESC_SIZE);
+                       __le32 *desc = dev->tx_descs + (i * DESC_SIZE);
                        pci_unmap_single(dev->pci_dev,
                                        desc_addr_get(desc + DESC_BUFPTR),
                                        le32_to_cpu(desc[DESC_CMDSTS]) & CMDSTS_LEN_MASK,
@@ -1108,7 +1110,7 @@ static int ns83820_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
        skb_frag_t *frag;
        int stopped = 0;
        int do_intr = 0;
-       volatile u32 *first_desc;
+       volatile __le32 *first_desc;
 
        dprintk("ns83820_hard_start_xmit\n");
 
@@ -1181,7 +1183,7 @@ again:
        first_desc = dev->tx_descs + (free_idx * DESC_SIZE);
 
        for (;;) {
-               volatile u32 *desc = dev->tx_descs + (free_idx * DESC_SIZE);
+               volatile __le32 *desc = dev->tx_descs + (free_idx * DESC_SIZE);
 
                dprintk("frag[%3u]: %4u @ 0x%08Lx\n", free_idx, len,
                        (unsigned long long)buf);
@@ -1456,7 +1458,8 @@ static int ns83820_stop(struct net_device *ndev)
 static void ns83820_tx_timeout(struct net_device *ndev)
 {
        struct ns83820 *dev = PRIV(ndev);
-        u32 tx_done_idx, *desc;
+        u32 tx_done_idx;
+       __le32 *desc;
        unsigned long flags;
 
        spin_lock_irqsave(&dev->tx_lock, flags);
index 4044bb1ada8655ebd3a7daa9af2395068efeb34d..e175f3910b18e53711429e9d940ef01814469483 100644 (file)
@@ -587,8 +587,7 @@ int phy_stop_interrupts(struct phy_device *phydev)
         * Finish any pending work; we might have been scheduled
         * to be called from keventd ourselves, though.
         */
-       if (!current_is_keventd())
-               flush_scheduled_work();
+       run_scheduled_work(&phydev->phy_queue);
 
        free_irq(phydev->irq, phydev);
 
index 85a392fab5cc4dbc1541033cc35d5aa5401dc2b6..f83b41d4cb0e64f8374b55b894bf916171b8a479 100644 (file)
@@ -225,6 +225,7 @@ MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl);
 
 static int rx_copybreak = 200;
 static int use_dac;
+static int ignore_parity_err;
 static struct {
        u32 msg_enable;
 } debug = { -1 };
@@ -470,6 +471,8 @@ module_param(use_dac, int, 0);
 MODULE_PARM_DESC(use_dac, "Enable PCI DAC. Unsafe on 32 bit PCI slot.");
 module_param_named(debug, debug.msg_enable, int, 0);
 MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)");
+module_param_named(ignore_parity_err, ignore_parity_err, bool, 0);
+MODULE_PARM_DESC(ignore_parity_err, "Ignore PCI parity error as target. Default: false");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(RTL8169_VERSION);
 
@@ -1284,11 +1287,6 @@ static void rtl8169_hw_phy_config(struct net_device *dev)
        /* Shazam ! */
 
        if (tp->mac_version == RTL_GIGA_MAC_VER_04) {
-               mdio_write(ioaddr, 31, 0x0001);
-               mdio_write(ioaddr,  9, 0x273a);
-               mdio_write(ioaddr, 14, 0x7bfb);
-               mdio_write(ioaddr, 27, 0x841e);
-
                mdio_write(ioaddr, 31, 0x0002);
                mdio_write(ioaddr,  1, 0x90d0);
                mdio_write(ioaddr, 31, 0x0000);
@@ -1817,12 +1815,25 @@ static void rtl8169_hw_reset(void __iomem *ioaddr)
        RTL_R8(ChipCmd);
 }
 
-static void
-rtl8169_hw_start(struct net_device *dev)
+static void rtl8169_set_rx_tx_config_registers(struct rtl8169_private *tp)
+{
+       void __iomem *ioaddr = tp->mmio_addr;
+       u32 cfg = rtl8169_rx_config;
+
+       cfg |= (RTL_R32(RxConfig) & rtl_chip_info[tp->chipset].RxConfigMask);
+       RTL_W32(RxConfig, cfg);
+
+       /* Set DMA burst size and Interframe Gap Time */
+       RTL_W32(TxConfig, (TX_DMA_BURST << TxDMAShift) |
+               (InterFrameGap << TxInterFrameGapShift));
+}
+
+static void rtl8169_hw_start(struct net_device *dev)
 {
        struct rtl8169_private *tp = netdev_priv(dev);
        void __iomem *ioaddr = tp->mmio_addr;
        struct pci_dev *pdev = tp->pci_dev;
+       u16 cmd;
        u32 i;
 
        /* Soft reset the chip. */
@@ -1835,6 +1846,11 @@ rtl8169_hw_start(struct net_device *dev)
                msleep_interruptible(1);
        }
 
+       if (tp->mac_version == RTL_GIGA_MAC_VER_05) {
+               RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) | PCIMulRW);
+               pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x08);
+       }
+
        if (tp->mac_version == RTL_GIGA_MAC_VER_13) {
                pci_write_config_word(pdev, 0x68, 0x00);
                pci_write_config_word(pdev, 0x69, 0x08);
@@ -1842,8 +1858,6 @@ rtl8169_hw_start(struct net_device *dev)
 
        /* Undocumented stuff. */
        if (tp->mac_version == RTL_GIGA_MAC_VER_05) {
-               u16 cmd;
-
                /* Realtek's r1000_n.c driver uses '&& 0x01' here. Well... */
                if ((RTL_R8(Config2) & 0x07) & 0x01)
                        RTL_W32(0x7c, 0x0007ffff);
@@ -1855,23 +1869,29 @@ rtl8169_hw_start(struct net_device *dev)
                pci_write_config_word(pdev, PCI_COMMAND, cmd);
        }
 
-
        RTL_W8(Cfg9346, Cfg9346_Unlock);
+       if ((tp->mac_version == RTL_GIGA_MAC_VER_01) ||
+           (tp->mac_version == RTL_GIGA_MAC_VER_02) ||
+           (tp->mac_version == RTL_GIGA_MAC_VER_03) ||
+           (tp->mac_version == RTL_GIGA_MAC_VER_04))
+               RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
+
        RTL_W8(EarlyTxThres, EarlyTxThld);
 
        /* Low hurts. Let's disable the filtering. */
        RTL_W16(RxMaxSize, 16383);
 
-       /* Set Rx Config register */
-       i = rtl8169_rx_config |
-               (RTL_R32(RxConfig) & rtl_chip_info[tp->chipset].RxConfigMask);
-       RTL_W32(RxConfig, i);
+       if ((tp->mac_version == RTL_GIGA_MAC_VER_01) ||
+           (tp->mac_version == RTL_GIGA_MAC_VER_02) ||
+           (tp->mac_version == RTL_GIGA_MAC_VER_03) ||
+           (tp->mac_version == RTL_GIGA_MAC_VER_04))
+               RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
+               rtl8169_set_rx_tx_config_registers(tp);
 
-       /* Set DMA burst size and Interframe Gap Time */
-       RTL_W32(TxConfig, (TX_DMA_BURST << TxDMAShift) |
-               (InterFrameGap << TxInterFrameGapShift));
+       cmd = RTL_R16(CPlusCmd);
+       RTL_W16(CPlusCmd, cmd);
 
-       tp->cp_cmd |= RTL_R16(CPlusCmd) | PCIMulRW;
+       tp->cp_cmd |= cmd | PCIMulRW;
 
        if ((tp->mac_version == RTL_GIGA_MAC_VER_02) ||
            (tp->mac_version == RTL_GIGA_MAC_VER_03)) {
@@ -1897,7 +1917,15 @@ rtl8169_hw_start(struct net_device *dev)
        RTL_W32(TxDescStartAddrLow, ((u64) tp->TxPhyAddr & DMA_32BIT_MASK));
        RTL_W32(RxDescAddrHigh, ((u64) tp->RxPhyAddr >> 32));
        RTL_W32(RxDescAddrLow, ((u64) tp->RxPhyAddr & DMA_32BIT_MASK));
-       RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
+
+       if ((tp->mac_version != RTL_GIGA_MAC_VER_01) &&
+           (tp->mac_version != RTL_GIGA_MAC_VER_02) &&
+           (tp->mac_version != RTL_GIGA_MAC_VER_03) &&
+           (tp->mac_version != RTL_GIGA_MAC_VER_04)) {
+               RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
+               rtl8169_set_rx_tx_config_registers(tp);
+       }
+
        RTL_W8(Cfg9346, Cfg9346_Lock);
 
        /* Initially a 10 us delay. Turned it into a PCI commit. - FR */
@@ -1992,7 +2020,7 @@ static int rtl8169_alloc_rx_skb(struct pci_dev *pdev, struct sk_buff **sk_buff,
        if (!skb)
                goto err_out;
 
-       skb_reserve(skb, align);
+       skb_reserve(skb, (align - 1) & (u32)skb->data);
        *sk_buff = skb;
 
        mapping = pci_map_single(pdev, skb->data, rx_buf_sz,
@@ -2355,12 +2383,17 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev)
        /*
         * The recovery sequence below admits a very elaborated explanation:
         * - it seems to work;
-        * - I did not see what else could be done.
+        * - I did not see what else could be done;
+        * - it makes iop3xx happy.
         *
         * Feel free to adjust to your needs.
         */
-       pci_write_config_word(pdev, PCI_COMMAND,
-                             pci_cmd | PCI_COMMAND_SERR | PCI_COMMAND_PARITY);
+       if (ignore_parity_err)
+               pci_cmd &= ~PCI_COMMAND_PARITY;
+       else
+               pci_cmd |= PCI_COMMAND_SERR | PCI_COMMAND_PARITY;
+
+       pci_write_config_word(pdev, PCI_COMMAND, pci_cmd);
 
        pci_write_config_word(pdev, PCI_STATUS,
                pci_status & (PCI_STATUS_DETECTED_PARITY |
@@ -2374,10 +2407,11 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev)
                tp->cp_cmd &= ~PCIDAC;
                RTL_W16(CPlusCmd, tp->cp_cmd);
                dev->features &= ~NETIF_F_HIGHDMA;
-               rtl8169_schedule_work(dev, rtl8169_reinit_task);
        }
 
        rtl8169_hw_reset(ioaddr);
+
+       rtl8169_schedule_work(dev, rtl8169_reinit_task);
 }
 
 static void
@@ -2457,7 +2491,7 @@ static inline int rtl8169_try_rx_copy(struct sk_buff **sk_buff, int pkt_size,
 
                skb = dev_alloc_skb(pkt_size + align);
                if (skb) {
-                       skb_reserve(skb, align);
+                       skb_reserve(skb, (align - 1) & (u32)skb->data);
                        eth_copy_and_sum(skb, sk_buff[0]->data, pkt_size, 0);
                        *sk_buff = skb;
                        rtl8169_mark_to_asic(desc, rx_buf_sz);
index d9d0a3a3c558b349e7c3d0a6147bb8a06538a743..0d6c95c7aedf9b6accd679bd2c29869eeb20e191 100644 (file)
@@ -750,7 +750,7 @@ int __init init_module(void)
        return 0;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        unregister_netdev(dev_seeq);
        release_region(dev_seeq->base_addr, SEEQ8005_IO_EXTENT);
index ab66d80a4455896d8fe7084c1f3943d50df3567a..3e7aa49afd00565e8a10a13b07c5fd98d6f44f64 100644 (file)
@@ -1319,7 +1319,7 @@ SK_BOOL   AutoNeg)        /* Is Auto-negotiation used ? */
        SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_INT_STAT, &Isrc);
 
 #ifdef xDEBUG
-       if ((Isrc & ~(PHY_B_IS_HCT | PHY_B_IS_LCT) ==
+       if ((Isrc & ~(PHY_B_IS_HCT | PHY_B_IS_LCT)) ==
                (PHY_B_IS_SCR_S_ER | PHY_B_IS_RRS_CHANGE | PHY_B_IS_LRS_CHANGE)) {
 
                SK_U32  Stat1, Stat2, Stat3;
index 23e5275d920c49f719855bd0ca52739834ecd965..f6223c533c015bff50618d66bc8c3340c048e337 100644 (file)
@@ -389,10 +389,10 @@ enum {
 /* Packet Arbiter Registers */
 /*     B3_PA_CTRL              16 bit  Packet Arbiter Ctrl Register */
 enum {
-       PA_CLR_TO_TX2   = 1<<13,        /* Clear IRQ Packet Timeout TX2 */
-       PA_CLR_TO_TX1   = 1<<12,        /* Clear IRQ Packet Timeout TX1 */
-       PA_CLR_TO_RX2   = 1<<11,        /* Clear IRQ Packet Timeout RX2 */
-       PA_CLR_TO_RX1   = 1<<10,        /* Clear IRQ Packet Timeout RX1 */
+       PA_CLR_TO_TX2   = 1<<13,/* Clear IRQ Packet Timeout TX2 */
+       PA_CLR_TO_TX1   = 1<<12,/* Clear IRQ Packet Timeout TX1 */
+       PA_CLR_TO_RX2   = 1<<11,/* Clear IRQ Packet Timeout RX2 */
+       PA_CLR_TO_RX1   = 1<<10,/* Clear IRQ Packet Timeout RX1 */
        PA_ENA_TO_TX2   = 1<<9, /* Enable  Timeout Timer TX2 */
        PA_DIS_TO_TX2   = 1<<8, /* Disable Timeout Timer TX2 */
        PA_ENA_TO_TX1   = 1<<7, /* Enable  Timeout Timer TX1 */
@@ -481,14 +481,14 @@ enum {
 /* RAM Buffer Register Offsets */
 enum {
 
-       RB_START        = 0x00,/* 32 bit        RAM Buffer Start Address */
+       RB_START= 0x00,/* 32 bit        RAM Buffer Start Address */
        RB_END  = 0x04,/* 32 bit        RAM Buffer End Address */
        RB_WP   = 0x08,/* 32 bit        RAM Buffer Write Pointer */
        RB_RP   = 0x0c,/* 32 bit        RAM Buffer Read Pointer */
-       RB_RX_UTPP      = 0x10,/* 32 bit        Rx Upper Threshold, Pause Packet */
-       RB_RX_LTPP      = 0x14,/* 32 bit        Rx Lower Threshold, Pause Packet */
-       RB_RX_UTHP      = 0x18,/* 32 bit        Rx Upper Threshold, High Prio */
-       RB_RX_LTHP      = 0x1c,/* 32 bit        Rx Lower Threshold, High Prio */
+       RB_RX_UTPP= 0x10,/* 32 bit      Rx Upper Threshold, Pause Packet */
+       RB_RX_LTPP= 0x14,/* 32 bit      Rx Lower Threshold, Pause Packet */
+       RB_RX_UTHP= 0x18,/* 32 bit      Rx Upper Threshold, High Prio */
+       RB_RX_LTHP= 0x1c,/* 32 bit      Rx Lower Threshold, High Prio */
        /* 0x10 - 0x1f: reserved at Tx RAM Buffer Registers */
        RB_PC   = 0x20,/* 32 bit        RAM Buffer Packet Counter */
        RB_LEV  = 0x24,/* 32 bit        RAM Buffer Level Register */
@@ -532,7 +532,7 @@ enum {
        PHY_ADDR_MARV   = 0,
 };
 
-#define RB_ADDR(offs, queue) (B16_RAM_REGS + (queue) + (offs))
+#define RB_ADDR(offs, queue) ((u16)B16_RAM_REGS + (u16)(queue) + (offs))
 
 /* Receive MAC FIFO, Receive LED, and Link_Sync regs (GENESIS only) */
 enum {
@@ -578,15 +578,15 @@ enum {
        MFF_DIS_TIST    = 1<<2, /* Disable Time Stamp Gener */
        MFF_CLR_INTIST  = 1<<1, /* Clear IRQ No Time Stamp */
        MFF_CLR_INSTAT  = 1<<0, /* Clear IRQ No Status */
-#define MFF_RX_CTRL_DEF MFF_ENA_TIM_PAT
+       MFF_RX_CTRL_DEF = MFF_ENA_TIM_PAT,
 };
 
 /*     TX_MFF_CTRL1    16 bit  Transmit MAC FIFO Control Reg 1 */
 enum {
-       MFF_CLR_PERR    = 1<<15,        /* Clear Parity Error IRQ */
-                                                               /* Bit 14:      reserved */
-       MFF_ENA_PKT_REC = 1<<13,        /* Enable  Packet Recovery */
-       MFF_DIS_PKT_REC = 1<<12,        /* Disable Packet Recovery */
+       MFF_CLR_PERR    = 1<<15, /* Clear Parity Error IRQ */
+
+       MFF_ENA_PKT_REC = 1<<13, /* Enable  Packet Recovery */
+       MFF_DIS_PKT_REC = 1<<12, /* Disable Packet Recovery */
 
        MFF_ENA_W4E     = 1<<7, /* Enable  Wait for Empty */
        MFF_DIS_W4E     = 1<<6, /* Disable Wait for Empty */
@@ -595,9 +595,10 @@ enum {
        MFF_DIS_LOOPB   = 1<<2, /* Disable Loopback */
        MFF_CLR_MAC_RST = 1<<1, /* Clear XMAC Reset */
        MFF_SET_MAC_RST = 1<<0, /* Set   XMAC Reset */
+
+       MFF_TX_CTRL_DEF  = MFF_ENA_PKT_REC | (u16) MFF_ENA_TIM_PAT | MFF_ENA_FLUSH,
 };
 
-#define MFF_TX_CTRL_DEF        (MFF_ENA_PKT_REC | MFF_ENA_TIM_PAT | MFF_ENA_FLUSH)
 
 /*     RX_MFF_TST2              8 bit  Receive MAC FIFO Test Register 2 */
 /*     TX_MFF_TST2              8 bit  Transmit MAC FIFO Test Register 2 */
@@ -1304,8 +1305,8 @@ enum {
 
 /* special defines for FIBER (88E1011S only) */
 enum {
-       PHY_M_AN_ASP_X  = 1<<8, /* Asymmetric Pause */
-       PHY_M_AN_PC_X   = 1<<7, /* MAC Pause implemented */
+       PHY_M_AN_ASP_X          = 1<<8, /* Asymmetric Pause */
+       PHY_M_AN_PC_X           = 1<<7, /* MAC Pause implemented */
        PHY_M_AN_1000X_AHD      = 1<<6, /* Advertise 10000Base-X Half Duplex */
        PHY_M_AN_1000X_AFD      = 1<<5, /* Advertise 10000Base-X Full Duplex */
 };
@@ -1320,7 +1321,7 @@ enum {
 
 /*****  PHY_MARV_1000T_CTRL    16 bit r/w      1000Base-T Control Reg *****/
 enum {
-       PHY_M_1000C_TEST        = 7<<13,/* Bit 15..13:  Test Modes */
+       PHY_M_1000C_TEST= 7<<13,/* Bit 15..13:  Test Modes */
        PHY_M_1000C_MSE = 1<<12, /* Manual Master/Slave Enable */
        PHY_M_1000C_MSC = 1<<11, /* M/S Configuration (1=Master) */
        PHY_M_1000C_MPD = 1<<10, /* Multi-Port Device */
@@ -1349,7 +1350,7 @@ enum {
        PHY_M_PC_EN_DET_PLUS    = 3<<8, /* Energy Detect Plus (Mode 2) */
 };
 
-#define PHY_M_PC_MDI_XMODE(x)  (((x)<<5) & PHY_M_PC_MDIX_MSK)
+#define PHY_M_PC_MDI_XMODE(x)  ((((u16)(x)<<5) & PHY_M_PC_MDIX_MSK)
 
 enum {
        PHY_M_PC_MAN_MDI        = 0, /* 00 = Manual MDI configuration */
@@ -1432,24 +1433,24 @@ enum {
        PHY_M_EC_DIS_LINK_P = 1<<12, /* Disable Link Pulses (88E1111 only) */
        PHY_M_EC_M_DSC_MSK  = 3<<10, /* Bit 11..10:     Master Downshift Counter */
                                        /* (88E1011 only) */
-       PHY_M_EC_S_DSC_MSK      = 3<<8,/* Bit  9.. 8:   Slave  Downshift Counter */
+       PHY_M_EC_S_DSC_MSK  = 3<<8,  /* Bit  9.. 8:     Slave  Downshift Counter */
                                       /* (88E1011 only) */
-       PHY_M_EC_M_DSC_MSK2     = 7<<9,/* Bit 11.. 9:   Master Downshift Counter */
+       PHY_M_EC_M_DSC_MSK2  = 7<<9, /* Bit 11.. 9:     Master Downshift Counter */
                                        /* (88E1111 only) */
-       PHY_M_EC_DOWN_S_ENA     = 1<<8, /* Downshift Enable (88E1111 only) */
+       PHY_M_EC_DOWN_S_ENA  = 1<<8, /* Downshift Enable (88E1111 only) */
                                        /* !!! Errata in spec. (1 = disable) */
-       PHY_M_EC_RX_TIM_CT      = 1<<7, /* RGMII Rx Timing Control*/
-       PHY_M_EC_MAC_S_MSK      = 7<<4,/* Bit  6.. 4:   Def. MAC interface speed */
-       PHY_M_EC_FIB_AN_ENA     = 1<<3, /* Fiber Auto-Neg. Enable (88E1011S only) */
-       PHY_M_EC_DTE_D_ENA      = 1<<2, /* DTE Detect Enable (88E1111 only) */
-       PHY_M_EC_TX_TIM_CT      = 1<<1, /* RGMII Tx Timing Control */
-       PHY_M_EC_TRANS_DIS      = 1<<0, /* Transmitter Disable (88E1111 only) */};
-
-#define PHY_M_EC_M_DSC(x)      ((x)<<10) /* 00=1x; 01=2x; 10=3x; 11=4x */
-#define PHY_M_EC_S_DSC(x)      ((x)<<8) /* 00=dis; 01=1x; 10=2x; 11=3x */
-#define PHY_M_EC_MAC_S(x)      ((x)<<4) /* 01X=0; 110=2.5; 111=25 (MHz) */
-
-#define PHY_M_EC_M_DSC_2(x)    ((x)<<9) /* 000=1x; 001=2x; 010=3x; 011=4x */
+       PHY_M_EC_RX_TIM_CT   = 1<<7, /* RGMII Rx Timing Control*/
+       PHY_M_EC_MAC_S_MSK   = 7<<4, /* Bit  6.. 4:     Def. MAC interface speed */
+       PHY_M_EC_FIB_AN_ENA  = 1<<3, /* Fiber Auto-Neg. Enable (88E1011S only) */
+       PHY_M_EC_DTE_D_ENA   = 1<<2, /* DTE Detect Enable (88E1111 only) */
+       PHY_M_EC_TX_TIM_CT   = 1<<1, /* RGMII Tx Timing Control */
+       PHY_M_EC_TRANS_DIS   = 1<<0, /* Transmitter Disable (88E1111 only) */};
+
+#define PHY_M_EC_M_DSC(x)      ((u16)(x)<<10) /* 00=1x; 01=2x; 10=3x; 11=4x */
+#define PHY_M_EC_S_DSC(x)      ((u16)(x)<<8) /* 00=dis; 01=1x; 10=2x; 11=3x */
+#define PHY_M_EC_MAC_S(x)      ((u16)(x)<<4) /* 01X=0; 110=2.5; 111=25 (MHz) */
+
+#define PHY_M_EC_M_DSC_2(x)    ((u16)(x)<<9) /* 000=1x; 001=2x; 010=3x; 011=4x */
                                                                                        /* 100=5x; 101=6x; 110=7x; 111=8x */
 enum {
        MAC_TX_CLK_0_MHZ        = 2,
@@ -1468,10 +1469,12 @@ enum {
        PHY_M_LEDC_LK_C_MSK     = 7<<3,/* Bit  5.. 3: Link Control Mask */
                                        /* (88E1111 only) */
 };
+#define PHY_M_LED_PULS_DUR(x)  (((u16)(x)<<12) & PHY_M_LEDC_PULS_MSK)
+#define PHY_M_LED_BLINK_RT(x)  (((u16)(x)<<8) & PHY_M_LEDC_BL_R_MSK)
 
 enum {
-       PHY_M_LEDC_LINK_MSK     = 3<<3,/* Bit  4.. 3: Link Control Mask */
-                                                                       /* (88E1011 only) */
+       PHY_M_LEDC_LINK_MSK     = 3<<3, /* Bit  4.. 3: Link Control Mask */
+                                       /* (88E1011 only) */
        PHY_M_LEDC_DP_CTRL      = 1<<2, /* Duplex Control */
        PHY_M_LEDC_DP_C_MSB     = 1<<2, /* Duplex Control (MSB, 88E1111 only) */
        PHY_M_LEDC_RX_CTRL      = 1<<1, /* Rx Activity / Link */
@@ -1479,27 +1482,24 @@ enum {
        PHY_M_LEDC_TX_C_MSB     = 1<<0, /* Tx Control (MSB, 88E1111 only) */
 };
 
-#define PHY_M_LED_PULS_DUR(x)  (((x)<<12) & PHY_M_LEDC_PULS_MSK)
-
 enum {
-       PULS_NO_STR     = 0,/* no pulse stretching */
-       PULS_21MS       = 1,/* 21 ms to 42 ms */
-       PULS_42MS       = 2,/* 42 ms to 84 ms */
-       PULS_84MS       = 3,/* 84 ms to 170 ms */
-       PULS_170MS      = 4,/* 170 ms to 340 ms */
-       PULS_340MS      = 5,/* 340 ms to 670 ms */
-       PULS_670MS      = 6,/* 670 ms to 1.3 s */
-       PULS_1300MS     = 7,/* 1.3 s to 2.7 s */
+       PULS_NO_STR     = 0, /* no pulse stretching */
+       PULS_21MS       = 1, /* 21 ms to 42 ms */
+       PULS_42MS       = 2, /* 42 ms to 84 ms */
+       PULS_84MS       = 3, /* 84 ms to 170 ms */
+       PULS_170MS      = 4, /* 170 ms to 340 ms */
+       PULS_340MS      = 5, /* 340 ms to 670 ms */
+       PULS_670MS      = 6, /* 670 ms to 1.3 s */
+       PULS_1300MS     = 7, /* 1.3 s to 2.7 s */
 };
 
-#define PHY_M_LED_BLINK_RT(x)  (((x)<<8) & PHY_M_LEDC_BL_R_MSK)
 
 enum {
-       BLINK_42MS      = 0,/* 42 ms */
-       BLINK_84MS      = 1,/* 84 ms */
-       BLINK_170MS     = 2,/* 170 ms */
-       BLINK_340MS     = 3,/* 340 ms */
-       BLINK_670MS     = 4,/* 670 ms */
+       BLINK_42MS      = 0, /* 42 ms */
+       BLINK_84MS      = 1, /* 84 ms */
+       BLINK_170MS     = 2, /* 170 ms */
+       BLINK_340MS     = 3, /* 340 ms */
+       BLINK_670MS     = 4, /* 670 ms */
 };
 
 /*****  PHY_MARV_LED_OVER      16 bit r/w      Manual LED Override Reg *****/
@@ -1525,7 +1525,7 @@ enum {
        PHY_M_EC2_FO_IMPED      = 1<<5, /* Fiber Output Impedance */
        PHY_M_EC2_FO_M_CLK      = 1<<4, /* Fiber Mode Clock Enable */
        PHY_M_EC2_FO_BOOST      = 1<<3, /* Fiber Output Boost */
-       PHY_M_EC2_FO_AM_MSK     = 7,/* Bit  2.. 0:      Fiber Output Amplitude */
+       PHY_M_EC2_FO_AM_MSK     = 7, /* Bit  2.. 0:     Fiber Output Amplitude */
 };
 
 /*****  PHY_MARV_EXT_P_STAT 16 bit r/w Ext. PHY Specific Status *****/
@@ -1550,7 +1550,7 @@ enum {
        PHY_M_CABD_DIS_WAIT     = 1<<15, /* Disable Waiting Period (Page 1) */
                                        /* (88E1111 only) */
        PHY_M_CABD_STAT_MSK     = 3<<13, /* Bit 14..13: Status Mask */
-       PHY_M_CABD_AMPL_MSK     = 0x1f<<8,/* Bit 12.. 8: Amplitude Mask */
+       PHY_M_CABD_AMPL_MSK     = 0x1f<<8, /* Bit 12.. 8: Amplitude Mask */
                                        /* (88E1111 only) */
        PHY_M_CABD_DIST_MSK     = 0xff, /* Bit  7.. 0: Distance Mask */
 };
@@ -1605,9 +1605,9 @@ enum {
 
 /*****  PHY_MARV_PHY_CTRL (page 3)             16 bit r/w      LED Control Reg. *****/
 enum {
-       PHY_M_LEDC_LOS_MSK      = 0xf<<12,/* Bit 15..12: LOS LED Ctrl. Mask */
+       PHY_M_LEDC_LOS_MSK      = 0xf<<12, /* Bit 15..12: LOS LED Ctrl. Mask */
        PHY_M_LEDC_INIT_MSK     = 0xf<<8, /* Bit 11.. 8: INIT LED Ctrl. Mask */
-       PHY_M_LEDC_STA1_MSK     = 0xf<<4,/* Bit  7.. 4: STAT1 LED Ctrl. Mask */
+       PHY_M_LEDC_STA1_MSK     = 0xf<<4, /* Bit  7.. 4: STAT1 LED Ctrl. Mask */
        PHY_M_LEDC_STA0_MSK     = 0xf, /* Bit  3.. 0: STAT0 LED Ctrl. Mask */
 };
 
@@ -1804,8 +1804,8 @@ enum {
 
 /*     GM_SMI_CTRL                     16 bit r/w      SMI Control Register */
 enum {
-       GM_SMI_CT_PHY_A_MSK     = 0x1f<<11,/* Bit 15..11:       PHY Device Address */
-       GM_SMI_CT_REG_A_MSK     = 0x1f<<6,/* Bit 10.. 6:        PHY Register Address */
+       GM_SMI_CT_PHY_A_MSK     = 0x1f<<11, /* Bit 15..11:      PHY Device Address */
+       GM_SMI_CT_REG_A_MSK     = 0x1f<<6, /* Bit 10.. 6:       PHY Register Address */
        GM_SMI_CT_OP_RD         = 1<<5, /* Bit  5:      OpCode Read (0=Write)*/
        GM_SMI_CT_RD_VAL        = 1<<4, /* Bit  4:      Read Valid (Read completed) */
        GM_SMI_CT_BUSY          = 1<<3, /* Bit  3:      Busy (Operation in progress) */
@@ -1875,9 +1875,9 @@ enum {
 
 /*     TX_GMF_CTRL_T   32 bit  Tx GMAC FIFO Control/Test */
 enum {
-       GMF_WSP_TST_ON  = 1<<18,/* Write Shadow Pointer Test On */
-       GMF_WSP_TST_OFF = 1<<17,/* Write Shadow Pointer Test Off */
-       GMF_WSP_STEP    = 1<<16,/* Write Shadow Pointer Step/Increment */
+       GMF_WSP_TST_ON  = 1<<18, /* Write Shadow Pointer Test On */
+       GMF_WSP_TST_OFF = 1<<17, /* Write Shadow Pointer Test Off */
+       GMF_WSP_STEP    = 1<<16, /* Write Shadow Pointer Step/Increment */
 
        GMF_CLI_TX_FU   = 1<<6, /* Clear IRQ Tx FIFO Underrun */
        GMF_CLI_TX_FC   = 1<<5, /* Clear IRQ Tx Frame Complete */
@@ -2111,18 +2111,18 @@ enum {
 
 /*     XM_MMU_CMD      16 bit r/w      MMU Command Register */
 enum {
-       XM_MMU_PHY_RDY  = 1<<12,/* Bit 12:      PHY Read Ready */
-       XM_MMU_PHY_BUSY = 1<<11,/* Bit 11:      PHY Busy */
-       XM_MMU_IGN_PF   = 1<<10,/* Bit 10:      Ignore Pause Frame */
-       XM_MMU_MAC_LB   = 1<<9, /* Bit  9:      Enable MAC Loopback */
-       XM_MMU_FRC_COL  = 1<<7, /* Bit  7:      Force Collision */
-       XM_MMU_SIM_COL  = 1<<6, /* Bit  6:      Simulate Collision */
-       XM_MMU_NO_PRE   = 1<<5, /* Bit  5:      No MDIO Preamble */
-       XM_MMU_GMII_FD  = 1<<4, /* Bit  4:      GMII uses Full Duplex */
-       XM_MMU_RAT_CTRL = 1<<3, /* Bit  3:      Enable Rate Control */
-       XM_MMU_GMII_LOOP= 1<<2, /* Bit  2:      PHY is in Loopback Mode */
-       XM_MMU_ENA_RX   = 1<<1, /* Bit  1:      Enable Receiver */
-       XM_MMU_ENA_TX   = 1<<0, /* Bit  0:      Enable Transmitter */
+       XM_MMU_PHY_RDY  = 1<<12, /* Bit 12:     PHY Read Ready */
+       XM_MMU_PHY_BUSY = 1<<11, /* Bit 11:     PHY Busy */
+       XM_MMU_IGN_PF   = 1<<10, /* Bit 10:     Ignore Pause Frame */
+       XM_MMU_MAC_LB   = 1<<9,  /* Bit  9:     Enable MAC Loopback */
+       XM_MMU_FRC_COL  = 1<<7,  /* Bit  7:     Force Collision */
+       XM_MMU_SIM_COL  = 1<<6,  /* Bit  6:     Simulate Collision */
+       XM_MMU_NO_PRE   = 1<<5,  /* Bit  5:     No MDIO Preamble */
+       XM_MMU_GMII_FD  = 1<<4,  /* Bit  4:     GMII uses Full Duplex */
+       XM_MMU_RAT_CTRL = 1<<3,  /* Bit  3:     Enable Rate Control */
+       XM_MMU_GMII_LOOP= 1<<2,  /* Bit  2:     PHY is in Loopback Mode */
+       XM_MMU_ENA_RX   = 1<<1,  /* Bit  1:     Enable Receiver */
+       XM_MMU_ENA_TX   = 1<<0,  /* Bit  0:     Enable Transmitter */
 };
 
 
@@ -2506,7 +2506,7 @@ static inline void skge_write8(const struct skge_hw *hw, int reg, u8 val)
 }
 
 /* MAC Related Registers inside the device. */
-#define SK_REG(port,reg)       (((port)<<7)+(reg))
+#define SK_REG(port,reg)       (((port)<<7)+(u16)(reg))
 #define SK_XMAC_REG(port, reg) \
        ((BASE_XMAC_1 + (port) * (BASE_XMAC_2 - BASE_XMAC_1)) | (reg) << 1)
 
index 842abd9396c64ca7aecee1de7be90e06a141d0f1..fb1d2c30c1bb4a34f0d89650e0ed75ed3b11256f 100644 (file)
@@ -100,33 +100,32 @@ module_param(idle_timeout, int, 0);
 MODULE_PARM_DESC(idle_timeout, "Watchdog timer for lost interrupts (ms)");
 
 static const struct pci_device_id sky2_id_table[] = {
-       { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) },
-       { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) },
+       { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, /* SK-9Sxx */
+       { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, /* SK-9Exx */
        { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) },    /* DGE-560T */
        { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4001) },    /* DGE-550SX */
        { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4B02) },    /* DGE-560SX */
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4340) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4341) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4342) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4343) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4344) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4345) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4346) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4347) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4350) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4351) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4352) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4353) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4360) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4362) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4363) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4364) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4365) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4366) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4367) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) },
-       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4369) },
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4340) }, /* 88E8021 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4341) }, /* 88E8022 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4342) }, /* 88E8061 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4343) }, /* 88E8062 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4344) }, /* 88E8021 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4345) }, /* 88E8022 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4346) }, /* 88E8061 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4347) }, /* 88E8062 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4350) }, /* 88E8035 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4351) }, /* 88E8036 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4352) }, /* 88E8038 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4353) }, /* 88E8039 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4356) }, /* 88EC033 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4360) }, /* 88E8052 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) }, /* 88E8050 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4362) }, /* 88E8053 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4363) }, /* 88E8055 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4364) }, /* 88E8056 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4366) }, /* 88EC036 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4367) }, /* 88EC032 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, /* 88EC034 */
        { 0 }
 };
 
@@ -522,7 +521,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
                /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */
                ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) | PHY_M_LEDC_TX_CTRL;
                /* turn off the Rx LED (LED_RX) */
-               ledover |= PHY_M_LED_MO_RX(MO_LED_OFF);
+               ledover &= ~PHY_M_LED_MO_RX;
        }
 
        if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev == CHIP_REV_YU_EC_A1) {
@@ -545,7 +544,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
 
                if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) {
                        /* turn on 100 Mbps LED (LED_LINK100) */
-                       ledover |= PHY_M_LED_MO_100(MO_LED_ON);
+                       ledover |= PHY_M_LED_MO_100;
                }
 
                if (ledover)
@@ -697,10 +696,15 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
 
 }
 
-/* Assign Ram Buffer allocation in units of 64bit (8 bytes) */
-static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 end)
+/* Assign Ram Buffer allocation to queue */
+static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 space)
 {
-       pr_debug(PFX "q %d %#x %#x\n", q, start, end);
+       u32 end;
+
+       /* convert from K bytes to qwords used for hw register */
+       start *= 1024/8;
+       space *= 1024/8;
+       end = start + space - 1;
 
        sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR);
        sky2_write32(hw, RB_ADDR(q, RB_START), start);
@@ -709,7 +713,6 @@ static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 end)
        sky2_write32(hw, RB_ADDR(q, RB_RP), start);
 
        if (q == Q_R1 || q == Q_R2) {
-               u32 space = end - start + 1;
                u32 tp = space - space/4;
 
                /* On receive queue's set the thresholds
@@ -1059,11 +1062,16 @@ static int sky2_rx_start(struct sky2_port *sky2)
        sky2->rx_put = sky2->rx_next = 0;
        sky2_qset(hw, rxq);
 
+       /* On PCI express lowering the watermark gives better performance */
+       if (pci_find_capability(hw->pdev, PCI_CAP_ID_EXP))
+               sky2_write32(hw, Q_ADDR(rxq, Q_WM), BMU_WM_PEX);
+
+       /* These chips have no ram buffer?
+        * MAC Rx RAM Read is controlled by hardware */
        if (hw->chip_id == CHIP_ID_YUKON_EC_U &&
-           (hw->chip_rev == CHIP_REV_YU_EC_U_A1 || hw->chip_rev == CHIP_REV_YU_EC_U_B0)) {
-               /* MAC Rx RAM Read is controlled by hardware */
+           (hw->chip_rev == CHIP_REV_YU_EC_U_A1
+            || hw->chip_rev == CHIP_REV_YU_EC_U_B0))
                sky2_write32(hw, Q_ADDR(rxq, Q_F), F_M_RX_RAM_DIS);
-       }
 
        sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1);
 
@@ -1139,7 +1147,7 @@ static int sky2_up(struct net_device *dev)
        struct sky2_port *sky2 = netdev_priv(dev);
        struct sky2_hw *hw = sky2->hw;
        unsigned port = sky2->port;
-       u32 ramsize, rxspace, imask;
+       u32 ramsize, imask;
        int cap, err = -ENOMEM;
        struct net_device *otherdev = hw->dev[sky2->port^1];
 
@@ -1192,20 +1200,25 @@ static int sky2_up(struct net_device *dev)
 
        sky2_mac_init(hw, port);
 
-       /* Determine available ram buffer space in qwords.  */
-       ramsize = sky2_read8(hw, B2_E_0) * 4096/8;
+       /* Register is number of 4K blocks on internal RAM buffer. */
+       ramsize = sky2_read8(hw, B2_E_0) * 4;
+       printk(KERN_INFO PFX "%s: ram buffer %dK\n", dev->name, ramsize);
 
-       if (ramsize > 6*1024/8)
-               rxspace = ramsize - (ramsize + 2) / 3;
-       else
-               rxspace = ramsize / 2;
+       if (ramsize > 0) {
+               u32 rxspace;
 
-       sky2_ramset(hw, rxqaddr[port], 0, rxspace-1);
-       sky2_ramset(hw, txqaddr[port], rxspace, ramsize-1);
+               if (ramsize < 16)
+                       rxspace = ramsize / 2;
+               else
+                       rxspace = 8 + (2*(ramsize - 16))/3;
+
+               sky2_ramset(hw, rxqaddr[port], 0, rxspace);
+               sky2_ramset(hw, txqaddr[port], rxspace, ramsize - rxspace);
 
-       /* Make sure SyncQ is disabled */
-       sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL),
-                   RB_RST_SET);
+               /* Make sure SyncQ is disabled */
+               sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL),
+                           RB_RST_SET);
+       }
 
        sky2_qset(hw, txqaddr[port]);
 
@@ -2917,18 +2930,8 @@ static void sky2_led(struct sky2_hw *hw, unsigned port, int on)
 
        default:
                gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0);
-               gm_phy_write(hw, port, PHY_MARV_LED_OVER,
-                            on ? PHY_M_LED_MO_DUP(MO_LED_ON) |
-                            PHY_M_LED_MO_10(MO_LED_ON) |
-                            PHY_M_LED_MO_100(MO_LED_ON) |
-                            PHY_M_LED_MO_1000(MO_LED_ON) |
-                            PHY_M_LED_MO_RX(MO_LED_ON)
-                            : PHY_M_LED_MO_DUP(MO_LED_OFF) |
-                            PHY_M_LED_MO_10(MO_LED_OFF) |
-                            PHY_M_LED_MO_100(MO_LED_OFF) |
-                            PHY_M_LED_MO_1000(MO_LED_OFF) |
-                            PHY_M_LED_MO_RX(MO_LED_OFF));
-
+               gm_phy_write(hw, port, PHY_MARV_LED_OVER, 
+                            on ? PHY_M_LED_ALL : 0);
        }
 }
 
index 7760545edbf2ae8a95f7e9611e6f752bf70e8952..6ed1d47dbbd3452bfa0460fb6b92df67c8370f5f 100644 (file)
@@ -608,7 +608,7 @@ enum {
        PHY_ADDR_MARV   = 0,
 };
 
-#define RB_ADDR(offs, queue) (B16_RAM_REGS + (queue) + (offs))
+#define RB_ADDR(offs, queue) ((u16) B16_RAM_REGS + (queue) + (offs))
 
 
 enum {
@@ -680,6 +680,7 @@ enum {
                          BMU_FIFO_ENA | BMU_OP_ON,
 
        BMU_WM_DEFAULT = 0x600,
+       BMU_WM_PEX     = 0x80,
 };
 
 /* Tx BMU Control / Status Registers (Yukon-2) */
@@ -1060,7 +1061,7 @@ enum {
        PHY_M_PC_EN_DET_PLUS    = 3<<8, /* Energy Detect Plus (Mode 2) */
 };
 
-#define PHY_M_PC_MDI_XMODE(x)  (((x)<<5) & PHY_M_PC_MDIX_MSK)
+#define PHY_M_PC_MDI_XMODE(x)  (((u16)(x)<<5) & PHY_M_PC_MDIX_MSK)
 
 enum {
        PHY_M_PC_MAN_MDI        = 0, /* 00 = Manual MDI configuration */
@@ -1156,13 +1157,13 @@ enum {
        PHY_M_EC_TX_TIM_CT  = 1<<1, /* RGMII Tx Timing Control */
        PHY_M_EC_TRANS_DIS  = 1<<0, /* Transmitter Disable (88E1111 only) */};
 
-#define PHY_M_EC_M_DSC(x)      ((x)<<10 & PHY_M_EC_M_DSC_MSK)
+#define PHY_M_EC_M_DSC(x)      ((u16)(x)<<10 & PHY_M_EC_M_DSC_MSK)
                                        /* 00=1x; 01=2x; 10=3x; 11=4x */
-#define PHY_M_EC_S_DSC(x)      ((x)<<8 & PHY_M_EC_S_DSC_MSK)
+#define PHY_M_EC_S_DSC(x)      ((u16)(x)<<8 & PHY_M_EC_S_DSC_MSK)
                                        /* 00=dis; 01=1x; 10=2x; 11=3x */
-#define PHY_M_EC_DSC_2(x)      ((x)<<9 & PHY_M_EC_M_DSC_MSK2)
+#define PHY_M_EC_DSC_2(x)      ((u16)(x)<<9 & PHY_M_EC_M_DSC_MSK2)
                                        /* 000=1x; 001=2x; 010=3x; 011=4x */
-#define PHY_M_EC_MAC_S(x)      ((x)<<4 & PHY_M_EC_MAC_S_MSK)
+#define PHY_M_EC_MAC_S(x)      ((u16)(x)<<4 & PHY_M_EC_MAC_S_MSK)
                                        /* 01X=0; 110=2.5; 111=25 (MHz) */
 
 /* for Yukon-2 Gigabit Ethernet PHY (88E1112 only) */
@@ -1173,7 +1174,7 @@ enum {
 };
 /* !!! Errata in spec. (1 = disable) */
 
-#define PHY_M_PC_DSC(x)                        (((x)<<12) & PHY_M_PC_DSC_MSK)
+#define PHY_M_PC_DSC(x)                        (((u16)(x)<<12) & PHY_M_PC_DSC_MSK)
                                                                                        /* 100=5x; 101=6x; 110=7x; 111=8x */
 enum {
        MAC_TX_CLK_0_MHZ        = 2,
@@ -1203,7 +1204,7 @@ enum {
        PHY_M_LEDC_TX_C_MSB     = 1<<0, /* Tx Control (MSB, 88E1111 only) */
 };
 
-#define PHY_M_LED_PULS_DUR(x)  (((x)<<12) & PHY_M_LEDC_PULS_MSK)
+#define PHY_M_LED_PULS_DUR(x)  (((u16)(x)<<12) & PHY_M_LEDC_PULS_MSK)
 
 /*****  PHY_MARV_PHY_STAT (page 3)16 bit r/w   Polarity Control Reg. *****/
 enum {
@@ -1233,7 +1234,7 @@ enum {
        PULS_1300MS     = 7,/* 1.3 s to 2.7 s */
 };
 
-#define PHY_M_LED_BLINK_RT(x)  (((x)<<8) & PHY_M_LEDC_BL_R_MSK)
+#define PHY_M_LED_BLINK_RT(x)  (((u16)(x)<<8) & PHY_M_LEDC_BL_R_MSK)
 
 enum {
        BLINK_42MS      = 0,/* 42 ms */
@@ -1243,21 +1244,18 @@ enum {
        BLINK_670MS     = 4,/* 670 ms */
 };
 
-/*****  PHY_MARV_LED_OVER      16 bit r/w      Manual LED Override Reg *****/
-#define PHY_M_LED_MO_SGMII(x)  ((x)<<14) /* Bit 15..14:  SGMII AN Timer */
-                                                                               /* Bit 13..12:  reserved */
-#define PHY_M_LED_MO_DUP(x)    ((x)<<10) /* Bit 11..10:  Duplex */
-#define PHY_M_LED_MO_10(x)     ((x)<<8) /* Bit  9.. 8:  Link 10 */
-#define PHY_M_LED_MO_100(x)    ((x)<<6) /* Bit  7.. 6:  Link 100 */
-#define PHY_M_LED_MO_1000(x)   ((x)<<4) /* Bit  5.. 4:  Link 1000 */
-#define PHY_M_LED_MO_RX(x)     ((x)<<2) /* Bit  3.. 2:  Rx */
-#define PHY_M_LED_MO_TX(x)     ((x)<<0) /* Bit  1.. 0:  Tx */
-
+/**** PHY_MARV_LED_OVER    16 bit r/w LED control */
 enum {
-       MO_LED_NORM     = 0,
-       MO_LED_BLINK    = 1,
-       MO_LED_OFF      = 2,
-       MO_LED_ON       = 3,
+       PHY_M_LED_MO_DUP  = 3<<10,/* Bit 11..10:  Duplex */
+       PHY_M_LED_MO_10   = 3<<8, /* Bit  9.. 8:  Link 10 */
+       PHY_M_LED_MO_100  = 3<<6, /* Bit  7.. 6:  Link 100 */
+       PHY_M_LED_MO_1000 = 3<<4, /* Bit  5.. 4:  Link 1000 */
+       PHY_M_LED_MO_RX   = 3<<2, /* Bit  3.. 2:  Rx */
+       PHY_M_LED_MO_TX   = 3<<0, /* Bit  1.. 0:  Tx */
+
+       PHY_M_LED_ALL     = PHY_M_LED_MO_DUP | PHY_M_LED_MO_10 
+                           | PHY_M_LED_MO_100 | PHY_M_LED_MO_1000
+                           | PHY_M_LED_MO_RX,
 };
 
 /*****  PHY_MARV_EXT_CTRL_2    16 bit r/w      Ext. PHY Specific Ctrl 2 *****/
@@ -1294,9 +1292,9 @@ enum {
        PHY_M_FELP_LED0_MSK = 0xf, /* Bit  3.. 0: LED0 Mask (SPEED) */
 };
 
-#define PHY_M_FELP_LED2_CTRL(x)        (((x)<<8) & PHY_M_FELP_LED2_MSK)
-#define PHY_M_FELP_LED1_CTRL(x)        (((x)<<4) & PHY_M_FELP_LED1_MSK)
-#define PHY_M_FELP_LED0_CTRL(x)        (((x)<<0) & PHY_M_FELP_LED0_MSK)
+#define PHY_M_FELP_LED2_CTRL(x)        (((u16)(x)<<8) & PHY_M_FELP_LED2_MSK)
+#define PHY_M_FELP_LED1_CTRL(x)        (((u16)(x)<<4) & PHY_M_FELP_LED1_MSK)
+#define PHY_M_FELP_LED0_CTRL(x)        (((u16)(x)<<0) & PHY_M_FELP_LED0_MSK)
 
 enum {
        LED_PAR_CTRL_COLX       = 0x00,
@@ -1552,8 +1550,8 @@ enum {
        GM_SMI_CT_BUSY          = 1<<3, /* Bit  3:      Busy (Operation in progress) */
 };
 
-#define GM_SMI_CT_PHY_AD(x)    (((x)<<11) & GM_SMI_CT_PHY_A_MSK)
-#define GM_SMI_CT_REG_AD(x)    (((x)<<6) & GM_SMI_CT_REG_A_MSK)
+#define GM_SMI_CT_PHY_AD(x)    (((u16)(x)<<11) & GM_SMI_CT_PHY_A_MSK)
+#define GM_SMI_CT_REG_AD(x)    (((u16)(x)<<6) & GM_SMI_CT_REG_A_MSK)
 
 /*     GM_PHY_ADDR                             16 bit r/w      GPHY Address Register */
 enum {
index 889ef0d7c37499bba55e9f0e311dcf9dc1abdcec..d70bc979534669ba60eb49109ad73797bcb00cdd 100644 (file)
@@ -593,7 +593,7 @@ static void cleanup_card(struct net_device *dev)
        iounmap(ei_status.mem);
 }
 
-void
+void __exit
 cleanup_module(void)
 {
        int this_dev;
index e10755ec5defa321075923080dc05d586d499374..2c5319c62fa50c520f1762880b7cea57f15aef4d 100644 (file)
@@ -437,7 +437,7 @@ int __init init_module(void)
        return -ENXIO;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        int this_dev;
 
index c0d13d65091333555f118f5c16f386a955b500cf..bd6e84506c292d57064ddebd8ab105d25a318bb0 100644 (file)
@@ -1616,7 +1616,7 @@ int __init init_module(void)
        return 0;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        unregister_netdev(devSMC9194);
        free_irq(devSMC9194->irq, devSMC9194);
index a8640169fc77afede8c7f28376ccc8967b214668..9367c574477ad57d6c89b6f5d8141227eea0dd22 100644 (file)
@@ -238,7 +238,7 @@ SMC_outw(u16 val, void __iomem *ioaddr, int reg)
 #define SMC_CAN_USE_16BIT      1
 #define SMC_CAN_USE_32BIT      0
 
-#define SMC_inb(a, r)          inb((u32)a) + (r))
+#define SMC_inb(a, r)          inb(((u32)a) + (r))
 #define SMC_inw(a, r)          inw(((u32)a) + (r))
 #define SMC_outb(v, a, r)      outb(v, ((u32)a) + (r))
 #define SMC_outw(v, a, r)      outw(v, ((u32)a) + (r))
@@ -434,6 +434,24 @@ static inline void LPD7_SMC_outsw (unsigned char* a, int r,
 
 #define SMC_IRQ_FLAGS          (0)
 
+#elif  defined(CONFIG_ARCH_VERSATILE)
+
+#define SMC_CAN_USE_8BIT       1
+#define SMC_CAN_USE_16BIT      1
+#define SMC_CAN_USE_32BIT      1
+#define SMC_NOWAIT             1
+
+#define SMC_inb(a, r)          readb((a) + (r))
+#define SMC_inw(a, r)          readw((a) + (r))
+#define SMC_inl(a, r)          readl((a) + (r))
+#define SMC_outb(v, a, r)      writeb(v, (a) + (r))
+#define SMC_outw(v, a, r)      writew(v, (a) + (r))
+#define SMC_outl(v, a, r)      writel(v, (a) + (r))
+#define SMC_insl(a, r, p, l)   readsl((a) + (r), p, l)
+#define SMC_outsl(a, r, p, l)  writesl((a) + (r), p, l)
+
+#define SMC_IRQ_FLAGS          (0)
+
 #else
 
 #define SMC_CAN_USE_8BIT       1
@@ -1216,7 +1234,7 @@ static const char * chip_ids[ 16 ] =  {
                if (SMC_CAN_USE_32BIT) {                                \
                        void *__ptr = (p);                              \
                        int __len = (l);                                \
-                       void *__ioaddr = ioaddr;                        \
+                       void __iomem *__ioaddr = ioaddr;                \
                        if (__len >= 2 && (unsigned long)__ptr & 2) {   \
                                __len -= 2;                             \
                                SMC_outw(*(u16 *)__ptr, ioaddr, DATA_REG); \
@@ -1240,7 +1258,7 @@ static const char * chip_ids[ 16 ] =  {
                if (SMC_CAN_USE_32BIT) {                                \
                        void *__ptr = (p);                              \
                        int __len = (l);                                \
-                       void *__ioaddr = ioaddr;                        \
+                       void __iomem *__ioaddr = ioaddr;                \
                        if ((unsigned long)__ptr & 2) {                 \
                                /*                                      \
                                 * We want 32bit alignment here.        \
index 47a1c09d19acc98b43faba5d799170ef6d646a9a..c62e85d89f4173e78d0a4c9227463d865800f0a4 100644 (file)
@@ -945,7 +945,7 @@ static void set_multicast_list( struct net_device *dev )
 
 static struct net_device *sun3lance_dev;
 
-int init_module(void)
+int __init init_module(void)
 {
        sun3lance_dev = sun3lance_probe(-1);
        if (IS_ERR(sun3lance_dev))
@@ -953,7 +953,7 @@ int init_module(void)
        return 0;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        unregister_netdev(sun3lance_dev);
 #ifdef CONFIG_SUN3
index d9123c9adc1e347d796af84b87f5cd2487fc54fd..571320ae87abf4ca106767846b9a57657c1366fd 100644 (file)
@@ -68,8 +68,8 @@
 
 #define DRV_MODULE_NAME                "tg3"
 #define PFX DRV_MODULE_NAME    ": "
-#define DRV_MODULE_VERSION     "3.69"
-#define DRV_MODULE_RELDATE     "November 15, 2006"
+#define DRV_MODULE_VERSION     "3.70"
+#define DRV_MODULE_RELDATE     "December 1, 2006"
 
 #define TG3_DEF_MAC_MODE       0
 #define TG3_DEF_RX_MODE                0
@@ -192,6 +192,7 @@ static struct pci_device_id tg3_pci_tbl[] = {
        {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5786)},
        {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787)},
        {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787M)},
+       {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787F)},
        {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5714)},
        {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5714S)},
        {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5715)},
@@ -1061,7 +1062,7 @@ static void tg3_frob_aux_power(struct tg3 *tp)
 {
        struct tg3 *tp_peer = tp;
 
-       if ((tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) != 0)
+       if ((tp->tg3_flags2 & TG3_FLG2_IS_NIC) == 0)
                return;
 
        if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
@@ -1212,8 +1213,8 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
                                      power_control);
                udelay(100);    /* Delay after power state change */
 
-               /* Switch out of Vaux if it is not a LOM */
-               if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT))
+               /* Switch out of Vaux if it is a NIC */
+               if (tp->tg3_flags2 & TG3_FLG2_IS_NIC)
                        tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl, 100);
 
                return 0;
@@ -1401,8 +1402,10 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
 static void tg3_link_report(struct tg3 *tp)
 {
        if (!netif_carrier_ok(tp->dev)) {
-               printk(KERN_INFO PFX "%s: Link is down.\n", tp->dev->name);
-       } else {
+               if (netif_msg_link(tp))
+                       printk(KERN_INFO PFX "%s: Link is down.\n",
+                              tp->dev->name);
+       } else if (netif_msg_link(tp)) {
                printk(KERN_INFO PFX "%s: Link is up at %d Mbps, %s duplex.\n",
                       tp->dev->name,
                       (tp->link_config.active_speed == SPEED_1000 ?
@@ -1557,12 +1560,6 @@ static void tg3_phy_copper_begin(struct tg3 *tp)
 
                tg3_writephy(tp, MII_ADVERTISE, new_adv);
        } else if (tp->link_config.speed == SPEED_INVALID) {
-               tp->link_config.advertising =
-                       (ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
-                        ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
-                        ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full |
-                        ADVERTISED_Autoneg | ADVERTISED_MII);
-
                if (tp->tg3_flags & TG3_FLAG_10_100_ONLY)
                        tp->link_config.advertising &=
                                ~(ADVERTISED_1000baseT_Half |
@@ -1706,25 +1703,36 @@ static int tg3_init_5401phy_dsp(struct tg3 *tp)
        return err;
 }
 
-static int tg3_copper_is_advertising_all(struct tg3 *tp)
+static int tg3_copper_is_advertising_all(struct tg3 *tp, u32 mask)
 {
-       u32 adv_reg, all_mask;
+       u32 adv_reg, all_mask = 0;
+
+       if (mask & ADVERTISED_10baseT_Half)
+               all_mask |= ADVERTISE_10HALF;
+       if (mask & ADVERTISED_10baseT_Full)
+               all_mask |= ADVERTISE_10FULL;
+       if (mask & ADVERTISED_100baseT_Half)
+               all_mask |= ADVERTISE_100HALF;
+       if (mask & ADVERTISED_100baseT_Full)
+               all_mask |= ADVERTISE_100FULL;
 
        if (tg3_readphy(tp, MII_ADVERTISE, &adv_reg))
                return 0;
 
-       all_mask = (ADVERTISE_10HALF | ADVERTISE_10FULL |
-                   ADVERTISE_100HALF | ADVERTISE_100FULL);
        if ((adv_reg & all_mask) != all_mask)
                return 0;
        if (!(tp->tg3_flags & TG3_FLAG_10_100_ONLY)) {
                u32 tg3_ctrl;
 
+               all_mask = 0;
+               if (mask & ADVERTISED_1000baseT_Half)
+                       all_mask |= ADVERTISE_1000HALF;
+               if (mask & ADVERTISED_1000baseT_Full)
+                       all_mask |= ADVERTISE_1000FULL;
+
                if (tg3_readphy(tp, MII_TG3_CTRL, &tg3_ctrl))
                        return 0;
 
-               all_mask = (MII_TG3_CTRL_ADV_1000_HALF |
-                           MII_TG3_CTRL_ADV_1000_FULL);
                if ((tg3_ctrl & all_mask) != all_mask)
                        return 0;
        }
@@ -1884,7 +1892,8 @@ static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset)
                                /* Force autoneg restart if we are exiting
                                 * low power mode.
                                 */
-                               if (!tg3_copper_is_advertising_all(tp))
+                               if (!tg3_copper_is_advertising_all(tp,
+                                               tp->link_config.advertising))
                                        current_link_up = 0;
                        } else {
                                current_link_up = 0;
@@ -3703,8 +3712,9 @@ static void tg3_tx_timeout(struct net_device *dev)
 {
        struct tg3 *tp = netdev_priv(dev);
 
-       printk(KERN_ERR PFX "%s: transmit timed out, resetting\n",
-              dev->name);
+       if (netif_msg_tx_err(tp))
+               printk(KERN_ERR PFX "%s: transmit timed out, resetting\n",
+                      dev->name);
 
        schedule_work(&tp->reset_task);
 }
@@ -6396,16 +6406,17 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
        udelay(40);
 
        /* tp->grc_local_ctrl is partially set up during tg3_get_invariants().
-        * If TG3_FLAG_EEPROM_WRITE_PROT is set, we should read the
+        * If TG3_FLG2_IS_NIC is zero, we should read the
         * register to preserve the GPIO settings for LOMs. The GPIOs,
         * whether used as inputs or outputs, are set by boot code after
         * reset.
         */
-       if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) {
+       if (!(tp->tg3_flags2 & TG3_FLG2_IS_NIC)) {
                u32 gpio_mask;
 
-               gpio_mask = GRC_LCLCTRL_GPIO_OE0 | GRC_LCLCTRL_GPIO_OE2 |
-                           GRC_LCLCTRL_GPIO_OUTPUT0 | GRC_LCLCTRL_GPIO_OUTPUT2;
+               gpio_mask = GRC_LCLCTRL_GPIO_OE0 | GRC_LCLCTRL_GPIO_OE1 |
+                           GRC_LCLCTRL_GPIO_OE2 | GRC_LCLCTRL_GPIO_OUTPUT0 |
+                           GRC_LCLCTRL_GPIO_OUTPUT1 | GRC_LCLCTRL_GPIO_OUTPUT2;
 
                if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
                        gpio_mask |= GRC_LCLCTRL_GPIO_OE3 |
@@ -6417,8 +6428,9 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
                tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask;
 
                /* GPIO1 must be driven high for eeprom write protect */
-               tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 |
-                                      GRC_LCLCTRL_GPIO_OUTPUT1);
+               if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT)
+                       tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 |
+                                              GRC_LCLCTRL_GPIO_OUTPUT1);
        }
        tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
        udelay(100);
@@ -8656,7 +8668,9 @@ static int tg3_test_registers(struct tg3 *tp)
        return 0;
 
 out:
-       printk(KERN_ERR PFX "Register test failed at offset %x\n", offset);
+       if (netif_msg_hw(tp))
+               printk(KERN_ERR PFX "Register test failed at offset %x\n",
+                      offset);
        tw32(offset, save_val);
        return -EIO;
 }
@@ -8781,17 +8795,20 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode)
                                        tg3_writephy(tp, 0x10, phy & ~0x4000);
                                tg3_writephy(tp, MII_TG3_EPHY_TEST, phytest);
                        }
-               }
-               val = BMCR_LOOPBACK | BMCR_FULLDPLX;
-               if (tp->tg3_flags & TG3_FLAG_10_100_ONLY)
-                       val |= BMCR_SPEED100;
-               else
-                       val |= BMCR_SPEED1000;
+                       val = BMCR_LOOPBACK | BMCR_FULLDPLX | BMCR_SPEED100;
+               } else
+                       val = BMCR_LOOPBACK | BMCR_FULLDPLX | BMCR_SPEED1000;
 
                tg3_writephy(tp, MII_BMCR, val);
                udelay(40);
-               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906)
+
+               mac_mode = (tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK) |
+                          MAC_MODE_LINK_POLARITY;
+               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
                        tg3_writephy(tp, MII_TG3_EPHY_PTEST, 0x1800);
+                       mac_mode |= MAC_MODE_PORT_MODE_MII;
+               } else
+                       mac_mode |= MAC_MODE_PORT_MODE_GMII;
 
                /* reset to prevent losing 1st rx packet intermittently */
                if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES) {
@@ -8799,12 +8816,6 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode)
                        udelay(10);
                        tw32_f(MAC_RX_MODE, tp->rx_mode);
                }
-               mac_mode = (tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK) |
-                          MAC_MODE_LINK_POLARITY;
-               if (tp->tg3_flags & TG3_FLAG_10_100_ONLY)
-                       mac_mode |= MAC_MODE_PORT_MODE_MII;
-               else
-                       mac_mode |= MAC_MODE_PORT_MODE_GMII;
                if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) {
                        mac_mode &= ~MAC_MODE_LINK_POLARITY;
                        tg3_writephy(tp, MII_TG3_EXT_CTRL,
@@ -9456,16 +9467,12 @@ static void __devinit tg3_get_5906_nvram_info(struct tg3 *tp)
 /* Chips other than 5700/5701 use the NVRAM for fetching info. */
 static void __devinit tg3_nvram_init(struct tg3 *tp)
 {
-       int j;
-
        tw32_f(GRC_EEPROM_ADDR,
             (EEPROM_ADDR_FSM_RESET |
              (EEPROM_DEFAULT_CLOCK_PERIOD <<
               EEPROM_ADDR_CLKPERD_SHIFT)));
 
-       /* XXX schedule_timeout() ... */
-       for (j = 0; j < 100; j++)
-               udelay(10);
+       msleep(1);
 
        /* Enable seeprom accesses. */
        tw32_f(GRC_LOCAL_CTRL,
@@ -9526,12 +9533,12 @@ static int tg3_nvram_read_using_eeprom(struct tg3 *tp,
              EEPROM_ADDR_ADDR_MASK) |
             EEPROM_ADDR_READ | EEPROM_ADDR_START);
 
-       for (i = 0; i < 10000; i++) {
+       for (i = 0; i < 1000; i++) {
                tmp = tr32(GRC_EEPROM_ADDR);
 
                if (tmp & EEPROM_ADDR_COMPLETE)
                        break;
-               udelay(100);
+               msleep(1);
        }
        if (!(tmp & EEPROM_ADDR_COMPLETE))
                return -EBUSY;
@@ -9656,12 +9663,12 @@ static int tg3_nvram_write_block_using_eeprom(struct tg3 *tp,
                        EEPROM_ADDR_START |
                        EEPROM_ADDR_WRITE);
 
-               for (j = 0; j < 10000; j++) {
+               for (j = 0; j < 1000; j++) {
                        val = tr32(GRC_EEPROM_ADDR);
 
                        if (val & EEPROM_ADDR_COMPLETE)
                                break;
-                       udelay(100);
+                       msleep(1);
                }
                if (!(val & EEPROM_ADDR_COMPLETE)) {
                        rc = -EBUSY;
@@ -9965,8 +9972,10 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
        tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
 
        if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
-               if (!(tr32(PCIE_TRANSACTION_CFG) & PCIE_TRANS_CFG_LOM))
+               if (!(tr32(PCIE_TRANSACTION_CFG) & PCIE_TRANS_CFG_LOM)) {
                        tp->tg3_flags &= ~TG3_FLAG_EEPROM_WRITE_PROT;
+                       tp->tg3_flags2 |= TG3_FLG2_IS_NIC;
+               }
                return;
        }
 
@@ -10066,10 +10075,17 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
                    tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL)
                        tp->led_ctrl = LED_CTRL_MODE_PHY_2;
 
-               if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP)
+               if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP) {
                        tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
-               else
+                       if ((tp->pdev->subsystem_vendor ==
+                            PCI_VENDOR_ID_ARIMA) &&
+                           (tp->pdev->subsystem_device == 0x205a ||
+                            tp->pdev->subsystem_device == 0x2063))
+                               tp->tg3_flags &= ~TG3_FLAG_EEPROM_WRITE_PROT;
+               } else {
                        tp->tg3_flags &= ~TG3_FLAG_EEPROM_WRITE_PROT;
+                       tp->tg3_flags2 |= TG3_FLG2_IS_NIC;
+               }
 
                if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) {
                        tp->tg3_flags |= TG3_FLAG_ENABLE_ASF;
@@ -10147,7 +10163,7 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
 
        if (!(tp->tg3_flags2 & TG3_FLG2_ANY_SERDES) &&
            !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) {
-               u32 bmsr, adv_reg, tg3_ctrl;
+               u32 bmsr, adv_reg, tg3_ctrl, mask;
 
                tg3_readphy(tp, MII_BMSR, &bmsr);
                if (!tg3_readphy(tp, MII_BMSR, &bmsr) &&
@@ -10171,7 +10187,10 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
                                             MII_TG3_CTRL_ENABLE_AS_MASTER);
                }
 
-               if (!tg3_copper_is_advertising_all(tp)) {
+               mask = (ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
+                       ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
+                       ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full);
+               if (!tg3_copper_is_advertising_all(tp, mask)) {
                        tg3_writephy(tp, MII_ADVERTISE, adv_reg);
 
                        if (!(tp->tg3_flags & TG3_FLAG_10_100_ONLY))
@@ -10695,7 +10714,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
                tp->tg3_flags |= TG3_FLAG_SRAM_USE_CONFIG;
 
        /* Get eeprom hw config before calling tg3_set_power_state().
-        * In particular, the TG3_FLAG_EEPROM_WRITE_PROT flag must be
+        * In particular, the TG3_FLG2_IS_NIC flag must be
         * determined before calling tg3_set_power_state() so that
         * we know whether or not to switch out of Vaux power.
         * When the flag is set, it means that GPIO1 is used for eeprom
@@ -10862,7 +10881,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
              tp->pdev->device == PCI_DEVICE_ID_TIGON3_5705F)) ||
            (tp->pdev->vendor == PCI_VENDOR_ID_BROADCOM &&
             (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5751F ||
-             tp->pdev->device == PCI_DEVICE_ID_TIGON3_5753F)) ||
+             tp->pdev->device == PCI_DEVICE_ID_TIGON3_5753F ||
+             tp->pdev->device == PCI_DEVICE_ID_TIGON3_5787F)) ||
            GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906)
                tp->tg3_flags |= TG3_FLAG_10_100_ONLY;
 
@@ -11912,13 +11932,15 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
 
        pci_set_drvdata(pdev, dev);
 
-       printk(KERN_INFO "%s: Tigon3 [partno(%s) rev %04x PHY(%s)] (%s) %sBaseT Ethernet ",
+       printk(KERN_INFO "%s: Tigon3 [partno(%s) rev %04x PHY(%s)] (%s) %s Ethernet ",
               dev->name,
               tp->board_part_number,
               tp->pci_chip_rev_id,
               tg3_phy_string(tp),
               tg3_bus_string(tp, str),
-              (tp->tg3_flags & TG3_FLAG_10_100_ONLY) ? "10/100" : "10/100/1000");
+              ((tp->tg3_flags & TG3_FLAG_10_100_ONLY) ? "10/100Base-TX" :
+               ((tp->tg3_flags2 & TG3_FLG2_ANY_SERDES) ? "1000Base-SX" :
+                "10/100/1000Base-T")));
 
        for (i = 0; i < 6; i++)
                printk("%2.2x%c", dev->dev_addr[i],
index 92f53000bce69f2895dad2183ac37013de7e58cb..dfaf4ed127bd712378168eb1b64b82b4bd5f39ef 100644 (file)
@@ -2233,6 +2233,7 @@ struct tg3 {
 #define TG3_FLG2_PCI_EXPRESS           0x00000200
 #define TG3_FLG2_ASF_NEW_HANDSHAKE     0x00000400
 #define TG3_FLG2_HW_AUTONEG            0x00000800
+#define TG3_FLG2_IS_NIC                        0x00001000
 #define TG3_FLG2_PHY_SERDES            0x00002000
 #define TG3_FLG2_CAPACITIVE_COUPLING   0x00004000
 #define TG3_FLG2_FLASH                 0x00008000
index 46dabdb120716cf2bc2a0422b58e168b555edb99..cec282a6f62d40b7ded07994bff8e3e729503227 100644 (file)
@@ -5706,7 +5706,7 @@ int __init init_module(void)
         return found ? 0 : -ENODEV;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
         int i;
 
index 74f894795a1b5ed154d8821b1a16ecb44d5124eb..4587f23f4e4b4aa95ba7e2c9e019ae8c9066161b 100644 (file)
@@ -3132,7 +3132,7 @@ static u16 wol_calc_crc(int size, u8 * pattern, u8 *mask_pattern)
        }
        /*      Finally, invert the result once to get the correct data */
        crc = ~crc;
-       return bitreverse(crc) >> 16;
+       return bitrev32(crc) >> 16;
 }
 
 /**
index e1bf8b93f9584e624315ce79144db11599ee6bb8..6c7dfb50143f7247a0f11fa2422b5b46e08c4417 100644 (file)
@@ -974,12 +974,12 @@ static int cosa_open(struct inode *inode, struct file *file)
        unsigned long flags;
        int n;
 
-       if ((n=iminor(file->f_dentry->d_inode)>>CARD_MINOR_BITS)
+       if ((n=iminor(file->f_path.dentry->d_inode)>>CARD_MINOR_BITS)
                >= nr_cards)
                return -ENODEV;
        cosa = cosa_cards+n;
 
-       if ((n=iminor(file->f_dentry->d_inode)
+       if ((n=iminor(file->f_path.dentry->d_inode)
                & ((1<<CARD_MINOR_BITS)-1)) >= cosa->nchannels)
                return -ENODEV;
        chan = cosa->chan + n;
index 41f1d6778849b99f520f8f36da76770c6d08437a..7f38012b9c92e2ddb094f3c53240c90850744563 100644 (file)
@@ -538,7 +538,7 @@ static void cleanup_card(struct net_device *dev)
        iounmap(ei_status.mem);
 }
 
-void
+void __exit
 cleanup_module(void)
 {
        int this_dev;
index efcdaf1c5f735fd7b5619a2c39ae221b6e0708f4..44a22701da9734df0155a7323cc574ee6752c071 100644 (file)
@@ -49,6 +49,7 @@
 #include <asm/uaccess.h>
 #include <net/ieee80211.h>
 #include <linux/kthread.h>
+#include <linux/freezer.h>
 
 #include "airo.h"
 
index 08bc57a4b895f8edc11b3fa2bf1759c99304b9e8..974a8e5bec8b493b6061a6433fa02fabdf5d1094 100644 (file)
@@ -1100,15 +1100,13 @@ static struct sta_info * ap_add_sta(struct ap_data *ap, u8 *addr)
 {
        struct sta_info *sta;
 
-       sta = (struct sta_info *)
-               kmalloc(sizeof(struct sta_info), GFP_ATOMIC);
+       sta = kzalloc(sizeof(struct sta_info), GFP_ATOMIC);
        if (sta == NULL) {
                PDEBUG(DEBUG_AP, "AP: kmalloc failed\n");
                return NULL;
        }
 
        /* initialize STA info data */
-       memset(sta, 0, sizeof(struct sta_info));
        sta->local = ap->local;
        skb_queue_head_init(&sta->tx_buf);
        memcpy(sta->addr, addr, ETH_ALEN);
index ee542ec6d6a8cd03d97cd0d8f8fdb985c0327275..8d8f4b9b8b07a032ef3c04ac1b928ca4187c289e 100644 (file)
@@ -563,12 +563,11 @@ static int prism2_config(struct pcmcia_device *link)
        PDEBUG(DEBUG_FLOW, "prism2_config()\n");
 
        parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
-       hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
+       hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
        if (parse == NULL || hw_priv == NULL) {
                ret = -ENOMEM;
                goto failed;
        }
-       memset(hw_priv, 0, sizeof(*hw_priv));
 
        tuple.Attributes = 0;
        tuple.TupleData = buf;
index ab26b52b3e768ef1f270735c0d9782fbed8babe6..24fc387bba6753255caee927c78352a6bcc2a2fc 100644 (file)
@@ -685,14 +685,12 @@ static int prism2_download(local_info_t *local,
                goto out;
        }
 
-       dl = kmalloc(sizeof(*dl) + param->num_areas *
+       dl = kzalloc(sizeof(*dl) + param->num_areas *
                     sizeof(struct prism2_download_data_area), GFP_KERNEL);
        if (dl == NULL) {
                ret = -ENOMEM;
                goto out;
        }
-       memset(dl, 0, sizeof(*dl) + param->num_areas *
-              sizeof(struct prism2_download_data_area));
        dl->dl_cmd = param->dl_cmd;
        dl->start_addr = param->start_addr;
        dl->num_areas = param->num_areas;
index c19e68636a1c89a2edf6dc5472a0386003bb0e0f..a394a23b9a20090ae54922a774725d2848cdd332 100644 (file)
@@ -347,14 +347,12 @@ static int hfa384x_cmd(struct net_device *dev, u16 cmd, u16 param0,
        if (signal_pending(current))
                return -EINTR;
 
-       entry = (struct hostap_cmd_queue *)
-               kmalloc(sizeof(*entry), GFP_ATOMIC);
+       entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
        if (entry == NULL) {
                printk(KERN_DEBUG "%s: hfa384x_cmd - kmalloc failed\n",
                       dev->name);
                return -ENOMEM;
        }
-       memset(entry, 0, sizeof(*entry));
        atomic_set(&entry->usecnt, 1);
        entry->type = CMD_SLEEP;
        entry->cmd = cmd;
@@ -517,14 +515,12 @@ static int hfa384x_cmd_callback(struct net_device *dev, u16 cmd, u16 param0,
                return -1;
        }
 
-       entry = (struct hostap_cmd_queue *)
-               kmalloc(sizeof(*entry), GFP_ATOMIC);
+       entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
        if (entry == NULL) {
                printk(KERN_DEBUG "%s: hfa384x_cmd_callback - kmalloc "
                       "failed\n", dev->name);
                return -ENOMEM;
        }
-       memset(entry, 0, sizeof(*entry));
        atomic_set(&entry->usecnt, 1);
        entry->type = CMD_CALLBACK;
        entry->cmd = cmd;
@@ -3016,14 +3012,12 @@ static int prism2_set_tim(struct net_device *dev, int aid, int set)
        iface = netdev_priv(dev);
        local = iface->local;
 
-       new_entry = (struct set_tim_data *)
-               kmalloc(sizeof(*new_entry), GFP_ATOMIC);
+       new_entry = kzalloc(sizeof(*new_entry), GFP_ATOMIC);
        if (new_entry == NULL) {
                printk(KERN_DEBUG "%s: prism2_set_tim: kmalloc failed\n",
                       local->dev->name);
                return -ENOMEM;
        }
-       memset(new_entry, 0, sizeof(*new_entry));
        new_entry->aid = aid;
        new_entry->set = set;
 
index 5fd2b1ad7f5eac6da3a81dcf466f14c65dbbf87a..b6a02a02da74e645287aa943ea3cfc57d21b53a9 100644 (file)
@@ -327,11 +327,10 @@ static void prism2_info_hostscanresults(local_info_t *local,
        ptr = (u8 *) pos;
 
        new_count = left / result_size;
-       results = kmalloc(new_count * sizeof(struct hfa384x_hostscan_result),
+       results = kcalloc(new_count, sizeof(struct hfa384x_hostscan_result),
                          GFP_ATOMIC);
        if (results == NULL)
                return;
-       memset(results, 0, new_count * sizeof(struct hfa384x_hostscan_result));
 
        for (i = 0; i < new_count; i++) {
                memcpy(&results[i], ptr, copy_len);
index d061fb3443ff9ea614af960986adcc44930f2794..3b7b8063ff1c7803eb18fb3ba48039ee5c65077f 100644 (file)
@@ -181,12 +181,10 @@ static int prism2_ioctl_siwencode(struct net_device *dev,
                struct ieee80211_crypt_data *new_crypt;
 
                /* take WEP into use */
-               new_crypt = (struct ieee80211_crypt_data *)
-                       kmalloc(sizeof(struct ieee80211_crypt_data),
+               new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
                                GFP_KERNEL);
                if (new_crypt == NULL)
                        return -ENOMEM;
-               memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
                new_crypt->ops = ieee80211_get_crypto_ops("WEP");
                if (!new_crypt->ops) {
                        request_module("ieee80211_crypt_wep");
@@ -3320,14 +3318,12 @@ static int prism2_ioctl_siwencodeext(struct net_device *dev,
 
                prism2_crypt_delayed_deinit(local, crypt);
 
-               new_crypt = (struct ieee80211_crypt_data *)
-                       kmalloc(sizeof(struct ieee80211_crypt_data),
+               new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
                                GFP_KERNEL);
                if (new_crypt == NULL) {
                        ret = -ENOMEM;
                        goto done;
                }
-               memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
                new_crypt->ops = ops;
                new_crypt->priv = new_crypt->ops->init(i);
                if (new_crypt->priv == NULL) {
@@ -3538,14 +3534,12 @@ static int prism2_ioctl_set_encryption(local_info_t *local,
 
                prism2_crypt_delayed_deinit(local, crypt);
 
-               new_crypt = (struct ieee80211_crypt_data *)
-                       kmalloc(sizeof(struct ieee80211_crypt_data),
+               new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
                                GFP_KERNEL);
                if (new_crypt == NULL) {
                        ret = -ENOMEM;
                        goto done;
                }
-               memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
                new_crypt->ops = ops;
                new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx);
                if (new_crypt->priv == NULL) {
index d1de9766c831f6059ff8aafa95bd541b25af5fe7..c4f6020baa9ee7d12bde7e27ab3aebac4bc9f842 100644 (file)
@@ -300,10 +300,9 @@ static int prism2_pci_probe(struct pci_dev *pdev,
        struct hostap_interface *iface;
        struct hostap_pci_priv *hw_priv;
 
-       hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
+       hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
        if (hw_priv == NULL)
                return -ENOMEM;
-       memset(hw_priv, 0, sizeof(*hw_priv));
 
        if (pci_enable_device(pdev))
                goto err_out_free;
index bc81b13a5a2a95a5bce76816c5ca31f0e8373092..e235e06478970d2e240986be13e96930981942db 100644 (file)
@@ -447,10 +447,9 @@ static int prism2_plx_probe(struct pci_dev *pdev,
        int tmd7160;
        struct hostap_plx_priv *hw_priv;
 
-       hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
+       hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
        if (hw_priv == NULL)
                return -ENOMEM;
-       memset(hw_priv, 0, sizeof(*hw_priv));
 
        if (pci_enable_device(pdev))
                goto err_out_free;
index 1bcd352a813bc24e71284a09f877cd66451d031d..dd9ba4aad7bb402b080518351f87db32da015f83 100644 (file)
@@ -6220,7 +6220,7 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
        /* Allocate and initialize the Tx/Rx queues and lists */
        if (ipw2100_queues_allocate(priv)) {
                printk(KERN_WARNING DRV_NAME
-                      "Error calilng ipw2100_queues_allocate.\n");
+                      "Error calling ipw2100_queues_allocate.\n");
                err = -ENOMEM;
                goto fail;
        }
index e82e56bb85e14071859055624c6ee53018294d04..22cb3fb7502e280a16a4d5e73f95bb42482ead3a 100644 (file)
@@ -70,7 +70,7 @@
 #define VQ
 #endif
 
-#define IPW2200_VERSION "1.1.4" VK VD VM VP VR VQ
+#define IPW2200_VERSION "1.2.0" VK VD VM VP VR VQ
 #define DRV_DESCRIPTION        "Intel(R) PRO/Wireless 2200/2915 Network Driver"
 #define DRV_COPYRIGHT  "Copyright(c) 2003-2006 Intel Corporation"
 #define DRV_VERSION     IPW2200_VERSION
@@ -7677,7 +7677,8 @@ static void ipw_handle_data_packet_monitor(struct ipw_priv *priv,
 
        /* Big bitfield of all the fields we provide in radiotap */
        ipw_rt->rt_hdr.it_present =
-           ((1 << IEEE80211_RADIOTAP_FLAGS) |
+           ((1 << IEEE80211_RADIOTAP_TSFT) |
+            (1 << IEEE80211_RADIOTAP_FLAGS) |
             (1 << IEEE80211_RADIOTAP_RATE) |
             (1 << IEEE80211_RADIOTAP_CHANNEL) |
             (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |
@@ -7686,10 +7687,14 @@ static void ipw_handle_data_packet_monitor(struct ipw_priv *priv,
 
        /* Zero the flags, we'll add to them as we go */
        ipw_rt->rt_flags = 0;
-       ipw_rt->rt_tsf = 0ULL;
+       ipw_rt->rt_tsf = (u64)(frame->parent_tsf[3] << 24 |
+                              frame->parent_tsf[2] << 16 |
+                              frame->parent_tsf[1] << 8  |
+                              frame->parent_tsf[0]);
 
        /* Convert signal to DBM */
        ipw_rt->rt_dbmsignal = antsignal;
+       ipw_rt->rt_dbmnoise = frame->noise;
 
        /* Convert the channel data and set the flags */
        ipw_rt->rt_channel = cpu_to_le16(ieee80211chan2mhz(received_channel));
@@ -7889,7 +7894,8 @@ static void ipw_handle_promiscuous_rx(struct ipw_priv *priv,
 
        /* Big bitfield of all the fields we provide in radiotap */
        ipw_rt->rt_hdr.it_present =
-           ((1 << IEEE80211_RADIOTAP_FLAGS) |
+           ((1 << IEEE80211_RADIOTAP_TSFT) |
+            (1 << IEEE80211_RADIOTAP_FLAGS) |
             (1 << IEEE80211_RADIOTAP_RATE) |
             (1 << IEEE80211_RADIOTAP_CHANNEL) |
             (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |
@@ -7898,7 +7904,10 @@ static void ipw_handle_promiscuous_rx(struct ipw_priv *priv,
 
        /* Zero the flags, we'll add to them as we go */
        ipw_rt->rt_flags = 0;
-       ipw_rt->rt_tsf = 0ULL;
+       ipw_rt->rt_tsf = (u64)(frame->parent_tsf[3] << 24 |
+                              frame->parent_tsf[2] << 16 |
+                              frame->parent_tsf[1] << 8  |
+                              frame->parent_tsf[0]);
 
        /* Convert to DBM */
        ipw_rt->rt_dbmsignal = signal;
@@ -8297,7 +8306,7 @@ static void ipw_rx(struct ipw_priv *priv)
                                    ("Notification: subtype=%02X flags=%02X size=%d\n",
                                     pkt->u.notification.subtype,
                                     pkt->u.notification.flags,
-                                    pkt->u.notification.size);
+                                    le16_to_cpu(pkt->u.notification.size));
                                ipw_rx_notification(priv, &pkt->u.notification);
                                break;
                        }
@@ -11145,14 +11154,13 @@ static int ipw_up(struct ipw_priv *priv)
                return -EIO;
 
        if (cmdlog && !priv->cmdlog) {
-               priv->cmdlog = kmalloc(sizeof(*priv->cmdlog) * cmdlog,
+               priv->cmdlog = kcalloc(cmdlog, sizeof(*priv->cmdlog),
                                       GFP_KERNEL);
                if (priv->cmdlog == NULL) {
                        IPW_ERROR("Error allocating %d command log entries.\n",
                                  cmdlog);
                        return -ENOMEM;
                } else {
-                       memset(priv->cmdlog, 0, sizeof(*priv->cmdlog) * cmdlog);
                        priv->cmdlog_len = cmdlog;
                }
        }
index a87eb51886c89e3d5122a20ace2506897bbbbd23..96606ed100761bca80fc5a04524f2b5fc0868959 100644 (file)
@@ -2141,11 +2141,9 @@ prism54_wpa_bss_ie_add(islpci_private *priv, u8 *bssid,
                                         struct islpci_bss_wpa_ie, list);
                        list_del(&bss->list);
                } else {
-                       bss = kmalloc(sizeof (*bss), GFP_ATOMIC);
-                       if (bss != NULL) {
+                       bss = kzalloc(sizeof (*bss), GFP_ATOMIC);
+                       if (bss != NULL)
                                priv->num_bss_wpa++;
-                               memset(bss, 0, sizeof (*bss));
-                       }
                }
                if (bss != NULL) {
                        memcpy(bss->bssid, bssid, ETH_ALEN);
@@ -2686,11 +2684,10 @@ prism2_ioctl_set_generic_element(struct net_device *ndev,
                return -EINVAL;
 
        alen = sizeof(*attach) + len;
-       attach = kmalloc(alen, GFP_KERNEL);
+       attach = kzalloc(alen, GFP_KERNEL);
        if (attach == NULL)
                return -ENOMEM;
 
-       memset(attach, 0, alen);
 #define WLAN_FC_TYPE_MGMT 0
 #define WLAN_FC_STYPE_ASSOC_REQ 0
 #define WLAN_FC_STYPE_REASSOC_REQ 2
index fbc52b6a30247f100d500daed5add811248de452..e6cf9df2c20655699618bd3f18595a99862772e3 100644 (file)
@@ -235,12 +235,10 @@ mgt_init(islpci_private *priv)
 {
        int i;
 
-       priv->mib = kmalloc(OID_NUM_LAST * sizeof (void *), GFP_KERNEL);
+       priv->mib = kcalloc(OID_NUM_LAST, sizeof (void *), GFP_KERNEL);
        if (!priv->mib)
                return -ENOMEM;
 
-       memset(priv->mib, 0, OID_NUM_LAST * sizeof (void *));
-
        /* Alloc the cache */
        for (i = 0; i < OID_NUM_LAST; i++) {
                if (isl_oid[i].flags & OID_FLAG_CACHED) {
index 337c692f6fd66e98ba057cc46fc38b9a7e5fdad0..ce3a8bac66ffb55d6d145b544d1b46e133caeaf6 100644 (file)
@@ -798,7 +798,7 @@ static unsigned int get_baud(struct tty_struct *tty)
  */
 static void set_baud(struct tty_struct *tty, unsigned int baudcode)
 {
-       struct termios old_termios = *(tty->termios);
+       struct ktermios 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);
index 8be99ebbe1cd9bfbc87a0e38cbafb1c078951318..77e11ddad836d135f444d53f567262686d408c96 100644 (file)
@@ -1673,3 +1673,16 @@ int zd_rfwritev_cr_locked(struct zd_chip *chip,
 
        return 0;
 }
+
+int zd_chip_set_multicast_hash(struct zd_chip *chip,
+                              struct zd_mc_hash *hash)
+{
+       struct zd_ioreq32 ioreqs[] = {
+               { CR_GROUP_HASH_P1, hash->low },
+               { CR_GROUP_HASH_P2, hash->high },
+       };
+
+       dev_dbg_f(zd_chip_dev(chip), "hash l 0x%08x h 0x%08x\n",
+               ioreqs[0].value, ioreqs[1].value);
+       return zd_iowrite32a(chip, ioreqs, ARRAY_SIZE(ioreqs));
+}
index ca892b9a6448b9abe16c9228c2dc2ee6a787d2ba..a4e3cee9b59d2f94b604f358535cc54dcb8ebe15 100644 (file)
 #define CR_BSSID_P1                    CTL_REG(0x0618)
 #define CR_BSSID_P2                    CTL_REG(0x061C)
 #define CR_BCN_PLCP_CFG                        CTL_REG(0x0620)
+
+/* Group hash table for filtering incoming packets.
+ *
+ * The group hash table is 64 bit large and split over two parts. The first
+ * part is the lower part. The upper 6 bits of the last byte of the target
+ * address are used as index. Packets are received if the hash table bit is
+ * set. This is used for multicast handling, but for broadcasts (address
+ * ff:ff:ff:ff:ff:ff) the highest bit in the second table must also be set.
+ */
 #define CR_GROUP_HASH_P1               CTL_REG(0x0624)
 #define CR_GROUP_HASH_P2               CTL_REG(0x0628)
-#define CR_RX_TIMEOUT                  CTL_REG(0x062C)
 
+#define CR_RX_TIMEOUT                  CTL_REG(0x062C)
 /* Basic rates supported by the BSS. When producing ACK or CTS messages, the
  * device will use a rate in this table that is less than or equal to the rate
  * of the incoming frame which prompted the response */
@@ -864,4 +873,36 @@ u8 zd_rx_strength_percent(u8 rssi);
 
 u16 zd_rx_rate(const void *rx_frame, const struct rx_status *status);
 
+struct zd_mc_hash {
+       u32 low;
+       u32 high;
+};
+
+static inline void zd_mc_clear(struct zd_mc_hash *hash)
+{
+       hash->low = 0;
+       /* The interfaces must always received broadcasts.
+        * The hash of the broadcast address ff:ff:ff:ff:ff:ff is 63.
+        */
+       hash->high = 0x80000000;
+}
+
+static inline void zd_mc_add_all(struct zd_mc_hash *hash)
+{
+       hash->low = hash->high = 0xffffffff;
+}
+
+static inline void zd_mc_add_addr(struct zd_mc_hash *hash, u8 *addr)
+{
+       unsigned int i = addr[5] >> 2;
+       if (i < 32) {
+               hash->low |= 1 << i;
+       } else {
+               hash->high |= 1 << (i-32);
+       }
+}
+
+int zd_chip_set_multicast_hash(struct zd_chip *chip,
+                              struct zd_mc_hash *hash);
+
 #endif /* _ZD_CHIP_H */
index f1573a9c23369e5051e8571189171b160e267d03..00ca704ece35b65f0951404d5d1f037869d9921b 100644 (file)
@@ -39,6 +39,8 @@ static void housekeeping_init(struct zd_mac *mac);
 static void housekeeping_enable(struct zd_mac *mac);
 static void housekeeping_disable(struct zd_mac *mac);
 
+static void set_multicast_hash_handler(struct work_struct *work);
+
 int zd_mac_init(struct zd_mac *mac,
                struct net_device *netdev,
                struct usb_interface *intf)
@@ -55,6 +57,7 @@ int zd_mac_init(struct zd_mac *mac,
        softmac_init(ieee80211_priv(netdev));
        zd_chip_init(&mac->chip, netdev, intf);
        housekeeping_init(mac);
+       INIT_WORK(&mac->set_multicast_hash_work, set_multicast_hash_handler);
        return 0;
 }
 
@@ -136,6 +139,7 @@ out:
 
 void zd_mac_clear(struct zd_mac *mac)
 {
+       flush_workqueue(zd_workqueue);
        zd_chip_clear(&mac->chip);
        ZD_ASSERT(!spin_is_locked(&mac->lock));
        ZD_MEMCLEAR(mac, sizeof(struct zd_mac));
@@ -256,6 +260,43 @@ int zd_mac_set_mac_address(struct net_device *netdev, void *p)
        return 0;
 }
 
+static void set_multicast_hash_handler(struct work_struct *work)
+{
+       struct zd_mac *mac = container_of(work, struct zd_mac,
+                                         set_multicast_hash_work);
+       struct zd_mc_hash hash;
+
+       spin_lock_irq(&mac->lock);
+       hash = mac->multicast_hash;
+       spin_unlock_irq(&mac->lock);
+
+       zd_chip_set_multicast_hash(&mac->chip, &hash);
+}
+
+void zd_mac_set_multicast_list(struct net_device *dev)
+{
+       struct zd_mc_hash hash;
+       struct zd_mac *mac = zd_netdev_mac(dev);
+       struct dev_mc_list *mc;
+       unsigned long flags;
+
+       if (dev->flags & (IFF_PROMISC|IFF_ALLMULTI)) {
+               zd_mc_add_all(&hash);
+       } else {
+               zd_mc_clear(&hash);
+               for (mc = dev->mc_list; mc; mc = mc->next) {
+                       dev_dbg_f(zd_mac_dev(mac), "mc addr " MAC_FMT "\n",
+                                 MAC_ARG(mc->dmi_addr));
+                       zd_mc_add_addr(&hash, mc->dmi_addr);
+               }
+       }
+
+       spin_lock_irqsave(&mac->lock, flags);
+       mac->multicast_hash = hash;
+       spin_unlock_irqrestore(&mac->lock, flags);
+       queue_work(zd_workqueue, &mac->set_multicast_hash_work);
+}
+
 int zd_mac_set_regdomain(struct zd_mac *mac, u8 regdomain)
 {
        int r;
@@ -618,6 +659,9 @@ int zd_mac_get_range(struct zd_mac *mac, struct iw_range *range)
        range->we_version_compiled = WIRELESS_EXT;
        range->we_version_source = 20;
 
+       range->enc_capa = IW_ENC_CAPA_WPA |  IW_ENC_CAPA_WPA2 |
+                         IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
+
        ZD_ASSERT(!irqs_disabled());
        spin_lock_irq(&mac->lock);
        regdomain = mac->regdomain;
@@ -930,7 +974,8 @@ static int is_data_packet_for_us(struct ieee80211_device *ieee,
        }
 
        return memcmp(hdr->addr1, netdev->dev_addr, ETH_ALEN) == 0 ||
-              is_multicast_ether_addr(hdr->addr1) ||
+              (is_multicast_ether_addr(hdr->addr1) &&
+               memcmp(hdr->addr3, netdev->dev_addr, ETH_ALEN) != 0) ||
               (netdev->flags & IFF_PROMISC);
 }
 
@@ -1062,10 +1107,8 @@ int zd_mac_rx(struct zd_mac *mac, const u8 *buffer, unsigned int length)
        memcpy(skb_put(skb, length), buffer, length);
 
        r = ieee80211_rx(ieee, skb, &stats);
-       if (!r) {
-               ZD_ASSERT(in_irq());
-               dev_kfree_skb_irq(skb);
-       }
+       if (!r)
+               dev_kfree_skb_any(skb);
        return 0;
 }
 
index d4e8b870409d144c8711b5cb9dc73d5f156e1e21..f0cf05dc7d3e0c9e5d36b32c348b2bac38c76c04 100644 (file)
@@ -133,6 +133,8 @@ struct zd_mac {
        struct iw_statistics iw_stats;
 
        struct housekeeping housekeeping;
+       struct work_struct set_multicast_hash_work;
+       struct zd_mc_hash multicast_hash;
        struct delayed_work set_rts_cts_work;
        struct delayed_work set_basic_rates_work;
 
@@ -189,6 +191,7 @@ int zd_mac_init_hw(struct zd_mac *mac, u8 device_type);
 int zd_mac_open(struct net_device *netdev);
 int zd_mac_stop(struct net_device *netdev);
 int zd_mac_set_mac_address(struct net_device *dev, void *p);
+void zd_mac_set_multicast_list(struct net_device *netdev);
 
 int zd_mac_rx(struct zd_mac *mac, const u8 *buffer, unsigned int length);
 
index 60f1b0f6d45b81d50c4fab4cb3a5ec6d9913c6fd..8bda48de31ef7f58da1a329d4a017a23b716b688 100644 (file)
@@ -242,7 +242,7 @@ struct net_device *zd_netdev_alloc(struct usb_interface *intf)
        netdev->open = zd_mac_open;
        netdev->stop = zd_mac_stop;
        /* netdev->get_stats = */
-       /* netdev->set_multicast_list = */
+       netdev->set_multicast_list = zd_mac_set_multicast_list;
        netdev->set_mac_address = zd_mac_set_mac_address;
        netdev->wireless_handlers = &iw_handler_def;
        /* netdev->ethtool_ops = */
index 43e521e991264208b0a519dce29155766acf6eb4..78c2e6e4b42e254522a21ebec6c291d5bd6422cd 100644 (file)
@@ -220,8 +220,8 @@ static unsigned long get_exec_dcookie(struct mm_struct * mm)
                        continue;
                if (!(vma->vm_flags & VM_EXECUTABLE))
                        continue;
-               cookie = fast_get_dcookie(vma->vm_file->f_dentry,
-                       vma->vm_file->f_vfsmnt);
+               cookie = fast_get_dcookie(vma->vm_file->f_path.dentry,
+                       vma->vm_file->f_path.mnt);
                break;
        }
 
@@ -246,8 +246,8 @@ static unsigned long lookup_dcookie(struct mm_struct * mm, unsigned long addr, o
                        continue;
 
                if (vma->vm_file) {
-                       cookie = fast_get_dcookie(vma->vm_file->f_dentry,
-                               vma->vm_file->f_vfsmnt);
+                       cookie = fast_get_dcookie(vma->vm_file->f_path.dentry,
+                               vma->vm_file->f_path.mnt);
                        *offset = (vma->vm_pgoff << PAGE_SHIFT) + addr -
                                vma->vm_start;
                } else {
index 39c96641bc72cdf0bdc6a9d71a192a99a4f30e8b..b61c17b3e298a8f3f81121a1d46e207cc7ace60a 100644 (file)
@@ -1975,7 +1975,7 @@ static int __devinit parport_ECPPS2_supported(struct parport *pb){return 0;}
 /* --- IRQ detection -------------------------------------- */
 
 /* Only if supports ECP mode */
-static int __devinit programmable_irq_support(struct parport *pb)
+static int programmable_irq_support(struct parport *pb)
 {
        int irq, intrLine;
        unsigned char oecr = inb (ECONTROL (pb));
@@ -1992,7 +1992,7 @@ static int __devinit programmable_irq_support(struct parport *pb)
        return irq;
 }
 
-static int __devinit irq_probe_ECP(struct parport *pb)
+static int irq_probe_ECP(struct parport *pb)
 {
        int i;
        unsigned long irqs;
@@ -2020,7 +2020,7 @@ static int __devinit irq_probe_ECP(struct parport *pb)
  * This detection seems that only works in National Semiconductors
  * This doesn't work in SMC, LGS, and Winbond 
  */
-static int __devinit irq_probe_EPP(struct parport *pb)
+static int irq_probe_EPP(struct parport *pb)
 {
 #ifndef ADVANCED_DETECT
        return PARPORT_IRQ_NONE;
@@ -2059,7 +2059,7 @@ static int __devinit irq_probe_EPP(struct parport *pb)
 #endif /* Advanced detection */
 }
 
-static int __devinit irq_probe_SPP(struct parport *pb)
+static int irq_probe_SPP(struct parport *pb)
 {
        /* Don't even try to do this. */
        return PARPORT_IRQ_NONE;
@@ -2747,6 +2747,7 @@ enum parport_pc_pci_cards {
        titan_1284p2,
        avlab_1p,
        avlab_2p,
+       oxsemi_952,
        oxsemi_954,
        oxsemi_840,
        aks_0100,
@@ -2822,6 +2823,7 @@ static struct parport_pc_pci {
        /* avlab_2p             */      { 2, { { 0, 1}, { 2, 3 },} },
        /* The Oxford Semi cards are unusual: 954 doesn't support ECP,
         * and 840 locks up if you write 1 to bit 2! */
+       /* oxsemi_952 */                { 1, { { 0, 1 }, } },
        /* oxsemi_954 */                { 1, { { 0, -1 }, } },
        /* oxsemi_840 */                { 1, { { 0, -1 }, } },
        /* aks_0100 */                  { 1, { { 0, -1 }, } },
@@ -2895,6 +2897,8 @@ static const struct pci_device_id parport_pc_pci_tbl[] = {
        /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/
        { 0x14db, 0x2120, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1p}, /* AFAVLAB_TK9902 */
        { 0x14db, 0x2121, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2p},
+       { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI952PP,
+         PCI_ANY_ID, PCI_ANY_ID, 0, 0, oxsemi_952 },
        { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI954PP,
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, oxsemi_954 },
        { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_12PCI840,
index 9fc9a34ef24a28e74ec07ca725eb0c6db91f29ac..ed3f7e1a563c79c06d9808bfc59c795665fc11c5 100644 (file)
@@ -26,7 +26,7 @@
 
 static DEFINE_SPINLOCK(msi_lock);
 static struct msi_desc* msi_desc[NR_IRQS] = { [0 ... NR_IRQS-1] = NULL };
-static kmem_cache_t* msi_cachep;
+static struct kmem_cache* msi_cachep;
 
 static int pci_msi_enable = 1;
 
@@ -255,10 +255,8 @@ static void enable_msi_mode(struct pci_dev *dev, int pos, int type)
                pci_write_config_word(dev, msi_control_reg(pos), control);
                dev->msix_enabled = 1;
        }
-       if (pci_find_capability(dev, PCI_CAP_ID_EXP)) {
-               /* PCI Express Endpoint device detected */
-               pci_intx(dev, 0);  /* disable intx */
-       }
+
+       pci_intx(dev, 0);  /* disable intx */
 }
 
 void disable_msi_mode(struct pci_dev *dev, int pos, int type)
@@ -276,10 +274,8 @@ void disable_msi_mode(struct pci_dev *dev, int pos, int type)
                pci_write_config_word(dev, msi_control_reg(pos), control);
                dev->msix_enabled = 0;
        }
-       if (pci_find_capability(dev, PCI_CAP_ID_EXP)) {
-               /* PCI Express Endpoint device detected */
-               pci_intx(dev, 1);  /* enable intx */
-       }
+
+       pci_intx(dev, 1);  /* enable intx */
 }
 
 static int msi_lookup_irq(struct pci_dev *dev, int type)
index 0eeac60042b347052a0dc9d380d9d74de256735c..6a3c1e7289001651b981663878bde47f78678fcb 100644 (file)
@@ -873,6 +873,7 @@ void __devinit pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
        dev->dev.release = pci_release_dev;
        pci_dev_get(dev);
 
+       set_dev_node(&dev->dev, pcibus_to_node(bus));
        dev->dev.dma_mask = &dev->dma_mask;
        dev->dev.coherent_dma_mask = 0xffffffffull;
 
index 99cf33379769310619557605b72c390bc913b39f..4a6760a3b31f23a38ad80e4d2a0f3813bc7c5a78 100644 (file)
@@ -23,7 +23,7 @@ static loff_t
 proc_bus_pci_lseek(struct file *file, loff_t off, int whence)
 {
        loff_t new = -1;
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
 
        mutex_lock(&inode->i_mutex);
        switch (whence) {
@@ -48,7 +48,7 @@ proc_bus_pci_lseek(struct file *file, loff_t off, int whence)
 static ssize_t
 proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
 {
-       const struct inode *ino = file->f_dentry->d_inode;
+       const struct inode *ino = file->f_path.dentry->d_inode;
        const struct proc_dir_entry *dp = PDE(ino);
        struct pci_dev *dev = dp->data;
        unsigned int pos = *ppos;
@@ -130,7 +130,7 @@ proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *pp
 static ssize_t
 proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, loff_t *ppos)
 {
-       const struct inode *ino = file->f_dentry->d_inode;
+       const struct inode *ino = file->f_path.dentry->d_inode;
        const struct proc_dir_entry *dp = PDE(ino);
        struct pci_dev *dev = dp->data;
        int pos = *ppos;
@@ -245,7 +245,7 @@ static int proc_bus_pci_ioctl(struct inode *inode, struct file *file, unsigned i
 #ifdef HAVE_PCI_MMAP
 static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        const struct proc_dir_entry *dp = PDE(inode);
        struct pci_dev *dev = dp->data;
        struct pci_filp_private *fpriv = file->private_data;
index b6746301d9a9cd2f56a3e85472eb4cc21312ad5b..52d4a38b366735714e8f3c90c9fca4022dcd6a70 100644 (file)
@@ -23,9 +23,9 @@
 #include <asm/io.h>
 #include <asm/sizes.h>
 
-#include <asm/arch/at91rm9200.h>
 #include <asm/arch/board.h>
 #include <asm/arch/gpio.h>
+#include <asm/arch/at91rm9200_mc.h>
 
 
 /*
index f9cd831a3f3159ab18085dae94476976ade6c4fd..606a467403389718a03f21bab041f61fde4caee4 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/pci.h>
 #include <linux/device.h>
 #include <linux/kthread.h>
+#include <linux/freezer.h>
 #include <asm/system.h>
 #include <asm/irq.h>
 
index d077870c6731ae9ed63161829ee4bcb3fa2ba218..327372b7a54e61deb9b22193eff13c99ed065264 100644 (file)
@@ -486,7 +486,7 @@ static ssize_t ds_read(struct file *file, char __user *buf,
     user_info_t *user;
     int ret;
 
-    ds_dbg(2, "ds_read(socket %d)\n", iminor(file->f_dentry->d_inode));
+    ds_dbg(2, "ds_read(socket %d)\n", iminor(file->f_path.dentry->d_inode));
 
     if (count < 4)
        return -EINVAL;
@@ -511,7 +511,7 @@ static ssize_t ds_read(struct file *file, char __user *buf,
 static ssize_t ds_write(struct file *file, const char __user *buf,
                        size_t count, loff_t *ppos)
 {
-    ds_dbg(2, "ds_write(socket %d)\n", iminor(file->f_dentry->d_inode));
+    ds_dbg(2, "ds_write(socket %d)\n", iminor(file->f_path.dentry->d_inode));
 
     if (count != 4)
        return -EINVAL;
@@ -529,7 +529,7 @@ static u_int ds_poll(struct file *file, poll_table *wait)
     struct pcmcia_socket *s;
     user_info_t *user;
 
-    ds_dbg(2, "ds_poll(socket %d)\n", iminor(file->f_dentry->d_inode));
+    ds_dbg(2, "ds_poll(socket %d)\n", iminor(file->f_path.dentry->d_inode));
 
     user = file->private_data;
     if (CHECK_USER(user))
index 227600cd636048478126adbb20bc7be1157577b1..91c047a7e635d832d7090bf62522a99e6dca8e34 100644 (file)
@@ -164,9 +164,17 @@ static DEVICE_ATTR(card_id,S_IRUGO,pnp_show_card_ids,NULL);
 
 static int pnp_interface_attach_card(struct pnp_card *card)
 {
-       device_create_file(&card->dev,&dev_attr_name);
-       device_create_file(&card->dev,&dev_attr_card_id);
+       int rc = device_create_file(&card->dev,&dev_attr_name);
+       if (rc) return rc;
+
+       rc = device_create_file(&card->dev,&dev_attr_card_id);
+       if (rc) goto err_name;
+
        return 0;
+
+err_name:
+       device_remove_file(&card->dev,&dev_attr_name);
+       return rc;
 }
 
 /**
@@ -306,16 +314,20 @@ found:
        down_write(&dev->dev.bus->subsys.rwsem);
        dev->card_link = clink;
        dev->dev.driver = &drv->link.driver;
-       if (pnp_bus_type.probe(&dev->dev)) {
-               dev->dev.driver = NULL;
-               dev->card_link = NULL;
-               up_write(&dev->dev.bus->subsys.rwsem);
-               return NULL;
-       }
-       device_bind_driver(&dev->dev);
+       if (pnp_bus_type.probe(&dev->dev))
+               goto err_out;
+       if (device_bind_driver(&dev->dev))
+               goto err_out;
+
        up_write(&dev->dev.bus->subsys.rwsem);
 
        return dev;
+
+err_out:
+       dev->dev.driver = NULL;
+       dev->card_link = NULL;
+       up_write(&dev->dev.bus->subsys.rwsem);
+       return NULL;
 }
 
 /**
index 9d8b415eca79ba729e0104d1a4af1e7f185123ef..ac9fcd499f3f0cb9912dee2e1400e6f1f519aad3 100644 (file)
@@ -461,8 +461,19 @@ static DEVICE_ATTR(id,S_IRUGO,pnp_show_current_ids,NULL);
 
 int pnp_interface_attach_device(struct pnp_dev *dev)
 {
-       device_create_file(&dev->dev,&dev_attr_options);
-       device_create_file(&dev->dev,&dev_attr_resources);
-       device_create_file(&dev->dev,&dev_attr_id);
+       int rc = device_create_file(&dev->dev,&dev_attr_options);
+       if (rc) goto err;
+       rc = device_create_file(&dev->dev,&dev_attr_resources);
+       if (rc) goto err_opt;
+       rc = device_create_file(&dev->dev,&dev_attr_id);
+       if (rc) goto err_res;
+
        return 0;
+
+err_res:
+       device_remove_file(&dev->dev,&dev_attr_resources);
+err_opt:
+       device_remove_file(&dev->dev,&dev_attr_options);
+err:
+       return rc;
 }
index 958c11bedd0d66da73e35de1d7d02f3760aaf91f..d21f3c1e72fc1fed3066e71e5674a799c8951bfd 100644 (file)
@@ -56,7 +56,7 @@ static loff_t isapnp_proc_bus_lseek(struct file *file, loff_t off, int whence)
 
 static ssize_t isapnp_proc_bus_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
 {
-       struct inode *ino = file->f_dentry->d_inode;
+       struct inode *ino = file->f_path.dentry->d_inode;
        struct proc_dir_entry *dp = PDE(ino);
        struct pnp_dev *dev = dp->data;
        int pos = *ppos;
index 81a6c83d89a644bb9400aef1ee2470f0a536784d..33adeba1a31f1c87930e1266989a44b36b9f775e 100644 (file)
@@ -61,6 +61,7 @@
 #include <linux/dmi.h>
 #include <linux/delay.h>
 #include <linux/acpi.h>
+#include <linux/freezer.h>
 
 #include <asm/page.h>
 #include <asm/desc.h>
@@ -530,7 +531,8 @@ static int __init pnpbios_init(void)
        if (check_legacy_ioport(PNPBIOS_BASE))
                return -ENODEV;
 #endif
-       if (pnpbios_disabled || dmi_check_system(pnpbios_dmi_table)) {
+       if (pnpbios_disabled || dmi_check_system(pnpbios_dmi_table) ||
+           paravirt_enabled()) {
                printk(KERN_INFO "PnPBIOS: Disabled\n");
                return -ENODEV;
        }
index fc766a7a611ee0a88327561f93f2996431c9bdb4..2a63ab2b47f4a11b4f07681f7111b96500267de9 100644 (file)
@@ -154,15 +154,23 @@ config RTC_DRV_DS1672
          will be called rtc-ds1672.
 
 config RTC_DRV_DS1742
-       tristate "Dallas DS1742"
+       tristate "Dallas DS1742/1743"
        depends on RTC_CLASS
        help
          If you say yes here you get support for the
-         Dallas DS1742 timekeeping chip.
+         Dallas DS1742/1743 timekeeping chip.
 
          This driver can also be built as a module. If so, the module
          will be called rtc-ds1742.
 
+config RTC_DRV_OMAP
+       tristate "TI OMAP1"
+       depends on RTC_CLASS && ( \
+               ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 )
+       help
+         Say "yes" here to support the real time clock on TI OMAP1 chips.
+         This driver can also be built as a module called rtc-omap.
+
 config RTC_DRV_PCF8563
        tristate "Philips PCF8563/Epson RTC8564"
        depends on RTC_CLASS && I2C
index 3ba5ff6e68004700162f2e05c75fe02e438ff0b9..bd4c45d333f07aff1d0a8bb79ba2750520994362 100644 (file)
@@ -21,6 +21,7 @@ obj-$(CONFIG_RTC_DRV_TEST)    += rtc-test.o
 obj-$(CONFIG_RTC_DRV_DS1307)   += rtc-ds1307.o
 obj-$(CONFIG_RTC_DRV_DS1672)   += rtc-ds1672.o
 obj-$(CONFIG_RTC_DRV_DS1742)   += rtc-ds1742.o
+obj-$(CONFIG_RTC_DRV_OMAP)     += rtc-omap.o
 obj-$(CONFIG_RTC_DRV_PCF8563)  += rtc-pcf8563.o
 obj-$(CONFIG_RTC_DRV_PCF8583)  += rtc-pcf8583.o
 obj-$(CONFIG_RTC_DRV_RS5C372)  += rtc-rs5c372.o
index 67e816a9a39fdc5c0f64e929f95cc6dbc4fcf58b..dfef1637bfb8a1a69dc1848d75e2b490a458ddaf 100644 (file)
@@ -237,17 +237,22 @@ static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind)
        /* read control register */
        err = ds1672_get_control(client, &control);
        if (err)
-               goto exit_detach;
+               goto exit_devreg;
 
        if (control & DS1672_REG_CONTROL_EOSC)
                dev_warn(&client->dev, "Oscillator not enabled. "
                                        "Set time to enable.\n");
 
        /* Register sysfs hooks */
-       device_create_file(&client->dev, &dev_attr_control);
+       err = device_create_file(&client->dev, &dev_attr_control);
+       if (err)
+               goto exit_devreg;
 
        return 0;
 
+exit_devreg:
+       rtc_device_unregister(rtc);
+
 exit_detach:
        i2c_detach_client(client);
 
index 6273a3d240a2afd2f4a57179d38219f6259797a1..17633bfa848028ba04970d22d05e59a236ed9081 100644 (file)
@@ -6,6 +6,10 @@
  * 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.
+ *
+ * Copyright (C) 2006 Torsten Ertbjerg Rasmussen <tr@newtec.dk>
+ *  - nvram size determined from resource
+ *  - this ds1742 driver now supports ds1743.
  */
 
 #include <linux/bcd.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
 
-#define DRV_VERSION "0.2"
+#define DRV_VERSION "0.3"
 
-#define RTC_REG_SIZE           0x800
-#define RTC_OFFSET             0x7f8
+#define RTC_SIZE               8
 
-#define RTC_CONTROL            (RTC_OFFSET + 0)
-#define RTC_CENTURY            (RTC_OFFSET + 0)
-#define RTC_SECONDS            (RTC_OFFSET + 1)
-#define RTC_MINUTES            (RTC_OFFSET + 2)
-#define RTC_HOURS              (RTC_OFFSET + 3)
-#define RTC_DAY                        (RTC_OFFSET + 4)
-#define RTC_DATE               (RTC_OFFSET + 5)
-#define RTC_MONTH              (RTC_OFFSET + 6)
-#define RTC_YEAR               (RTC_OFFSET + 7)
+#define RTC_CONTROL            0
+#define RTC_CENTURY            0
+#define RTC_SECONDS            1
+#define RTC_MINUTES            2
+#define RTC_HOURS              3
+#define RTC_DAY                        4
+#define RTC_DATE               5
+#define RTC_MONTH              6
+#define RTC_YEAR               7
 
 #define RTC_CENTURY_MASK       0x3f
 #define RTC_SECONDS_MASK       0x7f
 
 struct rtc_plat_data {
        struct rtc_device *rtc;
-       void __iomem *ioaddr;
+       void __iomem *ioaddr_nvram;
+       void __iomem *ioaddr_rtc;
+       size_t size_nvram;
+       size_t size;
        unsigned long baseaddr;
        unsigned long last_jiffies;
 };
@@ -57,7 +63,7 @@ static int ds1742_rtc_set_time(struct device *dev, struct rtc_time *tm)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
-       void __iomem *ioaddr = pdata->ioaddr;
+       void __iomem *ioaddr = pdata->ioaddr_rtc;
        u8 century;
 
        century = BIN2BCD((tm->tm_year + 1900) / 100);
@@ -82,7 +88,7 @@ static int ds1742_rtc_read_time(struct device *dev, struct rtc_time *tm)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
-       void __iomem *ioaddr = pdata->ioaddr;
+       void __iomem *ioaddr = pdata->ioaddr_rtc;
        unsigned int year, month, day, hour, minute, second, week;
        unsigned int century;
 
@@ -127,10 +133,10 @@ static ssize_t ds1742_nvram_read(struct kobject *kobj, char *buf,
        struct platform_device *pdev =
                to_platform_device(container_of(kobj, struct device, kobj));
        struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
-       void __iomem *ioaddr = pdata->ioaddr;
+       void __iomem *ioaddr = pdata->ioaddr_nvram;
        ssize_t count;
 
-       for (count = 0; size > 0 && pos < RTC_OFFSET; count++, size--)
+       for (count = 0; size > 0 && pos < pdata->size_nvram; count++, size--)
                *buf++ = readb(ioaddr + pos++);
        return count;
 }
@@ -141,10 +147,10 @@ static ssize_t ds1742_nvram_write(struct kobject *kobj, char *buf,
        struct platform_device *pdev =
                to_platform_device(container_of(kobj, struct device, kobj));
        struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
-       void __iomem *ioaddr = pdata->ioaddr;
+       void __iomem *ioaddr = pdata->ioaddr_nvram;
        ssize_t count;
 
-       for (count = 0; size > 0 && pos < RTC_OFFSET; count++, size--)
+       for (count = 0; size > 0 && pos < pdata->size_nvram; count++, size--)
                writeb(*buf++, ioaddr + pos++);
        return count;
 }
@@ -155,7 +161,6 @@ static struct bin_attribute ds1742_nvram_attr = {
                .mode = S_IRUGO | S_IWUGO,
                .owner = THIS_MODULE,
        },
-       .size = RTC_OFFSET,
        .read = ds1742_nvram_read,
        .write = ds1742_nvram_write,
 };
@@ -175,19 +180,23 @@ static int __init ds1742_rtc_probe(struct platform_device *pdev)
        pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
        if (!pdata)
                return -ENOMEM;
-       if (!request_mem_region(res->start, RTC_REG_SIZE, pdev->name)) {
+       pdata->size = res->end - res->start + 1;
+       if (!request_mem_region(res->start, pdata->size, pdev->name)) {
                ret = -EBUSY;
                goto out;
        }
        pdata->baseaddr = res->start;
-       ioaddr = ioremap(pdata->baseaddr, RTC_REG_SIZE);
+       ioaddr = ioremap(pdata->baseaddr, pdata->size);
        if (!ioaddr) {
                ret = -ENOMEM;
                goto out;
        }
-       pdata->ioaddr = ioaddr;
+       pdata->ioaddr_nvram = ioaddr;
+       pdata->size_nvram = pdata->size - RTC_SIZE;
+       pdata->ioaddr_rtc = ioaddr + pdata->size_nvram;
 
        /* turn RTC on if it was not on */
+       ioaddr = pdata->ioaddr_rtc;
        sec = readb(ioaddr + RTC_SECONDS);
        if (sec & RTC_STOP) {
                sec &= RTC_SECONDS_MASK;
@@ -208,6 +217,8 @@ static int __init ds1742_rtc_probe(struct platform_device *pdev)
        pdata->rtc = rtc;
        pdata->last_jiffies = jiffies;
        platform_set_drvdata(pdev, pdata);
+       ds1742_nvram_attr.size = max(ds1742_nvram_attr.size,
+                                    pdata->size_nvram);
        ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1742_nvram_attr);
        if (ret)
                goto out;
@@ -215,10 +226,10 @@ static int __init ds1742_rtc_probe(struct platform_device *pdev)
  out:
        if (pdata->rtc)
                rtc_device_unregister(pdata->rtc);
-       if (ioaddr)
-               iounmap(ioaddr);
+       if (pdata->ioaddr_nvram)
+               iounmap(pdata->ioaddr_nvram);
        if (pdata->baseaddr)
-               release_mem_region(pdata->baseaddr, RTC_REG_SIZE);
+               release_mem_region(pdata->baseaddr, pdata->size);
        kfree(pdata);
        return ret;
 }
@@ -229,8 +240,8 @@ static int __devexit ds1742_rtc_remove(struct platform_device *pdev)
 
        sysfs_remove_bin_file(&pdev->dev.kobj, &ds1742_nvram_attr);
        rtc_device_unregister(pdata->rtc);
-       iounmap(pdata->ioaddr);
-       release_mem_region(pdata->baseaddr, RTC_REG_SIZE);
+       iounmap(pdata->ioaddr_nvram);
+       release_mem_region(pdata->baseaddr, pdata->size);
        kfree(pdata);
        return 0;
 }
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
new file mode 100644 (file)
index 0000000..eac5fb1
--- /dev/null
@@ -0,0 +1,572 @@
+/*
+ * TI OMAP1 Real Time Clock interface for Linux
+ *
+ * Copyright (C) 2003 MontaVista Software, Inc.
+ * Author: George G. Davis <gdavis@mvista.com> or <source@mvista.com>
+ *
+ * Copyright (C) 2006 David Brownell (new RTC framework)
+ *
+ * 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/kernel.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <linux/rtc.h>
+#include <linux/bcd.h>
+#include <linux/platform_device.h>
+
+#include <asm/io.h>
+#include <asm/mach/time.h>
+
+
+/* The OMAP1 RTC is a year/month/day/hours/minutes/seconds BCD clock
+ * with century-range alarm matching, driven by the 32kHz clock.
+ *
+ * The main user-visible ways it differs from PC RTCs are by omitting
+ * "don't care" alarm fields and sub-second periodic IRQs, and having
+ * an autoadjust mechanism to calibrate to the true oscillator rate.
+ *
+ * Board-specific wiring options include using split power mode with
+ * RTC_OFF_NOFF used as the reset signal (so the RTC won't be reset),
+ * and wiring RTC_WAKE_INT (so the RTC alarm can wake the system from
+ * low power modes).  See the BOARD-SPECIFIC CUSTOMIZATION comment.
+ */
+
+#define OMAP_RTC_BASE                  0xfffb4800
+
+/* RTC registers */
+#define OMAP_RTC_SECONDS_REG           0x00
+#define OMAP_RTC_MINUTES_REG           0x04
+#define OMAP_RTC_HOURS_REG             0x08
+#define OMAP_RTC_DAYS_REG              0x0C
+#define OMAP_RTC_MONTHS_REG            0x10
+#define OMAP_RTC_YEARS_REG             0x14
+#define OMAP_RTC_WEEKS_REG             0x18
+
+#define OMAP_RTC_ALARM_SECONDS_REG     0x20
+#define OMAP_RTC_ALARM_MINUTES_REG     0x24
+#define OMAP_RTC_ALARM_HOURS_REG       0x28
+#define OMAP_RTC_ALARM_DAYS_REG                0x2c
+#define OMAP_RTC_ALARM_MONTHS_REG      0x30
+#define OMAP_RTC_ALARM_YEARS_REG       0x34
+
+#define OMAP_RTC_CTRL_REG              0x40
+#define OMAP_RTC_STATUS_REG            0x44
+#define OMAP_RTC_INTERRUPTS_REG                0x48
+
+#define OMAP_RTC_COMP_LSB_REG          0x4c
+#define OMAP_RTC_COMP_MSB_REG          0x50
+#define OMAP_RTC_OSC_REG               0x54
+
+/* OMAP_RTC_CTRL_REG bit fields: */
+#define OMAP_RTC_CTRL_SPLIT            (1<<7)
+#define OMAP_RTC_CTRL_DISABLE          (1<<6)
+#define OMAP_RTC_CTRL_SET_32_COUNTER   (1<<5)
+#define OMAP_RTC_CTRL_TEST             (1<<4)
+#define OMAP_RTC_CTRL_MODE_12_24       (1<<3)
+#define OMAP_RTC_CTRL_AUTO_COMP                (1<<2)
+#define OMAP_RTC_CTRL_ROUND_30S                (1<<1)
+#define OMAP_RTC_CTRL_STOP             (1<<0)
+
+/* OMAP_RTC_STATUS_REG bit fields: */
+#define OMAP_RTC_STATUS_POWER_UP        (1<<7)
+#define OMAP_RTC_STATUS_ALARM           (1<<6)
+#define OMAP_RTC_STATUS_1D_EVENT        (1<<5)
+#define OMAP_RTC_STATUS_1H_EVENT        (1<<4)
+#define OMAP_RTC_STATUS_1M_EVENT        (1<<3)
+#define OMAP_RTC_STATUS_1S_EVENT        (1<<2)
+#define OMAP_RTC_STATUS_RUN             (1<<1)
+#define OMAP_RTC_STATUS_BUSY            (1<<0)
+
+/* OMAP_RTC_INTERRUPTS_REG bit fields: */
+#define OMAP_RTC_INTERRUPTS_IT_ALARM    (1<<3)
+#define OMAP_RTC_INTERRUPTS_IT_TIMER    (1<<2)
+
+
+#define rtc_read(addr)         omap_readb(OMAP_RTC_BASE + (addr))
+#define rtc_write(val, addr)   omap_writeb(val, OMAP_RTC_BASE + (addr))
+
+
+/* platform_bus isn't hotpluggable, so for static linkage it'd be safe
+ * to get rid of probe() and remove() code ... too bad the driver struct
+ * remembers probe(), that's about 25% of the runtime footprint!!
+ */
+#ifndef        MODULE
+#undef __devexit
+#undef __devexit_p
+#define        __devexit       __exit
+#define        __devexit_p     __exit_p
+#endif
+
+
+/* we rely on the rtc framework to handle locking (rtc->ops_lock),
+ * so the only other requirement is that register accesses which
+ * require BUSY to be clear are made with IRQs locally disabled
+ */
+static void rtc_wait_not_busy(void)
+{
+       int     count = 0;
+       u8      status;
+
+       /* BUSY may stay active for 1/32768 second (~30 usec) */
+       for (count = 0; count < 50; count++) {
+               status = rtc_read(OMAP_RTC_STATUS_REG);
+               if ((status & (u8)OMAP_RTC_STATUS_BUSY) == 0)
+                       break;
+               udelay(1);
+       }
+       /* now we have ~15 usec to read/write various registers */
+}
+
+static irqreturn_t rtc_irq(int irq, void *class_dev)
+{
+       unsigned long           events = 0;
+       u8                      irq_data;
+
+       irq_data = rtc_read(OMAP_RTC_STATUS_REG);
+
+       /* alarm irq? */
+       if (irq_data & OMAP_RTC_STATUS_ALARM) {
+               rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG);
+               events |= RTC_IRQF | RTC_AF;
+       }
+
+       /* 1/sec periodic/update irq? */
+       if (irq_data & OMAP_RTC_STATUS_1S_EVENT)
+               events |= RTC_IRQF | RTC_UF;
+
+       rtc_update_irq(class_dev, 1, events);
+
+       return IRQ_HANDLED;
+}
+
+#ifdef CONFIG_RTC_INTF_DEV
+
+static int
+omap_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
+{
+       u8 reg;
+
+       switch (cmd) {
+       case RTC_AIE_OFF:
+       case RTC_AIE_ON:
+       case RTC_UIE_OFF:
+       case RTC_UIE_ON:
+               break;
+       default:
+               return -ENOIOCTLCMD;
+       }
+
+       local_irq_disable();
+       rtc_wait_not_busy();
+       reg = rtc_read(OMAP_RTC_INTERRUPTS_REG);
+       switch (cmd) {
+       /* AIE = Alarm Interrupt Enable */
+       case RTC_AIE_OFF:
+               reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM;
+               break;
+       case RTC_AIE_ON:
+               reg |= OMAP_RTC_INTERRUPTS_IT_ALARM;
+               break;
+       /* UIE = Update Interrupt Enable (1/second) */
+       case RTC_UIE_OFF:
+               reg &= ~OMAP_RTC_INTERRUPTS_IT_TIMER;
+               break;
+       case RTC_UIE_ON:
+               reg |= OMAP_RTC_INTERRUPTS_IT_TIMER;
+               break;
+       }
+       rtc_wait_not_busy();
+       rtc_write(reg, OMAP_RTC_INTERRUPTS_REG);
+       local_irq_enable();
+
+       return 0;
+}
+
+#else
+#define        omap_rtc_ioctl  NULL
+#endif
+
+/* this hardware doesn't support "don't care" alarm fields */
+static int tm2bcd(struct rtc_time *tm)
+{
+       if (rtc_valid_tm(tm) != 0)
+               return -EINVAL;
+
+       tm->tm_sec = BIN2BCD(tm->tm_sec);
+       tm->tm_min = BIN2BCD(tm->tm_min);
+       tm->tm_hour = BIN2BCD(tm->tm_hour);
+       tm->tm_mday = BIN2BCD(tm->tm_mday);
+
+       tm->tm_mon = BIN2BCD(tm->tm_mon + 1);
+
+       /* epoch == 1900 */
+       if (tm->tm_year < 100 || tm->tm_year > 199)
+               return -EINVAL;
+       tm->tm_year = BIN2BCD(tm->tm_year - 100);
+
+       return 0;
+}
+
+static void bcd2tm(struct rtc_time *tm)
+{
+       tm->tm_sec = BCD2BIN(tm->tm_sec);
+       tm->tm_min = BCD2BIN(tm->tm_min);
+       tm->tm_hour = BCD2BIN(tm->tm_hour);
+       tm->tm_mday = BCD2BIN(tm->tm_mday);
+       tm->tm_mon = BCD2BIN(tm->tm_mon) - 1;
+       /* epoch == 1900 */
+       tm->tm_year = BCD2BIN(tm->tm_year) + 100;
+}
+
+
+static int omap_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+       /* we don't report wday/yday/isdst ... */
+       local_irq_disable();
+       rtc_wait_not_busy();
+
+       tm->tm_sec = rtc_read(OMAP_RTC_SECONDS_REG);
+       tm->tm_min = rtc_read(OMAP_RTC_MINUTES_REG);
+       tm->tm_hour = rtc_read(OMAP_RTC_HOURS_REG);
+       tm->tm_mday = rtc_read(OMAP_RTC_DAYS_REG);
+       tm->tm_mon = rtc_read(OMAP_RTC_MONTHS_REG);
+       tm->tm_year = rtc_read(OMAP_RTC_YEARS_REG);
+
+       local_irq_enable();
+
+       bcd2tm(tm);
+       return 0;
+}
+
+static int omap_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+       if (tm2bcd(tm) < 0)
+               return -EINVAL;
+       local_irq_disable();
+       rtc_wait_not_busy();
+
+       rtc_write(tm->tm_year, OMAP_RTC_YEARS_REG);
+       rtc_write(tm->tm_mon, OMAP_RTC_MONTHS_REG);
+       rtc_write(tm->tm_mday, OMAP_RTC_DAYS_REG);
+       rtc_write(tm->tm_hour, OMAP_RTC_HOURS_REG);
+       rtc_write(tm->tm_min, OMAP_RTC_MINUTES_REG);
+       rtc_write(tm->tm_sec, OMAP_RTC_SECONDS_REG);
+
+       local_irq_enable();
+
+       return 0;
+}
+
+static int omap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
+{
+       local_irq_disable();
+       rtc_wait_not_busy();
+
+       alm->time.tm_sec = rtc_read(OMAP_RTC_ALARM_SECONDS_REG);
+       alm->time.tm_min = rtc_read(OMAP_RTC_ALARM_MINUTES_REG);
+       alm->time.tm_hour = rtc_read(OMAP_RTC_ALARM_HOURS_REG);
+       alm->time.tm_mday = rtc_read(OMAP_RTC_ALARM_DAYS_REG);
+       alm->time.tm_mon = rtc_read(OMAP_RTC_ALARM_MONTHS_REG);
+       alm->time.tm_year = rtc_read(OMAP_RTC_ALARM_YEARS_REG);
+
+       local_irq_enable();
+
+       bcd2tm(&alm->time);
+       alm->pending = !!(rtc_read(OMAP_RTC_INTERRUPTS_REG)
+                       & OMAP_RTC_INTERRUPTS_IT_ALARM);
+       alm->enabled = alm->pending && device_may_wakeup(dev);
+
+       return 0;
+}
+
+static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
+{
+       u8 reg;
+
+       /* Much userspace code uses RTC_ALM_SET, thus "don't care" for
+        * day/month/year specifies alarms up to 24 hours in the future.
+        * So we need to handle that ... but let's ignore the "don't care"
+        * values for hours/minutes/seconds.
+        */
+       if (alm->time.tm_mday <= 0
+                       && alm->time.tm_mon < 0
+                       && alm->time.tm_year < 0) {
+               struct rtc_time tm;
+               unsigned long now, then;
+
+               omap_rtc_read_time(dev, &tm);
+               rtc_tm_to_time(&tm, &now);
+
+               alm->time.tm_mday = tm.tm_mday;
+               alm->time.tm_mon = tm.tm_mon;
+               alm->time.tm_year = tm.tm_year;
+               rtc_tm_to_time(&alm->time, &then);
+
+               /* sometimes the alarm wraps into tomorrow */
+               if (then < now) {
+                       rtc_time_to_tm(now + 24 * 60 * 60, &tm);
+                       alm->time.tm_mday = tm.tm_mday;
+                       alm->time.tm_mon = tm.tm_mon;
+                       alm->time.tm_year = tm.tm_year;
+               }
+       }
+
+       if (tm2bcd(&alm->time) < 0)
+               return -EINVAL;
+
+       local_irq_disable();
+       rtc_wait_not_busy();
+
+       rtc_write(alm->time.tm_year, OMAP_RTC_ALARM_YEARS_REG);
+       rtc_write(alm->time.tm_mon, OMAP_RTC_ALARM_MONTHS_REG);
+       rtc_write(alm->time.tm_mday, OMAP_RTC_ALARM_DAYS_REG);
+       rtc_write(alm->time.tm_hour, OMAP_RTC_ALARM_HOURS_REG);
+       rtc_write(alm->time.tm_min, OMAP_RTC_ALARM_MINUTES_REG);
+       rtc_write(alm->time.tm_sec, OMAP_RTC_ALARM_SECONDS_REG);
+
+       reg = rtc_read(OMAP_RTC_INTERRUPTS_REG);
+       if (alm->enabled)
+               reg |= OMAP_RTC_INTERRUPTS_IT_ALARM;
+       else
+               reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM;
+       rtc_write(reg, OMAP_RTC_INTERRUPTS_REG);
+
+       local_irq_enable();
+
+       return 0;
+}
+
+static struct rtc_class_ops omap_rtc_ops = {
+       .ioctl          = omap_rtc_ioctl,
+       .read_time      = omap_rtc_read_time,
+       .set_time       = omap_rtc_set_time,
+       .read_alarm     = omap_rtc_read_alarm,
+       .set_alarm      = omap_rtc_set_alarm,
+};
+
+static int omap_rtc_alarm;
+static int omap_rtc_timer;
+
+static int __devinit omap_rtc_probe(struct platform_device *pdev)
+{
+       struct resource         *res, *mem;
+       struct rtc_device       *rtc;
+       u8                      reg, new_ctrl;
+
+       omap_rtc_timer = platform_get_irq(pdev, 0);
+       if (omap_rtc_timer <= 0) {
+               pr_debug("%s: no update irq?\n", pdev->name);
+               return -ENOENT;
+       }
+
+       omap_rtc_alarm = platform_get_irq(pdev, 1);
+       if (omap_rtc_alarm <= 0) {
+               pr_debug("%s: no alarm irq?\n", pdev->name);
+               return -ENOENT;
+       }
+
+       /* NOTE:  using static mapping for RTC registers */
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (res && res->start != OMAP_RTC_BASE) {
+               pr_debug("%s: RTC registers at %08x, expected %08x\n",
+                       pdev->name, (unsigned) res->start, OMAP_RTC_BASE);
+               return -ENOENT;
+       }
+
+       if (res)
+               mem = request_mem_region(res->start,
+                               res->end - res->start + 1,
+                               pdev->name);
+       else
+               mem = NULL;
+       if (!mem) {
+               pr_debug("%s: RTC registers at %08x are not free\n",
+                       pdev->name, OMAP_RTC_BASE);
+               return -EBUSY;
+       }
+
+       rtc = rtc_device_register(pdev->name, &pdev->dev,
+                       &omap_rtc_ops, THIS_MODULE);
+       if (IS_ERR(rtc)) {
+               pr_debug("%s: can't register RTC device, err %ld\n",
+                       pdev->name, PTR_ERR(rtc));
+               goto fail;
+       }
+       platform_set_drvdata(pdev, rtc);
+       class_set_devdata(&rtc->class_dev, mem);
+
+       /* clear pending irqs, and set 1/second periodic,
+        * which we'll use instead of update irqs
+        */
+       rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
+
+       /* clear old status */
+       reg = rtc_read(OMAP_RTC_STATUS_REG);
+       if (reg & (u8) OMAP_RTC_STATUS_POWER_UP) {
+               pr_info("%s: RTC power up reset detected\n",
+                       pdev->name);
+               rtc_write(OMAP_RTC_STATUS_POWER_UP, OMAP_RTC_STATUS_REG);
+       }
+       if (reg & (u8) OMAP_RTC_STATUS_ALARM)
+               rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG);
+
+       /* handle periodic and alarm irqs */
+       if (request_irq(omap_rtc_timer, rtc_irq, SA_INTERRUPT,
+                       rtc->class_dev.class_id, &rtc->class_dev)) {
+               pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n",
+                       pdev->name, omap_rtc_timer);
+               goto fail0;
+       }
+       if (request_irq(omap_rtc_alarm, rtc_irq, SA_INTERRUPT,
+                       rtc->class_dev.class_id, &rtc->class_dev)) {
+               pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n",
+                       pdev->name, omap_rtc_alarm);
+               goto fail1;
+       }
+
+       /* On boards with split power, RTC_ON_NOFF won't reset the RTC */
+       reg = rtc_read(OMAP_RTC_CTRL_REG);
+       if (reg & (u8) OMAP_RTC_CTRL_STOP)
+               pr_info("%s: already running\n", pdev->name);
+
+       /* force to 24 hour mode */
+       new_ctrl = reg & ~(OMAP_RTC_CTRL_SPLIT|OMAP_RTC_CTRL_AUTO_COMP);
+       new_ctrl |= OMAP_RTC_CTRL_STOP;
+
+       /* BOARD-SPECIFIC CUSTOMIZATION CAN GO HERE:
+        *
+        *  - Boards wired so that RTC_WAKE_INT does something, and muxed
+        *    right (W13_1610_RTC_WAKE_INT is the default after chip reset),
+        *    should initialize the device wakeup flag appropriately.
+        *
+        *  - Boards wired so RTC_ON_nOFF is used as the reset signal,
+        *    rather than nPWRON_RESET, should forcibly enable split
+        *    power mode.  (Some chip errata report that RTC_CTRL_SPLIT
+        *    is write-only, and always reads as zero...)
+        */
+       device_init_wakeup(&pdev->dev, 0);
+
+       if (new_ctrl & (u8) OMAP_RTC_CTRL_SPLIT)
+               pr_info("%s: split power mode\n", pdev->name);
+
+       if (reg != new_ctrl)
+               rtc_write(new_ctrl, OMAP_RTC_CTRL_REG);
+
+       return 0;
+
+fail1:
+       free_irq(omap_rtc_timer, NULL);
+fail0:
+       rtc_device_unregister(rtc);
+fail:
+       release_resource(mem);
+       return -EIO;
+}
+
+static int __devexit omap_rtc_remove(struct platform_device *pdev)
+{
+       struct rtc_device       *rtc = platform_get_drvdata(pdev);;
+
+       device_init_wakeup(&pdev->dev, 0);
+
+       /* leave rtc running, but disable irqs */
+       rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
+
+       free_irq(omap_rtc_timer, rtc);
+       free_irq(omap_rtc_alarm, rtc);
+
+       release_resource(class_get_devdata(&rtc->class_dev));
+       rtc_device_unregister(rtc);
+       return 0;
+}
+
+#ifdef CONFIG_PM
+
+static struct timespec rtc_delta;
+static u8 irqstat;
+
+static int omap_rtc_suspend(struct platform_device *pdev, pm_message_t state)
+{
+       struct rtc_time rtc_tm;
+       struct timespec time;
+
+       time.tv_nsec = 0;
+       omap_rtc_read_time(NULL, &rtc_tm);
+       rtc_tm_to_time(&rtc_tm, &time.tv_sec);
+
+       save_time_delta(&rtc_delta, &time);
+       irqstat = rtc_read(OMAP_RTC_INTERRUPTS_REG);
+
+       /* FIXME the RTC alarm is not currently acting as a wakeup event
+        * source, and in fact this enable() call is just saving a flag
+        * that's never used...
+        */
+       if (device_may_wakeup(&pdev->dev))
+               enable_irq_wake(omap_rtc_alarm);
+       else
+               rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
+
+       return 0;
+}
+
+static int omap_rtc_resume(struct platform_device *pdev)
+{
+       struct rtc_time rtc_tm;
+       struct timespec time;
+
+       time.tv_nsec = 0;
+       omap_rtc_read_time(NULL, &rtc_tm);
+       rtc_tm_to_time(&rtc_tm, &time.tv_sec);
+
+       restore_time_delta(&rtc_delta, &time);
+       if (device_may_wakeup(&pdev->dev))
+               disable_irq_wake(omap_rtc_alarm);
+       else
+               rtc_write(irqstat, OMAP_RTC_INTERRUPTS_REG);
+       return 0;
+}
+
+#else
+#define omap_rtc_suspend NULL
+#define omap_rtc_resume  NULL
+#endif
+
+static void omap_rtc_shutdown(struct platform_device *pdev)
+{
+       rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
+}
+
+MODULE_ALIAS("omap_rtc");
+static struct platform_driver omap_rtc_driver = {
+       .probe          = omap_rtc_probe,
+       .remove         = __devexit_p(omap_rtc_remove),
+       .suspend        = omap_rtc_suspend,
+       .resume         = omap_rtc_resume,
+       .shutdown       = omap_rtc_shutdown,
+       .driver         = {
+               .name   = "omap_rtc",
+               .owner  = THIS_MODULE,
+       },
+};
+
+static int __init rtc_init(void)
+{
+       return platform_driver_register(&omap_rtc_driver);
+}
+module_init(rtc_init);
+
+static void __exit rtc_exit(void)
+{
+       platform_driver_unregister(&omap_rtc_driver);
+}
+module_exit(rtc_exit);
+
+MODULE_AUTHOR("George G. Davis (and others)");
+MODULE_LICENSE("GPL");
index a44fe4efa216ac372cc8eac8d4e0d18aa6c9a71d..e2c7698fdba312c5b759df934d25375bd1c143be 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/rtc.h>
 #include <linux/bcd.h>
 
-#define DRV_VERSION "0.2"
+#define DRV_VERSION "0.3"
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { /* 0x32,*/ I2C_CLIENT_END };
@@ -39,6 +39,14 @@ static int rs5c372_attach(struct i2c_adapter *adapter);
 static int rs5c372_detach(struct i2c_client *client);
 static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind);
 
+struct rs5c372 {
+       u8 reg_addr;
+       u8 regs[17];
+       struct i2c_msg msg[1];
+       struct i2c_client client;
+       struct rtc_device *rtc;
+};
+
 static struct i2c_driver rs5c372_driver = {
        .driver         = {
                .name   = "rs5c372",
@@ -49,18 +57,16 @@ static struct i2c_driver rs5c372_driver = {
 
 static int rs5c372_get_datetime(struct i2c_client *client, struct rtc_time *tm)
 {
-       unsigned char buf[7] = { RS5C372_REG_BASE };
 
-       /* this implements the 1st reading method, according
-        * to the datasheet. buf[0] is initialized with
-        * address ptr and transmission format register.
+       struct rs5c372 *rs5c372 = i2c_get_clientdata(client);
+       u8 *buf = &(rs5c372->regs[1]);
+
+       /* this implements the 3rd reading method, according
+        * to the datasheet. rs5c372 defaults to internal
+        * address 0xF, so 0x0 is in regs[1]
         */
-       struct i2c_msg msgs[] = {
-               { client->addr, 0, 1, buf },
-               { client->addr, I2C_M_RD, 7, buf },
-       };
 
-       if ((i2c_transfer(client->adapter, msgs, 2)) != 2) {
+       if ((i2c_transfer(client->adapter, rs5c372->msg, 1)) != 1) {
                dev_err(&client->dev, "%s: read error\n", __FUNCTION__);
                return -EIO;
        }
@@ -114,23 +120,14 @@ static int rs5c372_set_datetime(struct i2c_client *client, struct rtc_time *tm)
 
 static int rs5c372_get_trim(struct i2c_client *client, int *osc, int *trim)
 {
-       unsigned char buf = RS5C372_REG_TRIM;
-
-       struct i2c_msg msgs[] = {
-               { client->addr, 0, 1, &buf },
-               { client->addr, I2C_M_RD, 1, &buf },
-       };
-
-       if ((i2c_transfer(client->adapter, msgs, 2)) != 2) {
-               dev_err(&client->dev, "%s: read error\n", __FUNCTION__);
-               return -EIO;
-       }
+       struct rs5c372 *rs5c372 = i2c_get_clientdata(client);
+       u8 tmp = rs5c372->regs[RS5C372_REG_TRIM + 1];
 
        if (osc)
-               *osc = (buf & RS5C372_TRIM_XSL) ? 32000 : 32768;
+               *osc = (tmp & RS5C372_TRIM_XSL) ? 32000 : 32768;
 
        if (trim) {
-               *trim = buf & RS5C372_TRIM_MASK;
+               *trim = tmp & RS5C372_TRIM_MASK;
                dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, *trim);
        }
 
@@ -201,7 +198,7 @@ static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind)
 {
        int err = 0;
        struct i2c_client *client;
-       struct rtc_device *rtc;
+       struct rs5c372 *rs5c372;
 
        dev_dbg(&adapter->dev, "%s\n", __FUNCTION__);
 
@@ -210,10 +207,11 @@ static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind)
                goto exit;
        }
 
-       if (!(client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) {
+       if (!(rs5c372 = kzalloc(sizeof(struct rs5c372), GFP_KERNEL))) {
                err = -ENOMEM;
                goto exit;
        }
+       client = &rs5c372->client;
 
        /* I2C client */
        client->addr = address;
@@ -222,32 +220,47 @@ static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind)
 
        strlcpy(client->name, rs5c372_driver.driver.name, I2C_NAME_SIZE);
 
+       i2c_set_clientdata(client, rs5c372);
+
+       rs5c372->msg[0].addr = address;
+       rs5c372->msg[0].flags = I2C_M_RD;
+       rs5c372->msg[0].len = sizeof(rs5c372->regs);
+       rs5c372->msg[0].buf = rs5c372->regs;
+
        /* Inform the i2c layer */
        if ((err = i2c_attach_client(client)))
                goto exit_kfree;
 
        dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
 
-       rtc = rtc_device_register(rs5c372_driver.driver.name, &client->dev,
-                               &rs5c372_rtc_ops, THIS_MODULE);
+       rs5c372->rtc = rtc_device_register(rs5c372_driver.driver.name,
+                               &client->dev, &rs5c372_rtc_ops, THIS_MODULE);
 
-       if (IS_ERR(rtc)) {
-               err = PTR_ERR(rtc);
+       if (IS_ERR(rs5c372->rtc)) {
+               err = PTR_ERR(rs5c372->rtc);
                goto exit_detach;
        }
 
-       i2c_set_clientdata(client, rtc);
-
-       device_create_file(&client->dev, &dev_attr_trim);
-       device_create_file(&client->dev, &dev_attr_osc);
+       err = device_create_file(&client->dev, &dev_attr_trim);
+       if (err)
+               goto exit_devreg;
+       err = device_create_file(&client->dev, &dev_attr_osc);
+       if (err)
+               goto exit_trim;
 
        return 0;
 
+exit_trim:
+       device_remove_file(&client->dev, &dev_attr_trim);
+
+exit_devreg:
+       rtc_device_unregister(rs5c372->rtc);
+
 exit_detach:
        i2c_detach_client(client);
 
 exit_kfree:
-       kfree(client);
+       kfree(rs5c372);
 
 exit:
        return err;
@@ -256,16 +269,15 @@ exit:
 static int rs5c372_detach(struct i2c_client *client)
 {
        int err;
-       struct rtc_device *rtc = i2c_get_clientdata(client);
+       struct rs5c372 *rs5c372 = i2c_get_clientdata(client);
 
-       if (rtc)
-               rtc_device_unregister(rtc);
+       if (rs5c372->rtc)
+               rtc_device_unregister(rs5c372->rtc);
 
        if ((err = i2c_detach_client(client)))
                return err;
 
-       kfree(client);
-
+       kfree(rs5c372);
        return 0;
 }
 
index 6ef9c62d5032afa97122331c4754513f9b44b0dc..f50a1b8e160706982f91c5a051abcc88f73d333e 100644 (file)
@@ -123,11 +123,18 @@ static int test_probe(struct platform_device *plat_dev)
                err = PTR_ERR(rtc);
                return err;
        }
-       device_create_file(&plat_dev->dev, &dev_attr_irq);
+
+       err = device_create_file(&plat_dev->dev, &dev_attr_irq);
+       if (err)
+               goto err;
 
        platform_set_drvdata(plat_dev, rtc);
 
        return 0;
+
+err:
+       rtc_device_unregister(rtc);
+       return err;
 }
 
 static int __devexit test_remove(struct platform_device *plat_dev)
index 522c69753bbfb3843b6dccf1c4f922b43e45a666..9a67487d086ba55ab36e202c1e7bbc9f9cf1239d 100644 (file)
@@ -562,11 +562,19 @@ static int x1205_probe(struct i2c_adapter *adapter, int address, int kind)
        else
                dev_err(&client->dev, "couldn't read status\n");
 
-       device_create_file(&client->dev, &dev_attr_atrim);
-       device_create_file(&client->dev, &dev_attr_dtrim);
+       err = device_create_file(&client->dev, &dev_attr_atrim);
+       if (err) goto exit_devreg;
+       err = device_create_file(&client->dev, &dev_attr_dtrim);
+       if (err) goto exit_atrim;
 
        return 0;
 
+exit_atrim:
+       device_remove_file(&client->dev, &dev_attr_atrim);
+
+exit_devreg:
+       rtc_device_unregister(rtc);
+
 exit_detach:
        i2c_detach_client(client);
 
index 2af2d9b53d180fff0148fb4ab830ca5fe1c0d135..492b68bcd7cc0e26be5cb44fc192f417c7402954 100644 (file)
@@ -1050,10 +1050,10 @@ dasd_int_handler(struct ccw_device *cdev, unsigned long intparm,
                }
        } else {                /* error */
                memcpy(&cqr->irb, irb, sizeof (struct irb));
-#ifdef ERP_DEBUG
-               /* dump sense data */
-               dasd_log_sense(cqr, irb);
-#endif
+               if (device->features & DASD_FEATURE_ERPLOG) {
+                       /* dump sense data */
+                       dasd_log_sense(cqr, irb);
+               }
                switch (era) {
                case dasd_era_fatal:
                        cqr->status = DASD_CQR_FAILED;
index 669805d4402dcdf628424cb0ff49900db9ba50ad..4d01040c2c63c0523cd49d5fee17fb483ff8520c 100644 (file)
@@ -2641,14 +2641,12 @@ dasd_3990_erp_action(struct dasd_ccw_req * cqr)
        struct dasd_ccw_req *erp = NULL;
        struct dasd_device *device = cqr->device;
        __u32 cpa = cqr->irb.scsw.cpa;
+       struct dasd_ccw_req *temp_erp = NULL;
 
-#ifdef ERP_DEBUG
-       /* print current erp_chain */
-       DEV_MESSAGE(KERN_ERR, device, "%s",
-                   "ERP chain at BEGINNING of ERP-ACTION");
-       {
-               struct dasd_ccw_req *temp_erp = NULL;
-
+       if (device->features & DASD_FEATURE_ERPLOG) {
+               /* print current erp_chain */
+               DEV_MESSAGE(KERN_ERR, device, "%s",
+                           "ERP chain at BEGINNING of ERP-ACTION");
                for (temp_erp = cqr;
                     temp_erp != NULL; temp_erp = temp_erp->refers) {
 
@@ -2658,7 +2656,6 @@ dasd_3990_erp_action(struct dasd_ccw_req * cqr)
                                    temp_erp->refers);
                }
        }
-#endif                         /* ERP_DEBUG */
 
        /* double-check if current erp/cqr was successfull */
        if ((cqr->irb.scsw.cstat == 0x00) &&
@@ -2695,11 +2692,10 @@ dasd_3990_erp_action(struct dasd_ccw_req * cqr)
                erp = dasd_3990_erp_handle_match_erp(cqr, erp);
        }
 
-#ifdef ERP_DEBUG
-       /* print current erp_chain */
-       DEV_MESSAGE(KERN_ERR, device, "%s", "ERP chain at END of ERP-ACTION");
-       {
-               struct dasd_ccw_req *temp_erp = NULL;
+       if (device->features & DASD_FEATURE_ERPLOG) {
+               /* print current erp_chain */
+               DEV_MESSAGE(KERN_ERR, device, "%s",
+                           "ERP chain at END of ERP-ACTION");
                for (temp_erp = erp;
                     temp_erp != NULL; temp_erp = temp_erp->refers) {
 
@@ -2709,7 +2705,6 @@ dasd_3990_erp_action(struct dasd_ccw_req * cqr)
                                    temp_erp->refers);
                }
        }
-#endif                         /* ERP_DEBUG */
 
        if (erp->status == DASD_CQR_FAILED)
                dasd_log_ccw(erp, 1, cpa);
index 17fdd8c9f740107dea18645fcf3133bbfd2ce29d..5943266152f5ec899de2f5a8a98b435328ff8872 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "dasd_int.h"
 
-kmem_cache_t *dasd_page_cache;
+struct kmem_cache *dasd_page_cache;
 EXPORT_SYMBOL_GPL(dasd_page_cache);
 
 /*
@@ -202,6 +202,8 @@ dasd_feature_list(char *str, char **endp)
                        features |= DASD_FEATURE_READONLY;
                else if (len == 4 && !strncmp(str, "diag", 4))
                        features |= DASD_FEATURE_USEDIAG;
+               else if (len == 6 && !strncmp(str, "erplog", 6))
+                       features |= DASD_FEATURE_ERPLOG;
                else {
                        MESSAGE(KERN_WARNING,
                                "unsupported feature: %*s, "
@@ -709,6 +711,52 @@ dasd_ro_store(struct device *dev, struct device_attribute *attr,
 }
 
 static DEVICE_ATTR(readonly, 0644, dasd_ro_show, dasd_ro_store);
+/*
+ * erplog controls the logging of ERP related data
+ * (e.g. failing channel programs).
+ */
+static ssize_t
+dasd_erplog_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct dasd_devmap *devmap;
+       int erplog;
+
+       devmap = dasd_find_busid(dev->bus_id);
+       if (!IS_ERR(devmap))
+               erplog = (devmap->features & DASD_FEATURE_ERPLOG) != 0;
+       else
+               erplog = (DASD_FEATURE_DEFAULT & DASD_FEATURE_ERPLOG) != 0;
+       return snprintf(buf, PAGE_SIZE, erplog ? "1\n" : "0\n");
+}
+
+static ssize_t
+dasd_erplog_store(struct device *dev, struct device_attribute *attr,
+             const char *buf, size_t count)
+{
+       struct dasd_devmap *devmap;
+       int val;
+       char *endp;
+
+       devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
+       if (IS_ERR(devmap))
+               return PTR_ERR(devmap);
+
+       val = simple_strtoul(buf, &endp, 0);
+       if (((endp + 1) < (buf + count)) || (val > 1))
+               return -EINVAL;
+
+       spin_lock(&dasd_devmap_lock);
+       if (val)
+               devmap->features |= DASD_FEATURE_ERPLOG;
+       else
+               devmap->features &= ~DASD_FEATURE_ERPLOG;
+       if (devmap->device)
+               devmap->device->features = devmap->features;
+       spin_unlock(&dasd_devmap_lock);
+       return count;
+}
+
+static DEVICE_ATTR(erplog, 0644, dasd_erplog_show, dasd_erplog_store);
 
 /*
  * use_diag controls whether the driver should use diag rather than ssch
@@ -896,6 +944,7 @@ static struct attribute * dasd_attrs[] = {
        &dev_attr_uid.attr,
        &dev_attr_use_diag.attr,
        &dev_attr_eer_enabled.attr,
+       &dev_attr_erplog.attr,
        NULL,
 };
 
index 5ecea3e4fdefd3a5bdaa8ef0cebc0711dc91028f..fdaa471e845fa78c73ff7a704bada1fb0f0b3ff7 100644 (file)
@@ -1215,7 +1215,7 @@ dasd_eckd_build_cp(struct dasd_device * device, struct request *req)
                dst = page_address(bv->bv_page) + bv->bv_offset;
                if (dasd_page_cache) {
                        char *copy = kmem_cache_alloc(dasd_page_cache,
-                                                     SLAB_DMA | __GFP_NOWARN);
+                                                     GFP_DMA | __GFP_NOWARN);
                        if (copy && rq_data_dir(req) == WRITE)
                                memcpy(copy + bv->bv_offset, dst, bv->bv_len);
                        if (copy)
index 80926c5482281293644f52e06888060e804a9f2a..b857fd5893fdc4d35586e929e3060a070aa5b4d5 100644 (file)
@@ -308,7 +308,7 @@ dasd_fba_build_cp(struct dasd_device * device, struct request *req)
                dst = page_address(bv->bv_page) + bv->bv_offset;
                if (dasd_page_cache) {
                        char *copy = kmem_cache_alloc(dasd_page_cache,
-                                                     SLAB_DMA | __GFP_NOWARN);
+                                                     GFP_DMA | __GFP_NOWARN);
                        if (copy && rq_data_dir(req) == WRITE)
                                memcpy(copy + bv->bv_offset, dst, bv->bv_len);
                        if (copy)
index 9f52004f6fc2f05315485842fabc029e4de4a8c3..fb725e3b08fe4b14b4f5d54b8bd8ea8791f086fa 100644 (file)
 
 #ifdef __KERNEL__
 
-/* erp debugging in dasd.c and dasd_3990_erp.c */
-#define ERP_DEBUG
-
-
 /* we keep old device allocation scheme; IOW, minors are still in 0..255 */
 #define DASD_PER_MAJOR (1U << (MINORBITS - DASD_PARTN_BITS))
 #define DASD_PARTN_MASK ((1 << DASD_PARTN_BITS) - 1)
@@ -474,7 +470,7 @@ extern struct dasd_profile_info_t dasd_global_profile;
 extern unsigned int dasd_profile_level;
 extern struct block_device_operations dasd_device_operations;
 
-extern kmem_cache_t *dasd_page_cache;
+extern struct kmem_cache *dasd_page_cache;
 
 struct dasd_ccw_req *
 dasd_kmalloc_request(char *, int, int, struct dasd_device *);
index 8fed3603e9eac2afe7163b76011e3e18b0084855..758cfb54286570b2333998adcf2180bf20ee32c5 100644 (file)
@@ -430,7 +430,7 @@ dasd_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        int rval;
 
        lock_kernel();
-       rval = dasd_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
+       rval = dasd_ioctl(filp->f_path.dentry->d_inode, filp, cmd, arg);
        unlock_kernel();
 
        return (rval == -EINVAL) ? -ENOIOCTLCMD : rval;
index 49e9628d9297d632c1b20847957f811bde719f48..c6cbcb3f925e094445d1935a6e44df791ea61f10 100644 (file)
 
 #ifdef CONFIG_MAGIC_SYSRQ
 static int ctrlchar_sysrq_key;
+static struct tty_struct *sysrq_tty;
 
 static void
-ctrlchar_handle_sysrq(void *tty)
+ctrlchar_handle_sysrq(struct work_struct *work)
 {
-       handle_sysrq(ctrlchar_sysrq_key, (struct tty_struct *) tty);
+       handle_sysrq(ctrlchar_sysrq_key, sysrq_tty);
 }
 
-static DECLARE_WORK(ctrlchar_work, ctrlchar_handle_sysrq, NULL);
+static DECLARE_WORK(ctrlchar_work, ctrlchar_handle_sysrq);
 #endif
 
 
@@ -53,7 +54,7 @@ ctrlchar_handle(const unsigned char *buf, int len, struct tty_struct *tty)
        /* racy */
        if (len == 3 && buf[1] == '-') {
                ctrlchar_sysrq_key = buf[2];
-               ctrlchar_work.data = tty;
+               sysrq_tty = tty;
                schedule_work(&ctrlchar_work);
                return CTRLCHAR_SYSRQ;
        }
index 78f8bda81daee67e38fc651c6988b66b940890a8..0893d306ae8094d10f512fc19fa4b1d288c5040a 100644 (file)
@@ -419,16 +419,20 @@ fs3270_open(struct inode *inode, struct file *filp)
        struct idal_buffer *ib;
        int minor, rc;
 
-       if (imajor(filp->f_dentry->d_inode) != IBM_FS3270_MAJOR)
+       if (imajor(filp->f_path.dentry->d_inode) != IBM_FS3270_MAJOR)
                return -ENODEV;
-       minor = iminor(filp->f_dentry->d_inode);
+       minor = iminor(filp->f_path.dentry->d_inode);
        /* Check for minor 0 multiplexer. */
        if (minor == 0) {
-               if (!current->signal->tty)
+               struct tty_struct *tty;
+               mutex_lock(&tty_mutex);
+               tty = get_current_tty();
+               if (!tty || tty->driver->major != IBM_TTY3270_MAJOR) {
+                       mutex_unlock(&tty_mutex);
                        return -ENODEV;
-               if (current->signal->tty->driver->major != IBM_TTY3270_MAJOR)
-                       return -ENODEV;
-               minor = current->signal->tty->index + RAW3270_FIRSTMINOR;
+               }
+               minor = tty->index + RAW3270_FIRSTMINOR;
+               mutex_unlock(&tty_mutex);
        }
        /* Check if some other program is already using fullscreen mode. */
        fp = (struct fs3270 *) raw3270_find_view(&fs3270_fn, minor);
index 6f43e04dbefdce1e57eee86bfd94960a7488d89d..2d173e5c8a098514d5f23f136bbe775122bc920e 100644 (file)
@@ -60,8 +60,6 @@ static unsigned short int sclp_tty_chars_count;
 
 struct tty_driver *sclp_tty_driver;
 
-extern struct termios  tty_std_termios;
-
 static struct sclp_ioctls sclp_ioctls;
 static struct sclp_ioctls sclp_ioctls_init =
 {
index 1f4c89967be4f0b7c742cba55455ed284a202121..c9f1c4c8bb134be37e6542fe1c27b1321075bcb5 100644 (file)
@@ -179,6 +179,7 @@ struct tape_char_data {
 /* Block Frontend Data */
 struct tape_blk_data
 {
+       struct tape_device *    device;
        /* Block device request queue. */
        request_queue_t *       request_queue;
        spinlock_t              request_queue_lock;
@@ -240,7 +241,7 @@ struct tape_device {
 #endif
 
        /* Function to start or stop the next request later. */
-       struct work_struct              tape_dnr;
+       struct delayed_work             tape_dnr;
 };
 
 /* Externals from tape_core.c */
index 7b95dab913d0240847abe36830373595ba551aa8..e765875e8db2eb4fb4ae3c0a4b6a03d8215bcaa4 100644 (file)
@@ -95,6 +95,12 @@ tape_34xx_medium_sense(struct tape_device *device)
        return rc;
 }
 
+struct tape_34xx_work {
+       struct tape_device      *device;
+       enum tape_op             op;
+       struct work_struct       work;
+};
+
 /*
  * These functions are currently used only to schedule a medium_sense for
  * later execution. This is because we get an interrupt whenever a medium
@@ -103,13 +109,10 @@ tape_34xx_medium_sense(struct tape_device *device)
  * interrupt handler.
  */
 static void
-tape_34xx_work_handler(void *data)
+tape_34xx_work_handler(struct work_struct *work)
 {
-       struct {
-               struct tape_device      *device;
-               enum tape_op             op;
-               struct work_struct       work;
-       } *p = data;
+       struct tape_34xx_work *p =
+               container_of(work, struct tape_34xx_work, work);
 
        switch(p->op) {
                case TO_MSEN:
@@ -126,17 +129,13 @@ tape_34xx_work_handler(void *data)
 static int
 tape_34xx_schedule_work(struct tape_device *device, enum tape_op op)
 {
-       struct {
-               struct tape_device      *device;
-               enum tape_op             op;
-               struct work_struct       work;
-       } *p;
+       struct tape_34xx_work *p;
 
        if ((p = kmalloc(sizeof(*p), GFP_ATOMIC)) == NULL)
                return -ENOMEM;
 
        memset(p, 0, sizeof(*p));
-       INIT_WORK(&p->work, tape_34xx_work_handler, p);
+       INIT_WORK(&p->work, tape_34xx_work_handler);
 
        p->device = tape_get_device_reference(device);
        p->op     = op;
index 928cbefc49d5959932f501b183487254e578f0c2..9df912f63188462f08990294c9e2366c80a2b632 100644 (file)
@@ -236,9 +236,10 @@ struct work_handler_data {
 };
 
 static void
-tape_3590_work_handler(void *data)
+tape_3590_work_handler(struct work_struct *work)
 {
-       struct work_handler_data *p = data;
+       struct work_handler_data *p =
+               container_of(work, struct work_handler_data, work);
 
        switch (p->op) {
        case TO_MSEN:
@@ -263,7 +264,7 @@ tape_3590_schedule_work(struct tape_device *device, enum tape_op op)
        if ((p = kzalloc(sizeof(*p), GFP_ATOMIC)) == NULL)
                return -ENOMEM;
 
-       INIT_WORK(&p->work, tape_3590_work_handler, p);
+       INIT_WORK(&p->work, tape_3590_work_handler);
 
        p->device = tape_get_device_reference(device);
        p->op = op;
index 3225fcd1dcb47eb41d86a5b2e4ea7cd18a208971..c8a89b3b87d4a2f421591779728bbc915b4af10d 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/blkdev.h>
 #include <linux/interrupt.h>
 #include <linux/buffer_head.h>
+#include <linux/kernel.h>
 
 #include <asm/debug.h>
 
@@ -143,7 +144,8 @@ tapeblock_start_request(struct tape_device *device, struct request *req)
  * queue.
  */
 static void
-tapeblock_requeue(void *data) {
+tapeblock_requeue(struct work_struct *work) {
+       struct tape_blk_data *  blkdat;
        struct tape_device *    device;
        request_queue_t *       queue;
        int                     nr_queued;
@@ -151,7 +153,8 @@ tapeblock_requeue(void *data) {
        struct list_head *      l;
        int                     rc;
 
-       device = (struct tape_device *) data;
+       blkdat = container_of(work, struct tape_blk_data, requeue_task);
+       device = blkdat->device;
        if (!device)
                return;
 
@@ -212,6 +215,7 @@ tapeblock_setup_device(struct tape_device * device)
        int                     rc;
 
        blkdat = &device->blk_data;
+       blkdat->device = device;
        spin_lock_init(&blkdat->request_queue_lock);
        atomic_set(&blkdat->requeue_scheduled, 0);
 
@@ -255,8 +259,8 @@ tapeblock_setup_device(struct tape_device * device)
 
        add_disk(disk);
 
-       INIT_WORK(&blkdat->requeue_task, tapeblock_requeue,
-               tape_get_device_reference(device));
+       tape_get_device_reference(device);
+       INIT_WORK(&blkdat->requeue_task, tapeblock_requeue);
 
        return 0;
 
@@ -271,7 +275,7 @@ void
 tapeblock_cleanup_device(struct tape_device *device)
 {
        flush_scheduled_work();
-       device->blk_data.requeue_task.data = tape_put_device(device);
+       tape_put_device(device);
 
        if (!device->blk_data.disk) {
                PRINT_ERR("(%s): No gendisk to clean up!\n",
index 97f75237bed6cbc3b2d64767a8e915e4eeee6740..31198c8f27182701af403025a0078b5cbf554eaa 100644 (file)
@@ -298,13 +298,13 @@ tapechar_open (struct inode *inode, struct file *filp)
        int minor, rc;
 
        DBF_EVENT(6, "TCHAR:open: %i:%i\n",
-               imajor(filp->f_dentry->d_inode),
-               iminor(filp->f_dentry->d_inode));
+               imajor(filp->f_path.dentry->d_inode),
+               iminor(filp->f_path.dentry->d_inode));
 
-       if (imajor(filp->f_dentry->d_inode) != tapechar_major)
+       if (imajor(filp->f_path.dentry->d_inode) != tapechar_major)
                return -ENODEV;
 
-       minor = iminor(filp->f_dentry->d_inode);
+       minor = iminor(filp->f_path.dentry->d_inode);
        device = tape_get_device(minor / TAPE_MINORS_PER_DEV);
        if (IS_ERR(device)) {
                DBF_EVENT(3, "TCHAR:open: tape_get_device() failed\n");
index 2826aed910432d948eb7bbd82ca2ac8239686128..c6c2e918b990d3645bb5e384f9de4b4aae5804c4 100644 (file)
@@ -28,7 +28,7 @@
 #define PRINTK_HEADER "TAPE_CORE: "
 
 static void __tape_do_irq (struct ccw_device *, unsigned long, struct irb *);
-static void tape_delayed_next_request(void * data);
+static void tape_delayed_next_request(struct work_struct *);
 
 /*
  * One list to contain all tape devices of all disciplines, so
@@ -272,7 +272,7 @@ __tape_cancel_io(struct tape_device *device, struct tape_request *request)
                                return 0;
                        case -EBUSY:
                                request->status = TAPE_REQUEST_CANCEL;
-                               schedule_work(&device->tape_dnr);
+                               schedule_delayed_work(&device->tape_dnr, 0);
                                return 0;
                        case -ENODEV:
                                DBF_EXCEPTION(2, "device gone, retry\n");
@@ -470,7 +470,7 @@ tape_alloc_device(void)
        *device->modeset_byte = 0;
        device->first_minor = -1;
        atomic_set(&device->ref_count, 1);
-       INIT_WORK(&device->tape_dnr, tape_delayed_next_request, device);
+       INIT_DELAYED_WORK(&device->tape_dnr, tape_delayed_next_request);
 
        return device;
 }
@@ -724,7 +724,7 @@ __tape_start_io(struct tape_device *device, struct tape_request *request)
        } else if (rc == -EBUSY) {
                /* The common I/O subsystem is currently busy. Retry later. */
                request->status = TAPE_REQUEST_QUEUED;
-               schedule_work(&device->tape_dnr);
+               schedule_delayed_work(&device->tape_dnr, 0);
                rc = 0;
        } else {
                /* Start failed. Remove request and indicate failure. */
@@ -790,11 +790,11 @@ __tape_start_next_request(struct tape_device *device)
 }
 
 static void
-tape_delayed_next_request(void *data)
+tape_delayed_next_request(struct work_struct *work)
 {
-       struct tape_device *    device;
+       struct tape_device *device =
+               container_of(work, struct tape_device, tape_dnr.work);
 
-       device = (struct tape_device *) data;
        DBF_LH(6, "tape_delayed_next_request(%p)\n", device);
        spin_lock_irq(get_ccwdev_lock(device->cdev));
        __tape_start_next_request(device);
index 4717c3611601f308094f588238a5b6c8c039cbd9..09844621edc0f5e9d2476fd019e57ffb2af42506 100644 (file)
@@ -1659,7 +1659,7 @@ tty3270_flush_buffer(struct tty_struct *tty)
  * Check for visible/invisible input switches
  */
 static void
-tty3270_set_termios(struct tty_struct *tty, struct termios *old)
+tty3270_set_termios(struct tty_struct *tty, struct ktermios *old)
 {
        struct tty3270 *tp;
        int new;
index dbfb77b03928ee3b59741bac5a1e2a32add8b71e..cbab8d2ce5cfd664b82fd6f189a0fbc9dfbbfb38 100644 (file)
@@ -183,7 +183,7 @@ css_get_ssd_info(struct subchannel *sch)
        page = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
        if (!page)
                return -ENOMEM;
-       spin_lock_irq(&sch->lock);
+       spin_lock_irq(sch->lock);
        ret = chsc_get_sch_desc_irq(sch, page);
        if (ret) {
                static int cio_chsc_err_msg;
@@ -197,7 +197,7 @@ css_get_ssd_info(struct subchannel *sch)
                        cio_chsc_err_msg = 1;
                }
        }
-       spin_unlock_irq(&sch->lock);
+       spin_unlock_irq(sch->lock);
        free_page((unsigned long)page);
        if (!ret) {
                int j, chpid, mask;
@@ -233,7 +233,7 @@ s390_subchannel_remove_chpid(struct device *dev, void *data)
        if (j >= 8)
                return 0;
 
-       spin_lock_irq(&sch->lock);
+       spin_lock_irq(sch->lock);
 
        stsch(sch->schid, &schib);
        if (!schib.pmcw.dnv)
@@ -265,10 +265,10 @@ s390_subchannel_remove_chpid(struct device *dev, void *data)
        else if (sch->lpm == mask)
                goto out_unreg;
 out_unlock:
-       spin_unlock_irq(&sch->lock);
+       spin_unlock_irq(sch->lock);
        return 0;
 out_unreg:
-       spin_unlock_irq(&sch->lock);
+       spin_unlock_irq(sch->lock);
        sch->lpm = 0;
        if (css_enqueue_subchannel_slow(sch->schid)) {
                css_clear_subchannel_slow_list();
@@ -378,12 +378,12 @@ __s390_process_res_acc(struct subchannel_id schid, void *data)
                /* Check if a subchannel is newly available. */
                return s390_process_res_acc_new_sch(schid);
 
-       spin_lock_irq(&sch->lock);
+       spin_lock_irq(sch->lock);
 
        chp_mask = s390_process_res_acc_sch(res_data, sch);
 
        if (chp_mask == 0) {
-               spin_unlock_irq(&sch->lock);
+               spin_unlock_irq(sch->lock);
                put_device(&sch->dev);
                return 0;
        }
@@ -397,7 +397,7 @@ __s390_process_res_acc(struct subchannel_id schid, void *data)
        else if (sch->driver && sch->driver->verify)
                sch->driver->verify(&sch->dev);
 
-       spin_unlock_irq(&sch->lock);
+       spin_unlock_irq(sch->lock);
        put_device(&sch->dev);
        return 0;
 }
@@ -635,21 +635,21 @@ __chp_add(struct subchannel_id schid, void *data)
        if (!sch)
                /* Check if the subchannel is now available. */
                return __chp_add_new_sch(schid);
-       spin_lock_irq(&sch->lock);
+       spin_lock_irq(sch->lock);
        for (i=0; i<8; i++) {
                mask = 0x80 >> i;
                if ((sch->schib.pmcw.pim & mask) &&
                    (sch->schib.pmcw.chpid[i] == chp->id)) {
                        if (stsch(sch->schid, &sch->schib) != 0) {
                                /* Endgame. */
-                               spin_unlock_irq(&sch->lock);
+                               spin_unlock_irq(sch->lock);
                                return -ENXIO;
                        }
                        break;
                }
        }
        if (i==8) {
-               spin_unlock_irq(&sch->lock);
+               spin_unlock_irq(sch->lock);
                return 0;
        }
        sch->lpm = ((sch->schib.pmcw.pim &
@@ -660,7 +660,7 @@ __chp_add(struct subchannel_id schid, void *data)
        if (sch->driver && sch->driver->verify)
                sch->driver->verify(&sch->dev);
 
-       spin_unlock_irq(&sch->lock);
+       spin_unlock_irq(sch->lock);
        put_device(&sch->dev);
        return 0;
 }
@@ -750,7 +750,7 @@ __s390_subchannel_vary_chpid(struct subchannel *sch, __u8 chpid, int on)
        if (!sch->ssd_info.valid)
                return;
        
-       spin_lock_irqsave(&sch->lock, flags);
+       spin_lock_irqsave(sch->lock, flags);
        old_lpm = sch->lpm;
        for (chp = 0; chp < 8; chp++) {
                if (sch->ssd_info.chpid[chp] != chpid)
@@ -785,7 +785,7 @@ __s390_subchannel_vary_chpid(struct subchannel *sch, __u8 chpid, int on)
                        sch->driver->verify(&sch->dev);
                break;
        }
-       spin_unlock_irqrestore(&sch->lock, flags);
+       spin_unlock_irqrestore(sch->lock, flags);
 }
 
 static int
index 20aee27838472139b0a0ce07f633cd5f5da8f2c8..7835a714a405c90018dc8fa2aea49f415c829851 100644 (file)
@@ -143,11 +143,11 @@ cio_tpi(void)
                return 1;
        local_bh_disable();
        irq_enter ();
-       spin_lock(&sch->lock);
+       spin_lock(sch->lock);
        memcpy (&sch->schib.scsw, &irb->scsw, sizeof (struct scsw));
        if (sch->driver && sch->driver->irq)
                sch->driver->irq(&sch->dev);
-       spin_unlock(&sch->lock);
+       spin_unlock(sch->lock);
        irq_exit ();
        _local_bh_enable();
        return 1;
@@ -415,6 +415,8 @@ cio_enable_subchannel (struct subchannel *sch, unsigned int isc)
        CIO_TRACE_EVENT (2, "ensch");
        CIO_TRACE_EVENT (2, sch->dev.bus_id);
 
+       if (sch_is_pseudo_sch(sch))
+               return -EINVAL;
        ccode = stsch (sch->schid, &sch->schib);
        if (ccode)
                return -ENODEV;
@@ -462,6 +464,8 @@ cio_disable_subchannel (struct subchannel *sch)
        CIO_TRACE_EVENT (2, "dissch");
        CIO_TRACE_EVENT (2, sch->dev.bus_id);
 
+       if (sch_is_pseudo_sch(sch))
+               return 0;
        ccode = stsch (sch->schid, &sch->schib);
        if (ccode == 3)         /* Not operational. */
                return -ENODEV;
@@ -496,6 +500,15 @@ cio_disable_subchannel (struct subchannel *sch)
        return ret;
 }
 
+int cio_create_sch_lock(struct subchannel *sch)
+{
+       sch->lock = kmalloc(sizeof(spinlock_t), GFP_KERNEL);
+       if (!sch->lock)
+               return -ENOMEM;
+       spin_lock_init(sch->lock);
+       return 0;
+}
+
 /*
  * cio_validate_subchannel()
  *
@@ -513,6 +526,7 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid)
 {
        char dbf_txt[15];
        int ccode;
+       int err;
 
        sprintf (dbf_txt, "valsch%x", schid.sch_no);
        CIO_TRACE_EVENT (4, dbf_txt);
@@ -520,9 +534,15 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid)
        /* Nuke all fields. */
        memset(sch, 0, sizeof(struct subchannel));
 
-       spin_lock_init(&sch->lock);
+       sch->schid = schid;
+       if (cio_is_console(schid)) {
+               sch->lock = cio_get_console_lock();
+       } else {
+               err = cio_create_sch_lock(sch);
+               if (err)
+                       goto out;
+       }
        mutex_init(&sch->reg_mutex);
-
        /* Set a name for the subchannel */
        snprintf (sch->dev.bus_id, BUS_ID_SIZE, "0.%x.%04x", schid.ssid,
                  schid.sch_no);
@@ -534,10 +554,10 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid)
         *  is not valid.
         */
        ccode = stsch_err (schid, &sch->schib);
-       if (ccode)
-               return (ccode == 3) ? -ENXIO : ccode;
-
-       sch->schid = schid;
+       if (ccode) {
+               err = (ccode == 3) ? -ENXIO : ccode;
+               goto out;
+       }
        /* Copy subchannel type from path management control word. */
        sch->st = sch->schib.pmcw.st;
 
@@ -550,14 +570,16 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid)
                          "non-I/O subchannel type %04X\n",
                          sch->schid.ssid, sch->schid.sch_no, sch->st);
                /* We stop here for non-io subchannels. */
-               return sch->st;
+               err = sch->st;
+               goto out;
        }
 
        /* Initialization for io subchannels. */
-       if (!sch->schib.pmcw.dnv)
+       if (!sch->schib.pmcw.dnv) {
                /* io subchannel but device number is invalid. */
-               return -ENODEV;
-
+               err = -ENODEV;
+               goto out;
+       }
        /* Devno is valid. */
        if (is_blacklisted (sch->schid.ssid, sch->schib.pmcw.dev)) {
                /*
@@ -567,7 +589,8 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid)
                CIO_MSG_EVENT(0, "Blacklisted device detected "
                              "at devno %04X, subchannel set %x\n",
                              sch->schib.pmcw.dev, sch->schid.ssid);
-               return -ENODEV;
+               err = -ENODEV;
+               goto out;
        }
        sch->opm = 0xff;
        if (!cio_is_console(sch->schid))
@@ -595,6 +618,11 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid)
        if ((sch->lpm & (sch->lpm - 1)) != 0)
                sch->schib.pmcw.mp = 1; /* multipath mode */
        return 0;
+out:
+       if (!cio_is_console(schid))
+               kfree(sch->lock);
+       sch->lock = NULL;
+       return err;
 }
 
 /*
@@ -637,7 +665,7 @@ do_IRQ (struct pt_regs *regs)
                }
                sch = (struct subchannel *)(unsigned long)tpi_info->intparm;
                if (sch)
-                       spin_lock(&sch->lock);
+                       spin_lock(sch->lock);
                /* Store interrupt response block to lowcore. */
                if (tsch (tpi_info->schid, irb) == 0 && sch) {
                        /* Keep subchannel information word up to date. */
@@ -648,7 +676,7 @@ do_IRQ (struct pt_regs *regs)
                                sch->driver->irq(&sch->dev);
                }
                if (sch)
-                       spin_unlock(&sch->lock);
+                       spin_unlock(sch->lock);
                /*
                 * Are more interrupts pending?
                 * If so, the tpi instruction will update the lowcore
@@ -687,10 +715,10 @@ wait_cons_dev (void)
        __ctl_load (cr6, 6, 6);
 
        do {
-               spin_unlock(&console_subchannel.lock);
+               spin_unlock(console_subchannel.lock);
                if (!cio_tpi())
                        cpu_relax();
-               spin_lock(&console_subchannel.lock);
+               spin_lock(console_subchannel.lock);
        } while (console_subchannel.schib.scsw.actl != 0);
        /*
         * restore previous isc value
index 4541c1af4b666aac7152bcbf9ef593a46074a0ef..35154a21035720f9f9ffd355577e7288cbb92761 100644 (file)
@@ -87,7 +87,7 @@ struct orb {
 /* subchannel data structure used by I/O subroutines */
 struct subchannel {
        struct subchannel_id schid;
-       spinlock_t lock;        /* subchannel lock */
+       spinlock_t *lock;       /* subchannel lock */
        struct mutex reg_mutex;
        enum {
                SUBCHANNEL_TYPE_IO = 0,
@@ -131,15 +131,19 @@ extern int cio_set_options (struct subchannel *, int);
 extern int cio_get_options (struct subchannel *);
 extern int cio_modify (struct subchannel *);
 
+int cio_create_sch_lock(struct subchannel *);
+
 /* Use with care. */
 #ifdef CONFIG_CCW_CONSOLE
 extern struct subchannel *cio_probe_console(void);
 extern void cio_release_console(void);
 extern int cio_is_console(struct subchannel_id);
 extern struct subchannel *cio_get_console_subchannel(void);
+extern spinlock_t * cio_get_console_lock(void);
 #else
 #define cio_is_console(schid) 0
 #define cio_get_console_subchannel() NULL
+#define cio_get_console_lock() NULL;
 #endif
 
 extern int cio_show_msg;
index 26cf2f5ae2e75bfedcd22397b69850f7eebd229c..4c81d890791e48d1c04b001d842af56a49301c00 100644 (file)
@@ -91,9 +91,9 @@ css_free_subchannel(struct subchannel *sch)
                /* Reset intparm to zeroes. */
                sch->schib.pmcw.intparm = 0;
                cio_modify(sch);
+               kfree(sch->lock);
                kfree(sch);
        }
-       
 }
 
 static void
@@ -102,8 +102,10 @@ css_subchannel_release(struct device *dev)
        struct subchannel *sch;
 
        sch = to_subchannel(dev);
-       if (!cio_is_console(sch->schid))
+       if (!cio_is_console(sch->schid)) {
+               kfree(sch->lock);
                kfree(sch);
+       }
 }
 
 extern int css_get_ssd_info(struct subchannel *sch);
@@ -135,14 +137,16 @@ css_register_subchannel(struct subchannel *sch)
        sch->dev.parent = &css[0]->device;
        sch->dev.bus = &css_bus_type;
        sch->dev.release = &css_subchannel_release;
-       
+       sch->dev.groups = subch_attr_groups;
+
        /* make it known to the system */
        ret = css_sch_device_register(sch);
-       if (ret)
+       if (ret) {
                printk (KERN_WARNING "%s: could not register %s\n",
                        __func__, sch->dev.bus_id);
-       else
-               css_get_ssd_info(sch);
+               return ret;
+       }
+       css_get_ssd_info(sch);
        return ret;
 }
 
@@ -201,18 +205,18 @@ static int css_evaluate_known_subchannel(struct subchannel *sch, int slow)
        unsigned long flags;
        enum { NONE, UNREGISTER, UNREGISTER_PROBE, REPROBE } action;
 
-       spin_lock_irqsave(&sch->lock, flags);
+       spin_lock_irqsave(sch->lock, flags);
        disc = device_is_disconnected(sch);
        if (disc && slow) {
                /* Disconnected devices are evaluated directly only.*/
-               spin_unlock_irqrestore(&sch->lock, flags);
+               spin_unlock_irqrestore(sch->lock, flags);
                return 0;
        }
        /* No interrupt after machine check - kill pending timers. */
        device_kill_pending_timer(sch);
        if (!disc && !slow) {
                /* Non-disconnected devices are evaluated on the slow path. */
-               spin_unlock_irqrestore(&sch->lock, flags);
+               spin_unlock_irqrestore(sch->lock, flags);
                return -EAGAIN;
        }
        event = css_get_subchannel_status(sch);
@@ -237,9 +241,9 @@ static int css_evaluate_known_subchannel(struct subchannel *sch, int slow)
                /* Ask driver what to do with device. */
                action = UNREGISTER;
                if (sch->driver && sch->driver->notify) {
-                       spin_unlock_irqrestore(&sch->lock, flags);
+                       spin_unlock_irqrestore(sch->lock, flags);
                        ret = sch->driver->notify(&sch->dev, event);
-                       spin_lock_irqsave(&sch->lock, flags);
+                       spin_lock_irqsave(sch->lock, flags);
                        if (ret)
                                action = NONE;
                }
@@ -264,9 +268,9 @@ static int css_evaluate_known_subchannel(struct subchannel *sch, int slow)
        case UNREGISTER:
        case UNREGISTER_PROBE:
                /* Unregister device (will use subchannel lock). */
-               spin_unlock_irqrestore(&sch->lock, flags);
+               spin_unlock_irqrestore(sch->lock, flags);
                css_sch_device_unregister(sch);
-               spin_lock_irqsave(&sch->lock, flags);
+               spin_lock_irqsave(sch->lock, flags);
 
                /* Reset intparm to zeroes. */
                sch->schib.pmcw.intparm = 0;
@@ -278,7 +282,7 @@ static int css_evaluate_known_subchannel(struct subchannel *sch, int slow)
        default:
                break;
        }
-       spin_unlock_irqrestore(&sch->lock, flags);
+       spin_unlock_irqrestore(sch->lock, flags);
        /* Probe if necessary. */
        if (action == UNREGISTER_PROBE)
                ret = css_probe_device(sch->schid);
@@ -573,12 +577,24 @@ css_cm_enable_store(struct device *dev, struct device_attribute *attr,
 
 static DEVICE_ATTR(cm_enable, 0644, css_cm_enable_show, css_cm_enable_store);
 
-static inline void __init
-setup_css(int nr)
+static inline int __init setup_css(int nr)
 {
        u32 tod_high;
+       int ret;
 
        memset(css[nr], 0, sizeof(struct channel_subsystem));
+       css[nr]->pseudo_subchannel =
+               kzalloc(sizeof(*css[nr]->pseudo_subchannel), GFP_KERNEL);
+       if (!css[nr]->pseudo_subchannel)
+               return -ENOMEM;
+       css[nr]->pseudo_subchannel->dev.parent = &css[nr]->device;
+       css[nr]->pseudo_subchannel->dev.release = css_subchannel_release;
+       sprintf(css[nr]->pseudo_subchannel->dev.bus_id, "defunct");
+       ret = cio_create_sch_lock(css[nr]->pseudo_subchannel);
+       if (ret) {
+               kfree(css[nr]->pseudo_subchannel);
+               return ret;
+       }
        mutex_init(&css[nr]->mutex);
        css[nr]->valid = 1;
        css[nr]->cssid = nr;
@@ -586,6 +602,7 @@ setup_css(int nr)
        css[nr]->device.release = channel_subsystem_release;
        tod_high = (u32) (get_clock() >> 32);
        css_generate_pgid(css[nr], tod_high);
+       return 0;
 }
 
 /*
@@ -622,10 +639,12 @@ init_channel_subsystem (void)
                        ret = -ENOMEM;
                        goto out_unregister;
                }
-               setup_css(i);
-               ret = device_register(&css[i]->device);
+               ret = setup_css(i);
                if (ret)
                        goto out_free;
+               ret = device_register(&css[i]->device);
+               if (ret)
+                       goto out_free_all;
                if (css_characteristics_avail &&
                    css_chsc_characteristics.secm) {
                        ret = device_create_file(&css[i]->device,
@@ -633,6 +652,9 @@ init_channel_subsystem (void)
                        if (ret)
                                goto out_device;
                }
+               ret = device_register(&css[i]->pseudo_subchannel->dev);
+               if (ret)
+                       goto out_file;
        }
        css_init_done = 1;
 
@@ -640,13 +662,19 @@ init_channel_subsystem (void)
 
        for_each_subchannel(__init_channel_subsystem, NULL);
        return 0;
+out_file:
+       device_remove_file(&css[i]->device, &dev_attr_cm_enable);
 out_device:
        device_unregister(&css[i]->device);
+out_free_all:
+       kfree(css[i]->pseudo_subchannel->lock);
+       kfree(css[i]->pseudo_subchannel);
 out_free:
        kfree(css[i]);
 out_unregister:
        while (i > 0) {
                i--;
+               device_unregister(&css[i]->pseudo_subchannel->dev);
                if (css_characteristics_avail && css_chsc_characteristics.secm)
                        device_remove_file(&css[i]->device,
                                           &dev_attr_cm_enable);
@@ -658,6 +686,11 @@ out:
        return ret;
 }
 
+int sch_is_pseudo_sch(struct subchannel *sch)
+{
+       return sch == to_css(sch->dev.parent)->pseudo_subchannel;
+}
+
 /*
  * find a driver for a subchannel. They identify by the subchannel
  * type with the exception that the console subchannel driver has its own
index 9ff064e71767657480ae3ee5dc185a05e334cd96..3464c5b875c470d8436f8054c740ff6a17f661f0 100644 (file)
@@ -73,6 +73,8 @@ struct senseid {
 }  __attribute__ ((packed,aligned(4)));
 
 struct ccw_device_private {
+       struct ccw_device *cdev;
+       struct subchannel *sch;
        int state;              /* device state */
        atomic_t onoff;
        unsigned long registered;
@@ -158,6 +160,8 @@ struct channel_subsystem {
        int cm_enabled;
        void *cub_addr1;
        void *cub_addr2;
+       /* for orphaned ccw devices */
+       struct subchannel *pseudo_subchannel;
 };
 #define to_css(dev) container_of(dev, struct channel_subsystem, device)
 
@@ -185,6 +189,11 @@ void css_clear_subchannel_slow_list(void);
 int css_slow_subchannels_exist(void);
 extern int need_rescan;
 
+int sch_is_pseudo_sch(struct subchannel *);
+
 extern struct workqueue_struct *slow_path_wq;
 extern struct work_struct slow_path_work;
+
+int subchannel_add_files (struct device *);
+extern struct attribute_group *subch_attr_groups[];
 #endif
index d3d3716ff84b6b317d6244fd67971eb494fa6cca..803579053c2fe012dbf4854b13c12baa156a8f86 100644 (file)
@@ -23,6 +23,7 @@
 #include <asm/param.h>         /* HZ */
 
 #include "cio.h"
+#include "cio_debug.h"
 #include "css.h"
 #include "device.h"
 #include "ioasm.h"
@@ -234,9 +235,11 @@ chpids_show (struct device * dev, struct device_attribute *attr, char * buf)
        ssize_t ret = 0;
        int chp;
 
-       for (chp = 0; chp < 8; chp++)
-               ret += sprintf (buf+ret, "%02x ", ssd->chpid[chp]);
-
+       if (ssd)
+               for (chp = 0; chp < 8; chp++)
+                       ret += sprintf (buf+ret, "%02x ", ssd->chpid[chp]);
+       else
+               ret += sprintf (buf, "n/a");
        ret += sprintf (buf+ret, "\n");
        return min((ssize_t)PAGE_SIZE, ret);
 }
@@ -294,14 +297,44 @@ online_show (struct device *dev, struct device_attribute *attr, char *buf)
        return sprintf(buf, cdev->online ? "1\n" : "0\n");
 }
 
+int ccw_device_is_orphan(struct ccw_device *cdev)
+{
+       return sch_is_pseudo_sch(to_subchannel(cdev->dev.parent));
+}
+
+static void ccw_device_unregister(struct work_struct *work)
+{
+       struct ccw_device_private *priv;
+       struct ccw_device *cdev;
+
+       priv = container_of(work, struct ccw_device_private, kick_work);
+       cdev = priv->cdev;
+       if (test_and_clear_bit(1, &cdev->private->registered))
+               device_unregister(&cdev->dev);
+       put_device(&cdev->dev);
+}
+
 static void
 ccw_device_remove_disconnected(struct ccw_device *cdev)
 {
        struct subchannel *sch;
+       unsigned long flags;
        /*
         * Forced offline in disconnected state means
         * 'throw away device'.
         */
+       if (ccw_device_is_orphan(cdev)) {
+               /* Deregister ccw device. */
+               spin_lock_irqsave(cdev->ccwlock, flags);
+               cdev->private->state = DEV_STATE_NOT_OPER;
+               spin_unlock_irqrestore(cdev->ccwlock, flags);
+               if (get_device(&cdev->dev)) {
+                       PREPARE_WORK(&cdev->private->kick_work,
+                                    ccw_device_unregister);
+                       queue_work(ccw_device_work, &cdev->private->kick_work);
+               }
+               return ;
+       }
        sch = to_subchannel(cdev->dev.parent);
        css_sch_device_unregister(sch);
        /* Reset intparm to zeroes. */
@@ -462,6 +495,8 @@ available_show (struct device *dev, struct device_attribute *attr, char *buf)
        struct ccw_device *cdev = to_ccwdev(dev);
        struct subchannel *sch;
 
+       if (ccw_device_is_orphan(cdev))
+               return sprintf(buf, "no device\n");
        switch (cdev->private->state) {
        case DEV_STATE_BOXED:
                return sprintf(buf, "boxed\n");
@@ -498,11 +533,10 @@ static struct attribute_group subch_attr_group = {
        .attrs = subch_attrs,
 };
 
-static inline int
-subchannel_add_files (struct device *dev)
-{
-       return sysfs_create_group(&dev->kobj, &subch_attr_group);
-}
+struct attribute_group *subch_attr_groups[] = {
+       &subch_attr_group,
+       NULL,
+};
 
 static struct attribute * ccwdev_attrs[] = {
        &dev_attr_devtype.attr,
@@ -563,11 +597,10 @@ match_devno(struct device * dev, void * data)
 
        cdev = to_ccwdev(dev);
        if ((cdev->private->state == DEV_STATE_DISCONNECTED) &&
+           !ccw_device_is_orphan(cdev) &&
            ccw_dev_id_is_equal(&cdev->private->dev_id, &d->dev_id) &&
-           (cdev != d->sibling)) {
-               cdev->private->state = DEV_STATE_NOT_OPER;
+           (cdev != d->sibling))
                return 1;
-       }
        return 0;
 }
 
@@ -584,13 +617,36 @@ static struct ccw_device * get_disc_ccwdev_by_dev_id(struct ccw_dev_id *dev_id,
        return dev ? to_ccwdev(dev) : NULL;
 }
 
-static void
-ccw_device_add_changed(void *data)
+static int match_orphan(struct device *dev, void *data)
+{
+       struct ccw_dev_id *dev_id;
+       struct ccw_device *cdev;
+
+       dev_id = data;
+       cdev = to_ccwdev(dev);
+       return ccw_dev_id_is_equal(&cdev->private->dev_id, dev_id);
+}
+
+static struct ccw_device *
+get_orphaned_ccwdev_by_dev_id(struct channel_subsystem *css,
+                             struct ccw_dev_id *dev_id)
 {
+       struct device *dev;
 
+       dev = device_find_child(&css->pseudo_subchannel->dev, dev_id,
+                               match_orphan);
+
+       return dev ? to_ccwdev(dev) : NULL;
+}
+
+static void
+ccw_device_add_changed(struct work_struct *work)
+{
+       struct ccw_device_private *priv;
        struct ccw_device *cdev;
 
-       cdev = data;
+       priv = container_of(work, struct ccw_device_private, kick_work);
+       cdev = priv->cdev;
        if (device_add(&cdev->dev)) {
                put_device(&cdev->dev);
                return;
@@ -602,64 +658,21 @@ ccw_device_add_changed(void *data)
        }
 }
 
-extern int css_get_ssd_info(struct subchannel *sch);
-
-void
-ccw_device_do_unreg_rereg(void *data)
+void ccw_device_do_unreg_rereg(struct work_struct *work)
 {
+       struct ccw_device_private *priv;
        struct ccw_device *cdev;
        struct subchannel *sch;
-       int need_rename;
 
-       cdev = data;
+       priv = container_of(work, struct ccw_device_private, kick_work);
+       cdev = priv->cdev;
        sch = to_subchannel(cdev->dev.parent);
-       if (cdev->private->dev_id.devno != sch->schib.pmcw.dev) {
-               /*
-                * The device number has changed. This is usually only when
-                * a device has been detached under VM and then re-appeared
-                * on another subchannel because of a different attachment
-                * order than before. Ideally, we should should just switch
-                * subchannels, but unfortunately, this is not possible with
-                * the current implementation.
-                * Instead, we search for the old subchannel for this device
-                * number and deregister so there are no collisions with the
-                * newly registered ccw_device.
-                * FIXME: Find another solution so the block layer doesn't
-                *        get possibly sick...
-                */
-               struct ccw_device *other_cdev;
-               struct ccw_dev_id dev_id;
-
-               need_rename = 1;
-               dev_id.devno = sch->schib.pmcw.dev;
-               dev_id.ssid = sch->schid.ssid;
-               other_cdev = get_disc_ccwdev_by_dev_id(&dev_id, cdev);
-               if (other_cdev) {
-                       struct subchannel *other_sch;
-
-                       other_sch = to_subchannel(other_cdev->dev.parent);
-                       if (get_device(&other_sch->dev)) {
-                               stsch(other_sch->schid, &other_sch->schib);
-                               if (other_sch->schib.pmcw.dnv) {
-                                       other_sch->schib.pmcw.intparm = 0;
-                                       cio_modify(other_sch);
-                               }
-                               css_sch_device_unregister(other_sch);
-                       }
-               }
-               /* Update ssd info here. */
-               css_get_ssd_info(sch);
-               cdev->private->dev_id.devno = sch->schib.pmcw.dev;
-       } else
-               need_rename = 0;
+
        device_remove_files(&cdev->dev);
        if (test_and_clear_bit(1, &cdev->private->registered))
                device_del(&cdev->dev);
-       if (need_rename)
-               snprintf (cdev->dev.bus_id, BUS_ID_SIZE, "0.%x.%04x",
-                         sch->schid.ssid, sch->schib.pmcw.dev);
        PREPARE_WORK(&cdev->private->kick_work,
-                    ccw_device_add_changed, cdev);
+                    ccw_device_add_changed);
        queue_work(ccw_device_work, &cdev->private->kick_work);
 }
 
@@ -673,18 +686,194 @@ ccw_device_release(struct device *dev)
        kfree(cdev);
 }
 
+static struct ccw_device * io_subchannel_allocate_dev(struct subchannel *sch)
+{
+       struct ccw_device *cdev;
+
+       cdev  = kzalloc(sizeof(*cdev), GFP_KERNEL);
+       if (cdev) {
+               cdev->private = kzalloc(sizeof(struct ccw_device_private),
+                                       GFP_KERNEL | GFP_DMA);
+               if (cdev->private)
+                       return cdev;
+       }
+       kfree(cdev);
+       return ERR_PTR(-ENOMEM);
+}
+
+static int io_subchannel_initialize_dev(struct subchannel *sch,
+                                       struct ccw_device *cdev)
+{
+       cdev->private->cdev = cdev;
+       atomic_set(&cdev->private->onoff, 0);
+       cdev->dev.parent = &sch->dev;
+       cdev->dev.release = ccw_device_release;
+       INIT_LIST_HEAD(&cdev->private->kick_work.entry);
+       /* Do first half of device_register. */
+       device_initialize(&cdev->dev);
+       if (!get_device(&sch->dev)) {
+               if (cdev->dev.release)
+                       cdev->dev.release(&cdev->dev);
+               return -ENODEV;
+       }
+       return 0;
+}
+
+static struct ccw_device * io_subchannel_create_ccwdev(struct subchannel *sch)
+{
+       struct ccw_device *cdev;
+       int ret;
+
+       cdev = io_subchannel_allocate_dev(sch);
+       if (!IS_ERR(cdev)) {
+               ret = io_subchannel_initialize_dev(sch, cdev);
+               if (ret) {
+                       kfree(cdev);
+                       cdev = ERR_PTR(ret);
+               }
+       }
+       return cdev;
+}
+
+static int io_subchannel_recog(struct ccw_device *, struct subchannel *);
+
+static void sch_attach_device(struct subchannel *sch,
+                             struct ccw_device *cdev)
+{
+       spin_lock_irq(sch->lock);
+       sch->dev.driver_data = cdev;
+       cdev->private->schid = sch->schid;
+       cdev->ccwlock = sch->lock;
+       device_trigger_reprobe(sch);
+       spin_unlock_irq(sch->lock);
+}
+
+static void sch_attach_disconnected_device(struct subchannel *sch,
+                                          struct ccw_device *cdev)
+{
+       struct subchannel *other_sch;
+       int ret;
+
+       other_sch = to_subchannel(get_device(cdev->dev.parent));
+       ret = device_move(&cdev->dev, &sch->dev);
+       if (ret) {
+               CIO_MSG_EVENT(2, "Moving disconnected device 0.%x.%04x failed "
+                             "(ret=%d)!\n", cdev->private->dev_id.ssid,
+                             cdev->private->dev_id.devno, ret);
+               put_device(&other_sch->dev);
+               return;
+       }
+       other_sch->dev.driver_data = NULL;
+       /* No need to keep a subchannel without ccw device around. */
+       css_sch_device_unregister(other_sch);
+       put_device(&other_sch->dev);
+       sch_attach_device(sch, cdev);
+}
+
+static void sch_attach_orphaned_device(struct subchannel *sch,
+                                      struct ccw_device *cdev)
+{
+       int ret;
+
+       /* Try to move the ccw device to its new subchannel. */
+       ret = device_move(&cdev->dev, &sch->dev);
+       if (ret) {
+               CIO_MSG_EVENT(0, "Moving device 0.%x.%04x from orphanage "
+                             "failed (ret=%d)!\n",
+                             cdev->private->dev_id.ssid,
+                             cdev->private->dev_id.devno, ret);
+               return;
+       }
+       sch_attach_device(sch, cdev);
+}
+
+static void sch_create_and_recog_new_device(struct subchannel *sch)
+{
+       struct ccw_device *cdev;
+
+       /* Need to allocate a new ccw device. */
+       cdev = io_subchannel_create_ccwdev(sch);
+       if (IS_ERR(cdev)) {
+               /* OK, we did everything we could... */
+               css_sch_device_unregister(sch);
+               return;
+       }
+       spin_lock_irq(sch->lock);
+       sch->dev.driver_data = cdev;
+       spin_unlock_irq(sch->lock);
+       /* Start recognition for the new ccw device. */
+       if (io_subchannel_recog(cdev, sch)) {
+               spin_lock_irq(sch->lock);
+               sch->dev.driver_data = NULL;
+               spin_unlock_irq(sch->lock);
+               if (cdev->dev.release)
+                       cdev->dev.release(&cdev->dev);
+               css_sch_device_unregister(sch);
+       }
+}
+
+
+void ccw_device_move_to_orphanage(struct work_struct *work)
+{
+       struct ccw_device_private *priv;
+       struct ccw_device *cdev;
+       struct ccw_device *replacing_cdev;
+       struct subchannel *sch;
+       int ret;
+       struct channel_subsystem *css;
+       struct ccw_dev_id dev_id;
+
+       priv = container_of(work, struct ccw_device_private, kick_work);
+       cdev = priv->cdev;
+       sch = to_subchannel(cdev->dev.parent);
+       css = to_css(sch->dev.parent);
+       dev_id.devno = sch->schib.pmcw.dev;
+       dev_id.ssid = sch->schid.ssid;
+
+       /*
+        * Move the orphaned ccw device to the orphanage so the replacing
+        * ccw device can take its place on the subchannel.
+        */
+       ret = device_move(&cdev->dev, &css->pseudo_subchannel->dev);
+       if (ret) {
+               CIO_MSG_EVENT(0, "Moving device 0.%x.%04x to orphanage failed "
+                             "(ret=%d)!\n", cdev->private->dev_id.ssid,
+                             cdev->private->dev_id.devno, ret);
+               return;
+       }
+       cdev->ccwlock = css->pseudo_subchannel->lock;
+       /*
+        * Search for the replacing ccw device
+        * - among the disconnected devices
+        * - in the orphanage
+        */
+       replacing_cdev = get_disc_ccwdev_by_dev_id(&dev_id, cdev);
+       if (replacing_cdev) {
+               sch_attach_disconnected_device(sch, replacing_cdev);
+               return;
+       }
+       replacing_cdev = get_orphaned_ccwdev_by_dev_id(css, &dev_id);
+       if (replacing_cdev) {
+               sch_attach_orphaned_device(sch, replacing_cdev);
+               return;
+       }
+       sch_create_and_recog_new_device(sch);
+}
+
 /*
  * Register recognized device.
  */
 static void
-io_subchannel_register(void *data)
+io_subchannel_register(struct work_struct *work)
 {
+       struct ccw_device_private *priv;
        struct ccw_device *cdev;
        struct subchannel *sch;
        int ret;
        unsigned long flags;
 
-       cdev = data;
+       priv = container_of(work, struct ccw_device_private, kick_work);
+       cdev = priv->cdev;
        sch = to_subchannel(cdev->dev.parent);
 
        /*
@@ -709,9 +898,9 @@ io_subchannel_register(void *data)
                printk (KERN_WARNING "%s: could not register %s\n",
                        __func__, cdev->dev.bus_id);
                put_device(&cdev->dev);
-               spin_lock_irqsave(&sch->lock, flags);
+               spin_lock_irqsave(sch->lock, flags);
                sch->dev.driver_data = NULL;
-               spin_unlock_irqrestore(&sch->lock, flags);
+               spin_unlock_irqrestore(sch->lock, flags);
                kfree (cdev->private);
                kfree (cdev);
                put_device(&sch->dev);
@@ -719,11 +908,6 @@ io_subchannel_register(void *data)
                        wake_up(&ccw_device_init_wq);
                return;
        }
-
-       ret = subchannel_add_files(cdev->dev.parent);
-       if (ret)
-               printk(KERN_WARNING "%s: could not add attributes to %s\n",
-                      __func__, sch->dev.bus_id);
        put_device(&cdev->dev);
 out:
        cdev->private->flags.recog_done = 1;
@@ -734,11 +918,14 @@ out:
 }
 
 void
-ccw_device_call_sch_unregister(void *data)
+ccw_device_call_sch_unregister(struct work_struct *work)
 {
-       struct ccw_device *cdev = data;
+       struct ccw_device_private *priv;
+       struct ccw_device *cdev;
        struct subchannel *sch;
 
+       priv = container_of(work, struct ccw_device_private, kick_work);
+       cdev = priv->cdev;
        sch = to_subchannel(cdev->dev.parent);
        css_sch_device_unregister(sch);
        /* Reset intparm to zeroes. */
@@ -768,7 +955,7 @@ io_subchannel_recog_done(struct ccw_device *cdev)
                        break;
                sch = to_subchannel(cdev->dev.parent);
                PREPARE_WORK(&cdev->private->kick_work,
-                            ccw_device_call_sch_unregister, cdev);
+                            ccw_device_call_sch_unregister);
                queue_work(slow_path_wq, &cdev->private->kick_work);
                if (atomic_dec_and_test(&ccw_device_init_count))
                        wake_up(&ccw_device_init_wq);
@@ -783,7 +970,7 @@ io_subchannel_recog_done(struct ccw_device *cdev)
                if (!get_device(&cdev->dev))
                        break;
                PREPARE_WORK(&cdev->private->kick_work,
-                            io_subchannel_register, cdev);
+                            io_subchannel_register);
                queue_work(slow_path_wq, &cdev->private->kick_work);
                break;
        }
@@ -797,7 +984,7 @@ io_subchannel_recog(struct ccw_device *cdev, struct subchannel *sch)
 
        sch->dev.driver_data = cdev;
        sch->driver = &io_subchannel_driver;
-       cdev->ccwlock = &sch->lock;
+       cdev->ccwlock = sch->lock;
 
        /* Init private data. */
        priv = cdev->private;
@@ -817,9 +1004,9 @@ io_subchannel_recog(struct ccw_device *cdev, struct subchannel *sch)
        atomic_inc(&ccw_device_init_count);
 
        /* Start async. device sensing. */
-       spin_lock_irq(&sch->lock);
+       spin_lock_irq(sch->lock);
        rc = ccw_device_recognition(cdev);
-       spin_unlock_irq(&sch->lock);
+       spin_unlock_irq(sch->lock);
        if (rc) {
                if (atomic_dec_and_test(&ccw_device_init_count))
                        wake_up(&ccw_device_init_wq);
@@ -827,12 +1014,55 @@ io_subchannel_recog(struct ccw_device *cdev, struct subchannel *sch)
        return rc;
 }
 
+static void ccw_device_move_to_sch(struct work_struct *work)
+{
+       struct ccw_device_private *priv;
+       int rc;
+       struct subchannel *sch;
+       struct ccw_device *cdev;
+       struct subchannel *former_parent;
+
+       priv = container_of(work, struct ccw_device_private, kick_work);
+       sch = priv->sch;
+       cdev = priv->cdev;
+       former_parent = ccw_device_is_orphan(cdev) ?
+               NULL : to_subchannel(get_device(cdev->dev.parent));
+       mutex_lock(&sch->reg_mutex);
+       /* Try to move the ccw device to its new subchannel. */
+       rc = device_move(&cdev->dev, &sch->dev);
+       mutex_unlock(&sch->reg_mutex);
+       if (rc) {
+               CIO_MSG_EVENT(2, "Moving device 0.%x.%04x to subchannel "
+                             "0.%x.%04x failed (ret=%d)!\n",
+                             cdev->private->dev_id.ssid,
+                             cdev->private->dev_id.devno, sch->schid.ssid,
+                             sch->schid.sch_no, rc);
+               css_sch_device_unregister(sch);
+               goto out;
+       }
+       if (former_parent) {
+               spin_lock_irq(former_parent->lock);
+               former_parent->dev.driver_data = NULL;
+               spin_unlock_irq(former_parent->lock);
+               css_sch_device_unregister(former_parent);
+               /* Reset intparm to zeroes. */
+               former_parent->schib.pmcw.intparm = 0;
+               cio_modify(former_parent);
+       }
+       sch_attach_device(sch, cdev);
+out:
+       if (former_parent)
+               put_device(&former_parent->dev);
+       put_device(&cdev->dev);
+}
+
 static int
 io_subchannel_probe (struct subchannel *sch)
 {
        struct ccw_device *cdev;
        int rc;
        unsigned long flags;
+       struct ccw_dev_id dev_id;
 
        if (sch->dev.driver_data) {
                /*
@@ -843,7 +1073,6 @@ io_subchannel_probe (struct subchannel *sch)
                cdev = sch->dev.driver_data;
                device_initialize(&cdev->dev);
                ccw_device_register(cdev);
-               subchannel_add_files(&sch->dev);
                /*
                 * Check if the device is already online. If it is
                 * the reference count needs to be corrected
@@ -856,33 +1085,37 @@ io_subchannel_probe (struct subchannel *sch)
                        get_device(&cdev->dev);
                return 0;
        }
-       cdev = kzalloc (sizeof(*cdev), GFP_KERNEL);
+       /*
+        * First check if a fitting device may be found amongst the
+        * disconnected devices or in the orphanage.
+        */
+       dev_id.devno = sch->schib.pmcw.dev;
+       dev_id.ssid = sch->schid.ssid;
+       cdev = get_disc_ccwdev_by_dev_id(&dev_id, NULL);
        if (!cdev)
-               return -ENOMEM;
-       cdev->private = kzalloc(sizeof(struct ccw_device_private),
-                               GFP_KERNEL | GFP_DMA);
-       if (!cdev->private) {
-               kfree(cdev);
-               return -ENOMEM;
-       }
-       atomic_set(&cdev->private->onoff, 0);
-       cdev->dev.parent = &sch->dev;
-       cdev->dev.release = ccw_device_release;
-       INIT_LIST_HEAD(&cdev->private->kick_work.entry);
-       /* Do first half of device_register. */
-       device_initialize(&cdev->dev);
-
-       if (!get_device(&sch->dev)) {
-               if (cdev->dev.release)
-                       cdev->dev.release(&cdev->dev);
-               return -ENODEV;
+               cdev = get_orphaned_ccwdev_by_dev_id(to_css(sch->dev.parent),
+                                                    &dev_id);
+       if (cdev) {
+               /*
+                * Schedule moving the device until when we have a registered
+                * subchannel to move to and succeed the probe. We can
+                * unregister later again, when the probe is through.
+                */
+               cdev->private->sch = sch;
+               PREPARE_WORK(&cdev->private->kick_work,
+                            ccw_device_move_to_sch);
+               queue_work(slow_path_wq, &cdev->private->kick_work);
+               return 0;
        }
+       cdev = io_subchannel_create_ccwdev(sch);
+       if (IS_ERR(cdev))
+               return PTR_ERR(cdev);
 
        rc = io_subchannel_recog(cdev, sch);
        if (rc) {
-               spin_lock_irqsave(&sch->lock, flags);
+               spin_lock_irqsave(sch->lock, flags);
                sch->dev.driver_data = NULL;
-               spin_unlock_irqrestore(&sch->lock, flags);
+               spin_unlock_irqrestore(sch->lock, flags);
                if (cdev->dev.release)
                        cdev->dev.release(&cdev->dev);
        }
@@ -890,17 +1123,6 @@ io_subchannel_probe (struct subchannel *sch)
        return rc;
 }
 
-static void
-ccw_device_unregister(void *data)
-{
-       struct ccw_device *cdev;
-
-       cdev = (struct ccw_device *)data;
-       if (test_and_clear_bit(1, &cdev->private->registered))
-               device_unregister(&cdev->dev);
-       put_device(&cdev->dev);
-}
-
 static int
 io_subchannel_remove (struct subchannel *sch)
 {
@@ -921,7 +1143,7 @@ io_subchannel_remove (struct subchannel *sch)
         */
        if (get_device(&cdev->dev)) {
                PREPARE_WORK(&cdev->private->kick_work,
-                            ccw_device_unregister, cdev);
+                            ccw_device_unregister);
                queue_work(ccw_device_work, &cdev->private->kick_work);
        }
        return 0;
@@ -1003,6 +1225,13 @@ static struct ccw_device console_cdev;
 static struct ccw_device_private console_private;
 static int console_cdev_in_use;
 
+static DEFINE_SPINLOCK(ccw_console_lock);
+
+spinlock_t * cio_get_console_lock(void)
+{
+       return &ccw_console_lock;
+}
+
 static int
 ccw_device_console_enable (struct ccw_device *cdev, struct subchannel *sch)
 {
@@ -1048,6 +1277,7 @@ ccw_device_probe_console(void)
        memset(&console_cdev, 0, sizeof(struct ccw_device));
        memset(&console_private, 0, sizeof(struct ccw_device_private));
        console_cdev.private = &console_private;
+       console_private.cdev = &console_cdev;
        ret = ccw_device_console_enable(&console_cdev, sch);
        if (ret) {
                cio_release_console();
index 9233b5c0bcc87ca6e9a7df4a7e9c59fe047bd946..29db6341d632ce0bd5a9f78b6982c3367a388349 100644 (file)
@@ -78,8 +78,10 @@ void io_subchannel_recog_done(struct ccw_device *cdev);
 
 int ccw_device_cancel_halt_clear(struct ccw_device *);
 
-void ccw_device_do_unreg_rereg(void *);
-void ccw_device_call_sch_unregister(void *);
+void ccw_device_do_unreg_rereg(struct work_struct *);
+void ccw_device_call_sch_unregister(struct work_struct *);
+void ccw_device_move_to_orphanage(struct work_struct *);
+int ccw_device_is_orphan(struct ccw_device *);
 
 int ccw_device_recognition(struct ccw_device *);
 int ccw_device_online(struct ccw_device *);
index 09c7672eb3f3a659e95d33bb5988f8d7db47e6c4..eed14572fc3b01e3445ee30a46e30bae6a15a006 100644 (file)
@@ -186,15 +186,14 @@ ccw_device_handle_oper(struct ccw_device *cdev)
        /*
         * Check if cu type and device type still match. If
         * not, it is certainly another device and we have to
-        * de- and re-register. Also check here for non-matching devno.
+        * de- and re-register.
         */
        if (cdev->id.cu_type != cdev->private->senseid.cu_type ||
            cdev->id.cu_model != cdev->private->senseid.cu_model ||
            cdev->id.dev_type != cdev->private->senseid.dev_type ||
-           cdev->id.dev_model != cdev->private->senseid.dev_model ||
-           cdev->private->dev_id.devno != sch->schib.pmcw.dev) {
+           cdev->id.dev_model != cdev->private->senseid.dev_model) {
                PREPARE_WORK(&cdev->private->kick_work,
-                            ccw_device_do_unreg_rereg, cdev);
+                            ccw_device_do_unreg_rereg);
                queue_work(ccw_device_work, &cdev->private->kick_work);
                return 0;
        }
@@ -329,19 +328,21 @@ ccw_device_sense_id_done(struct ccw_device *cdev, int err)
 }
 
 static void
-ccw_device_oper_notify(void *data)
+ccw_device_oper_notify(struct work_struct *work)
 {
+       struct ccw_device_private *priv;
        struct ccw_device *cdev;
        struct subchannel *sch;
        int ret;
 
-       cdev = data;
+       priv = container_of(work, struct ccw_device_private, kick_work);
+       cdev = priv->cdev;
        sch = to_subchannel(cdev->dev.parent);
        ret = (sch->driver && sch->driver->notify) ?
                sch->driver->notify(&sch->dev, CIO_OPER) : 0;
        if (!ret)
                /* Driver doesn't want device back. */
-               ccw_device_do_unreg_rereg(cdev);
+               ccw_device_do_unreg_rereg(work);
        else {
                /* Reenable channel measurements, if needed. */
                cmf_reenable(cdev);
@@ -377,8 +378,7 @@ ccw_device_done(struct ccw_device *cdev, int state)
 
        if (cdev->private->flags.donotify) {
                cdev->private->flags.donotify = 0;
-               PREPARE_WORK(&cdev->private->kick_work, ccw_device_oper_notify,
-                            cdev);
+               PREPARE_WORK(&cdev->private->kick_work, ccw_device_oper_notify);
                queue_work(ccw_device_notify_work, &cdev->private->kick_work);
        }
        wake_up(&cdev->private->wait_q);
@@ -528,13 +528,15 @@ ccw_device_recog_timeout(struct ccw_device *cdev, enum dev_event dev_event)
 
 
 static void
-ccw_device_nopath_notify(void *data)
+ccw_device_nopath_notify(struct work_struct *work)
 {
+       struct ccw_device_private *priv;
        struct ccw_device *cdev;
        struct subchannel *sch;
        int ret;
 
-       cdev = data;
+       priv = container_of(work, struct ccw_device_private, kick_work);
+       cdev = priv->cdev;
        sch = to_subchannel(cdev->dev.parent);
        /* Extra sanity. */
        if (sch->lpm)
@@ -547,8 +549,7 @@ ccw_device_nopath_notify(void *data)
                        cio_disable_subchannel(sch);
                        if (get_device(&cdev->dev)) {
                                PREPARE_WORK(&cdev->private->kick_work,
-                                            ccw_device_call_sch_unregister,
-                                            cdev);
+                                            ccw_device_call_sch_unregister);
                                queue_work(ccw_device_work,
                                           &cdev->private->kick_work);
                        } else
@@ -607,7 +608,7 @@ ccw_device_verify_done(struct ccw_device *cdev, int err)
                /* Reset oper notify indication after verify error. */
                cdev->private->flags.donotify = 0;
                PREPARE_WORK(&cdev->private->kick_work,
-                            ccw_device_nopath_notify, cdev);
+                            ccw_device_nopath_notify);
                queue_work(ccw_device_notify_work, &cdev->private->kick_work);
                ccw_device_done(cdev, DEV_STATE_NOT_OPER);
                break;
@@ -674,6 +675,10 @@ ccw_device_offline(struct ccw_device *cdev)
 {
        struct subchannel *sch;
 
+       if (ccw_device_is_orphan(cdev)) {
+               ccw_device_done(cdev, DEV_STATE_OFFLINE);
+               return 0;
+       }
        sch = to_subchannel(cdev->dev.parent);
        if (stsch(sch->schid, &sch->schib) || !sch->schib.pmcw.dnv)
                return -ENODEV;
@@ -738,7 +743,7 @@ ccw_device_offline_notoper(struct ccw_device *cdev, enum dev_event dev_event)
        sch = to_subchannel(cdev->dev.parent);
        if (get_device(&cdev->dev)) {
                PREPARE_WORK(&cdev->private->kick_work,
-                            ccw_device_call_sch_unregister, cdev);
+                            ccw_device_call_sch_unregister);
                queue_work(ccw_device_work, &cdev->private->kick_work);
        }
        wake_up(&cdev->private->wait_q);
@@ -769,7 +774,7 @@ ccw_device_online_notoper(struct ccw_device *cdev, enum dev_event dev_event)
        }
        if (get_device(&cdev->dev)) {
                PREPARE_WORK(&cdev->private->kick_work,
-                            ccw_device_call_sch_unregister, cdev);
+                            ccw_device_call_sch_unregister);
                queue_work(ccw_device_work, &cdev->private->kick_work);
        }
        wake_up(&cdev->private->wait_q);
@@ -874,7 +879,7 @@ ccw_device_online_timeout(struct ccw_device *cdev, enum dev_event dev_event)
                sch = to_subchannel(cdev->dev.parent);
                if (!sch->lpm) {
                        PREPARE_WORK(&cdev->private->kick_work,
-                                    ccw_device_nopath_notify, cdev);
+                                    ccw_device_nopath_notify);
                        queue_work(ccw_device_notify_work,
                                   &cdev->private->kick_work);
                } else
@@ -969,7 +974,7 @@ ccw_device_killing_irq(struct ccw_device *cdev, enum dev_event dev_event)
                              ERR_PTR(-EIO));
        if (!sch->lpm) {
                PREPARE_WORK(&cdev->private->kick_work,
-                            ccw_device_nopath_notify, cdev);
+                            ccw_device_nopath_notify);
                queue_work(ccw_device_notify_work, &cdev->private->kick_work);
        } else if (cdev->private->flags.doverify)
                /* Start delayed path verification. */
@@ -992,7 +997,7 @@ ccw_device_killing_timeout(struct ccw_device *cdev, enum dev_event dev_event)
                sch = to_subchannel(cdev->dev.parent);
                if (!sch->lpm) {
                        PREPARE_WORK(&cdev->private->kick_work,
-                                    ccw_device_nopath_notify, cdev);
+                                    ccw_device_nopath_notify);
                        queue_work(ccw_device_notify_work,
                                   &cdev->private->kick_work);
                } else
@@ -1021,7 +1026,7 @@ void device_kill_io(struct subchannel *sch)
        if (ret == -ENODEV) {
                if (!sch->lpm) {
                        PREPARE_WORK(&cdev->private->kick_work,
-                                    ccw_device_nopath_notify, cdev);
+                                    ccw_device_nopath_notify);
                        queue_work(ccw_device_notify_work,
                                   &cdev->private->kick_work);
                } else
@@ -1033,7 +1038,7 @@ void device_kill_io(struct subchannel *sch)
                              ERR_PTR(-EIO));
        if (!sch->lpm) {
                PREPARE_WORK(&cdev->private->kick_work,
-                            ccw_device_nopath_notify, cdev);
+                            ccw_device_nopath_notify);
                queue_work(ccw_device_notify_work, &cdev->private->kick_work);
        } else
                /* Start delayed path verification. */
@@ -1104,7 +1109,8 @@ device_trigger_reprobe(struct subchannel *sch)
        /* Update some values. */
        if (stsch(sch->schid, &sch->schib))
                return;
-
+       if (!sch->schib.pmcw.dnv)
+               return;
        /*
         * The pim, pam, pom values may not be accurate, but they are the best
         * we have before performing device selection :/
@@ -1118,7 +1124,13 @@ device_trigger_reprobe(struct subchannel *sch)
                sch->schib.pmcw.mp = 1;
        sch->schib.pmcw.intparm = (__u32)(unsigned long)sch;
        /* We should also udate ssd info, but this has to wait. */
-       ccw_device_start_id(cdev, 0);
+       /* Check if this is another device which appeared on the same sch. */
+       if (sch->schib.pmcw.dev != cdev->private->dev_id.devno) {
+               PREPARE_WORK(&cdev->private->kick_work,
+                            ccw_device_move_to_orphanage);
+               queue_work(ccw_device_work, &cdev->private->kick_work);
+       } else
+               ccw_device_start_id(cdev, 0);
 }
 
 static void
index b39c1fa48acd22cac1fd92990da9699193913510..d269607336ec212368d7302511426c43c7cefab0 100644 (file)
@@ -316,9 +316,9 @@ __ccw_device_retry_loop(struct ccw_device *cdev, struct ccw1 *ccw, long magic, _
                        ccw_device_set_timeout(cdev, 0);
                if (ret == -EBUSY) {
                        /* Try again later. */
-                       spin_unlock_irq(&sch->lock);
+                       spin_unlock_irq(sch->lock);
                        msleep(10);
-                       spin_lock_irq(&sch->lock);
+                       spin_lock_irq(sch->lock);
                        continue;
                }
                if (ret != 0)
@@ -326,12 +326,12 @@ __ccw_device_retry_loop(struct ccw_device *cdev, struct ccw1 *ccw, long magic, _
                        break;
                /* Wait for end of request. */
                cdev->private->intparm = magic;
-               spin_unlock_irq(&sch->lock);
+               spin_unlock_irq(sch->lock);
                wait_event(cdev->private->wait_q,
                           (cdev->private->intparm == -EIO) ||
                           (cdev->private->intparm == -EAGAIN) ||
                           (cdev->private->intparm == 0));
-               spin_lock_irq(&sch->lock);
+               spin_lock_irq(sch->lock);
                /* Check at least for channel end / device end */
                if (cdev->private->intparm == -EIO) {
                        /* Non-retryable error. */
@@ -342,9 +342,9 @@ __ccw_device_retry_loop(struct ccw_device *cdev, struct ccw1 *ccw, long magic, _
                        /* Success. */
                        break;
                /* Try again later. */
-               spin_unlock_irq(&sch->lock);
+               spin_unlock_irq(sch->lock);
                msleep(10);
-               spin_lock_irq(&sch->lock);
+               spin_lock_irq(sch->lock);
        } while (1);
 
        return ret;
@@ -389,7 +389,7 @@ read_dev_chars (struct ccw_device *cdev, void **buffer, int length)
                return ret;
        }
 
-       spin_lock_irq(&sch->lock);
+       spin_lock_irq(sch->lock);
        /* Save interrupt handler. */
        handler = cdev->handler;
        /* Temporarily install own handler. */
@@ -406,7 +406,7 @@ read_dev_chars (struct ccw_device *cdev, void **buffer, int length)
 
        /* Restore interrupt handler. */
        cdev->handler = handler;
-       spin_unlock_irq(&sch->lock);
+       spin_unlock_irq(sch->lock);
 
        clear_normalized_cda (rdc_ccw);
        kfree(rdc_ccw);
@@ -463,7 +463,7 @@ read_conf_data_lpm (struct ccw_device *cdev, void **buffer, int *length, __u8 lp
        rcd_ccw->count = ciw->count;
        rcd_ccw->flags = CCW_FLAG_SLI;
 
-       spin_lock_irq(&sch->lock);
+       spin_lock_irq(sch->lock);
        /* Save interrupt handler. */
        handler = cdev->handler;
        /* Temporarily install own handler. */
@@ -480,7 +480,7 @@ read_conf_data_lpm (struct ccw_device *cdev, void **buffer, int *length, __u8 lp
 
        /* Restore interrupt handler. */
        cdev->handler = handler;
-       spin_unlock_irq(&sch->lock);
+       spin_unlock_irq(sch->lock);
 
        /*
         * on success we update the user input parms
@@ -537,7 +537,7 @@ ccw_device_stlck(struct ccw_device *cdev)
                kfree(buf);
                return -ENOMEM;
        }
-       spin_lock_irqsave(&sch->lock, flags);
+       spin_lock_irqsave(sch->lock, flags);
        ret = cio_enable_subchannel(sch, 3);
        if (ret)
                goto out_unlock;
@@ -559,9 +559,9 @@ ccw_device_stlck(struct ccw_device *cdev)
                goto out_unlock;
        }
        cdev->private->irb.scsw.actl |= SCSW_ACTL_START_PEND;
-       spin_unlock_irqrestore(&sch->lock, flags);
+       spin_unlock_irqrestore(sch->lock, flags);
        wait_event(cdev->private->wait_q, cdev->private->irb.scsw.actl == 0);
-       spin_lock_irqsave(&sch->lock, flags);
+       spin_lock_irqsave(sch->lock, flags);
        cio_disable_subchannel(sch); //FIXME: return code?
        if ((cdev->private->irb.scsw.dstat !=
             (DEV_STAT_CHN_END|DEV_STAT_DEV_END)) ||
@@ -572,7 +572,7 @@ ccw_device_stlck(struct ccw_device *cdev)
 out_unlock:
        kfree(buf);
        kfree(buf2);
-       spin_unlock_irqrestore(&sch->lock, flags);
+       spin_unlock_irqrestore(sch->lock, flags);
        return ret;
 }
 
index 8d5fa1b4d11f10829a57f8676d4f7f14ecb3e427..9d4ea449a608c80995c7b13efa210fec1c244d6d 100644 (file)
@@ -46,6 +46,7 @@
 #include <asm/timex.h>
 
 #include <asm/debug.h>
+#include <asm/s390_rdev.h>
 #include <asm/qdio.h>
 
 #include "cio.h"
@@ -65,12 +66,12 @@ MODULE_LICENSE("GPL");
 /******************** HERE WE GO ***********************************/
 
 static const char version[] = "QDIO base support version 2";
+extern struct bus_type ccw_bus_type;
 
-#ifdef QDIO_PERFORMANCE_STATS
+static int qdio_performance_stats = 0;
 static int proc_perf_file_registration;
 static unsigned long i_p_c, i_p_nc, o_p_c, o_p_nc, ii_p_c, ii_p_nc;
 static struct qdio_perf_stats perf_stats;
-#endif /* QDIO_PERFORMANCE_STATS */
 
 static int hydra_thinints;
 static int is_passthrough = 0;
@@ -275,9 +276,8 @@ qdio_siga_sync(struct qdio_q *q, unsigned int gpr2,
        QDIO_DBF_TEXT4(0,trace,"sigasync");
        QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
 
-#ifdef QDIO_PERFORMANCE_STATS
-       perf_stats.siga_syncs++;
-#endif /* QDIO_PERFORMANCE_STATS */
+       if (qdio_performance_stats)
+               perf_stats.siga_syncs++;
 
        cc = do_siga_sync(q->schid, gpr2, gpr3);
        if (cc)
@@ -322,9 +322,8 @@ qdio_siga_output(struct qdio_q *q)
        __u32 busy_bit;
        __u64 start_time=0;
 
-#ifdef QDIO_PERFORMANCE_STATS
-       perf_stats.siga_outs++;
-#endif /* QDIO_PERFORMANCE_STATS */
+       if (qdio_performance_stats)
+               perf_stats.siga_outs++;
 
        QDIO_DBF_TEXT4(0,trace,"sigaout");
        QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
@@ -358,9 +357,8 @@ qdio_siga_input(struct qdio_q *q)
        QDIO_DBF_TEXT4(0,trace,"sigain");
        QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
 
-#ifdef QDIO_PERFORMANCE_STATS
-       perf_stats.siga_ins++;
-#endif /* QDIO_PERFORMANCE_STATS */
+       if (qdio_performance_stats)
+               perf_stats.siga_ins++;
 
        cc = do_siga_input(q->schid, q->mask);
        
@@ -954,9 +952,8 @@ __qdio_outbound_processing(struct qdio_q *q)
 
        if (unlikely(qdio_reserve_q(q))) {
                qdio_release_q(q);
-#ifdef QDIO_PERFORMANCE_STATS
-               o_p_c++;
-#endif /* QDIO_PERFORMANCE_STATS */
+               if (qdio_performance_stats)
+                       o_p_c++;
                /* as we're sissies, we'll check next time */
                if (likely(!atomic_read(&q->is_in_shutdown))) {
                        qdio_mark_q(q);
@@ -964,10 +961,10 @@ __qdio_outbound_processing(struct qdio_q *q)
                }
                return;
        }
-#ifdef QDIO_PERFORMANCE_STATS
-       o_p_nc++;
-       perf_stats.tl_runs++;
-#endif /* QDIO_PERFORMANCE_STATS */
+       if (qdio_performance_stats) {
+               o_p_nc++;
+               perf_stats.tl_runs++;
+       }
 
        /* see comment in qdio_kick_outbound_q */
        siga_attempts=atomic_read(&q->busy_siga_counter);
@@ -1142,15 +1139,16 @@ qdio_has_inbound_q_moved(struct qdio_q *q)
 {
        int i;
 
-#ifdef QDIO_PERFORMANCE_STATS
        static int old_pcis=0;
        static int old_thinints=0;
 
-       if ((old_pcis==perf_stats.pcis)&&(old_thinints==perf_stats.thinints))
-               perf_stats.start_time_inbound=NOW;
-       else
-               old_pcis=perf_stats.pcis;
-#endif /* QDIO_PERFORMANCE_STATS */
+       if (qdio_performance_stats) {
+               if ((old_pcis==perf_stats.pcis)&&
+                   (old_thinints==perf_stats.thinints))
+                       perf_stats.start_time_inbound=NOW;
+               else
+                       old_pcis=perf_stats.pcis;
+       }
 
        i=qdio_get_inbound_buffer_frontier(q);
        if ( (i!=GET_SAVED_FRONTIER(q)) ||
@@ -1340,10 +1338,10 @@ qdio_kick_inbound_handler(struct qdio_q *q)
        q->siga_error=0;
        q->error_status_flags=0;
 
-#ifdef QDIO_PERFORMANCE_STATS
-       perf_stats.inbound_time+=NOW-perf_stats.start_time_inbound;
-       perf_stats.inbound_cnt++;
-#endif /* QDIO_PERFORMANCE_STATS */
+       if (qdio_performance_stats) {
+               perf_stats.inbound_time+=NOW-perf_stats.start_time_inbound;
+               perf_stats.inbound_cnt++;
+       }
 }
 
 static inline void
@@ -1363,9 +1361,8 @@ __tiqdio_inbound_processing(struct qdio_q *q, int spare_ind_was_set)
         */
        if (unlikely(qdio_reserve_q(q))) {
                qdio_release_q(q);
-#ifdef QDIO_PERFORMANCE_STATS
-               ii_p_c++;
-#endif /* QDIO_PERFORMANCE_STATS */
+               if (qdio_performance_stats)
+                       ii_p_c++;
                /* 
                 * as we might just be about to stop polling, we make
                 * sure that we check again at least once more 
@@ -1373,9 +1370,8 @@ __tiqdio_inbound_processing(struct qdio_q *q, int spare_ind_was_set)
                tiqdio_sched_tl();
                return;
        }
-#ifdef QDIO_PERFORMANCE_STATS
-       ii_p_nc++;
-#endif /* QDIO_PERFORMANCE_STATS */
+       if (qdio_performance_stats)
+               ii_p_nc++;
        if (unlikely(atomic_read(&q->is_in_shutdown))) {
                qdio_unmark_q(q);
                goto out;
@@ -1416,11 +1412,11 @@ __tiqdio_inbound_processing(struct qdio_q *q, int spare_ind_was_set)
                irq_ptr = (struct qdio_irq*)q->irq_ptr;
                for (i=0;i<irq_ptr->no_output_qs;i++) {
                        oq = irq_ptr->output_qs[i];
-#ifdef QDIO_PERFORMANCE_STATS
-                       perf_stats.tl_runs--;
-#endif /* QDIO_PERFORMANCE_STATS */
-                       if (!qdio_is_outbound_q_done(oq))
+                       if (!qdio_is_outbound_q_done(oq)) {
+                               if (qdio_performance_stats)
+                                       perf_stats.tl_runs--;
                                __qdio_outbound_processing(oq);
+                       }
                }
        }
 
@@ -1457,9 +1453,8 @@ __qdio_inbound_processing(struct qdio_q *q)
 
        if (unlikely(qdio_reserve_q(q))) {
                qdio_release_q(q);
-#ifdef QDIO_PERFORMANCE_STATS
-               i_p_c++;
-#endif /* QDIO_PERFORMANCE_STATS */
+               if (qdio_performance_stats)
+                       i_p_c++;
                /* as we're sissies, we'll check next time */
                if (likely(!atomic_read(&q->is_in_shutdown))) {
                        qdio_mark_q(q);
@@ -1467,10 +1462,10 @@ __qdio_inbound_processing(struct qdio_q *q)
                }
                return;
        }
-#ifdef QDIO_PERFORMANCE_STATS
-       i_p_nc++;
-       perf_stats.tl_runs++;
-#endif /* QDIO_PERFORMANCE_STATS */
+       if (qdio_performance_stats) {
+               i_p_nc++;
+               perf_stats.tl_runs++;
+       }
 
 again:
        if (qdio_has_inbound_q_moved(q)) {
@@ -1516,9 +1511,8 @@ tiqdio_reset_processing_state(struct qdio_q *q, int q_laps)
 
        if (unlikely(qdio_reserve_q(q))) {
                qdio_release_q(q);
-#ifdef QDIO_PERFORMANCE_STATS
-               ii_p_c++;
-#endif /* QDIO_PERFORMANCE_STATS */
+               if (qdio_performance_stats)
+                       ii_p_c++;
                /* 
                 * as we might just be about to stop polling, we make
                 * sure that we check again at least once more 
@@ -1609,9 +1603,8 @@ tiqdio_tl(unsigned long data)
 {
        QDIO_DBF_TEXT4(0,trace,"iqdio_tl");
 
-#ifdef QDIO_PERFORMANCE_STATS
-       perf_stats.tl_runs++;
-#endif /* QDIO_PERFORMANCE_STATS */
+       if (qdio_performance_stats)
+               perf_stats.tl_runs++;
 
        tiqdio_inbound_checks();
 }
@@ -1918,10 +1911,10 @@ tiqdio_thinint_handler(void)
 {
        QDIO_DBF_TEXT4(0,trace,"thin_int");
 
-#ifdef QDIO_PERFORMANCE_STATS
-       perf_stats.thinints++;
-       perf_stats.start_time_inbound=NOW;
-#endif /* QDIO_PERFORMANCE_STATS */
+       if (qdio_performance_stats) {
+               perf_stats.thinints++;
+               perf_stats.start_time_inbound=NOW;
+       }
 
        /* SVS only when needed:
         * issue SVS to benefit from iqdio interrupt avoidance
@@ -1976,18 +1969,17 @@ qdio_handle_pci(struct qdio_irq *irq_ptr)
        int i;
        struct qdio_q *q;
 
-#ifdef QDIO_PERFORMANCE_STATS
-       perf_stats.pcis++;
-       perf_stats.start_time_inbound=NOW;
-#endif /* QDIO_PERFORMANCE_STATS */
+       if (qdio_performance_stats) {
+               perf_stats.pcis++;
+               perf_stats.start_time_inbound=NOW;
+       }
        for (i=0;i<irq_ptr->no_input_qs;i++) {
                q=irq_ptr->input_qs[i];
                if (q->is_input_q&QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT)
                        qdio_mark_q(q);
                else {
-#ifdef QDIO_PERFORMANCE_STATS
-                       perf_stats.tl_runs--;
-#endif /* QDIO_PERFORMANCE_STATS */
+                       if (qdio_performance_stats)
+                               perf_stats.tl_runs--;
                        __qdio_inbound_processing(q);
                }
        }
@@ -1995,11 +1987,10 @@ qdio_handle_pci(struct qdio_irq *irq_ptr)
                return;
        for (i=0;i<irq_ptr->no_output_qs;i++) {
                q=irq_ptr->output_qs[i];
-#ifdef QDIO_PERFORMANCE_STATS
-               perf_stats.tl_runs--;
-#endif /* QDIO_PERFORMANCE_STATS */
                if (qdio_is_outbound_q_done(q))
                        continue;
+               if (qdio_performance_stats)
+                       perf_stats.tl_runs--;
                if (!irq_ptr->sync_done_on_outb_pcis)
                        SYNC_MEMORY;
                __qdio_outbound_processing(q);
@@ -2045,11 +2036,13 @@ omit_handler_call:
 }
 
 static void
-qdio_call_shutdown(void *data)
+qdio_call_shutdown(struct work_struct *work)
 {
+       struct ccw_device_private *priv;
        struct ccw_device *cdev;
 
-       cdev = (struct ccw_device *)data;
+       priv = container_of(work, struct ccw_device_private, kick_work);
+       cdev = priv->cdev;
        qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR);
        put_device(&cdev->dev);
 }
@@ -2091,7 +2084,7 @@ qdio_timeout_handler(struct ccw_device *cdev)
                if (get_device(&cdev->dev)) {
                        /* Can't call shutdown from interrupt context. */
                        PREPARE_WORK(&cdev->private->kick_work,
-                                    qdio_call_shutdown, (void *)cdev);
+                                    qdio_call_shutdown);
                        queue_work(ccw_device_work, &cdev->private->kick_work);
                }
                break;
@@ -3458,19 +3451,18 @@ do_qdio_handle_outbound(struct qdio_q *q, unsigned int callflags,
        struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr;
 
        /* This is the outbound handling of queues */
-#ifdef QDIO_PERFORMANCE_STATS
-       perf_stats.start_time_outbound=NOW;
-#endif /* QDIO_PERFORMANCE_STATS */
+       if (qdio_performance_stats)
+               perf_stats.start_time_outbound=NOW;
 
        qdio_do_qdio_fill_output(q,qidx,count,buffers);
 
        used_elements=atomic_add_return(count, &q->number_of_buffers_used) - count;
 
        if (callflags&QDIO_FLAG_DONT_SIGA) {
-#ifdef QDIO_PERFORMANCE_STATS
-               perf_stats.outbound_time+=NOW-perf_stats.start_time_outbound;
-               perf_stats.outbound_cnt++;
-#endif /* QDIO_PERFORMANCE_STATS */
+               if (qdio_performance_stats) {
+                       perf_stats.outbound_time+=NOW-perf_stats.start_time_outbound;
+                       perf_stats.outbound_cnt++;
+               }
                return;
        }
        if (q->is_iqdio_q) {
@@ -3500,9 +3492,8 @@ do_qdio_handle_outbound(struct qdio_q *q, unsigned int callflags,
                                qdio_kick_outbound_q(q);
                        } else {
                                QDIO_DBF_TEXT3(0,trace, "fast-req");
-#ifdef QDIO_PERFORMANCE_STATS
-                               perf_stats.fast_reqs++;
-#endif /* QDIO_PERFORMANCE_STATS */
+                               if (qdio_performance_stats)
+                                       perf_stats.fast_reqs++;
                        }
                }
                /* 
@@ -3513,10 +3504,10 @@ do_qdio_handle_outbound(struct qdio_q *q, unsigned int callflags,
                __qdio_outbound_processing(q);
        }
 
-#ifdef QDIO_PERFORMANCE_STATS
-       perf_stats.outbound_time+=NOW-perf_stats.start_time_outbound;
-       perf_stats.outbound_cnt++;
-#endif /* QDIO_PERFORMANCE_STATS */
+       if (qdio_performance_stats) {
+               perf_stats.outbound_time+=NOW-perf_stats.start_time_outbound;
+               perf_stats.outbound_cnt++;
+       }
 }
 
 /* count must be 1 in iqdio */
@@ -3574,7 +3565,6 @@ do_QDIO(struct ccw_device *cdev,unsigned int callflags,
        return 0;
 }
 
-#ifdef QDIO_PERFORMANCE_STATS
 static int
 qdio_perf_procfile_read(char *buffer, char **buffer_location, off_t offset,
                        int buffer_length, int *eof, void *data)
@@ -3590,29 +3580,29 @@ qdio_perf_procfile_read(char *buffer, char **buffer_location, off_t offset,
        _OUTP_IT("i_p_nc/c=%lu/%lu\n",i_p_nc,i_p_c);
        _OUTP_IT("ii_p_nc/c=%lu/%lu\n",ii_p_nc,ii_p_c);
        _OUTP_IT("o_p_nc/c=%lu/%lu\n",o_p_nc,o_p_c);
-       _OUTP_IT("Number of tasklet runs (total)                  : %u\n",
+       _OUTP_IT("Number of tasklet runs (total)                  : %lu\n",
                 perf_stats.tl_runs);
        _OUTP_IT("\n");
-       _OUTP_IT("Number of SIGA sync's issued                    : %u\n",
+       _OUTP_IT("Number of SIGA sync's issued                    : %lu\n",
                 perf_stats.siga_syncs);
-       _OUTP_IT("Number of SIGA in's issued                      : %u\n",
+       _OUTP_IT("Number of SIGA in's issued                      : %lu\n",
                 perf_stats.siga_ins);
-       _OUTP_IT("Number of SIGA out's issued                     : %u\n",
+       _OUTP_IT("Number of SIGA out's issued                     : %lu\n",
                 perf_stats.siga_outs);
-       _OUTP_IT("Number of PCIs caught                           : %u\n",
+       _OUTP_IT("Number of PCIs caught                           : %lu\n",
                 perf_stats.pcis);
-       _OUTP_IT("Number of adapter interrupts caught             : %u\n",
+       _OUTP_IT("Number of adapter interrupts caught             : %lu\n",
                 perf_stats.thinints);
-       _OUTP_IT("Number of fast requeues (outg. SBALs w/o SIGA)  : %u\n",
+       _OUTP_IT("Number of fast requeues (outg. SBALs w/o SIGA)  : %lu\n",
                 perf_stats.fast_reqs);
        _OUTP_IT("\n");
-       _OUTP_IT("Total time of all inbound actions (us) incl. UL : %u\n",
+       _OUTP_IT("Total time of all inbound actions (us) incl. UL : %lu\n",
                 perf_stats.inbound_time);
-       _OUTP_IT("Number of inbound transfers                     : %u\n",
+       _OUTP_IT("Number of inbound transfers                     : %lu\n",
                 perf_stats.inbound_cnt);
-       _OUTP_IT("Total time of all outbound do_QDIOs (us)        : %u\n",
+       _OUTP_IT("Total time of all outbound do_QDIOs (us)        : %lu\n",
                 perf_stats.outbound_time);
-       _OUTP_IT("Number of do_QDIOs outbound                     : %u\n",
+       _OUTP_IT("Number of do_QDIOs outbound                     : %lu\n",
                 perf_stats.outbound_cnt);
        _OUTP_IT("\n");
 
@@ -3620,12 +3610,10 @@ qdio_perf_procfile_read(char *buffer, char **buffer_location, off_t offset,
 }
 
 static struct proc_dir_entry *qdio_perf_proc_file;
-#endif /* QDIO_PERFORMANCE_STATS */
 
 static void
 qdio_add_procfs_entry(void)
 {
-#ifdef QDIO_PERFORMANCE_STATS
         proc_perf_file_registration=0;
        qdio_perf_proc_file=create_proc_entry(QDIO_PERF,
                                              S_IFREG|0444,&proc_root);
@@ -3637,20 +3625,58 @@ qdio_add_procfs_entry(void)
                 QDIO_PRINT_WARN("was not able to register perf. " \
                                "proc-file (%i).\n",
                                proc_perf_file_registration);
-#endif /* QDIO_PERFORMANCE_STATS */
 }
 
 static void
 qdio_remove_procfs_entry(void)
 {
-#ifdef QDIO_PERFORMANCE_STATS
        perf_stats.tl_runs=0;
 
         if (!proc_perf_file_registration) /* means if it went ok earlier */
                remove_proc_entry(QDIO_PERF,&proc_root);
-#endif /* QDIO_PERFORMANCE_STATS */
 }
 
+/**
+ * attributes in sysfs
+ *****************************************************************************/
+
+static ssize_t
+qdio_performance_stats_show(struct bus_type *bus, char *buf)
+{
+       return sprintf(buf, "%i\n", qdio_performance_stats ? 1 : 0);
+}
+
+static ssize_t
+qdio_performance_stats_store(struct bus_type *bus, const char *buf, size_t count)
+{
+       char *tmp;
+       int i;
+
+       i = simple_strtoul(buf, &tmp, 16);
+       if ((i == 0) || (i == 1)) {
+               if (i == qdio_performance_stats)
+                       return count;
+               qdio_performance_stats = i;
+               if (i==0) {
+                       /* reset perf. stat. info */
+                       i_p_nc = 0;
+                       i_p_c = 0;
+                       ii_p_nc = 0;
+                       ii_p_c = 0;
+                       o_p_nc = 0;
+                       o_p_c = 0;
+                       memset(&perf_stats, 0, sizeof(struct qdio_perf_stats));
+               }
+       } else {
+               QDIO_PRINT_WARN("QDIO performance_stats: write 0 or 1 to this file!\n");
+               return -EINVAL;
+       }
+       return count;
+}
+
+static BUS_ATTR(qdio_performance_stats, 0644, qdio_performance_stats_show,
+                       qdio_performance_stats_store);
+
 static void
 tiqdio_register_thinints(void)
 {
@@ -3695,6 +3721,7 @@ qdio_release_qdio_memory(void)
        kfree(indicators);
 }
 
+
 static void
 qdio_unregister_dbf_views(void)
 {
@@ -3796,9 +3823,7 @@ static int __init
 init_QDIO(void)
 {
        int res;
-#ifdef QDIO_PERFORMANCE_STATS
        void *ptr;
-#endif /* QDIO_PERFORMANCE_STATS */
 
        printk("qdio: loading %s\n",version);
 
@@ -3811,13 +3836,12 @@ init_QDIO(void)
                return res;
 
        QDIO_DBF_TEXT0(0,setup,"initQDIO");
+       res = bus_create_file(&ccw_bus_type, &bus_attr_qdio_performance_stats);
 
-#ifdef QDIO_PERFORMANCE_STATS
-               memset((void*)&perf_stats,0,sizeof(perf_stats));
+       memset((void*)&perf_stats,0,sizeof(perf_stats));
        QDIO_DBF_TEXT0(0,setup,"perfstat");
        ptr=&perf_stats;
        QDIO_DBF_HEX0(0,setup,&ptr,sizeof(void*));
-#endif /* QDIO_PERFORMANCE_STATS */
 
        qdio_add_procfs_entry();
 
@@ -3841,7 +3865,7 @@ cleanup_QDIO(void)
        qdio_release_qdio_memory();
        qdio_unregister_dbf_views();
        mempool_destroy(qdio_mempool_scssc);
-
+       bus_remove_file(&ccw_bus_type, &bus_attr_qdio_performance_stats);
        printk("qdio: %s: module removed\n",version);
 }
 
index 42927c1b745124d9483541c8b3282f7ddb628836..ec9af72b2afc061d7c84d4a8ddb74cab1b13611d 100644 (file)
 #endif /* CONFIG_QDIO_DEBUG */
 #define QDIO_USE_PROCESSING_STATE
 
-#ifdef CONFIG_QDIO_PERF_STATS
-#define QDIO_PERFORMANCE_STATS
-#endif /* CONFIG_QDIO_PERF_STATS */
-
 #define QDIO_MINIMAL_BH_RELIEF_TIME 16
 #define QDIO_TIMER_POLL_VALUE 1
 #define IQDIO_TIMER_POLL_VALUE 1
@@ -409,25 +405,23 @@ do_clear_global_summary(void)
 #define CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS 0x08
 #define CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS 0x04
 
-#ifdef QDIO_PERFORMANCE_STATS
 struct qdio_perf_stats {
-       unsigned int tl_runs;
+       unsigned long tl_runs;
 
-       unsigned int siga_outs;
-       unsigned int siga_ins;
-       unsigned int siga_syncs;
-       unsigned int pcis;
-       unsigned int thinints;
-       unsigned int fast_reqs;
+       unsigned long siga_outs;
+       unsigned long siga_ins;
+       unsigned long siga_syncs;
+       unsigned long pcis;
+       unsigned long thinints;
+       unsigned long fast_reqs;
 
        __u64 start_time_outbound;
-       unsigned int outbound_cnt;
-       unsigned int outbound_time;
+       unsigned long outbound_cnt;
+       unsigned long outbound_time;
        __u64 start_time_inbound;
-       unsigned int inbound_cnt;
-       unsigned int inbound_time;
+       unsigned long inbound_cnt;
+       unsigned long inbound_time;
 };
-#endif /* QDIO_PERFORMANCE_STATS */
 
 /* unlikely as the later the better */
 #define SYNC_MEMORY if (unlikely(q->siga_sync)) qdio_siga_sync_q(q)
index e4dc947e74e9fc2402a70e438c6e649bb0853ad6..ad60afe5dd11cbccc3927347018f94eec8b120f7 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/kthread.h>
 #include <linux/mutex.h>
 #include <asm/s390_rdev.h>
+#include <asm/reset.h>
 
 #include "ap_bus.h"
 
@@ -1128,6 +1129,19 @@ static void ap_poll_thread_stop(void)
        mutex_unlock(&ap_poll_thread_mutex);
 }
 
+static void ap_reset(void)
+{
+       int i, j;
+
+       for (i = 0; i < AP_DOMAINS; i++)
+               for (j = 0; j < AP_DEVICES; j++)
+                       ap_reset_queue(AP_MKQID(j, i));
+}
+
+static struct reset_call ap_reset_call = {
+       .fn = ap_reset,
+};
+
 /**
  * The module initialization code.
  */
@@ -1144,6 +1158,7 @@ int __init ap_module_init(void)
                printk(KERN_WARNING "AP instructions not installed.\n");
                return -ENODEV;
        }
+       register_reset_call(&ap_reset_call);
 
        /* Create /sys/bus/ap. */
        rc = bus_register(&ap_bus_type);
@@ -1197,6 +1212,7 @@ out_bus:
                bus_remove_file(&ap_bus_type, ap_bus_attrs[i]);
        bus_unregister(&ap_bus_type);
 out:
+       unregister_reset_call(&ap_reset_call);
        return rc;
 }
 
@@ -1227,6 +1243,7 @@ void ap_module_exit(void)
        for (i = 0; ap_bus_attrs[i]; i++)
                bus_remove_file(&ap_bus_type, ap_bus_attrs[i]);
        bus_unregister(&ap_bus_type);
+       unregister_reset_call(&ap_reset_call);
 }
 
 #ifndef CONFIG_ZCRYPT_MONOLITHIC
index 74c0eac083e46a19d5026c385350268b6fa39047..32933ed54b8a05dbe3534ac90395bbbf3d1ee283 100644 (file)
@@ -1032,9 +1032,9 @@ struct zfcp_data {
        wwn_t                   init_wwpn;
        fcp_lun_t               init_fcp_lun;
        char                    *driver_version;
-       kmem_cache_t            *fsf_req_qtcb_cache;
-       kmem_cache_t            *sr_buffer_cache;
-       kmem_cache_t            *gid_pn_cache;
+       struct kmem_cache               *fsf_req_qtcb_cache;
+       struct kmem_cache               *sr_buffer_cache;
+       struct kmem_cache               *gid_pn_cache;
 };
 
 /**
index 277826cdd0c845ff3eda616ebc7eb0130169e7c1..067f1519eb04dcda87ff07f79d6cae072675770e 100644 (file)
@@ -109,7 +109,7 @@ zfcp_fsf_req_alloc(mempool_t *pool, int req_flags)
                        ptr = kmalloc(size, GFP_ATOMIC);
                else
                        ptr = kmem_cache_alloc(zfcp_data.fsf_req_qtcb_cache,
-                                              SLAB_ATOMIC);
+                                              GFP_ATOMIC);
        }
 
        if (unlikely(!ptr))
index 385f4f768311500ea278ae379bf7a29b86d196c0..ac7d1258efee13610244b8e7a81feaf4a0348c7f 100644 (file)
@@ -621,7 +621,7 @@ static long read_ecp(unsigned minor, char __user *c, unsigned long cnt)
 static ssize_t bpp_read(struct file *f, char __user *c, size_t cnt, loff_t * ppos)
 {
       long rc;
-      unsigned minor = iminor(f->f_dentry->d_inode);
+      unsigned minor = iminor(f->f_path.dentry->d_inode);
       if (minor >= BPP_NO) return -ENODEV;
       if (!instances[minor].present) return -ENODEV;
 
@@ -774,7 +774,7 @@ static long write_ecp(unsigned minor, const char __user *c, unsigned long cnt)
 static ssize_t bpp_write(struct file *f, const char __user *c, size_t cnt, loff_t * ppos)
 {
       long errno = 0;
-      unsigned minor = iminor(f->f_dentry->d_inode);
+      unsigned minor = iminor(f->f_path.dentry->d_inode);
       if (minor >= BPP_NO) return -ENODEV;
       if (!instances[minor].present) return -ENODEV;
 
index f5803ecb19995cc200ef5eefa0cc882fba04d149..ad1c7db96cb4d8eb7bc38f561ff5535f3dd168c7 100644 (file)
@@ -404,7 +404,7 @@ static long wd_compat_ioctl(struct file *file, unsigned int cmd,
        case WIOCSTOP:
        case WIOCGSTAT:
                lock_kernel();
-               rval = wd_ioctl(file->f_dentry->d_inode, file, cmd, arg);
+               rval = wd_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
                unlock_kernel();
                break;
        /* everything else is handled by the generic compat layer */
index d92bc8827a9e0d3c7c68b8cef8ed8bce8c9b6acd..a4909e0c7f83877d435869735fa8ecffd30d3808 100644 (file)
@@ -121,7 +121,7 @@ static long d7s_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        __u8 ireg = 0;
        int error = 0;
 
-       if (D7S_MINOR != iminor(file->f_dentry->d_inode))
+       if (D7S_MINOR != iminor(file->f_path.dentry->d_inode))
                return -ENODEV;
 
        lock_kernel();
index 81ba2d71cee2aa4e206a361fa909a6dd82a2974c..4e2a0e2dcc2e9da9bdde64f2582588694d06f22f 100644 (file)
@@ -676,7 +676,7 @@ static long openprom_compat_ioctl(struct file *file, unsigned int cmd,
        case OPROMSETCUR:
        case OPROMPCI2NODE:
        case OPROMPATH2NODE:
-               rval = openprom_ioctl(file->f_dentry->d_inode, file, cmd, arg);
+               rval = openprom_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
                break;
        }
 
index 55b2b31bd7abbf0d2dbcde64af303c952b442821..2722af5d340428402e9085ba5421d4eee115e1cf 100644 (file)
@@ -610,7 +610,7 @@ static int vfc_mmap(struct file *file, struct vm_area_struct *vma)
        unsigned int map_size, ret, map_offset;
        struct vfc_dev *dev;
        
-       dev = vfc_get_dev_ptr(iminor(file->f_dentry->d_inode));
+       dev = vfc_get_dev_ptr(iminor(file->f_path.dentry->d_inode));
        if(dev == NULL)
                return -ENODEV;
 
index 335a25540c08687b5c171aa74ec7124c7465cace..68103e508db7077455dd437db6eae86797d63c0c 100644 (file)
@@ -313,7 +313,7 @@ NCR_700_detect(struct scsi_host_template *tpnt,
        hostdata->status = memory + STATUS_OFFSET;
        /* all of these offsets are L1_CACHE_BYTES separated.  It is fatal
         * if this isn't sufficient separation to avoid dma flushing issues */
-       BUG_ON(!dma_is_consistent(pScript) && L1_CACHE_BYTES < dma_get_cache_alignment());
+       BUG_ON(!dma_is_consistent(hostdata->dev, pScript) && L1_CACHE_BYTES < dma_get_cache_alignment());
        hostdata->slots = (struct NCR_700_command_slot *)(memory + SLOTS_OFFSET);
        hostdata->dev = dev;
 
@@ -362,11 +362,11 @@ NCR_700_detect(struct scsi_host_template *tpnt,
        for (j = 0; j < PATCHES; j++)
                script[LABELPATCHES[j]] = bS_to_host(pScript + SCRIPT[LABELPATCHES[j]]);
        /* now patch up fixed addresses. */
-       script_patch_32(script, MessageLocation,
+       script_patch_32(hostdata->dev, script, MessageLocation,
                        pScript + MSGOUT_OFFSET);
-       script_patch_32(script, StatusAddress,
+       script_patch_32(hostdata->dev, script, StatusAddress,
                        pScript + STATUS_OFFSET);
-       script_patch_32(script, ReceiveMsgAddress,
+       script_patch_32(hostdata->dev, script, ReceiveMsgAddress,
                        pScript + MSGIN_OFFSET);
 
        hostdata->script = script;
@@ -821,8 +821,9 @@ process_extended_message(struct Scsi_Host *host,
                        shost_printk(KERN_WARNING, host,
                                "Unexpected SDTR msg\n");
                        hostdata->msgout[0] = A_REJECT_MSG;
-                       dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE);
-                       script_patch_16(hostdata->script, MessageCount, 1);
+                       dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE);
+                       script_patch_16(hostdata->dev, hostdata->script,
+                                       MessageCount, 1);
                        /* SendMsgOut returns, so set up the return
                         * address */
                        resume_offset = hostdata->pScript + Ent_SendMessageWithATN;
@@ -833,8 +834,9 @@ process_extended_message(struct Scsi_Host *host,
                printk(KERN_INFO "scsi%d: (%d:%d), Unsolicited WDTR after CMD, Rejecting\n",
                       host->host_no, pun, lun);
                hostdata->msgout[0] = A_REJECT_MSG;
-               dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE);
-               script_patch_16(hostdata->script, MessageCount, 1);
+               dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE);
+               script_patch_16(hostdata->dev, hostdata->script, MessageCount,
+                               1);
                resume_offset = hostdata->pScript + Ent_SendMessageWithATN;
 
                break;
@@ -847,8 +849,9 @@ process_extended_message(struct Scsi_Host *host,
                printk("\n");
                /* just reject it */
                hostdata->msgout[0] = A_REJECT_MSG;
-               dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE);
-               script_patch_16(hostdata->script, MessageCount, 1);
+               dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE);
+               script_patch_16(hostdata->dev, hostdata->script, MessageCount,
+                               1);
                /* SendMsgOut returns, so set up the return
                 * address */
                resume_offset = hostdata->pScript + Ent_SendMessageWithATN;
@@ -929,8 +932,9 @@ process_message(struct Scsi_Host *host,     struct NCR_700_Host_Parameters *hostdata
                printk("\n");
                /* just reject it */
                hostdata->msgout[0] = A_REJECT_MSG;
-               dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE);
-               script_patch_16(hostdata->script, MessageCount, 1);
+               dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE);
+               script_patch_16(hostdata->dev, hostdata->script, MessageCount,
+                               1);
                /* SendMsgOut returns, so set up the return
                 * address */
                resume_offset = hostdata->pScript + Ent_SendMessageWithATN;
@@ -939,7 +943,7 @@ process_message(struct Scsi_Host *host,     struct NCR_700_Host_Parameters *hostdata
        }
        NCR_700_writel(temp, host, TEMP_REG);
        /* set us up to receive another message */
-       dma_cache_sync(hostdata->msgin, MSG_ARRAY_SIZE, DMA_FROM_DEVICE);
+       dma_cache_sync(hostdata->dev, hostdata->msgin, MSG_ARRAY_SIZE, DMA_FROM_DEVICE);
        return resume_offset;
 }
 
@@ -1019,9 +1023,9 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
                                slot->SG[1].ins = bS_to_host(SCRIPT_RETURN);
                                slot->SG[1].pAddr = 0;
                                slot->resume_offset = hostdata->pScript;
-                               dma_cache_sync(slot->SG, sizeof(slot->SG[0])*2, DMA_TO_DEVICE);
-                               dma_cache_sync(SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);
-                               
+                               dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG[0])*2, DMA_TO_DEVICE);
+                               dma_cache_sync(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);
+
                                /* queue the command for reissue */
                                slot->state = NCR_700_SLOT_QUEUED;
                                slot->flags = NCR_700_FLAG_AUTOSENSE;
@@ -1136,11 +1140,12 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
                        hostdata->cmd = slot->cmnd;
 
                        /* re-patch for this command */
-                       script_patch_32_abs(hostdata->script, CommandAddress, 
-                                           slot->pCmd);
-                       script_patch_16(hostdata->script,
+                       script_patch_32_abs(hostdata->dev, hostdata->script,
+                                           CommandAddress, slot->pCmd);
+                       script_patch_16(hostdata->dev, hostdata->script,
                                        CommandCount, slot->cmnd->cmd_len);
-                       script_patch_32_abs(hostdata->script, SGScriptStartAddress,
+                       script_patch_32_abs(hostdata->dev, hostdata->script,
+                                           SGScriptStartAddress,
                                            to32bit(&slot->pSG[0].ins));
 
                        /* Note: setting SXFER only works if we're
@@ -1150,13 +1155,13 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
                         * should therefore always clear ACK */
                        NCR_700_writeb(NCR_700_get_SXFER(hostdata->cmd->device),
                                       host, SXFER_REG);
-                       dma_cache_sync(hostdata->msgin,
+                       dma_cache_sync(hostdata->dev, hostdata->msgin,
                                       MSG_ARRAY_SIZE, DMA_FROM_DEVICE);
-                       dma_cache_sync(hostdata->msgout,
+                       dma_cache_sync(hostdata->dev, hostdata->msgout,
                                       MSG_ARRAY_SIZE, DMA_TO_DEVICE);
                        /* I'm just being paranoid here, the command should
                         * already have been flushed from the cache */
-                       dma_cache_sync(slot->cmnd->cmnd,
+                       dma_cache_sync(hostdata->dev, slot->cmnd->cmnd,
                                       slot->cmnd->cmd_len, DMA_TO_DEVICE);
 
 
@@ -1220,7 +1225,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
                hostdata->reselection_id = reselection_id;
                /* just in case we have a stale simple tag message, clear it */
                hostdata->msgin[1] = 0;
-               dma_cache_sync(hostdata->msgin,
+               dma_cache_sync(hostdata->dev, hostdata->msgin,
                               MSG_ARRAY_SIZE, DMA_BIDIRECTIONAL);
                if(hostdata->tag_negotiated & (1<<reselection_id)) {
                        resume_offset = hostdata->pScript + Ent_GetReselectionWithTag;
@@ -1336,7 +1341,7 @@ process_selection(struct Scsi_Host *host, __u32 dsp)
        hostdata->cmd = NULL;
        /* clear any stale simple tag message */
        hostdata->msgin[1] = 0;
-       dma_cache_sync(hostdata->msgin, MSG_ARRAY_SIZE,
+       dma_cache_sync(hostdata->dev, hostdata->msgin, MSG_ARRAY_SIZE,
                       DMA_BIDIRECTIONAL);
 
        if(id == 0xff) {
@@ -1433,29 +1438,30 @@ NCR_700_start_command(struct scsi_cmnd *SCp)
                NCR_700_set_flag(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION);
        }
 
-       script_patch_16(hostdata->script, MessageCount, count);
+       script_patch_16(hostdata->dev, hostdata->script, MessageCount, count);
 
 
-       script_patch_ID(hostdata->script,
+       script_patch_ID(hostdata->dev, hostdata->script,
                        Device_ID, 1<<scmd_id(SCp));
 
-       script_patch_32_abs(hostdata->script, CommandAddress, 
+       script_patch_32_abs(hostdata->dev, hostdata->script, CommandAddress,
                            slot->pCmd);
-       script_patch_16(hostdata->script, CommandCount, SCp->cmd_len);
+       script_patch_16(hostdata->dev, hostdata->script, CommandCount,
+                       SCp->cmd_len);
        /* finally plumb the beginning of the SG list into the script
         * */
-       script_patch_32_abs(hostdata->script, SGScriptStartAddress,
-                           to32bit(&slot->pSG[0].ins));
+       script_patch_32_abs(hostdata->dev, hostdata->script,
+                           SGScriptStartAddress, to32bit(&slot->pSG[0].ins));
        NCR_700_clear_fifo(SCp->device->host);
 
        if(slot->resume_offset == 0)
                slot->resume_offset = hostdata->pScript;
        /* now perform all the writebacks and invalidates */
-       dma_cache_sync(hostdata->msgout, count, DMA_TO_DEVICE);
-       dma_cache_sync(hostdata->msgin, MSG_ARRAY_SIZE,
+       dma_cache_sync(hostdata->dev, hostdata->msgout, count, DMA_TO_DEVICE);
+       dma_cache_sync(hostdata->dev, hostdata->msgin, MSG_ARRAY_SIZE,
                       DMA_FROM_DEVICE);
-       dma_cache_sync(SCp->cmnd, SCp->cmd_len, DMA_TO_DEVICE);
-       dma_cache_sync(hostdata->status, 1, DMA_FROM_DEVICE);
+       dma_cache_sync(hostdata->dev, SCp->cmnd, SCp->cmd_len, DMA_TO_DEVICE);
+       dma_cache_sync(hostdata->dev, hostdata->status, 1, DMA_FROM_DEVICE);
 
        /* set the synchronous period/offset */
        NCR_700_writeb(NCR_700_get_SXFER(SCp->device),
@@ -1631,7 +1637,7 @@ NCR_700_intr(int irq, void *dev_id)
                                        slot->SG[i].ins = bS_to_host(SCRIPT_NOP);
                                        slot->SG[i].pAddr = 0;
                                }
-                               dma_cache_sync(slot->SG, sizeof(slot->SG), DMA_TO_DEVICE);
+                               dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG), DMA_TO_DEVICE);
                                /* and pretend we disconnected after
                                 * the command phase */
                                resume_offset = hostdata->pScript + Ent_MsgInDuringData;
@@ -1897,9 +1903,9 @@ NCR_700_queuecommand(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *))
                }
                slot->SG[i].ins = bS_to_host(SCRIPT_RETURN);
                slot->SG[i].pAddr = 0;
-               dma_cache_sync(slot->SG, sizeof(slot->SG), DMA_TO_DEVICE);
+               dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG), DMA_TO_DEVICE);
                DEBUG((" SETTING %08lx to %x\n",
-                      (&slot->pSG[i].ins), 
+                      (&slot->pSG[i].ins),
                       slot->SG[i].ins));
        }
        slot->resume_offset = 0;
index f5c3caf344a7626b4c87bf670595e6fa120a5bc6..f38822db4210886f8654c33bd03a3e2dd15635b9 100644 (file)
@@ -415,31 +415,31 @@ struct NCR_700_Host_Parameters {
 #define NCR_710_MIN_XFERP      0
 #define NCR_700_MIN_PERIOD     25 /* for SDTR message, 100ns */
 
-#define script_patch_32(script, symbol, value) \
+#define script_patch_32(dev, script, symbol, value) \
 { \
        int i; \
        for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
                __u32 val = bS_to_cpu((script)[A_##symbol##_used[i]]) + value; \
                (script)[A_##symbol##_used[i]] = bS_to_host(val); \
-               dma_cache_sync(&(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
+               dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
                DEBUG((" script, patching %s at %d to 0x%lx\n", \
                       #symbol, A_##symbol##_used[i], (value))); \
        } \
 }
 
-#define script_patch_32_abs(script, symbol, value) \
+#define script_patch_32_abs(dev, script, symbol, value) \
 { \
        int i; \
        for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
                (script)[A_##symbol##_used[i]] = bS_to_host(value); \
-               dma_cache_sync(&(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
+               dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
                DEBUG((" script, patching %s at %d to 0x%lx\n", \
                       #symbol, A_##symbol##_used[i], (value))); \
        } \
 }
 
 /* Used for patching the SCSI ID in the SELECT instruction */
-#define script_patch_ID(script, symbol, value) \
+#define script_patch_ID(dev, script, symbol, value) \
 { \
        int i; \
        for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
@@ -447,13 +447,13 @@ struct NCR_700_Host_Parameters {
                val &= 0xff00ffff; \
                val |= ((value) & 0xff) << 16; \
                (script)[A_##symbol##_used[i]] = bS_to_host(val); \
-               dma_cache_sync(&(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
+               dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
                DEBUG((" script, patching ID field %s at %d to 0x%x\n", \
                       #symbol, A_##symbol##_used[i], val)); \
        } \
 }
 
-#define script_patch_16(script, symbol, value) \
+#define script_patch_16(dev, script, symbol, value) \
 { \
        int i; \
        for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
@@ -461,7 +461,7 @@ struct NCR_700_Host_Parameters {
                val &= 0xffff0000; \
                val |= ((value) & 0xffff); \
                (script)[A_##symbol##_used[i]] = bS_to_host(val); \
-               dma_cache_sync(&(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
+               dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
                DEBUG((" script, patching short field %s at %d to 0x%x\n", \
                       #symbol, A_##symbol##_used[i], val)); \
        } \
index 69569096dae537f164d52df669510de68bf866a8..60f5827271851e064d1ce807dd2b1848f4950ab0 100644 (file)
@@ -1737,7 +1737,7 @@ config SCSI_NCR53C7xx_FAST
 
 config SUN3_SCSI
        tristate "Sun3 NCR5380 SCSI"
-       depends on SUN3 && SCSI && BROKEN
+       depends on SUN3 && SCSI
        select SCSI_SPI_ATTRS
        help
          This option will enable support for the OBIO (onboard io) NCR5380
index 71a031df7a34320af014a1a64dc66364e3bae348..32f513b1b78ab314253e7ddceb4117aa5e40fcad 100644 (file)
@@ -56,8 +56,8 @@
 /* 2*ITNL timeout + 1 second */
 #define AIC94XX_SCB_TIMEOUT  (5*HZ)
 
-extern kmem_cache_t *asd_dma_token_cache;
-extern kmem_cache_t *asd_ascb_cache;
+extern struct kmem_cache *asd_dma_token_cache;
+extern struct kmem_cache *asd_ascb_cache;
 extern char sas_addr_str[2*SAS_ADDR_SIZE + 1];
 
 static inline void asd_stringify_sas_addr(char *p, const u8 *sas_addr)
index af7e011343643fab6b8404d2a04f419707eb2018..da94e126ca832d5e4d157c65c3b34acaab20620c 100644 (file)
@@ -1047,7 +1047,7 @@ irqreturn_t asd_hw_isr(int irq, void *dev_id)
 static inline struct asd_ascb *asd_ascb_alloc(struct asd_ha_struct *asd_ha,
                                              gfp_t gfp_flags)
 {
-       extern kmem_cache_t *asd_ascb_cache;
+       extern struct kmem_cache *asd_ascb_cache;
        struct asd_seq_data *seq = &asd_ha->seq;
        struct asd_ascb *ascb;
        unsigned long flags;
index 42302ef05ee56579777d2854e7d6e0c6942dfdf2..fbc82b00a418cf8ff6d43603a36ca75f2a83fa81 100644 (file)
@@ -450,8 +450,8 @@ static inline void asd_destroy_ha_caches(struct asd_ha_struct *asd_ha)
        asd_ha->scb_pool = NULL;
 }
 
-kmem_cache_t *asd_dma_token_cache;
-kmem_cache_t *asd_ascb_cache;
+struct kmem_cache *asd_dma_token_cache;
+struct kmem_cache *asd_ascb_cache;
 
 static int asd_create_global_caches(void)
 {
index 1427a41e844104149a7e71c4a3e639f01711718b..8f6b5bf580f6757fdcace40c5a41eb5359827d98 100644 (file)
@@ -110,6 +110,7 @@ typedef struct ide_scsi_obj {
 } idescsi_scsi_t;
 
 static DEFINE_MUTEX(idescsi_ref_mutex);
+static int idescsi_nocd;                       /* Set by module param to skip cd */
 
 #define ide_scsi_g(disk) \
        container_of((disk)->private_data, struct ide_scsi_obj, driver)
@@ -1127,6 +1128,9 @@ static int ide_scsi_probe(ide_drive_t *drive)
                warned = 1;
        }
 
+       if (idescsi_nocd && drive->media == ide_cdrom)
+               return -ENODEV;
+
        if (!strstr("ide-scsi", drive->driver_req) ||
            !drive->present ||
            drive->media == ide_disk ||
@@ -1187,6 +1191,8 @@ static void __exit exit_idescsi_module(void)
        driver_unregister(&idescsi_driver.gen_driver);
 }
 
+module_param(idescsi_nocd, int, 0600);
+MODULE_PARM_DESC(idescsi_nocd, "Disable handling of CD-ROMs so they may be driven by ide-cd");
 module_init(init_idescsi_module);
 module_exit(exit_idescsi_module);
 MODULE_LICENSE("GPL");
index ccd4dafce8e2d6d96a1d92df972c9be13e85d0b6..b318500785e58cdc9556064ee25f115feec070c6 100644 (file)
@@ -6940,7 +6940,7 @@ static int __devinit ipr_alloc_cmd_blks(struct ipr_ioa_cfg *ioa_cfg)
                return -ENOMEM;
 
        for (i = 0; i < IPR_NUM_CMD_BLKS; i++) {
-               ipr_cmd = pci_pool_alloc (ioa_cfg->ipr_cmd_pool, SLAB_KERNEL, &dma_addr);
+               ipr_cmd = pci_pool_alloc (ioa_cfg->ipr_cmd_pool, GFP_KERNEL, &dma_addr);
 
                if (!ipr_cmd) {
                        ipr_free_cmd_blks(ioa_cfg);
index d65bc4e0f2147f33a6ca81cb44fecac9ef3b1e66..2f0c07fc3f48c1da732c37e4862727b976595432 100644 (file)
@@ -36,7 +36,7 @@
 
 #include "../scsi_sas_internal.h"
 
-kmem_cache_t *sas_task_cache;
+struct kmem_cache *sas_task_cache;
 
 /*------------ SAS addr hash -----------*/
 void sas_hash_addr(u8 *hashed, const u8 *sas_addr)
index cbe0cad83b685c67d245049188519c83cefdf718..d03523d3bf38b73d173ce07f9a55cfc2d6067335 100644 (file)
@@ -24,7 +24,7 @@ char qla2x00_version_str[40];
 /*
  * SRB allocation cache
  */
-static kmem_cache_t *srb_cachep;
+static struct kmem_cache *srb_cachep;
 
 /*
  * Ioctl related information.
index 969c9e431028561b510be598dd7e846c0c86f62e..9ef693c8809aac59ef2d823798fd5592664c042c 100644 (file)
@@ -19,7 +19,7 @@ char qla4xxx_version_str[40];
 /*
  * SRB allocation cache
  */
-static kmem_cache_t *srb_cachep;
+static struct kmem_cache *srb_cachep;
 
 /*
  * Module parameter information and variables
index fafc00deaadea6fab42609d673b03aa6c8f4e7ee..24cffd98ee63546ce716e0277812dda9bafd08d2 100644 (file)
@@ -136,7 +136,7 @@ const char * scsi_device_type(unsigned type)
 EXPORT_SYMBOL(scsi_device_type);
 
 struct scsi_host_cmd_pool {
-       kmem_cache_t    *slab;
+       struct kmem_cache       *slab;
        unsigned int    users;
        char            *name;
        unsigned int    slab_flags;
index fb616c69151f69a3d6697658de3bbc87827729b6..1748e27501cdee45da304d4cdfd97f1c0ff37372 100644 (file)
@@ -36,7 +36,7 @@
 struct scsi_host_sg_pool {
        size_t          size;
        char            *name; 
-       kmem_cache_t    *slab;
+       struct kmem_cache       *slab;
        mempool_t       *pool;
 };
 
@@ -241,7 +241,7 @@ struct scsi_io_context {
        char sense[SCSI_SENSE_BUFFERSIZE];
 };
 
-static kmem_cache_t *scsi_io_context_cache;
+static struct kmem_cache *scsi_io_context_cache;
 
 static void scsi_end_async(struct request *req, int uptodate)
 {
index 386dbae17b446a2ccec29c401d2bc711ae04270f..d402aff5f314a4b2728da2d2d3c8f1c063092958 100644 (file)
@@ -33,7 +33,7 @@
 #include "scsi_tgt_priv.h"
 
 static struct workqueue_struct *scsi_tgtd;
-static kmem_cache_t *scsi_tgt_cmd_cache;
+static struct kmem_cache *scsi_tgt_cmd_cache;
 
 /*
  * TODO: this struct will be killed when the block layer supports large bios
index f6a452846fab7ba75a85c0242cdd4b4f3b881384..978bfc1e0c6a37c5edf91c916b783837a6ad4440 100644 (file)
@@ -863,7 +863,7 @@ static void sd_rescan(struct device *dev)
  */
 static long sd_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-       struct block_device *bdev = file->f_dentry->d_inode->i_bdev;
+       struct block_device *bdev = file->f_path.dentry->d_inode->i_bdev;
        struct gendisk *disk = bdev->bd_disk;
        struct scsi_device *sdev = scsi_disk(disk)->device;
 
index 587274dd70596a18d7eda3f9326bd8220a9ec017..e016e0906e1a99aa2a26728e3b9238213aafd97b 100644 (file)
@@ -922,7 +922,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
        struct st_modedef *STm;
        struct st_partstat *STps;
        char *name = tape_name(STp);
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        int mode = TAPE_MODE(inode);
 
        STp->ready = ST_READY;
index 3b3f3050a877f0e221ee49fb649b45cc20b9acbc..43f5b6aa7dc4a502ff82ea4487572aa36611c76a 100644 (file)
@@ -1271,7 +1271,7 @@ static irqreturn_t NCR5380_intr (int irq, void *dev_id)
        NCR_PRINT(NDEBUG_INTR);
        if ((NCR5380_read(STATUS_REG) & (SR_SEL|SR_IO)) == (SR_SEL|SR_IO)) {
            done = 0;
-           ENABLE_IRQ();
+//         ENABLE_IRQ();
            INT_PRINTK("scsi%d: SEL interrupt\n", HOSTNO);
            NCR5380_reselect(instance);
            (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG);
@@ -1304,7 +1304,7 @@ static irqreturn_t NCR5380_intr (int irq, void *dev_id)
                INT_PRINTK("scsi%d: PHASE MISM or EOP interrupt\n", HOSTNO);
                NCR5380_dma_complete( instance );
                done = 0;
-               ENABLE_IRQ();
+//             ENABLE_IRQ();
            } else
 #endif /* REAL_DMA */
            {
index d56d85dd9ba0ed60c943e8bd99956a22c06418ca..69ee3e4a820e0dfc1a38b7b2537af29e84fe00bd 100644 (file)
@@ -75,9 +75,9 @@
 #define REAL_DMA
 
 #include "scsi.h"
+#include "initio.h"
 #include <scsi/scsi_host.h>
 #include "sun3_scsi.h"
-#include "NCR5380.h"
 
 static void NCR5380_print(struct Scsi_Host *instance);
 
index a1103b3e2034444769b608ad95ff7683e7978c5b..b29a9d661ca41740b7e7a9693f4a04fb806ec64a 100644 (file)
@@ -221,7 +221,7 @@ struct sun3_udc_regs {
  *
  */
 
-
+#include "NCR5380.h"
 
 #if NDEBUG & NDEBUG_ARBITRATION
 #define ARB_PRINTK(format, args...) \
index 92def310a84c05eeaf3a317c99468799fc65bb17..bb0c9fd99e68646617e94fb6aa8cdffc91d7bedd 100644 (file)
@@ -41,9 +41,9 @@
 #define REAL_DMA
 
 #include "scsi.h"
+#include "initio.h"
 #include <scsi/scsi_host.h>
 #include "sun3_scsi.h"
-#include "NCR5380.h"
 
 extern int sun3_map_test(unsigned long, char *);
 
index 6a1a568ca6498b932c89c5eaeed32142885ebf02..facb6785561906dc0b738ed5ca35cbe55946f064 100644 (file)
@@ -214,8 +214,8 @@ static void serial21285_shutdown(struct uart_port *port)
 }
 
 static void
-serial21285_set_termios(struct uart_port *port, struct termios *termios,
-                       struct termios *old)
+serial21285_set_termios(struct uart_port *port, struct ktermios *termios,
+                       struct ktermios *old)
 {
        unsigned long flags;
        unsigned int baud, quot, h_lcr;
index 9b8b585513ec5aaeccf108f0d0a0498b174a7ea3..cad426c9711e970d0b7d62718bf894b7ca54536c 100644 (file)
@@ -1061,7 +1061,7 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
        return 0;
 }
 
-static void rs_set_termios(struct tty_struct *tty, struct termios *old_termios)
+static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
        struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
 
index 634ecca36a7737d19397ea9b32d2d6636a6fc65a..68817a7d8c0d46c7ea33e05e3a1eeac7013a7db8 100644 (file)
@@ -1523,7 +1523,7 @@ static int rs_360_ioctl(struct tty_struct *tty, struct file * file,
 
 /* FIX UP modem control here someday......
 */
-static void rs_360_set_termios(struct tty_struct *tty, struct termios *old_termios)
+static void rs_360_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
        ser_info_t *info = (ser_info_t *)tty->driver_data;
 
index e34bd03cfce738c4d82ff34aae9718af1e53332d..51f3c739f7e1b87943734ae1fd746c72492891eb 100644 (file)
@@ -1763,8 +1763,8 @@ static unsigned int serial8250_get_divisor(struct uart_port *port, unsigned int
 }
 
 static void
-serial8250_set_termios(struct uart_port *port, struct termios *termios,
-                      struct termios *old)
+serial8250_set_termios(struct uart_port *port, struct ktermios *termios,
+                      struct ktermios *old)
 {
        struct uart_8250_port *up = (struct uart_8250_port *)port;
        unsigned char cval, fcr = 0;
diff --git a/drivers/serial/8250_exar_st16c554.c b/drivers/serial/8250_exar_st16c554.c
new file mode 100644 (file)
index 0000000..567143a
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ *  linux/drivers/serial/8250_exar.c
+ *
+ *  Written by Paul B Schroeder < pschroeder "at" uplogix "dot" com >
+ *  Based on 8250_boca.
+ *
+ *  Copyright (C) 2005 Russell King.
+ *  Data taken from include/asm-i386/serial.h
+ *
+ * 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/module.h>
+#include <linux/init.h>
+#include <linux/serial_8250.h>
+
+#define PORT(_base,_irq)                               \
+       {                                               \
+               .iobase         = _base,                \
+               .irq            = _irq,                 \
+               .uartclk        = 1843200,              \
+               .iotype         = UPIO_PORT,            \
+               .flags          = UPF_BOOT_AUTOCONF,    \
+       }
+
+static struct plat_serial8250_port exar_data[] = {
+       PORT(0x100, 5),
+       PORT(0x108, 5),
+       PORT(0x110, 5),
+       PORT(0x118, 5),
+       { },
+};
+
+static struct platform_device exar_device = {
+       .name                   = "serial8250",
+       .id                     = PLAT8250_DEV_EXAR_ST16C554,
+       .dev                    = {
+               .platform_data  = exar_data,
+       },
+};
+
+static int __init exar_init(void)
+{
+       return platform_device_register(&exar_device);
+}
+
+module_init(exar_init);
+
+MODULE_AUTHOR("Paul B Schroeder");
+MODULE_DESCRIPTION("8250 serial probe module for Exar cards");
+MODULE_LICENSE("GPL");
index 71d907c8288b15a69214dc47f19578495da8a33c..d3d6b82706b5edbb548211187e96e28956859a4a 100644 (file)
@@ -464,11 +464,38 @@ static void __devexit serial_pnp_remove(struct pnp_dev *dev)
                serial8250_unregister_port(line - 1);
 }
 
+#ifdef CONFIG_PM
+static int serial_pnp_suspend(struct pnp_dev *dev, pm_message_t state)
+{
+       long line = (long)pnp_get_drvdata(dev);
+
+       if (!line)
+               return -ENODEV;
+       serial8250_suspend_port(line - 1);
+       return 0;
+}
+
+static int serial_pnp_resume(struct pnp_dev *dev)
+{
+       long line = (long)pnp_get_drvdata(dev);
+
+       if (!line)
+               return -ENODEV;
+       serial8250_resume_port(line - 1);
+       return 0;
+}
+#else
+#define serial_pnp_suspend NULL
+#define serial_pnp_resume NULL
+#endif /* CONFIG_PM */
+
 static struct pnp_driver serial_pnp_driver = {
        .name           = "serial",
-       .id_table       = pnp_dev_table,
        .probe          = serial_pnp_probe,
        .remove         = __devexit_p(serial_pnp_remove),
+       .suspend        = serial_pnp_suspend,
+       .resume         = serial_pnp_resume,
+       .id_table       = pnp_dev_table,
 };
 
 static int __init serial8250_pnp_init(void)
index 0b71e7d18903ddd6d36e1d859cde23beee02c891..fc12d5df10e2175f3c6346c7a371ca79da8c6780 100644 (file)
@@ -210,6 +210,17 @@ config SERIAL_8250_BOCA
          To compile this driver as a module, choose M here: the module
          will be called 8250_boca.
 
+config SERIAL_8250_EXAR_ST16C554
+       tristate "Support Exar ST16C554/554D Quad UART"
+       depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
+       help
+         The Uplogix Envoy TU301 uses this Exar Quad UART.  If you are
+         tinkering with your Envoy TU301, or have a machine with this UART,
+         say Y here.
+
+         To compile this driver as a module, choose M here: the module
+         will be called 8250_exar_st16c554.
+
 config SERIAL_8250_HUB6
        tristate "Support Hub6 cards"
        depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
@@ -511,6 +522,25 @@ config SERIAL_IMX_CONSOLE
          your boot loader (lilo or loadlin) about how to pass options to the
          kernel at boot time.)
 
+config SERIAL_UARTLITE
+       tristate "Xilinx uartlite serial port support"
+       depends on PPC32
+       select SERIAL_CORE
+       help
+         Say Y here if you want to use the Xilinx uartlite serial controller.
+
+         To compile this driver as a module, choose M here: the
+         module will be called uartlite.ko.
+
+config SERIAL_UARTLITE_CONSOLE
+       bool "Support for console on Xilinx uartlite serial port"
+       depends on SERIAL_UARTLITE=y
+       select SERIAL_CORE_CONSOLE
+       help
+         Say Y here if you wish to use a Xilinx uartlite as the system
+         console (the system console is the device which receives all kernel
+         messages and warnings and which allows logins in single user mode).
+
 config SERIAL_SUNCORE
        bool
        depends on SPARC
index b4d8a7c182e3a7b780cf2a9dfe8c87e4298055f2..df3632cd7df92e449cdc90bc61dcddc06d692209 100644 (file)
@@ -17,6 +17,7 @@ obj-$(CONFIG_SERIAL_8250_CONSOLE) += 8250_early.o
 obj-$(CONFIG_SERIAL_8250_FOURPORT) += 8250_fourport.o
 obj-$(CONFIG_SERIAL_8250_ACCENT) += 8250_accent.o
 obj-$(CONFIG_SERIAL_8250_BOCA) += 8250_boca.o
+obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554) += 8250_exar_st16c554.o
 obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o
 obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o
 obj-$(CONFIG_SERIAL_8250_AU1X00) += 8250_au1x00.o
@@ -55,4 +56,5 @@ obj-$(CONFIG_SERIAL_VR41XX) += vr41xx_siu.o
 obj-$(CONFIG_SERIAL_SGI_IOC4) += ioc4_serial.o
 obj-$(CONFIG_SERIAL_SGI_IOC3) += ioc3_serial.o
 obj-$(CONFIG_SERIAL_ATMEL) += atmel_serial.o
+obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o
 obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
index 4213fabc62bf864a033aca5ff1c5b120b830cf57..61db6973755a4ee76eed9f27cac40ced59814c20 100644 (file)
@@ -129,6 +129,8 @@ static void pl010_rx_chars(struct uart_port *port)
                 */
                rsr = readb(port->membase + UART01x_RSR) | UART_DUMMY_RSR_RX;
                if (unlikely(rsr & UART01x_RSR_ANY)) {
+                       writel(0, port->membase + UART01x_ECR);
+
                        if (rsr & UART01x_RSR_BE) {
                                rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE);
                                port->icount.brk++;
@@ -343,8 +345,8 @@ static void pl010_shutdown(struct uart_port *port)
 }
 
 static void
-pl010_set_termios(struct uart_port *port, struct termios *termios,
-                    struct termios *old)
+pl010_set_termios(struct uart_port *port, struct ktermios *termios,
+                    struct ktermios *old)
 {
        unsigned int lcr_h, old_cr;
        unsigned long flags;
index d503625730df56dc4334868acba23a33d486e802..9a3b374b2a08d89399b91d75cd613351b83978bf 100644 (file)
@@ -412,8 +412,8 @@ static void pl011_shutdown(struct uart_port *port)
 }
 
 static void
-pl011_set_termios(struct uart_port *port, struct termios *termios,
-                    struct termios *old)
+pl011_set_termios(struct uart_port *port, struct ktermios *termios,
+                    struct ktermios *old)
 {
        unsigned int lcr_h, old_cr;
        unsigned long flags;
index 391a1f4167a4f38819997c5a80cb12607e788fa6..ed7f7209ea5926a8aa840b667884448f6c232ead 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  linux/drivers/char/at91_serial.c
+ *  linux/drivers/char/atmel_serial.c
  *
  *  Driver for Atmel AT91 / AT32 Serial ports
  *  Copyright (C) 2003 Rick Bronson
 
 #include <asm/io.h>
 
-#include <asm/arch/at91rm9200_pdc.h>
 #include <asm/mach/serial_at91.h>
 #include <asm/arch/board.h>
+#include <asm/arch/at91_pdc.h>
 #ifdef CONFIG_ARM
-#include <asm/arch/system.h>
+#include <asm/arch/cpu.h>
 #include <asm/arch/gpio.h>
 #endif
 
@@ -137,8 +137,8 @@ static void atmel_set_mctrl(struct uart_port *port, u_int mctrl)
        unsigned int control = 0;
        unsigned int mode;
 
-#ifdef CONFIG_ARM
-       if (arch_identify() == ARCH_ID_AT91RM9200) {
+#ifdef CONFIG_ARCH_AT91RM9200
+       if (cpu_is_at91rm9200()) {
                /*
                 * AT91RM9200 Errata #39: RTS0 is not internally connected to PA21.
                 *  We need to drive the pin manually.
@@ -478,7 +478,7 @@ static void atmel_serial_pm(struct uart_port *port, unsigned int state, unsigned
 /*
  * Change the port parameters
  */
-static void atmel_set_termios(struct uart_port *port, struct termios * termios, struct termios * old)
+static void atmel_set_termios(struct uart_port *port, struct ktermios * termios, struct ktermios * old)
 {
        unsigned long flags;
        unsigned int mode, imr, quot, baud;
index eced2ad1a8d9b793d9da4a47a1ca13ac50832bf2..fe1763b2a6d52bb88edfba40cdd6d709710058fb 100644 (file)
@@ -31,8 +31,8 @@
 #define                ATMEL_US_RSTIT          (1 << 13)               /* Reset Iterations */
 #define                ATMEL_US_RSTNACK        (1 << 14)               /* Reset Non Acknowledge */
 #define                ATMEL_US_RETTO          (1 << 15)               /* Rearm Time-out */
-#define                ATMEL_US_DTREN          (1 << 16)               /* Data Terminal Ready Enable */
-#define                ATMEL_US_DTRDIS         (1 << 17)               /* Data Terminal Ready Disable */
+#define                ATMEL_US_DTREN          (1 << 16)               /* Data Terminal Ready Enable [AT91RM9200 only] */
+#define                ATMEL_US_DTRDIS         (1 << 17)               /* Data Terminal Ready Disable [AT91RM9200 only] */
 #define                ATMEL_US_RTSEN          (1 << 18)               /* Request To Send Enable */
 #define                ATMEL_US_RTSDIS         (1 << 19)               /* Request To Send Disable */
 
@@ -92,9 +92,9 @@
 #define                ATMEL_US_TXBUFE         (1 << 11)               /* Transmission Buffer Empty */
 #define                ATMEL_US_RXBUFF         (1 << 12)               /* Reception Buffer Full */
 #define                ATMEL_US_NACK           (1 << 13)               /* Non Acknowledge */
-#define                ATMEL_US_RIIC           (1 << 16)               /* Ring Indicator Input Change */
-#define                ATMEL_US_DSRIC          (1 << 17)               /* Data Set Ready Input Change */
-#define                ATMEL_US_DCDIC          (1 << 18)               /* Data Carrier Detect Input Change */
+#define                ATMEL_US_RIIC           (1 << 16)               /* Ring Indicator Input Change [AT91RM9200 only] */
+#define                ATMEL_US_DSRIC          (1 << 17)               /* Data Set Ready Input Change [AT91RM9200 only] */
+#define                ATMEL_US_DCDIC          (1 << 18)               /* Data Carrier Detect Input Change [AT91RM9200 only] */
 #define                ATMEL_US_CTSIC          (1 << 19)               /* Clear to Send Input Change */
 #define                ATMEL_US_RI             (1 << 20)               /* RI */
 #define                ATMEL_US_DSR            (1 << 21)               /* DSR */
 #define ATMEL_US_CSR           0x14                    /* Channel Status Register */
 #define ATMEL_US_RHR           0x18                    /* Receiver Holding Register */
 #define ATMEL_US_THR           0x1c                    /* Transmitter Holding Register */
+#define        ATMEL_US_SYNH           (1 << 15)               /* Transmit/Receive Sync [SAM9 only] */
 
 #define ATMEL_US_BRGR          0x20                    /* Baud Rate Generator Register */
 #define                ATMEL_US_CD             (0xffff << 0)           /* Clock Divider */
index 598012714882751888ede1f3dda4f11941c94680..23827189ec0e7891645d36fac7e933be6acadadf 100644 (file)
@@ -286,8 +286,8 @@ static void clps711xuart_shutdown(struct uart_port *port)
 }
 
 static void
-clps711xuart_set_termios(struct uart_port *port, struct termios *termios,
-                        struct termios *old)
+clps711xuart_set_termios(struct uart_port *port, struct ktermios *termios,
+                        struct ktermios *old)
 {
        unsigned int ubrlcr, baud, quot;
        unsigned long flags;
index 7a24e53546c71501c4017cf231a6615ce57ab8c2..42b050c46abed3c17572b1865e5ba9c2a3432dde 100644 (file)
@@ -804,8 +804,8 @@ static struct e100_serial rs_table[] = {
 
 #define NR_PORTS (sizeof(rs_table)/sizeof(struct e100_serial))
 
-static struct termios *serial_termios[NR_PORTS];
-static struct termios *serial_termios_locked[NR_PORTS];
+static struct ktermios *serial_termios[NR_PORTS];
+static struct ktermios *serial_termios_locked[NR_PORTS];
 #ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER
 static struct fast_timer fast_timers[NR_PORTS];
 #endif
@@ -4223,7 +4223,7 @@ rs_ioctl(struct tty_struct *tty, struct file * file,
 }
 
 static void
-rs_set_termios(struct tty_struct *tty, struct termios *old_termios)
+rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
        struct e100_serial *info = (struct e100_serial *)tty->driver_data;
 
@@ -4877,6 +4877,8 @@ rs_init(void)
        driver->init_termios = tty_std_termios;
        driver->init_termios.c_cflag =
                B115200 | CS8 | CREAD | HUPCL | CLOCAL; /* is normally B9600 default... */
+       driver->init_termios.c_ispeed = 115200;
+       driver->init_termios.c_ospeed = 115200;
        driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
        driver->termios = serial_termios;
        driver->termios_locked = serial_termios_locked;
index f30b93d6ef79ff85e7a0318eba71880d3c6a6686..4a23340663aaaa10448d80a9865b8052057653bf 100644 (file)
@@ -93,8 +93,8 @@ struct e100_serial {
 
        struct work_struct      work;
        struct async_icount     icount;   /* error-statistics etc.*/
-       struct termios          normal_termios;
-       struct termios          callout_termios;
+       struct ktermios         normal_termios;
+       struct ktermios         callout_termios;
 #ifdef DECLARE_WAITQUEUE
        wait_queue_head_t       open_wait;
        wait_queue_head_t       close_wait;
index 53662b33b84164c9f023033a3cdbb7d4dcd5b429..587d87b9eb3cebede48fa55362b56ccd8339e16d 100644 (file)
@@ -1,11 +1,13 @@
 /*
- * dz.c: Serial port driver for DECStations equiped
+ * dz.c: Serial port driver for DECstations equipped
  *       with the DZ chipset.
  *
  * Copyright (C) 1998 Olivier A. D. Lebaillif
  *
  * Email: olivier.lebaillif@ifrsys.com
  *
+ * Copyright (C) 2004, 2006  Maciej W. Rozycki
+ *
  * [31-AUG-98] triemer
  * Changed IRQ to use Harald's dec internals interrupts.h
  * removed base_addr code - moving address assignment to setup.c
 
 #undef DEBUG_DZ
 
+#if defined(CONFIG_SERIAL_DZ_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
+#include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/console.h>
+#include <linux/sysrq.h>
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
 #include <linux/serial_core.h>
 #include <asm/system.h>
 #include <asm/uaccess.h>
 
-#define CONSOLE_LINE (3)       /* for definition of struct console */
-
 #include "dz.h"
 
-#define DZ_INTR_DEBUG 1
-
 static char *dz_name = "DECstation DZ serial driver version ";
-static char *dz_version = "1.02";
+static char *dz_version = "1.03";
 
 struct dz_port {
        struct uart_port        port;
@@ -61,22 +65,6 @@ struct dz_port {
 
 static struct dz_port dz_ports[DZ_NB_PORT];
 
-#ifdef DEBUG_DZ
-/*
- * debugging code to send out chars via prom
- */
-static void debug_console(const char *s, int count)
-{
-       unsigned i;
-
-       for (i = 0; i < count; i++) {
-               if (*s == 10)
-                       prom_printf("%c", 13);
-               prom_printf("%c", *s++);
-       }
-}
-#endif
-
 /*
  * ------------------------------------------------------------
  * dz_in () and dz_out ()
@@ -90,6 +78,7 @@ static inline unsigned short dz_in(struct dz_port *dport, unsigned offset)
 {
        volatile unsigned short *addr =
                (volatile unsigned short *) (dport->port.membase + offset);
+
        return *addr;
 }
 
@@ -98,6 +87,7 @@ static inline void dz_out(struct dz_port *dport, unsigned offset,
 {
        volatile unsigned short *addr =
                (volatile unsigned short *) (dport->port.membase + offset);
+
        *addr = value;
 }
 
@@ -144,7 +134,7 @@ static void dz_stop_rx(struct uart_port *uport)
 
        spin_lock_irqsave(&dport->port.lock, flags);
        dport->cflag &= ~DZ_CREAD;
-       dz_out(dport, DZ_LPR, dport->cflag);
+       dz_out(dport, DZ_LPR, dport->cflag | dport->port.line);
        spin_unlock_irqrestore(&dport->port.lock, flags);
 }
 
@@ -155,14 +145,14 @@ static void dz_enable_ms(struct uart_port *port)
 
 /*
  * ------------------------------------------------------------
- * Here starts the interrupt handling routines.  All of the
- * following subroutines are declared as inline and are folded
- * into dz_interrupt.  They were separated out for readability's
- * sake.
  *
- * Note: rs_interrupt() is a "fast" interrupt, which means that it
+ * Here start the interrupt handling routines.  All of the following
+ * subroutines are declared as inline and are folded into
+ * dz_interrupt.  They were separated out for readability's sake.
+ *
+ * Note: dz_interrupt() is a "fast" interrupt, which means that it
  * runs with interrupts turned off.  People who may want to modify
- * rs_interrupt() should try to keep the interrupt handler as fast as
+ * dz_interrupt() should try to keep the interrupt handler as fast as
  * possible.  After you are done making modifications, it is not a bad
  * idea to do:
  *
@@ -180,92 +170,74 @@ static void dz_enable_ms(struct uart_port *port)
  * This routine deals with inputs from any lines.
  * ------------------------------------------------------------
  */
-static inline void dz_receive_chars(struct dz_port *dport)
+static inline void dz_receive_chars(struct dz_port *dport_in,
+                                   struct pt_regs *regs)
 {
+       struct dz_port *dport;
        struct tty_struct *tty = NULL;
        struct uart_icount *icount;
-       int ignore = 0;
-       unsigned short status, tmp;
+       int lines_rx[DZ_NB_PORT] = { [0 ... DZ_NB_PORT - 1] = 0 };
+       unsigned short status;
        unsigned char ch, flag;
+       int i;
 
-       /* this code is going to be a problem...
-          the call to tty_flip_buffer is going to need
-          to be rethought...
-        */
-       do {
-               status = dz_in(dport, DZ_RBUF);
-
-               /* punt so we don't get duplicate characters */
-               if (!(status & DZ_DVAL))
-                       goto ignore_char;
-
-
-               ch = UCHAR(status);     /* grab the char */
-               flag = TTY_NORMAL;
+       while ((status = dz_in(dport_in, DZ_RBUF)) & DZ_DVAL) {
+               dport = &dz_ports[LINE(status)];
+               tty = dport->port.info->tty;    /* point to the proper dev */
 
-#if 0
-               if (info->is_console) {
-                       if (ch == 0)
-                               return;         /* it's a break ... */
-               }
-#endif
+               ch = UCHAR(status);             /* grab the char */
 
-               tty = dport->port.info->tty;/* now tty points to the proper dev */
                icount = &dport->port.icount;
-
-               if (!tty)
-                       break;
-
                icount->rx++;
 
-               /* keep track of the statistics */
-               if (status & (DZ_OERR | DZ_FERR | DZ_PERR)) {
-                       if (status & DZ_PERR)   /* parity error */
-                               icount->parity++;
-                       else if (status & DZ_FERR)      /* frame error */
-                               icount->frame++;
-                       if (status & DZ_OERR)   /* overrun error */
-                               icount->overrun++;
-
-                       /*  check to see if we should ignore the character
-                          and mask off conditions that should be ignored
+               flag = TTY_NORMAL;
+               if (status & DZ_FERR) {         /* frame error */
+                       /*
+                        * There is no separate BREAK status bit, so
+                        * treat framing errors as BREAKs for Magic SysRq
+                        * and SAK; normally, otherwise.
                         */
-
-                       if (status & dport->port.ignore_status_mask) {
-                               if (++ignore > 100)
-                                       break;
-                               goto ignore_char;
-                       }
-                       /* mask off the error conditions we want to ignore */
-                       tmp = status & dport->port.read_status_mask;
-
-                       if (tmp & DZ_PERR) {
-                               flag = TTY_PARITY;
-#ifdef DEBUG_DZ
-                               debug_console("PERR\n", 5);
-#endif
-                       } else if (tmp & DZ_FERR) {
+                       if (uart_handle_break(&dport->port))
+                               continue;
+                       if (dport->port.flags & UPF_SAK)
+                               flag = TTY_BREAK;
+                       else
                                flag = TTY_FRAME;
-#ifdef DEBUG_DZ
-                               debug_console("FERR\n", 5);
-#endif
-                       }
-                       if (tmp & DZ_OERR) {
-#ifdef DEBUG_DZ
-                               debug_console("OERR\n", 5);
-#endif
-                               tty_insert_flip_char(tty, ch, flag);
-                               ch = 0;
-                               flag = TTY_OVERRUN;
-                       }
+               } else if (status & DZ_OERR)    /* overrun error */
+                       flag = TTY_OVERRUN;
+               else if (status & DZ_PERR)      /* parity error */
+                       flag = TTY_PARITY;
+
+               /* keep track of the statistics */
+               switch (flag) {
+               case TTY_FRAME:
+                       icount->frame++;
+                       break;
+               case TTY_PARITY:
+                       icount->parity++;
+                       break;
+               case TTY_OVERRUN:
+                       icount->overrun++;
+                       break;
+               case TTY_BREAK:
+                       icount->brk++;
+                       break;
+               default:
+                       break;
                }
-               tty_insert_flip_char(tty, ch, flag);
-             ignore_char:
-                       ;
-       } while (status & DZ_DVAL);
 
-       if (tty)
-               tty_flip_buffer_push(tty);
+               if (uart_handle_sysrq_char(&dport->port, ch, regs))
+                       continue;
+
+               if ((status & dport->port.ignore_status_mask) == 0) {
+                       uart_insert_char(&dport->port,
+                                        status, DZ_OERR, ch, flag);
+                       lines_rx[LINE(status)] = 1;
+               }
+       }
+       for (i = 0; i < DZ_NB_PORT; i++)
+               if (lines_rx[i])
+                       tty_flip_buffer_push(dz_ports[i].port.info->tty);
 }
 
 /*
@@ -275,26 +247,32 @@ static inline void dz_receive_chars(struct dz_port *dport)
  * This routine deals with outputs to any lines.
  * ------------------------------------------------------------
  */
-static inline void dz_transmit_chars(struct dz_port *dport)
+static inline void dz_transmit_chars(struct dz_port *dport_in)
 {
-       struct circ_buf *xmit = &dport->port.info->xmit;
+       struct dz_port *dport;
+       struct circ_buf *xmit;
+       unsigned short status;
        unsigned char tmp;
 
-       if (dport->port.x_char) {       /* XON/XOFF chars */
+       status = dz_in(dport_in, DZ_CSR);
+       dport = &dz_ports[LINE(status)];
+       xmit = &dport->port.info->xmit;
+
+       if (dport->port.x_char) {               /* XON/XOFF chars */
                dz_out(dport, DZ_TDR, dport->port.x_char);
                dport->port.icount.tx++;
                dport->port.x_char = 0;
                return;
        }
-       /* if nothing to do or stopped or hardware stopped */
+       /* If nothing to do or stopped or hardware stopped. */
        if (uart_circ_empty(xmit) || uart_tx_stopped(&dport->port)) {
                dz_stop_tx(&dport->port);
                return;
        }
 
        /*
-        * if something to do ... (rember the dz has no output fifo so we go
-        * one char at a time :-<
+        * If something to do... (remember the dz has no output fifo,
+        * so we go one char at a time) :-<
         */
        tmp = xmit->buf[xmit->tail];
        xmit->tail = (xmit->tail + 1) & (DZ_XMIT_SIZE - 1);
@@ -304,23 +282,29 @@ static inline void dz_transmit_chars(struct dz_port *dport)
        if (uart_circ_chars_pending(xmit) < DZ_WAKEUP_CHARS)
                uart_write_wakeup(&dport->port);
 
-       /* Are we done */
+       /* Are we are done. */
        if (uart_circ_empty(xmit))
                dz_stop_tx(&dport->port);
 }
 
 /*
  * ------------------------------------------------------------
- * check_modem_status ()
+ * check_modem_status()
  *
- * Only valid for the MODEM line duh !
+ * DS 3100 & 5100: Only valid for the MODEM line, duh!
+ * DS 5000/200: Valid for the MODEM and PRINTER line.
  * ------------------------------------------------------------
  */
 static inline void check_modem_status(struct dz_port *dport)
 {
+       /*
+        * FIXME:
+        * 1. No status change interrupt; use a timer.
+        * 2. Handle the 3100/5000 as appropriate. --macro
+        */
        unsigned short status;
 
-       /* if not ne modem line just return */
+       /* If not the modem line just return.  */
        if (dport->port.line != DZ_MODEM)
                return;
 
@@ -341,21 +325,18 @@ static inline void check_modem_status(struct dz_port *dport)
  */
 static irqreturn_t dz_interrupt(int irq, void *dev)
 {
-       struct dz_port *dport;
+       struct dz_port *dport = (struct dz_port *)dev;
        unsigned short status;
 
        /* get the reason why we just got an irq */
-       status = dz_in((struct dz_port *)dev, DZ_CSR);
-       dport = &dz_ports[LINE(status)];
+       status = dz_in(dport, DZ_CSR);
 
-       if (status & DZ_RDONE)
-               dz_receive_chars(dport);
+       if ((status & (DZ_RDONE | DZ_RIE)) == (DZ_RDONE | DZ_RIE))
+               dz_receive_chars(dport, regs);
 
-       if (status & DZ_TRDY)
+       if ((status & (DZ_TRDY | DZ_TIE)) == (DZ_TRDY | DZ_TIE))
                dz_transmit_chars(dport);
 
-       /* FIXME: what about check modem status??? --rmk */
-
        return IRQ_HANDLED;
 }
 
@@ -367,13 +348,13 @@ static irqreturn_t dz_interrupt(int irq, void *dev)
 
 static unsigned int dz_get_mctrl(struct uart_port *uport)
 {
+       /*
+        * FIXME: Handle the 3100/5000 as appropriate. --macro
+        */
        struct dz_port *dport = (struct dz_port *)uport;
        unsigned int mctrl = TIOCM_CAR | TIOCM_DSR | TIOCM_CTS;
 
        if (dport->port.line == DZ_MODEM) {
-               /*
-                * CHECKME: This is a guess from the other code... --rmk
-                */
                if (dz_in(dport, DZ_MSR) & DZ_MODEM_DSR)
                        mctrl &= ~TIOCM_DSR;
        }
@@ -383,6 +364,9 @@ static unsigned int dz_get_mctrl(struct uart_port *uport)
 
 static void dz_set_mctrl(struct uart_port *uport, unsigned int mctrl)
 {
+       /*
+        * FIXME: Handle the 3100/5000 as appropriate. --macro
+        */
        struct dz_port *dport = (struct dz_port *)uport;
        unsigned short tmp;
 
@@ -409,13 +393,6 @@ static int dz_startup(struct uart_port *uport)
        unsigned long flags;
        unsigned short tmp;
 
-       /* The dz lines for the mouse/keyboard must be
-        * opened using their respective drivers.
-        */
-       if ((dport->port.line == DZ_KEYBOARD) ||
-           (dport->port.line == DZ_MOUSE))
-               return -ENODEV;
-
        spin_lock_irqsave(&dport->port.lock, flags);
 
        /* enable the interrupt and the scanning */
@@ -442,7 +419,8 @@ static void dz_shutdown(struct uart_port *uport)
 }
 
 /*
- * get_lsr_info - get line status register info
+ * -------------------------------------------------------------------
+ * dz_tx_empty() -- get the transmitter empty status
  *
  * Purpose: Let user call ioctl() to get info when the UART physically
  *          is emptied.  On bus types like RS485, the transmitter must
@@ -450,21 +428,28 @@ static void dz_shutdown(struct uart_port *uport)
  *          the transmit shift register is empty, not be done when the
  *          transmit holding register is empty.  This functionality
  *          allows an RS485 driver to be written in user space.
+ * -------------------------------------------------------------------
  */
 static unsigned int dz_tx_empty(struct uart_port *uport)
 {
        struct dz_port *dport = (struct dz_port *)uport;
-       unsigned short status = dz_in(dport, DZ_LPR);
+       unsigned short tmp, mask = 1 << dport->port.line;
 
-       /* FIXME: this appears to be obviously broken --rmk. */
-       return status ? TIOCSER_TEMT : 0;
+       tmp = dz_in(dport, DZ_TCR);
+       tmp &= mask;
+
+       return tmp ? 0 : TIOCSER_TEMT;
 }
 
 static void dz_break_ctl(struct uart_port *uport, int break_state)
 {
+       /*
+        * FIXME: Can't access BREAK bits in TDR easily;
+        * reuse the code for polled TX. --macro
+        */
        struct dz_port *dport = (struct dz_port *)uport;
        unsigned long flags;
-       unsigned short tmp, mask = 1 << uport->line;
+       unsigned short tmp, mask = 1 << dport->port.line;
 
        spin_lock_irqsave(&uport->lock, flags);
        tmp = dz_in(dport, DZ_TCR);
@@ -476,8 +461,8 @@ static void dz_break_ctl(struct uart_port *uport, int break_state)
        spin_unlock_irqrestore(&uport->lock, flags);
 }
 
-static void dz_set_termios(struct uart_port *uport, struct termios *termios,
-                          struct termios *old_termios)
+static void dz_set_termios(struct uart_port *uport, struct ktermios *termios,
+                          struct ktermios *old_termios)
 {
        struct dz_port *dport = (struct dz_port *)uport;
        unsigned long flags;
@@ -561,7 +546,7 @@ static void dz_set_termios(struct uart_port *uport, struct termios *termios,
 
        spin_lock_irqsave(&dport->port.lock, flags);
 
-       dz_out(dport, DZ_LPR, cflag);
+       dz_out(dport, DZ_LPR, cflag | dport->port.line);
        dport->cflag = cflag;
 
        /* setup accept flag */
@@ -650,7 +635,7 @@ static void __init dz_init_ports(void)
        for (i = 0, dport = dz_ports; i < DZ_NB_PORT; i++, dport++) {
                spin_lock_init(&dport->port.lock);
                dport->port.membase     = (char *) base;
-               dport->port.iotype      = UPIO_PORT;
+               dport->port.iotype      = UPIO_MEM;
                dport->port.irq         = dec_interrupt[DEC_IRQ_DZ11];
                dport->port.line        = i;
                dport->port.fifosize    = 1;
@@ -662,10 +647,7 @@ static void __init dz_init_ports(void)
 static void dz_reset(struct dz_port *dport)
 {
        dz_out(dport, DZ_CSR, DZ_CLR);
-
        while (dz_in(dport, DZ_CSR) & DZ_CLR);
-               /* FIXME: cpu_relax? */
-
        iob();
 
        /* enable scanning */
@@ -673,26 +655,55 @@ static void dz_reset(struct dz_port *dport)
 }
 
 #ifdef CONFIG_SERIAL_DZ_CONSOLE
+/*
+ * -------------------------------------------------------------------
+ * dz_console_putchar() -- transmit a character
+ *
+ * Polled transmission.  This is tricky.  We need to mask transmit
+ * interrupts so that they do not interfere, enable the transmitter
+ * for the line requested and then wait till the transmit scanner
+ * requests data for this line.  But it may request data for another
+ * line first, in which case we have to disable its transmitter and
+ * repeat waiting till our line pops up.  Only then the character may
+ * be transmitted.  Finally, the state of the transmitter mask is
+ * restored.  Welcome to the world of PDP-11!
+ * -------------------------------------------------------------------
+ */
 static void dz_console_putchar(struct uart_port *uport, int ch)
 {
        struct dz_port *dport = (struct dz_port *)uport;
        unsigned long flags;
-       int loops = 2500;
-       unsigned short tmp = (unsigned char)ch;
-       /* this code sends stuff out to serial device - spinning its
-          wheels and waiting. */
+       unsigned short csr, tcr, trdy, mask;
+       int loops = 10000;
 
        spin_lock_irqsave(&dport->port.lock, flags);
+       csr = dz_in(dport, DZ_CSR);
+       dz_out(dport, DZ_CSR, csr & ~DZ_TIE);
+       tcr = dz_in(dport, DZ_TCR);
+       tcr |= 1 << dport->port.line;
+       mask = tcr;
+       dz_out(dport, DZ_TCR, mask);
+       iob();
+       spin_unlock_irqrestore(&dport->port.lock, flags);
 
-       /* spin our wheels */
-       while (((dz_in(dport, DZ_CSR) & DZ_TRDY) != DZ_TRDY) && loops--)
-               /* FIXME: cpu_relax, udelay? --rmk */
-               ;
+       while (loops--) {
+               trdy = dz_in(dport, DZ_CSR);
+               if (!(trdy & DZ_TRDY))
+                       continue;
+               trdy = (trdy & DZ_TLINE) >> 8;
+               if (trdy == dport->port.line)
+                       break;
+               mask &= ~(1 << trdy);
+               dz_out(dport, DZ_TCR, mask);
+               iob();
+               udelay(2);
+       }
 
-       /* Actually transmit the character. */
-       dz_out(dport, DZ_TDR, tmp);
+       if (loops)                              /* Cannot send otherwise. */
+               dz_out(dport, DZ_TDR, ch);
 
-       spin_unlock_irqrestore(&dport->port.lock, flags);
+       dz_out(dport, DZ_TCR, tcr);
+       dz_out(dport, DZ_CSR, csr);
 }
 
 /*
@@ -703,11 +714,11 @@ static void dz_console_putchar(struct uart_port *uport, int ch)
  * The console must be locked when we get here.
  * -------------------------------------------------------------------
  */
-static void dz_console_print(struct console *cons,
+static void dz_console_print(struct console *co,
                             const char *str,
                             unsigned int count)
 {
-       struct dz_port *dport = &dz_ports[CONSOLE_LINE];
+       struct dz_port *dport = &dz_ports[co->index];
 #ifdef DEBUG_DZ
        prom_printf((char *) str);
 #endif
@@ -716,49 +727,43 @@ static void dz_console_print(struct console *cons,
 
 static int __init dz_console_setup(struct console *co, char *options)
 {
-       struct dz_port *dport = &dz_ports[CONSOLE_LINE];
+       struct dz_port *dport = &dz_ports[co->index];
        int baud = 9600;
        int bits = 8;
        int parity = 'n';
        int flow = 'n';
-       int ret;
-       unsigned short mask, tmp;
 
        if (options)
                uart_parse_options(options, &baud, &parity, &bits, &flow);
 
        dz_reset(dport);
 
-       ret = uart_set_options(&dport->port, co, baud, parity, bits, flow);
-       if (ret == 0) {
-               mask = 1 << dport->port.line;
-               tmp = dz_in(dport, DZ_TCR);     /* read the TX flag */
-               if (!(tmp & mask)) {
-                       tmp |= mask;            /* set the TX flag */
-                       dz_out(dport, DZ_TCR, tmp);
-               }
-       }
-
-       return ret;
+       return uart_set_options(&dport->port, co, baud, parity, bits, flow);
 }
 
-static struct console dz_sercons =
-{
+static struct uart_driver dz_reg;
+static struct console dz_sercons = {
        .name   = "ttyS",
        .write  = dz_console_print,
        .device = uart_console_device,
        .setup  = dz_console_setup,
-       .flags  = CON_CONSDEV | CON_PRINTBUFFER,
-       .index  = CONSOLE_LINE,
+       .flags  = CON_PRINTBUFFER,
+       .index  = -1,
+       .data   = &dz_reg,
 };
 
-void __init dz_serial_console_init(void)
+static int __init dz_serial_console_init(void)
 {
-       dz_init_ports();
-
-       register_console(&dz_sercons);
+       if (!IOASIC) {
+               dz_init_ports();
+               register_console(&dz_sercons);
+               return 0;
+       } else
+               return -ENXIO;
 }
 
+console_initcall(dz_serial_console_init);
+
 #define SERIAL_DZ_CONSOLE      &dz_sercons
 #else
 #define SERIAL_DZ_CONSOLE      NULL
@@ -767,35 +772,29 @@ void __init dz_serial_console_init(void)
 static struct uart_driver dz_reg = {
        .owner                  = THIS_MODULE,
        .driver_name            = "serial",
-       .dev_name               = "ttyS%d",
+       .dev_name               = "ttyS",
        .major                  = TTY_MAJOR,
        .minor                  = 64,
        .nr                     = DZ_NB_PORT,
        .cons                   = SERIAL_DZ_CONSOLE,
 };
 
-int __init dz_init(void)
+static int __init dz_init(void)
 {
-       unsigned long flags;
        int ret, i;
 
+       if (IOASIC)
+               return -ENXIO;
+
        printk("%s%s\n", dz_name, dz_version);
 
        dz_init_ports();
 
-       save_flags(flags);
-       cli();
-
 #ifndef CONFIG_SERIAL_DZ_CONSOLE
        /* reset the chip */
        dz_reset(&dz_ports[0]);
 #endif
 
-       /* order matters here... the trick is that flags
-          is updated... in request_irq - to immediatedly obliterate
-          it is unwise. */
-       restore_flags(flags);
-
        if (request_irq(dz_ports[0].port.irq, dz_interrupt,
                        IRQF_DISABLED, "DZ", &dz_ports[0]))
                panic("Unable to register DZ interrupt");
@@ -810,5 +809,7 @@ int __init dz_init(void)
        return ret;
 }
 
+module_init(dz_init);
+
 MODULE_DESCRIPTION("DECstation DZ serial driver");
 MODULE_LICENSE("GPL");
index 86ef417382bbbe938b54ece6cdc83ca03b69cbb6..9674d4e4987251ac72e1e7c45e88e0e70228b638 100644 (file)
@@ -1,20 +1,22 @@
 /*
- * dz.h: Serial port driver for DECStations equiped 
+ * dz.h: Serial port driver for DECstations equipped
  *       with the DZ chipset.
  *
  * Copyright (C) 1998 Olivier A. D. Lebaillif 
  *             
  * Email: olivier.lebaillif@ifrsys.com
  *
+ * Copyright (C) 2004, 2006  Maciej W. Rozycki
  */
 #ifndef DZ_SERIAL_H
 #define DZ_SERIAL_H
 
 /*
- * Definitions for the Control and Status Received.
+ * Definitions for the Control and Status Register.
  */
 #define DZ_TRDY        0x8000                 /* Transmitter empty */
-#define DZ_TIE         0x4000                 /* Transmitter Interrupt Enable */
+#define DZ_TIE         0x4000                 /* Transmitter Interrupt Enbl */
+#define DZ_TLINE       0x0300                 /* Transmitter Line Number */
 #define DZ_RDONE       0x0080                 /* Receiver data ready */
 #define DZ_RIE         0x0040                 /* Receive Interrupt Enable */
 #define DZ_MSE         0x0020                 /* Master Scan Enable */
 #define DZ_MAINT       0x0008                 /* Loop Back Mode */
 
 /*
- * Definitions for the Received buffer. 
+ * Definitions for the Receiver Buffer Register.
  */
-#define DZ_RBUF_MASK   0x00FF                 /* Data Mask in the Receive Buffer */
-#define DZ_LINE_MASK   0x0300                 /* Line Mask in the Receive Buffer */
+#define DZ_RBUF_MASK   0x00FF                 /* Data Mask */
+#define DZ_LINE_MASK   0x0300                 /* Line Mask */
 #define DZ_DVAL        0x8000                 /* Valid Data indicator */
 #define DZ_OERR        0x4000                 /* Overrun error indicator */
 #define DZ_FERR        0x2000                 /* Frame error indicator */
 #define DZ_PERR        0x1000                 /* Parity error indicator */
 
-#define LINE(x) (x & DZ_LINE_MASK) >> 8       /* Get the line number from the input buffer */
-#define UCHAR(x) (unsigned char)(x & DZ_RBUF_MASK)
+#define LINE(x) ((x & DZ_LINE_MASK) >> 8)     /* Get the line number
+                                                 from the input buffer */
+#define UCHAR(x) ((unsigned char)(x & DZ_RBUF_MASK))
 
 /*
- * Definitions for the Transmit Register.
+ * Definitions for the Transmit Control Register.
  */
 #define DZ_LINE_KEYBOARD 0x0001
 #define DZ_LINE_MOUSE    0x0002
 #define DZ_LINE_MODEM    0x0004
 #define DZ_LINE_PRINTER  0x0008
 
+#define DZ_MODEM_RTS     0x0800               /* RTS for the modem line (2) */
 #define DZ_MODEM_DTR     0x0400               /* DTR for the modem line (2) */
+#define DZ_PRINT_RTS     0x0200               /* RTS for the prntr line (3) */
+#define DZ_PRINT_DTR     0x0100               /* DTR for the prntr line (3) */
+#define DZ_LNENB         0x000f               /* Transmitter Line Enable */
 
 /*
  * Definitions for the Modem Status Register.
  */
+#define DZ_MODEM_RI      0x0800               /* RI for the modem line (2) */
+#define DZ_MODEM_CD      0x0400               /* CD for the modem line (2) */
 #define DZ_MODEM_DSR     0x0200               /* DSR for the modem line (2) */
+#define DZ_MODEM_CTS     0x0100               /* CTS for the modem line (2) */
+#define DZ_PRINT_RI      0x0008               /* RI for the printer line (3) */
+#define DZ_PRINT_CD      0x0004               /* CD for the printer line (3) */
+#define DZ_PRINT_DSR     0x0002               /* DSR for the prntr line (3) */
+#define DZ_PRINT_CTS     0x0001               /* CTS for the prntr line (3) */
 
 /*
  * Definitions for the Transmit Data Register.
index 8aa0f641866b3622338b21542e9638ce3a101e26..7d623003e65ed841f4f3d2e1c00559884919be04 100644 (file)
@@ -1087,8 +1087,8 @@ static void icom_close(struct uart_port *port)
 }
 
 static void icom_set_termios(struct uart_port *port,
-                            struct termios *termios,
-                            struct termios *old_termios)
+                            struct ktermios *termios,
+                            struct ktermios *old_termios)
 {
        int baud;
        unsigned cflag, iflag;
index ee5c782597dd82cac10689462f3322779ff5f29d..e216dcf29376582776418cf2ccfb825885a91124 100644 (file)
@@ -459,8 +459,8 @@ static void imx_shutdown(struct uart_port *port)
 }
 
 static void
-imx_set_termios(struct uart_port *port, struct termios *termios,
-                  struct termios *old)
+imx_set_termios(struct uart_port *port, struct ktermios *termios,
+                  struct ktermios *old)
 {
        struct imx_port *sport = (struct imx_port *)port;
        unsigned long flags;
index 2308d26c862987a24c1a055cbcb27af325216036..9cc0be932316e86545de429622e9ebbe5f837215 100644 (file)
@@ -950,7 +950,7 @@ static void transmit_chars(struct uart_port *the_port)
  */
 static void
 ioc3_change_speed(struct uart_port *the_port,
-                 struct termios *new_termios, struct termios *old_termios)
+                 struct ktermios *new_termios, struct ktermios *old_termios)
 {
        struct ioc3_port *port = get_ioc3_port(the_port);
        unsigned int cflag;
@@ -1853,7 +1853,7 @@ static int ic3_startup(struct uart_port *the_port)
  */
 static void
 ic3_set_termios(struct uart_port *the_port,
-               struct termios *termios, struct termios *old_termios)
+               struct ktermios *termios, struct ktermios *old_termios)
 {
        unsigned long port_flags;
 
index 711bd151143913c0f48a836701f196dbc96eeb79..c862f67c985af312b15f11d68cb29390688bfacb 100644 (file)
@@ -1681,7 +1681,7 @@ static void transmit_chars(struct uart_port *the_port)
  */
 static void
 ioc4_change_speed(struct uart_port *the_port,
-                 struct termios *new_termios, struct termios *old_termios)
+                 struct ktermios *new_termios, struct ktermios *old_termios)
 {
        struct ioc4_port *port = get_ioc4_port(the_port, 0);
        int baud, bits;
@@ -1802,7 +1802,7 @@ static inline int ic4_startup_local(struct uart_port *the_port)
        ioc4_set_proto(port, the_port->mapbase);
 
        /* set the speed of the serial port */
-       ioc4_change_speed(the_port, info->tty->termios, (struct termios *)0);
+       ioc4_change_speed(the_port, info->tty->termios, (struct ktermios *)0);
 
        return 0;
 }
@@ -2570,7 +2570,7 @@ static int ic4_startup(struct uart_port *the_port)
  */
 static void
 ic4_set_termios(struct uart_port *the_port,
-               struct termios *termios, struct termios *old_termios)
+               struct ktermios *termios, struct ktermios *old_termios)
 {
        unsigned long port_flags;
 
index dca6c1bde8f9f5180ce28c08293b6e3da4103fdd..0746c9446ae018c13273505fc5abbd5b1dc6a852 100644 (file)
@@ -840,8 +840,8 @@ ip22zilog_convert_to_zs(struct uart_ip22zilog_port *up, unsigned int cflag,
 
 /* The port lock is not held.  */
 static void
-ip22zilog_set_termios(struct uart_port *port, struct termios *termios,
-                     struct termios *old)
+ip22zilog_set_termios(struct uart_port *port, struct ktermios *termios,
+                     struct ktermios *old)
 {
        struct uart_ip22zilog_port *up = (struct uart_ip22zilog_port *) port;
        unsigned long flags;
index f8262e6ad8d3c3fc9728e621248c2d54f70bf2e5..7cf1c60027f842022a72e3f6dfed1c9ee35ea6d1 100644 (file)
@@ -142,7 +142,7 @@ static void jsm_tty_send_xchar(struct uart_port *port, char ch)
 {
        unsigned long lock_flags;
        struct jsm_channel *channel = (struct jsm_channel *)port;
-       struct termios *termios;
+       struct ktermios *termios;
 
        spin_lock_irqsave(&port->lock, lock_flags);
        termios = port->info->tty->termios;
@@ -180,7 +180,7 @@ static int jsm_tty_open(struct uart_port *port)
        struct jsm_board *brd;
        int rc = 0;
        struct jsm_channel *channel = (struct jsm_channel *)port;
-       struct termios *termios;
+       struct ktermios *termios;
 
        /* Get board pointer from our array of majors we have allocated */
        brd = channel->ch_bd;
@@ -269,7 +269,7 @@ static int jsm_tty_open(struct uart_port *port)
 static void jsm_tty_close(struct uart_port *port)
 {
        struct jsm_board *bd;
-       struct termios *ts;
+       struct ktermios *ts;
        struct jsm_channel *channel = (struct jsm_channel *)port;
 
        jsm_printk(CLOSE, INFO, &channel->ch_bd->pci_dev, "start\n");
@@ -302,8 +302,8 @@ static void jsm_tty_close(struct uart_port *port)
 }
 
 static void jsm_tty_set_termios(struct uart_port *port,
-                                struct termios *termios,
-                                struct termios *old_termios)
+                                struct ktermios *termios,
+                                struct ktermios *old_termios)
 {
        unsigned long lock_flags;
        struct jsm_channel *channel = (struct jsm_channel *)port;
index 7656a35f5e2f34fe06b3c0d6898e9e99d555de6f..6e09c8b395e8d4a5541f14223511904d76d9919e 100644 (file)
@@ -699,7 +699,7 @@ static unsigned int m32r_sio_get_divisor(struct uart_port *port,
 }
 
 static void m32r_sio_set_termios(struct uart_port *port,
-       struct termios *termios, struct termios *old)
+       struct ktermios *termios, struct ktermios *old)
 {
        struct uart_sio_port *up = (struct uart_sio_port *)port;
        unsigned char cval = 0;
index 3db206d29b338b36df60bd6920872fcdb6d4702b..08430961a89513885688a5197dadbfa24361d79c 100644 (file)
@@ -1132,7 +1132,7 @@ static int mcfrs_ioctl(struct tty_struct *tty, struct file * file,
        return 0;
 }
 
-static void mcfrs_set_termios(struct tty_struct *tty, struct termios *old_termios)
+static void mcfrs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
        struct mcf_serial *info = (struct mcf_serial *)tty->driver_data;
 
index 6dd579ed977782d66e26465806afe5ee97f9701d..9d11a75663e668462ca871851ac647529d9d8ad2 100644 (file)
@@ -270,8 +270,8 @@ mpc52xx_uart_shutdown(struct uart_port *port)
 }
 
 static void
-mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new,
-                         struct termios *old)
+mpc52xx_uart_set_termios(struct uart_port *port, struct ktermios *new,
+                         struct ktermios *old)
 {
        struct mpc52xx_psc __iomem *psc = PSC(port);
        unsigned long flags;
index 8eea69f29989947d3c8ca0f16c08a0ee08f965bc..3d2fcc57b1ced216ec9d6702f5c10a73edd8631f 100644 (file)
@@ -555,7 +555,7 @@ mpsc_sdma_start_tx(struct mpsc_port_info *pi)
        if (!mpsc_sdma_tx_active(pi)) {
                txre = (struct mpsc_tx_desc *)(pi->txr +
                        (pi->txr_tail * MPSC_TXRE_SIZE));
-               dma_cache_sync((void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE);
+               dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE);
 #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
                if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
                        invalidate_dcache_range((ulong)txre,
@@ -931,7 +931,7 @@ mpsc_init_rings(struct mpsc_port_info *pi)
        }
        txre->link = cpu_to_be32(pi->txr_p);    /* Wrap last back to first */
 
-       dma_cache_sync((void *) pi->dma_region, MPSC_DMA_ALLOC_SIZE,
+       dma_cache_sync(pi->port.dev, (void *) pi->dma_region, MPSC_DMA_ALLOC_SIZE,
                DMA_BIDIRECTIONAL);
 #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
                if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
@@ -1005,7 +1005,7 @@ mpsc_rx_intr(struct mpsc_port_info *pi)
 
        rxre = (struct mpsc_rx_desc *)(pi->rxr + (pi->rxr_posn*MPSC_RXRE_SIZE));
 
-       dma_cache_sync((void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE);
+       dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE);
 #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
        if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
                invalidate_dcache_range((ulong)rxre,
@@ -1029,7 +1029,7 @@ mpsc_rx_intr(struct mpsc_port_info *pi)
                }
 
                bp = pi->rxb + (pi->rxr_posn * MPSC_RXBE_SIZE);
-               dma_cache_sync((void *) bp, MPSC_RXBE_SIZE, DMA_FROM_DEVICE);
+               dma_cache_sync(pi->port.dev, (void *) bp, MPSC_RXBE_SIZE, DMA_FROM_DEVICE);
 #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
                if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
                        invalidate_dcache_range((ulong)bp,
@@ -1098,7 +1098,7 @@ next_frame:
                                            SDMA_DESC_CMDSTAT_F |
                                            SDMA_DESC_CMDSTAT_L);
                wmb();
-               dma_cache_sync((void *)rxre, MPSC_RXRE_SIZE, DMA_BIDIRECTIONAL);
+               dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, DMA_BIDIRECTIONAL);
 #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
                if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
                        flush_dcache_range((ulong)rxre,
@@ -1109,7 +1109,7 @@ next_frame:
                pi->rxr_posn = (pi->rxr_posn + 1) & (MPSC_RXR_ENTRIES - 1);
                rxre = (struct mpsc_rx_desc *)(pi->rxr +
                        (pi->rxr_posn * MPSC_RXRE_SIZE));
-               dma_cache_sync((void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE);
+               dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE);
 #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
                if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
                        invalidate_dcache_range((ulong)rxre,
@@ -1143,7 +1143,7 @@ mpsc_setup_tx_desc(struct mpsc_port_info *pi, u32 count, u32 intr)
                                                           SDMA_DESC_CMDSTAT_EI
                                                           : 0));
        wmb();
-       dma_cache_sync((void *) txre, MPSC_TXRE_SIZE, DMA_BIDIRECTIONAL);
+       dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, DMA_BIDIRECTIONAL);
 #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
        if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
                flush_dcache_range((ulong)txre,
@@ -1192,7 +1192,7 @@ mpsc_copy_tx_data(struct mpsc_port_info *pi)
                else /* All tx data copied into ring bufs */
                        return;
 
-               dma_cache_sync((void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL);
+               dma_cache_sync(pi->port.dev, (void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL);
 #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
                if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
                        flush_dcache_range((ulong)bp,
@@ -1217,7 +1217,7 @@ mpsc_tx_intr(struct mpsc_port_info *pi)
                txre = (struct mpsc_tx_desc *)(pi->txr +
                        (pi->txr_tail * MPSC_TXRE_SIZE));
 
-               dma_cache_sync((void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE);
+               dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE);
 #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
                if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
                        invalidate_dcache_range((ulong)txre,
@@ -1235,7 +1235,7 @@ mpsc_tx_intr(struct mpsc_port_info *pi)
 
                        txre = (struct mpsc_tx_desc *)(pi->txr +
                                (pi->txr_tail * MPSC_TXRE_SIZE));
-                       dma_cache_sync((void *) txre, MPSC_TXRE_SIZE,
+                       dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE,
                                DMA_FROM_DEVICE);
 #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
                        if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
@@ -1440,8 +1440,8 @@ mpsc_shutdown(struct uart_port *port)
 }
 
 static void
-mpsc_set_termios(struct uart_port *port, struct termios *termios,
-                struct termios *old)
+mpsc_set_termios(struct uart_port *port, struct ktermios *termios,
+                struct ktermios *old)
 {
        struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
        u32 baud;
@@ -1652,7 +1652,7 @@ mpsc_console_write(struct console *co, const char *s, uint count)
                        count--;
                }
 
-               dma_cache_sync((void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL);
+               dma_cache_sync(pi->port.dev, (void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL);
 #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
                if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
                        flush_dcache_range((ulong)bp,
index 8ad1b8c5ec5d2427eaeef6baefe217874a1eb6d6..ccb8fa1800a58e0b8a9f1fdf1b32b40d1e225831 100644 (file)
@@ -273,8 +273,8 @@ static void mux_shutdown(struct uart_port *port)
  * The Serial Mux does not support this function.
  */
 static void
-mux_set_termios(struct uart_port *port, struct termios *termios,
-               struct termios *old)
+mux_set_termios(struct uart_port *port, struct ktermios *termios,
+               struct ktermios *old)
 {
 }
 
index 062bad457b1a6775c5566e6a311a2e09798cb642..b56f7db4503100097471c7e037e76a2a967d1349 100644 (file)
@@ -337,8 +337,8 @@ static void netx_shutdown(struct uart_port *port)
 }
 
 static void
-netx_set_termios(struct uart_port *port, struct termios *termios,
-                  struct termios *old)
+netx_set_termios(struct uart_port *port, struct ktermios *termios,
+                  struct ktermios *old)
 {
        unsigned int baud, quot;
        unsigned char old_cr;
index bf9809ed9c0ba72177887be032914008cc5ca490..752ef07516b9d7d6cfa6ec2842334b0a790ab20a 100644 (file)
@@ -1262,8 +1262,8 @@ static void pmz_irda_setup(struct uart_pmac_port *uap, unsigned long *baud)
 }
 
 
-static void __pmz_set_termios(struct uart_port *port, struct termios *termios,
-                             struct termios *old)
+static void __pmz_set_termios(struct uart_port *port, struct ktermios *termios,
+                             struct ktermios *old)
 {
        struct uart_pmac_port *uap = to_pmz(port);
        unsigned long baud;
@@ -1273,7 +1273,7 @@ static void __pmz_set_termios(struct uart_port *port, struct termios *termios,
        if (ZS_IS_ASLEEP(uap))
                return;
 
-       memcpy(&uap->termios_cache, termios, sizeof(struct termios));
+       memcpy(&uap->termios_cache, termios, sizeof(struct ktermios));
 
        /* XXX Check which revs of machines actually allow 1 and 4Mb speeds
         * on the IR dongle. Note that the IRTTY driver currently doesn't know
@@ -1313,8 +1313,8 @@ static void __pmz_set_termios(struct uart_port *port, struct termios *termios,
 }
 
 /* The port lock is not held.  */
-static void pmz_set_termios(struct uart_port *port, struct termios *termios,
-                           struct termios *old)
+static void pmz_set_termios(struct uart_port *port, struct ktermios *termios,
+                           struct ktermios *old)
 {
        struct uart_pmac_port *uap = to_pmz(port);
        unsigned long flags;
index c03f9bfacdd897022d1d3d20f065830447e44975..570b0d925e83037d39d3b367c444bf9a5476792e 100644 (file)
@@ -60,7 +60,7 @@ struct uart_pmac_port {
        volatile struct dbdma_regs      __iomem *tx_dma_regs;
        volatile struct dbdma_regs      __iomem *rx_dma_regs;
 
-       struct termios                  termios_cache;
+       struct ktermios                 termios_cache;
 };
 
 #define to_pmz(p) ((struct uart_pmac_port *)(p))
index 415fe9633a9b7ce81cddade5929a71b72fd12370..d403aaa55092460e41f439d6404fc4fe34ac257f 100644 (file)
@@ -433,8 +433,8 @@ static void serial_pxa_shutdown(struct uart_port *port)
 }
 
 static void
-serial_pxa_set_termios(struct uart_port *port, struct termios *termios,
-                      struct termios *old)
+serial_pxa_set_termios(struct uart_port *port, struct ktermios *termios,
+                      struct ktermios *old)
 {
        struct uart_pxa_port *up = (struct uart_pxa_port *)port;
        unsigned char cval, fcr = 0;
index 8dfc2dd058ca4ba74aee7f2467f890c04698c006..3ba9208ebd0c87de5c610a683b29cf2733a15a80 100644 (file)
@@ -738,8 +738,8 @@ static unsigned int s3c24xx_serial_getclk(struct uart_port *port,
 }
 
 static void s3c24xx_serial_set_termios(struct uart_port *port,
-                                      struct termios *termios,
-                                      struct termios *old)
+                                      struct ktermios *termios,
+                                      struct ktermios *old)
 {
        struct s3c2410_uartcfg *cfg = s3c24xx_port_to_cfg(port);
        struct s3c24xx_uart_port *ourport = to_ourport(port);
index d4065266b6fcf9af83e7714aa8da9eb74b50d221..58a83c27e14b44e5dc11574a3f893f62121a478c 100644 (file)
@@ -408,8 +408,8 @@ static void sa1100_shutdown(struct uart_port *port)
 }
 
 static void
-sa1100_set_termios(struct uart_port *port, struct termios *termios,
-                  struct termios *old)
+sa1100_set_termios(struct uart_port *port, struct ktermios *termios,
+                  struct ktermios *old)
 {
        struct sa1100_port *sport = (struct sa1100_port *)port;
        unsigned long flags;
index c67b05e9a45144c3410c23ed0050f4f70ec26c9a..f84982e508c7efc7e2eb6bcdca37f95ee22e8b67 100644 (file)
@@ -65,7 +65,7 @@ static struct lock_class_key port_lock_key;
 #define uart_console(port)     (0)
 #endif
 
-static void uart_change_speed(struct uart_state *state, struct termios *old_termios);
+static void uart_change_speed(struct uart_state *state, struct ktermios *old_termios);
 static void uart_wait_until_sent(struct tty_struct *tty, int timeout);
 static void uart_change_pm(struct uart_state *state, int pm_state);
 
@@ -338,8 +338,8 @@ EXPORT_SYMBOL(uart_update_timeout);
  *     we're actually going to be using.
  */
 unsigned int
-uart_get_baud_rate(struct uart_port *port, struct termios *termios,
-                  struct termios *old, unsigned int min, unsigned int max)
+uart_get_baud_rate(struct uart_port *port, struct ktermios *termios,
+                  struct ktermios *old, unsigned int min, unsigned int max)
 {
        unsigned int try, baud, altbaud = 38400;
        upf_t flags = port->flags & UPF_SPD_MASK;
@@ -421,11 +421,11 @@ uart_get_divisor(struct uart_port *port, unsigned int baud)
 EXPORT_SYMBOL(uart_get_divisor);
 
 static void
-uart_change_speed(struct uart_state *state, struct termios *old_termios)
+uart_change_speed(struct uart_state *state, struct ktermios *old_termios)
 {
        struct tty_struct *tty = state->info->tty;
        struct uart_port *port = state->port;
-       struct termios *termios;
+       struct ktermios *termios;
 
        /*
         * If we have no tty, termios, or the port does not exist,
@@ -1139,7 +1139,7 @@ uart_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd,
        return ret;
 }
 
-static void uart_set_termios(struct tty_struct *tty, struct termios *old_termios)
+static void uart_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
        struct uart_state *state = tty->driver_data;
        unsigned long flags;
@@ -1866,7 +1866,7 @@ int __init
 uart_set_options(struct uart_port *port, struct console *co,
                 int baud, int parity, int bits, int flow)
 {
-       struct termios termios;
+       struct ktermios termios;
        int i;
 
        /*
@@ -1876,7 +1876,7 @@ uart_set_options(struct uart_port *port, struct console *co,
        spin_lock_init(&port->lock);
        lockdep_set_class(&port->lock, &port_lock_key);
 
-       memset(&termios, 0, sizeof(struct termios));
+       memset(&termios, 0, sizeof(struct ktermios));
 
        termios.c_cflag = CREAD | HUPCL | CLOCAL;
 
@@ -1991,12 +1991,12 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *port)
         * Re-enable the console device after suspending.
         */
        if (uart_console(port)) {
-               struct termios termios;
+               struct ktermios termios;
 
                /*
                 * First try to use the console cflag setting.
                 */
-               memset(&termios, 0, sizeof(struct termios));
+               memset(&termios, 0, sizeof(struct ktermios));
                termios.c_cflag = port->cons->cflag;
 
                /*
@@ -2189,6 +2189,7 @@ int uart_register_driver(struct uart_driver *drv)
        normal->subtype         = SERIAL_TYPE_NORMAL;
        normal->init_termios    = tty_std_termios;
        normal->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+       normal->init_termios.c_ispeed = normal->init_termios.c_ospeed = 9600;
        normal->flags           = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
        normal->driver_state    = drv;
        tty_set_operations(normal, &uart_ops);
index 5e1ac356bbb07b7630bb5453a850fb25daf047ce..eb18d429752d2d40458eb47234f3fd4649bf39fd 100644 (file)
@@ -348,8 +348,8 @@ static void lh7a40xuart_shutdown (struct uart_port* port)
 }
 
 static void lh7a40xuart_set_termios (struct uart_port* port,
-                                    struct termios* termios,
-                                    struct termios* old)
+                                    struct ktermios* termios,
+                                    struct ktermios* old)
 {
        unsigned int con;
        unsigned int inten;
index 2a48289ac72277b6f516b16635595400009dbd17..7186a82c47595582dfe3de1dbac4b6bb283585ba 100644 (file)
@@ -556,8 +556,8 @@ static void serial_txx9_shutdown(struct uart_port *port)
 }
 
 static void
-serial_txx9_set_termios(struct uart_port *port, struct termios *termios,
-                      struct termios *old)
+serial_txx9_set_termios(struct uart_port *port, struct ktermios *termios,
+                      struct ktermios *old)
 {
        struct uart_txx9_port *up = (struct uart_txx9_port *)port;
        unsigned int cval, fcr = 0;
index 3b5f19ec21263420256345eec45ae32f39f1adcd..9031b57f12ddd754e93db42015d69e47ffabade4 100644 (file)
@@ -943,8 +943,8 @@ static void sci_shutdown(struct uart_port *port)
                s->disable(port);
 }
 
-static void sci_set_termios(struct uart_port *port, struct termios *termios,
-                           struct termios *old)
+static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
+                           struct ktermios *old)
 {
        struct sci_port *s = &sci_ports[port->line];
        unsigned int status, baud, smr_val;
index 956b2cf08e1e09f39d90f0a4d12df15b93817979..253ceb895ca7bcf9a10b77b50e0493044aa30a32 100644 (file)
@@ -361,8 +361,8 @@ static int snp_startup(struct uart_port *port)
  *
  */
 static void
-snp_set_termios(struct uart_port *port, struct termios *termios,
-               struct termios *old)
+snp_set_termios(struct uart_port *port, struct ktermios *termios,
+               struct ktermios *old)
 {
 }
 
index 03941d27d15dcdb2d8338e47b63d852bf73e2fb0..40d48566215c07a9c3523a864e0be027872e962f 100644 (file)
@@ -281,8 +281,8 @@ static void sunhv_shutdown(struct uart_port *port)
 }
 
 /* port->lock is not held.  */
-static void sunhv_set_termios(struct uart_port *port, struct termios *termios,
-                             struct termios *old)
+static void sunhv_set_termios(struct uart_port *port, struct ktermios *termios,
+                             struct ktermios *old)
 {
        unsigned int baud = uart_get_baud_rate(port, termios, old, 0, 4000000);
        unsigned int quot = uart_get_divisor(port, baud);
index 08a7cd6a3a0c77a6a11497bd73be4141b33bfd0c..493d5bbb661be7daacc3e3f11aca47c32932811f 100644 (file)
@@ -786,8 +786,8 @@ static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cfla
 }
 
 /* port->lock is not held.  */
-static void sunsab_set_termios(struct uart_port *port, struct termios *termios,
-                              struct termios *old)
+static void sunsab_set_termios(struct uart_port *port, struct ktermios *termios,
+                              struct ktermios *old)
 {
        struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
        unsigned long flags;
index c577faea60e8ae7437a77e3f36b668805af174b4..564592b2b2ba26c32d10f49a34a799554295029d 100644 (file)
@@ -893,8 +893,8 @@ sunsu_change_speed(struct uart_port *port, unsigned int cflag,
 }
 
 static void
-sunsu_set_termios(struct uart_port *port, struct termios *termios,
-                 struct termios *old)
+sunsu_set_termios(struct uart_port *port, struct ktermios *termios,
+                 struct ktermios *old)
 {
        unsigned int baud, quot;
 
index b2cc703b2b9e976e6fc74d0f9f652a7960612c4e..75de919a9471f066c9766c61463594cc5f4d5e62 100644 (file)
@@ -922,8 +922,8 @@ sunzilog_convert_to_zs(struct uart_sunzilog_port *up, unsigned int cflag,
 
 /* The port lock is not held.  */
 static void
-sunzilog_set_termios(struct uart_port *port, struct termios *termios,
-                    struct termios *old)
+sunzilog_set_termios(struct uart_port *port, struct ktermios *termios,
+                    struct ktermios *old)
 {
        struct uart_sunzilog_port *up = (struct uart_sunzilog_port *) port;
        unsigned long flags;
diff --git a/drivers/serial/uartlite.c b/drivers/serial/uartlite.c
new file mode 100644 (file)
index 0000000..92eba89
--- /dev/null
@@ -0,0 +1,505 @@
+/*
+ * uartlite.c: Serial driver for Xilinx uartlite serial controller
+ *
+ * Peter Korsgaard <jacmet@sunsite.dk>
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2.  This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/console.h>
+#include <linux/serial.h>
+#include <linux/serial_core.h>
+#include <linux/tty.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <asm/io.h>
+
+#define ULITE_MAJOR            204
+#define ULITE_MINOR            187
+#define ULITE_NR_UARTS         4
+
+/* For register details see datasheet:
+   http://www.xilinx.com/bvdocs/ipcenter/data_sheet/opb_uartlite.pdf
+*/
+#define ULITE_RX               0x00
+#define ULITE_TX               0x04
+#define ULITE_STATUS           0x08
+#define ULITE_CONTROL          0x0c
+
+#define ULITE_REGION           16
+
+#define ULITE_STATUS_RXVALID   0x01
+#define ULITE_STATUS_RXFULL    0x02
+#define ULITE_STATUS_TXEMPTY   0x04
+#define ULITE_STATUS_TXFULL    0x08
+#define ULITE_STATUS_IE                0x10
+#define ULITE_STATUS_OVERRUN   0x20
+#define ULITE_STATUS_FRAME     0x40
+#define ULITE_STATUS_PARITY    0x80
+
+#define ULITE_CONTROL_RST_TX   0x01
+#define ULITE_CONTROL_RST_RX   0x02
+#define ULITE_CONTROL_IE       0x10
+
+
+static struct uart_port ports[ULITE_NR_UARTS];
+
+static int ulite_receive(struct uart_port *port, int stat)
+{
+       struct tty_struct *tty = port->info->tty;
+       unsigned char ch = 0;
+       char flag = TTY_NORMAL;
+
+       if ((stat & (ULITE_STATUS_RXVALID | ULITE_STATUS_OVERRUN
+                    | ULITE_STATUS_FRAME)) == 0)
+               return 0;
+
+       /* stats */
+       if (stat & ULITE_STATUS_RXVALID) {
+               port->icount.rx++;
+               ch = readb(port->membase + ULITE_RX);
+
+               if (stat & ULITE_STATUS_PARITY)
+                       port->icount.parity++;
+       }
+
+       if (stat & ULITE_STATUS_OVERRUN)
+               port->icount.overrun++;
+
+       if (stat & ULITE_STATUS_FRAME)
+               port->icount.frame++;
+
+
+       /* drop byte with parity error if IGNPAR specificed */
+       if (stat & port->ignore_status_mask & ULITE_STATUS_PARITY)
+               stat &= ~ULITE_STATUS_RXVALID;
+
+       stat &= port->read_status_mask;
+
+       if (stat & ULITE_STATUS_PARITY)
+               flag = TTY_PARITY;
+
+
+       stat &= ~port->ignore_status_mask;
+
+       if (stat & ULITE_STATUS_RXVALID)
+               tty_insert_flip_char(tty, ch, flag);
+
+       if (stat & ULITE_STATUS_FRAME)
+               tty_insert_flip_char(tty, 0, TTY_FRAME);
+
+       if (stat & ULITE_STATUS_OVERRUN)
+               tty_insert_flip_char(tty, 0, TTY_OVERRUN);
+
+       return 1;
+}
+
+static int ulite_transmit(struct uart_port *port, int stat)
+{
+       struct circ_buf *xmit  = &port->info->xmit;
+
+       if (stat & ULITE_STATUS_TXFULL)
+               return 0;
+
+       if (port->x_char) {
+               writeb(port->x_char, port->membase + ULITE_TX);
+               port->x_char = 0;
+               port->icount.tx++;
+               return 1;
+       }
+
+       if (uart_circ_empty(xmit) || uart_tx_stopped(port))
+               return 0;
+
+       writeb(xmit->buf[xmit->tail], port->membase + ULITE_TX);
+       xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE-1);
+       port->icount.tx++;
+
+       /* wake up */
+       if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
+               uart_write_wakeup(port);
+
+       return 1;
+}
+
+static irqreturn_t ulite_isr(int irq, void *dev_id)
+{
+       struct uart_port *port = (struct uart_port *)dev_id;
+       int busy;
+
+       do {
+               int stat = readb(port->membase + ULITE_STATUS);
+               busy  = ulite_receive(port, stat);
+               busy |= ulite_transmit(port, stat);
+       } while (busy);
+
+       tty_flip_buffer_push(port->info->tty);
+
+       return IRQ_HANDLED;
+}
+
+static unsigned int ulite_tx_empty(struct uart_port *port)
+{
+       unsigned long flags;
+       unsigned int ret;
+
+       spin_lock_irqsave(&port->lock, flags);
+       ret = readb(port->membase + ULITE_STATUS);
+       spin_unlock_irqrestore(&port->lock, flags);
+
+       return ret & ULITE_STATUS_TXEMPTY ? TIOCSER_TEMT : 0;
+}
+
+static unsigned int ulite_get_mctrl(struct uart_port *port)
+{
+       return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
+}
+
+static void ulite_set_mctrl(struct uart_port *port, unsigned int mctrl)
+{
+       /* N/A */
+}
+
+static void ulite_stop_tx(struct uart_port *port)
+{
+       /* N/A */
+}
+
+static void ulite_start_tx(struct uart_port *port)
+{
+       ulite_transmit(port, readb(port->membase + ULITE_STATUS));
+}
+
+static void ulite_stop_rx(struct uart_port *port)
+{
+       /* don't forward any more data (like !CREAD) */
+       port->ignore_status_mask = ULITE_STATUS_RXVALID | ULITE_STATUS_PARITY
+               | ULITE_STATUS_FRAME | ULITE_STATUS_OVERRUN;
+}
+
+static void ulite_enable_ms(struct uart_port *port)
+{
+       /* N/A */
+}
+
+static void ulite_break_ctl(struct uart_port *port, int ctl)
+{
+       /* N/A */
+}
+
+static int ulite_startup(struct uart_port *port)
+{
+       int ret;
+
+       ret = request_irq(port->irq, ulite_isr,
+                         IRQF_DISABLED | IRQF_SAMPLE_RANDOM, "uartlite", port);
+       if (ret)
+               return ret;
+
+       writeb(ULITE_CONTROL_RST_RX | ULITE_CONTROL_RST_TX,
+              port->membase + ULITE_CONTROL);
+       writeb(ULITE_CONTROL_IE, port->membase + ULITE_CONTROL);
+
+       return 0;
+}
+
+static void ulite_shutdown(struct uart_port *port)
+{
+       writeb(0, port->membase + ULITE_CONTROL);
+       readb(port->membase + ULITE_CONTROL); /* dummy */
+       free_irq(port->irq, port);
+}
+
+static void ulite_set_termios(struct uart_port *port, struct ktermios *termios,
+                             struct ktermios *old)
+{
+       unsigned long flags;
+       unsigned int baud;
+
+       spin_lock_irqsave(&port->lock, flags);
+
+       port->read_status_mask = ULITE_STATUS_RXVALID | ULITE_STATUS_OVERRUN
+               | ULITE_STATUS_TXFULL;
+
+       if (termios->c_iflag & INPCK)
+               port->read_status_mask |=
+                       ULITE_STATUS_PARITY | ULITE_STATUS_FRAME;
+
+       port->ignore_status_mask = 0;
+       if (termios->c_iflag & IGNPAR)
+               port->ignore_status_mask |= ULITE_STATUS_PARITY
+                       | ULITE_STATUS_FRAME | ULITE_STATUS_OVERRUN;
+
+       /* ignore all characters if CREAD is not set */
+       if ((termios->c_cflag & CREAD) == 0)
+               port->ignore_status_mask |=
+                       ULITE_STATUS_RXVALID | ULITE_STATUS_PARITY
+                       | ULITE_STATUS_FRAME | ULITE_STATUS_OVERRUN;
+
+       /* update timeout */
+       baud = uart_get_baud_rate(port, termios, old, 0, 460800);
+       uart_update_timeout(port, termios->c_cflag, baud);
+
+       spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static const char *ulite_type(struct uart_port *port)
+{
+       return port->type == PORT_UARTLITE ? "uartlite" : NULL;
+}
+
+static void ulite_release_port(struct uart_port *port)
+{
+       release_mem_region(port->mapbase, ULITE_REGION);
+       iounmap(port->membase);
+       port->membase = 0;
+}
+
+static int ulite_request_port(struct uart_port *port)
+{
+       if (!request_mem_region(port->mapbase, ULITE_REGION, "uartlite")) {
+               dev_err(port->dev, "Memory region busy\n");
+               return -EBUSY;
+       }
+
+       port->membase = ioremap(port->mapbase, ULITE_REGION);
+       if (!port->membase) {
+               dev_err(port->dev, "Unable to map registers\n");
+               release_mem_region(port->mapbase, ULITE_REGION);
+               return -EBUSY;
+       }
+
+       return 0;
+}
+
+static void ulite_config_port(struct uart_port *port, int flags)
+{
+       ulite_request_port(port);
+       port->type = PORT_UARTLITE;
+}
+
+static int ulite_verify_port(struct uart_port *port, struct serial_struct *ser)
+{
+       /* we don't want the core code to modify any port params */
+       return -EINVAL;
+}
+
+static struct uart_ops ulite_ops = {
+       .tx_empty       = ulite_tx_empty,
+       .set_mctrl      = ulite_set_mctrl,
+       .get_mctrl      = ulite_get_mctrl,
+       .stop_tx        = ulite_stop_tx,
+       .start_tx       = ulite_start_tx,
+       .stop_rx        = ulite_stop_rx,
+       .enable_ms      = ulite_enable_ms,
+       .break_ctl      = ulite_break_ctl,
+       .startup        = ulite_startup,
+       .shutdown       = ulite_shutdown,
+       .set_termios    = ulite_set_termios,
+       .type           = ulite_type,
+       .release_port   = ulite_release_port,
+       .request_port   = ulite_request_port,
+       .config_port    = ulite_config_port,
+       .verify_port    = ulite_verify_port
+};
+
+#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
+static void ulite_console_wait_tx(struct uart_port *port)
+{
+       int i;
+
+       /* wait up to 10ms for the character(s) to be sent */
+       for (i = 0; i < 10000; i++) {
+               if (readb(port->membase + ULITE_STATUS) & ULITE_STATUS_TXEMPTY)
+                       break;
+               udelay(1);
+       }
+}
+
+static void ulite_console_putchar(struct uart_port *port, int ch)
+{
+       ulite_console_wait_tx(port);
+       writeb(ch, port->membase + ULITE_TX);
+}
+
+static void ulite_console_write(struct console *co, const char *s,
+                               unsigned int count)
+{
+       struct uart_port *port = &ports[co->index];
+       unsigned long flags;
+       unsigned int ier;
+       int locked = 1;
+
+       if (oops_in_progress) {
+               locked = spin_trylock_irqsave(&port->lock, flags);
+       } else
+               spin_lock_irqsave(&port->lock, flags);
+
+       /* save and disable interrupt */
+       ier = readb(port->membase + ULITE_STATUS) & ULITE_STATUS_IE;
+       writeb(0, port->membase + ULITE_CONTROL);
+
+       uart_console_write(port, s, count, ulite_console_putchar);
+
+       ulite_console_wait_tx(port);
+
+       /* restore interrupt state */
+       if (ier)
+               writeb(ULITE_CONTROL_IE, port->membase + ULITE_CONTROL);
+
+       if (locked)
+               spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static int __init ulite_console_setup(struct console *co, char *options)
+{
+       struct uart_port *port;
+       int baud = 9600;
+       int bits = 8;
+       int parity = 'n';
+       int flow = 'n';
+
+       if (co->index < 0 || co->index >= ULITE_NR_UARTS)
+               return -EINVAL;
+
+       port = &ports[co->index];
+
+       /* not initialized yet? */
+       if (!port->membase)
+               return -ENODEV;
+
+       if (options)
+               uart_parse_options(options, &baud, &parity, &bits, &flow);
+
+       return uart_set_options(port, co, baud, parity, bits, flow);
+}
+
+static struct uart_driver ulite_uart_driver;
+
+static struct console ulite_console = {
+       .name   = "ttyUL",
+       .write  = ulite_console_write,
+       .device = uart_console_device,
+       .setup  = ulite_console_setup,
+       .flags  = CON_PRINTBUFFER,
+       .index  = -1, /* Specified on the cmdline (e.g. console=ttyUL0 ) */
+       .data   = &ulite_uart_driver,
+};
+
+static int __init ulite_console_init(void)
+{
+       register_console(&ulite_console);
+       return 0;
+}
+
+console_initcall(ulite_console_init);
+
+#endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */
+
+static struct uart_driver ulite_uart_driver = {
+       .owner          = THIS_MODULE,
+       .driver_name    = "uartlite",
+       .dev_name       = "ttyUL",
+       .major          = ULITE_MAJOR,
+       .minor          = ULITE_MINOR,
+       .nr             = ULITE_NR_UARTS,
+#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
+       .cons           = &ulite_console,
+#endif
+};
+
+static int __devinit ulite_probe(struct platform_device *pdev)
+{
+       struct resource *res, *res2;
+       struct uart_port *port;
+
+       if (pdev->id < 0 || pdev->id >= ULITE_NR_UARTS)
+               return -EINVAL;
+
+       if (ports[pdev->id].membase)
+               return -EBUSY;
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!res)
+               return -ENODEV;
+
+       res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+       if (!res2)
+               return -ENODEV;
+
+       port = &ports[pdev->id];
+
+       port->fifosize  = 16;
+       port->regshift  = 2;
+       port->iotype    = UPIO_MEM;
+       port->iobase    = 1; /* mark port in use */
+       port->mapbase   = res->start;
+       port->membase   = 0;
+       port->ops       = &ulite_ops;
+       port->irq       = res2->start;
+       port->flags     = UPF_BOOT_AUTOCONF;
+       port->dev       = &pdev->dev;
+       port->type      = PORT_UNKNOWN;
+       port->line      = pdev->id;
+
+       uart_add_one_port(&ulite_uart_driver, port);
+       platform_set_drvdata(pdev, port);
+
+       return 0;
+}
+
+static int ulite_remove(struct platform_device *pdev)
+{
+       struct uart_port *port = platform_get_drvdata(pdev);
+
+       platform_set_drvdata(pdev, NULL);
+
+       if (port)
+               uart_remove_one_port(&ulite_uart_driver, port);
+
+       /* mark port as free */
+       port->membase = 0;
+
+       return 0;
+}
+
+static struct platform_driver ulite_platform_driver = {
+       .probe  = ulite_probe,
+       .remove = ulite_remove,
+       .driver = {
+                  .owner = THIS_MODULE,
+                  .name  = "uartlite",
+                  },
+};
+
+int __init ulite_init(void)
+{
+       int ret;
+
+       ret = uart_register_driver(&ulite_uart_driver);
+       if (ret)
+               return ret;
+
+       ret = platform_driver_register(&ulite_platform_driver);
+       if (ret)
+               uart_unregister_driver(&ulite_uart_driver);
+
+       return ret;
+}
+
+void __exit ulite_exit(void)
+{
+       platform_driver_unregister(&ulite_platform_driver);
+       uart_unregister_driver(&ulite_uart_driver);
+}
+
+module_init(ulite_init);
+module_exit(ulite_exit);
+
+MODULE_AUTHOR("Peter Korsgaard <jacmet@sunsite.dk>");
+MODULE_DESCRIPTION("Xilinx uartlite serial driver");
+MODULE_LICENSE("GPL");
index 28f3bbff87bf48f1c5bbc16b8cc4affc26429b65..dd98aca6ed08114389c9b6a87ad5de07445a4a6b 100644 (file)
@@ -404,8 +404,8 @@ static void v850e_uart_shutdown (struct uart_port *port)
 }
 
 static void
-v850e_uart_set_termios (struct uart_port *port, struct termios *termios,
-                       struct termios *old)
+v850e_uart_set_termios (struct uart_port *port, struct ktermios *termios,
+                       struct ktermios *old)
 {
        unsigned cflags = termios->c_cflag;
 
index fd51f8182dec1f20f3a4d43d6c66361d5485b5e0..cf0e663b42ed97781c353f98cd8abb779b592a3c 100644 (file)
@@ -562,8 +562,8 @@ static void siu_shutdown(struct uart_port *port)
        free_irq(port->irq, port);
 }
 
-static void siu_set_termios(struct uart_port *port, struct termios *new,
-                            struct termios *old)
+static void siu_set_termios(struct uart_port *port, struct ktermios *new,
+                            struct ktermios *old)
 {
        tcflag_t c_cflag, c_iflag;
        uint8_t lcr, fcr, ier;
index c3c0626f550b80469482d8891654485228b220fe..270e6211c2e318e2b970d0e0ece11f90e5847df6 100644 (file)
@@ -360,12 +360,13 @@ spi_alloc_master(struct device *dev, unsigned size)
        if (!dev)
                return NULL;
 
-       master = kzalloc(size + sizeof *master, SLAB_KERNEL);
+       master = kzalloc(size + sizeof *master, GFP_KERNEL);
        if (!master)
                return NULL;
 
        class_device_initialize(&master->cdev);
        master->cdev.class = &spi_master_class;
+       kobj_set_kset_s(&master->cdev, spi_master_class.subsys);
        master->cdev.dev = get_device(dev);
        spi_master_set_devdata(master, &master[1]);
 
@@ -447,7 +448,9 @@ static int __unregister(struct device *dev, void *unused)
  */
 void spi_unregister_master(struct spi_master *master)
 {
-       (void) device_for_each_child(master->cdev.dev, NULL, __unregister);
+       int dummy;
+
+       dummy = device_for_each_child(master->cdev.dev, NULL, __unregister);
        class_device_unregister(&master->cdev);
 }
 EXPORT_SYMBOL_GPL(spi_unregister_master);
@@ -463,15 +466,13 @@ EXPORT_SYMBOL_GPL(spi_unregister_master);
  */
 struct spi_master *spi_busnum_to_master(u16 bus_num)
 {
-       if (bus_num) {
-               char                    name[8];
-               struct kobject          *bus;
-
-               snprintf(name, sizeof name, "spi%u", bus_num);
-               bus = kset_find_obj(&spi_master_class.subsys.kset, name);
-               if (bus)
-                       return container_of(bus, struct spi_master, cdev.kobj);
-       }
+       char                    name[9];
+       struct kobject          *bus;
+
+       snprintf(name, sizeof name, "spi%u", bus_num);
+       bus = kset_find_obj(&spi_master_class.subsys.kset, name);
+       if (bus)
+               return container_of(bus, struct spi_master, cdev.kobj);
        return NULL;
 }
 EXPORT_SYMBOL_GPL(spi_busnum_to_master);
@@ -607,7 +608,7 @@ static int __init spi_init(void)
 {
        int     status;
 
-       buf = kmalloc(SPI_BUFSIZ, SLAB_KERNEL);
+       buf = kmalloc(SPI_BUFSIZ, GFP_KERNEL);
        if (!buf) {
                status = -ENOMEM;
                goto err0;
index 08c1c57c612851ca14b0e20e7fda9bd22e91a074..57289b61d0beadd3dd543b853c233918f22daccc 100644 (file)
@@ -196,7 +196,7 @@ int spi_bitbang_setup(struct spi_device *spi)
                return -EINVAL;
 
        if (!cs) {
-               cs = kzalloc(sizeof *cs, SLAB_KERNEL);
+               cs = kzalloc(sizeof *cs, GFP_KERNEL);
                if (!cs)
                        return -ENOMEM;
                spi->controller_state = cs;
index c2f601f8e4f21df7106952a147c83c2e13626fca..312987a0321072aa2c9974c8b476ffc97416b7bb 100644 (file)
@@ -251,6 +251,8 @@ static void butterfly_attach(struct parport *p)
         * setting up a platform device like this is an ugly kluge...
         */
        pdev = platform_device_register_simple("butterfly", -1, NULL, 0);
+       if (IS_ERR(pdev))
+               return;
 
        master = spi_alloc_master(&pdev->dev, sizeof *pp);
        if (!master) {
index 792becdfe6f844737b06ccc6dca776b4934b3e4c..fc3197273663e93c48f975cded7c748727ad0370 100644 (file)
@@ -1238,7 +1238,7 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
        return 0;
 }
 
-static void rs_set_termios(struct tty_struct *tty, struct termios *old_termios)
+static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
        struct dec_serial *info = (struct dec_serial *)tty->driver_data;
        int was_stopped;
index 1b601b6cf2a2b78c148395d641955523e07b7515..df4cc1fb5f68df840bfe9382a151862598046343 100644 (file)
@@ -2747,7 +2747,7 @@ static void alaw2ulaw(unsigned char *buff, unsigned long len)
 static ssize_t ixj_read(struct file * file_p, char __user *buf, size_t length, loff_t * ppos)
 {
        unsigned long i = *ppos;
-       IXJ * j = get_ixj(NUM(file_p->f_dentry->d_inode));
+       IXJ * j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
 
        DECLARE_WAITQUEUE(wait, current);
 
@@ -2804,7 +2804,7 @@ static ssize_t ixj_enhanced_read(struct file * file_p, char __user *buf, size_t
 {
        int pre_retval;
        ssize_t read_retval = 0;
-       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
+       IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
 
        pre_retval = ixj_PreRead(j, 0L);
        switch (pre_retval) {
@@ -2883,7 +2883,7 @@ static ssize_t ixj_enhanced_write(struct file * file_p, const char __user *buf,
        int pre_retval;
        ssize_t write_retval = 0;
 
-       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
+       IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
 
        pre_retval = ixj_PreWrite(j, 0L);
        switch (pre_retval) {
@@ -4582,7 +4582,7 @@ static unsigned int ixj_poll(struct file *file_p, poll_table * wait)
 {
        unsigned int mask = 0;
 
-       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
+       IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
 
        poll_wait(file_p, &(j->poll_q), wait);
        if (j->read_buffer_ready > 0)
@@ -6657,7 +6657,7 @@ static int ixj_ioctl(struct inode *inode, struct file *file_p, unsigned int cmd,
 
 static int ixj_fasync(int fd, struct file *file_p, int mode)
 {
-       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
+       IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
 
        return fasync_helper(fd, file_p, mode, &j->async_queue);
 }
index f9b1719b9a372d562da3d65d959123ba1e1243fc..9980a4ddfed934617a7726c6c612a24edebb4d27 100644 (file)
@@ -24,7 +24,7 @@ config USB_ARCH_HAS_OHCI
        default y if ARCH_S3C2410
        default y if PXA27x
        default y if ARCH_EP93XX
-       default y if (ARCH_AT91RM9200 || ARCH_AT91SAM9261)
+       default y if ARCH_AT91
        default y if ARCH_PNX4008
        # PPC:
        default y if STB03xxx
index f2d196fa1e8b0a613fac5dca91caf043b14bbed2..dae4ef1e8fe592f6338a3d75917134c3198f5e4c 100644 (file)
@@ -64,6 +64,8 @@
 #include <linux/kthread.h>
 #include <linux/version.h>
 #include <linux/mutex.h>
+#include <linux/freezer.h>
+
 #include <asm/unaligned.h>
 
 #include "usbatm.h"
index 7f1fa956dcdb6b0c558f8bb9a835a07222f22867..98199628e394e66df0e3c1c7a42e0874d420d3c4 100644 (file)
@@ -677,10 +677,10 @@ static const __u8 acm_tty_size[] = {
        5, 6, 7, 8
 };
 
-static void acm_tty_set_termios(struct tty_struct *tty, struct termios *termios_old)
+static void acm_tty_set_termios(struct tty_struct *tty, struct ktermios *termios_old)
 {
        struct acm *acm = tty->driver_data;
-       struct termios *termios = tty->termios;
+       struct ktermios *termios = tty->termios;
        struct usb_cdc_line_coding newline;
        int newctrl = acm->ctrlout;
 
index 840442a25b6183844979b3c2f5fc58d3607fb7ac..c3915dc28608da7aa3ef3ae88fc005cbdf37eba7 100644 (file)
@@ -93,7 +93,7 @@ void hcd_buffer_destroy (struct usb_hcd *hcd)
 }
 
 
-/* sometimes alloc/free could use kmalloc with SLAB_DMA, for
+/* sometimes alloc/free could use kmalloc with GFP_DMA, for
  * better sharing and to leverage mm/slab.c intelligence.
  */
 
index 9be41ed1f9a6999e0f481463d508ec7b77296e2a..2651c2e2a89f5671e842b4c979f84f8d75857449 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/usbdevice_fs.h>
 #include <linux/kthread.h>
 #include <linux/mutex.h>
+#include <linux/freezer.h>
 
 #include <asm/semaphore.h>
 #include <asm/uaccess.h>
@@ -460,7 +461,7 @@ void usb_hub_tt_clear_buffer (struct usb_device *udev, int pipe)
         * since each TT has "at least two" buffers that can need it (and
         * there can be many TTs per hub).  even if they're uncommon.
         */
-       if ((clear = kmalloc (sizeof *clear, SLAB_ATOMIC)) == NULL) {
+       if ((clear = kmalloc (sizeof *clear, GFP_ATOMIC)) == NULL) {
                dev_err (&udev->dev, "can't save CLEAR_TT_BUFFER state\n");
                /* FIXME recover somehow ... RESET_TT? */
                return;
@@ -2371,7 +2372,7 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)
        struct usb_qualifier_descriptor *qual;
        int                             status;
 
-       qual = kmalloc (sizeof *qual, SLAB_KERNEL);
+       qual = kmalloc (sizeof *qual, GFP_KERNEL);
        if (qual == NULL)
                return;
 
@@ -2922,7 +2923,7 @@ static int config_descriptors_changed(struct usb_device *udev)
                if (len < le16_to_cpu(udev->config[index].desc.wTotalLength))
                        len = le16_to_cpu(udev->config[index].desc.wTotalLength);
        }
-       buf = kmalloc (len, SLAB_KERNEL);
+       buf = kmalloc (len, GFP_KERNEL);
        if (buf == NULL) {
                dev_err(&udev->dev, "no mem to re-read configs after reset\n");
                /* assume the worst */
index b5d6a79af0be3473b94e23dd73c6340e7db650ee..11dad22da41cc373d28957d47372e342c19fad9d 100644 (file)
@@ -379,7 +379,7 @@ static loff_t default_file_lseek (struct file *file, loff_t offset, int orig)
 {
        loff_t retval = -EINVAL;
 
-       mutex_lock(&file->f_dentry->d_inode->i_mutex);
+       mutex_lock(&file->f_path.dentry->d_inode->i_mutex);
        switch(orig) {
        case 0:
                if (offset > 0) {
@@ -396,7 +396,7 @@ static loff_t default_file_lseek (struct file *file, loff_t offset, int orig)
        default:
                break;
        }
-       mutex_unlock(&file->f_dentry->d_inode->i_mutex);
+       mutex_unlock(&file->f_path.dentry->d_inode->i_mutex);
        return retval;
 }
 
index 7390b67c609d043667ed4c76de460815f106a769..149aa8bfb1fe4e2bb353ae49f490e7dc081ea48a 100644 (file)
@@ -488,7 +488,7 @@ void usb_sg_wait (struct usb_sg_request *io)
                int     retval;
 
                io->urbs [i]->dev = io->dev;
-               retval = usb_submit_urb (io->urbs [i], SLAB_ATOMIC);
+               retval = usb_submit_urb (io->urbs [i], GFP_ATOMIC);
 
                /* after we submit, let completions or cancelations fire;
                 * we handshake using io->status.
index bbbc82a8336a4f65858f815f586541b99091fb4c..4097a86c4b5e125c5de26dc6905259d52ab13657 100644 (file)
@@ -189,7 +189,7 @@ config USB_OTG
 
 config USB_GADGET_AT91
        boolean "AT91 USB Device Port"
-       depends on ARCH_AT91RM9200
+       depends on ARCH_AT91
        select USB_GADGET_SELECTED
        help
           Many Atmel AT91 processors (such as the AT91RM2000) have a
index 8b975d15538ddff6fb93e2757e7d1888be538881..a265e262a2eefd4239513613962a54d6bbee64d3 100644 (file)
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 #include <linux/utsname.h>
 
 #include <linux/usb_ch9.h>
@@ -1909,10 +1909,10 @@ static int fsync_sub(struct lun *curlun)
        if (!filp->f_op->fsync)
                return -EINVAL;
 
-       inode = filp->f_dentry->d_inode;
+       inode = filp->f_path.dentry->d_inode;
        mutex_lock(&inode->i_mutex);
        rc = filemap_fdatawrite(inode->i_mapping);
-       err = filp->f_op->fsync(filp, filp->f_dentry, 1);
+       err = filp->f_op->fsync(filp, filp->f_path.dentry, 1);
        if (!rc)
                rc = err;
        err = filemap_fdatawait(inode->i_mapping);
@@ -1950,7 +1950,7 @@ static int do_synchronize_cache(struct fsg_dev *fsg)
 static void invalidate_sub(struct lun *curlun)
 {
        struct file     *filp = curlun->filp;
-       struct inode    *inode = filp->f_dentry->d_inode;
+       struct inode    *inode = filp->f_path.dentry->d_inode;
        unsigned long   rc;
 
        rc = invalidate_inode_pages(inode->i_mapping);
@@ -3526,8 +3526,8 @@ static int open_backing_file(struct lun *curlun, const char *filename)
        if (!(filp->f_mode & FMODE_WRITE))
                ro = 1;
 
-       if (filp->f_dentry)
-               inode = filp->f_dentry->d_inode;
+       if (filp->f_path.dentry)
+               inode = filp->f_path.dentry->d_inode;
        if (inode && S_ISBLK(inode->i_mode)) {
                if (bdev_read_only(inode->i_bdev))
                        ro = 1;
@@ -3606,7 +3606,7 @@ static ssize_t show_file(struct device *dev, struct device_attribute *attr, char
 
        down_read(&fsg->filesem);
        if (backing_file_is_open(curlun)) {     // Get the complete pathname
-               p = d_path(curlun->filp->f_dentry, curlun->filp->f_vfsmnt,
+               p = d_path(curlun->filp->f_path.dentry, curlun->filp->f_path.mnt,
                                buf, PAGE_SIZE - 1);
                if (IS_ERR(p))
                        rc = PTR_ERR(p);
@@ -4030,8 +4030,8 @@ static int __init fsg_bind(struct usb_gadget *gadget)
                if (backing_file_is_open(curlun)) {
                        p = NULL;
                        if (pathbuf) {
-                               p = d_path(curlun->filp->f_dentry,
-                                       curlun->filp->f_vfsmnt,
+                               p = d_path(curlun->filp->f_path.dentry,
+                                       curlun->filp->f_path.mnt,
                                        pathbuf, PATH_MAX);
                                if (IS_ERR(p))
                                        p = NULL;
index 64554acad63f915ca41d06fe69a2ac66c12d0fa9..31351826f2baddc7c18d17276016745f3d5c2491 100644 (file)
@@ -1236,7 +1236,7 @@ autoconf_fail:
 
 
        /* ok, we made sense of the hardware ... */
-       dev = kzalloc(sizeof(*dev), SLAB_KERNEL);
+       dev = kzalloc(sizeof(*dev), GFP_KERNEL);
        if (!dev) {
                return -ENOMEM;
        }
index a3076da3f4eb03f60dc93494346b2b9d54755fb6..805a9826842d51a1c9a05443d4208fa62e477cb1 100644 (file)
@@ -1864,7 +1864,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        }
 
        /* alloc, and start init */
-       dev = kmalloc (sizeof *dev, SLAB_KERNEL);
+       dev = kmalloc (sizeof *dev, GFP_KERNEL);
        if (dev == NULL){
                pr_debug("enomem %s\n", pci_name(pdev));
                retval = -ENOMEM;
index 86924f9cdd7e0c5e57845e4f4a41d63a188414b2..3fb1044a4db03eb41bde7022f7773ae9640b6be8 100644 (file)
@@ -412,7 +412,7 @@ ep_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr)
        /* FIXME readahead for O_NONBLOCK and poll(); careful with ZLPs */
 
        value = -ENOMEM;
-       kbuf = kmalloc (len, SLAB_KERNEL);
+       kbuf = kmalloc (len, GFP_KERNEL);
        if (unlikely (!kbuf))
                goto free1;
 
@@ -456,7 +456,7 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
        /* FIXME writebehind for O_NONBLOCK and poll(), qlen = 1 */
 
        value = -ENOMEM;
-       kbuf = kmalloc (len, SLAB_KERNEL);
+       kbuf = kmalloc (len, GFP_KERNEL);
        if (!kbuf)
                goto free1;
        if (copy_from_user (kbuf, buf, len)) {
@@ -1898,7 +1898,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
        buf += 4;
        length -= 4;
 
-       kbuf = kmalloc (length, SLAB_KERNEL);
+       kbuf = kmalloc (length, GFP_KERNEL);
        if (!kbuf)
                return -ENOMEM;
        if (copy_from_user (kbuf, buf, length)) {
index 0b590831582c43f5fb96e275125aeb082beeca53..3024c679e38e9fcec4e5ada07f8bc00bd799f045 100644 (file)
@@ -2861,7 +2861,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
        }
 
        /* alloc, and start init */
-       dev = kzalloc (sizeof *dev, SLAB_KERNEL);
+       dev = kzalloc (sizeof *dev, GFP_KERNEL);
        if (dev == NULL){
                retval = -ENOMEM;
                goto done;
index 48a09fd89d18f44158ebcfe2e4041b01698c5679..030d87c28c2f614f4874c6c1867638fe410b5e87 100644 (file)
@@ -2581,7 +2581,7 @@ omap_udc_setup(struct platform_device *odev, struct otg_transceiver *xceiv)
        /* UDC_PULLUP_EN gates the chip clock */
        // OTG_SYSCON_1_REG |= DEV_IDLE_EN;
 
-       udc = kzalloc(sizeof(*udc), SLAB_KERNEL);
+       udc = kzalloc(sizeof(*udc), GFP_KERNEL);
        if (!udc)
                return -ENOMEM;
 
index 208e55a667ac0d2124ece6bb49c17dbe1cf59d27..5516c59ed5ec28d6ea1dc864fd8a9ebd504bdd56 100644 (file)
@@ -200,7 +200,7 @@ static void gs_unthrottle(struct tty_struct * tty);
 static void gs_break(struct tty_struct *tty, int break_state);
 static int  gs_ioctl(struct tty_struct *tty, struct file *file,
        unsigned int cmd, unsigned long arg);
-static void gs_set_termios(struct tty_struct *tty, struct termios *old);
+static void gs_set_termios(struct tty_struct *tty, struct ktermios *old);
 
 static int gs_send(struct gs_dev *dev);
 static int gs_send_packet(struct gs_dev *dev, char *packet,
@@ -1077,7 +1077,7 @@ static int gs_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd,
 /*
  * gs_set_termios
  */
-static void gs_set_termios(struct tty_struct *tty, struct termios *old)
+static void gs_set_termios(struct tty_struct *tty, struct ktermios *old)
 {
 }
 
index 0f809dd684921662a0aa41a4dc99d54f90f3e2f7..40710ea1b4900daeed459219d17aa0cc41dd5ebe 100644 (file)
@@ -1190,7 +1190,7 @@ autoconf_fail:
 
 
        /* ok, we made sense of the hardware ... */
-       dev = kzalloc(sizeof(*dev), SLAB_KERNEL);
+       dev = kzalloc(sizeof(*dev), GFP_KERNEL);
        if (!dev)
                return -ENOMEM;
        spin_lock_init (&dev->lock);
index 34b7a31cd85b90900a45a8626c186084a16f234f..56349d21e6ea9105d6ce6fbd19eaa6b142b3d83d 100644 (file)
@@ -492,7 +492,7 @@ show_periodic (struct class_device *class_dev, char *buf)
        unsigned                i;
        __le32                  tag;
 
-       if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, SLAB_ATOMIC)))
+       if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, GFP_ATOMIC)))
                return 0;
        seen_count = 0;
 
index 87eca6aeacf255dcf04b0fce1e0effbd4eee9e0d..9325e46a68c03d847386a5d3884d8cc163039828 100644 (file)
@@ -188,7 +188,7 @@ static DEFINE_TIMER(bulk_eot_timer, NULL, 0, 0);
 #define CHECK_ALIGN(x) if (((__u32)(x)) & 0x00000003) \
 {panic("Alignment check (DWORD) failed at %s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);}
 
-#define SLAB_FLAG     (in_interrupt() ? SLAB_ATOMIC : SLAB_KERNEL)
+#define SLAB_FLAG     (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL)
 #define KMALLOC_FLAG  (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL)
 
 /* Most helpful debugging aid */
@@ -275,13 +275,13 @@ static volatile USB_SB_Desc_t TxIntrSB_zout __attribute__ ((aligned (4)));
 static int zout_buffer[4] __attribute__ ((aligned (4)));
 
 /* Cache for allocating new EP and SB descriptors. */
-static kmem_cache_t *usb_desc_cache;
+static struct kmem_cache *usb_desc_cache;
 
 /* Cache for the registers allocated in the top half. */
-static kmem_cache_t *top_half_reg_cache;
+static struct kmem_cache *top_half_reg_cache;
 
 /* Cache for the data allocated in the isoc descr top half. */
-static kmem_cache_t *isoc_compl_cache;
+static struct kmem_cache *isoc_compl_cache;
 
 static struct usb_bus *etrax_usb_bus;
 
@@ -1743,7 +1743,7 @@ static irqreturn_t etrax_usb_tx_interrupt(int irq, void *vhc)
 
                *R_DMA_CH8_SUB3_CLR_INTR = IO_STATE(R_DMA_CH8_SUB3_CLR_INTR, clr_descr, do);
 
-               comp_data = (usb_isoc_complete_data_t*)kmem_cache_alloc(isoc_compl_cache, SLAB_ATOMIC);
+               comp_data = (usb_isoc_complete_data_t*)kmem_cache_alloc(isoc_compl_cache, GFP_ATOMIC);
                assert(comp_data != NULL);
 
                 INIT_WORK(&comp_data->usb_bh, etrax_usb_isoc_descr_interrupt_bottom_half, comp_data);
@@ -3010,7 +3010,7 @@ static void etrax_usb_add_to_isoc_sb_list(struct urb *urb, int epid)
                        if (!urb->iso_frame_desc[i].length)
                                continue;
 
-                       next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_ATOMIC);
+                       next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, GFP_ATOMIC);
                        assert(next_sb_desc != NULL);
 
                        if (urb->iso_frame_desc[i].length > 0) {
@@ -3063,7 +3063,7 @@ static void etrax_usb_add_to_isoc_sb_list(struct urb *urb, int epid)
                if (TxIsocEPList[epid].sub == 0) {
                        dbg_isoc("Isoc traffic not already running, allocating SB");
 
-                       next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_ATOMIC);
+                       next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, GFP_ATOMIC);
                        assert(next_sb_desc != NULL);
 
                        next_sb_desc->command = (IO_STATE(USB_SB_command, tt, in) |
@@ -3317,7 +3317,7 @@ static irqreturn_t etrax_usb_hc_interrupt_top_half(int irq, void *vhc)
 
        restore_flags(flags);
 
-       reg = (usb_interrupt_registers_t *)kmem_cache_alloc(top_half_reg_cache, SLAB_ATOMIC);
+       reg = (usb_interrupt_registers_t *)kmem_cache_alloc(top_half_reg_cache, GFP_ATOMIC);
 
        assert(reg != NULL);
 
index 8293c1d4be3f3049e0fb531cff33966436803541..0f47a57dac28578a25e745c343a589796f8838cf 100644 (file)
@@ -505,7 +505,7 @@ show_periodic (struct class_device *class_dev, char *buf)
        char                    *next;
        unsigned                i;
 
-       if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, SLAB_ATOMIC)))
+       if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, GFP_ATOMIC)))
                return 0;
        seen_count = 0;
 
index a95275a401b1c5b24aeae778699e90a2127cc5aa..b28a9b602066e03afeba49bfeb7dc8dfc8043392 100644 (file)
@@ -945,7 +945,7 @@ MODULE_LICENSE ("GPL");
 #include "ohci-ppc-soc.c"
 #endif
 
-#if defined(CONFIG_ARCH_AT91RM9200) || defined(CONFIG_ARCH_AT91SAM9261)
+#ifdef CONFIG_ARCH_AT91
 #include "ohci-at91.c"
 #endif
 
@@ -962,8 +962,7 @@ MODULE_LICENSE ("GPL");
       || defined (CONFIG_ARCH_EP93XX) \
       || defined (CONFIG_SOC_AU1X00) \
       || defined (CONFIG_USB_OHCI_HCD_PPC_SOC) \
-      || defined (CONFIG_ARCH_AT91RM9200) \
-      || defined (CONFIG_ARCH_AT91SAM9261) \
+      || defined (CONFIG_ARCH_AT91) \
       || defined (CONFIG_ARCH_PNX4008) \
        )
 #error "missing bus glue for ohci-hcd"
index 2dbb77414905209969e86724c5a15f80791c061c..7f26f9bdbaf1e61e70a8090e9ed3648f538f7f85 100644 (file)
@@ -134,7 +134,7 @@ static int isp1301_attach(struct i2c_adapter *adap, int addr, int kind)
 {
        struct i2c_client *c;
 
-       c = (struct i2c_client *)kzalloc(sizeof(*c), SLAB_KERNEL);
+       c = (struct i2c_client *)kzalloc(sizeof(*c), GFP_KERNEL);
 
        if (!c)
                return -ENOMEM;
index 226bf3de8edd5ce092c551f0a90daa96ba2fc9e4..e87692c31be470b6df00d7a305154918bfa82ce7 100644 (file)
@@ -81,7 +81,7 @@ MODULE_PARM_DESC(debug, "Debug level");
 static char *errbuf;
 #define ERRBUF_LEN    (32 * 1024)
 
-static kmem_cache_t *uhci_up_cachep;   /* urb_priv */
+static struct kmem_cache *uhci_up_cachep;      /* urb_priv */
 
 static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state);
 static void wakeup_rh(struct uhci_hcd *uhci);
index 06115f22a4fac7420113b7b30d134b08cf3aa6b3..30b88459ac7dc544cba4b89819a2ad362471967a 100644 (file)
@@ -498,7 +498,7 @@ static inline struct urb_priv *uhci_alloc_urb_priv(struct uhci_hcd *uhci,
 {
        struct urb_priv *urbp;
 
-       urbp = kmem_cache_alloc(uhci_up_cachep, SLAB_ATOMIC);
+       urbp = kmem_cache_alloc(uhci_up_cachep, GFP_ATOMIC);
        if (!urbp)
                return NULL;
 
index 661af7aa62367c0f2bdf8fa05773c31eb24e3b54..8a62d4785755ef38319372611aeed6a040d89d3a 100644 (file)
@@ -6,9 +6,10 @@ comment "USB Input Devices"
 
 config USB_HID
        tristate "USB Human Interface Device (full HID) support"
-       depends on USB
+       default y
+       depends on USB && HID
        ---help---
-         Say Y here if you want full HID support to connect keyboards,
+         Say Y here if you want full HID support to connect USB keyboards,
          mice, joysticks, graphic tablets, or any other HID based devices
          to your computer via USB. You also need to select HID Input layer
          support (below) if you want to use keyboards, mice, joysticks and
@@ -27,20 +28,10 @@ config USB_HID
 comment "Input core support is needed for USB HID input layer or HIDBP support"
        depends on USB_HID && INPUT=n
 
-config USB_HIDINPUT
-       bool "HID input layer support"
-       default y
-       depends on INPUT && USB_HID
-       help
-         Say Y here if you want to use a USB keyboard, mouse or joystick,
-         or any other HID input device.
-
-         If unsure, say Y.
-
-config USB_HIDINPUT_POWERBOOK
+config USB_HID_POWERBOOK
        bool "Enable support for iBook/PowerBook special keys"
        default n
-       depends on USB_HIDINPUT
+       depends on USB_HID
        help
          Say Y here if you want support for the special keys (Fn, Numlock) on
          Apple iBooks and PowerBooks.
@@ -49,7 +40,7 @@ config USB_HIDINPUT_POWERBOOK
 
 config HID_FF
        bool "Force feedback support (EXPERIMENTAL)"
-       depends on USB_HIDINPUT && EXPERIMENTAL
+       depends on USB_HID && EXPERIMENTAL
        help
          Say Y here is you want force feedback support for a few HID devices.
          See below for a list of supported devices.
index d946d5213b30d0481035406caf1ada2101f178f7..1a24b5bfa05fcd493adecc2822e3aab0fe862c62 100644 (file)
@@ -11,9 +11,6 @@ usbhid-objs   := hid-core.o
 ifeq ($(CONFIG_USB_HIDDEV),y)
        usbhid-objs     += hiddev.o
 endif
-ifeq ($(CONFIG_USB_HIDINPUT),y)
-       usbhid-objs     += hid-input.o
-endif
 ifeq ($(CONFIG_HID_PID),y)
        usbhid-objs     += hid-pidff.o
 endif
index 0096373b5f98b974f5c67c9341f67e7718c877a2..909138e5aa04029685ec901d31ecf51c15f9376e 100644 (file)
@@ -152,7 +152,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
        if (!acecad || !input_dev)
                goto fail1;
 
-       acecad->data = usb_buffer_alloc(dev, 8, SLAB_KERNEL, &acecad->data_dma);
+       acecad->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &acecad->data_dma);
        if (!acecad->data)
                goto fail1;
 
index bf428184608fe435cffbe3b15e2d7df401524f5c..9f52429ce6543156d328ef4ac947201bf87a726b 100644 (file)
@@ -1988,7 +1988,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
                goto fail1;
 
        aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH,
-                                       SLAB_ATOMIC, &aiptek->data_dma);
+                                       GFP_ATOMIC, &aiptek->data_dma);
        if (!aiptek->data)
                goto fail1;
 
index 4c213513484dcb38d154220a55094e226f8dd5b5..c77291d3d063d548f3b1786d28272ea79a56bcc6 100644 (file)
 #define APPLE_VENDOR_ID                0x05AC
 
 /* These names come from Info.plist in AppleUSBTrackpad.kext */
-#define GEYSER_ANSI_PRODUCT_ID 0x0214
-#define GEYSER_ISO_PRODUCT_ID  0x0215
-#define GEYSER_JIS_PRODUCT_ID  0x0216
+#define FOUNTAIN_ANSI_PRODUCT_ID       0x020E
+#define FOUNTAIN_ISO_PRODUCT_ID                0x020F
+
+#define FOUNTAIN_TP_ONLY_PRODUCT_ID    0x030A
+
+#define GEYSER1_TP_ONLY_PRODUCT_ID     0x030B
+
+#define GEYSER_ANSI_PRODUCT_ID         0x0214
+#define GEYSER_ISO_PRODUCT_ID          0x0215
+#define GEYSER_JIS_PRODUCT_ID          0x0216
 
 /* MacBook devices */
-#define GEYSER3_ANSI_PRODUCT_ID        0x0217
-#define GEYSER3_ISO_PRODUCT_ID 0x0218
-#define GEYSER3_JIS_PRODUCT_ID 0x0219
+#define GEYSER3_ANSI_PRODUCT_ID                0x0217
+#define GEYSER3_ISO_PRODUCT_ID         0x0218
+#define GEYSER3_JIS_PRODUCT_ID         0x0219
+
+/*
+ * Geyser IV: same as Geyser III according to Info.plist in AppleUSBTrackpad.kext
+ * -> same IOClass (AppleUSBGrIIITrackpad), same acceleration tables
+ */
+#define GEYSER4_ANSI_PRODUCT_ID        0x021A
+#define GEYSER4_ISO_PRODUCT_ID 0x021B
+#define GEYSER4_JIS_PRODUCT_ID 0x021C
 
 #define ATP_DEVICE(prod)                                       \
        .match_flags = USB_DEVICE_ID_MATCH_DEVICE |             \
 
 /* table of devices that work with this driver */
 static struct usb_device_id atp_table [] = {
-       { ATP_DEVICE(0x020E) },
-       { ATP_DEVICE(0x020F) },
-       { ATP_DEVICE(0x030A) },
-       { ATP_DEVICE(0x030B) },
+       { ATP_DEVICE(FOUNTAIN_ANSI_PRODUCT_ID) },
+       { ATP_DEVICE(FOUNTAIN_ISO_PRODUCT_ID) },
+       { ATP_DEVICE(FOUNTAIN_TP_ONLY_PRODUCT_ID) },
+       { ATP_DEVICE(GEYSER1_TP_ONLY_PRODUCT_ID) },
 
        /* PowerBooks Oct 2005 */
        { ATP_DEVICE(GEYSER_ANSI_PRODUCT_ID) },
        { ATP_DEVICE(GEYSER_ISO_PRODUCT_ID) },
        { ATP_DEVICE(GEYSER_JIS_PRODUCT_ID) },
 
+       /* Core Duo MacBook & MacBook Pro */
        { ATP_DEVICE(GEYSER3_ANSI_PRODUCT_ID) },
        { ATP_DEVICE(GEYSER3_ISO_PRODUCT_ID) },
        { ATP_DEVICE(GEYSER3_JIS_PRODUCT_ID) },
 
+       /* Core2 Duo MacBook & MacBook Pro */
+       { ATP_DEVICE(GEYSER4_ANSI_PRODUCT_ID) },
+       { ATP_DEVICE(GEYSER4_ISO_PRODUCT_ID) },
+       { ATP_DEVICE(GEYSER4_JIS_PRODUCT_ID) },
+
        /* Terminating entry */
        { }
 };
@@ -108,7 +129,7 @@ MODULE_DEVICE_TABLE (usb, atp_table);
  */
 #define ATP_THRESHOLD   5
 
-/* MacBook Pro (Geyser 3) initialization constants */
+/* MacBook Pro (Geyser 3 & 4) initialization constants */
 #define ATP_GEYSER3_MODE_READ_REQUEST_ID 1
 #define ATP_GEYSER3_MODE_WRITE_REQUEST_ID 9
 #define ATP_GEYSER3_MODE_REQUEST_VALUE 0x300
@@ -154,6 +175,13 @@ MODULE_AUTHOR("Johannes Berg, Stelian Pop, Frank Arnold, Michael Hanselmann");
 MODULE_DESCRIPTION("Apple PowerBooks USB touchpad driver");
 MODULE_LICENSE("GPL");
 
+/*
+ * Make the threshold a module parameter
+ */
+static int threshold = ATP_THRESHOLD;
+module_param(threshold, int, 0644);
+MODULE_PARM_DESC(threshold, "Discards any change in data from a sensor (trackpad has hundreds of these sensors) less than this value");
+
 static int debug = 1;
 module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "Activate debugging output");
@@ -174,7 +202,10 @@ static inline int atp_is_geyser_3(struct atp *dev)
 
        return (productId == GEYSER3_ANSI_PRODUCT_ID) ||
                (productId == GEYSER3_ISO_PRODUCT_ID) ||
-               (productId == GEYSER3_JIS_PRODUCT_ID);
+               (productId == GEYSER3_JIS_PRODUCT_ID) ||
+               (productId == GEYSER4_ANSI_PRODUCT_ID) ||
+               (productId == GEYSER4_ISO_PRODUCT_ID) ||
+               (productId == GEYSER4_JIS_PRODUCT_ID);
 }
 
 static int atp_calculate_abs(int *xy_sensors, int nb_sensors, int fact,
@@ -183,16 +214,48 @@ static int atp_calculate_abs(int *xy_sensors, int nb_sensors, int fact,
        int i;
        /* values to calculate mean */
        int pcum = 0, psum = 0;
+       int is_increasing = 0;
 
        *fingers = 0;
 
        for (i = 0; i < nb_sensors; i++) {
-               if (xy_sensors[i] < ATP_THRESHOLD)
+               if (xy_sensors[i] < threshold) {
+                       if (is_increasing)
+                               is_increasing = 0;
+
                        continue;
-               if ((i - 1 < 0) || (xy_sensors[i - 1] < ATP_THRESHOLD))
+               }
+
+               /*
+                * Makes the finger detection more versatile.  For example,
+                * two fingers with no gap will be detected.  Also, my
+                * tests show it less likely to have intermittent loss
+                * of multiple finger readings while moving around (scrolling).
+                *
+                * Changes the multiple finger detection to counting humps on
+                * sensors (transitions from nonincreasing to increasing)
+                * instead of counting transitions from low sensors (no
+                * finger reading) to high sensors (finger above
+                * sensor)
+                *
+                * - Jason Parekh <jasonparekh@gmail.com>
+                */
+               if (i < 1 || (!is_increasing && xy_sensors[i - 1] < xy_sensors[i])) {
                        (*fingers)++;
-               pcum += xy_sensors[i] * i;
-               psum += xy_sensors[i];
+                       is_increasing = 1;
+               } else if (i > 0 && xy_sensors[i - 1] >= xy_sensors[i]) {
+                       is_increasing = 0;
+               }
+
+               /*
+                * Subtracts threshold so a high sensor that just passes the threshold
+                * won't skew the calculated absolute coordinate.  Fixes an issue
+                * where slowly moving the mouse would occassionaly jump a number of
+                * pixels (let me restate--slowly moving the mouse makes this issue
+                * most apparent).
+                */
+               pcum += (xy_sensors[i] - threshold) * i;
+               psum += (xy_sensors[i] - threshold);
        }
 
        if (psum > 0) {
index ff23318dc301aeb7eecd626395015af70f702327..b724e36f7b9203385039fff0b14c382b6a170dec 100644 (file)
@@ -592,7 +592,7 @@ static void ati_remote_irq_in(struct urb *urb)
                        __FUNCTION__, urb->status);
        }
 
-       retval = usb_submit_urb(urb, SLAB_ATOMIC);
+       retval = usb_submit_urb(urb, GFP_ATOMIC);
        if (retval)
                dev_err(&ati_remote->interface->dev, "%s: usb_submit_urb()=%d\n",
                        __FUNCTION__, retval);
@@ -604,12 +604,12 @@ static void ati_remote_irq_in(struct urb *urb)
 static int ati_remote_alloc_buffers(struct usb_device *udev,
                                    struct ati_remote *ati_remote)
 {
-       ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC,
+       ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, GFP_ATOMIC,
                                             &ati_remote->inbuf_dma);
        if (!ati_remote->inbuf)
                return -1;
 
-       ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC,
+       ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, GFP_ATOMIC,
                                              &ati_remote->outbuf_dma);
        if (!ati_remote->outbuf)
                return -1;
index 4295bab4f1e2653a69bba6a5326488d782e64e0f..89fa6885709b60b04ba0ca32322bb4a84ef786ae 100644 (file)
@@ -4,6 +4,7 @@
  *  Copyright (c) 1999 Andreas Gal
  *  Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
  *  Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
+ *  Copyright (c) 2006 Jiri Kosina
  */
 
 /*
@@ -32,8 +33,9 @@
 
 #include <linux/usb.h>
 
-#include "hid.h"
+#include <linux/hid.h>
 #include <linux/hiddev.h>
+#include "usbhid.h"
 
 /*
  * Version Information
@@ -54,886 +56,10 @@ static unsigned int hid_mousepoll_interval;
 module_param_named(mousepoll, hid_mousepoll_interval, uint, 0644);
 MODULE_PARM_DESC(mousepoll, "Polling interval of mice");
 
-/*
- * Register a new report for a device.
- */
-
-static struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id)
-{
-       struct hid_report_enum *report_enum = device->report_enum + type;
-       struct hid_report *report;
-
-       if (report_enum->report_id_hash[id])
-               return report_enum->report_id_hash[id];
-
-       if (!(report = kzalloc(sizeof(struct hid_report), GFP_KERNEL)))
-               return NULL;
-
-       if (id != 0)
-               report_enum->numbered = 1;
-
-       report->id = id;
-       report->type = type;
-       report->size = 0;
-       report->device = device;
-       report_enum->report_id_hash[id] = report;
-
-       list_add_tail(&report->list, &report_enum->report_list);
-
-       return report;
-}
-
-/*
- * Register a new field for this report.
- */
-
-static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values)
-{
-       struct hid_field *field;
-
-       if (report->maxfield == HID_MAX_FIELDS) {
-               dbg("too many fields in report");
-               return NULL;
-       }
-
-       if (!(field = kzalloc(sizeof(struct hid_field) + usages * sizeof(struct hid_usage)
-               + values * sizeof(unsigned), GFP_KERNEL))) return NULL;
-
-       field->index = report->maxfield++;
-       report->field[field->index] = field;
-       field->usage = (struct hid_usage *)(field + 1);
-       field->value = (unsigned *)(field->usage + usages);
-       field->report = report;
-
-       return field;
-}
-
-/*
- * Open a collection. The type/usage is pushed on the stack.
- */
-
-static int open_collection(struct hid_parser *parser, unsigned type)
-{
-       struct hid_collection *collection;
-       unsigned usage;
-
-       usage = parser->local.usage[0];
-
-       if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) {
-               dbg("collection stack overflow");
-               return -1;
-       }
-
-       if (parser->device->maxcollection == parser->device->collection_size) {
-               collection = kmalloc(sizeof(struct hid_collection) *
-                               parser->device->collection_size * 2, GFP_KERNEL);
-               if (collection == NULL) {
-                       dbg("failed to reallocate collection array");
-                       return -1;
-               }
-               memcpy(collection, parser->device->collection,
-                       sizeof(struct hid_collection) *
-                       parser->device->collection_size);
-               memset(collection + parser->device->collection_size, 0,
-                       sizeof(struct hid_collection) *
-                       parser->device->collection_size);
-               kfree(parser->device->collection);
-               parser->device->collection = collection;
-               parser->device->collection_size *= 2;
-       }
-
-       parser->collection_stack[parser->collection_stack_ptr++] =
-               parser->device->maxcollection;
-
-       collection = parser->device->collection +
-               parser->device->maxcollection++;
-       collection->type = type;
-       collection->usage = usage;
-       collection->level = parser->collection_stack_ptr - 1;
-
-       if (type == HID_COLLECTION_APPLICATION)
-               parser->device->maxapplication++;
-
-       return 0;
-}
-
-/*
- * Close a collection.
- */
-
-static int close_collection(struct hid_parser *parser)
-{
-       if (!parser->collection_stack_ptr) {
-               dbg("collection stack underflow");
-               return -1;
-       }
-       parser->collection_stack_ptr--;
-       return 0;
-}
-
-/*
- * Climb up the stack, search for the specified collection type
- * and return the usage.
- */
-
-static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type)
-{
-       int n;
-       for (n = parser->collection_stack_ptr - 1; n >= 0; n--)
-               if (parser->device->collection[parser->collection_stack[n]].type == type)
-                       return parser->device->collection[parser->collection_stack[n]].usage;
-       return 0; /* we know nothing about this usage type */
-}
-
-/*
- * Add a usage to the temporary parser table.
- */
-
-static int hid_add_usage(struct hid_parser *parser, unsigned usage)
-{
-       if (parser->local.usage_index >= HID_MAX_USAGES) {
-               dbg("usage index exceeded");
-               return -1;
-       }
-       parser->local.usage[parser->local.usage_index] = usage;
-       parser->local.collection_index[parser->local.usage_index] =
-               parser->collection_stack_ptr ?
-               parser->collection_stack[parser->collection_stack_ptr - 1] : 0;
-       parser->local.usage_index++;
-       return 0;
-}
-
-/*
- * Register a new field for this report.
- */
-
-static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsigned flags)
-{
-       struct hid_report *report;
-       struct hid_field *field;
-       int usages;
-       unsigned offset;
-       int i;
-
-       if (!(report = hid_register_report(parser->device, report_type, parser->global.report_id))) {
-               dbg("hid_register_report failed");
-               return -1;
-       }
-
-       if (parser->global.logical_maximum < parser->global.logical_minimum) {
-               dbg("logical range invalid %d %d", parser->global.logical_minimum, parser->global.logical_maximum);
-               return -1;
-       }
-
-       offset = report->size;
-       report->size += parser->global.report_size * parser->global.report_count;
-
-       if (!parser->local.usage_index) /* Ignore padding fields */
-               return 0;
-
-       usages = max_t(int, parser->local.usage_index, parser->global.report_count);
-
-       if ((field = hid_register_field(report, usages, parser->global.report_count)) == NULL)
-               return 0;
-
-       field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL);
-       field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL);
-       field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION);
-
-       for (i = 0; i < usages; i++) {
-               int j = i;
-               /* Duplicate the last usage we parsed if we have excess values */
-               if (i >= parser->local.usage_index)
-                       j = parser->local.usage_index - 1;
-               field->usage[i].hid = parser->local.usage[j];
-               field->usage[i].collection_index =
-                       parser->local.collection_index[j];
-       }
-
-       field->maxusage = usages;
-       field->flags = flags;
-       field->report_offset = offset;
-       field->report_type = report_type;
-       field->report_size = parser->global.report_size;
-       field->report_count = parser->global.report_count;
-       field->logical_minimum = parser->global.logical_minimum;
-       field->logical_maximum = parser->global.logical_maximum;
-       field->physical_minimum = parser->global.physical_minimum;
-       field->physical_maximum = parser->global.physical_maximum;
-       field->unit_exponent = parser->global.unit_exponent;
-       field->unit = parser->global.unit;
-
-       return 0;
-}
-
-/*
- * Read data value from item.
- */
-
-static u32 item_udata(struct hid_item *item)
-{
-       switch (item->size) {
-               case 1: return item->data.u8;
-               case 2: return item->data.u16;
-               case 4: return item->data.u32;
-       }
-       return 0;
-}
-
-static s32 item_sdata(struct hid_item *item)
-{
-       switch (item->size) {
-               case 1: return item->data.s8;
-               case 2: return item->data.s16;
-               case 4: return item->data.s32;
-       }
-       return 0;
-}
-
-/*
- * Process a global item.
- */
-
-static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
-{
-       switch (item->tag) {
-
-               case HID_GLOBAL_ITEM_TAG_PUSH:
-
-                       if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) {
-                               dbg("global enviroment stack overflow");
-                               return -1;
-                       }
-
-                       memcpy(parser->global_stack + parser->global_stack_ptr++,
-                               &parser->global, sizeof(struct hid_global));
-                       return 0;
-
-               case HID_GLOBAL_ITEM_TAG_POP:
-
-                       if (!parser->global_stack_ptr) {
-                               dbg("global enviroment stack underflow");
-                               return -1;
-                       }
-
-                       memcpy(&parser->global, parser->global_stack + --parser->global_stack_ptr,
-                               sizeof(struct hid_global));
-                       return 0;
-
-               case HID_GLOBAL_ITEM_TAG_USAGE_PAGE:
-                       parser->global.usage_page = item_udata(item);
-                       return 0;
-
-               case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM:
-                       parser->global.logical_minimum = item_sdata(item);
-                       return 0;
-
-               case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM:
-                       if (parser->global.logical_minimum < 0)
-                               parser->global.logical_maximum = item_sdata(item);
-                       else
-                               parser->global.logical_maximum = item_udata(item);
-                       return 0;
-
-               case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM:
-                       parser->global.physical_minimum = item_sdata(item);
-                       return 0;
-
-               case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM:
-                       if (parser->global.physical_minimum < 0)
-                               parser->global.physical_maximum = item_sdata(item);
-                       else
-                               parser->global.physical_maximum = item_udata(item);
-                       return 0;
-
-               case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT:
-                       parser->global.unit_exponent = item_sdata(item);
-                       return 0;
-
-               case HID_GLOBAL_ITEM_TAG_UNIT:
-                       parser->global.unit = item_udata(item);
-                       return 0;
-
-               case HID_GLOBAL_ITEM_TAG_REPORT_SIZE:
-                       if ((parser->global.report_size = item_udata(item)) > 32) {
-                               dbg("invalid report_size %d", parser->global.report_size);
-                               return -1;
-                       }
-                       return 0;
-
-               case HID_GLOBAL_ITEM_TAG_REPORT_COUNT:
-                       if ((parser->global.report_count = item_udata(item)) > HID_MAX_USAGES) {
-                               dbg("invalid report_count %d", parser->global.report_count);
-                               return -1;
-                       }
-                       return 0;
-
-               case HID_GLOBAL_ITEM_TAG_REPORT_ID:
-                       if ((parser->global.report_id = item_udata(item)) == 0) {
-                               dbg("report_id 0 is invalid");
-                               return -1;
-                       }
-                       return 0;
-
-               default:
-                       dbg("unknown global tag 0x%x", item->tag);
-                       return -1;
-       }
-}
-
-/*
- * Process a local item.
- */
-
-static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
-{
-       __u32 data;
-       unsigned n;
-
-       if (item->size == 0) {
-               dbg("item data expected for local item");
-               return -1;
-       }
-
-       data = item_udata(item);
-
-       switch (item->tag) {
-
-               case HID_LOCAL_ITEM_TAG_DELIMITER:
-
-                       if (data) {
-                               /*
-                                * We treat items before the first delimiter
-                                * as global to all usage sets (branch 0).
-                                * In the moment we process only these global
-                                * items and the first delimiter set.
-                                */
-                               if (parser->local.delimiter_depth != 0) {
-                                       dbg("nested delimiters");
-                                       return -1;
-                               }
-                               parser->local.delimiter_depth++;
-                               parser->local.delimiter_branch++;
-                       } else {
-                               if (parser->local.delimiter_depth < 1) {
-                                       dbg("bogus close delimiter");
-                                       return -1;
-                               }
-                               parser->local.delimiter_depth--;
-                       }
-                       return 1;
-
-               case HID_LOCAL_ITEM_TAG_USAGE:
-
-                       if (parser->local.delimiter_branch > 1) {
-                               dbg("alternative usage ignored");
-                               return 0;
-                       }
-
-                       if (item->size <= 2)
-                               data = (parser->global.usage_page << 16) + data;
-
-                       return hid_add_usage(parser, data);
-
-               case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
-
-                       if (parser->local.delimiter_branch > 1) {
-                               dbg("alternative usage ignored");
-                               return 0;
-                       }
-
-                       if (item->size <= 2)
-                               data = (parser->global.usage_page << 16) + data;
-
-                       parser->local.usage_minimum = data;
-                       return 0;
-
-               case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM:
-
-                       if (parser->local.delimiter_branch > 1) {
-                               dbg("alternative usage ignored");
-                               return 0;
-                       }
-
-                       if (item->size <= 2)
-                               data = (parser->global.usage_page << 16) + data;
-
-                       for (n = parser->local.usage_minimum; n <= data; n++)
-                               if (hid_add_usage(parser, n)) {
-                                       dbg("hid_add_usage failed\n");
-                                       return -1;
-                               }
-                       return 0;
-
-               default:
-
-                       dbg("unknown local item tag 0x%x", item->tag);
-                       return 0;
-       }
-       return 0;
-}
-
-/*
- * Process a main item.
- */
-
-static int hid_parser_main(struct hid_parser *parser, struct hid_item *item)
-{
-       __u32 data;
-       int ret;
-
-       data = item_udata(item);
-
-       switch (item->tag) {
-               case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION:
-                       ret = open_collection(parser, data & 0xff);
-                       break;
-               case HID_MAIN_ITEM_TAG_END_COLLECTION:
-                       ret = close_collection(parser);
-                       break;
-               case HID_MAIN_ITEM_TAG_INPUT:
-                       ret = hid_add_field(parser, HID_INPUT_REPORT, data);
-                       break;
-               case HID_MAIN_ITEM_TAG_OUTPUT:
-                       ret = hid_add_field(parser, HID_OUTPUT_REPORT, data);
-                       break;
-               case HID_MAIN_ITEM_TAG_FEATURE:
-                       ret = hid_add_field(parser, HID_FEATURE_REPORT, data);
-                       break;
-               default:
-                       dbg("unknown main item tag 0x%x", item->tag);
-                       ret = 0;
-       }
-
-       memset(&parser->local, 0, sizeof(parser->local));       /* Reset the local parser environment */
-
-       return ret;
-}
-
-/*
- * Process a reserved item.
- */
-
-static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item)
-{
-       dbg("reserved item type, tag 0x%x", item->tag);
-       return 0;
-}
-
-/*
- * Free a report and all registered fields. The field->usage and
- * field->value table's are allocated behind the field, so we need
- * only to free(field) itself.
- */
-
-static void hid_free_report(struct hid_report *report)
-{
-       unsigned n;
-
-       for (n = 0; n < report->maxfield; n++)
-               kfree(report->field[n]);
-       kfree(report);
-}
-
-/*
- * Free a device structure, all reports, and all fields.
- */
-
-static void hid_free_device(struct hid_device *device)
-{
-       unsigned i,j;
-
-       for (i = 0; i < HID_REPORT_TYPES; i++) {
-               struct hid_report_enum *report_enum = device->report_enum + i;
-
-               for (j = 0; j < 256; j++) {
-                       struct hid_report *report = report_enum->report_id_hash[j];
-                       if (report)
-                               hid_free_report(report);
-               }
-       }
-
-       kfree(device->rdesc);
-       kfree(device);
-}
-
-/*
- * Fetch a report description item from the data stream. We support long
- * items, though they are not used yet.
- */
-
-static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item)
-{
-       u8 b;
-
-       if ((end - start) <= 0)
-               return NULL;
-
-       b = *start++;
-
-       item->type = (b >> 2) & 3;
-       item->tag  = (b >> 4) & 15;
-
-       if (item->tag == HID_ITEM_TAG_LONG) {
-
-               item->format = HID_ITEM_FORMAT_LONG;
-
-               if ((end - start) < 2)
-                       return NULL;
-
-               item->size = *start++;
-               item->tag  = *start++;
-
-               if ((end - start) < item->size)
-                       return NULL;
-
-               item->data.longdata = start;
-               start += item->size;
-               return start;
-       }
-
-       item->format = HID_ITEM_FORMAT_SHORT;
-       item->size = b & 3;
-
-       switch (item->size) {
-
-               case 0:
-                       return start;
-
-               case 1:
-                       if ((end - start) < 1)
-                               return NULL;
-                       item->data.u8 = *start++;
-                       return start;
-
-               case 2:
-                       if ((end - start) < 2)
-                               return NULL;
-                       item->data.u16 = le16_to_cpu(get_unaligned((__le16*)start));
-                       start = (__u8 *)((__le16 *)start + 1);
-                       return start;
-
-               case 3:
-                       item->size++;
-                       if ((end - start) < 4)
-                               return NULL;
-                       item->data.u32 = le32_to_cpu(get_unaligned((__le32*)start));
-                       start = (__u8 *)((__le32 *)start + 1);
-                       return start;
-       }
-
-       return NULL;
-}
-
-/*
- * Parse a report description into a hid_device structure. Reports are
- * enumerated, fields are attached to these reports.
- */
-
-static struct hid_device *hid_parse_report(__u8 *start, unsigned size)
-{
-       struct hid_device *device;
-       struct hid_parser *parser;
-       struct hid_item item;
-       __u8 *end;
-       unsigned i;
-       static int (*dispatch_type[])(struct hid_parser *parser,
-                                     struct hid_item *item) = {
-               hid_parser_main,
-               hid_parser_global,
-               hid_parser_local,
-               hid_parser_reserved
-       };
-
-       if (!(device = kzalloc(sizeof(struct hid_device), GFP_KERNEL)))
-               return NULL;
-
-       if (!(device->collection = kzalloc(sizeof(struct hid_collection) *
-                                  HID_DEFAULT_NUM_COLLECTIONS, GFP_KERNEL))) {
-               kfree(device);
-               return NULL;
-       }
-       device->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
-
-       for (i = 0; i < HID_REPORT_TYPES; i++)
-               INIT_LIST_HEAD(&device->report_enum[i].report_list);
-
-       if (!(device->rdesc = (__u8 *)kmalloc(size, GFP_KERNEL))) {
-               kfree(device->collection);
-               kfree(device);
-               return NULL;
-       }
-       memcpy(device->rdesc, start, size);
-       device->rsize = size;
-
-       if (!(parser = kzalloc(sizeof(struct hid_parser), GFP_KERNEL))) {
-               kfree(device->rdesc);
-               kfree(device->collection);
-               kfree(device);
-               return NULL;
-       }
-       parser->device = device;
-
-       end = start + size;
-       while ((start = fetch_item(start, end, &item)) != NULL) {
-
-               if (item.format != HID_ITEM_FORMAT_SHORT) {
-                       dbg("unexpected long global item");
-                       kfree(device->collection);
-                       hid_free_device(device);
-                       kfree(parser);
-                       return NULL;
-               }
-
-               if (dispatch_type[item.type](parser, &item)) {
-                       dbg("item %u %u %u %u parsing failed\n",
-                               item.format, (unsigned)item.size, (unsigned)item.type, (unsigned)item.tag);
-                       kfree(device->collection);
-                       hid_free_device(device);
-                       kfree(parser);
-                       return NULL;
-               }
-
-               if (start == end) {
-                       if (parser->collection_stack_ptr) {
-                               dbg("unbalanced collection at end of report description");
-                               kfree(device->collection);
-                               hid_free_device(device);
-                               kfree(parser);
-                               return NULL;
-                       }
-                       if (parser->local.delimiter_depth) {
-                               dbg("unbalanced delimiter at end of report description");
-                               kfree(device->collection);
-                               hid_free_device(device);
-                               kfree(parser);
-                               return NULL;
-                       }
-                       kfree(parser);
-                       return device;
-               }
-       }
-
-       dbg("item fetching failed at offset %d\n", (int)(end - start));
-       kfree(device->collection);
-       hid_free_device(device);
-       kfree(parser);
-       return NULL;
-}
-
-/*
- * Convert a signed n-bit integer to signed 32-bit integer. Common
- * cases are done through the compiler, the screwed things has to be
- * done by hand.
- */
-
-static s32 snto32(__u32 value, unsigned n)
-{
-       switch (n) {
-               case 8:  return ((__s8)value);
-               case 16: return ((__s16)value);
-               case 32: return ((__s32)value);
-       }
-       return value & (1 << (n - 1)) ? value | (-1 << n) : value;
-}
-
-/*
- * Convert a signed 32-bit integer to a signed n-bit integer.
- */
-
-static u32 s32ton(__s32 value, unsigned n)
-{
-       s32 a = value >> (n - 1);
-       if (a && a != -1)
-               return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1;
-       return value & ((1 << n) - 1);
-}
-
-/*
- * Extract/implement a data field from/to a little endian report (bit array).
- *
- * Code sort-of follows HID spec:
- *     http://www.usb.org/developers/devclass_docs/HID1_11.pdf
- *
- * While the USB HID spec allows unlimited length bit fields in "report
- * descriptors", most devices never use more than 16 bits.
- * One model of UPS is claimed to report "LINEV" as a 32-bit field.
- * Search linux-kernel and linux-usb-devel archives for "hid-core extract".
- */
-
-static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n)
-{
-       u64 x;
-
-       WARN_ON(n > 32);
-
-       report += offset >> 3;  /* adjust byte index */
-       offset &= 7;            /* now only need bit offset into one byte */
-       x = get_unaligned((u64 *) report);
-       x = le64_to_cpu(x);
-       x = (x >> offset) & ((1ULL << n) - 1);  /* extract bit field */
-       return (u32) x;
-}
-
-/*
- * "implement" : set bits in a little endian bit stream.
- * Same concepts as "extract" (see comments above).
- * The data mangled in the bit stream remains in little endian
- * order the whole time. It make more sense to talk about
- * endianness of register values by considering a register
- * a "cached" copy of the little endiad bit stream.
- */
-static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value)
-{
-       u64 x;
-       u64 m = (1ULL << n) - 1;
-
-       WARN_ON(n > 32);
-
-       WARN_ON(value > m);
-       value &= m;
-
-       report += offset >> 3;
-       offset &= 7;
-
-       x = get_unaligned((u64 *)report);
-       x &= cpu_to_le64(~(m << offset));
-       x |= cpu_to_le64(((u64) value) << offset);
-       put_unaligned(x, (u64 *) report);
-}
-
-/*
- * Search an array for a value.
- */
-
-static __inline__ int search(__s32 *array, __s32 value, unsigned n)
-{
-       while (n--) {
-               if (*array++ == value)
-                       return 0;
-       }
-       return -1;
-}
-
-static void hid_process_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value, int interrupt)
-{
-       hid_dump_input(usage, value);
-       if (hid->claimed & HID_CLAIMED_INPUT)
-               hidinput_hid_event(hid, field, usage, value);
-       if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt)
-               hiddev_hid_event(hid, field, usage, value);
-}
-
-/*
- * Analyse a received field, and fetch the data from it. The field
- * content is stored for next report processing (we do differential
- * reporting to the layer).
- */
-
-static void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, int interrupt)
-{
-       unsigned n;
-       unsigned count = field->report_count;
-       unsigned offset = field->report_offset;
-       unsigned size = field->report_size;
-       __s32 min = field->logical_minimum;
-       __s32 max = field->logical_maximum;
-       __s32 *value;
-
-       if (!(value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC)))
-               return;
-
-       for (n = 0; n < count; n++) {
-
-                       value[n] = min < 0 ? snto32(extract(data, offset + n * size, size), size) :
-                                                   extract(data, offset + n * size, size);
-
-                       if (!(field->flags & HID_MAIN_ITEM_VARIABLE) /* Ignore report if ErrorRollOver */
-                           && value[n] >= min && value[n] <= max
-                           && field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1)
-                               goto exit;
-       }
-
-       for (n = 0; n < count; n++) {
-
-               if (HID_MAIN_ITEM_VARIABLE & field->flags) {
-                       hid_process_event(hid, field, &field->usage[n], value[n], interrupt);
-                       continue;
-               }
-
-               if (field->value[n] >= min && field->value[n] <= max
-                       && field->usage[field->value[n] - min].hid
-                       && search(value, field->value[n], count))
-                               hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt);
-
-               if (value[n] >= min && value[n] <= max
-                       && field->usage[value[n] - min].hid
-                       && search(field->value, value[n], count))
-                               hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt);
-       }
-
-       memcpy(field->value, value, count * sizeof(__s32));
-exit:
-       kfree(value);
-}
-
-static int hid_input_report(int type, struct urb *urb, int interrupt)
-{
-       struct hid_device *hid = urb->context;
-       struct hid_report_enum *report_enum = hid->report_enum + type;
-       u8 *data = urb->transfer_buffer;
-       int len = urb->actual_length;
-       struct hid_report *report;
-       int n, size;
-
-       if (!len) {
-               dbg("empty report");
-               return -1;
-       }
-
-#ifdef DEBUG_DATA
-       printk(KERN_DEBUG __FILE__ ": report (size %u) (%snumbered)\n", len, report_enum->numbered ? "" : "un");
-#endif
-
-       n = 0;                          /* Normally report number is 0 */
-       if (report_enum->numbered) {    /* Device uses numbered reports, data[0] is report number */
-               n = *data++;
-               len--;
-       }
-
-#ifdef DEBUG_DATA
-       {
-               int i;
-               printk(KERN_DEBUG __FILE__ ": report %d (size %u) = ", n, len);
-               for (i = 0; i < len; i++)
-                       printk(" %02x", data[i]);
-               printk("\n");
-       }
-#endif
-
-       if (!(report = report_enum->report_id_hash[n])) {
-               dbg("undefined report_id %d received", n);
-               return -1;
-       }
-
-       size = ((report->size - 1) >> 3) + 1;
-
-       if (len < size) {
-               dbg("report %d is too short, (%d < %d)", report->id, len, size);
-               memset(data + len, 0, size - len);
-       }
-
-       if (hid->claimed & HID_CLAIMED_HIDDEV)
-               hiddev_report_event(hid, report);
-
-       for (n = 0; n < report->maxfield; n++)
-               hid_input_field(hid, report->field[n], data, interrupt);
-
-       if (hid->claimed & HID_CLAIMED_INPUT)
-               hidinput_report_event(hid, report);
-
-       return 0;
-}
+static int usbhid_pb_fnmode = 1;
+module_param_named(pb_fnmode, usbhid_pb_fnmode, int, 0644);
+MODULE_PARM_DESC(pb_fnmode,
+               "Mode of fn key on PowerBooks (0 = disabled, 1 = fkeyslast, 2 = fkeysfirst)");
 
 /*
  * Input submission and I/O error handler.
@@ -946,15 +72,16 @@ static int hid_start_in(struct hid_device *hid)
 {
        unsigned long flags;
        int rc = 0;
+       struct usbhid_device *usbhid = hid->driver_data;
 
-       spin_lock_irqsave(&hid->inlock, flags);
-       if (hid->open > 0 && !test_bit(HID_SUSPENDED, &hid->iofl) &&
-                       !test_and_set_bit(HID_IN_RUNNING, &hid->iofl)) {
-               rc = usb_submit_urb(hid->urbin, GFP_ATOMIC);
+       spin_lock_irqsave(&usbhid->inlock, flags);
+       if (hid->open > 0 && !test_bit(HID_SUSPENDED, &usbhid->iofl) &&
+                       !test_and_set_bit(HID_IN_RUNNING, &usbhid->iofl)) {
+               rc = usb_submit_urb(usbhid->urbin, GFP_ATOMIC);
                if (rc != 0)
-                       clear_bit(HID_IN_RUNNING, &hid->iofl);
+                       clear_bit(HID_IN_RUNNING, &usbhid->iofl);
        }
-       spin_unlock_irqrestore(&hid->inlock, flags);
+       spin_unlock_irqrestore(&usbhid->inlock, flags);
        return rc;
 }
 
@@ -962,8 +89,9 @@ static int hid_start_in(struct hid_device *hid)
 static void hid_retry_timeout(unsigned long _hid)
 {
        struct hid_device *hid = (struct hid_device *) _hid;
+       struct usbhid_device *usbhid = hid->driver_data;
 
-       dev_dbg(&hid->intf->dev, "retrying intr urb\n");
+       dev_dbg(&usbhid->intf->dev, "retrying intr urb\n");
        if (hid_start_in(hid))
                hid_io_error(hid);
 }
@@ -971,38 +99,39 @@ static void hid_retry_timeout(unsigned long _hid)
 /* Workqueue routine to reset the device or clear a halt */
 static void hid_reset(struct work_struct *work)
 {
-       struct hid_device *hid =
-               container_of(work, struct hid_device, reset_work);
+       struct usbhid_device *usbhid =
+               container_of(work, struct usbhid_device, reset_work);
+       struct hid_device *hid = usbhid->hid;
        int rc_lock, rc = 0;
 
-       if (test_bit(HID_CLEAR_HALT, &hid->iofl)) {
-               dev_dbg(&hid->intf->dev, "clear halt\n");
-               rc = usb_clear_halt(hid->dev, hid->urbin->pipe);
-               clear_bit(HID_CLEAR_HALT, &hid->iofl);
+       if (test_bit(HID_CLEAR_HALT, &usbhid->iofl)) {
+               dev_dbg(&usbhid->intf->dev, "clear halt\n");
+               rc = usb_clear_halt(to_usb_device(hid->dev), usbhid->urbin->pipe);
+               clear_bit(HID_CLEAR_HALT, &usbhid->iofl);
                hid_start_in(hid);
        }
 
-       else if (test_bit(HID_RESET_PENDING, &hid->iofl)) {
-               dev_dbg(&hid->intf->dev, "resetting device\n");
-               rc = rc_lock = usb_lock_device_for_reset(hid->dev, hid->intf);
+       else if (test_bit(HID_RESET_PENDING, &usbhid->iofl)) {
+               dev_dbg(&usbhid->intf->dev, "resetting device\n");
+               rc = rc_lock = usb_lock_device_for_reset(to_usb_device(hid->dev), usbhid->intf);
                if (rc_lock >= 0) {
-                       rc = usb_reset_composite_device(hid->dev, hid->intf);
+                       rc = usb_reset_composite_device(to_usb_device(hid->dev), usbhid->intf);
                        if (rc_lock)
-                               usb_unlock_device(hid->dev);
+                               usb_unlock_device(to_usb_device(hid->dev));
                }
-               clear_bit(HID_RESET_PENDING, &hid->iofl);
+               clear_bit(HID_RESET_PENDING, &usbhid->iofl);
        }
 
        switch (rc) {
        case 0:
-               if (!test_bit(HID_IN_RUNNING, &hid->iofl))
+               if (!test_bit(HID_IN_RUNNING, &usbhid->iofl))
                        hid_io_error(hid);
                break;
        default:
                err("can't reset device, %s-%s/input%d, status %d",
-                               hid->dev->bus->bus_name,
-                               hid->dev->devpath,
-                               hid->ifnum, rc);
+                               to_usb_device(hid->dev)->bus->bus_name,
+                               to_usb_device(hid->dev)->devpath,
+                               usbhid->ifnum, rc);
                /* FALLTHROUGH */
        case -EHOSTUNREACH:
        case -ENODEV:
@@ -1015,33 +144,34 @@ static void hid_reset(struct work_struct *work)
 static void hid_io_error(struct hid_device *hid)
 {
        unsigned long flags;
+       struct usbhid_device *usbhid = hid->driver_data;
 
-       spin_lock_irqsave(&hid->inlock, flags);
+       spin_lock_irqsave(&usbhid->inlock, flags);
 
        /* Stop when disconnected */
-       if (usb_get_intfdata(hid->intf) == NULL)
+       if (usb_get_intfdata(usbhid->intf) == NULL)
                goto done;
 
        /* When an error occurs, retry at increasing intervals */
-       if (hid->retry_delay == 0) {
-               hid->retry_delay = 13;  /* Then 26, 52, 104, 104, ... */
-               hid->stop_retry = jiffies + msecs_to_jiffies(1000);
-       } else if (hid->retry_delay < 100)
-               hid->retry_delay *= 2;
+       if (usbhid->retry_delay == 0) {
+               usbhid->retry_delay = 13;       /* Then 26, 52, 104, 104, ... */
+               usbhid->stop_retry = jiffies + msecs_to_jiffies(1000);
+       } else if (usbhid->retry_delay < 100)
+               usbhid->retry_delay *= 2;
 
-       if (time_after(jiffies, hid->stop_retry)) {
+       if (time_after(jiffies, usbhid->stop_retry)) {
 
                /* Retries failed, so do a port reset */
-               if (!test_and_set_bit(HID_RESET_PENDING, &hid->iofl)) {
-                       schedule_work(&hid->reset_work);
+               if (!test_and_set_bit(HID_RESET_PENDING, &usbhid->iofl)) {
+                       schedule_work(&usbhid->reset_work);
                        goto done;
                }
        }
 
-       mod_timer(&hid->io_retry,
-                       jiffies + msecs_to_jiffies(hid->retry_delay));
+       mod_timer(&usbhid->io_retry,
+                       jiffies + msecs_to_jiffies(usbhid->retry_delay));
 done:
-       spin_unlock_irqrestore(&hid->inlock, flags);
+       spin_unlock_irqrestore(&usbhid->inlock, flags);
 }
 
 /*
@@ -1051,108 +181,50 @@ done:
 static void hid_irq_in(struct urb *urb)
 {
        struct hid_device       *hid = urb->context;
+       struct usbhid_device    *usbhid = hid->driver_data;
        int                     status;
 
        switch (urb->status) {
                case 0:                 /* success */
-                       hid->retry_delay = 0;
-                       hid_input_report(HID_INPUT_REPORT, urb, 1);
+                       usbhid->retry_delay = 0;
+                       hid_input_report(urb->context, HID_INPUT_REPORT,
+                                        urb->transfer_buffer,
+                                        urb->actual_length, 1);
                        break;
                case -EPIPE:            /* stall */
-                       clear_bit(HID_IN_RUNNING, &hid->iofl);
-                       set_bit(HID_CLEAR_HALT, &hid->iofl);
-                       schedule_work(&hid->reset_work);
+                       clear_bit(HID_IN_RUNNING, &usbhid->iofl);
+                       set_bit(HID_CLEAR_HALT, &usbhid->iofl);
+                       schedule_work(&usbhid->reset_work);
                        return;
                case -ECONNRESET:       /* unlink */
                case -ENOENT:
                case -ESHUTDOWN:        /* unplug */
-                       clear_bit(HID_IN_RUNNING, &hid->iofl);
+                       clear_bit(HID_IN_RUNNING, &usbhid->iofl);
                        return;
                case -EILSEQ:           /* protocol error or unplug */
                case -EPROTO:           /* protocol error or unplug */
                case -ETIME:            /* protocol error or unplug */
                case -ETIMEDOUT:        /* Should never happen, but... */
-                       clear_bit(HID_IN_RUNNING, &hid->iofl);
+                       clear_bit(HID_IN_RUNNING, &usbhid->iofl);
                        hid_io_error(hid);
                        return;
                default:                /* error */
                        warn("input irq status %d received", urb->status);
        }
 
-       status = usb_submit_urb(urb, SLAB_ATOMIC);
+       status = usb_submit_urb(urb, GFP_ATOMIC);
        if (status) {
-               clear_bit(HID_IN_RUNNING, &hid->iofl);
+               clear_bit(HID_IN_RUNNING, &usbhid->iofl);
                if (status != -EPERM) {
                        err("can't resubmit intr, %s-%s/input%d, status %d",
-                                       hid->dev->bus->bus_name,
-                                       hid->dev->devpath,
-                                       hid->ifnum, status);
+                                       to_usb_device(hid->dev)->bus->bus_name,
+                                       to_usb_device(hid->dev)->devpath,
+                                       usbhid->ifnum, status);
                        hid_io_error(hid);
                }
        }
 }
 
-/*
- * Output the field into the report.
- */
-
-static void hid_output_field(struct hid_field *field, __u8 *data)
-{
-       unsigned count = field->report_count;
-       unsigned offset = field->report_offset;
-       unsigned size = field->report_size;
-       unsigned n;
-
-       for (n = 0; n < count; n++) {
-               if (field->logical_minimum < 0) /* signed values */
-                       implement(data, offset + n * size, size, s32ton(field->value[n], size));
-               else                            /* unsigned values */
-                       implement(data, offset + n * size, size, field->value[n]);
-       }
-}
-
-/*
- * Create a report.
- */
-
-static void hid_output_report(struct hid_report *report, __u8 *data)
-{
-       unsigned n;
-
-       if (report->id > 0)
-               *data++ = report->id;
-
-       for (n = 0; n < report->maxfield; n++)
-               hid_output_field(report->field[n], data);
-}
-
-/*
- * Set a field value. The report this field belongs to has to be
- * created and transferred to the device, to set this value in the
- * device.
- */
-
-int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
-{
-       unsigned size = field->report_size;
-
-       hid_dump_input(field->usage + offset, value);
-
-       if (offset >= field->report_count) {
-               dbg("offset (%d) exceeds report_count (%d)", offset, field->report_count);
-               hid_dump_field(field, 8);
-               return -1;
-       }
-       if (field->logical_minimum < 0) {
-               if (value != snto32(s32ton(value, size), size)) {
-                       dbg("value %d is out of range", value);
-                       return -1;
-               }
-       }
-       field->value[offset] = value;
-       return 0;
-}
-
 /*
  * Find a report field with a specified HID usage.
  */
@@ -1173,16 +245,17 @@ struct hid_field *hid_find_field_by_usage(struct hid_device *hid, __u32 wanted_u
 static int hid_submit_out(struct hid_device *hid)
 {
        struct hid_report *report;
+       struct usbhid_device *usbhid = hid->driver_data;
 
-       report = hid->out[hid->outtail];
+       report = usbhid->out[usbhid->outtail];
 
-       hid_output_report(report, hid->outbuf);
-       hid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + 1 + (report->id > 0);
-       hid->urbout->dev = hid->dev;
+       hid_output_report(report, usbhid->outbuf);
+       usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + 1 + (report->id > 0);
+       usbhid->urbout->dev = to_usb_device(hid->dev);
 
        dbg("submitting out urb");
 
-       if (usb_submit_urb(hid->urbout, GFP_ATOMIC)) {
+       if (usb_submit_urb(usbhid->urbout, GFP_ATOMIC)) {
                err("usb_submit_urb(out) failed");
                return -1;
        }
@@ -1195,42 +268,43 @@ static int hid_submit_ctrl(struct hid_device *hid)
        struct hid_report *report;
        unsigned char dir;
        int len;
+       struct usbhid_device *usbhid = hid->driver_data;
 
-       report = hid->ctrl[hid->ctrltail].report;
-       dir = hid->ctrl[hid->ctrltail].dir;
+       report = usbhid->ctrl[usbhid->ctrltail].report;
+       dir = usbhid->ctrl[usbhid->ctrltail].dir;
 
        len = ((report->size - 1) >> 3) + 1 + (report->id > 0);
        if (dir == USB_DIR_OUT) {
-               hid_output_report(report, hid->ctrlbuf);
-               hid->urbctrl->pipe = usb_sndctrlpipe(hid->dev, 0);
-               hid->urbctrl->transfer_buffer_length = len;
+               hid_output_report(report, usbhid->ctrlbuf);
+               usbhid->urbctrl->pipe = usb_sndctrlpipe(to_usb_device(hid->dev), 0);
+               usbhid->urbctrl->transfer_buffer_length = len;
        } else {
                int maxpacket, padlen;
 
-               hid->urbctrl->pipe = usb_rcvctrlpipe(hid->dev, 0);
-               maxpacket = usb_maxpacket(hid->dev, hid->urbctrl->pipe, 0);
+               usbhid->urbctrl->pipe = usb_rcvctrlpipe(to_usb_device(hid->dev), 0);
+               maxpacket = usb_maxpacket(to_usb_device(hid->dev), usbhid->urbctrl->pipe, 0);
                if (maxpacket > 0) {
                        padlen = (len + maxpacket - 1) / maxpacket;
                        padlen *= maxpacket;
-                       if (padlen > hid->bufsize)
-                               padlen = hid->bufsize;
+                       if (padlen > usbhid->bufsize)
+                               padlen = usbhid->bufsize;
                } else
                        padlen = 0;
-               hid->urbctrl->transfer_buffer_length = padlen;
+               usbhid->urbctrl->transfer_buffer_length = padlen;
        }
-       hid->urbctrl->dev = hid->dev;
+       usbhid->urbctrl->dev = to_usb_device(hid->dev);
 
-       hid->cr->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE | dir;
-       hid->cr->bRequest = (dir == USB_DIR_OUT) ? HID_REQ_SET_REPORT : HID_REQ_GET_REPORT;
-       hid->cr->wValue = cpu_to_le16(((report->type + 1) << 8) | report->id);
-       hid->cr->wIndex = cpu_to_le16(hid->ifnum);
-       hid->cr->wLength = cpu_to_le16(len);
+       usbhid->cr->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE | dir;
+       usbhid->cr->bRequest = (dir == USB_DIR_OUT) ? HID_REQ_SET_REPORT : HID_REQ_GET_REPORT;
+       usbhid->cr->wValue = cpu_to_le16(((report->type + 1) << 8) | report->id);
+       usbhid->cr->wIndex = cpu_to_le16(usbhid->ifnum);
+       usbhid->cr->wLength = cpu_to_le16(len);
 
        dbg("submitting ctrl urb: %s wValue=0x%04x wIndex=0x%04x wLength=%u",
-               hid->cr->bRequest == HID_REQ_SET_REPORT ? "Set_Report" : "Get_Report",
-               hid->cr->wValue, hid->cr->wIndex, hid->cr->wLength);
+               usbhid->cr->bRequest == HID_REQ_SET_REPORT ? "Set_Report" : "Get_Report",
+               usbhid->cr->wValue, usbhid->cr->wIndex, usbhid->cr->wLength);
 
-       if (usb_submit_urb(hid->urbctrl, GFP_ATOMIC)) {
+       if (usb_submit_urb(usbhid->urbctrl, GFP_ATOMIC)) {
                err("usb_submit_urb(ctrl) failed");
                return -1;
        }
@@ -1245,6 +319,7 @@ static int hid_submit_ctrl(struct hid_device *hid)
 static void hid_irq_out(struct urb *urb)
 {
        struct hid_device *hid = urb->context;
+       struct usbhid_device *usbhid = hid->driver_data;
        unsigned long flags;
        int unplug = 0;
 
@@ -1262,24 +337,24 @@ static void hid_irq_out(struct urb *urb)
                        warn("output irq status %d received", urb->status);
        }
 
-       spin_lock_irqsave(&hid->outlock, flags);
+       spin_lock_irqsave(&usbhid->outlock, flags);
 
        if (unplug)
-               hid->outtail = hid->outhead;
+               usbhid->outtail = usbhid->outhead;
        else
-               hid->outtail = (hid->outtail + 1) & (HID_OUTPUT_FIFO_SIZE - 1);
+               usbhid->outtail = (usbhid->outtail + 1) & (HID_OUTPUT_FIFO_SIZE - 1);
 
-       if (hid->outhead != hid->outtail) {
+       if (usbhid->outhead != usbhid->outtail) {
                if (hid_submit_out(hid)) {
-                       clear_bit(HID_OUT_RUNNING, &hid->iofl);
+                       clear_bit(HID_OUT_RUNNING, &usbhid->iofl);
                        wake_up(&hid->wait);
                }
-               spin_unlock_irqrestore(&hid->outlock, flags);
+               spin_unlock_irqrestore(&usbhid->outlock, flags);
                return;
        }
 
-       clear_bit(HID_OUT_RUNNING, &hid->iofl);
-       spin_unlock_irqrestore(&hid->outlock, flags);
+       clear_bit(HID_OUT_RUNNING, &usbhid->iofl);
+       spin_unlock_irqrestore(&usbhid->outlock, flags);
        wake_up(&hid->wait);
 }
 
@@ -1290,15 +365,17 @@ static void hid_irq_out(struct urb *urb)
 static void hid_ctrl(struct urb *urb)
 {
        struct hid_device *hid = urb->context;
+       struct usbhid_device *usbhid = hid->driver_data;
        unsigned long flags;
        int unplug = 0;
 
-       spin_lock_irqsave(&hid->ctrllock, flags);
+       spin_lock_irqsave(&usbhid->ctrllock, flags);
 
        switch (urb->status) {
                case 0:                 /* success */
-                       if (hid->ctrl[hid->ctrltail].dir == USB_DIR_IN)
-                               hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, 0);
+                       if (usbhid->ctrl[usbhid->ctrltail].dir == USB_DIR_IN)
+                               hid_input_report(urb->context, usbhid->ctrl[usbhid->ctrltail].report->type,
+                                               urb->transfer_buffer, urb->actual_length, 0);
                        break;
                case -ESHUTDOWN:        /* unplug */
                        unplug = 1;
@@ -1313,76 +390,102 @@ static void hid_ctrl(struct urb *urb)
        }
 
        if (unplug)
-               hid->ctrltail = hid->ctrlhead;
+               usbhid->ctrltail = usbhid->ctrlhead;
        else
-               hid->ctrltail = (hid->ctrltail + 1) & (HID_CONTROL_FIFO_SIZE - 1);
+               usbhid->ctrltail = (usbhid->ctrltail + 1) & (HID_CONTROL_FIFO_SIZE - 1);
 
-       if (hid->ctrlhead != hid->ctrltail) {
+       if (usbhid->ctrlhead != usbhid->ctrltail) {
                if (hid_submit_ctrl(hid)) {
-                       clear_bit(HID_CTRL_RUNNING, &hid->iofl);
+                       clear_bit(HID_CTRL_RUNNING, &usbhid->iofl);
                        wake_up(&hid->wait);
                }
-               spin_unlock_irqrestore(&hid->ctrllock, flags);
+               spin_unlock_irqrestore(&usbhid->ctrllock, flags);
                return;
        }
 
-       clear_bit(HID_CTRL_RUNNING, &hid->iofl);
-       spin_unlock_irqrestore(&hid->ctrllock, flags);
+       clear_bit(HID_CTRL_RUNNING, &usbhid->iofl);
+       spin_unlock_irqrestore(&usbhid->ctrllock, flags);
        wake_up(&hid->wait);
 }
 
-void hid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir)
+void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir)
 {
        int head;
        unsigned long flags;
+       struct usbhid_device *usbhid = hid->driver_data;
 
        if ((hid->quirks & HID_QUIRK_NOGET) && dir == USB_DIR_IN)
                return;
 
-       if (hid->urbout && dir == USB_DIR_OUT && report->type == HID_OUTPUT_REPORT) {
+       if (usbhid->urbout && dir == USB_DIR_OUT && report->type == HID_OUTPUT_REPORT) {
 
-               spin_lock_irqsave(&hid->outlock, flags);
+               spin_lock_irqsave(&usbhid->outlock, flags);
 
-               if ((head = (hid->outhead + 1) & (HID_OUTPUT_FIFO_SIZE - 1)) == hid->outtail) {
-                       spin_unlock_irqrestore(&hid->outlock, flags);
+               if ((head = (usbhid->outhead + 1) & (HID_OUTPUT_FIFO_SIZE - 1)) == usbhid->outtail) {
+                       spin_unlock_irqrestore(&usbhid->outlock, flags);
                        warn("output queue full");
                        return;
                }
 
-               hid->out[hid->outhead] = report;
-               hid->outhead = head;
+               usbhid->out[usbhid->outhead] = report;
+               usbhid->outhead = head;
 
-               if (!test_and_set_bit(HID_OUT_RUNNING, &hid->iofl))
+               if (!test_and_set_bit(HID_OUT_RUNNING, &usbhid->iofl))
                        if (hid_submit_out(hid))
-                               clear_bit(HID_OUT_RUNNING, &hid->iofl);
+                               clear_bit(HID_OUT_RUNNING, &usbhid->iofl);
 
-               spin_unlock_irqrestore(&hid->outlock, flags);
+               spin_unlock_irqrestore(&usbhid->outlock, flags);
                return;
        }
 
-       spin_lock_irqsave(&hid->ctrllock, flags);
+       spin_lock_irqsave(&usbhid->ctrllock, flags);
 
-       if ((head = (hid->ctrlhead + 1) & (HID_CONTROL_FIFO_SIZE - 1)) == hid->ctrltail) {
-               spin_unlock_irqrestore(&hid->ctrllock, flags);
+       if ((head = (usbhid->ctrlhead + 1) & (HID_CONTROL_FIFO_SIZE - 1)) == usbhid->ctrltail) {
+               spin_unlock_irqrestore(&usbhid->ctrllock, flags);
                warn("control queue full");
                return;
        }
 
-       hid->ctrl[hid->ctrlhead].report = report;
-       hid->ctrl[hid->ctrlhead].dir = dir;
-       hid->ctrlhead = head;
+       usbhid->ctrl[usbhid->ctrlhead].report = report;
+       usbhid->ctrl[usbhid->ctrlhead].dir = dir;
+       usbhid->ctrlhead = head;
 
-       if (!test_and_set_bit(HID_CTRL_RUNNING, &hid->iofl))
+       if (!test_and_set_bit(HID_CTRL_RUNNING, &usbhid->iofl))
                if (hid_submit_ctrl(hid))
-                       clear_bit(HID_CTRL_RUNNING, &hid->iofl);
+                       clear_bit(HID_CTRL_RUNNING, &usbhid->iofl);
+
+       spin_unlock_irqrestore(&usbhid->ctrllock, flags);
+}
+
+static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
+{
+       struct hid_device *hid = dev->private;
+       struct hid_field *field;
+       int offset;
+
+       if (type == EV_FF)
+               return input_ff_event(dev, type, code, value);
+
+       if (type != EV_LED)
+               return -1;
+
+       if ((offset = hidinput_find_field(hid, type, code, &field)) == -1) {
+               warn("event field not found");
+               return -1;
+       }
+
+       hid_set_field(field, offset, value);
+       usbhid_submit_report(hid, field->report, USB_DIR_OUT);
 
-       spin_unlock_irqrestore(&hid->ctrllock, flags);
+       return 0;
 }
 
-int hid_wait_io(struct hid_device *hid)
+int usbhid_wait_io(struct hid_device *hid)
 {
-       if (!wait_event_timeout(hid->wait, (!test_bit(HID_CTRL_RUNNING, &hid->iofl) &&
-                                       !test_bit(HID_OUT_RUNNING, &hid->iofl)),
+       struct usbhid_device *usbhid = hid->driver_data;
+
+       if (!wait_event_timeout(hid->wait, (!test_bit(HID_CTRL_RUNNING, &usbhid->iofl) &&
+                                       !test_bit(HID_OUT_RUNNING, &usbhid->iofl)),
                                        10*HZ)) {
                dbg("timeout waiting for ctrl or out queue to clear");
                return -1;
@@ -1414,7 +517,7 @@ static int hid_get_class_descriptor(struct usb_device *dev, int ifnum,
        return result;
 }
 
-int hid_open(struct hid_device *hid)
+int usbhid_open(struct hid_device *hid)
 {
        ++hid->open;
        if (hid_start_in(hid))
@@ -1422,10 +525,24 @@ int hid_open(struct hid_device *hid)
        return 0;
 }
 
-void hid_close(struct hid_device *hid)
+void usbhid_close(struct hid_device *hid)
 {
+       struct usbhid_device *usbhid = hid->driver_data;
+
        if (!--hid->open)
-               usb_kill_urb(hid->urbin);
+               usb_kill_urb(usbhid->urbin);
+}
+
+static int hidinput_open(struct input_dev *dev)
+{
+       struct hid_device *hid = dev->private;
+       return usbhid_open(hid);
+}
+
+static void hidinput_close(struct input_dev *dev)
+{
+       struct hid_device *hid = dev->private;
+       usbhid_close(hid);
 }
 
 #define USB_VENDOR_ID_PANJIT           0x134c
@@ -1437,26 +554,27 @@ void hid_close(struct hid_device *hid)
  * Initialize all reports
  */
 
-void hid_init_reports(struct hid_device *hid)
+void usbhid_init_reports(struct hid_device *hid)
 {
        struct hid_report *report;
+       struct usbhid_device *usbhid = hid->driver_data;
        int err, ret;
 
        list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list)
-               hid_submit_report(hid, report, USB_DIR_IN);
+               usbhid_submit_report(hid, report, USB_DIR_IN);
 
        list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list)
-               hid_submit_report(hid, report, USB_DIR_IN);
+               usbhid_submit_report(hid, report, USB_DIR_IN);
 
        err = 0;
-       ret = hid_wait_io(hid);
+       ret = usbhid_wait_io(hid);
        while (ret) {
                err |= ret;
-               if (test_bit(HID_CTRL_RUNNING, &hid->iofl))
-                       usb_kill_urb(hid->urbctrl);
-               if (test_bit(HID_OUT_RUNNING, &hid->iofl))
-                       usb_kill_urb(hid->urbout);
-               ret = hid_wait_io(hid);
+               if (test_bit(HID_CTRL_RUNNING, &usbhid->iofl))
+                       usb_kill_urb(usbhid->urbctrl);
+               if (test_bit(HID_OUT_RUNNING, &usbhid->iofl))
+                       usb_kill_urb(usbhid->urbout);
+               ret = usbhid_wait_io(hid);
        }
 
        if (err)
@@ -1670,6 +788,9 @@ void hid_init_reports(struct hid_device *hid)
 #define USB_VENDOR_ID_AIRCABLE         0x16CA
 #define USB_DEVICE_ID_AIRCABLE1                0x1502
 
+#define USB_VENDOR_ID_LOGITECH         0x046d
+#define USB_DEVICE_ID_LOGITECH_USB_RECEIVER    0xc101
+
 /*
  * Alphabetically sorted blacklist by quirk type.
  */
@@ -1841,7 +962,9 @@ static const struct hid_blacklist {
        { USB_VENDOR_ID_PANJIT, 0x0004, HID_QUIRK_IGNORE },
 
        { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET },
-       
+
+       { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_USB_RECEIVER, HID_QUIRK_BAD_RELATIVE_KEYS },
+
        { 0, 0 }
 };
 
@@ -1864,13 +987,15 @@ static void hid_find_max_report(struct hid_device *hid, unsigned int type, int *
 
 static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid)
 {
-       if (!(hid->inbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->inbuf_dma)))
+       struct usbhid_device *usbhid = hid->driver_data;
+
+       if (!(usbhid->inbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_ATOMIC, &usbhid->inbuf_dma)))
                return -1;
-       if (!(hid->outbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->outbuf_dma)))
+       if (!(usbhid->outbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_ATOMIC, &usbhid->outbuf_dma)))
                return -1;
-       if (!(hid->cr = usb_buffer_alloc(dev, sizeof(*(hid->cr)), SLAB_ATOMIC, &hid->cr_dma)))
+       if (!(usbhid->cr = usb_buffer_alloc(dev, sizeof(*(usbhid->cr)), GFP_ATOMIC, &usbhid->cr_dma)))
                return -1;
-       if (!(hid->ctrlbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->ctrlbuf_dma)))
+       if (!(usbhid->ctrlbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_ATOMIC, &usbhid->ctrlbuf_dma)))
                return -1;
 
        return 0;
@@ -1878,14 +1003,16 @@ static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid)
 
 static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid)
 {
-       if (hid->inbuf)
-               usb_buffer_free(dev, hid->bufsize, hid->inbuf, hid->inbuf_dma);
-       if (hid->outbuf)
-               usb_buffer_free(dev, hid->bufsize, hid->outbuf, hid->outbuf_dma);
-       if (hid->cr)
-               usb_buffer_free(dev, sizeof(*(hid->cr)), hid->cr, hid->cr_dma);
-       if (hid->ctrlbuf)
-               usb_buffer_free(dev, hid->bufsize, hid->ctrlbuf, hid->ctrlbuf_dma);
+       struct usbhid_device *usbhid = hid->driver_data;
+
+       if (usbhid->inbuf)
+               usb_buffer_free(dev, usbhid->bufsize, usbhid->inbuf, usbhid->inbuf_dma);
+       if (usbhid->outbuf)
+               usb_buffer_free(dev, usbhid->bufsize, usbhid->outbuf, usbhid->outbuf_dma);
+       if (usbhid->cr)
+               usb_buffer_free(dev, sizeof(*(usbhid->cr)), usbhid->cr, usbhid->cr_dma);
+       if (usbhid->ctrlbuf)
+               usb_buffer_free(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma);
 }
 
 /*
@@ -1911,6 +1038,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
        unsigned quirks = 0, rsize = 0;
        char *rdesc;
        int n, len, insize = 0;
+       struct usbhid_device *usbhid;
 
         /* Ignore all Wacom devices */
         if (le16_to_cpu(dev->descriptor.idVendor) == USB_VENDOR_ID_WACOM)
@@ -1980,13 +1108,19 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
        kfree(rdesc);
        hid->quirks = quirks;
 
-       hid->bufsize = HID_MIN_BUFFER_SIZE;
-       hid_find_max_report(hid, HID_INPUT_REPORT, &hid->bufsize);
-       hid_find_max_report(hid, HID_OUTPUT_REPORT, &hid->bufsize);
-       hid_find_max_report(hid, HID_FEATURE_REPORT, &hid->bufsize);
+       if (!(usbhid = kzalloc(sizeof(struct usbhid_device), GFP_KERNEL)))
+               goto fail;
+
+       hid->driver_data = usbhid;
+       usbhid->hid = hid;
 
-       if (hid->bufsize > HID_MAX_BUFFER_SIZE)
-               hid->bufsize = HID_MAX_BUFFER_SIZE;
+       usbhid->bufsize = HID_MIN_BUFFER_SIZE;
+       hid_find_max_report(hid, HID_INPUT_REPORT, &usbhid->bufsize);
+       hid_find_max_report(hid, HID_OUTPUT_REPORT, &usbhid->bufsize);
+       hid_find_max_report(hid, HID_FEATURE_REPORT, &usbhid->bufsize);
+
+       if (usbhid->bufsize > HID_MAX_BUFFER_SIZE)
+               usbhid->bufsize = HID_MAX_BUFFER_SIZE;
 
        hid_find_max_report(hid, HID_INPUT_REPORT, &insize);
 
@@ -2015,47 +1149,47 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
                        interval = hid_mousepoll_interval;
 
                if (usb_endpoint_dir_in(endpoint)) {
-                       if (hid->urbin)
+                       if (usbhid->urbin)
                                continue;
-                       if (!(hid->urbin = usb_alloc_urb(0, GFP_KERNEL)))
+                       if (!(usbhid->urbin = usb_alloc_urb(0, GFP_KERNEL)))
                                goto fail;
                        pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
-                       usb_fill_int_urb(hid->urbin, dev, pipe, hid->inbuf, insize,
+                       usb_fill_int_urb(usbhid->urbin, dev, pipe, usbhid->inbuf, insize,
                                         hid_irq_in, hid, interval);
-                       hid->urbin->transfer_dma = hid->inbuf_dma;
-                       hid->urbin->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+                       usbhid->urbin->transfer_dma = usbhid->inbuf_dma;
+                       usbhid->urbin->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
                } else {
-                       if (hid->urbout)
+                       if (usbhid->urbout)
                                continue;
-                       if (!(hid->urbout = usb_alloc_urb(0, GFP_KERNEL)))
+                       if (!(usbhid->urbout = usb_alloc_urb(0, GFP_KERNEL)))
                                goto fail;
                        pipe = usb_sndintpipe(dev, endpoint->bEndpointAddress);
-                       usb_fill_int_urb(hid->urbout, dev, pipe, hid->outbuf, 0,
+                       usb_fill_int_urb(usbhid->urbout, dev, pipe, usbhid->outbuf, 0,
                                         hid_irq_out, hid, interval);
-                       hid->urbout->transfer_dma = hid->outbuf_dma;
-                       hid->urbout->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+                       usbhid->urbout->transfer_dma = usbhid->outbuf_dma;
+                       usbhid->urbout->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
                }
        }
 
-       if (!hid->urbin) {
+       if (!usbhid->urbin) {
                err("couldn't find an input interrupt endpoint");
                goto fail;
        }
 
        init_waitqueue_head(&hid->wait);
 
-       INIT_WORK(&hid->reset_work, hid_reset);
-       setup_timer(&hid->io_retry, hid_retry_timeout, (unsigned long) hid);
+       INIT_WORK(&usbhid->reset_work, hid_reset);
+       setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid);
 
-       spin_lock_init(&hid->inlock);
-       spin_lock_init(&hid->outlock);
-       spin_lock_init(&hid->ctrllock);
+       spin_lock_init(&usbhid->inlock);
+       spin_lock_init(&usbhid->outlock);
+       spin_lock_init(&usbhid->ctrllock);
 
        hid->version = le16_to_cpu(hdesc->bcdHID);
        hid->country = hdesc->bCountryCode;
-       hid->dev = dev;
-       hid->intf = intf;
-       hid->ifnum = interface->desc.bInterfaceNumber;
+       hid->dev = &dev->dev;
+       usbhid->intf = intf;
+       usbhid->ifnum = interface->desc.bInterfaceNumber;
 
        hid->name[0] = 0;
 
@@ -2073,6 +1207,10 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
                         le16_to_cpu(dev->descriptor.idVendor),
                         le16_to_cpu(dev->descriptor.idProduct));
 
+       hid->bus = BUS_USB;
+       hid->vendor = dev->descriptor.idVendor;
+       hid->product = dev->descriptor.idProduct;
+
        usb_make_path(dev, hid->phys, sizeof(hid->phys));
        strlcat(hid->phys, "/input", sizeof(hid->phys));
        len = strlen(hid->phys);
@@ -2083,22 +1221,32 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
        if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0)
                hid->uniq[0] = 0;
 
-       hid->urbctrl = usb_alloc_urb(0, GFP_KERNEL);
-       if (!hid->urbctrl)
+       usbhid->urbctrl = usb_alloc_urb(0, GFP_KERNEL);
+       if (!usbhid->urbctrl)
                goto fail;
 
-       usb_fill_control_urb(hid->urbctrl, dev, 0, (void *) hid->cr,
-                            hid->ctrlbuf, 1, hid_ctrl, hid);
-       hid->urbctrl->setup_dma = hid->cr_dma;
-       hid->urbctrl->transfer_dma = hid->ctrlbuf_dma;
-       hid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP);
+       usb_fill_control_urb(usbhid->urbctrl, dev, 0, (void *) usbhid->cr,
+                            usbhid->ctrlbuf, 1, hid_ctrl, hid);
+       usbhid->urbctrl->setup_dma = usbhid->cr_dma;
+       usbhid->urbctrl->transfer_dma = usbhid->ctrlbuf_dma;
+       usbhid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP);
+       hid->hidinput_input_event = usb_hidinput_input_event;
+       hid->hidinput_open = hidinput_open;
+       hid->hidinput_close = hidinput_close;
+#ifdef CONFIG_USB_HIDDEV
+       hid->hiddev_hid_event = hiddev_hid_event;
+       hid->hiddev_report_event = hiddev_report_event;
+#endif
+#ifdef CONFIG_USB_HIDINPUT_POWERBOOK
+       hid->pb_fnmode = usbhid_pb_fnmode;
+#endif
 
        return hid;
 
 fail:
-       usb_free_urb(hid->urbin);
-       usb_free_urb(hid->urbout);
-       usb_free_urb(hid->urbctrl);
+       usb_free_urb(usbhid->urbin);
+       usb_free_urb(usbhid->urbout);
+       usb_free_urb(usbhid->urbctrl);
        hid_free_buffers(dev, hid);
        hid_free_device(hid);
 
@@ -2108,18 +1256,21 @@ fail:
 static void hid_disconnect(struct usb_interface *intf)
 {
        struct hid_device *hid = usb_get_intfdata (intf);
+       struct usbhid_device *usbhid;
 
        if (!hid)
                return;
 
-       spin_lock_irq(&hid->inlock);    /* Sync with error handler */
+       usbhid = hid->driver_data;
+
+       spin_lock_irq(&usbhid->inlock); /* Sync with error handler */
        usb_set_intfdata(intf, NULL);
-       spin_unlock_irq(&hid->inlock);
-       usb_kill_urb(hid->urbin);
-       usb_kill_urb(hid->urbout);
-       usb_kill_urb(hid->urbctrl);
+       spin_unlock_irq(&usbhid->inlock);
+       usb_kill_urb(usbhid->urbin);
+       usb_kill_urb(usbhid->urbout);
+       usb_kill_urb(usbhid->urbctrl);
 
-       del_timer_sync(&hid->io_retry);
+       del_timer_sync(&usbhid->io_retry);
        flush_scheduled_work();
 
        if (hid->claimed & HID_CLAIMED_INPUT)
@@ -2127,11 +1278,11 @@ static void hid_disconnect(struct usb_interface *intf)
        if (hid->claimed & HID_CLAIMED_HIDDEV)
                hiddev_disconnect(hid);
 
-       usb_free_urb(hid->urbin);
-       usb_free_urb(hid->urbctrl);
-       usb_free_urb(hid->urbout);
+       usb_free_urb(usbhid->urbin);
+       usb_free_urb(usbhid->urbctrl);
+       usb_free_urb(usbhid->urbout);
 
-       hid_free_buffers(hid->dev, hid);
+       hid_free_buffers(to_usb_device(hid->dev), hid);
        hid_free_device(hid);
 }
 
@@ -2148,7 +1299,7 @@ static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id)
        if (!(hid = usb_hid_configure(intf)))
                return -ENODEV;
 
-       hid_init_reports(hid);
+       usbhid_init_reports(hid);
        hid_dump_device(hid);
 
        if (!hidinput_connect(hid))
@@ -2164,6 +1315,13 @@ static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id)
                return -ENODEV;
        }
 
+       /* This only gets called when we are a single-input (most of the
+        * time). IOW, not a HID_QUIRK_MULTI_INPUT. The hid_ff_init() is
+        * only useful in this case, and not for multi-input quirks. */
+       if ((hid->claimed & HID_CLAIMED_INPUT) &&
+                       !(hid->quirks & HID_QUIRK_MULTI_INPUT))
+               hid_ff_init(hid);
+
        printk(KERN_INFO);
 
        if (hid->claimed & HID_CLAIMED_INPUT)
@@ -2194,12 +1352,13 @@ static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id)
 static int hid_suspend(struct usb_interface *intf, pm_message_t message)
 {
        struct hid_device *hid = usb_get_intfdata (intf);
+       struct usbhid_device *usbhid = hid->driver_data;
 
-       spin_lock_irq(&hid->inlock);    /* Sync with error handler */
-       set_bit(HID_SUSPENDED, &hid->iofl);
-       spin_unlock_irq(&hid->inlock);
-       del_timer(&hid->io_retry);
-       usb_kill_urb(hid->urbin);
+       spin_lock_irq(&usbhid->inlock); /* Sync with error handler */
+       set_bit(HID_SUSPENDED, &usbhid->iofl);
+       spin_unlock_irq(&usbhid->inlock);
+       del_timer(&usbhid->io_retry);
+       usb_kill_urb(usbhid->urbin);
        dev_dbg(&intf->dev, "suspend\n");
        return 0;
 }
@@ -2207,10 +1366,11 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
 static int hid_resume(struct usb_interface *intf)
 {
        struct hid_device *hid = usb_get_intfdata (intf);
+       struct usbhid_device *usbhid = hid->driver_data;
        int status;
 
-       clear_bit(HID_SUSPENDED, &hid->iofl);
-       hid->retry_delay = 0;
+       clear_bit(HID_SUSPENDED, &usbhid->iofl);
+       usbhid->retry_delay = 0;
        status = hid_start_in(hid);
        dev_dbg(&intf->dev, "resume status %d\n", status);
        return status;
index a8fc46c721c50cf0a1a8485d50da96c800b3f5fe..f8f660ee3fac0a581207b7327611c6100d8daf7c 100644 (file)
@@ -32,7 +32,7 @@
 #undef DEBUG
 #include <linux/usb.h>
 
-#include "hid.h"
+#include <linux/hid.h>
 
 /*
  * This table contains pointers to initializers. To add support for new
@@ -70,8 +70,8 @@ static struct hid_ff_initializer inits[] = {
 int hid_ff_init(struct hid_device* hid)
 {
        struct hid_ff_initializer *init;
-       int vendor = le16_to_cpu(hid->dev->descriptor.idVendor);
-       int product = le16_to_cpu(hid->dev->descriptor.idProduct);
+       int vendor = le16_to_cpu(to_usb_device(hid->dev)->descriptor.idVendor);
+       int product = le16_to_cpu(to_usb_device(hid->dev)->descriptor.idProduct);
 
        for (init = inits; init->idVendor; init++)
                if (init->idVendor == vendor && init->idProduct == product)
@@ -79,3 +79,5 @@ int hid_ff_init(struct hid_device* hid)
 
        return init->init(hid);
 }
+EXPORT_SYMBOL_GPL(hid_ff_init);
+
index 93da222b6da8ffce8ab4d11762ab562e2d4fc2d1..e47466268565668d10285c3948f5acbc3b49a3ba 100644 (file)
@@ -29,7 +29,8 @@
 
 #include <linux/input.h>
 #include <linux/usb.h>
-#include "hid.h"
+#include <linux/hid.h>
+#include "usbhid.h"
 
 struct device_type {
        u16 idVendor;
@@ -75,7 +76,7 @@ static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *ef
                report->field[0]->value[2] = x;
                report->field[0]->value[3] = y;
                dbg("(x, y)=(%04x, %04x)", x, y);
-               hid_submit_report(hid, report, USB_DIR_OUT);
+               usbhid_submit_report(hid, report, USB_DIR_OUT);
                break;
 
        case FF_RUMBLE:
@@ -90,7 +91,7 @@ static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *ef
                report->field[0]->value[2] = left;
                report->field[0]->value[3] = right;
                dbg("(left, right)=(%04x, %04x)", left, right);
-               hid_submit_report(hid, report, USB_DIR_OUT);
+               usbhid_submit_report(hid, report, USB_DIR_OUT);
                break;
        }
        return 0;
index 5420c13eb8eb27c1ff9eeb5adeab88b543fc9828..cbd2d53fefff532223f7f3a00139f0ce09162b76 100644 (file)
@@ -28,7 +28,9 @@
 #include <linux/input.h>
 #include <linux/usb.h>
 
-#include "hid.h"
+#include <linux/hid.h>
+
+#include "usbhid.h"
 
 #define        PID_EFFECTS_MAX         64
 
@@ -260,7 +262,7 @@ static void pidff_set_envelope_report(struct pidff_device *pidff,
        debug("attack %u => %d", envelope->attack_level,
              pidff->set_envelope[PID_ATTACK_LEVEL].value[0]);
 
-       hid_submit_report(pidff->hid, pidff->reports[PID_SET_ENVELOPE],
+       usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_ENVELOPE],
                          USB_DIR_OUT);
 }
 
@@ -287,7 +289,7 @@ static void pidff_set_constant_force_report(struct pidff_device *pidff,
        pidff_set_signed(&pidff->set_constant[PID_MAGNITUDE],
                         effect->u.constant.level);
 
-       hid_submit_report(pidff->hid, pidff->reports[PID_SET_CONSTANT],
+       usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_CONSTANT],
                          USB_DIR_OUT);
 }
 
@@ -322,7 +324,7 @@ static void pidff_set_effect_report(struct pidff_device *pidff,
                                pidff->effect_direction);
        pidff->set_effect[PID_START_DELAY].value[0] = effect->replay.delay;
 
-       hid_submit_report(pidff->hid, pidff->reports[PID_SET_EFFECT],
+       usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_EFFECT],
                          USB_DIR_OUT);
 }
 
@@ -354,7 +356,7 @@ static void pidff_set_periodic_report(struct pidff_device *pidff,
        pidff_set(&pidff->set_periodic[PID_PHASE], effect->u.periodic.phase);
        pidff->set_periodic[PID_PERIOD].value[0] = effect->u.periodic.period;
 
-       hid_submit_report(pidff->hid, pidff->reports[PID_SET_PERIODIC],
+       usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_PERIODIC],
                          USB_DIR_OUT);
 
 }
@@ -396,8 +398,8 @@ static void pidff_set_condition_report(struct pidff_device *pidff,
                          effect->u.condition[i].left_saturation);
                pidff_set(&pidff->set_condition[PID_DEAD_BAND],
                          effect->u.condition[i].deadband);
-               hid_wait_io(pidff->hid);
-               hid_submit_report(pidff->hid, pidff->reports[PID_SET_CONDITION],
+               usbhid_wait_io(pidff->hid);
+               usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_CONDITION],
                                  USB_DIR_OUT);
        }
 }
@@ -438,7 +440,7 @@ static void pidff_set_ramp_force_report(struct pidff_device *pidff,
                         effect->u.ramp.start_level);
        pidff_set_signed(&pidff->set_ramp[PID_RAMP_END],
                         effect->u.ramp.end_level);
-       hid_submit_report(pidff->hid, pidff->reports[PID_SET_RAMP],
+       usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_RAMP],
                          USB_DIR_OUT);
 }
 
@@ -463,19 +465,19 @@ static int pidff_request_effect_upload(struct pidff_device *pidff, int efnum)
        int j;
 
        pidff->create_new_effect_type->value[0] = efnum;
-       hid_submit_report(pidff->hid, pidff->reports[PID_CREATE_NEW_EFFECT],
+       usbhid_submit_report(pidff->hid, pidff->reports[PID_CREATE_NEW_EFFECT],
                          USB_DIR_OUT);
        debug("create_new_effect sent, type: %d", efnum);
 
        pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0] = 0;
        pidff->block_load_status->value[0] = 0;
-       hid_wait_io(pidff->hid);
+       usbhid_wait_io(pidff->hid);
 
        for (j = 0; j < 60; j++) {
                debug("pid_block_load requested");
-               hid_submit_report(pidff->hid, pidff->reports[PID_BLOCK_LOAD],
+               usbhid_submit_report(pidff->hid, pidff->reports[PID_BLOCK_LOAD],
                                  USB_DIR_IN);
-               hid_wait_io(pidff->hid);
+               usbhid_wait_io(pidff->hid);
                if (pidff->block_load_status->value[0] ==
                    pidff->status_id[PID_BLOCK_LOAD_SUCCESS]) {
                        debug("device reported free memory: %d bytes",
@@ -511,8 +513,8 @@ static void pidff_playback_pid(struct pidff_device *pidff, int pid_id, int n)
                pidff->effect_operation[PID_LOOP_COUNT].value[0] = n;
        }
 
-       hid_wait_io(pidff->hid);
-       hid_submit_report(pidff->hid, pidff->reports[PID_EFFECT_OPERATION],
+       usbhid_wait_io(pidff->hid);
+       usbhid_submit_report(pidff->hid, pidff->reports[PID_EFFECT_OPERATION],
                          USB_DIR_OUT);
 }
 
@@ -534,7 +536,7 @@ static int pidff_playback(struct input_dev *dev, int effect_id, int value)
 static void pidff_erase_pid(struct pidff_device *pidff, int pid_id)
 {
        pidff->block_free[PID_EFFECT_BLOCK_INDEX].value[0] = pid_id;
-       hid_submit_report(pidff->hid, pidff->reports[PID_BLOCK_FREE],
+       usbhid_submit_report(pidff->hid, pidff->reports[PID_BLOCK_FREE],
                          USB_DIR_OUT);
 }
 
@@ -714,7 +716,7 @@ static void pidff_set_gain(struct input_dev *dev, u16 gain)
        struct pidff_device *pidff = dev->ff->private;
 
        pidff_set(&pidff->device_gain[PID_DEVICE_GAIN_FIELD], gain);
-       hid_submit_report(pidff->hid, pidff->reports[PID_DEVICE_GAIN],
+       usbhid_submit_report(pidff->hid, pidff->reports[PID_DEVICE_GAIN],
                          USB_DIR_OUT);
 }
 
@@ -739,7 +741,7 @@ static void pidff_autocenter(struct pidff_device *pidff, u16 magnitude)
        pidff_set(&pidff->set_effect[PID_GAIN], magnitude);
        pidff->set_effect[PID_START_DELAY].value[0] = 0;
 
-       hid_submit_report(pidff->hid, pidff->reports[PID_SET_EFFECT],
+       usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_EFFECT],
                          USB_DIR_OUT);
 }
 
@@ -1163,19 +1165,19 @@ static void pidff_reset(struct pidff_device *pidff)
 
        pidff->device_control->value[0] = pidff->control_id[PID_RESET];
        /* We reset twice as sometimes hid_wait_io isn't waiting long enough */
-       hid_submit_report(hid, pidff->reports[PID_DEVICE_CONTROL], USB_DIR_OUT);
-       hid_wait_io(hid);
-       hid_submit_report(hid, pidff->reports[PID_DEVICE_CONTROL], USB_DIR_OUT);
-       hid_wait_io(hid);
+       usbhid_submit_report(hid, pidff->reports[PID_DEVICE_CONTROL], USB_DIR_OUT);
+       usbhid_wait_io(hid);
+       usbhid_submit_report(hid, pidff->reports[PID_DEVICE_CONTROL], USB_DIR_OUT);
+       usbhid_wait_io(hid);
 
        pidff->device_control->value[0] =
                pidff->control_id[PID_ENABLE_ACTUATORS];
-       hid_submit_report(hid, pidff->reports[PID_DEVICE_CONTROL], USB_DIR_OUT);
-       hid_wait_io(hid);
+       usbhid_submit_report(hid, pidff->reports[PID_DEVICE_CONTROL], USB_DIR_OUT);
+       usbhid_wait_io(hid);
 
        /* pool report is sometimes messed up, refetch it */
-       hid_submit_report(hid, pidff->reports[PID_POOL], USB_DIR_IN);
-       hid_wait_io(hid);
+       usbhid_submit_report(hid, pidff->reports[PID_POOL], USB_DIR_IN);
+       usbhid_wait_io(hid);
 
        if (pidff->pool[PID_SIMULTANEOUS_MAX].value) {
                int sim_effects = pidff->pool[PID_SIMULTANEOUS_MAX].value[0];
@@ -1187,9 +1189,9 @@ static void pidff_reset(struct pidff_device *pidff)
                                break;
                        }
                        debug("pid_pool requested again");
-                       hid_submit_report(hid, pidff->reports[PID_POOL],
+                       usbhid_submit_report(hid, pidff->reports[PID_POOL],
                                          USB_DIR_IN);
-                       hid_wait_io(hid);
+                       usbhid_wait_io(hid);
                }
        }
 }
@@ -1275,7 +1277,7 @@ int hid_pidff_init(struct hid_device *hid)
 
        if (test_bit(FF_GAIN, dev->ffbit)) {
                pidff_set(&pidff->device_gain[PID_DEVICE_GAIN_FIELD], 0xffff);
-               hid_submit_report(pidff->hid, pidff->reports[PID_DEVICE_GAIN],
+               usbhid_submit_report(pidff->hid, pidff->reports[PID_DEVICE_GAIN],
                                  USB_DIR_OUT);
        }
 
index 2d5be4c318ac2a566e99e89865391a2140a7b2eb..ab67331620d0976b17daea16c5e113a089a0b7ba 100644 (file)
@@ -32,7 +32,8 @@
 #undef DEBUG
 #include <linux/usb.h>
 
-#include "hid.h"
+#include <linux/hid.h>
+#include "usbhid.h"
 
 /* Usages for thrustmaster devices I know about */
 #define THRUSTMASTER_USAGE_RUMBLE_LR   (HID_UP_GENDESK | 0xbb)
@@ -70,7 +71,7 @@ static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *ef
        tmff->rumble->value[0] = left;
        tmff->rumble->value[1] = right;
        dbg("(left,right)=(%08x, %08x)", left, right);
-       hid_submit_report(hid, tmff->report, USB_DIR_OUT);
+       usbhid_submit_report(hid, tmff->report, USB_DIR_OUT);
 
        return 0;
 }
index d2ce3214572c59e9184d987939791640c11ab99a..7bd8238ca2125b61fe71f112cf18c4721599e6cb 100644 (file)
@@ -27,7 +27,8 @@
 
 #include <linux/input.h>
 #include <linux/usb.h>
-#include "hid.h"
+#include <linux/hid.h>
+#include "usbhid.h"
 
 struct zpff_device {
        struct hid_report *report;
@@ -56,7 +57,7 @@ static int hid_zpff_play(struct input_dev *dev, void *data,
        zpff->report->field[2]->value[0] = left;
        zpff->report->field[3]->value[0] = right;
        debug("running with 0x%02x 0x%02x", left, right);
-       hid_submit_report(hid, zpff->report, USB_DIR_OUT);
+       usbhid_submit_report(hid, zpff->report, USB_DIR_OUT);
 
        return 0;
 }
@@ -101,7 +102,7 @@ int hid_zpff_init(struct hid_device *hid)
        zpff->report->field[1]->value[0] = 0x02;
        zpff->report->field[2]->value[0] = 0x00;
        zpff->report->field[3]->value[0] = 0x00;
-       hid_submit_report(hid, zpff->report, USB_DIR_OUT);
+       usbhid_submit_report(hid, zpff->report, USB_DIR_OUT);
 
        printk(KERN_INFO "Force feedback for Zeroplus based devices by "
               "Anssi Hannula <anssi.hannula@gmail.com>\n");
index 7dc14d0cacc1bd5c79298fba41a11aa33749cdaf..114d6c9f64b17175ffb0fc8d8edde27be24c507c 100644 (file)
@@ -32,8 +32,9 @@
 #include <linux/smp_lock.h>
 #include <linux/input.h>
 #include <linux/usb.h>
-#include "hid.h"
+#include <linux/hid.h>
 #include <linux/hiddev.h>
+#include "usbhid.h"
 
 #ifdef CONFIG_USB_DYNAMIC_MINORS
 #define HIDDEV_MINOR_BASE      0
@@ -196,7 +197,7 @@ void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
 
        hiddev_send_event(hid, &uref);
 }
-
+EXPORT_SYMBOL_GPL(hiddev_hid_event);
 
 void hiddev_report_event(struct hid_device *hid, struct hid_report *report)
 {
@@ -213,6 +214,7 @@ void hiddev_report_event(struct hid_device *hid, struct hid_report *report)
 
        hiddev_send_event(hid, &uref);
 }
+
 /*
  * fasync file op
  */
@@ -239,7 +241,7 @@ static int hiddev_release(struct inode * inode, struct file * file)
 
        if (!--list->hiddev->open) {
                if (list->hiddev->exist)
-                       hid_close(list->hiddev->hid);
+                       usbhid_close(list->hiddev->hid);
                else
                        kfree(list->hiddev);
        }
@@ -270,7 +272,7 @@ static int hiddev_open(struct inode *inode, struct file *file)
 
        if (!list->hiddev->open++)
                if (list->hiddev->exist)
-                       hid_open(hiddev_table[i]->hid);
+                       usbhid_open(hiddev_table[i]->hid);
 
        return 0;
 }
@@ -382,7 +384,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
        struct hiddev_list *list = file->private_data;
        struct hiddev *hiddev = list->hiddev;
        struct hid_device *hid = hiddev->hid;
-       struct usb_device *dev = hid->dev;
+       struct usb_device *dev = to_usb_device(hid->dev);
        struct hiddev_collection_info cinfo;
        struct hiddev_report_info rinfo;
        struct hiddev_field_info finfo;
@@ -391,6 +393,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
        struct hiddev_devinfo dinfo;
        struct hid_report *report;
        struct hid_field *field;
+       struct usbhid_device *usbhid = hid->driver_data;
        void __user *user_arg = (void __user *)arg;
        int i;
 
@@ -420,7 +423,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
                dinfo.bustype = BUS_USB;
                dinfo.busnum = dev->bus->busnum;
                dinfo.devnum = dev->devnum;
-               dinfo.ifnum = hid->ifnum;
+               dinfo.ifnum = usbhid->ifnum;
                dinfo.vendor = le16_to_cpu(dev->descriptor.idVendor);
                dinfo.product = le16_to_cpu(dev->descriptor.idProduct);
                dinfo.version = le16_to_cpu(dev->descriptor.bcdDevice);
@@ -479,7 +482,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
                }
 
        case HIDIOCINITREPORT:
-               hid_init_reports(hid);
+               usbhid_init_reports(hid);
 
                return 0;
 
@@ -493,8 +496,8 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
                if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL)
                        return -EINVAL;
 
-               hid_submit_report(hid, report, USB_DIR_IN);
-               hid_wait_io(hid);
+               usbhid_submit_report(hid, report, USB_DIR_IN);
+               usbhid_wait_io(hid);
 
                return 0;
 
@@ -508,8 +511,8 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
                if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL)
                        return -EINVAL;
 
-               hid_submit_report(hid, report, USB_DIR_OUT);
-               hid_wait_io(hid);
+               usbhid_submit_report(hid, report, USB_DIR_OUT);
+               usbhid_wait_io(hid);
 
                return 0;
 
@@ -745,6 +748,7 @@ static struct usb_class_driver hiddev_class = {
 int hiddev_connect(struct hid_device *hid)
 {
        struct hiddev *hiddev;
+       struct usbhid_device *usbhid = hid->driver_data;
        int i;
        int retval;
 
@@ -760,7 +764,7 @@ int hiddev_connect(struct hid_device *hid)
        if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL)))
                return -1;
 
-       retval = usb_register_dev(hid->intf, &hiddev_class);
+       retval = usb_register_dev(usbhid->intf, &hiddev_class);
        if (retval) {
                err("Not able to get a minor for this device.");
                kfree(hiddev);
@@ -772,10 +776,10 @@ int hiddev_connect(struct hid_device *hid)
        hiddev->hid = hid;
        hiddev->exist = 1;
 
-       hid->minor = hid->intf->minor;
+       hid->minor = usbhid->intf->minor;
        hid->hiddev = hiddev;
 
-       hiddev_table[hid->intf->minor - HIDDEV_MINOR_BASE] = hiddev;
+       hiddev_table[usbhid->intf->minor - HIDDEV_MINOR_BASE] = hiddev;
 
        return 0;
 }
@@ -788,14 +792,15 @@ static struct usb_class_driver hiddev_class;
 void hiddev_disconnect(struct hid_device *hid)
 {
        struct hiddev *hiddev = hid->hiddev;
+       struct usbhid_device *usbhid = hid->driver_data;
 
        hiddev->exist = 0;
 
        hiddev_table[hiddev->hid->minor - HIDDEV_MINOR_BASE] = NULL;
-       usb_deregister_dev(hiddev->hid->intf, &hiddev_class);
+       usb_deregister_dev(usbhid->intf, &hiddev_class);
 
        if (hiddev->open) {
-               hid_close(hiddev->hid);
+               usbhid_close(hiddev->hid);
                wake_up_interruptible(&hiddev->wait);
        } else {
                kfree(hiddev);
index 50aa8108a50b27d82b6cdb95a6d3f07b7cc06c67..98bd323369c72f6f6ab120073178c7bbdd144370 100644 (file)
@@ -456,7 +456,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
        remote->in_endpoint = endpoint;
        remote->toggle = -1;    /* Set to -1 so we will always not match the toggle from the first remote message. */
 
-       remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, SLAB_ATOMIC, &remote->in_dma);
+       remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, GFP_ATOMIC, &remote->in_dma);
        if (!remote->in_buffer) {
                retval = -ENOMEM;
                goto fail1;
index 79a85d46cb13b3f7bdd2a3ed1c783c7672ba4aa4..92c4e07da4c816e07759c395d93b98ab69f01225 100644 (file)
@@ -164,7 +164,7 @@ static int mtouchusb_alloc_buffers(struct usb_device *udev, struct mtouch_usb *m
        dbg("%s - called", __FUNCTION__);
 
        mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE,
-                                       SLAB_ATOMIC, &mtouch->data_dma);
+                                       GFP_ATOMIC, &mtouch->data_dma);
 
        if (!mtouch->data)
                return -1;
index 0bf91778c40def170820b04b41ae949dc66a8b13..fea97e5437f8b87c6676f2aaa065401975070151 100644 (file)
@@ -277,12 +277,12 @@ static int powermate_input_event(struct input_dev *dev, unsigned int type, unsig
 static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_device *pm)
 {
        pm->data = usb_buffer_alloc(udev, POWERMATE_PAYLOAD_SIZE_MAX,
-                                   SLAB_ATOMIC, &pm->data_dma);
+                                   GFP_ATOMIC, &pm->data_dma);
        if (!pm->data)
                return -1;
 
        pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)),
-                                       SLAB_ATOMIC, &pm->configcr_dma);
+                                       GFP_ATOMIC, &pm->configcr_dma);
        if (!pm->configcr)
                return -1;
 
index 05c0d1ca39ab2497c72f6bc80955c36757850b24..2a314b0659225cc4fff70fe716427027fdd06e4f 100644 (file)
@@ -248,7 +248,7 @@ static int touchkit_alloc_buffers(struct usb_device *udev,
                                  struct touchkit_usb *touchkit)
 {
        touchkit->data = usb_buffer_alloc(udev, TOUCHKIT_REPORT_DATA_SIZE,
-                                         SLAB_ATOMIC, &touchkit->data_dma);
+                                         GFP_ATOMIC, &touchkit->data_dma);
 
        if (!touchkit->data)
                return -1;
diff --git a/drivers/usb/input/usbhid.h b/drivers/usb/input/usbhid.h
new file mode 100644 (file)
index 0000000..830107e
--- /dev/null
@@ -0,0 +1,84 @@
+#ifndef __USBHID_H
+#define __USBHID_H
+
+/*
+ *  Copyright (c) 1999 Andreas Gal
+ *  Copyright (c) 2000-2001 Vojtech Pavlik
+ *  Copyright (c) 2006 Jiri Kosina
+ */
+
+/*
+ * 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
+ *
+ */
+
+#include <linux/types.h>
+#include <linux/slab.h>
+#include <linux/list.h>
+#include <linux/timer.h>
+#include <linux/workqueue.h>
+#include <linux/input.h>
+
+/*  API provided by hid-core.c for USB HID drivers */
+int usbhid_wait_io(struct hid_device* hid);
+void usbhid_close(struct hid_device *hid);
+int usbhid_open(struct hid_device *hid);
+void usbhid_init_reports(struct hid_device *hid);
+void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir);
+
+/*
+ * USB-specific HID struct, to be pointed to
+ * from struct hid_device->driver_data
+ */
+
+struct usbhid_device {
+       struct hid_device *hid;                                         /* pointer to corresponding HID dev */
+
+       struct usb_interface *intf;                                     /* USB interface */
+       int ifnum;                                                      /* USB interface number */
+
+       unsigned int bufsize;                                           /* URB buffer size */
+
+       struct urb *urbin;                                              /* Input URB */
+       char *inbuf;                                                    /* Input buffer */
+       dma_addr_t inbuf_dma;                                           /* Input buffer dma */
+       spinlock_t inlock;                                              /* Input fifo spinlock */
+
+       struct urb *urbctrl;                                            /* Control URB */
+       struct usb_ctrlrequest *cr;                                     /* Control request struct */
+       dma_addr_t cr_dma;                                              /* Control request struct dma */
+       struct hid_control_fifo ctrl[HID_CONTROL_FIFO_SIZE];            /* Control fifo */
+       unsigned char ctrlhead, ctrltail;                               /* Control fifo head & tail */
+       char *ctrlbuf;                                                  /* Control buffer */
+       dma_addr_t ctrlbuf_dma;                                         /* Control buffer dma */
+       spinlock_t ctrllock;                                            /* Control fifo spinlock */
+
+       struct urb *urbout;                                             /* Output URB */
+       struct hid_report *out[HID_CONTROL_FIFO_SIZE];                  /* Output pipe fifo */
+       unsigned char outhead, outtail;                                 /* Output pipe fifo head & tail */
+       char *outbuf;                                                   /* Output buffer */
+       dma_addr_t outbuf_dma;                                          /* Output buffer dma */
+       spinlock_t outlock;                                             /* Output fifo spinlock */
+
+       unsigned long iofl;                                             /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */
+       struct timer_list io_retry;                                     /* Retry timer */
+       unsigned long stop_retry;                                       /* Time to give up, in jiffies */
+       unsigned int retry_delay;                                       /* Delay length in ms */
+       struct work_struct reset_work;                                  /* Task context for resets */
+
+};
+
+#endif
+
index dac88640eab637532e37334afb2c1bf0a6486ab1..8505824848f6b7995bc40bd1cab9ef1ad3038a9c 100644 (file)
@@ -122,7 +122,7 @@ static void usb_kbd_irq(struct urb *urb)
        memcpy(kbd->old, kbd->new, 8);
 
 resubmit:
-       i = usb_submit_urb (urb, SLAB_ATOMIC);
+       i = usb_submit_urb (urb, GFP_ATOMIC);
        if (i)
                err ("can't resubmit intr, %s-%s/input0, status %d",
                                kbd->usbdev->bus->bus_name,
@@ -196,11 +196,11 @@ static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd)
                return -1;
        if (!(kbd->led = usb_alloc_urb(0, GFP_KERNEL)))
                return -1;
-       if (!(kbd->new = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &kbd->new_dma)))
+       if (!(kbd->new = usb_buffer_alloc(dev, 8, GFP_ATOMIC, &kbd->new_dma)))
                return -1;
-       if (!(kbd->cr = usb_buffer_alloc(dev, sizeof(struct usb_ctrlrequest), SLAB_ATOMIC, &kbd->cr_dma)))
+       if (!(kbd->cr = usb_buffer_alloc(dev, sizeof(struct usb_ctrlrequest), GFP_ATOMIC, &kbd->cr_dma)))
                return -1;
-       if (!(kbd->leds = usb_buffer_alloc(dev, 1, SLAB_ATOMIC, &kbd->leds_dma)))
+       if (!(kbd->leds = usb_buffer_alloc(dev, 1, GFP_ATOMIC, &kbd->leds_dma)))
                return -1;
 
        return 0;
index 68a55642c082da8f77b2ef28c8eab73e5ef90e15..64a33e420cfbabb3b6758f25353c67b4b02ee55e 100644 (file)
@@ -86,7 +86,7 @@ static void usb_mouse_irq(struct urb *urb)
 
        input_sync(dev);
 resubmit:
-       status = usb_submit_urb (urb, SLAB_ATOMIC);
+       status = usb_submit_urb (urb, GFP_ATOMIC);
        if (status)
                err ("can't resubmit intr, %s-%s/input0, status %d",
                                mouse->usbdev->bus->bus_name,
@@ -137,7 +137,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
        if (!mouse || !input_dev)
                goto fail1;
 
-       mouse->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &mouse->data_dma);
+       mouse->data = usb_buffer_alloc(dev, 8, GFP_ATOMIC, &mouse->data_dma);
        if (!mouse->data)
                goto fail1;
 
index 49704d4ed0e296f7a850761a0c9bb84784f27797..7f3c57da9bc0767abf96a69e87f02b13fa296249 100644 (file)
@@ -680,7 +680,7 @@ static int usbtouch_probe(struct usb_interface *intf,
                type->process_pkt = usbtouch_process_pkt;
 
        usbtouch->data = usb_buffer_alloc(udev, type->rept_size,
-                                         SLAB_KERNEL, &usbtouch->data_dma);
+                                         GFP_KERNEL, &usbtouch->data_dma);
        if (!usbtouch->data)
                goto out_free;
 
index df97e5c803f9b08ab2a23f5552486c8541e430fc..e4bc76ebc83567ad325b72563c5b7c1a0a412b64 100644 (file)
@@ -325,7 +325,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
                goto fail1;
 
        xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN,
-                                      SLAB_ATOMIC, &xpad->idata_dma);
+                                      GFP_ATOMIC, &xpad->idata_dma);
        if (!xpad->idata)
                goto fail1;
 
index 2268ca311ade7d4d0ee5246ce9141c17940e6b77..caff8e6d74480eec88e8355499f956f79136f0da 100644 (file)
@@ -874,17 +874,17 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
 
        /* allocate usb buffers */
        yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN,
-                                       SLAB_ATOMIC, &yld->irq_dma);
+                                       GFP_ATOMIC, &yld->irq_dma);
        if (yld->irq_data == NULL)
                return usb_cleanup(yld, -ENOMEM);
 
        yld->ctl_data = usb_buffer_alloc(udev, USB_PKT_LEN,
-                                       SLAB_ATOMIC, &yld->ctl_dma);
+                                       GFP_ATOMIC, &yld->ctl_dma);
        if (!yld->ctl_data)
                return usb_cleanup(yld, -ENOMEM);
 
        yld->ctl_req = usb_buffer_alloc(udev, sizeof(*(yld->ctl_req)),
-                                       SLAB_ATOMIC, &yld->ctl_req_dma);
+                                       GFP_ATOMIC, &yld->ctl_req_dma);
        if (yld->ctl_req == NULL)
                return usb_cleanup(yld, -ENOMEM);
 
index 9659c79e187e16f65bc0036a2b8cad74f59c2db2..371bf2b1197db8761ff01e20fe25ea97ce5fbb65 100644 (file)
@@ -377,7 +377,7 @@ static void interfacekit_irq(struct urb *urb)
                schedule_delayed_work(&kit->do_notify, 0);
 
 resubmit:
-       status = usb_submit_urb(urb, SLAB_ATOMIC);
+       status = usb_submit_urb(urb, GFP_ATOMIC);
        if (status)
                err("can't resubmit intr, %s-%s/interfacekit0, status %d",
                        kit->udev->bus->bus_name,
@@ -568,7 +568,7 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
 
        kit->dev_no = -1;
        kit->ifkit = ifkit;
-       kit->data = usb_buffer_alloc(dev, URB_INT_SIZE, SLAB_ATOMIC, &kit->data_dma);
+       kit->data = usb_buffer_alloc(dev, URB_INT_SIZE, GFP_ATOMIC, &kit->data_dma);
        if (!kit->data)
                goto out;
 
index 2bb4fa572bb72492f3f6aa6b60c18e841bd56605..5727e1ea2f91db1cd454545d16190ad32535779b 100644 (file)
@@ -151,7 +151,7 @@ static void motorcontrol_irq(struct urb *urb)
                schedule_delayed_work(&mc->do_notify, 0);
 
 resubmit:
-       status = usb_submit_urb(urb, SLAB_ATOMIC);
+       status = usb_submit_urb(urb, GFP_ATOMIC);
        if (status)
                dev_err(&mc->intf->dev,
                        "can't resubmit intr, %s-%s/motorcontrol0, status %d",
@@ -338,7 +338,7 @@ static int motorcontrol_probe(struct usb_interface *intf, const struct usb_devic
                goto out;
 
        mc->dev_no = -1;
-       mc->data = usb_buffer_alloc(dev, URB_INT_SIZE, SLAB_ATOMIC, &mc->data_dma);
+       mc->data = usb_buffer_alloc(dev, URB_INT_SIZE, GFP_ATOMIC, &mc->data_dma);
        if (!mc->data)
                goto out;
 
index b99ca9c798218d2a713999b5033b1730966a09d3..0398908b15d482589eb4225ca192163fd9b3b297 100644 (file)
@@ -3168,7 +3168,7 @@ sisusb_compat_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
                case SISUSB_GET_CONFIG:
                case SISUSB_COMMAND:
                        lock_kernel();
-                       retval = sisusb_ioctl(f->f_dentry->d_inode, f, cmd, arg);
+                       retval = sisusb_ioctl(f->f_path.dentry->d_inode, f, cmd, arg);
                        unlock_kernel();
                        return retval;
 
index 194065dbb51f0866831b0976b3da05c167178c06..fb321864a92da4b85e551b9534582c31eecbac0b 100644 (file)
@@ -213,7 +213,7 @@ static struct urb *simple_alloc_urb (
 
        if (bytes < 0)
                return NULL;
-       urb = usb_alloc_urb (0, SLAB_KERNEL);
+       urb = usb_alloc_urb (0, GFP_KERNEL);
        if (!urb)
                return urb;
        usb_fill_bulk_urb (urb, udev, pipe, NULL, bytes, simple_callback, NULL);
@@ -223,7 +223,7 @@ static struct urb *simple_alloc_urb (
        urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
        if (usb_pipein (pipe))
                urb->transfer_flags |= URB_SHORT_NOT_OK;
-       urb->transfer_buffer = usb_buffer_alloc (udev, bytes, SLAB_KERNEL,
+       urb->transfer_buffer = usb_buffer_alloc (udev, bytes, GFP_KERNEL,
                        &urb->transfer_dma);
        if (!urb->transfer_buffer) {
                usb_free_urb (urb);
@@ -315,7 +315,7 @@ static int simple_io (
                init_completion (&completion);
                if (usb_pipeout (urb->pipe))
                        simple_fill_buf (urb);
-               if ((retval = usb_submit_urb (urb, SLAB_KERNEL)) != 0)
+               if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0)
                        break;
 
                /* NOTE:  no timeouts; can't be broken out of by interrupt */
@@ -374,7 +374,7 @@ alloc_sglist (int nents, int max, int vary)
        unsigned                i;
        unsigned                size = max;
 
-       sg = kmalloc (nents * sizeof *sg, SLAB_KERNEL);
+       sg = kmalloc (nents * sizeof *sg, GFP_KERNEL);
        if (!sg)
                return NULL;
 
@@ -382,7 +382,7 @@ alloc_sglist (int nents, int max, int vary)
                char            *buf;
                unsigned        j;
 
-               buf = kzalloc (size, SLAB_KERNEL);
+               buf = kzalloc (size, GFP_KERNEL);
                if (!buf) {
                        free_sglist (sg, i);
                        return NULL;
@@ -428,7 +428,7 @@ static int perform_sglist (
                                (udev->speed == USB_SPEED_HIGH)
                                        ? (INTERRUPT_RATE << 3)
                                        : INTERRUPT_RATE,
-                               sg, nents, 0, SLAB_KERNEL);
+                               sg, nents, 0, GFP_KERNEL);
                
                if (retval)
                        break;
@@ -819,7 +819,7 @@ error:
 
        /* resubmit if we need to, else mark this as done */
        if ((status == 0) && (ctx->pending < ctx->count)) {
-               if ((status = usb_submit_urb (urb, SLAB_ATOMIC)) != 0) {
+               if ((status = usb_submit_urb (urb, GFP_ATOMIC)) != 0) {
                        dbg ("can't resubmit ctrl %02x.%02x, err %d",
                                reqp->bRequestType, reqp->bRequest, status);
                        urb->dev = NULL;
@@ -855,7 +855,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
         * as with bulk/intr sglists, sglen is the queue depth; it also
         * controls which subtests run (more tests than sglen) or rerun.
         */
-       urb = kcalloc(param->sglen, sizeof(struct urb *), SLAB_KERNEL);
+       urb = kcalloc(param->sglen, sizeof(struct urb *), GFP_KERNEL);
        if (!urb)
                return -ENOMEM;
        for (i = 0; i < param->sglen; i++) {
@@ -981,7 +981,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
                if (!u)
                        goto cleanup;
 
-               reqp = usb_buffer_alloc (udev, sizeof *reqp, SLAB_KERNEL,
+               reqp = usb_buffer_alloc (udev, sizeof *reqp, GFP_KERNEL,
                                &u->setup_dma);
                if (!reqp)
                        goto cleanup;
@@ -999,7 +999,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
        context.urb = urb;
        spin_lock_irq (&context.lock);
        for (i = 0; i < param->sglen; i++) {
-               context.status = usb_submit_urb (urb [i], SLAB_ATOMIC);
+               context.status = usb_submit_urb (urb [i], GFP_ATOMIC);
                if (context.status != 0) {
                        dbg ("can't submit urb[%d], status %d",
                                        i, context.status);
@@ -1041,7 +1041,7 @@ static void unlink1_callback (struct urb *urb)
 
        // we "know" -EPIPE (stall) never happens
        if (!status)
-               status = usb_submit_urb (urb, SLAB_ATOMIC);
+               status = usb_submit_urb (urb, GFP_ATOMIC);
        if (status) {
                urb->status = status;
                complete ((struct completion *) urb->context);
@@ -1067,7 +1067,7 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
         * FIXME want additional tests for when endpoint is STALLing
         * due to errors, or is just NAKing requests.
         */
-       if ((retval = usb_submit_urb (urb, SLAB_KERNEL)) != 0) {
+       if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) {
                dev_dbg (&dev->intf->dev, "submit fail %d\n", retval);
                return retval;
        }
@@ -1251,7 +1251,7 @@ static int ctrl_out (struct usbtest_dev *dev,
        if (length < 1 || length > 0xffff || vary >= length)
                return -EINVAL;
 
-       buf = kmalloc(length, SLAB_KERNEL);
+       buf = kmalloc(length, GFP_KERNEL);
        if (!buf)
                return -ENOMEM;
 
@@ -1403,7 +1403,7 @@ static struct urb *iso_alloc_urb (
        maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11));
        packets = (bytes + maxp - 1) / maxp;
 
-       urb = usb_alloc_urb (packets, SLAB_KERNEL);
+       urb = usb_alloc_urb (packets, GFP_KERNEL);
        if (!urb)
                return urb;
        urb->dev = udev;
@@ -1411,7 +1411,7 @@ static struct urb *iso_alloc_urb (
 
        urb->number_of_packets = packets;
        urb->transfer_buffer_length = bytes;
-       urb->transfer_buffer = usb_buffer_alloc (udev, bytes, SLAB_KERNEL,
+       urb->transfer_buffer = usb_buffer_alloc (udev, bytes, GFP_KERNEL,
                        &urb->transfer_dma);
        if (!urb->transfer_buffer) {
                usb_free_urb (urb);
@@ -1481,7 +1481,7 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,
        spin_lock_irq (&context.lock);
        for (i = 0; i < param->sglen; i++) {
                ++context.pending;
-               status = usb_submit_urb (urbs [i], SLAB_ATOMIC);
+               status = usb_submit_urb (urbs [i], GFP_ATOMIC);
                if (status < 0) {
                        ERROR (dev, "submit iso[%d], error %d\n", i, status);
                        if (i == 0) {
@@ -1900,7 +1900,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
        }
 #endif
 
-       dev = kzalloc(sizeof(*dev), SLAB_KERNEL);
+       dev = kzalloc(sizeof(*dev), GFP_KERNEL);
        if (!dev)
                return -ENOMEM;
        info = (struct usbtest_info *) id->driver_info;
@@ -1910,7 +1910,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
        dev->intf = intf;
 
        /* cacheline-aligned scratch for i/o */
-       if ((dev->buf = kmalloc (TBUF_SIZE, SLAB_KERNEL)) == NULL) {
+       if ((dev->buf = kmalloc (TBUF_SIZE, GFP_KERNEL)) == NULL) {
                kfree (dev);
                return -ENOMEM;
        }
index 7a2346c53284b93a502b47b5911159f343a70ecc..05cf2c9a8f84c3fbb42ffaaabf971d8bd2a526ea 100644 (file)
@@ -50,7 +50,7 @@ struct mon_event_text {
 
 #define SLAB_NAME_SZ  30
 struct mon_reader_text {
-       kmem_cache_t *e_slab;
+       struct kmem_cache *e_slab;
        int nevents;
        struct list_head e_list;
        struct mon_reader r;    /* In C, parent class can be placed anywhere */
@@ -63,7 +63,7 @@ struct mon_reader_text {
        char slab_name[SLAB_NAME_SZ];
 };
 
-static void mon_text_ctor(void *, kmem_cache_t *, unsigned long);
+static void mon_text_ctor(void *, struct kmem_cache *, unsigned long);
 
 /*
  * mon_text_submit
@@ -147,7 +147,7 @@ static void mon_text_event(struct mon_reader_text *rp, struct urb *urb,
        stamp = mon_get_timestamp();
 
        if (rp->nevents >= EVENT_MAX ||
-           (ep = kmem_cache_alloc(rp->e_slab, SLAB_ATOMIC)) == NULL) {
+           (ep = kmem_cache_alloc(rp->e_slab, GFP_ATOMIC)) == NULL) {
                rp->r.m_bus->cnt_text_lost++;
                return;
        }
@@ -188,7 +188,7 @@ static void mon_text_error(void *data, struct urb *urb, int error)
        struct mon_event_text *ep;
 
        if (rp->nevents >= EVENT_MAX ||
-           (ep = kmem_cache_alloc(rp->e_slab, SLAB_ATOMIC)) == NULL) {
+           (ep = kmem_cache_alloc(rp->e_slab, GFP_ATOMIC)) == NULL) {
                rp->r.m_bus->cnt_text_lost++;
                return;
        }
@@ -450,7 +450,7 @@ const struct file_operations mon_fops_text = {
 /*
  * Slab interface: constructor.
  */
-static void mon_text_ctor(void *mem, kmem_cache_t *slab, unsigned long sflags)
+static void mon_text_ctor(void *mem, struct kmem_cache *slab, unsigned long sflags)
 {
        /*
         * Nothing to initialize. No, really!
index 907b820a5faf4ffd9cea63f1b17c588f8f69ab79..4852012735f66c207030abb7676136ff43a0f3cd 100644 (file)
@@ -345,7 +345,7 @@ static void catc_irq_done(struct urb *urb)
                } 
        }
 resubmit:
-       status = usb_submit_urb (urb, SLAB_ATOMIC);
+       status = usb_submit_urb (urb, GFP_ATOMIC);
        if (status)
                err ("can't resubmit intr, %s-%s, status %d",
                                catc->usbdev->bus->bus_name,
index a77410562e1208d76e7124386897acdba7f33efe..4936359545134db670434fbba9e011a97f943184 100644 (file)
@@ -383,7 +383,7 @@ static void nc_ensure_sync(struct usbnet *dev)
                int                     status;
 
                /* Send a flush */
-               urb = usb_alloc_urb(0, SLAB_ATOMIC);
+               urb = usb_alloc_urb(0, GFP_ATOMIC);
                if (!urb)
                        return;
 
index b5690b3834e3250606c026dcc7bffe5a5b1118bd..d48c024cff595ff2987be71fb33ab536c05ad5f9 100644 (file)
@@ -856,7 +856,7 @@ static void intr_callback(struct urb *urb)
                pegasus->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4];
        }
 
-       status = usb_submit_urb(urb, SLAB_ATOMIC);
+       status = usb_submit_urb(urb, GFP_ATOMIC);
        if (status == -ENODEV)
                netif_device_detach(pegasus->net);
        if (status && netif_msg_timer(pegasus))
index c2a28d88ef3c8d174124790c0be00f116173d5c5..99f26b3e502f39dcd017c5854c635dabb435a16d 100644 (file)
@@ -469,7 +469,7 @@ static void rndis_unbind(struct usbnet *dev, struct usb_interface *intf)
        struct rndis_halt       *halt;
 
        /* try to clear any rndis state/activity (no i/o from stack!) */
-       halt = kcalloc(1, sizeof *halt, SLAB_KERNEL);
+       halt = kcalloc(1, sizeof *halt, GFP_KERNEL);
        if (halt) {
                halt->msg_type = RNDIS_MSG_HALT;
                halt->msg_len = ccpu2(sizeof *halt);
index 72171f94ded48eb648c061b92f648bda8f2600b4..c54235f73cb68b14c1a733536ac0411a91dc3093 100644 (file)
@@ -587,7 +587,7 @@ static void intr_callback(struct urb *urb)
        }
 
 resubmit:
-       status = usb_submit_urb (urb, SLAB_ATOMIC);
+       status = usb_submit_urb (urb, GFP_ATOMIC);
        if (status == -ENODEV)
                netif_device_detach(dev->netdev);
        else if (status)
index 327f97555679df645334d981c5ef15ed7de802ff..6e39e998825914acfaf899c5a9d77e2b13b59d31 100644 (file)
@@ -179,9 +179,9 @@ static int init_status (struct usbnet *dev, struct usb_interface *intf)
        period = max ((int) dev->status->desc.bInterval,
                (dev->udev->speed == USB_SPEED_HIGH) ? 7 : 3);
 
-       buf = kmalloc (maxp, SLAB_KERNEL);
+       buf = kmalloc (maxp, GFP_KERNEL);
        if (buf) {
-               dev->interrupt = usb_alloc_urb (0, SLAB_KERNEL);
+               dev->interrupt = usb_alloc_urb (0, GFP_KERNEL);
                if (!dev->interrupt) {
                        kfree (buf);
                        return -ENOMEM;
index 863966c1c5ac3befc71c296cc7a25b9255516bb7..5261cd22ee6bf635e6f8b44fc5cd7acd99ddb275 100644 (file)
@@ -156,7 +156,7 @@ cleanup:
 }
 
 static void ark3116_set_termios(struct usb_serial_port *port,
-                               struct termios *old_termios)
+                               struct ktermios *old_termios)
 {
        struct usb_serial *serial = port->serial;
        struct ark3116_private *priv = usb_get_serial_port_data(port);
@@ -326,7 +326,7 @@ static void ark3116_set_termios(struct usb_serial_port *port,
 
 static int ark3116_open(struct usb_serial_port *port, struct file *filp)
 {
-       struct termios tmp_termios;
+       struct ktermios tmp_termios;
        struct usb_serial *serial = port->serial;
        char *buf;
        int result = 0;
index 8835bb58ca9bfa5ec7d9a873dba1972275ad34ac..38b4dae319eedc3e8c0a30e1cc2243404ccd1b79 100644 (file)
@@ -92,7 +92,7 @@ static void belkin_sa_shutdown                (struct usb_serial *serial);
 static int  belkin_sa_open             (struct usb_serial_port *port, struct file *filp);
 static void belkin_sa_close            (struct usb_serial_port *port, struct file *filp);
 static void belkin_sa_read_int_callback (struct urb *urb);
-static void belkin_sa_set_termios      (struct usb_serial_port *port, struct termios * old);
+static void belkin_sa_set_termios      (struct usb_serial_port *port, struct ktermios * 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);
@@ -333,7 +333,7 @@ exit:
                     __FUNCTION__, retval);
 }
 
-static void belkin_sa_set_termios (struct usb_serial_port *port, struct termios *old_termios)
+static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
 {
        struct usb_serial *serial = port->serial;
        struct belkin_sa_private *priv = usb_get_serial_port_data(port);
index 7167728d764ce8033d1f3f1f3e2687b4930bfdcf..9386e216d68155caec8c9467ddfe4dd005c61859 100644 (file)
@@ -65,7 +65,7 @@ static int usb_console_setup(struct console *co, char *options)
        struct usb_serial_port *port;
        int retval = 0;
        struct tty_struct *tty;
-       struct termios *termios;
+       struct ktermios *termios;
 
        dbg ("%s", __FUNCTION__);
 
index f95d42c0d16a9c46e7d5f01e58f7f27716790f8e..2f9b7ac326633a6d6835164d52c7a9c00648e7a2 100644 (file)
@@ -41,7 +41,7 @@ static int cp2101_open(struct usb_serial_port*, struct file*);
 static void cp2101_cleanup(struct usb_serial_port*);
 static void cp2101_close(struct usb_serial_port*, struct file*);
 static void cp2101_get_termios(struct usb_serial_port*);
-static void cp2101_set_termios(struct usb_serial_port*, struct termios*);
+static void cp2101_set_termios(struct usb_serial_port*, struct ktermios*);
 static int cp2101_tiocmget (struct usb_serial_port *, struct file *);
 static int cp2101_tiocmset (struct usb_serial_port *, struct file *,
                unsigned int, unsigned int);
@@ -506,7 +506,7 @@ static void cp2101_get_termios (struct usb_serial_port *port)
 }
 
 static void cp2101_set_termios (struct usb_serial_port *port,
-               struct termios *old_termios)
+               struct ktermios *old_termios)
 {
        unsigned int cflag, old_cflag=0;
        int baud=0, bits;
index 093f303b3189d2a515a467e8c32598a5626aceca..a1fdb85b8c0ae91225c447f5cb79b6c19792e991 100644 (file)
@@ -143,7 +143,7 @@ struct cypress_private {
        wait_queue_head_t delta_msr_wait;  /* used for TIOCMIWAIT */
        char prev_status, diff_status;     /* used for TIOCMIWAIT */
        /* we pass a pointer to this as the arguement sent to cypress_set_termios old_termios */
-       struct termios tmp_termios;        /* stores the old termios settings */
+       struct ktermios tmp_termios;       /* stores the old termios settings */
 };
 
 /* write buffer structure */
@@ -165,7 +165,7 @@ static int  cypress_write           (struct usb_serial_port *port, const unsigned char *b
 static void cypress_send               (struct usb_serial_port *port);
 static int  cypress_write_room         (struct usb_serial_port *port);
 static int  cypress_ioctl              (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
-static void cypress_set_termios                (struct usb_serial_port *port, struct termios * old);
+static void cypress_set_termios                (struct usb_serial_port *port, struct ktermios * old);
 static int  cypress_tiocmget           (struct usb_serial_port *port, struct file *file);
 static int  cypress_tiocmset           (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
 static int  cypress_chars_in_buffer    (struct usb_serial_port *port);
@@ -949,13 +949,13 @@ static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsi
 
        switch (cmd) {
                case TIOCGSERIAL:
-                       if (copy_to_user((void __user *)arg, port->tty->termios, sizeof(struct termios))) {
+                       if (copy_to_user((void __user *)arg, port->tty->termios, sizeof(struct ktermios))) {
                                return -EFAULT;
                        }
                        return (0);
                        break;
                case TIOCSSERIAL:
-                       if (copy_from_user(port->tty->termios, (void __user *)arg, sizeof(struct termios))) {
+                       if (copy_from_user(port->tty->termios, (void __user *)arg, sizeof(struct ktermios))) {
                                return -EFAULT;
                        }
                        /* here we need to call cypress_set_termios to invoke the new settings */
@@ -1019,7 +1019,7 @@ static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsi
 
 
 static void cypress_set_termios (struct usb_serial_port *port,
-               struct termios *old_termios)
+               struct ktermios *old_termios)
 {
        struct cypress_private *priv = usb_get_serial_port_data(port);
        struct tty_struct *tty;
index 83d0e21145b01cf9b1b46352eae664b51799a164..9d9ea874639ce047bc3ac855d4b94abd020fa254 100644 (file)
@@ -449,7 +449,7 @@ static int digi_transmit_idle( struct usb_serial_port *port,
 static void digi_rx_throttle (struct usb_serial_port *port);
 static void digi_rx_unthrottle (struct usb_serial_port *port);
 static void digi_set_termios( struct usb_serial_port *port, 
-       struct termios *old_termios );
+       struct ktermios *old_termios );
 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 );
@@ -976,7 +976,7 @@ dbg( "digi_rx_unthrottle: TOP: port=%d", priv->dp_port_num );
 
 
 static void digi_set_termios( struct usb_serial_port *port, 
-       struct termios *old_termios )
+       struct ktermios *old_termios )
 {
 
        struct digi_port *priv = usb_get_serial_port_data(port);
@@ -1463,7 +1463,7 @@ static int digi_open( struct usb_serial_port *port, struct file *filp )
        int ret;
        unsigned char buf[32];
        struct digi_port *priv = usb_get_serial_port_data(port);
-       struct termios not_termios;
+       struct ktermios not_termios;
        unsigned long flags = 0;
 
 
index 4ce10a8319539f56187034ecfa611c4b7b663a05..92beeb19795f15ae325b3599771832c7f851b759 100644 (file)
@@ -92,7 +92,7 @@ static int  empeg_ioctl                       (struct usb_serial_port *port,
                                        struct file * file,
                                        unsigned int cmd,
                                        unsigned long arg);
-static void empeg_set_termios          (struct usb_serial_port *port, struct termios *old_termios);
+static void empeg_set_termios          (struct usb_serial_port *port, struct ktermios *old_termios);
 static void empeg_write_bulk_callback  (struct urb *urb);
 static void empeg_read_bulk_callback   (struct urb *urb);
 
@@ -442,7 +442,7 @@ static int empeg_ioctl (struct usb_serial_port *port, struct file * file, unsign
 }
 
 
-static void empeg_set_termios (struct usb_serial_port *port, struct termios *old_termios)
+static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
 {
 
        dbg("%s - port %d", __FUNCTION__, port->number);
index 72e4d48f51e9c18e9e6f4130dda00ad504261c0e..41b0ad2d56ac97062d353a12779f2d55e2610418 100644 (file)
@@ -595,7 +595,7 @@ static int  ftdi_chars_in_buffer    (struct usb_serial_port *port);
 static void ftdi_write_bulk_callback   (struct urb *urb);
 static void ftdi_read_bulk_callback    (struct urb *urb);
 static void ftdi_process_read          (struct work_struct *work);
-static void ftdi_set_termios           (struct usb_serial_port *port, struct termios * old);
+static void ftdi_set_termios           (struct usb_serial_port *port, struct ktermios * old);
 static int  ftdi_tiocmget               (struct usb_serial_port *port, struct file *file);
 static int  ftdi_tiocmset              (struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear);
 static int  ftdi_ioctl                 (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
@@ -1880,7 +1880,7 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state )
  * WARNING: set_termios calls this with old_termios in kernel space
  */
 
-static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_termios)
+static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
 { /* ftdi_termios */
        struct usb_device *dev = port->serial->dev;
        unsigned int cflag = port->tty->termios->c_cflag;
index d06547a13f2823c85106099ab18361b3e4d866f2..f623d58370a4c2561a5be318a4d9f01a90f5b063 100644 (file)
@@ -229,7 +229,7 @@ static int  edge_write_room         (struct usb_serial_port *port);
 static int  edge_chars_in_buffer       (struct usb_serial_port *port);
 static void edge_throttle              (struct usb_serial_port *port);
 static void edge_unthrottle            (struct usb_serial_port *port);
-static void edge_set_termios           (struct usb_serial_port *port, struct termios *old_termios);
+static void edge_set_termios           (struct usb_serial_port *port, struct ktermios *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);
@@ -257,7 +257,7 @@ static void handle_new_lsr          (struct edgeport_port *edge_port, __u8 lsrData, __u8
 static int  send_iosp_ext_cmd          (struct edgeport_port *edge_port, __u8 command, __u8 param);
 static int  calc_baud_rate_divisor     (int baud_rate, int *divisor);
 static int  send_cmd_write_baud_rate   (struct edgeport_port *edge_port, int baudRate);
-static void change_port_settings       (struct edgeport_port *edge_port, struct termios *old_termios);
+static void change_port_settings       (struct edgeport_port *edge_port, struct ktermios *old_termios);
 static int  send_cmd_write_uart_register       (struct edgeport_port *edge_port, __u8 regNum, __u8 regValue);
 static int  write_cmd_usb              (struct edgeport_port *edge_port, unsigned char *buffer, int writeLength);
 static void send_more_port_data                (struct edgeport_serial *edge_serial, struct edgeport_port *edge_port);
@@ -1431,7 +1431,7 @@ static void edge_unthrottle (struct usb_serial_port *port)
  * SerialSetTermios
  *     this function is called by the tty driver when it wants to change the termios structure
  *****************************************************************************/
-static void edge_set_termios (struct usb_serial_port *port, struct termios *old_termios)
+static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
 {
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
        struct tty_struct *tty = port->tty;
@@ -2412,7 +2412,7 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r
 #ifndef CMSPAR
 #define CMSPAR 0
 #endif
-static void change_port_settings (struct edgeport_port *edge_port, struct termios *old_termios)
+static void change_port_settings (struct edgeport_port *edge_port, struct ktermios *old_termios)
 {
        struct tty_struct *tty;
        int baud;
index ee0c921e15206458516409617ca1c648d1cfdf2d..2da2684e080982a4f72c91ee3c26b9c79a85568b 100644 (file)
@@ -238,7 +238,7 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned c
 static void stop_read(struct edgeport_port *edge_port);
 static int restart_read(struct edgeport_port *edge_port);
 
-static void edge_set_termios (struct usb_serial_port *port, struct termios *old_termios);
+static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios);
 static void edge_send(struct usb_serial_port *port);
 
 /* circular buffer */
@@ -2361,7 +2361,7 @@ static int restart_read(struct edgeport_port *edge_port)
        return status;
 }
 
-static void change_port_settings (struct edgeport_port *edge_port, struct termios *old_termios)
+static void change_port_settings (struct edgeport_port *edge_port, struct ktermios *old_termios)
 {
        struct ump_uart_config *config;
        struct tty_struct *tty;
@@ -2512,7 +2512,7 @@ static void change_port_settings (struct edgeport_port *edge_port, struct termio
        return;
 }
 
-static void edge_set_termios (struct usb_serial_port *port, struct termios *old_termios)
+static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
 {
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
        struct tty_struct *tty = port->tty;
index 331bf81556fcca1978b4bd4e2cac6ad358356f7a..8fdf486e346528a2d36363003e1e133dcf9e6310 100644 (file)
@@ -107,7 +107,7 @@ static void ir_close (struct usb_serial_port *port, struct file *filep);
 static int  ir_write (struct usb_serial_port *port, const unsigned char *buf, int count);
 static void ir_write_bulk_callback (struct urb *urb);
 static void ir_read_bulk_callback (struct urb *urb);
-static void ir_set_termios (struct usb_serial_port *port, struct termios *old_termios);
+static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_termios);
 
 static u8 ir_baud = 0;
 static u8 ir_xbof = 0;
@@ -497,7 +497,7 @@ static void ir_read_bulk_callback (struct urb *urb)
        return;
 }
 
-static void ir_set_termios (struct usb_serial_port *port, struct termios *old_termios)
+static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
 {
        unsigned char *transfer_buffer;
        unsigned int cflag;
index 7639652cec42f84e94356c6f453efbe9593ed27d..9d2fdfd6865f4bde3d5a7171338ad1398db34a7e 100644 (file)
@@ -264,7 +264,7 @@ static void keyspan_break_ctl (struct usb_serial_port *port, int break_state)
 
 
 static void keyspan_set_termios (struct usb_serial_port *port, 
-                                    struct termios *old_termios)
+                                    struct ktermios *old_termios)
 {
        int                             baud_rate, device_port;
        struct keyspan_port_private     *p_priv;
index 7472ed6bf62653dd581af8d3eb8333b17be13e13..6413d73c139cb39a0beb209aebe12e33e964ee2d 100644 (file)
@@ -59,7 +59,7 @@ static int  keyspan_ioctl             (struct usb_serial_port *port,
                                         unsigned int cmd,
                                         unsigned long arg);
 static void keyspan_set_termios                (struct usb_serial_port *port,
-                                        struct termios *old);
+                                        struct ktermios *old);
 static void keyspan_break_ctl          (struct usb_serial_port *port,
                                         int break_state);
 static int  keyspan_tiocmget           (struct usb_serial_port *port,
index e09a0bfe62316f2ad890edbbb0a4ea1b5704fdb9..126b9703bbaf1136f2a4f50ab432982c44f09ba6 100644 (file)
@@ -365,7 +365,7 @@ static void keyspan_pda_break_ctl (struct usb_serial_port *port, int break_state
 
 
 static void keyspan_pda_set_termios (struct usb_serial_port *port, 
-                                    struct termios *old_termios)
+                                    struct ktermios *old_termios)
 {
        struct usb_serial *serial = port->serial;
        unsigned int cflag = port->tty->termios->c_cflag;
index 17e205699c2bca32970e0c2b26e79095ea7e91ae..73d755df4840e32527dfbb10386723726295f4cc 100644 (file)
@@ -86,7 +86,7 @@ static int  klsi_105_write_room          (struct usb_serial_port *port);
 
 static void klsi_105_read_bulk_callback  (struct urb *urb);
 static void klsi_105_set_termios         (struct usb_serial_port *port,
-                                         struct termios * old);
+                                         struct ktermios *old);
 static int  klsi_105_ioctl              (struct usb_serial_port *port,
                                          struct file * file,
                                          unsigned int cmd,
@@ -164,7 +164,7 @@ struct klsi_105_port_settings {
 #define URB_TRANSFER_BUFFER_SIZE       64
 struct klsi_105_private {
        struct klsi_105_port_settings   cfg;
-       struct termios                  termios;
+       struct ktermios                 termios;
        unsigned long                   line_state; /* modem line settings */
        /* write pool */
        struct urb *                    write_urb_pool[NUM_URBS];
@@ -688,7 +688,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb)
 
 
 static void klsi_105_set_termios (struct usb_serial_port *port,
-                                 struct termios *old_termios)
+                                 struct ktermios *old_termios)
 {
        struct klsi_105_private *priv = usb_get_serial_port_data(port);
        unsigned int iflag = port->tty->termios->c_iflag;
index 237289920f03deb7438cda346fbd54966dd34d80..e284d6c0fd35b03f5f42c97ff6af5358463bd1a3 100644 (file)
@@ -136,7 +136,7 @@ struct kobil_private {
        int cur_pos; // index of the next char to send in buf
        __u16 device_type;
        int line_state;
-       struct termios internal_termios;
+       struct ktermios internal_termios;
 };
 
 
@@ -624,11 +624,11 @@ static int  kobil_ioctl(struct usb_serial_port *port, struct file *file,
 
        switch (cmd) {
        case TCGETS:   // 0x5401
-               if (!access_ok(VERIFY_WRITE, user_arg, sizeof(struct termios))) {
+               if (!access_ok(VERIFY_WRITE, user_arg, sizeof(struct ktermios))) {
                        dbg("%s - port %d Error in access_ok", __FUNCTION__, port->number);
                        return -EFAULT;
                }
-               if (kernel_termios_to_user_termios((struct termios __user *)arg,
+               if (kernel_termios_to_user_termios((struct ktermios __user *)arg,
                                                   &priv->internal_termios))
                        return -EFAULT;
                return 0;
@@ -638,12 +638,12 @@ static int  kobil_ioctl(struct usb_serial_port *port, struct file *file,
                        dbg("%s - port %d Error: port->tty->termios is NULL", __FUNCTION__, port->number);
                        return -ENOTTY;
                }
-               if (!access_ok(VERIFY_READ, user_arg, sizeof(struct termios))) {
+               if (!access_ok(VERIFY_READ, user_arg, sizeof(struct ktermios))) {
                        dbg("%s - port %d Error in access_ok", __FUNCTION__, port->number);
                        return -EFAULT;
                }
                if (user_termios_to_kernel_termios(&priv->internal_termios,
-                                                  (struct termios __user *)arg))
+                                                  (struct ktermios __user *)arg))
                        return -EFAULT;
                
                settings = kzalloc(50, GFP_KERNEL);
index a906e500a02b0748a7e73f2a4e582a498ddda579..38b1d17e06ef797149f74fc32b9dde2d3225f7c5 100644 (file)
@@ -98,7 +98,7 @@ static void mct_u232_close             (struct usb_serial_port *port,
                                          struct file *filp);
 static void mct_u232_read_int_callback   (struct urb *urb);
 static void mct_u232_set_termios         (struct usb_serial_port *port,
-                                         struct termios * old);
+                                         struct ktermios * old);
 static int  mct_u232_ioctl              (struct usb_serial_port *port,
                                          struct file * file,
                                          unsigned int cmd,
@@ -556,7 +556,7 @@ exit:
 } /* mct_u232_read_int_callback */
 
 static void mct_u232_set_termios (struct usb_serial_port *port,
-                                 struct termios *old_termios)
+                                 struct ktermios *old_termios)
 {
        struct usb_serial *serial = port->serial;
        struct mct_u232_private *priv = usb_get_serial_port_data(port);
index 82cd15b894b0ffebb6d98fe02801c14f0e160eab..e55f4ed81d7bc3344a21b119f6e941b54c074d0c 100644 (file)
@@ -363,7 +363,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
 
        /* Initialising the write urb pool */
        for (j = 0; j < NUM_URBS; ++j) {
-               urb = usb_alloc_urb(0,SLAB_ATOMIC);
+               urb = usb_alloc_urb(0,GFP_ATOMIC);
                mos7720_port->write_urb_pool[j] = urb;
 
                if (urb == NULL) {
@@ -1014,7 +1014,7 @@ static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port,
  *      the specified new settings.
  */
 static void change_port_settings(struct moschip_port *mos7720_port,
-                                struct termios *old_termios)
+                                struct ktermios *old_termios)
 {
        struct usb_serial_port *port;
        struct usb_serial *serial;
@@ -1203,7 +1203,7 @@ static void change_port_settings(struct moschip_port *mos7720_port,
  *     termios structure.
  */
 static void mos7720_set_termios(struct usb_serial_port *port,
-                               struct termios *old_termios)
+                               struct ktermios *old_termios)
 {
        int status;
        unsigned int cflag;
index 02c89e10b2cf103752c72d993d3aa7cf2cfd98b5..8cc728a49e41fce1b644e42507c2106491bc6ac6 100644 (file)
@@ -826,7 +826,7 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
 
        /* Initialising the write urb pool */
        for (j = 0; j < NUM_URBS; ++j) {
-               urb = usb_alloc_urb(0, SLAB_ATOMIC);
+               urb = usb_alloc_urb(0, GFP_ATOMIC);
                mos7840_port->write_urb_pool[j] = urb;
 
                if (urb == NULL) {
@@ -1931,7 +1931,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
  *****************************************************************************/
 
 static void mos7840_change_port_settings(struct moschip_port *mos7840_port,
-                                        struct termios *old_termios)
+                                        struct ktermios *old_termios)
 {
        struct tty_struct *tty;
        int baud;
@@ -2118,7 +2118,7 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port,
  *****************************************************************************/
 
 static void mos7840_set_termios(struct usb_serial_port *port,
-                               struct termios *old_termios)
+                               struct ktermios *old_termios)
 {
        int status;
        unsigned int cflag;
@@ -2786,7 +2786,7 @@ static int mos7840_startup(struct usb_serial *serial)
                                    i + 1, status);
 
                }
-               mos7840_port->control_urb = usb_alloc_urb(0, SLAB_ATOMIC);
+               mos7840_port->control_urb = usb_alloc_urb(0, GFP_ATOMIC);
                mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL);
 
        }
index 130afbbd3fca6c97b9e8c9400961b1583eca6c72..0ae4098718c360601976de27738cad3264b5a0c0 100644 (file)
@@ -59,7 +59,7 @@ static int  option_chars_in_buffer(struct usb_serial_port *port);
 static int  option_ioctl(struct usb_serial_port *port, struct file *file,
                        unsigned int cmd, unsigned long arg);
 static void option_set_termios(struct usb_serial_port *port,
-                               struct termios *old);
+                               struct ktermios *old);
 static void option_break_ctl(struct usb_serial_port *port, int break_state);
 static int  option_tiocmget(struct usb_serial_port *port, struct file *file);
 static int  option_tiocmset(struct usb_serial_port *port, struct file *file,
@@ -230,7 +230,7 @@ static void option_break_ctl(struct usb_serial_port *port, int break_state)
 }
 
 static void option_set_termios(struct usb_serial_port *port,
-                       struct termios *old_termios)
+                       struct ktermios *old_termios)
 {
        dbg("%s", __FUNCTION__);
 
index bc800c8787a87a1bc048ae225abd2e695ee3e07b..d124d780e42e27703216908337f011094d181c4c 100644 (file)
@@ -455,7 +455,7 @@ static int pl2303_chars_in_buffer(struct usb_serial_port *port)
 }
 
 static void pl2303_set_termios(struct usb_serial_port *port,
-                              struct termios *old_termios)
+                              struct ktermios *old_termios)
 {
        struct usb_serial *serial = port->serial;
        struct pl2303_private *priv = usb_get_serial_port_data(port);
@@ -687,7 +687,7 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp)
 
 static int pl2303_open(struct usb_serial_port *port, struct file *filp)
 {
-       struct termios tmp_termios;
+       struct ktermios tmp_termios;
        struct usb_serial *serial = port->serial;
        struct pl2303_private *priv = usb_get_serial_port_data(port);
        unsigned char *buf;
index 4b5097fa48d726cbeb7e66e8b8a45840fedda1a3..6d8e91e00ecff4031613cdb9a1adbf438bf855ef 100644 (file)
@@ -145,7 +145,7 @@ static void sierra_break_ctl(struct usb_serial_port *port, int break_state)
 }
 
 static void sierra_set_termios(struct usb_serial_port *port,
-                       struct termios *old_termios)
+                       struct ktermios *old_termios)
 {
        dbg("%s", __FUNCTION__);
 
index ae98d8cbdbb8712f2b214f5192193ba75a6017bf..f42eb9ea64052a1a9d6dc90ee59966fc392a9c90 100644 (file)
@@ -161,7 +161,7 @@ static void ti_throttle(struct usb_serial_port *port);
 static void ti_unthrottle(struct usb_serial_port *port);
 static int ti_ioctl(struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg);
 static void ti_set_termios(struct usb_serial_port *port,
-       struct termios *old_termios);
+       struct ktermios *old_termios);
 static int ti_tiocmget(struct usb_serial_port *port, struct file *file);
 static int ti_tiocmset(struct usb_serial_port *port, struct file *file,
        unsigned int set, unsigned int clear);
@@ -881,7 +881,7 @@ static int ti_ioctl(struct usb_serial_port *port, struct file *file,
 
 
 static void ti_set_termios(struct usb_serial_port *port,
-       struct termios *old_termios)
+       struct ktermios *old_termios)
 {
        struct ti_port *tport = usb_get_serial_port_data(port);
        struct tty_struct *tty = port->tty;
index 3d5072f14b8d049081fbc2c88fad03bb157f6e9b..716f6806cc8902e055a7af4298e554e0512dcbc6 100644 (file)
@@ -397,7 +397,7 @@ exit:
        return retval;
 }
 
-static void serial_set_termios (struct tty_struct *tty, struct termios * old)
+static void serial_set_termios (struct tty_struct *tty, struct ktermios * old)
 {
        struct usb_serial_port *port = tty->driver_data;
 
index eef5eaa5fa0bae67ebb82648cc20af507d29b226..b09f06096056f211ed129d54b2ef9b17ac43dc53 100644 (file)
@@ -46,7 +46,7 @@ static int  visor_probe               (struct usb_serial *serial, const struct usb_device_id
 static int  visor_calc_num_ports(struct usb_serial *serial);
 static void visor_shutdown     (struct usb_serial *serial);
 static int  visor_ioctl                (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
-static void visor_set_termios  (struct usb_serial_port *port, struct termios *old_termios);
+static void visor_set_termios  (struct usb_serial_port *port, struct ktermios *old_termios);
 static void visor_write_bulk_callback  (struct urb *urb);
 static void visor_read_bulk_callback   (struct urb *urb);
 static void visor_read_int_callback    (struct urb *urb);
@@ -916,7 +916,7 @@ static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsign
 
 
 /* This function is all nice and good, but we don't change anything based on it :) */
-static void visor_set_termios (struct usb_serial_port *port, struct termios *old_termios)
+static void visor_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
 {
        unsigned int cflag;
 
index 154c7d290597776b82b9ec076db976b4eff228e6..dc45e58e2b8c88892e92bcecacc5fdba32a839ee 100644 (file)
@@ -145,7 +145,7 @@ static void whiteheat_close         (struct usb_serial_port *port, struct file *filp);
 static int  whiteheat_write            (struct usb_serial_port *port, const unsigned char *buf, int count);
 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 void whiteheat_set_termios      (struct usb_serial_port *port, struct ktermios * 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);
@@ -597,7 +597,7 @@ static void whiteheat_shutdown (struct usb_serial *serial)
 static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
 {
        int             retval = 0;
-       struct termios  old_term;
+       struct ktermios old_term;
 
        dbg("%s - port %d", __FUNCTION__, port->number);
 
@@ -870,7 +870,7 @@ static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, un
 }
 
 
-static void whiteheat_set_termios (struct usb_serial_port *port, struct termios *old_termios)
+static void whiteheat_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
 {
        dbg("%s -port %d", __FUNCTION__, port->number);
 
index 3a158d58441fc380d3997005e8ea27f58b8c57df..e565d3d2ab2909088bf7dde1d1372fb57fb7b25f 100644 (file)
@@ -76,7 +76,7 @@ static void usb_onetouch_irq(struct urb *urb)
        input_sync(dev);
 
 resubmit:
-       status = usb_submit_urb (urb, SLAB_ATOMIC);
+       status = usb_submit_urb (urb, GFP_ATOMIC);
        if (status)
                err ("can't resubmit intr, %s-%s/input0, status %d",
                        onetouch->udev->bus->bus_name,
@@ -154,7 +154,7 @@ int onetouch_connect_input(struct us_data *ss)
                goto fail1;
 
        onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN,
-                                         SLAB_ATOMIC, &onetouch->data_dma);
+                                         GFP_ATOMIC, &onetouch->data_dma);
        if (!onetouch->data)
                goto fail1;
 
index 47644b5b61553c4082257aa8cd4763587375c197..323293a3e61f08936ab16fcbc9820fdcc9056492 100644 (file)
@@ -427,7 +427,7 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
        US_DEBUGP("%s: xfer %u bytes, %d entries\n", __FUNCTION__,
                        length, num_sg);
        result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0,
-                       sg, num_sg, length, SLAB_NOIO);
+                       sg, num_sg, length, GFP_NOIO);
        if (result) {
                US_DEBUGP("usb_sg_init returned %d\n", result);
                return USB_STOR_XFER_ERROR;
index b401084b3d223a01061c3c24562b0e05cd2941dd..70644506651f2bf58042ea9f1c5707145c3cb5c9 100644 (file)
@@ -49,7 +49,7 @@
 
 #include <linux/sched.h>
 #include <linux/errno.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/slab.h>
index 7a43020fa5835136ced2b4826ac3cffdd7823efb..ab1daecfeac6e1b3c9513094cfe0f3756197add1 100644 (file)
@@ -541,6 +541,7 @@ config FB_TGA
        select FB_CFB_FILLRECT
        select FB_CFB_COPYAREA
        select FB_CFB_IMAGEBLIT
+       select BITREVERSE
        help
          This is the frame buffer device driver for generic TGA graphic
          cards. Say Y if you have one of those.
@@ -551,6 +552,7 @@ config FB_VESA
        select FB_CFB_FILLRECT
        select FB_CFB_COPYAREA
        select FB_CFB_IMAGEBLIT
+       select VIDEO_SELECT
        help
          This is the frame buffer device driver for generic VESA 2.0
          compliant graphic cards. The older VESA 1.2 cards are not supported.
@@ -705,6 +707,7 @@ config FB_NVIDIA
        select FB_CFB_FILLRECT
        select FB_CFB_COPYAREA
        select FB_CFB_IMAGEBLIT
+       select BITREVERSE
        help
          This driver supports graphics boards with the nVidia chips, TNT
          and newer. For very old chipsets, such as the RIVA128, then use
@@ -744,6 +747,7 @@ config FB_RIVA
        select FB_CFB_FILLRECT
        select FB_CFB_COPYAREA
        select FB_CFB_IMAGEBLIT
+       select BITREVERSE
        help
          This driver supports graphics boards with the nVidia Riva/Geforce
          chips.
index 397005eb392df2ff5e2044f54df3bb99cb029962..b3717c8f1bc2b474585b4c8afff35c6b7a2f1f2c 100644 (file)
@@ -535,8 +535,11 @@ static void __init s3triofb_of_init(struct device_node *dp)
 #endif
 
     fb_info.flags = FBINFO_FLAG_DEFAULT;
-    if (register_framebuffer(&fb_info) < 0)
-       return;
+    if (register_framebuffer(&fb_info) < 0) {
+               iounmap(fb_info.screen_base);
+               fb_info.screen_base = NULL;
+               return;
+    }
 
     printk("fb%d: S3 Trio frame buffer device on %s\n",
           fb_info.node, dp->full_name);
index a4e3fca058919ba2373e449d8910e6c2a1724984..88a47845c4f7db713a9960948ffbbf9fa29155dd 100644 (file)
@@ -2407,10 +2407,10 @@ default_chipset:
                                                   fb_info.fix.smem_len);
        if (!videomemory) {
                printk("amifb: WARNING! unable to map videomem cached writethrough\n");
-               videomemory = ZTWO_VADDR(fb_info.fix.smem_start);
-       }
+               fb_info.screen_base = (char *)ZTWO_VADDR(fb_info.fix.smem_start);
+       } else
+               fb_info.screen_base = (char *)videomemory;
 
-       fb_info.screen_base = (char *)videomemory;
        memset(dummysprite, 0, DUMMYSPRITEMEMSIZE);
 
        /*
@@ -2453,6 +2453,8 @@ static void amifb_deinit(void)
 {
        fb_dealloc_cmap(&fb_info.cmap);
        chipfree();
+       if (videomemory)
+               iounmap((void*)videomemory);
        release_mem_region(CUSTOM_PHYSADDR+0xe0, 0x120);
        custom.dmacon = DMAF_ALL | DMAF_MASTER;
 }
index ab34b96acc317b659b32616e09e228911f0638a3..30a8369757e7ceca4b2a82ef49c98f7f9cb05cf3 100644 (file)
@@ -454,7 +454,7 @@ static ssize_t arcfb_write(struct file *file, const char __user *buf, size_t cou
        unsigned int xres;
 
        p = *ppos;
-       inode = file->f_dentry->d_inode;
+       inode = file->f_path.dentry->d_inode;
        fbidx = iminor(inode);
        info = registered_fb[fbidx];
 
index 02c41a626fa25c2fa5d280e527fb3f8e6236ff71..602db660bc73d7bb2ef41a8246bd05e10afdd609 100644 (file)
@@ -2804,8 +2804,19 @@ int __init atafb_init(void)
        atafb_set_disp(-1, &fb_info);
        do_install_cmap(0, &fb_info);
 
-       if (register_framebuffer(&fb_info) < 0)
+       if (register_framebuffer(&fb_info) < 0) {
+#ifdef ATAFB_EXT
+               if (external_addr) {
+                       iounmap(external_addr);
+                       external_addr = NULL;
+               }
+               if (external_vgaiobase) {
+                       iounmap((void*)external_vgaiobase);
+                       external_vgaiobase = 0;
+               }
+#endif
                return -EINVAL;
+       }
 
        printk("Determined %dx%d, depth %d\n",
               disp.var.xres, disp.var.yres, disp.var.bits_per_pixel);
index 276a21530b9527c4e5dbf1d4624ea116488f5163..3feddf89d100b881bf75aa69aa2be55fa8bc42be 100644 (file)
@@ -1333,6 +1333,8 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll,
        if (vclk * 12 < c.ppll_min)
                vclk = c.ppll_min/12;
 
+       pll->post_divider = -1;
+
        /* now, find an acceptable divider */
        for (i = 0; i < sizeof(post_dividers); i++) {
                output_freq = post_dividers[i] * vclk;
@@ -1342,6 +1344,9 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll,
                }
        }
 
+       if (pll->post_divider < 0)
+               return -EINVAL;
+
        /* calculate feedback divider */
        n = c.ref_divider * output_freq;
        d = c.ref_clk;
index b04f49fb976ac3fe72d1f6d9bb955afccda1b012..f72faff33c0ce2048ffd8f0831da661958a16b52 100644 (file)
@@ -126,7 +126,6 @@ union aty_pll {
      */
 
 struct atyfb_par {
-       struct aty_cmap_regs __iomem *aty_cmap_regs;
        struct { u8 red, green, blue; } palette[256];
        const struct aty_dac_ops *dac_ops;
        const struct aty_pll_ops *pll_ops;
@@ -186,6 +185,7 @@ struct atyfb_par {
        int mtrr_aper;
        int mtrr_reg;
 #endif
+       u32 mem_cntl;
 };
 
     /*
@@ -227,7 +227,7 @@ static inline u32 aty_ld_le32(int regindex, const struct atyfb_par *par)
                regindex -= 0x800;
 
 #ifdef CONFIG_ATARI
-       return in_le32((volatile u32 *)(par->ati_regbase + regindex));
+       return in_le32(par->ati_regbase + regindex);
 #else
        return readl(par->ati_regbase + regindex);
 #endif
@@ -240,7 +240,7 @@ static inline void aty_st_le32(int regindex, u32 val, const struct atyfb_par *pa
                regindex -= 0x800;
 
 #ifdef CONFIG_ATARI
-       out_le32((volatile u32 *)(par->ati_regbase + regindex), val);
+       out_le32(par->ati_regbase + regindex, val);
 #else
        writel(val, par->ati_regbase + regindex);
 #endif
@@ -253,7 +253,7 @@ static inline void aty_st_le16(int regindex, u16 val,
        if (regindex >= 0x400)
                regindex -= 0x800;
 #ifdef CONFIG_ATARI
-       out_le16((volatile u16 *)(par->ati_regbase + regindex), val);
+       out_le16(par->ati_regbase + regindex, val);
 #else
        writel(val, par->ati_regbase + regindex);
 #endif
@@ -315,6 +315,7 @@ struct aty_pll_ops {
        void (*set_pll)   (const struct fb_info * info, const union aty_pll * pll);
        void (*get_pll)   (const struct fb_info *info, union aty_pll * pll);
        int (*init_pll)   (const struct fb_info * info, union aty_pll * pll);
+       void (*resume_pll)(const struct fb_info *info, union aty_pll *pll);
 };
 
 extern const struct aty_pll_ops aty_pll_ati18818_1; /* ATI 18818 */
index e815b354c09df1f57ba5fa83bab29706ff6029f9..176f9b85cdbebbc3f3d32dafc450c8d54adf1952 100644 (file)
@@ -203,14 +203,6 @@ static void ATIReduceRatio(int *Numerator, int *Denominator)
      *  The Hardware parameters for each card
      */
 
-struct aty_cmap_regs {
-       u8 windex;
-       u8 lut;
-       u8 mask;
-       u8 rindex;
-       u8 cntl;
-};
-
 struct pci_mmap_map {
        unsigned long voff;
        unsigned long poff;
@@ -249,7 +241,8 @@ static int atyfb_sync(struct fb_info *info);
      *  Internal routines
      */
 
-static int aty_init(struct fb_info *info, const char *name);
+static int aty_init(struct fb_info *info);
+static void aty_resume_chip(struct fb_info *info);
 #ifdef CONFIG_ATARI
 static int store_video_par(char *videopar, unsigned char m64_num);
 #endif
@@ -1937,17 +1930,14 @@ static void atyfb_save_palette(struct atyfb_par *par, int enter)
                aty_st_8(DAC_CNTL, tmp, par);
                aty_st_8(DAC_MASK, 0xff, par);
 
-               writeb(i, &par->aty_cmap_regs->rindex);
-               atyfb_save.r[enter][i] = readb(&par->aty_cmap_regs->lut);
-               atyfb_save.g[enter][i] = readb(&par->aty_cmap_regs->lut);
-               atyfb_save.b[enter][i] = readb(&par->aty_cmap_regs->lut);
-               writeb(i, &par->aty_cmap_regs->windex);
-               writeb(atyfb_save.r[1 - enter][i],
-                      &par->aty_cmap_regs->lut);
-               writeb(atyfb_save.g[1 - enter][i],
-                      &par->aty_cmap_regs->lut);
-               writeb(atyfb_save.b[1 - enter][i],
-                      &par->aty_cmap_regs->lut);
+               aty_st_8(DAC_R_INDEX, i, par);
+               atyfb_save.r[enter][i] = aty_ld_8(DAC_DATA, par);
+               atyfb_save.g[enter][i] = aty_ld_8(DAC_DATA, par);
+               atyfb_save.b[enter][i] = aty_ld_8(DAC_DATA, par);
+               aty_st_8(DAC_W_INDEX, i, par);
+               aty_st_8(DAC_DATA, atyfb_save.r[1 - enter][i], par);
+               aty_st_8(DAC_DATA, atyfb_save.g[1 - enter][i], par);
+               aty_st_8(DAC_DATA, atyfb_save.b[1 - enter][i], par);
        }
 }
 
@@ -1982,6 +1972,7 @@ static void atyfb_palette(int enter)
 
 #if defined(CONFIG_PM) && defined(CONFIG_PCI)
 
+#ifdef CONFIG_PPC_PMAC
 /* Power management routines. Those are used for PowerBook sleep.
  */
 static int aty_power_mgmt(int sleep, struct atyfb_par *par)
@@ -2038,21 +2029,13 @@ static int aty_power_mgmt(int sleep, struct atyfb_par *par)
 
        return timeout ? 0 : -EIO;
 }
+#endif
 
 static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 {
        struct fb_info *info = pci_get_drvdata(pdev);
        struct atyfb_par *par = (struct atyfb_par *) info->par;
 
-#ifndef CONFIG_PPC_PMAC
-       /* HACK ALERT ! Once I find a proper way to say to each driver
-        * individually what will happen with it's PCI slot, I'll change
-        * that. On laptops, the AGP slot is just unclocked, so D2 is
-        * expected, while on desktops, the card is powered off
-        */
-       return 0;
-#endif /* CONFIG_PPC_PMAC */
-
        if (state.event == pdev->dev.power.power_state.event)
                return 0;
 
@@ -2070,6 +2053,7 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
        par->asleep = 1;
        par->lock_blank = 1;
 
+#ifdef CONFIG_PPC_PMAC
        /* Set chip to "suspend" mode */
        if (aty_power_mgmt(1, par)) {
                par->asleep = 0;
@@ -2079,6 +2063,9 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
                release_console_sem();
                return -EIO;
        }
+#else
+       pci_set_power_state(pdev, pci_choose_state(pdev, state));
+#endif
 
        release_console_sem();
 
@@ -2097,8 +2084,15 @@ static int atyfb_pci_resume(struct pci_dev *pdev)
 
        acquire_console_sem();
 
+#ifdef CONFIG_PPC_PMAC
        if (pdev->dev.power.power_state.event == 2)
                aty_power_mgmt(0, par);
+#else
+       pci_set_power_state(pdev, PCI_D0);
+#endif
+
+       aty_resume_chip(info);
+
        par->asleep = 0;
 
        /* Restore display */
@@ -2344,24 +2338,16 @@ static int __devinit atyfb_get_timings_from_lcd(struct atyfb_par *par,
 }
 #endif /* defined(__i386__) && defined(CONFIG_FB_ATY_GENERIC_LCD) */
 
-static int __devinit aty_init(struct fb_info *info, const char *name)
+static int __devinit aty_init(struct fb_info *info)
 {
        struct atyfb_par *par = (struct atyfb_par *) info->par;
        const char *ramname = NULL, *xtal;
        int gtb_memsize, has_var = 0;
        struct fb_var_screeninfo var;
-       u8 pll_ref_div;
-       u32 i;
-#if defined(CONFIG_PPC)
-       int sense;
-#endif
 
        init_waitqueue_head(&par->vblank.wait);
        spin_lock_init(&par->int_lock);
 
-       par->aty_cmap_regs =
-           (struct aty_cmap_regs __iomem *) (par->ati_regbase + 0xc0);
-
 #ifdef CONFIG_PPC_PMAC
        /* The Apple iBook1 uses non-standard memory frequencies. We detect it
         * and set the frequency manually. */
@@ -2464,18 +2450,21 @@ static int __devinit aty_init(struct fb_info *info, const char *name)
                        par->pll_limits.mclk = 63;
        }
 
-       if (M64_HAS(GTB_DSP)
-           && (pll_ref_div = aty_ld_pll_ct(PLL_REF_DIV, par))) {
-               int diff1, diff2;
-               diff1 = 510 * 14 / pll_ref_div - par->pll_limits.pll_max;
-               diff2 = 510 * 29 / pll_ref_div - par->pll_limits.pll_max;
-               if (diff1 < 0)
-                       diff1 = -diff1;
-               if (diff2 < 0)
-                       diff2 = -diff2;
-               if (diff2 < diff1) {
-                       par->ref_clk_per = 1000000000000ULL / 29498928;
-                       xtal = "29.498928";
+       if (M64_HAS(GTB_DSP)) {
+               u8 pll_ref_div = aty_ld_pll_ct(PLL_REF_DIV, par);
+
+               if (pll_ref_div) {
+                       int diff1, diff2;
+                       diff1 = 510 * 14 / pll_ref_div - par->pll_limits.pll_max;
+                       diff2 = 510 * 29 / pll_ref_div - par->pll_limits.pll_max;
+                       if (diff1 < 0)
+                               diff1 = -diff1;
+                       if (diff2 < 0)
+                               diff2 = -diff2;
+                       if (diff2 < diff1) {
+                               par->ref_clk_per = 1000000000000ULL / 29498928;
+                               xtal = "29.498928";
+                       }
                }
        }
 #endif /* CONFIG_FB_ATY_CT */
@@ -2485,10 +2474,10 @@ static int __devinit aty_init(struct fb_info *info, const char *name)
        if(par->pll_ops->get_pll)
                par->pll_ops->get_pll(info, &saved_pll);
 
-       i = aty_ld_le32(MEM_CNTL, par);
+       par->mem_cntl = aty_ld_le32(MEM_CNTL, par);
        gtb_memsize = M64_HAS(GTB_DSP);
        if (gtb_memsize)
-               switch (i & 0xF) {      /* 0xF used instead of MEM_SIZE_ALIAS */
+               switch (par->mem_cntl & 0xF) {  /* 0xF used instead of MEM_SIZE_ALIAS */
                case MEM_SIZE_512K:
                        info->fix.smem_len = 0x80000;
                        break;
@@ -2510,7 +2499,7 @@ static int __devinit aty_init(struct fb_info *info, const char *name)
                default:
                        info->fix.smem_len = 0x80000;
        } else
-               switch (i & MEM_SIZE_ALIAS) {
+               switch (par->mem_cntl & MEM_SIZE_ALIAS) {
                case MEM_SIZE_512K:
                        info->fix.smem_len = 0x80000;
                        break;
@@ -2540,20 +2529,20 @@ static int __devinit aty_init(struct fb_info *info, const char *name)
 
        if (vram) {
                info->fix.smem_len = vram * 1024;
-               i = i & ~(gtb_memsize ? 0xF : MEM_SIZE_ALIAS);
+               par->mem_cntl &= ~(gtb_memsize ? 0xF : MEM_SIZE_ALIAS);
                if (info->fix.smem_len <= 0x80000)
-                       i |= MEM_SIZE_512K;
+                       par->mem_cntl |= MEM_SIZE_512K;
                else if (info->fix.smem_len <= 0x100000)
-                       i |= MEM_SIZE_1M;
+                       par->mem_cntl |= MEM_SIZE_1M;
                else if (info->fix.smem_len <= 0x200000)
-                       i |= gtb_memsize ? MEM_SIZE_2M_GTB : MEM_SIZE_2M;
+                       par->mem_cntl |= gtb_memsize ? MEM_SIZE_2M_GTB : MEM_SIZE_2M;
                else if (info->fix.smem_len <= 0x400000)
-                       i |= gtb_memsize ? MEM_SIZE_4M_GTB : MEM_SIZE_4M;
+                       par->mem_cntl |= gtb_memsize ? MEM_SIZE_4M_GTB : MEM_SIZE_4M;
                else if (info->fix.smem_len <= 0x600000)
-                       i |= gtb_memsize ? MEM_SIZE_6M_GTB : MEM_SIZE_6M;
+                       par->mem_cntl |= gtb_memsize ? MEM_SIZE_6M_GTB : MEM_SIZE_6M;
                else
-                       i |= gtb_memsize ? MEM_SIZE_8M_GTB : MEM_SIZE_8M;
-               aty_st_le32(MEM_CNTL, i, par);
+                       par->mem_cntl |= gtb_memsize ? MEM_SIZE_8M_GTB : MEM_SIZE_8M;
+               aty_st_le32(MEM_CNTL, par->mem_cntl, par);
        }
 
        /*
@@ -2599,11 +2588,12 @@ static int __devinit aty_init(struct fb_info *info, const char *name)
 #endif
        if(par->pll_ops->init_pll)
                par->pll_ops->init_pll(info, &par->pll);
+       if (par->pll_ops->resume_pll)
+               par->pll_ops->resume_pll(info, &par->pll);
 
        /*
-        *  Last page of 8 MB (4 MB on ISA) aperture is MMIO
-        *  FIXME: we should use the auxiliary aperture instead so we can access
-        *  the full 8 MB of video RAM on 8 MB boards
+        *  Last page of 8 MB (4 MB on ISA) aperture is MMIO,
+        *  unless the auxiliary register aperture is used.
         */
 
        if (!par->aux_start &&
@@ -2669,6 +2659,7 @@ static int __devinit aty_init(struct fb_info *info, const char *name)
                                has_var = 1;
                } else {
                        if (default_vmode == VMODE_CHOOSE) {
+                               int sense;
                                if (M64_HAS(G3_PB_1024x768))
                                        /* G3 PowerBook with 1024x768 LCD */
                                        default_vmode = VMODE_1024_768_60;
@@ -2749,7 +2740,7 @@ static int __devinit aty_init(struct fb_info *info, const char *name)
        fb_list = info;
 
        PRINTKI("fb%d: %s frame buffer device on %s\n",
-              info->node, info->fix.id, name);
+               info->node, info->fix.id, par->bus_type == ISA ? "ISA" : "PCI");
        return 0;
 
 aty_init_exit:
@@ -2770,6 +2761,19 @@ aty_init_exit:
        return -1;
 }
 
+static void aty_resume_chip(struct fb_info *info)
+{
+       struct atyfb_par *par = info->par;
+
+       aty_st_le32(MEM_CNTL, par->mem_cntl, par);
+
+       if (par->pll_ops->resume_pll)
+               par->pll_ops->resume_pll(info, &par->pll);
+
+       if (par->aux_start)
+               aty_st_le32(BUS_CNTL, aty_ld_le32(BUS_CNTL, par) | BUS_APER_REG_DIS, par);
+}
+
 #ifdef CONFIG_ATARI
 static int __devinit store_video_par(char *video_str, unsigned char m64_num)
 {
@@ -2826,9 +2830,9 @@ static int atyfb_blank(int blank, struct fb_info *info)
 #endif
 
        gen_cntl = aty_ld_le32(CRTC_GEN_CNTL, par);
+       gen_cntl &= ~0x400004c;
        switch (blank) {
-               case FB_BLANK_UNBLANK:
-                       gen_cntl &= ~0x400004c;
+               case FB_BLANK_UNBLANK:
                        break;
                case FB_BLANK_NORMAL:
                        gen_cntl |= 0x4000040;
@@ -2863,17 +2867,10 @@ static int atyfb_blank(int blank, struct fb_info *info)
 static void aty_st_pal(u_int regno, u_int red, u_int green, u_int blue,
                       const struct atyfb_par *par)
 {
-#ifdef CONFIG_ATARI
-       out_8(&par->aty_cmap_regs->windex, regno);
-       out_8(&par->aty_cmap_regs->lut, red);
-       out_8(&par->aty_cmap_regs->lut, green);
-       out_8(&par->aty_cmap_regs->lut, blue);
-#else
-       writeb(regno, &par->aty_cmap_regs->windex);
-       writeb(red, &par->aty_cmap_regs->lut);
-       writeb(green, &par->aty_cmap_regs->lut);
-       writeb(blue, &par->aty_cmap_regs->lut);
-#endif
+       aty_st_8(DAC_W_INDEX, regno, par);
+       aty_st_8(DAC_DATA, red, par);
+       aty_st_8(DAC_DATA, green, par);
+       aty_st_8(DAC_DATA, blue, par);
 }
 
     /*
@@ -3182,7 +3179,7 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev,
 
 #ifdef __i386__
 #ifdef CONFIG_FB_ATY_GENERIC_LCD
-static void aty_init_lcd(struct atyfb_par *par, u32 bios_base)
+static void __devinit aty_init_lcd(struct atyfb_par *par, u32 bios_base)
 {
        u32 driv_inf_tab, sig;
        u16 lcd_ofs;
@@ -3527,6 +3524,10 @@ static int __devinit atyfb_setup_generic(struct pci_dev *pdev, struct fb_info *i
 atyfb_setup_generic_fail:
        iounmap(par->ati_regbase);
        par->ati_regbase = NULL;
+       if (info->screen_base) {
+               iounmap(info->screen_base);
+               info->screen_base = NULL;
+       }
        return ret;
 }
 
@@ -3594,7 +3595,7 @@ static int __devinit atyfb_pci_probe(struct pci_dev *pdev, const struct pci_devi
        pci_set_drvdata(pdev, info);
 
        /* Init chip & register framebuffer */
-       if (aty_init(info, "PCI"))
+       if (aty_init(info))
                goto err_release_io;
 
 #ifdef __sparc__
@@ -3641,12 +3642,13 @@ err_release_mem:
 
 #ifdef CONFIG_ATARI
 
-static int __devinit atyfb_atari_probe(void)
+static int __init atyfb_atari_probe(void)
 {
        struct atyfb_par *par;
        struct fb_info *info;
        int m64_num;
        u32 clock_r;
+       int num_found = 0;
 
        for (m64_num = 0; m64_num < mach64_count; m64_num++) {
                if (!phys_vmembase[m64_num] || !phys_size[m64_num] ||
@@ -3694,16 +3696,34 @@ static int __devinit atyfb_atari_probe(void)
                        break;
                }
 
-               if (aty_init(info, "ISA bus")) {
+               /* Fake pci_id for correct_chipset() */
+               switch (aty_ld_le32(CONFIG_CHIP_ID, par) & CFG_CHIP_TYPE) {
+               case 0x00d7:
+                       par->pci_id = PCI_CHIP_MACH64GX;
+                       break;
+               case 0x0057:
+                       par->pci_id = PCI_CHIP_MACH64CX;
+                       break;
+               default:
+                       break;
+               }
+
+               if (correct_chipset(par) || aty_init(info)) {
+                       iounmap(info->screen_base);
+                       iounmap(par->ati_regbase);
                        framebuffer_release(info);
-                       /* This is insufficient! kernel_map has added two large chunks!! */
-                       return -ENXIO;
+               } else {
+                       num_found++;
                }
        }
+
+       return num_found ? 0 : -ENXIO;
 }
 
 #endif /* CONFIG_ATARI */
 
+#ifdef CONFIG_PCI
+
 static void __devexit atyfb_remove(struct fb_info *info)
 {
        struct atyfb_par *par = (struct atyfb_par *) info->par;
@@ -3751,7 +3771,6 @@ static void __devexit atyfb_remove(struct fb_info *info)
        framebuffer_release(info);
 }
 
-#ifdef CONFIG_PCI
 
 static void __devexit atyfb_pci_remove(struct pci_dev *pdev)
 {
@@ -3786,7 +3805,7 @@ static struct pci_driver atyfb_driver = {
 #endif /* CONFIG_PCI */
 
 #ifndef MODULE
-static int __devinit atyfb_setup(char *options)
+static int __init atyfb_setup(char *options)
 {
        char *this_opt;
 
@@ -3858,7 +3877,7 @@ static int __devinit atyfb_setup(char *options)
 }
 #endif  /*  MODULE  */
 
-static int __devinit atyfb_init(void)
+static int __init atyfb_init(void)
 {
     int err1 = 1, err2 = 1;
 #ifndef MODULE
index 5080816be653de4802a523d364ef720d394d0808..f3b487b8710ba28725e1336b9fac6a2e0b1c7536 100644 (file)
@@ -370,8 +370,8 @@ void aty_set_pll_ct(const struct fb_info *info, const union aty_pll *pll)
 #endif
 }
 
-static void __init aty_get_pll_ct(const struct fb_info *info,
-                                 union aty_pll *pll)
+static void __devinit aty_get_pll_ct(const struct fb_info *info,
+                                    union aty_pll *pll)
 {
        struct atyfb_par *par = (struct atyfb_par *) info->par;
        u8 tmp, clock;
@@ -394,12 +394,12 @@ static void __init aty_get_pll_ct(const struct fb_info *info,
        }
 }
 
-static int __init aty_init_pll_ct(const struct fb_info *info,
-                                union aty_pll *pll)
+static int __devinit aty_init_pll_ct(const struct fb_info *info,
+                                    union aty_pll *pll)
 {
        struct atyfb_par *par = (struct atyfb_par *) info->par;
-       u8 mpost_div, xpost_div, sclk_post_div_real, sclk_fb_div, spll_cntl2;
-       u32 q, i, memcntl, trp;
+       u8 mpost_div, xpost_div, sclk_post_div_real;
+       u32 q, memcntl, trp;
        u32 dsp_config, dsp_on_off, vga_dsp_config, vga_dsp_on_off;
 #ifdef DEBUG
        int pllmclk, pllsclk;
@@ -575,14 +575,30 @@ static int __init aty_init_pll_ct(const struct fb_info *info,
                        mpost_div += (q <  32*8);
                }
                sclk_post_div_real = postdividers[mpost_div];
-               sclk_fb_div = q * sclk_post_div_real / 8;
-               spll_cntl2 = mpost_div << 4;
+               pll->ct.sclk_fb_div = q * sclk_post_div_real / 8;
+               pll->ct.spll_cntl2 = mpost_div << 4;
 #ifdef DEBUG
-               pllsclk = (1000000 * 2 * sclk_fb_div) /
+               pllsclk = (1000000 * 2 * pll->ct.sclk_fb_div) /
                        (par->ref_clk_per * pll->ct.pll_ref_div);
                printk("atyfb(%s): use sclk, pllsclk=%d MHz, sclk=mclk=%d MHz\n",
                        __FUNCTION__, pllsclk, pllsclk / sclk_post_div_real);
 #endif
+       }
+
+       /* Disable the extra precision pixel clock controls since we do not use them. */
+       pll->ct.ext_vpll_cntl = aty_ld_pll_ct(EXT_VPLL_CNTL, par);
+       pll->ct.ext_vpll_cntl &= ~(EXT_VPLL_EN | EXT_VPLL_VGA_EN | EXT_VPLL_INSYNC);
+
+       return 0;
+}
+
+static void aty_resume_pll_ct(const struct fb_info *info,
+                             union aty_pll *pll)
+{
+       struct atyfb_par *par = info->par;
+
+       if (par->mclk_per != par->xclk_per) {
+               int i;
                /*
                * This disables the sclk, crashes the computer as reported:
                * aty_st_pll_ct(SPLL_CNTL2, 3, info);
@@ -590,8 +606,8 @@ static int __init aty_init_pll_ct(const struct fb_info *info,
                * So it seems the sclk must be enabled before it is used;
                * so PLL_GEN_CNTL must be programmed *after* the sclk.
                */
-               aty_st_pll_ct(SCLK_FB_DIV, sclk_fb_div, par);
-               aty_st_pll_ct(SPLL_CNTL2, spll_cntl2, par);
+               aty_st_pll_ct(SCLK_FB_DIV, pll->ct.sclk_fb_div, par);
+               aty_st_pll_ct(SPLL_CNTL2, pll->ct.spll_cntl2, par);
                /*
                 * The sclk has been started. However, I believe the first clock
                 * ticks it generates are not very stable. Hope this primitive loop
@@ -605,11 +621,7 @@ static int __init aty_init_pll_ct(const struct fb_info *info,
        aty_st_pll_ct(PLL_GEN_CNTL, pll->ct.pll_gen_cntl, par);
        aty_st_pll_ct(MCLK_FB_DIV, pll->ct.mclk_fb_div, par);
        aty_st_pll_ct(PLL_EXT_CNTL, pll->ct.pll_ext_cntl, par);
-       /* Disable the extra precision pixel clock controls since we do not use them. */
-       aty_st_pll_ct(EXT_VPLL_CNTL, aty_ld_pll_ct(EXT_VPLL_CNTL, par) &
-               ~(EXT_VPLL_EN | EXT_VPLL_VGA_EN | EXT_VPLL_INSYNC), par);
-
-       return 0;
+       aty_st_pll_ct(EXT_VPLL_CNTL, pll->ct.ext_vpll_cntl, par);
 }
 
 static int dummy(void)
@@ -626,5 +638,6 @@ const struct aty_pll_ops aty_pll_ct = {
        .pll_to_var     = aty_pll_to_var_ct,
        .set_pll        = aty_set_pll_ct,
        .get_pll        = aty_get_pll_ct,
-       .init_pll       = aty_init_pll_ct
+       .init_pll       = aty_init_pll_ct,
+       .resume_pll     = aty_resume_pll_ct,
 };
index ea531a6f45d1f6ec29854a88a452dc0bba8646f5..38c7dbf8c151a72747602eae0b38027445b8e89c 100644 (file)
@@ -104,10 +104,9 @@ static int __devinit radeon_parse_montype_prop(struct device_node *dp, u8 **out_
        if (pedid == NULL)
                return mt;
 
-       tmp = (u8 *)kmalloc(EDID_LENGTH, GFP_KERNEL);
+       tmp = kmemdup(pedid, EDID_LENGTH, GFP_KERNEL);
        if (!tmp)
                return mt;
-       memcpy(tmp, pedid, EDID_LENGTH);
        *out_EDID = tmp;
        return mt;
 }
index 2855534dc235a1d74a1386caca59699fc263ad6e..164fe2f231ec6c9c575df9a2ddbf4547d2b53de1 100644 (file)
@@ -274,7 +274,7 @@ static struct au1100fb_panel known_lcd_panels[] =
                .bpp = 16,
                .control_base = 0x0004886A |
                        LCD_CONTROL_DEFAULT_PO | LCD_CONTROL_DEFAULT_SBPPF |
-                       LCD_CONTROL_BPP_16,
+                       LCD_CONTROL_BPP_16 | LCD_CONTROL_SBB_4,
                .clkcontrol_base = 0x00020000,
                .horztiming = 0x005aff1f,
                .verttiming = 0x16000e57,
index 27597c576eff3f4cb0a116dee1d682f8ce4f9383..db8c191b12013e941c1ab61cea7db7101763bdc0 100644 (file)
 #include <linux/err.h>
 #include <linux/fb.h>
 
+
+#if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
+                          defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE))
+/* This callback gets called when something important happens inside a
+ * framebuffer driver. We're looking if that important event is blanking,
+ * and if it is, we're switching backlight power as well ...
+ */
+static int fb_notifier_callback(struct notifier_block *self,
+                               unsigned long event, void *data)
+{
+       struct backlight_device *bd;
+       struct fb_event *evdata = data;
+
+       /* If we aren't interested in this event, skip it immediately ... */
+       if (event != FB_EVENT_BLANK)
+               return 0;
+
+       bd = container_of(self, struct backlight_device, fb_notif);
+       down(&bd->sem);
+       if (bd->props)
+               if (!bd->props->check_fb ||
+                   bd->props->check_fb(evdata->info)) {
+                       bd->props->fb_blank = *(int *)evdata->data;
+                       if (likely(bd->props && bd->props->update_status))
+                               bd->props->update_status(bd);
+               }
+       up(&bd->sem);
+       return 0;
+}
+
+static int backlight_register_fb(struct backlight_device *bd)
+{
+       memset(&bd->fb_notif, 0, sizeof(bd->fb_notif));
+       bd->fb_notif.notifier_call = fb_notifier_callback;
+
+       return fb_register_client(&bd->fb_notif);
+}
+
+static void backlight_unregister_fb(struct backlight_device *bd)
+{
+       fb_unregister_client(&bd->fb_notif);
+}
+#else
+static inline int backlight_register_fb(struct backlight_device *bd)
+{
+       return 0;
+}
+
+static inline void backlight_unregister_fb(struct backlight_device *bd)
+{
+}
+#endif /* CONFIG_FB */
+
 static ssize_t backlight_show_power(struct class_device *cdev, char *buf)
 {
        int rc = -ENXIO;
@@ -142,7 +195,7 @@ static struct class backlight_class = {
        .store  = _store,                                       \
 }
 
-static struct class_device_attribute bl_class_device_attributes[] = {
+static const struct class_device_attribute bl_class_device_attributes[] = {
        DECLARE_ATTR(power, 0644, backlight_show_power, backlight_store_power),
        DECLARE_ATTR(brightness, 0644, backlight_show_brightness,
                     backlight_store_brightness),
@@ -151,33 +204,6 @@ static struct class_device_attribute bl_class_device_attributes[] = {
        DECLARE_ATTR(max_brightness, 0444, backlight_show_max_brightness, NULL),
 };
 
-/* This callback gets called when something important happens inside a
- * framebuffer driver. We're looking if that important event is blanking,
- * and if it is, we're switching backlight power as well ...
- */
-static int fb_notifier_callback(struct notifier_block *self,
-                               unsigned long event, void *data)
-{
-       struct backlight_device *bd;
-       struct fb_event *evdata =(struct fb_event *)data;
-
-       /* If we aren't interested in this event, skip it immediately ... */
-       if (event != FB_EVENT_BLANK)
-               return 0;
-
-       bd = container_of(self, struct backlight_device, fb_notif);
-       down(&bd->sem);
-       if (bd->props)
-               if (!bd->props->check_fb ||
-                   bd->props->check_fb(evdata->info)) {
-                       bd->props->fb_blank = *(int *)evdata->data;
-                       if (likely(bd->props && bd->props->update_status))
-                               bd->props->update_status(bd);
-               }
-       up(&bd->sem);
-       return 0;
-}
-
 /**
  * backlight_device_register - create and register a new object of
  *   backlight_device class.
@@ -215,10 +241,7 @@ error:             kfree(new_bd);
                return ERR_PTR(rc);
        }
 
-       memset(&new_bd->fb_notif, 0, sizeof(new_bd->fb_notif));
-       new_bd->fb_notif.notifier_call = fb_notifier_callback;
-
-       rc = fb_register_client(&new_bd->fb_notif);
+       rc = backlight_register_fb(new_bd);
        if (unlikely(rc))
                goto error;
 
@@ -259,16 +282,10 @@ void backlight_device_unregister(struct backlight_device *bd)
                                         &bl_class_device_attributes[i]);
 
        down(&bd->sem);
-       if (likely(bd->props && bd->props->update_status)) {
-               bd->props->brightness = 0;
-               bd->props->power = 0;
-               bd->props->update_status(bd);
-       }
-
        bd->props = NULL;
        up(&bd->sem);
 
-       fb_unregister_client(&bd->fb_notif);
+       backlight_unregister_fb(bd);
 
        class_device_unregister(&bd->class_dev);
 }
index d07ecb53c68b85bad48b7f8fd243105857a5fec9..61587ca2cdbb5f708f3d0f37babec91fa3153163 100644 (file)
@@ -135,6 +135,10 @@ static int corgibl_probe(struct platform_device *pdev)
 
 static int corgibl_remove(struct platform_device *dev)
 {
+       corgibl_data.power = 0;
+       corgibl_data.brightness = 0;
+       corgibl_send_intensity(corgi_backlight_device);
+
        backlight_device_unregister(corgi_backlight_device);
 
        printk("Corgi Backlight Driver Unloaded\n");
index e3993213d10e39cb2e98629dc114775dcc23aa37..1c569fb543ae80f6bef9d6954954398ae358a1c2 100644 (file)
@@ -117,6 +117,10 @@ static int __init hp680bl_probe(struct platform_device *dev)
 
 static int hp680bl_remove(struct platform_device *dev)
 {
+       hp680bl_data.brightness = 0;
+       hp680bl_data.power = 0;
+       hp680bl_send_intensity(hp680_backlight_device);
+
        backlight_device_unregister(hp680_backlight_device);
 
        return 0;
index bc8ab005a3fb174a9eecc050a76301469ed2916f..f6e041627edbb874419cc146ecd6df167fbe67c1 100644 (file)
 #include <linux/err.h>
 #include <linux/fb.h>
 
+#if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
+                          defined(CONFIG_LCD_CLASS_DEVICE_MODULE))
+/* This callback gets called when something important happens inside a
+ * framebuffer driver. We're looking if that important event is blanking,
+ * and if it is, we're switching lcd power as well ...
+ */
+static int fb_notifier_callback(struct notifier_block *self,
+                                unsigned long event, void *data)
+{
+       struct lcd_device *ld;
+       struct fb_event *evdata = data;
+
+       /* If we aren't interested in this event, skip it immediately ... */
+       if (event != FB_EVENT_BLANK)
+               return 0;
+
+       ld = container_of(self, struct lcd_device, fb_notif);
+       down(&ld->sem);
+       if (ld->props)
+               if (!ld->props->check_fb || ld->props->check_fb(evdata->info))
+                       ld->props->set_power(ld, *(int *)evdata->data);
+       up(&ld->sem);
+       return 0;
+}
+
+static int lcd_register_fb(struct lcd_device *ld)
+{
+       memset(&ld->fb_notif, 0, sizeof(&ld->fb_notif));
+       ld->fb_notif.notifier_call = fb_notifier_callback;
+       return fb_register_client(&ld->fb_notif);
+}
+
+static void lcd_unregister_fb(struct lcd_device *ld)
+{
+       fb_unregister_client(&ld->fb_notif);
+}
+#else
+static int lcd_register_fb(struct lcd_device *ld)
+{
+       return 0;
+}
+
+static inline void lcd_unregister_fb(struct lcd_device *ld)
+{
+}
+#endif /* CONFIG_FB */
+
 static ssize_t lcd_show_power(struct class_device *cdev, char *buf)
 {
        int rc;
@@ -121,35 +168,12 @@ static struct class lcd_class = {
        .store  = _store,                                       \
 }
 
-static struct class_device_attribute lcd_class_device_attributes[] = {
+static const struct class_device_attribute lcd_class_device_attributes[] = {
        DECLARE_ATTR(power, 0644, lcd_show_power, lcd_store_power),
        DECLARE_ATTR(contrast, 0644, lcd_show_contrast, lcd_store_contrast),
        DECLARE_ATTR(max_contrast, 0444, lcd_show_max_contrast, NULL),
 };
 
-/* This callback gets called when something important happens inside a
- * framebuffer driver. We're looking if that important event is blanking,
- * and if it is, we're switching lcd power as well ...
- */
-static int fb_notifier_callback(struct notifier_block *self,
-                                unsigned long event, void *data)
-{
-       struct lcd_device *ld;
-       struct fb_event *evdata =(struct fb_event *)data;
-
-       /* If we aren't interested in this event, skip it immediately ... */
-       if (event != FB_EVENT_BLANK)
-               return 0;
-
-       ld = container_of(self, struct lcd_device, fb_notif);
-       down(&ld->sem);
-       if (ld->props)
-               if (!ld->props->check_fb || ld->props->check_fb(evdata->info))
-                       ld->props->set_power(ld, *(int *)evdata->data);
-       up(&ld->sem);
-       return 0;
-}
-
 /**
  * lcd_device_register - register a new object of lcd_device class.
  * @name: the name of the new object(must be the same as the name of the
@@ -186,10 +210,8 @@ error:             kfree(new_ld);
                return ERR_PTR(rc);
        }
 
-       memset(&new_ld->fb_notif, 0, sizeof(new_ld->fb_notif));
-       new_ld->fb_notif.notifier_call = fb_notifier_callback;
+       rc = lcd_register_fb(new_ld);
 
-       rc = fb_register_client(&new_ld->fb_notif);
        if (unlikely(rc))
                goto error;
 
@@ -232,9 +254,7 @@ void lcd_device_unregister(struct lcd_device *ld)
        down(&ld->sem);
        ld->props = NULL;
        up(&ld->sem);
-
-       fb_unregister_client(&ld->fb_notif);
-
+       lcd_unregister_fb(ld);
        class_device_unregister(&ld->class_dev);
 }
 EXPORT_SYMBOL(lcd_device_unregister);
index 628571c63bacc4905517c5563a7fc0fa7848c564..2d7905410b2ac61a11b1a9d83d0f59e42a6b86ba 100644 (file)
@@ -200,6 +200,10 @@ static int locomolcd_remove(struct locomo_dev *dev)
 {
        unsigned long flags;
 
+       locomobl_data.brightness = 0;
+       locomobl_data.power = 0;
+       locomolcd_set_intensity(locomolcd_bl_device);
+
        backlight_device_unregister(locomolcd_bl_device);
        local_irq_save(flags);
        locomolcd_dev = NULL;
index 51d35386a9450d74bd8d96ea674b7356dfd3341a..261004473c8e76b8e446317a7dfec8bbb9342517 100644 (file)
@@ -42,7 +42,7 @@
 #define DPRINTK(fmt, args...)
 #endif
 
-static u32 cfb_tab8[] = {
+static const u32 cfb_tab8[] = {
 #if defined(__BIG_ENDIAN)
     0x00000000,0x000000ff,0x0000ff00,0x0000ffff,
     0x00ff0000,0x00ff00ff,0x00ffff00,0x00ffffff,
@@ -58,7 +58,7 @@ static u32 cfb_tab8[] = {
 #endif
 };
 
-static u32 cfb_tab16[] = {
+static const u32 cfb_tab16[] = {
 #if defined(__BIG_ENDIAN)
     0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff
 #elif defined(__LITTLE_ENDIAN)
@@ -68,7 +68,7 @@ static u32 cfb_tab16[] = {
 #endif
 };
 
-static u32 cfb_tab32[] = {
+static const u32 cfb_tab32[] = {
        0x00000000, 0xffffffff
 };
 
@@ -218,7 +218,7 @@ static inline void fast_imageblit(const struct fb_image *image, struct fb_info *
        u32 bit_mask, end_mask, eorx, shift;
        const char *s = image->data, *src;
        u32 __iomem *dst;
-       u32 *tab = NULL;
+       const u32 *tab = NULL;
        int i, j, k;
                
        switch (bpp) {
index daf43f535a0b971540ed274706cd747a0e30d81e..2c4bc6205738992f643128a812769859352f20f8 100644 (file)
@@ -2442,7 +2442,10 @@ static int cirrusfb_pci_register (struct pci_dev *pdev,
        printk ("Cirrus Logic chipset on PCI bus\n");
        pci_set_drvdata(pdev, info);
 
-       return cirrusfb_register(cinfo);
+       ret = cirrusfb_register(cinfo);
+       if (ret)
+               iounmap(cinfo->fbmem);
+       return ret;
 
 err_release_legacy:
        if (release_io_ports)
@@ -2574,7 +2577,15 @@ static int cirrusfb_zorro_register(struct zorro_dev *z,
        printk (KERN_INFO "Cirrus Logic chipset on Zorro bus\n");
        zorro_set_drvdata(z, info);
 
-       return cirrusfb_register(cinfo);
+       ret = cirrusfb_register(cinfo);
+       if (ret) {
+               if (btype == BT_PICASSO4) {
+                       iounmap(cinfo->fbmem);
+                       iounmap(cinfo->regbase - 0x600000);
+               } else if (board_addr > 0x01000000)
+                       iounmap(cinfo->fbmem);
+       }
+       return ret;
 
 err_unmap_regbase:
        /* Parental advisory: explicit hack */
index 7d07d838356904e0b14462a9f50911abaaa92257..f577bd80e020ee832c28657629128d57cd7a73f7 100644 (file)
@@ -1,11 +1,13 @@
 /*
- * linux/drivers/video/softcursor.c -- Generic software cursor for frame buffer devices
+ * linux/drivers/video/softcursor.c
+ *
+ * Generic software cursor for frame buffer devices
  *
  *  Created 14 Nov 2002 by James Simmons
  *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of this archive
- * for more details.
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License.  See the file COPYING in the main directory of this
+ * archive for more details.
  */
 
 #include <linux/module.h>
@@ -25,7 +27,7 @@ int soft_cursor(struct fb_info *info, struct fb_cursor *cursor)
        unsigned int buf_align = info->pixmap.buf_align - 1;
        unsigned int i, size, dsize, s_pitch, d_pitch;
        struct fb_image *image;
-       u8 *dst;
+       u8 *src, *dst;
 
        if (info->state != FBINFO_STATE_RUNNING)
                return 0;
@@ -45,7 +47,8 @@ int soft_cursor(struct fb_info *info, struct fb_cursor *cursor)
                }
        }
 
-       image = (struct fb_image *) (ops->cursor_src + dsize);
+       src = ops->cursor_src + sizeof(struct fb_image);
+       image = (struct fb_image *)ops->cursor_src;
        *image = cursor->image;
        d_pitch = (s_pitch + scan_align) & ~scan_align;
 
@@ -57,21 +60,18 @@ int soft_cursor(struct fb_info *info, struct fb_cursor *cursor)
                switch (cursor->rop) {
                case ROP_XOR:
                        for (i = 0; i < dsize; i++)
-                               ops->cursor_src[i] = image->data[i] ^
-                                       cursor->mask[i];
+                               src[i] = image->data[i] ^ cursor->mask[i];
                        break;
                case ROP_COPY:
                default:
                        for (i = 0; i < dsize; i++)
-                               ops->cursor_src[i] = image->data[i] &
-                                       cursor->mask[i];
+                               src[i] = image->data[i] & cursor->mask[i];
                        break;
                }
        } else
-               memcpy(ops->cursor_src, image->data, dsize);
+               memcpy(src, image->data, dsize);
 
-       fb_pad_aligned_buffer(dst, d_pitch, ops->cursor_src, s_pitch,
-                             image->height);
+       fb_pad_aligned_buffer(dst, d_pitch, src, s_pitch, image->height);
        image->data = dst;
        info->fbops->fb_imageblit(info, image);
        return 0;
index 45586aaabd1e9ab41eec1214606f91caeb596979..57b21e533036983637c4fd6be89b3ba581ee042c 100644 (file)
@@ -345,7 +345,7 @@ static void sticon_save_screen(struct vc_data *conp)
 {
 }
 
-static struct consw sti_con = {
+static const struct consw sti_con = {
        .owner                  = THIS_MODULE,
        .con_startup            = sticon_startup,
        .con_init               = sticon_init,
index 0a2c10a1abf88cff76baf460d9cfdf96dbd6cc41..4a9bde2c839b41dae6922ff71965928833908b7b 100644 (file)
@@ -93,27 +93,27 @@ static void vgacon_invert_region(struct vc_data *c, u16 * p, int count);
 static unsigned long vgacon_uni_pagedir[2];
 
 /* Description of the hardware situation */
-static unsigned long   vga_vram_base;          /* Base of video memory */
-static unsigned long   vga_vram_end;           /* End of video memory */
-static int             vga_vram_size;          /* Size of video memory */
-static u16             vga_video_port_reg;     /* Video register select port */
-static u16             vga_video_port_val;     /* Video register value port */
-static unsigned int    vga_video_num_columns;  /* Number of text columns */
-static unsigned int    vga_video_num_lines;    /* Number of text lines */
-static int             vga_can_do_color = 0;   /* Do we support colors? */
-static unsigned int    vga_default_font_height;/* Height of default screen font */
-static unsigned char   vga_video_type;         /* Card type */
-static unsigned char   vga_hardscroll_enabled;
-static unsigned char   vga_hardscroll_user_enable = 1;
+static int             vga_init_done           __read_mostly;
+static unsigned long   vga_vram_base           __read_mostly;  /* Base of video memory */
+static unsigned long   vga_vram_end            __read_mostly;  /* End of video memory */
+static unsigned int    vga_vram_size           __read_mostly;  /* Size of video memory */
+static u16             vga_video_port_reg      __read_mostly;  /* Video register select port */
+static u16             vga_video_port_val      __read_mostly;  /* Video register value port */
+static unsigned int    vga_video_num_columns;                  /* Number of text columns */
+static unsigned int    vga_video_num_lines;                    /* Number of text lines */
+static int             vga_can_do_color        __read_mostly;  /* Do we support colors? */
+static unsigned int    vga_default_font_height __read_mostly;  /* Height of default screen font */
+static unsigned char   vga_video_type          __read_mostly;  /* Card type */
+static unsigned char   vga_hardscroll_enabled  __read_mostly;
+static unsigned char   vga_hardscroll_user_enable __read_mostly = 1;
 static unsigned char   vga_font_is_default = 1;
 static int             vga_vesa_blanked;
 static int             vga_palette_blanked;
 static int             vga_is_gfx;
 static int             vga_512_chars;
 static int             vga_video_font_height;
-static int             vga_scan_lines;
-static unsigned int    vga_rolled_over = 0;
-static int              vga_init_done;
+static int             vga_scan_lines          __read_mostly;
+static unsigned int    vga_rolled_over;
 
 static int __init no_scroll(char *str)
 {
index c40e72dafb0e99e8ae8edd877bca9a49e86c66ef..0b8d5b12115282c1c04e3cee40165aae65e3a024 100644 (file)
@@ -109,8 +109,6 @@ static void cv64_dump(void);
 #define wb_64(regs,reg,dat) (*(((volatile unsigned char *)regs) + reg) = dat)
 #define rb_64(regs, reg) (*(((volatile unsigned char *)regs) + reg))
 
-#define ww_64(regs,reg,dat) (*((volatile unsigned short *)(regs + reg) = dat)
-
 struct cyberfb_par {
        struct fb_var_screeninfo var;
        __u32 type;
@@ -1055,6 +1053,8 @@ int __init cyberfb_init(void)
 
            if (register_framebuffer(&fb_info) < 0) {
                    DPRINTK("EXIT - register_framebuffer failed\n");
+                       if (CyberBase)
+                               iounmap(CyberBase);
                    release_mem_region(CyberMem_phys, 0x400000);
                    release_mem_region(CyberRegs_phys, 0x10000);
                    return -EINVAL;
index 737257d278f0a05ee5257fb4ba2d48f2ea0723c5..29e07c1098876997db774ae77572a1e9d649c175 100644 (file)
@@ -405,7 +405,7 @@ static inline unsigned long copy_to_user16(void *to, const void *from,
 static ssize_t
 epson1355fb_read(struct file *file, char *buf, size_t count, loff_t * ppos)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int fbidx = iminor(inode);
        struct fb_info *info = registered_fb[fbidx];
        unsigned long p = *ppos;
@@ -437,7 +437,7 @@ static ssize_t
 epson1355fb_write(struct file *file, const char *buf,
                  size_t count, loff_t * ppos)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int fbidx = iminor(inode);
        struct fb_info *info = registered_fb[fbidx];
        unsigned long p = *ppos;
index e8b135f3d80d1590bf59cd905f213b701fe83a5a..148108afdd51a03b445fa9b9ff90ba54fd6f06be 100644 (file)
 
 #include <asm/uaccess.h>
 
-static u16 red2[] = {
+static u16 red2[] __read_mostly = {
     0x0000, 0xaaaa
 };
-static u16 green2[] = {
+static u16 green2[] __read_mostly = {
     0x0000, 0xaaaa
 };
-static u16 blue2[] = {
+static u16 blue2[] __read_mostly = {
     0x0000, 0xaaaa
 };
 
-static u16 red4[] = {
+static u16 red4[] __read_mostly = {
     0x0000, 0xaaaa, 0x5555, 0xffff
 };
-static u16 green4[] = {
+static u16 green4[] __read_mostly = {
     0x0000, 0xaaaa, 0x5555, 0xffff
 };
-static u16 blue4[] = {
+static u16 blue4[] __read_mostly = {
     0x0000, 0xaaaa, 0x5555, 0xffff
 };
 
-static u16 red8[] = {
+static u16 red8[] __read_mostly = {
     0x0000, 0x0000, 0x0000, 0x0000, 0xaaaa, 0xaaaa, 0xaaaa, 0xaaaa
 };
-static u16 green8[] = {
+static u16 green8[] __read_mostly = {
     0x0000, 0x0000, 0xaaaa, 0xaaaa, 0x0000, 0x0000, 0x5555, 0xaaaa
 };
-static u16 blue8[] = {
+static u16 blue8[] __read_mostly = {
     0x0000, 0xaaaa, 0x0000, 0xaaaa, 0x0000, 0xaaaa, 0x0000, 0xaaaa
 };
 
-static u16 red16[] = {
+static u16 red16[] __read_mostly = {
     0x0000, 0x0000, 0x0000, 0x0000, 0xaaaa, 0xaaaa, 0xaaaa, 0xaaaa,
     0x5555, 0x5555, 0x5555, 0x5555, 0xffff, 0xffff, 0xffff, 0xffff
 };
-static u16 green16[] = {
+static u16 green16[] __read_mostly = {
     0x0000, 0x0000, 0xaaaa, 0xaaaa, 0x0000, 0x0000, 0x5555, 0xaaaa,
     0x5555, 0x5555, 0xffff, 0xffff, 0x5555, 0x5555, 0xffff, 0xffff
 };
-static u16 blue16[] = {
+static u16 blue16[] __read_mostly = {
     0x0000, 0xaaaa, 0x0000, 0xaaaa, 0x0000, 0xaaaa, 0x0000, 0xaaaa,
     0x5555, 0xffff, 0x5555, 0xffff, 0x5555, 0xffff, 0x5555, 0xffff
 };
 
-static struct fb_cmap default_2_colors = {
-    0, 2, red2, green2, blue2, NULL
+static const struct fb_cmap default_2_colors = {
+    .len=2, .red=red2, .green=green2, .blue=blue2
 };
-static struct fb_cmap default_8_colors = {
-    0, 8, red8, green8, blue8, NULL
+static const struct fb_cmap default_8_colors = {
+    .len=8, .red=red8, .green=green8, .blue=blue8
 };
-static struct fb_cmap default_4_colors = {
-    0, 4, red4, green4, blue4, NULL
+static const struct fb_cmap default_4_colors = {
+    .len=4, .red=red4, .green=green4, .blue=blue4
 };
-static struct fb_cmap default_16_colors = {
-    0, 16, red16, green16, blue16, NULL
+static const struct fb_cmap default_16_colors = {
+    .len=16, .red=red16, .green=green16, .blue=blue16
 };
 
 
+
 /**
  *     fb_alloc_cmap - allocate a colormap
  *     @cmap: frame buffer colormap structure
@@ -146,7 +147,7 @@ void fb_dealloc_cmap(struct fb_cmap *cmap)
  *     Copy contents of colormap from @from to @to.
  */
 
-int fb_copy_cmap(struct fb_cmap *from, struct fb_cmap *to)
+int fb_copy_cmap(const struct fb_cmap *from, struct fb_cmap *to)
 {
        int tooff = 0, fromoff = 0;
        int size;
@@ -170,7 +171,7 @@ int fb_copy_cmap(struct fb_cmap *from, struct fb_cmap *to)
        return 0;
 }
 
-int fb_cmap_to_user(struct fb_cmap *from, struct fb_cmap_user *to)
+int fb_cmap_to_user(const struct fb_cmap *from, struct fb_cmap_user *to)
 {
        int tooff = 0, fromoff = 0;
        int size;
@@ -282,7 +283,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
  *
  */
 
-struct fb_cmap *fb_default_cmap(int len)
+const struct fb_cmap *fb_default_cmap(int len)
 {
     if (len <= 2)
        return &default_2_colors;
@@ -305,22 +306,22 @@ void fb_invert_cmaps(void)
 {
     u_int i;
 
-    for (i = 0; i < 2; i++) {
+    for (i = 0; i < ARRAY_SIZE(red2); i++) {
        red2[i] = ~red2[i];
        green2[i] = ~green2[i];
        blue2[i] = ~blue2[i];
     }
-    for (i = 0; i < 4; i++) {
+    for (i = 0; i < ARRAY_SIZE(red4); i++) {
        red4[i] = ~red4[i];
        green4[i] = ~green4[i];
        blue4[i] = ~blue4[i];
     }
-    for (i = 0; i < 8; i++) {
+    for (i = 0; i < ARRAY_SIZE(red8); i++) {
        red8[i] = ~red8[i];
        green8[i] = ~green8[i];
        blue8[i] = ~blue8[i];
     }
-    for (i = 0; i < 16; i++) {
+    for (i = 0; i < ARRAY_SIZE(red16); i++) {
        red16[i] = ~red16[i];
        green16[i] = ~green16[i];
        blue16[i] = ~blue16[i];
index b5498999c4eccb6a57ec3dffc1e8c0860b4be5a9..0847c5e72cbd73ff2fcf53afe59c1d729810e2d9 100644 (file)
@@ -57,7 +57,7 @@ struct fb_cvt_data {
        u32 status;
 };
 
-static int fb_cvt_vbi_tab[] = {
+static const unsigned char fb_cvt_vbi_tab[] = {
        4,        /* 4:3      */
        5,        /* 16:9     */
        6,        /* 16:10    */
index e973a87fbb01b02634732a7606bf837a96d9a4c2..3cfea315a48ff1305c5202a09dd577c709a79fd1 100644 (file)
@@ -52,8 +52,8 @@
 
 #define FBPIXMAPSIZE   (1024 * 8)
 
-struct fb_info *registered_fb[FB_MAX];
-int num_registered_fb;
+struct fb_info *registered_fb[FB_MAX] __read_mostly;
+int num_registered_fb __read_mostly;
 
 /*
  * Helpers
@@ -202,7 +202,7 @@ static void  fb_set_logo_truepalette(struct fb_info *info,
                                            const struct linux_logo *logo,
                                            u32 *palette)
 {
-       unsigned char mask[9] = { 0,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff };
+       static const unsigned char mask[] = { 0,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff };
        unsigned char redmask, greenmask, bluemask;
        int redshift, greenshift, blueshift;
        int i;
@@ -317,7 +317,7 @@ static struct logo_data {
        int needs_truepalette;
        int needs_cmapreset;
        const struct linux_logo *logo;
-} fb_logo;
+} fb_logo __read_mostly;
 
 static void fb_rotate_logo_ud(const u8 *in, u8 *out, u32 width, u32 height)
 {
@@ -572,7 +572,7 @@ static ssize_t
 fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 {
        unsigned long p = *ppos;
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int fbidx = iminor(inode);
        struct fb_info *info = registered_fb[fbidx];
        u32 *buffer, *dst;
@@ -647,7 +647,7 @@ static ssize_t
 fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 {
        unsigned long p = *ppos;
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int fbidx = iminor(inode);
        struct fb_info *info = registered_fb[fbidx];
        u32 *buffer, *src;
@@ -1081,7 +1081,7 @@ static int fb_get_fscreeninfo(struct inode *inode, struct file *file,
 static long
 fb_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int fbidx = iminor(inode);
        struct fb_info *info = registered_fb[fbidx];
        struct fb_ops *fb = info->fbops;
@@ -1121,7 +1121,7 @@ fb_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static int 
 fb_mmap(struct file *file, struct vm_area_struct * vma)
 {
-       int fbidx = iminor(file->f_dentry->d_inode);
+       int fbidx = iminor(file->f_path.dentry->d_inode);
        struct fb_info *info = registered_fb[fbidx];
        struct fb_ops *fb = info->fbops;
        unsigned long off;
@@ -1253,7 +1253,7 @@ fb_release(struct inode *inode, struct file *file)
        return 0;
 }
 
-static struct file_operations fb_fops = {
+static const struct file_operations fb_fops = {
        .owner =        THIS_MODULE,
        .read =         fb_read,
        .write =        fb_write,
@@ -1459,8 +1459,8 @@ int fb_new_modelist(struct fb_info *info)
        return err;
 }
 
-static char *video_options[FB_MAX];
-static int ofonly;
+static char *video_options[FB_MAX] __read_mostly;
+static int ofonly __read_mostly;
 
 extern const char *global_mode_option;
 
index de93139ccbb5a5cb265eee0706200b12cde5c551..6b385c39b8b5cdc13b0ec781c72067aed810ef78 100644 (file)
@@ -58,7 +58,7 @@ struct broken_edid {
        u32 fix;
 };
 
-static struct broken_edid brokendb[] = {
+static const struct broken_edid brokendb[] = {
        /* DEC FR-PCXAV-YZ */
        {
                .manufacturer = "DEC",
index 2a0e8210d398e6c964aa69028161cd3af471a44d..949141bd44d44af445eeba4035b939f8c728f21f 100644 (file)
@@ -968,6 +968,8 @@ static int ffb_init_one(struct of_device *op)
 
        if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
                printk(KERN_ERR "ffb: Could not allocate color map.\n");
+               of_iounmap(all->par.fbc, sizeof(struct ffb_fbc));
+               of_iounmap(all->par.dac, sizeof(struct ffb_dac));
                kfree(all);
                return -ENOMEM;
        }
@@ -978,6 +980,8 @@ static int ffb_init_one(struct of_device *op)
        if (err < 0) {
                printk(KERN_ERR "ffb: Could not register framebuffer.\n");
                fb_dealloc_cmap(&all->info.cmap);
+               of_iounmap(all->par.fbc, sizeof(struct ffb_fbc));
+               of_iounmap(all->par.dac, sizeof(struct ffb_dac));
                kfree(all);
                return err;
        }
index 998374cfae6d0686f992cc00938bf4d460a436ec..70ff55b1459675db71c6025e588129446434cbf4 100644 (file)
@@ -283,6 +283,7 @@ static int __devinit fm2fb_probe(struct zorro_dev *z,
 
        if (register_framebuffer(info) < 0) {
                fb_dealloc_cmap(&info->cmap);
+               iounmap(info->screen_base);
                framebuffer_release(info);
                zorro_release_device(z);
                return -EINVAL;
index 4e173ef20a7dd83e70541f86b5f78f67e3a6c365..a814b6c2605c77574164ba2f527e3647db03cbd4 100644 (file)
@@ -23,6 +23,26 @@ config FB_GEODE_GX
 
          If unsure, say N.
 
+config FB_GEODE_GX_SET_FBSIZE
+       bool "Manually specify the Geode GX framebuffer size"
+       depends on FB_GEODE_GX
+       default n
+       ---help---
+         If you want to manually specify the size of your GX framebuffer,
+         say Y here, otherwise say N to dynamically probe it.
+
+         Say N unless you know what you are doing.
+
+config FB_GEODE_GX_FBSIZE
+       hex "Size of the GX framebuffer, in bytes"
+       depends on FB_GEODE_GX_SET_FBSIZE
+       default "0x1600000"
+       ---help---
+         Specify the size of the GX framebuffer.  Normally, you will
+         want this to be MB aligned.  Common values are 0x80000 (8MB)
+         and 0x1600000 (16MB).  Don't change this unless you know what
+         you are doing
+
 config FB_GEODE_GX1
        tristate "AMD Geode GX1 framebuffer support (EXPERIMENTAL)"
        depends on FB && FB_GEODE && EXPERIMENTAL
index 825c3405f5c2121fb57d95789bf7a6e83aef0209..0f16e4bffc6c86874114fec752fd4a42f05de0b8 100644 (file)
 #include "geodefb.h"
 #include "display_gx.h"
 
-int gx_frame_buffer_size(void)
+#ifdef CONFIG_FB_GEODE_GX_SET_FBSIZE
+unsigned int gx_frame_buffer_size(void)
 {
-       /* Assuming 16 MiB. */
-       return 16*1024*1024;
+       return CONFIG_FB_GEODE_GX_FBSIZE;
 }
+#else
+unsigned int gx_frame_buffer_size(void)
+{
+       unsigned int val;
+
+       /* FB size is reported by a virtual register */
+       /* Virtual register class = 0x02 */
+       /* VG_MEM_SIZE(512Kb units) = 0x00 */
+
+       outw(0xFC53, 0xAC1C);
+       outw(0x0200, 0xAC1C);
+
+       val = (unsigned int)(inw(0xAC1E)) & 0xFFl;
+       return (val << 19);
+}
+#endif
 
 int gx_line_delta(int xres, int bpp)
 {
@@ -81,6 +97,7 @@ static void gx_set_mode(struct fb_info *info)
        writel(((info->var.xres * info->var.bits_per_pixel/8) >> 3) + 2,
               par->dc_regs + DC_LINE_SIZE);
 
+
        /* Enable graphics and video data and unmask address lines. */
        dcfg |= DC_DCFG_GDEN | DC_DCFG_VDEN | DC_DCFG_A20M | DC_DCFG_A18M;
 
index 86c623361305887675e2099f67ccafaaed553f1c..0af33f329e88ff03c8acbe17615cf63b9032f8d8 100644 (file)
 #ifndef __DISPLAY_GX_H__
 #define __DISPLAY_GX_H__
 
-int gx_frame_buffer_size(void);
+unsigned int gx_frame_buffer_size(void);
 int gx_line_delta(int xres, int bpp);
 
 extern struct geode_dc_ops gx_dc_ops;
 
+/* MSR that tells us if a TFT or CRT is attached */
+#define GLD_MSR_CONFIG   0xC0002001
+#define GLD_MSR_CONFIG_DM_FP 0x40
+
 /* Display controller registers */
 
 #define DC_UNLOCK 0x00
@@ -93,4 +97,5 @@ extern struct geode_dc_ops gx_dc_ops;
 #define DC_PAL_ADDRESS 0x70
 #define DC_PAL_DATA    0x74
 
+#define DC_GLIU0_MEM_OFFSET 0x84
 #endif /* !__DISPLAY_GX1_H__ */
index 0d3643fc6293ba76880b371779288f99d46306c4..cf841efa229ad68cd20bc76d4ccc788f98767e30 100644 (file)
 #include "display_gx.h"
 #include "video_gx.h"
 
-static char mode_option[32] = "640x480-16@60";
+static char *mode_option;
 
 /* Modes relevant to the GX (taken from modedb.c) */
-static const struct fb_videomode __initdata gx_modedb[] = {
+static const struct fb_videomode gx_modedb[] __initdata = {
        /* 640x480-60 VESA */
        { NULL, 60, 640, 480, 39682,  48, 16, 33, 10, 96, 2,
          0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
@@ -240,6 +240,12 @@ static int __init gxfb_map_video_memory(struct fb_info *info, struct pci_dev *de
        if (!info->screen_base)
                return -ENOMEM;
 
+       /* Set the 16MB aligned base address of the graphics memory region
+        * in the display controller */
+
+       writel(info->fix.smem_start & 0xFF000000,
+                       par->dc_regs + DC_GLIU0_MEM_OFFSET);
+
        dev_info(&dev->dev, "%d Kibyte of video memory at 0x%lx\n",
                 info->fix.smem_len / 1024, info->fix.smem_start);
 
@@ -302,6 +308,7 @@ static int __init gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *i
        struct geodefb_par *par;
        struct fb_info *info;
        int ret;
+       unsigned long val;
 
        info = gxfb_init_fbinfo(&pdev->dev);
        if (!info)
@@ -317,6 +324,15 @@ static int __init gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *i
                goto err;
        }
 
+       /* Figure out if this is a TFT or CRT part */
+
+       rdmsrl(GLD_MSR_CONFIG, val);
+
+       if ((val & GLD_MSR_CONFIG_DM_FP) == GLD_MSR_CONFIG_DM_FP)
+               par->enable_crt = 0;
+       else
+               par->enable_crt = 1;
+
        ret = fb_find_mode(&info->var, info, mode_option,
                           gx_modedb, ARRAY_SIZE(gx_modedb), NULL, 16);
        if (ret == 0 || ret == 4) {
@@ -325,7 +341,8 @@ static int __init gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *i
                goto err;
        }
 
-        /* Clear the frame buffer of garbage. */
+
+       /* Clear the frame buffer of garbage. */
         memset_io(info->screen_base, 0, info->fix.smem_len);
 
        gxfb_check_var(&info->var, info);
@@ -380,7 +397,7 @@ static void gxfb_remove(struct pci_dev *pdev)
 }
 
 static struct pci_device_id gxfb_id_table[] = {
-       { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_VIDEO,
+       { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_GX_VIDEO,
          PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16,
          0xff0000, 0 },
        { 0, }
@@ -395,11 +412,35 @@ static struct pci_driver gxfb_driver = {
        .remove         = gxfb_remove,
 };
 
+#ifndef MODULE
+static int __init gxfb_setup(char *options)
+{
+
+       char *opt;
+
+       if (!options || !*options)
+               return 0;
+
+       while ((opt = strsep(&options, ",")) != NULL) {
+               if (!*opt)
+                       continue;
+
+               mode_option = opt;
+       }
+
+       return 0;
+}
+#endif
+
 static int __init gxfb_init(void)
 {
 #ifndef MODULE
-       if (fb_get_options("gxfb", NULL))
+       char *option = NULL;
+
+       if (fb_get_options("gxfb", &option))
                return -ENODEV;
+
+       gxfb_setup(option);
 #endif
        return pci_register_driver(&gxfb_driver);
 }
@@ -412,8 +453,8 @@ static void __exit gxfb_cleanup(void)
 module_init(gxfb_init);
 module_exit(gxfb_cleanup);
 
-module_param_string(mode, mode_option, sizeof(mode_option), 0444);
-MODULE_PARM_DESC(mode, "video mode (<x>x<y>[-<bpp>][@<refr>])");
+module_param(mode_option, charp, 0);
+MODULE_PARM_DESC(mode_option, "video mode (<x>x<y>[-<bpp>][@<refr>])");
 
 MODULE_DESCRIPTION("Framebuffer driver for the AMD Geode GX");
 MODULE_LICENSE("GPL");
index 2b2a7880ea751fe579b7ff9bd5eebdf19a5bca73..7f3f18d06718846483d5c67d0dcfb2a3caf52ceb 100644 (file)
@@ -175,13 +175,88 @@ static void gx_set_dclk_frequency(struct fb_info *info)
        } while (timeout-- && !(dotpll & MSR_GLCP_DOTPLL_LOCK));
 }
 
+static void
+gx_configure_tft(struct fb_info *info)
+{
+       struct geodefb_par *par = info->par;
+       unsigned long val;
+       unsigned long fp;
+
+       /* Set up the DF pad select MSR */
+
+       rdmsrl(GX_VP_MSR_PAD_SELECT, val);
+       val &= ~GX_VP_PAD_SELECT_MASK;
+       val |= GX_VP_PAD_SELECT_TFT;
+       wrmsrl(GX_VP_MSR_PAD_SELECT, val);
+
+       /* Turn off the panel */
+
+       fp = readl(par->vid_regs + GX_FP_PM);
+       fp &= ~GX_FP_PM_P;
+       writel(fp, par->vid_regs + GX_FP_PM);
+
+       /* Set timing 1 */
+
+       fp = readl(par->vid_regs + GX_FP_PT1);
+       fp &= GX_FP_PT1_VSIZE_MASK;
+       fp |= info->var.yres << GX_FP_PT1_VSIZE_SHIFT;
+       writel(fp, par->vid_regs + GX_FP_PT1);
+
+       /* Timing 2 */
+       /* Set bits that are always on for TFT */
+
+       fp = 0x0F100000;
+
+       /* Add sync polarity */
+
+       if (!(info->var.sync & FB_SYNC_VERT_HIGH_ACT))
+               fp |= GX_FP_PT2_VSP;
+
+       if (!(info->var.sync & FB_SYNC_HOR_HIGH_ACT))
+               fp |= GX_FP_PT2_HSP;
+
+       writel(fp, par->vid_regs + GX_FP_PT2);
+
+       /*  Set the dither control */
+       writel(0x70, par->vid_regs + GX_FP_DFC);
+
+       /* Enable the FP data and power (in case the BIOS didn't) */
+
+       fp = readl(par->vid_regs + GX_DCFG);
+       fp |= GX_DCFG_FP_PWR_EN | GX_DCFG_FP_DATA_EN;
+       writel(fp, par->vid_regs + GX_DCFG);
+
+       /* Unblank the panel */
+
+       fp = readl(par->vid_regs + GX_FP_PM);
+       fp |= GX_FP_PM_P;
+       writel(fp, par->vid_regs + GX_FP_PM);
+}
+
 static void gx_configure_display(struct fb_info *info)
 {
        struct geodefb_par *par = info->par;
-       u32 dcfg, fp_pm;
+       u32 dcfg, misc;
+
+       /* Set up the MISC register */
+
+       misc = readl(par->vid_regs + GX_MISC);
+
+       /* Power up the DAC */
+       misc &= ~(GX_MISC_A_PWRDN | GX_MISC_DAC_PWRDN);
+
+       /* Disable gamma correction */
+       misc |= GX_MISC_GAM_EN;
+
+       writel(misc, par->vid_regs + GX_MISC);
 
+       /* Write the display configuration */
        dcfg = readl(par->vid_regs + GX_DCFG);
 
+       /* Disable hsync and vsync */
+       dcfg &= ~(GX_DCFG_VSYNC_EN | GX_DCFG_HSYNC_EN);
+       writel(dcfg, par->vid_regs + GX_DCFG);
+
        /* Clear bits from existing mode. */
        dcfg &= ~(GX_DCFG_CRT_SYNC_SKW_MASK
                  | GX_DCFG_CRT_HSYNC_POL   | GX_DCFG_CRT_VSYNC_POL
@@ -199,12 +274,19 @@ static void gx_configure_display(struct fb_info *info)
        if (info->var.sync & FB_SYNC_VERT_HIGH_ACT)
                dcfg |= GX_DCFG_CRT_VSYNC_POL;
 
+       /* Enable the display logic */
+       /* Set up the DACS to blank normally */
+
+       dcfg |= GX_DCFG_CRT_EN | GX_DCFG_DAC_BL_EN;
+
+       /* Enable the external DAC VREF? */
+
        writel(dcfg, par->vid_regs + GX_DCFG);
 
-       /* Power on flat panel. */
-       fp_pm = readl(par->vid_regs + GX_FP_PM);
-       fp_pm |= GX_FP_PM_P;
-       writel(fp_pm, par->vid_regs + GX_FP_PM);
+       /* Set up the flat panel (if it is enabled) */
+
+       if (par->enable_crt == 0)
+               gx_configure_tft(info);
 }
 
 static int gx_blank_display(struct fb_info *info, int blank_mode)
@@ -245,12 +327,15 @@ static int gx_blank_display(struct fb_info *info, int blank_mode)
        writel(dcfg, par->vid_regs + GX_DCFG);
 
        /* Power on/off flat panel. */
-       fp_pm = readl(par->vid_regs + GX_FP_PM);
-       if (blank_mode == FB_BLANK_POWERDOWN)
-               fp_pm &= ~GX_FP_PM_P;
-       else
-               fp_pm |= GX_FP_PM_P;
-       writel(fp_pm, par->vid_regs + GX_FP_PM);
+
+       if (par->enable_crt == 0) {
+               fp_pm = readl(par->vid_regs + GX_FP_PM);
+               if (blank_mode == FB_BLANK_POWERDOWN)
+                       fp_pm &= ~GX_FP_PM_P;
+               else
+                       fp_pm |= GX_FP_PM_P;
+               writel(fp_pm, par->vid_regs + GX_FP_PM);
+       }
 
        return 0;
 }
index 2d9211f3ed848833cae6a3de9be6caabb7bae862..ce28d8f382dcea25c7f3aec5c5066e0ee3cb2641 100644 (file)
 
 extern struct geode_vid_ops gx_vid_ops;
 
+/* GX Flatpanel control MSR */
+#define GX_VP_MSR_PAD_SELECT           0xC0002011
+#define GX_VP_PAD_SELECT_MASK          0x3FFFFFFF
+#define GX_VP_PAD_SELECT_TFT           0x1FFFFFFF
+
 /* Geode GX video processor registers */
 
 #define GX_DCFG                0x0008
@@ -20,6 +25,8 @@ extern struct geode_vid_ops gx_vid_ops;
 #  define GX_DCFG_HSYNC_EN             0x00000002
 #  define GX_DCFG_VSYNC_EN             0x00000004
 #  define GX_DCFG_DAC_BL_EN            0x00000008
+#  define GX_DCFG_FP_PWR_EN            0x00000040
+#  define GX_DCFG_FP_DATA_EN           0x00000080
 #  define GX_DCFG_CRT_HSYNC_POL                0x00000100
 #  define GX_DCFG_CRT_VSYNC_POL                0x00000200
 #  define GX_DCFG_CRT_SYNC_SKW_MASK    0x0001C000
@@ -28,10 +35,28 @@ extern struct geode_vid_ops gx_vid_ops;
 #  define GX_DCFG_GV_GAM               0x00200000
 #  define GX_DCFG_DAC_VREF             0x04000000
 
+/* Geode GX MISC video configuration */
+
+#define GX_MISC 0x50
+#define GX_MISC_GAM_EN     0x00000001
+#define GX_MISC_DAC_PWRDN  0x00000400
+#define GX_MISC_A_PWRDN    0x00000800
+
 /* Geode GX flat panel display control registers */
+
+#define GX_FP_PT1 0x0400
+#define GX_FP_PT1_VSIZE_MASK 0x7FF0000
+#define GX_FP_PT1_VSIZE_SHIFT 16
+
+#define GX_FP_PT2 0x408
+#define GX_FP_PT2_VSP (1 << 23)
+#define GX_FP_PT2_HSP (1 << 22)
+
 #define GX_FP_PM 0x410
 #  define GX_FP_PM_P 0x01000000
 
+#define GX_FP_DFC 0x418
+
 /* Geode GX clock control MSRs */
 
 #define MSR_GLCP_SYS_RSTPLL    0x4c000014
index 91cf3b577d156c4b78dea835d24b80b61461634f..9ab9b839a0f5e57cbf643c9bd7c238388d33ba9a 100644 (file)
@@ -295,6 +295,8 @@ static int __init hpfb_init_one(unsigned long phys_base, unsigned long virt_base
 
        if (register_framebuffer(&fb_info) < 0) {
                fb_dealloc_cmap(&fb_info.cmap);
+               iounmap(fb_info.screen_base);
+               fb_info.screen_base = NULL;
                return 1;
        }
 
index b38d805db3134673723716083703efa571c84c4a..b952e4504abeaf6fa11910c0b158dba09ce93397 100644 (file)
@@ -162,9 +162,7 @@ int i810_probe_i2c_connector(struct fb_info *info, u8 **out_edid, int conn)
 
                if (e != NULL) {
                        DPRINTK("i810-i2c: Getting EDID from BIOS\n");
-                       edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
-                       if (edid)
-                               memcpy(edid, e, EDID_LENGTH);
+                       edid = kmemdup(e, EDID_LENGTH, GFP_KERNEL);
                }
        }
 
index e6df492c22a506ba1cec0d49ba1e227c23ab3578..655ae0fa99cae55ecac13efe6469908ae8afd619 100644 (file)
@@ -384,19 +384,21 @@ int __init igafb_init(void)
         if (!con_is_present())
                 return -ENXIO;
 
-        pdev = pci_find_device(PCI_VENDOR_ID_INTERG, 
+        pdev = pci_get_device(PCI_VENDOR_ID_INTERG,
                                PCI_DEVICE_ID_INTERG_1682, 0);
        if (pdev == NULL) {
                /*
                 * XXX We tried to use cyber2000fb.c for IGS 2000.
                 * But it does not initialize the chip in JavaStation-E, alas.
                 */
-               pdev = pci_find_device(PCI_VENDOR_ID_INTERG, 0x2000, 0);
+               pdev = pci_get_device(PCI_VENDOR_ID_INTERG, 0x2000, 0);
                if(pdev == NULL) {
                        return -ENXIO;
                }
                iga2000 = 1;
        }
+       /* We leak a reference here but as it cannot be unloaded this is
+          fine. If you write unload code remember to free it in unload */
        
        size = sizeof(struct fb_info) + sizeof(struct iga_par) + sizeof(u32)*16;
 
index 6f9de04193d216d62f62511f7bbb0cd821d3c0df..664fc5cf962a42f6f18cda1c5dc9f87ee5c236d0 100644 (file)
@@ -1058,10 +1058,9 @@ intelfb_init_var(struct intelfb_info *dinfo)
                u8 *edid_d = NULL;
 
                if (edid_s) {
-                       edid_d = kmalloc(EDID_LENGTH, GFP_KERNEL);
+                       edid_d = kmemdup(edid_s, EDID_LENGTH, GFP_KERNEL);
 
                        if (edid_d) {
-                               memcpy(edid_d, edid_s, EDID_LENGTH);
                                fb_edid_to_monspecs(edid_d,
                                                    &dinfo->info->monspecs);
                                kfree(edid_d);
index 80a043807161fbae1f0e908b6a1f2d2ff56a8355..180d94c2b4d232e21d02a5b6d90ff8825018da5a 100644 (file)
@@ -608,6 +608,22 @@ void __init macfb_setup(char *options)
        }
 }
 
+static void __init iounmap_macfb(void)
+{
+       if (valkyrie_cmap_regs)
+               iounmap(valkyrie_cmap_regs);
+       if (dafb_cmap_regs)
+               iounmap(dafb_cmap_regs);
+       if (v8_brazil_cmap_regs)
+               iounmap(v8_brazil_cmap_regs);
+       if (rbv_cmap_regs)
+               iounmap(rbv_cmap_regs);
+       if (civic_cmap_regs)
+               iounmap(civic_cmap_regs);
+       if (csc_cmap_regs)
+               iounmap(csc_cmap_regs);
+}
+
 static int __init macfb_init(void)
 {
        int video_cmap_len, video_is_nubus = 0;
@@ -962,6 +978,10 @@ static int __init macfb_init(void)
        if (!err)
                printk("fb%d: %s frame buffer device\n",
                       fb_info.node, fb_info.fix.id);
+       else {
+               iounmap(fb_info.screen_base);
+               iounmap_macfb();
+       }
        return err;
 }
 
index 84aab3ad024eb67bbc6aebff563f6ac6de96cef0..472a3ca3d92d18af8826310609172d459ef704bf 100644 (file)
@@ -10,6 +10,8 @@ struct mbxfb_debugfs_data {
        struct dentry *clock;
        struct dentry *display;
        struct dentry *gsctl;
+       struct dentry *sdram;
+       struct dentry *misc;
 };
 
 static int open_file_generic(struct inode *inode, struct file *file)
@@ -29,11 +31,11 @@ static ssize_t sysconf_read_file(struct file *file, char __user *userbuf,
 {
        char * s = big_buffer;
 
-       s += sprintf(s, "SYSCFG = %08lx\n", SYSCFG);
-       s += sprintf(s, "PFBASE = %08lx\n", PFBASE);
-       s += sprintf(s, "PFCEIL = %08lx\n", PFCEIL);
-       s += sprintf(s, "POLLFLAG = %08lx\n", POLLFLAG);
-       s += sprintf(s, "SYSRST = %08lx\n", SYSRST);
+       s += sprintf(s, "SYSCFG = %08x\n", readl(SYSCFG));
+       s += sprintf(s, "PFBASE = %08x\n", readl(PFBASE));
+       s += sprintf(s, "PFCEIL = %08x\n", readl(PFCEIL));
+       s += sprintf(s, "POLLFLAG = %08x\n", readl(POLLFLAG));
+       s += sprintf(s, "SYSRST = %08x\n", readl(SYSRST));
 
        return  simple_read_from_buffer(userbuf, count, ppos,
                                        big_buffer, s-big_buffer);
@@ -45,24 +47,24 @@ static ssize_t gsctl_read_file(struct file *file, char __user *userbuf,
 {
        char * s = big_buffer;
 
-       s += sprintf(s, "GSCTRL = %08lx\n", GSCTRL);
-       s += sprintf(s, "VSCTRL = %08lx\n", VSCTRL);
-       s += sprintf(s, "GBBASE = %08lx\n", GBBASE);
-       s += sprintf(s, "VBBASE = %08lx\n", VBBASE);
-       s += sprintf(s, "GDRCTRL = %08lx\n", GDRCTRL);
-       s += sprintf(s, "VCMSK = %08lx\n", VCMSK);
-       s += sprintf(s, "GSCADR = %08lx\n", GSCADR);
-       s += sprintf(s, "VSCADR = %08lx\n", VSCADR);
-       s += sprintf(s, "VUBASE = %08lx\n", VUBASE);
-       s += sprintf(s, "VVBASE = %08lx\n", VVBASE);
-       s += sprintf(s, "GSADR = %08lx\n", GSADR);
-       s += sprintf(s, "VSADR = %08lx\n", VSADR);
-       s += sprintf(s, "HCCTRL = %08lx\n", HCCTRL);
-       s += sprintf(s, "HCSIZE = %08lx\n", HCSIZE);
-       s += sprintf(s, "HCPOS = %08lx\n", HCPOS);
-       s += sprintf(s, "HCBADR = %08lx\n", HCBADR);
-       s += sprintf(s, "HCCKMSK = %08lx\n", HCCKMSK);
-       s += sprintf(s, "GPLUT = %08lx\n", GPLUT);
+       s += sprintf(s, "GSCTRL = %08x\n", readl(GSCTRL));
+       s += sprintf(s, "VSCTRL = %08x\n", readl(VSCTRL));
+       s += sprintf(s, "GBBASE = %08x\n", readl(GBBASE));
+       s += sprintf(s, "VBBASE = %08x\n", readl(VBBASE));
+       s += sprintf(s, "GDRCTRL = %08x\n", readl(GDRCTRL));
+       s += sprintf(s, "VCMSK = %08x\n", readl(VCMSK));
+       s += sprintf(s, "GSCADR = %08x\n", readl(GSCADR));
+       s += sprintf(s, "VSCADR = %08x\n", readl(VSCADR));
+       s += sprintf(s, "VUBASE = %08x\n", readl(VUBASE));
+       s += sprintf(s, "VVBASE = %08x\n", readl(VVBASE));
+       s += sprintf(s, "GSADR = %08x\n", readl(GSADR));
+       s += sprintf(s, "VSADR = %08x\n", readl(VSADR));
+       s += sprintf(s, "HCCTRL = %08x\n", readl(HCCTRL));
+       s += sprintf(s, "HCSIZE = %08x\n", readl(HCSIZE));
+       s += sprintf(s, "HCPOS = %08x\n", readl(HCPOS));
+       s += sprintf(s, "HCBADR = %08x\n", readl(HCBADR));
+       s += sprintf(s, "HCCKMSK = %08x\n", readl(HCCKMSK));
+       s += sprintf(s, "GPLUT = %08x\n", readl(GPLUT));
 
        return  simple_read_from_buffer(userbuf, count, ppos,
                                        big_buffer, s-big_buffer);
@@ -73,36 +75,36 @@ static ssize_t display_read_file(struct file *file, char __user *userbuf,
 {
        char * s = big_buffer;
 
-       s += sprintf(s, "DSCTRL = %08lx\n", DSCTRL);
-       s += sprintf(s, "DHT01 = %08lx\n", DHT01);
-       s += sprintf(s, "DHT02 = %08lx\n", DHT02);
-       s += sprintf(s, "DHT03 = %08lx\n", DHT03);
-       s += sprintf(s, "DVT01 = %08lx\n", DVT01);
-       s += sprintf(s, "DVT02 = %08lx\n", DVT02);
-       s += sprintf(s, "DVT03 = %08lx\n", DVT03);
-       s += sprintf(s, "DBCOL = %08lx\n", DBCOL);
-       s += sprintf(s, "BGCOLOR = %08lx\n", BGCOLOR);
-       s += sprintf(s, "DINTRS = %08lx\n", DINTRS);
-       s += sprintf(s, "DINTRE = %08lx\n", DINTRE);
-       s += sprintf(s, "DINTRCNT = %08lx\n", DINTRCNT);
-       s += sprintf(s, "DSIG = %08lx\n", DSIG);
-       s += sprintf(s, "DMCTRL = %08lx\n", DMCTRL);
-       s += sprintf(s, "CLIPCTRL = %08lx\n", CLIPCTRL);
-       s += sprintf(s, "SPOCTRL = %08lx\n", SPOCTRL);
-       s += sprintf(s, "SVCTRL = %08lx\n", SVCTRL);
-       s += sprintf(s, "DLSTS = %08lx\n", DLSTS);
-       s += sprintf(s, "DLLCTRL = %08lx\n", DLLCTRL);
-       s += sprintf(s, "DVLNUM = %08lx\n", DVLNUM);
-       s += sprintf(s, "DUCTRL = %08lx\n", DUCTRL);
-       s += sprintf(s, "DVECTRL = %08lx\n", DVECTRL);
-       s += sprintf(s, "DHDET = %08lx\n", DHDET);
-       s += sprintf(s, "DVDET = %08lx\n", DVDET);
-       s += sprintf(s, "DODMSK = %08lx\n", DODMSK);
-       s += sprintf(s, "CSC01 = %08lx\n", CSC01);
-       s += sprintf(s, "CSC02 = %08lx\n", CSC02);
-       s += sprintf(s, "CSC03 = %08lx\n", CSC03);
-       s += sprintf(s, "CSC04 = %08lx\n", CSC04);
-       s += sprintf(s, "CSC05 = %08lx\n", CSC05);
+       s += sprintf(s, "DSCTRL = %08x\n", readl(DSCTRL));
+       s += sprintf(s, "DHT01 = %08x\n", readl(DHT01));
+       s += sprintf(s, "DHT02 = %08x\n", readl(DHT02));
+       s += sprintf(s, "DHT03 = %08x\n", readl(DHT03));
+       s += sprintf(s, "DVT01 = %08x\n", readl(DVT01));
+       s += sprintf(s, "DVT02 = %08x\n", readl(DVT02));
+       s += sprintf(s, "DVT03 = %08x\n", readl(DVT03));
+       s += sprintf(s, "DBCOL = %08x\n", readl(DBCOL));
+       s += sprintf(s, "BGCOLOR = %08x\n", readl(BGCOLOR));
+       s += sprintf(s, "DINTRS = %08x\n", readl(DINTRS));
+       s += sprintf(s, "DINTRE = %08x\n", readl(DINTRE));
+       s += sprintf(s, "DINTRCNT = %08x\n", readl(DINTRCNT));
+       s += sprintf(s, "DSIG = %08x\n", readl(DSIG));
+       s += sprintf(s, "DMCTRL = %08x\n", readl(DMCTRL));
+       s += sprintf(s, "CLIPCTRL = %08x\n", readl(CLIPCTRL));
+       s += sprintf(s, "SPOCTRL = %08x\n", readl(SPOCTRL));
+       s += sprintf(s, "SVCTRL = %08x\n", readl(SVCTRL));
+       s += sprintf(s, "DLSTS = %08x\n", readl(DLSTS));
+       s += sprintf(s, "DLLCTRL = %08x\n", readl(DLLCTRL));
+       s += sprintf(s, "DVLNUM = %08x\n", readl(DVLNUM));
+       s += sprintf(s, "DUCTRL = %08x\n", readl(DUCTRL));
+       s += sprintf(s, "DVECTRL = %08x\n", readl(DVECTRL));
+       s += sprintf(s, "DHDET = %08x\n", readl(DHDET));
+       s += sprintf(s, "DVDET = %08x\n", readl(DVDET));
+       s += sprintf(s, "DODMSK = %08x\n", readl(DODMSK));
+       s += sprintf(s, "CSC01 = %08x\n", readl(CSC01));
+       s += sprintf(s, "CSC02 = %08x\n", readl(CSC02));
+       s += sprintf(s, "CSC03 = %08x\n", readl(CSC03));
+       s += sprintf(s, "CSC04 = %08x\n", readl(CSC04));
+       s += sprintf(s, "CSC05 = %08x\n", readl(CSC05));
 
        return  simple_read_from_buffer(userbuf, count, ppos,
                                        big_buffer, s-big_buffer);
@@ -113,24 +115,61 @@ static ssize_t clock_read_file(struct file *file, char __user *userbuf,
 {
        char * s = big_buffer;
 
-       s += sprintf(s, "SYSCLKSRC = %08lx\n", SYSCLKSRC);
-       s += sprintf(s, "PIXCLKSRC = %08lx\n", PIXCLKSRC);
-       s += sprintf(s, "CLKSLEEP = %08lx\n", CLKSLEEP);
-       s += sprintf(s, "COREPLL = %08lx\n", COREPLL);
-       s += sprintf(s, "DISPPLL = %08lx\n", DISPPLL);
-       s += sprintf(s, "PLLSTAT = %08lx\n", PLLSTAT);
-       s += sprintf(s, "VOVRCLK = %08lx\n", VOVRCLK);
-       s += sprintf(s, "PIXCLK = %08lx\n", PIXCLK);
-       s += sprintf(s, "MEMCLK = %08lx\n", MEMCLK);
-       s += sprintf(s, "M24CLK = %08lx\n", M24CLK);
-       s += sprintf(s, "MBXCLK = %08lx\n", MBXCLK);
-       s += sprintf(s, "SDCLK = %08lx\n", SDCLK);
-       s += sprintf(s, "PIXCLKDIV = %08lx\n", PIXCLKDIV);
+       s += sprintf(s, "SYSCLKSRC = %08x\n", readl(SYSCLKSRC));
+       s += sprintf(s, "PIXCLKSRC = %08x\n", readl(PIXCLKSRC));
+       s += sprintf(s, "CLKSLEEP = %08x\n", readl(CLKSLEEP));
+       s += sprintf(s, "COREPLL = %08x\n", readl(COREPLL));
+       s += sprintf(s, "DISPPLL = %08x\n", readl(DISPPLL));
+       s += sprintf(s, "PLLSTAT = %08x\n", readl(PLLSTAT));
+       s += sprintf(s, "VOVRCLK = %08x\n", readl(VOVRCLK));
+       s += sprintf(s, "PIXCLK = %08x\n", readl(PIXCLK));
+       s += sprintf(s, "MEMCLK = %08x\n", readl(MEMCLK));
+       s += sprintf(s, "M24CLK = %08x\n", readl(M24CLK));
+       s += sprintf(s, "MBXCLK = %08x\n", readl(MBXCLK));
+       s += sprintf(s, "SDCLK = %08x\n", readl(SDCLK));
+       s += sprintf(s, "PIXCLKDIV = %08x\n", readl(PIXCLKDIV));
 
        return  simple_read_from_buffer(userbuf, count, ppos,
                                        big_buffer, s-big_buffer);
 }
 
+static ssize_t sdram_read_file(struct file *file, char __user *userbuf,
+                              size_t count, loff_t *ppos)
+{
+       char * s = big_buffer;
+
+       s += sprintf(s, "LMRST = %08x\n", readl(LMRST));
+       s += sprintf(s, "LMCFG = %08x\n", readl(LMCFG));
+       s += sprintf(s, "LMPWR = %08x\n", readl(LMPWR));
+       s += sprintf(s, "LMPWRSTAT = %08x\n", readl(LMPWRSTAT));
+       s += sprintf(s, "LMCEMR = %08x\n", readl(LMCEMR));
+       s += sprintf(s, "LMTYPE = %08x\n", readl(LMTYPE));
+       s += sprintf(s, "LMTIM = %08x\n", readl(LMTIM));
+       s += sprintf(s, "LMREFRESH = %08x\n", readl(LMREFRESH));
+       s += sprintf(s, "LMPROTMIN = %08x\n", readl(LMPROTMIN));
+       s += sprintf(s, "LMPROTMAX = %08x\n", readl(LMPROTMAX));
+       s += sprintf(s, "LMPROTCFG = %08x\n", readl(LMPROTCFG));
+       s += sprintf(s, "LMPROTERR = %08x\n", readl(LMPROTERR));
+
+       return  simple_read_from_buffer(userbuf, count, ppos,
+                                       big_buffer, s-big_buffer);
+}
+
+static ssize_t misc_read_file(struct file *file, char __user *userbuf,
+                              size_t count, loff_t *ppos)
+{
+       char * s = big_buffer;
+
+       s += sprintf(s, "LCD_CONFIG = %08x\n", readl(LCD_CONFIG));
+       s += sprintf(s, "ODFBPWR = %08x\n", readl(ODFBPWR));
+       s += sprintf(s, "ODFBSTAT = %08x\n", readl(ODFBSTAT));
+       s += sprintf(s, "ID = %08x\n", readl(ID));
+
+       return  simple_read_from_buffer(userbuf, count, ppos,
+                                       big_buffer, s-big_buffer);
+}
+
+
 static struct file_operations sysconf_fops = {
        .read = sysconf_read_file,
        .write = write_file_dummy,
@@ -155,6 +194,17 @@ static struct file_operations gsctl_fops = {
        .open = open_file_generic,
 };
 
+static struct file_operations sdram_fops = {
+       .read = sdram_read_file,
+       .write = write_file_dummy,
+       .open = open_file_generic,
+};
+
+static struct file_operations misc_fops = {
+       .read = misc_read_file,
+       .write = write_file_dummy,
+       .open = open_file_generic,
+};
 
 static void __devinit mbxfb_debugfs_init(struct fb_info *fbi)
 {
@@ -173,6 +223,10 @@ static void __devinit mbxfb_debugfs_init(struct fb_info *fbi)
                                      fbi, &display_fops);
        dbg->gsctl = debugfs_create_file("gsctl", 0444, dbg->dir,
                                    fbi, &gsctl_fops);
+       dbg->sdram = debugfs_create_file("sdram", 0444, dbg->dir,
+                                       fbi, &sdram_fops);
+       dbg->misc = debugfs_create_file("misc", 0444, dbg->dir,
+                                       fbi, &misc_fops);
 }
 
 static void __devexit mbxfb_debugfs_remove(struct fb_info *fbi)
@@ -180,6 +234,8 @@ static void __devexit mbxfb_debugfs_remove(struct fb_info *fbi)
        struct mbxfb_info *mfbi = fbi->par;
        struct mbxfb_debugfs_data *dbg = mfbi->debugfs_data;
 
+       debugfs_remove(dbg->misc);
+       debugfs_remove(dbg->sdram);
        debugfs_remove(dbg->gsctl);
        debugfs_remove(dbg->display);
        debugfs_remove(dbg->clock);
index a32d1af79e07c4b349e2e88e65d8d9d4cf6bf4ab..980d5f6239026ea30f34fa0dac462de4342c3ce5 100644 (file)
@@ -1,8 +1,14 @@
 /*
  *  linux/drivers/video/mbx/mbxfb.c
  *
+ *  Copyright (C) 2006 8D Technologies inc
+ *  Raphael Assenat <raph@8d.com>
+ *     - Added video overlay support
+ *     - Various improvements
+ *
  *  Copyright (C) 2006 Compulab, Ltd.
  *  Mike Rapoport <mike@compulab.co.il>
+ *     - Creation of driver
  *
  *   Based on pxafb.c
  *
@@ -19,6 +25,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/uaccess.h>
 
 #include <asm/io.h>
 
 
 static unsigned long virt_base_2700;
 
+#define write_reg(val, reg) do { writel((val), (reg)); } while(0)
+
+/* Without this delay, the graphics appears somehow scaled and
+ * there is a lot of jitter in scanlines. This delay is probably
+ * needed only after setting some specific register(s) somewhere,
+ * not all over the place... */
+#define write_reg_dly(val, reg) do { writel((val), reg); udelay(1000); } while(0)
+
 #define MIN_XRES       16
 #define MIN_YRES       16
 #define MAX_XRES       2048
@@ -257,19 +272,17 @@ static int mbxfb_set_par(struct fb_info *info)
        gsctrl &= ~(FMsk(GSCTRL_GSWIDTH) | FMsk(GSCTRL_GSHEIGHT));
        gsctrl |= Gsctrl_Width(info->var.xres) |
                Gsctrl_Height(info->var.yres);
-       writel(gsctrl, GSCTRL);
-       udelay(1000);
+       write_reg_dly(gsctrl, GSCTRL);
 
        gsadr &= ~(FMsk(GSADR_SRCSTRIDE));
        gsadr |= Gsadr_Srcstride(info->var.xres * info->var.bits_per_pixel /
                                 (8 * 16) - 1);
-       writel(gsadr, GSADR);
-       udelay(1000);
+       write_reg_dly(gsadr, GSADR);
 
        /* setup timings */
        var->pixclock = mbxfb_get_pixclock(info->var.pixclock, &div);
 
-       writel((Disp_Pll_M(div.m) | Disp_Pll_N(div.n) |
+       write_reg_dly((Disp_Pll_M(div.m) | Disp_Pll_N(div.n) |
                Disp_Pll_P(div.p) | DISP_PLL_EN), DISPPLL);
 
        hbps = var->hsync_len;
@@ -282,18 +295,20 @@ static int mbxfb_set_par(struct fb_info *info)
        vfps = vas + var->yres;
        vt = vfps + var->lower_margin;
 
-       writel((Dht01_Hbps(hbps) | Dht01_Ht(ht)), DHT01);
-       writel((Dht02_Hlbs(has) | Dht02_Has(has)), DHT02);
-       writel((Dht03_Hfps(hfps) | Dht03_Hrbs(hfps)), DHT03);
-       writel((Dhdet_Hdes(has) | Dhdet_Hdef(hfps)), DHDET);
+       write_reg_dly((Dht01_Hbps(hbps) | Dht01_Ht(ht)), DHT01);
+       write_reg_dly((Dht02_Hlbs(has) | Dht02_Has(has)), DHT02);
+       write_reg_dly((Dht03_Hfps(hfps) | Dht03_Hrbs(hfps)), DHT03);
+       write_reg_dly((Dhdet_Hdes(has) | Dhdet_Hdef(hfps)), DHDET);
 
-       writel((Dvt01_Vbps(vbps) | Dvt01_Vt(vt)), DVT01);
-       writel((Dvt02_Vtbs(vas) | Dvt02_Vas(vas)), DVT02);
-       writel((Dvt03_Vfps(vfps) | Dvt03_Vbbs(vfps)), DVT03);
-       writel((Dvdet_Vdes(vas) | Dvdet_Vdef(vfps)), DVDET);
-       writel((Dvectrl_Vevent(vfps) | Dvectrl_Vfetch(vbps)), DVECTRL);
+       write_reg_dly((Dvt01_Vbps(vbps) | Dvt01_Vt(vt)), DVT01);
+       write_reg_dly((Dvt02_Vtbs(vas) | Dvt02_Vas(vas)), DVT02);
+       write_reg_dly((Dvt03_Vfps(vfps) | Dvt03_Vbbs(vfps)), DVT03);
+       write_reg_dly((Dvdet_Vdes(vas) | Dvdet_Vdef(vfps)), DVDET);
+       write_reg_dly((Dvectrl_Vevent(vfps) | Dvectrl_Vfetch(vbps)), DVECTRL);
 
-       writel((readl(DSCTRL) | DSCTRL_SYNCGEN_EN), DSCTRL);
+       write_reg_dly((readl(DSCTRL) | DSCTRL_SYNCGEN_EN), DSCTRL);
+
+       write_reg_dly(DINTRE_VEVENT0_EN, DINTRE);
 
        return 0;
 }
@@ -305,23 +320,203 @@ static int mbxfb_blank(int blank, struct fb_info *info)
        case FB_BLANK_VSYNC_SUSPEND:
        case FB_BLANK_HSYNC_SUSPEND:
        case FB_BLANK_NORMAL:
-               writel((readl(DSCTRL) & ~DSCTRL_SYNCGEN_EN), DSCTRL);
-               udelay(1000);
-               writel((readl(PIXCLK) & ~PIXCLK_EN), PIXCLK);
-               udelay(1000);
-               writel((readl(VOVRCLK) & ~VOVRCLK_EN), VOVRCLK);
-               udelay(1000);
+               write_reg_dly((readl(DSCTRL) & ~DSCTRL_SYNCGEN_EN), DSCTRL);
+               write_reg_dly((readl(PIXCLK) & ~PIXCLK_EN), PIXCLK);
+               write_reg_dly((readl(VOVRCLK) & ~VOVRCLK_EN), VOVRCLK);
                break;
        case FB_BLANK_UNBLANK:
-               writel((readl(DSCTRL) | DSCTRL_SYNCGEN_EN), DSCTRL);
-               udelay(1000);
-               writel((readl(PIXCLK) | PIXCLK_EN), PIXCLK);
-               udelay(1000);
+               write_reg_dly((readl(DSCTRL) | DSCTRL_SYNCGEN_EN), DSCTRL);
+               write_reg_dly((readl(PIXCLK) | PIXCLK_EN), PIXCLK);
                break;
        }
        return 0;
 }
 
+static int mbxfb_setupOverlay(struct mbxfb_overlaySetup *set)
+{
+       u32 vsctrl, vbbase, vscadr, vsadr;
+       u32 sssize, spoctrl, svctrl, shctrl;
+       u32 vubase, vvbase;
+       u32 vovrclk;
+
+       if (set->scaled_width==0 || set->scaled_height==0)
+               return -EINVAL;
+
+       /* read registers which have reserved bits
+        * so we can write them back as-is. */
+       vovrclk = readl(VOVRCLK);
+       vsctrl = readl(VSCTRL);
+       vscadr = readl(VSCADR);
+       vubase = readl(VUBASE);
+       vvbase = readl(VVBASE);
+
+       spoctrl = readl(SPOCTRL);
+       sssize = readl(SSSIZE);
+
+
+       vbbase = Vbbase_Glalpha(set->alpha);
+
+       vsctrl &= ~(    FMsk(VSCTRL_VSWIDTH) |
+                                       FMsk(VSCTRL_VSHEIGHT) |
+                                       FMsk(VSCTRL_VPIXFMT) |
+                                       VSCTRL_GAMMA_EN | VSCTRL_CSC_EN |
+                                       VSCTRL_COSITED );
+       vsctrl |= Vsctrl_Width(set->width) | Vsctrl_Height(set->height) |
+                               VSCTRL_CSC_EN;
+
+       vscadr &= ~(VSCADR_STR_EN | VSCADR_COLKEY_EN | VSCADR_COLKEYSRC |
+                               FMsk(VSCADR_BLEND_M) | FMsk(VSCADR_BLEND_POS) |
+                               FMsk(VSCADR_VBASE_ADR) );
+       vubase &= ~(VUBASE_UVHALFSTR | FMsk(VUBASE_UBASE_ADR));
+       vvbase &= ~(FMsk(VVBASE_VBASE_ADR));
+
+       switch (set->fmt)
+       {
+               case MBXFB_FMT_YUV12:
+                       vsctrl |= VSCTRL_VPIXFMT_YUV12;
+
+                       set->Y_stride = ((set->width) + 0xf ) & ~0xf;
+
+                       break;
+               case MBXFB_FMT_UY0VY1:
+                       vsctrl |= VSCTRL_VPIXFMT_UY0VY1;
+                       set->Y_stride = (set->width*2 + 0xf ) & ~0xf;
+                       break;
+               case MBXFB_FMT_VY0UY1:
+                       vsctrl |= VSCTRL_VPIXFMT_VY0UY1;
+                       set->Y_stride = (set->width*2 + 0xf ) & ~0xf;
+                       break;
+               case MBXFB_FMT_Y0UY1V:
+                       vsctrl |= VSCTRL_VPIXFMT_Y0UY1V;
+                       set->Y_stride = (set->width*2 + 0xf ) & ~0xf;
+                       break;
+               case MBXFB_FMT_Y0VY1U:
+                       vsctrl |= VSCTRL_VPIXFMT_Y0VY1U;
+                       set->Y_stride = (set->width*2 + 0xf ) & ~0xf;
+                       break;
+               default:
+                       return -EINVAL;
+       }
+
+       /* VSCTRL has the bits which sets the Video Pixel Format.
+        * When passing from a packed to planar format,
+        * if we write VSCTRL first, VVBASE and VUBASE would
+        * be zero if we would not set them here. (And then,
+        * the chips hangs and only a reset seems to fix it).
+        *
+        * If course, the values calculated here have no meaning
+        * for packed formats.
+        */
+       set->UV_stride = ((set->width/2) + 0x7 ) & ~0x7;
+               set->U_offset = set->height * set->Y_stride;
+               set->V_offset = set->U_offset +
+                                               set->height * set->UV_stride;
+       vubase |= Vubase_Ubase_Adr(
+                       (0x60000 + set->mem_offset + set->U_offset)>>3);
+       vvbase |= Vvbase_Vbase_Adr(
+                       (0x60000 + set->mem_offset + set->V_offset)>>3);
+
+
+       vscadr |= VSCADR_BLEND_VID | VSCADR_BLEND_GLOB |
+               Vscadr_Vbase_Adr((0x60000 + set->mem_offset)>>4);
+
+       if (set->enable)
+               vscadr |= VSCADR_STR_EN;
+
+
+       vsadr = Vsadr_Srcstride((set->Y_stride)/16-1) |
+               Vsadr_Xstart(set->x) | Vsadr_Ystart(set->y);
+
+       sssize &= ~(FMsk(SSSIZE_SC_WIDTH) | FMsk(SSSIZE_SC_HEIGHT));
+       sssize = Sssize_Sc_Width(set->scaled_width-1) |
+                       Sssize_Sc_Height(set->scaled_height-1);
+
+       spoctrl &= ~(SPOCTRL_H_SC_BP | SPOCTRL_V_SC_BP |
+                       SPOCTRL_HV_SC_OR | SPOCTRL_VS_UR_C |
+                       FMsk(SPOCTRL_VORDER) | FMsk(SPOCTRL_VPITCH));
+       spoctrl = Spoctrl_Vpitch((set->height<<11)/set->scaled_height)
+                                                       | SPOCTRL_VORDER_2TAP;
+
+       /* Bypass horiz/vert scaler when same size */
+       if (set->scaled_width == set->width)
+               spoctrl |= SPOCTRL_H_SC_BP;
+       if (set->scaled_height == set->height)
+               spoctrl |= SPOCTRL_V_SC_BP;
+
+       svctrl = Svctrl_Initial1(1<<10) | Svctrl_Initial2(1<<10);
+
+       shctrl = Shctrl_Hinitial(4<<11)
+                       | Shctrl_Hpitch((set->width<<11)/set->scaled_width);
+
+       /* Video plane registers */
+       write_reg(vsctrl, VSCTRL);
+       write_reg(vbbase, VBBASE);
+       write_reg(vscadr, VSCADR);
+       write_reg(vubase, VUBASE);
+       write_reg(vvbase, VVBASE);
+       write_reg(vsadr, VSADR);
+
+       /* Video scaler registers */
+       write_reg(sssize, SSSIZE);
+       write_reg(spoctrl, SPOCTRL);
+       write_reg(svctrl, SVCTRL);
+       write_reg(shctrl, SHCTRL);
+
+       /* RAPH: Using those coefficients, the scaled
+        * image is quite blurry. I dont know how
+        * to improve them ; The chip documentation
+        * was not helpful.. */
+       write_reg(0x21212121, VSCOEFF0);
+       write_reg(0x21212121, VSCOEFF1);
+       write_reg(0x21212121, VSCOEFF2);
+       write_reg(0x21212121, VSCOEFF3);
+       write_reg(0x21212121, VSCOEFF4);
+       write_reg(0x00000000, HSCOEFF0);
+       write_reg(0x00000000, HSCOEFF1);
+       write_reg(0x00000000, HSCOEFF2);
+       write_reg(0x03020201, HSCOEFF3);
+       write_reg(0x09070604, HSCOEFF4);
+       write_reg(0x0f0e0c0a, HSCOEFF5);
+       write_reg(0x15141211, HSCOEFF6);
+       write_reg(0x19181716, HSCOEFF7);
+       write_reg(0x00000019, HSCOEFF8);
+
+       /* Clock */
+       if (set->enable)
+               vovrclk |= 1;
+       else
+               vovrclk &= ~1;
+
+       write_reg(vovrclk, VOVRCLK);
+
+       return 0;
+}
+
+static int mbxfb_ioctl(struct fb_info *info, unsigned int cmd,
+                               unsigned long arg)
+{
+       struct mbxfb_overlaySetup setup;
+       int res;
+
+       if (cmd == MBXFB_IOCX_OVERLAY)
+       {
+               if (copy_from_user(&setup, (void __user*)arg,
+                                       sizeof(struct mbxfb_overlaySetup)))
+                       return -EFAULT;
+
+               res = mbxfb_setupOverlay(&setup);
+               if (res)
+                       return res;
+
+               if (copy_to_user((void __user*)arg, &setup,
+                                       sizeof(struct mbxfb_overlaySetup)))
+                       return -EFAULT;
+
+               return 0;
+       }
+       return -EINVAL;
+}
+
 static struct fb_ops mbxfb_ops = {
        .owner = THIS_MODULE,
        .fb_check_var = mbxfb_check_var,
@@ -331,6 +526,7 @@ static struct fb_ops mbxfb_ops = {
        .fb_copyarea = cfb_copyarea,
        .fb_imageblit = cfb_imageblit,
        .fb_blank = mbxfb_blank,
+       .fb_ioctl = mbxfb_ioctl,
 };
 
 /*
@@ -339,36 +535,29 @@ static struct fb_ops mbxfb_ops = {
 */
 static void __devinit setup_memc(struct fb_info *fbi)
 {
-       struct mbxfb_info *mfbi = fbi->par;
        unsigned long tmp;
        int i;
 
        /* FIXME: use platfrom specific parameters */
        /* setup SDRAM controller */
-       writel((LMCFG_LMC_DS | LMCFG_LMC_TS | LMCFG_LMD_TS |
+       write_reg_dly((LMCFG_LMC_DS | LMCFG_LMC_TS | LMCFG_LMD_TS |
                LMCFG_LMA_TS),
               LMCFG);
-       udelay(1000);
 
-       writel(LMPWR_MC_PWR_ACT, LMPWR);
-       udelay(1000);
+       write_reg_dly(LMPWR_MC_PWR_ACT, LMPWR);
 
        /* setup SDRAM timings */
-       writel((Lmtim_Tras(7) | Lmtim_Trp(3) | Lmtim_Trcd(3) |
+       write_reg_dly((Lmtim_Tras(7) | Lmtim_Trp(3) | Lmtim_Trcd(3) |
                Lmtim_Trc(9) | Lmtim_Tdpl(2)),
               LMTIM);
-       udelay(1000);
        /* setup SDRAM refresh rate */
-       writel(0xc2b, LMREFRESH);
-       udelay(1000);
+       write_reg_dly(0xc2b, LMREFRESH);
        /* setup SDRAM type parameters */
-       writel((LMTYPE_CASLAT_3 | LMTYPE_BKSZ_2 | LMTYPE_ROWSZ_11 |
+       write_reg_dly((LMTYPE_CASLAT_3 | LMTYPE_BKSZ_2 | LMTYPE_ROWSZ_11 |
                LMTYPE_COLSZ_8),
               LMTYPE);
-       udelay(1000);
        /* enable memory controller */
-       writel(LMPWR_MC_PWR_ACT, LMPWR);
-       udelay(1000);
+       write_reg_dly(LMPWR_MC_PWR_ACT, LMPWR);
 
        /* perform dummy reads */
        for ( i = 0; i < 16; i++ ) {
@@ -379,34 +568,30 @@ static void __devinit setup_memc(struct fb_info *fbi)
 static void enable_clocks(struct fb_info *fbi)
 {
        /* enable clocks */
-       writel(SYSCLKSRC_PLL_2, SYSCLKSRC);
-       udelay(1000);
-       writel(PIXCLKSRC_PLL_1, PIXCLKSRC);
-       udelay(1000);
-       writel(0x00000000, CLKSLEEP);
-       udelay(1000);
-       writel((Core_Pll_M(0x17) | Core_Pll_N(0x3) | Core_Pll_P(0x0) |
+       write_reg_dly(SYSCLKSRC_PLL_2, SYSCLKSRC);
+       write_reg_dly(PIXCLKSRC_PLL_1, PIXCLKSRC);
+       write_reg_dly(0x00000000, CLKSLEEP);
+
+       /* PLL output = (Frefclk * M) / (N * 2^P )
+        *
+        * M: 0x17, N: 0x3, P: 0x0 == 100 Mhz!
+        * M: 0xb, N: 0x1, P: 0x1 == 71 Mhz
+        * */
+       write_reg_dly((Core_Pll_M(0xb) | Core_Pll_N(0x1) | Core_Pll_P(0x1) |
                CORE_PLL_EN),
               COREPLL);
-       udelay(1000);
-       writel((Disp_Pll_M(0x1b) | Disp_Pll_N(0x7) | Disp_Pll_P(0x1) |
+
+       write_reg_dly((Disp_Pll_M(0x1b) | Disp_Pll_N(0x7) | Disp_Pll_P(0x1) |
                DISP_PLL_EN),
               DISPPLL);
 
-       writel(0x00000000, VOVRCLK);
-       udelay(1000);
-       writel(PIXCLK_EN, PIXCLK);
-       udelay(1000);
-       writel(MEMCLK_EN, MEMCLK);
-       udelay(1000);
-       writel(0x00000006, M24CLK);
-       udelay(1000);
-       writel(0x00000006, MBXCLK);
-       udelay(1000);
-       writel(SDCLK_EN, SDCLK);
-       udelay(1000);
-       writel(0x00000001, PIXCLKDIV);
-       udelay(1000);
+       write_reg_dly(0x00000000, VOVRCLK);
+       write_reg_dly(PIXCLK_EN, PIXCLK);
+       write_reg_dly(MEMCLK_EN, MEMCLK);
+       write_reg_dly(0x00000006, M24CLK);
+       write_reg_dly(0x00000006, MBXCLK);
+       write_reg_dly(SDCLK_EN, SDCLK);
+       write_reg_dly(0x00000001, PIXCLKDIV);
 }
 
 static void __devinit setup_graphics(struct fb_info *fbi)
@@ -430,16 +615,11 @@ static void __devinit setup_graphics(struct fb_info *fbi)
                break;
        }
 
-       writel(gsctrl, GSCTRL);
-       udelay(1000);
-       writel(0x00000000, GBBASE);
-       udelay(1000);
-       writel(0x00ffffff, GDRCTRL);
-       udelay(1000);
-       writel((GSCADR_STR_EN | Gscadr_Gbase_Adr(0x6000)), GSCADR);
-       udelay(1000);
-       writel(0x00000000, GPLUT);
-       udelay(1000);
+       write_reg_dly(gsctrl, GSCTRL);
+       write_reg_dly(0x00000000, GBBASE);
+       write_reg_dly(0x00ffffff, GDRCTRL);
+       write_reg_dly((GSCADR_STR_EN | Gscadr_Gbase_Adr(0x6000)), GSCADR);
+       write_reg_dly(0x00000000, GPLUT);
 }
 
 static void __devinit setup_display(struct fb_info *fbi)
@@ -451,17 +631,14 @@ static void __devinit setup_display(struct fb_info *fbi)
                dsctrl |= DSCTRL_HS_POL;
        if (fbi->var.sync & FB_SYNC_VERT_HIGH_ACT)
                dsctrl |= DSCTRL_VS_POL;
-       writel(dsctrl, DSCTRL);
-       udelay(1000);
-       writel(0xd0303010, DMCTRL);
-       udelay(1000);
-       writel((readl(DSCTRL) | DSCTRL_SYNCGEN_EN), DSCTRL);
+       write_reg_dly(dsctrl, DSCTRL);
+       write_reg_dly(0xd0303010, DMCTRL);
+       write_reg_dly((readl(DSCTRL) | DSCTRL_SYNCGEN_EN), DSCTRL);
 }
 
 static void __devinit enable_controller(struct fb_info *fbi)
 {
-       writel(SYSRST_RST, SYSRST);
-       udelay(1000);
+       write_reg_dly(SYSRST_RST, SYSRST);
 
 
        enable_clocks(fbi);
@@ -478,12 +655,12 @@ static void __devinit enable_controller(struct fb_info *fbi)
 static int mbxfb_suspend(struct platform_device *dev, pm_message_t state)
 {
        /* make frame buffer memory enter self-refresh mode */
-       writel(LMPWR_MC_PWR_SRM, LMPWR);
+       write_reg_dly(LMPWR_MC_PWR_SRM, LMPWR);
        while (LMPWRSTAT != LMPWRSTAT_MC_PWR_SRM)
                ; /* empty statement */
 
        /* reset the device, since it's initial state is 'mostly sleeping' */
-       writel(SYSRST_RST, SYSRST);
+       write_reg_dly(SYSRST_RST, SYSRST);
        return 0;
 }
 
@@ -495,7 +672,7 @@ static int mbxfb_resume(struct platform_device *dev)
 /*     setup_graphics(fbi); */
 /*     setup_display(fbi); */
 
-       writel((readl(DSCTRL) | DSCTRL_SYNCGEN_EN), DSCTRL);
+       write_reg_dly((readl(DSCTRL) | DSCTRL_SYNCGEN_EN), DSCTRL);
        return 0;
 }
 #else
@@ -520,6 +697,12 @@ static int __devinit mbxfb_probe(struct platform_device *dev)
 
        dev_dbg(dev, "mbxfb_probe\n");
 
+       pdata = dev->dev.platform_data;
+       if (!pdata) {
+               dev_err(&dev->dev, "platform data is required\n");
+               return -EINVAL;
+       }
+
        fbi = framebuffer_alloc(sizeof(struct mbxfb_info), &dev->dev);
        if (fbi == NULL) {
                dev_err(&dev->dev, "framebuffer_alloc failed\n");
@@ -528,7 +711,8 @@ static int __devinit mbxfb_probe(struct platform_device *dev)
 
        mfbi = fbi->par;
        fbi->pseudo_palette = mfbi->pseudo_palette;
-       pdata = dev->dev.platform_data;
+
+
        if (pdata->probe)
                mfbi->platform_probe = pdata->probe;
        if (pdata->remove)
@@ -578,16 +762,16 @@ static int __devinit mbxfb_probe(struct platform_device *dev)
                goto err4;
        }
 
-       /* FIXME: get from platform */
        fbi->screen_base = (char __iomem *)(mfbi->fb_virt_addr + 0x60000);
-       fbi->screen_size = 8 * 1024 * 1024;     /* 8 Megs */
+       fbi->screen_size = pdata->memsize;
        fbi->fbops = &mbxfb_ops;
 
        fbi->var = mbxfb_default;
        fbi->fix = mbxfb_fix;
        fbi->fix.smem_start = mfbi->fb_phys_addr + 0x60000;
-       fbi->fix.smem_len = 8 * 1024 * 1024;
-       fbi->fix.line_length = 640 * 2;
+       fbi->fix.smem_len = pdata->memsize;
+       fbi->fix.line_length = mbxfb_default.xres_virtual *
+                                       mbxfb_default.bits_per_pixel / 8;
 
        ret = fb_alloc_cmap(&fbi->cmap, 256, 0);
        if (ret < 0) {
@@ -636,8 +820,7 @@ static int __devexit mbxfb_remove(struct platform_device *dev)
 {
        struct fb_info *fbi = platform_get_drvdata(dev);
 
-       writel(SYSRST_RST, SYSRST);
-       udelay(1000);
+       write_reg_dly(SYSRST_RST, SYSRST);
 
        mbxfb_debugfs_remove(fbi);
 
index c226a8e45312c855f6452e7bf69caaed8164e0b6..9a24fb0c7d483f89a2df087f54f8a6502e1b212a 100644 (file)
 #define GPLUT_LUTDATA  Fld(24,0)
 #define Gplut_Lutdata(x)       ((x) << FShft(GPLUT_LUTDATA))
 
+/* VSCTRL - Video Surface Control Register */
+#define VSCTRL_VPIXFMT         Fld(4,27)
+#define VSCTRL_VPIXFMT_YUV12   ((0x9) << FShft(VSCTRL_VPIXFMT))
+#define VSCTRL_VPIXFMT_UY0VY1  ((0xc) << FShft(VSCTRL_VPIXFMT))
+#define VSCTRL_VPIXFMT_VY0UY1  ((0xd) << FShft(VSCTRL_VPIXFMT))
+#define VSCTRL_VPIXFMT_Y0UY1V  ((0xe) << FShft(VSCTRL_VPIXFMT))
+#define VSCTRL_VPIXFMT_Y0VY1U  ((0xf) << FShft(VSCTRL_VPIXFMT))
+#define VSCTRL_GAMMA_EN                (1 << 26)
+#define VSCTRL_CSC_EN          (1 << 25)
+#define VSCTRL_COSITED         (1 << 22)
+#define VSCTRL_VSWIDTH         Fld(11,11)
+#define Vsctrl_Width(Pixels) /* Video Width [1-2048] */ \
+                       (((Pixels) - 1) << FShft(VSCTRL_VSWIDTH))
+#define VSCTRL_VSHEIGHT                Fld(11,0)
+#define Vsctrl_Height(Pixels) /* Video Height [1-2048] */ \
+                       (((Pixels) - 1) << FShft(VSCTRL_VSHEIGHT))
+
+/* VBBASE - Video Blending Base Register */
+#define VBBASE_GLALPHA         Fld(8,24)
+#define Vbbase_Glalpha(x)      ((x) << FShft(VBBASE_GLALPHA))
+
+#define VBBASE_COLKEY          Fld(24,0)
+#define Vbbase_Colkey(x)       ((x) << FShft(VBBASE_COLKEY))
+
+/* VCMSK - Video Color Key Mask Register */
+#define VCMSK_COLKEY_M         Fld(24,0)
+#define Vcmsk_colkey_m(x)      ((x) << FShft(VCMSK_COLKEY_M))
+
+/* VSCADR - Video Stream Control Rddress Register */
+#define VSCADR_STR_EN          (1 << 31)
+#define VSCADR_COLKEY_EN       (1 << 30)
+#define VSCADR_COLKEYSRC       (1 << 29)
+#define VSCADR_BLEND_M         Fld(2,27)
+#define VSCADR_BLEND_NONE      ((0x0) << FShft(VSCADR_BLEND_M))
+#define VSCADR_BLEND_INV       ((0x1) << FShft(VSCADR_BLEND_M))
+#define VSCADR_BLEND_GLOB      ((0x2) << FShft(VSCADR_BLEND_M))
+#define VSCADR_BLEND_PIX       ((0x3) << FShft(VSCADR_BLEND_M))
+#define VSCADR_BLEND_POS       Fld(2,24)
+#define VSCADR_BLEND_GFX       ((0x0) << FShft(VSCADR_BLEND_POS))
+#define VSCADR_BLEND_VID       ((0x1) << FShft(VSCADR_BLEND_POS))
+#define VSCADR_BLEND_CUR       ((0x2) << FShft(VSCADR_BLEND_POS))
+#define VSCADR_VBASE_ADR       Fld(23,0)
+#define Vscadr_Vbase_Adr(x)    ((x) << FShft(VSCADR_VBASE_ADR))
+
+/* VUBASE - Video U Base Register */
+#define VUBASE_UVHALFSTR       (1 << 31)
+#define VUBASE_UBASE_ADR       Fld(24,0)
+#define Vubase_Ubase_Adr(x)    ((x) << FShft(VUBASE_UBASE_ADR))
+
+/* VVBASE - Video V Base Register */
+#define VVBASE_VBASE_ADR       Fld(24,0)
+#define Vvbase_Vbase_Adr(x)    ((x) << FShft(VVBASE_VBASE_ADR))
+
+/* VSADR - Video Stride Address Register */
+#define VSADR_SRCSTRIDE                Fld(10,22)
+#define Vsadr_Srcstride(x)     ((x) << FShft(VSADR_SRCSTRIDE))
+#define VSADR_XSTART           Fld(11,11)
+#define Vsadr_Xstart(x)                ((x) << FShft(VSADR_XSTART))
+#define VSADR_YSTART           Fld(11,0)
+#define Vsadr_Ystart(x)                ((x) << FShft(VSADR_YSTART))
+
 /* HCCTRL - Hardware Cursor Register fields */
 #define HCCTRL_CUR_EN  (1 << 31)
 #define HCCTRL_COLKEY_EN       (1 << 29)
 #define DMCTRL_BURSTLEN        Fld(6,0)
 #define Dmctrl_Burstlen(x)     ((x) << FShft(DMCTRL_BURSTLEN))
 
+/* DINTRS - Display Interrupt Status Register */
+#define DINTRS_CUR_OR_S                (1 << 18)
+#define DINTRS_STR2_OR_S       (1 << 17)
+#define DINTRS_STR1_OR_S       (1 << 16)
+#define DINTRS_CUR_UR_S                (1 << 6)
+#define DINTRS_STR2_UR_S       (1 << 5)
+#define DINTRS_STR1_UR_S       (1 << 4)
+#define DINTRS_VEVENT1_S       (1 << 3)
+#define DINTRS_VEVENT0_S       (1 << 2)
+#define DINTRS_HBLNK1_S                (1 << 1)
+#define DINTRS_HBLNK0_S                (1 << 0)
+
+/* DINTRE - Display Interrupt Enable Register */
+#define DINTRE_CUR_OR_EN       (1 << 18)
+#define DINTRE_STR2_OR_EN      (1 << 17)
+#define DINTRE_STR1_OR_EN      (1 << 16)
+#define DINTRE_CUR_UR_EN       (1 << 6)
+#define DINTRE_STR2_UR_EN      (1 << 5)
+#define DINTRE_STR1_UR_EN      (1 << 4)
+#define DINTRE_VEVENT1_EN      (1 << 3)
+#define DINTRE_VEVENT0_EN      (1 << 2)
+#define DINTRE_HBLNK1_EN       (1 << 1)
+#define DINTRE_HBLNK0_EN       (1 << 0)
+
 
 /* DLSTS - display load status register */
 #define DLSTS_RLD_ADONE        (1 << 23)
 #define DLLCTRL_RLD_ADRLN      Fld(8,24)
 #define Dllctrl_Rld_Adrln(x)   ((x) << FShft(DLLCTRL_RLD_ADRLN))
 
+/* CLIPCTRL - Clipping Control Register */
+#define CLIPCTRL_HSKIP         Fld(11,16)
+#define Clipctrl_Hskip         ((x) << FShft(CLIPCTRL_HSKIP))
+#define CLIPCTRL_VSKIP         Fld(11,0)
+#define Clipctrl_Vskip         ((x) << FShft(CLIPCTRL_VSKIP))
+
 /* SPOCTRL - Scale Pitch/Order Control Register */
 #define SPOCTRL_H_SC_BP                (1 << 31)
 #define SPOCTRL_V_SC_BP                (1 << 30)
 #define SPOCTRL_HV_SC_OR       (1 << 29)
 #define SPOCTRL_VS_UR_C                (1 << 27)
-#define SPOCTRL_VORDER Fld(2,16)
+#define SPOCTRL_VORDER         Fld(2,16)
 #define SPOCTRL_VORDER_1TAP    ((0x0) << FShft(SPOCTRL_VORDER))
 #define SPOCTRL_VORDER_2TAP    ((0x1) << FShft(SPOCTRL_VORDER))
 #define SPOCTRL_VORDER_4TAP    ((0x3) << FShft(SPOCTRL_VORDER))
-#define SPOCTRL_VPITCH Fld(16,0)
+#define SPOCTRL_VPITCH         Fld(16,0)
 #define Spoctrl_Vpitch(x)      ((x) << FShft(SPOCTRL_VPITCH))
 
+/* SVCTRL - Scale Vertical Control Register */
+#define SVCTRL_INITIAL1                Fld(16,16)
+#define Svctrl_Initial1(x)     ((x) << FShft(SVCTRL_INITIAL1))
+#define SVCTRL_INITIAL2                Fld(16,0)
+#define Svctrl_Initial2(x)     ((x) << FShft(SVCTRL_INITIAL2))
+
+/* SHCTRL - Scale Horizontal Control Register */
+#define SHCTRL_HINITIAL                Fld(16,16)
+#define Shctrl_Hinitial(x)     ((x) << FShft(SHCTRL_HINITIAL))
+#define SHCTRL_HDECIM          (1 << 15)
+#define SHCTRL_HPITCH          Fld(15,0)
+#define Shctrl_Hpitch(x)       ((x) << FShft(SHCTRL_HPITCH))
+
+/* SSSIZE - Scale Surface Size Register */
+#define SSSIZE_SC_WIDTH                Fld(11,16)
+#define Sssize_Sc_Width(x)     ((x) << FShft(SSSIZE_SC_WIDTH))
+#define SSSIZE_SC_HEIGHT       Fld(11,0)
+#define Sssize_Sc_Height(x)    ((x) << FShft(SSSIZE_SC_HEIGHT))
+
 #endif /* __REG_BITS_2700G_ */
index ad20be07666b75009f8d1021c0e7455b620a7e9c..a7c63d865aadeffd1e5fbabb3406e5c65c617c00 100644 (file)
 #define HSCOEFF0       __REG_2700G(0x000021b4)
 #define HSCOEFF1       __REG_2700G(0x000021b8)
 #define HSCOEFF2       __REG_2700G(0x000021bc)
-#define HSCOEFF3       __REG_2700G(0x000021b0)
+#define HSCOEFF3       __REG_2700G(0x000021c0)
 #define HSCOEFF4       __REG_2700G(0x000021c4)
 #define HSCOEFF5       __REG_2700G(0x000021c8)
 #define HSCOEFF6       __REG_2700G(0x000021cc)
index d1267904c280947aaac3916a659233f11fbe967d..5df41f6f2b86064f1b1db8d42a10ec5386ea4f4a 100644 (file)
@@ -34,8 +34,6 @@ const char *global_mode_option;
      *  Standard video mode definitions (taken from XFree86)
      */
 
-#define DEFAULT_MODEDB_INDEX   0
-
 static const struct fb_videomode modedb[] = {
     {
        /* 640x400 @ 70 Hz, 31.5 kHz hsync */
@@ -505,8 +503,10 @@ int fb_find_mode(struct fb_var_screeninfo *var,
        db = modedb;
        dbsize = ARRAY_SIZE(modedb);
     }
+
     if (!default_mode)
-       default_mode = &modedb[DEFAULT_MODEDB_INDEX];
+       default_mode = &db[0];
+
     if (!default_bpp)
        default_bpp = 8;
 
index 59a6f5fa5ae64992a25dee1357917ccfe8785d2c..deaf820cb38f798542271ef2ebf65277f5efc087 100644 (file)
@@ -1932,7 +1932,7 @@ static int __devinit neo_init_hw(struct fb_info *info)
        printk(KERN_DEBUG "--- Neo extended register dump ---\n");
        for (int w = 0; w < 0x85; w++)
                printk(KERN_DEBUG "CR %p: %p\n", (void *) w,
-                      (void *) vga_rcrt(NULL, w);
+                      (void *) vga_rcrt(NULL, w));
        for (int w = 0; w < 0xC7; w++)
                printk(KERN_DEBUG "GR %p: %p\n", (void *) w,
                       (void *) vga_rgfx(NULL, w));
index 4aefb8f41637277c520edad864d369d7fbbe897b..9efb8a3854e2671d18b5f944b855035a3c9c0029 100644 (file)
@@ -261,41 +261,6 @@ void NVResetGraphics(struct fb_info *info)
        NVDmaKickoff(par);
 }
 
-u8 byte_rev[256] = {
-       0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
-       0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
-       0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
-       0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
-       0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
-       0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
-       0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
-       0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
-       0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
-       0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
-       0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
-       0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
-       0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
-       0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
-       0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
-       0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
-       0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
-       0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
-       0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
-       0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
-       0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
-       0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
-       0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
-       0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
-       0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
-       0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
-       0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
-       0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
-       0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
-       0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
-       0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
-       0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
-};
-
 int nvidiafb_sync(struct fb_info *info)
 {
        struct nvidia_par *par = info->par;
index 19eef3a090232854860ad993365993dc7e5f68f6..442e85328341d63847e85e56a7910547b32b9a28 100644 (file)
@@ -210,11 +210,8 @@ int nvidia_probe_i2c_connector(struct fb_info *info, int conn, u8 **out_edid)
                /* try to get from firmware */
                const u8 *e = fb_firmware_edid(info->device);
 
-               if (e != NULL) {
-                       edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
-                       if (edid)
-                               memcpy(edid, e, EDID_LENGTH);
-               }
+               if (e != NULL)
+                       edid = kmemdup(e, EDID_LENGTH, GFP_KERNEL);
        }
 
        *out_edid = edid;
index 4243d7fae972a34fc0d197956fd760bb3d77db72..e009d242ea10c6de95bb0edf11e78a58619c1f68 100644 (file)
 #define READ_GET(par) (NV_RD32(&(par)->FIFO[0x0011], 0) >> 2)
 
 #ifdef __LITTLE_ENDIAN
+
+#include <linux/bitrev.h>
+
 #define reverse_order(l)        \
 do {                            \
        u8 *a = (u8 *)(l);      \
-       *a = byte_rev[*a], a++; \
-       *a = byte_rev[*a], a++; \
-       *a = byte_rev[*a], a++; \
-       *a = byte_rev[*a];      \
+       a[0] = bitrev8(a[0]);   \
+       a[1] = bitrev8(a[1]);   \
+       a[2] = bitrev8(a[2]);   \
+       a[3] = bitrev8(a[3]);   \
 } while(0)
 #else
 #define reverse_order(l) do { } while(0)
index d9af88c2b580ec9b0cc5923151d506a4dc9ed0f0..181875fe35c662899e5964d52da76d7ca6a483ce 100644 (file)
@@ -72,10 +72,9 @@ int nvidia_probe_of_connector(struct fb_info *info, int conn, u8 **out_edid)
                }
        }
        if (pedid) {
-               *out_edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
+               *out_edid = kmemdup(pedid, EDID_LENGTH, GFP_KERNEL);
                if (*out_edid == NULL)
                        return -1;
-               memcpy(*out_edid, pedid, EDID_LENGTH);
                printk(KERN_DEBUG "nvidiafb: Found OF EDID for head %d\n", conn);
                return 0;
        }
index 861271017655cd8694715047394100a684d94d42..43058d0cf5b7b86a47961dacd2da8a77708d89f1 100644 (file)
@@ -62,7 +62,6 @@ extern void nvidiafb_fillrect(struct fb_info *info,
 extern void nvidiafb_imageblit(struct fb_info *info,
                               const struct fb_image *image);
 extern int nvidiafb_sync(struct fb_info *info);
-extern u8 byte_rev[256];
 
 /* in nv_backlight.h */
 #ifdef CONFIG_FB_NVIDIA_BACKLIGHT
index 9a40bbecf76b1293fe15df72c37bd9df9303a169..9576a55eaf165c73b1489f700ecd0df205a5f798 100644 (file)
@@ -402,6 +402,9 @@ static void __init offb_init_fb(const char *name, const char *full_name,
        fb_alloc_cmap(&info->cmap, 256, 0);
 
        if (register_framebuffer(info) < 0) {
+               iounmap(par->cmap_adr);
+               par->cmap_adr = NULL;
+               iounmap(info->screen_base);
                kfree(info);
                release_mem_region(res_start, res_size);
                return;
index cb26c6df0583f41cc94d30807e69aae468923ab2..2338716558243bd4e0807283a10af67a974f3b3b 100644 (file)
@@ -627,6 +627,9 @@ static int __devinit platinumfb_probe(struct of_device* odev,
        
        rc = platinum_init_fb(info);
        if (rc != 0) {
+               iounmap(pinfo->frame_buffer);
+               iounmap(pinfo->platinum_regs);
+               iounmap(pinfo->cmap_regs);
                dev_set_drvdata(&odev->dev, NULL);
                framebuffer_release(info);
        }
index 73e2d7d1660835a8f26ae3669c3486ea18e8cf80..a06a064ad7575bf6cd9e0126d9f8312f95689d79 100644 (file)
@@ -186,7 +186,7 @@ static void __init pmagbbfb_screen_setup(struct fb_info *info)
 static void __init pmagbbfb_osc_setup(struct fb_info *info)
 {
        static unsigned int pmagbbfb_freqs[] __initdata = {
-               130808, 119843, 104000, 92980, 74367, 72800,
+               130808, 119843, 104000, 92980, 74370, 72800,
                69197, 66000, 65000, 50350, 36000, 32000, 25175
        };
        struct pmagbbfb_par *par = info->par;
index c7bc80921f1613196deeca432f015451184b4c87..a93618bc9d274527fd627f4decdabb96347ff05f 100644 (file)
@@ -905,6 +905,15 @@ static int __init pvr2fb_dc_init(void)
 
 static void pvr2fb_dc_exit(void)
 {
+       if (fb_info->screen_base) {
+               iounmap(fb_info->screen_base);
+               fb_info->screen_base = NULL;
+       }
+       if (currentpar->mmio_base) {
+               iounmap((void *)currentpar->mmio_base);
+               currentpar->mmio_base = 0;
+       }
+
        free_irq(HW_EVENT_VSYNC, 0);
 #ifdef CONFIG_SH_DMA
        free_dma(pvr2dma);
@@ -946,6 +955,15 @@ static int __devinit pvr2fb_pci_probe(struct pci_dev *pdev,
 
 static void __devexit pvr2fb_pci_remove(struct pci_dev *pdev)
 {
+       if (fb_info->screen_base) {
+               iounmap(fb_info->screen_base);
+               fb_info->screen_base = NULL;
+       }
+       if (currentpar->mmio_base) {
+               iounmap((void *)currentpar->mmio_base);
+               currentpar->mmio_base = 0;
+       }
+
        pci_release_regions(pdev);
 }
 
index cf41ff177644c3d9ecdb843a2f1790f5d73fb314..bc7ffc84e1855cf0276b1a6e0470a26cf8abb184 100644 (file)
@@ -1423,8 +1423,10 @@ int __init retz3fb_init(void)
 
                do_install_cmap(0, fb_info);
 
-               if (register_framebuffer(fb_info) < 0)
+               if (register_framebuffer(fb_info) < 0) {
+                       iounmap(zinfo->base);
                        return -EINVAL;
+               }
 
                printk(KERN_INFO "fb%d: %s frame buffer device, using %ldK of "
                       "video memory\n", fb_info->node,
index a433cc78ef90b1d7c11639c52c838ae56457f504..345e8b1c1af86cbc89378ca988dd28ca40d89224 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/backlight.h>
+#include <linux/bitrev.h>
 #ifdef CONFIG_MTRR
 #include <asm/mtrr.h>
 #endif
@@ -521,48 +522,13 @@ static inline unsigned char MISCin(struct riva_par *par)
        return (VGA_RD08(par->riva.PVIO, 0x3cc));
 }
 
-static u8 byte_rev[256] = {
-       0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
-       0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
-       0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
-       0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
-       0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
-       0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
-       0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
-       0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
-       0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
-       0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
-       0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
-       0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
-       0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
-       0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
-       0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
-       0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
-       0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
-       0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
-       0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
-       0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
-       0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
-       0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
-       0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
-       0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
-       0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
-       0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
-       0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
-       0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
-       0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
-       0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
-       0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
-       0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
-};
-
 static inline void reverse_order(u32 *l)
 {
        u8 *a = (u8 *)l;
-       *a = byte_rev[*a], a++;
-       *a = byte_rev[*a], a++;
-       *a = byte_rev[*a], a++;
-       *a = byte_rev[*a];
+       a[0] = bitrev8(a[0]);
+       a[1] = bitrev8(a[1]);
+       a[2] = bitrev8(a[2]);
+       a[3] = bitrev8(a[3]);
 }
 
 /* ------------------------------------------------------------------------- *
@@ -774,11 +740,12 @@ static void riva_load_state(struct riva_par *par, struct riva_regs *regs)
  * CALLED FROM:
  * rivafb_set_par()
  */
-static void riva_load_video_mode(struct fb_info *info)
+static int riva_load_video_mode(struct fb_info *info)
 {
        int bpp, width, hDisplaySize, hDisplay, hStart,
            hEnd, hTotal, height, vDisplay, vStart, vEnd, vTotal, dotClock;
        int hBlankStart, hBlankEnd, vBlankStart, vBlankEnd;
+       int rc;
        struct riva_par *par = info->par;
        struct riva_regs newmode;
        
@@ -884,8 +851,10 @@ static void riva_load_video_mode(struct fb_info *info)
        else
                newmode.misc_output |= 0x80;    
 
-       par->riva.CalcStateExt(&par->riva, &newmode.ext, bpp, width,
-                                 hDisplaySize, height, dotClock);
+       rc = CalcStateExt(&par->riva, &newmode.ext, bpp, width,
+                         hDisplaySize, height, dotClock);
+       if (rc)
+               goto out;
 
        newmode.ext.scale = NV_RD32(par->riva.PRAMDAC, 0x00000848) &
                0xfff000ff;
@@ -917,8 +886,12 @@ static void riva_load_video_mode(struct fb_info *info)
        par->current_state = newmode;
        riva_load_state(par, &par->current_state);
        par->riva.LockUnlock(&par->riva, 0); /* important for HW cursor */
+
+out:
        rivafb_blank(FB_BLANK_UNBLANK, info);
        NVTRACE_LEAVE();
+
+       return rc;
 }
 
 static void riva_update_var(struct fb_var_screeninfo *var, struct fb_videomode *modedb)
@@ -1286,12 +1259,15 @@ static int rivafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
 static int rivafb_set_par(struct fb_info *info)
 {
        struct riva_par *par = info->par;
+       int rc = 0;
 
        NVTRACE_ENTER();
        /* vgaHWunlock() + riva unlock (0x7F) */
        CRTCout(par, 0x11, 0xFF);
        par->riva.LockUnlock(&par->riva, 0);
-       riva_load_video_mode(info);
+       rc = riva_load_video_mode(info);
+       if (rc)
+               goto out;
        if(!(info->flags & FBINFO_HWACCEL_DISABLED))
                riva_setup_accel(info);
        
@@ -1304,8 +1280,10 @@ static int rivafb_set_par(struct fb_info *info)
                info->pixmap.scan_align = 1;
        else
                info->pixmap.scan_align = 4;
+
+out:
        NVTRACE_LEAVE();
-       return 0;
+       return rc;
 }
 
 /**
index b6f8690b96c9eed89b9bf80d28269a71605978ed..e0b8c521cc9ca008a4c5e27459348a5a6497315f 100644 (file)
@@ -1227,7 +1227,7 @@ static int CalcVClock
  * Calculate extended mode parameters (SVGA) and save in a 
  * mode state structure.
  */
-static void CalcStateExt
+int CalcStateExt
 (
     RIVA_HW_INST  *chip,
     RIVA_HW_STATE *state,
@@ -1249,7 +1249,8 @@ static void CalcStateExt
      * Extended RIVA registers.
      */
     pixelDepth = (bpp + 1)/8;
-    CalcVClock(dotClock, &VClk, &m, &n, &p, chip);
+    if (!CalcVClock(dotClock, &VClk, &m, &n, &p, chip))
+       return -EINVAL;
 
     switch (chip->Architecture)
     {
@@ -1327,6 +1328,8 @@ static void CalcStateExt
     state->pitch1   =
     state->pitch2   =
     state->pitch3   = pixelDepth * width;
+
+    return 0;
 }
 /*
  * Load fixed function state and pre-calculated/stored state.
@@ -2026,7 +2029,6 @@ static void nv3GetConfig
      */
     chip->Busy            = nv3Busy;
     chip->ShowHideCursor  = ShowHideCursor;
-    chip->CalcStateExt    = CalcStateExt;
     chip->LoadStateExt    = LoadStateExt;
     chip->UnloadStateExt  = UnloadStateExt;
     chip->SetStartAddress = SetStartAddress3;
@@ -2084,7 +2086,6 @@ static void nv4GetConfig
      */
     chip->Busy            = nv4Busy;
     chip->ShowHideCursor  = ShowHideCursor;
-    chip->CalcStateExt    = CalcStateExt;
     chip->LoadStateExt    = LoadStateExt;
     chip->UnloadStateExt  = UnloadStateExt;
     chip->SetStartAddress = SetStartAddress;
@@ -2186,7 +2187,6 @@ static void nv10GetConfig
      */
     chip->Busy            = nv10Busy;
     chip->ShowHideCursor  = ShowHideCursor;
-    chip->CalcStateExt    = CalcStateExt;
     chip->LoadStateExt    = LoadStateExt;
     chip->UnloadStateExt  = UnloadStateExt;
     chip->SetStartAddress = SetStartAddress;
index a1e71a626df2b8e13ba039ed17536f81b2814281..c2769f73e0b2a23ca677c53bf86d78006005e826 100644 (file)
@@ -463,7 +463,6 @@ typedef struct _riva_hw_inst
      * Common chip functions.
      */
     int  (*Busy)(struct _riva_hw_inst *);
-    void (*CalcStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *,int,int,int,int,int);
     void (*LoadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *);
     void (*UnloadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *);
     void (*SetStartAddress)(struct _riva_hw_inst *,U032);
@@ -528,6 +527,22 @@ typedef struct _riva_hw_state
     U032 pitch2;
     U032 pitch3;
 } RIVA_HW_STATE;
+
+/*
+ * function prototypes
+ */
+
+extern int CalcStateExt
+(
+    RIVA_HW_INST  *chip,
+    RIVA_HW_STATE *state,
+    int            bpp,
+    int            width,
+    int            hDisplaySize,
+    int            height,
+    int            dotClock
+);
+
 /*
  * External routines.
  */
index 59407343cc731d25322d025e9b7485fb814551d5..ccef56d0c15794fced4c4c71b93a2ce21288f0a3 100644 (file)
@@ -131,7 +131,7 @@ static void s3c2410fb_set_lcdaddr(struct s3c2410fb_info *fbi)
        saddr2 += (var->xres * var->yres * var->bits_per_pixel)/8;
        saddr2>>= 1;
 
-       saddr3 =  S3C2410_OFFSIZE(0) | S3C2410_PAGEWIDTH(var->xres);
+       saddr3 =  S3C2410_OFFSIZE(0) | S3C2410_PAGEWIDTH((var->xres * var->bits_per_pixel / 16) & 0x3ff);
 
        dprintk("LCDSADDR1 = 0x%08lx\n", saddr1);
        dprintk("LCDSADDR2 = 0x%08lx\n", saddr2);
@@ -199,28 +199,86 @@ static int s3c2410fb_check_var(struct fb_var_screeninfo *var,
                var->bits_per_pixel = fbi->mach_info->bpp.min;
 
        /* set r/g/b positions */
+       switch (var->bits_per_pixel) {
+               case 1:
+               case 2:
+               case 4:
+                       var->red.offset         = 0;
+                       var->red.length         = var->bits_per_pixel;
+                       var->green              = var->red;
+                       var->blue               = var->red;
+                       var->transp.offset      = 0;
+                       var->transp.length      = 0;
+                       break;
+               case 8:
+                       if ( fbi->mach_info->type != S3C2410_LCDCON1_TFT ) {
+                               /* 8 bpp 332 */
+                               var->red.length         = 3;
+                               var->red.offset         = 5;
+                               var->green.length       = 3;
+                               var->green.offset       = 2;
+                               var->blue.length        = 2;
+                               var->blue.offset        = 0;
+                               var->transp.length      = 0;
+                       } else {
+                               var->red.offset         = 0;
+                               var->red.length         = var->bits_per_pixel;
+                               var->green              = var->red;
+                               var->blue               = var->red;
+                               var->transp.offset      = 0;
+                               var->transp.length      = 0;
+                       }
+                       break;
+               case 12:
+                       /* 12 bpp 444 */
+                       var->red.length         = 4;
+                       var->red.offset         = 8;
+                       var->green.length       = 4;
+                       var->green.offset       = 4;
+                       var->blue.length        = 4;
+                       var->blue.offset        = 0;
+                       var->transp.length      = 0;
+                       break;
+
+               default:
+               case 16:
+                       if (fbi->regs.lcdcon5 & S3C2410_LCDCON5_FRM565 ) {
+                               /* 16 bpp, 565 format */
+                               var->red.offset         = 11;
+                               var->green.offset       = 5;
+                               var->blue.offset        = 0;
+                               var->red.length         = 5;
+                               var->green.length       = 6;
+                               var->blue.length        = 5;
+                               var->transp.length      = 0;
+                       } else {
+                               /* 16 bpp, 5551 format */
+                               var->red.offset         = 11;
+                               var->green.offset       = 6;
+                               var->blue.offset        = 1;
+                               var->red.length         = 5;
+                               var->green.length       = 5;
+                               var->blue.length        = 5;
+                               var->transp.length      = 0;
+                       }
+                       break;
+               case 24:
+                       /* 24 bpp 888 */
+                       var->red.length         = 8;
+                       var->red.offset         = 16;
+                       var->green.length       = 8;
+                       var->green.offset       = 8;
+                       var->blue.length        = 8;
+                       var->blue.offset        = 0;
+                       var->transp.length      = 0;
+                       break;
 
-       if (var->bits_per_pixel == 16) {
-               var->red.offset         = 11;
-               var->green.offset       = 5;
-               var->blue.offset        = 0;
-               var->red.length         = 5;
-               var->green.length       = 6;
-               var->blue.length        = 5;
-               var->transp.length      = 0;
-       } else {
-               var->red.length         = var->bits_per_pixel;
-               var->red.offset         = 0;
-               var->green.length       = var->bits_per_pixel;
-               var->green.offset       = 0;
-               var->blue.length        = var->bits_per_pixel;
-               var->blue.offset        = 0;
-               var->transp.length      = 0;
-       }
 
+       }
        return 0;
 }
 
+
 /* s3c2410fb_activate_var
  *
  * activate (set) the controller from the given framebuffer
@@ -230,29 +288,61 @@ static int s3c2410fb_check_var(struct fb_var_screeninfo *var,
 static void s3c2410fb_activate_var(struct s3c2410fb_info *fbi,
                                   struct fb_var_screeninfo *var)
 {
+       int hs;
+
        fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_MODEMASK;
+       fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_TFT;
 
        dprintk("%s: var->xres  = %d\n", __FUNCTION__, var->xres);
        dprintk("%s: var->yres  = %d\n", __FUNCTION__, var->yres);
        dprintk("%s: var->bpp   = %d\n", __FUNCTION__, var->bits_per_pixel);
 
-       switch (var->bits_per_pixel) {
-       case 1:
-               fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT1BPP;
-               break;
-       case 2:
-               fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT2BPP;
-               break;
-       case 4:
-               fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT4BPP;
-               break;
-       case 8:
-               fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT8BPP;
-               break;
-       case 16:
-               fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT16BPP;
-               break;
-       }
+       fbi->regs.lcdcon1 |= fbi->mach_info->type;
+
+       if (fbi->mach_info->type == S3C2410_LCDCON1_TFT)
+               switch (var->bits_per_pixel) {
+               case 1:
+                       fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT1BPP;
+                       break;
+               case 2:
+                       fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT2BPP;
+                       break;
+               case 4:
+                       fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT4BPP;
+                       break;
+               case 8:
+                       fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT8BPP;
+                       break;
+               case 16:
+                       fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT16BPP;
+                       break;
+
+               default:
+                       /* invalid pixel depth */
+                       dev_err(fbi->dev, "invalid bpp %d\n", var->bits_per_pixel);
+               }
+       else
+               switch (var->bits_per_pixel) {
+               case 1:
+                       fbi->regs.lcdcon1 |= S3C2410_LCDCON1_STN1BPP;
+                       break;
+               case 2:
+                       fbi->regs.lcdcon1 |= S3C2410_LCDCON1_STN2GREY;
+                       break;
+               case 4:
+                       fbi->regs.lcdcon1 |= S3C2410_LCDCON1_STN4GREY;
+                       break;
+               case 8:
+                       fbi->regs.lcdcon1 |= S3C2410_LCDCON1_STN8BPP;
+                       break;
+               case 12:
+                       fbi->regs.lcdcon1 |= S3C2410_LCDCON1_STN12BPP;
+                       break;
+
+               default:
+                       /* invalid pixel depth */
+                       dev_err(fbi->dev, "invalid bpp %d\n", var->bits_per_pixel);
+               }
 
        /* check to see if we need to update sync/borders */
 
@@ -283,15 +373,44 @@ static void s3c2410fb_activate_var(struct s3c2410fb_info *fbi,
        fbi->regs.lcdcon2 &= ~S3C2410_LCDCON2_LINEVAL(0x3ff);
        fbi->regs.lcdcon2 |=  S3C2410_LCDCON2_LINEVAL(var->yres - 1);
 
+       switch(fbi->mach_info->type) {
+               case S3C2410_LCDCON1_DSCAN4:
+               case S3C2410_LCDCON1_STN8:
+                       hs = var->xres / 8;
+                       break;
+               case S3C2410_LCDCON1_STN4:
+                       hs = var->xres / 4;
+                       break;
+               default:
+               case S3C2410_LCDCON1_TFT:
+                       hs = var->xres;
+                       break;
+
+       }
+
+       /* Special cases : STN color displays */
+       if ( ((fbi->regs.lcdcon1 & S3C2410_LCDCON1_MODEMASK) == S3C2410_LCDCON1_STN8BPP) \
+         || ((fbi->regs.lcdcon1 & S3C2410_LCDCON1_MODEMASK) == S3C2410_LCDCON1_STN12BPP) ) {
+               hs = hs * 3;
+       }
+
+
        fbi->regs.lcdcon3 &= ~S3C2410_LCDCON3_HOZVAL(0x7ff);
-       fbi->regs.lcdcon3 |=  S3C2410_LCDCON3_HOZVAL(var->xres - 1);
+       fbi->regs.lcdcon3 |=  S3C2410_LCDCON3_HOZVAL(hs - 1);
 
        if (var->pixclock > 0) {
                int clkdiv = s3c2410fb_calc_pixclk(fbi, var->pixclock);
 
-               clkdiv = (clkdiv / 2) -1;
-               if (clkdiv < 0)
-                       clkdiv = 0;
+               if (fbi->mach_info->type == S3C2410_LCDCON1_TFT) {
+                       clkdiv = (clkdiv / 2) -1;
+                       if (clkdiv < 0)
+                               clkdiv = 0;
+               }
+               else {
+                       clkdiv = (clkdiv / 2);
+                       if (clkdiv < 2)
+                               clkdiv = 2;
+               }
 
                fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_CLKVAL(0x3ff);
                fbi->regs.lcdcon1 |=  S3C2410_LCDCON1_CLKVAL(clkdiv);
@@ -329,10 +448,18 @@ static int s3c2410fb_set_par(struct fb_info *info)
        struct s3c2410fb_info *fbi = info->par;
        struct fb_var_screeninfo *var = &info->var;
 
-       if (var->bits_per_pixel == 16)
-               fbi->fb->fix.visual = FB_VISUAL_TRUECOLOR;
-       else
-               fbi->fb->fix.visual = FB_VISUAL_PSEUDOCOLOR;
+       switch (var->bits_per_pixel)
+       {
+               case 16:
+                       fbi->fb->fix.visual = FB_VISUAL_TRUECOLOR;
+                       break;
+               case 1:
+                        fbi->fb->fix.visual = FB_VISUAL_MONO01;
+                        break;
+               default:
+                        fbi->fb->fix.visual = FB_VISUAL_PSEUDOCOLOR;
+                        break;
+       }
 
        fbi->fb->fix.line_length     = (var->width*var->bits_per_pixel)/8;
 
index 3f94223b7f0ca86c4b76a01553c6b89240c388e9..cef5bf591cdf26413daa85d74c20d1b197b2c8f0 100644 (file)
@@ -227,11 +227,8 @@ int savagefb_probe_i2c_connector(struct fb_info *info, u8 **out_edid)
                /* try to get from firmware */
                const u8 *e = fb_firmware_edid(info->device);
 
-               if (e) {
-                       edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
-                       if (edid)
-                               memcpy(edid, e, EDID_LENGTH);
-               }
+               if (e)
+                       edid = kmemdup(e, EDID_LENGTH, GFP_KERNEL);
        }
 
        *out_edid = edid;
index f13faddc618102f3040a8370ace0203f2344372a..47e1896cffeb83d4b94b5b5a535b338cdf4b0279 100644 (file)
@@ -445,11 +445,8 @@ SiS_CR36BIOSWord23d(struct SiS_Private *SiS_Pr)
 void
 SiS_DDC2Delay(struct SiS_Private *SiS_Pr, unsigned int delaytime)
 {
-   unsigned int i, j;
-
-   for(i = 0; i < delaytime; i++) {
-      j += SiS_GetReg(SiS_Pr->SiS_P3c4,0x05);
-   }
+   while (delaytime-- > 0)
+      SiS_GetReg(SiS_Pr->SiS_P3c4, 0x05);
 }
 
 #if defined(SIS300) || defined(SIS315H)
index 3e16e2d9d55dd50a39187b9d332e41b67b4723e1..69f3b264a22ec5a900afea7706f4649d820cda81 100644 (file)
@@ -1291,6 +1291,7 @@ out_err3:
 out_err2:
        release_mem_region(fix->smem_start, fix->smem_len);
 out_err1:
+       iounmap(info->screen_base);
        fb_dealloc_cmap(&info->cmap);
 out_err0:
        kfree(fb);
@@ -1364,6 +1365,8 @@ stifb_cleanup(void)
                        unregister_framebuffer(sti->info);
                        release_mem_region(info->fix.mmio_start, info->fix.mmio_len);
                        release_mem_region(info->fix.smem_start, info->fix.smem_len);
+                               if (info->screen_base)
+                                       iounmap(info->screen_base);
                        fb_dealloc_cmap(&info->cmap);
                        kfree(info); 
                }
index 94fde625a6c070b61a96b786720e4c3be2ac060e..4b88fab83b74bdbc008e8c3e86910e5549c79dac 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/fb.h>
 #include <linux/pci.h>
 #include <linux/selection.h>
+#include <linux/bitrev.h>
 #include <asm/io.h>
 #include <video/tgafb.h>
 
@@ -517,41 +518,6 @@ tgafb_blank(int blank, struct fb_info *info)
 static void
 tgafb_imageblit(struct fb_info *info, const struct fb_image *image)
 {
-       static unsigned char const bitrev[256] = {
-               0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
-               0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
-               0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
-               0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
-               0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
-               0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
-               0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
-               0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
-               0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
-               0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
-               0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
-               0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
-               0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
-               0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
-               0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
-               0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
-               0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
-               0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
-               0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
-               0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
-               0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
-               0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
-               0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
-               0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
-               0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
-               0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
-               0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
-               0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
-               0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
-               0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
-               0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
-               0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
-       };
-
        struct tga_par *par = (struct tga_par *) info->par;
        u32 fgcolor, bgcolor, dx, dy, width, height, vxres, vyres, pixelmask;
        unsigned long rincr, line_length, shift, pos, is8bpp;
@@ -649,7 +615,7 @@ tgafb_imageblit(struct fb_info *info, const struct fb_image *image)
                        /* The image data is bit big endian; we need
                           little endian.  */
                        for (j = 0; j < bwidth; ++j)
-                               mask |= bitrev[data[j]] << (j * 8);
+                               mask |= bitrev8(data[j]) << (j * 8);
 
                        __raw_writel(mask << shift, fb_base + pos);
 
@@ -676,10 +642,10 @@ tgafb_imageblit(struct fb_info *info, const struct fb_image *image)
                for (i = 0; i < height; ++i) {
                        for (j = 0; j < bwidth; j += 4) {
                                u32 mask = 0;
-                               mask |= bitrev[data[j+0]] << (0 * 8);
-                               mask |= bitrev[data[j+1]] << (1 * 8);
-                               mask |= bitrev[data[j+2]] << (2 * 8);
-                               mask |= bitrev[data[j+3]] << (3 * 8);
+                               mask |= bitrev8(data[j+0]) << (0 * 8);
+                               mask |= bitrev8(data[j+1]) << (1 * 8);
+                               mask |= bitrev8(data[j+2]) << (2 * 8);
+                               mask |= bitrev8(data[j+3]) << (3 * 8);
                                __raw_writel(mask, fb_base + pos + j*bincr);
                        }
                        pos += line_length;
@@ -699,7 +665,7 @@ tgafb_imageblit(struct fb_info *info, const struct fb_image *image)
                        for (i = 0; i < height; ++i) {
                                u32 mask = 0;
                                for (j = 0; j < bwidth; ++j)
-                                       mask |= bitrev[data[j]] << (j * 8);
+                                       mask |= bitrev8(data[j]) << (j * 8);
                                __raw_writel(mask, fb_base + pos);
                                pos += line_length;
                                data += rincr;
@@ -726,8 +692,8 @@ tgafb_imageblit(struct fb_info *info, const struct fb_image *image)
                for (i = 0; i < height; ++i) {
                        for (j = 0; j < bwidth; j += 2) {
                                u32 mask = 0;
-                               mask |= bitrev[data[j+0]] << (0 * 8);
-                               mask |= bitrev[data[j+1]] << (1 * 8);
+                               mask |= bitrev8(data[j+0]) << (0 * 8);
+                               mask |= bitrev8(data[j+1]) << (1 * 8);
                                mask <<= shift;
                                __raw_writel(mask, fb_base + pos + j*bincr);
                        }
@@ -746,9 +712,9 @@ tgafb_imageblit(struct fb_info *info, const struct fb_image *image)
                        bwidth = (width & 15) > 8;
 
                        for (i = 0; i < height; ++i) {
-                               u32 mask = bitrev[data[0]];
+                               u32 mask = bitrev8(data[0]);
                                if (bwidth)
-                                       mask |= bitrev[data[1]] << 8;
+                                       mask |= bitrev8(data[1]) << 8;
                                mask <<= shift;
                                __raw_writel(mask, fb_base + pos);
                                pos += line_length;
@@ -1473,6 +1439,8 @@ tgafb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
        return 0;
 
  err1:
+       if (mem_base)
+               iounmap(mem_base);
        release_mem_region(bar0_start, bar0_len);
  err0:
        kfree(all);
index 14175cdb9c9c837ab097e915c7415cf3d1ae0b8d..55e8aa450bfa36e2760ed5557610386c9654000a 100644 (file)
@@ -1130,7 +1130,8 @@ static int __devinit trident_pci_probe(struct pci_dev * dev, const struct pci_de
        
        if (!request_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len, "tridentfb")) {
                debug("request_mem_region failed!\n");
-               return -1;
+               err = -1;
+               goto out_unmap;
        }
 
        fb_info.screen_base = ioremap_nocache(tridentfb_fix.smem_start,
@@ -1139,7 +1140,8 @@ static int __devinit trident_pci_probe(struct pci_dev * dev, const struct pci_de
        if (!fb_info.screen_base) {
                release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len);
                debug("ioremap failed\n");
-               return -1;
+               err = -1;
+               goto out_unmap;
        }
 
        output("%s board found\n", pci_name(dev));
@@ -1162,8 +1164,10 @@ static int __devinit trident_pci_probe(struct pci_dev * dev, const struct pci_de
 #endif
        fb_info.pseudo_palette = pseudo_pal;
 
-       if (!fb_find_mode(&default_var,&fb_info,mode,NULL,0,NULL,bpp))
-               return -EINVAL;
+       if (!fb_find_mode(&default_var,&fb_info,mode,NULL,0,NULL,bpp)) {
+               err = -EINVAL;
+               goto out_unmap;
+       }
        fb_alloc_cmap(&fb_info.cmap,256,0);
        if (defaultaccel && acc)
                default_var.accel_flags |= FB_ACCELF_TEXT;
@@ -1174,12 +1178,20 @@ static int __devinit trident_pci_probe(struct pci_dev * dev, const struct pci_de
        fb_info.device = &dev->dev;
        if (register_framebuffer(&fb_info) < 0) {
                printk(KERN_ERR "tridentfb: could not register Trident framebuffer\n");
-               return -EINVAL;
+               err = -EINVAL;
+               goto out_unmap;
        }
        output("fb%d: %s frame buffer device %dx%d-%dbpp\n",
           fb_info.node, fb_info.fix.id,default_var.xres,
           default_var.yres,default_var.bits_per_pixel);
        return 0;
+
+out_unmap:
+       if (default_par.io_virt)
+               iounmap(default_par.io_virt);
+       if (fb_info.screen_base)
+               iounmap(fb_info.screen_base);
+       return err;
 }
 
 static void __devexit trident_pci_remove(struct pci_dev * dev)
index 2196448396ec3b90e4f127d4a5179e5cfd35befe..e16322d157d0b9446a9e9cf6d0c2a99cc2898c7e 100644 (file)
@@ -47,17 +47,16 @@ static struct fb_fix_screeninfo vesafb_fix __initdata = {
        .accel  = FB_ACCEL_NONE,
 };
 
-static int             inverse   = 0;
-static int             mtrr      = 0; /* disable mtrr */
-static int            vram_remap __initdata = 0; /* Set amount of memory to be used */
-static int            vram_total __initdata = 0; /* Set total amount of memory */
-static int             pmi_setpal = 1; /* pmi for palette changes ??? */
-static int             ypan       = 0;  /* 0..nothing, 1..ypan, 2..ywrap */
-static unsigned short  *pmi_base  = NULL;
-static void            (*pmi_start)(void);
-static void            (*pmi_pal)(void);
-static int             depth;
-static int             vga_compat;
+static int   inverse    __read_mostly;
+static int   mtrr       __read_mostly;         /* disable mtrr */
+static int   vram_remap __initdata;            /* Set amount of memory to be used */
+static int   vram_total __initdata;            /* Set total amount of memory */
+static int   pmi_setpal __read_mostly = 1;     /* pmi for palette changes ??? */
+static int   ypan       __read_mostly;         /* 0..nothing, 1..ypan, 2..ywrap */
+static void  (*pmi_start)(void) __read_mostly;
+static void  (*pmi_pal)  (void) __read_mostly;
+static int   depth      __read_mostly;
+static int   vga_compat __read_mostly;
 /* --------------------------------------------------------------------- */
 
 static int vesafb_pan_display(struct fb_var_screeninfo *var,
@@ -312,6 +311,7 @@ static int __init vesafb_probe(struct platform_device *dev)
                ypan = pmi_setpal = 0; /* not available or some DOS TSR ... */
 
        if (ypan || pmi_setpal) {
+               unsigned short *pmi_base;
                pmi_base  = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
                pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
                pmi_pal   = (void*)((char*)pmi_base + pmi_base[2]);
@@ -456,6 +456,8 @@ static int __init vesafb_probe(struct platform_device *dev)
               info->node, info->fix.id);
        return 0;
 err:
+       if (info->screen_base)
+               iounmap(info->screen_base);
        framebuffer_release(info);
        release_mem_region(vesafb_fix.smem_start, size_total);
        return err;
index 43d5a6d9c4a63880a7aecfe590cf5ec4104a1ac6..6aff63d5b295f97211a88ef84243f16613d4c7a1 100644 (file)
@@ -264,7 +264,7 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
                               const struct fb_info *info,
                               int mul, int div)
 {
-       static struct {
+       static const struct {
                u32 pixclock;
                u8  misc;
                u8  seq_clock_mode;
@@ -652,7 +652,7 @@ static int vga16fb_set_par(struct fb_info *info)
 
 static void ega16_setpalette(int regno, unsigned red, unsigned green, unsigned blue)
 {
-       static unsigned char map[] = { 000, 001, 010, 011 };
+       static const unsigned char map[] = { 000, 001, 010, 011 };
        int val;
        
        if (regno >= 16)
@@ -1139,23 +1139,19 @@ static void vga16fb_copyarea(struct fb_info *info, const struct fb_copyarea *are
        }
 }
 
-#ifdef __LITTLE_ENDIAN
-static unsigned int transl_l[] =
-{0x0,0x8,0x4,0xC,0x2,0xA,0x6,0xE,0x1,0x9,0x5,0xD,0x3,0xB,0x7,0xF};
-static unsigned int transl_h[] =
-{0x000, 0x800, 0x400, 0xC00, 0x200, 0xA00, 0x600, 0xE00,
- 0x100, 0x900, 0x500, 0xD00, 0x300, 0xB00, 0x700, 0xF00};
-#else
-#ifdef __BIG_ENDIAN
-static unsigned int transl_h[] =
-{0x0,0x8,0x4,0xC,0x2,0xA,0x6,0xE,0x1,0x9,0x5,0xD,0x3,0xB,0x7,0xF};
-static unsigned int transl_l[] =
-{0x000, 0x800, 0x400, 0xC00, 0x200, 0xA00, 0x600, 0xE00,
- 0x100, 0x900, 0x500, 0xD00, 0x300, 0xB00, 0x700, 0xF00};
+#define TRANS_MASK_LOW  {0x0,0x8,0x4,0xC,0x2,0xA,0x6,0xE,0x1,0x9,0x5,0xD,0x3,0xB,0x7,0xF}
+#define TRANS_MASK_HIGH {0x000, 0x800, 0x400, 0xC00, 0x200, 0xA00, 0x600, 0xE00, \
+                        0x100, 0x900, 0x500, 0xD00, 0x300, 0xB00, 0x700, 0xF00}
+
+#if defined(__LITTLE_ENDIAN)
+static const u16 transl_l[] = TRANS_MASK_LOW;
+static const u16 transl_h[] = TRANS_MASK_HIGH;
+#elif defined(__BIG_ENDIAN)
+static const u16 transl_l[] = TRANS_MASK_HIGH;
+static const u16 transl_h[] = TRANS_MASK_LOW;
 #else
 #error "Only __BIG_ENDIAN and __LITTLE_ENDIAN are supported in vga-planes"
 #endif
-#endif
 
 static void vga_8planes_imageblit(struct fb_info *info, const struct fb_image *image)
 {
index 64378959dd7b09fdcd23f1d4da13e5b2dbc5c7ff..b9fb6fb3600d59ee950b9d79fa34e0ce8f2b3f49 100644 (file)
@@ -1799,7 +1799,7 @@ int __init virgefb_init(void)
                #warning release resources
                printk(KERN_ERR "virgefb.c: register_framebuffer failed\n");
                DPRINTK("EXIT\n");
-               return -EINVAL;
+               goto out_unmap;
        }
 
        printk(KERN_INFO "fb%d: %s frame buffer device, using %ldK of video memory\n",
@@ -1809,6 +1809,21 @@ int __init virgefb_init(void)
 
        DPRINTK("EXIT\n");
        return 0;
+
+out_unmap:
+       if (board_addr >= 0x01000000) {
+               if (v_ram)
+                       iounmap((void*)v_ram);
+               if (vgaio_regs)
+                       iounmap(vgaio_regs);
+               if (mmio_regs)
+                       iounmap(mmio_regs);
+               if (vcode_switch_base)
+                       iounmap((void*)vcode_switch_base);
+               v_ram = vcode_switch_base = 0;
+               vgaio_regs = mmio_regs = NULL;
+       }
+       return -EINVAL;
 }
 
 
index 93845a2c7c21d92780854ca1f9460a6d7c9ae315..6bb0b54965f2ac3d1257cadea6a2d7911f2aa13e 100644 (file)
@@ -2,10 +2,6 @@
 # Makefile for the Dallas's 1-wire bus.
 #
 
-ifeq ($(CONFIG_W1_DS2433_CRC), y)
-EXTRA_CFLAGS   += -DCONFIG_W1_F23_CRC
-endif
-
 obj-$(CONFIG_W1)       += wire.o
 wire-objs              := w1.o w1_int.o w1_family.o w1_netlink.o w1_io.o
 
index 70e21e2d70c334000cfaaf0b5133da3c0daa1f21..725dcfdfddb412d2de253cfc142e08b7cccf66af 100644 (file)
@@ -2,10 +2,6 @@
 # Makefile for the Dallas's 1-wire slaves.
 #
 
-ifeq ($(CONFIG_W1_SLAVE_DS2433_CRC), y)
-EXTRA_CFLAGS += -DCONFIG_W1_F23_CRC
-endif
-
 obj-$(CONFIG_W1_SLAVE_THERM)   += w1_therm.o
 obj-$(CONFIG_W1_SLAVE_SMEM)    += w1_smem.o
 obj-$(CONFIG_W1_SLAVE_DS2433)  += w1_ds2433.o
index 2ac238f1480e234d05b260b5a78d9631f0858f49..8ea17a53eed853223be23df1e78878009ebf5577 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/device.h>
 #include <linux/types.h>
 #include <linux/delay.h>
-#ifdef CONFIG_W1_F23_CRC
+#ifdef CONFIG_W1_SLAVE_DS2433_CRC
 #include <linux/crc16.h>
 
 #define CRC16_INIT             0
@@ -62,7 +62,7 @@ static inline size_t w1_f23_fix_count(loff_t off, size_t count, size_t size)
        return count;
 }
 
-#ifdef CONFIG_W1_F23_CRC
+#ifdef CONFIG_W1_SLAVE_DS2433_CRC
 static int w1_f23_refresh_block(struct w1_slave *sl, struct w1_f23_data *data,
                                int block)
 {
@@ -89,13 +89,13 @@ static int w1_f23_refresh_block(struct w1_slave *sl, struct w1_f23_data *data,
 
        return 0;
 }
-#endif /* CONFIG_W1_F23_CRC */
+#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
 
 static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off,
                               size_t count)
 {
        struct w1_slave *sl = kobj_to_w1_slave(kobj);
-#ifdef CONFIG_W1_F23_CRC
+#ifdef CONFIG_W1_SLAVE_DS2433_CRC
        struct w1_f23_data *data = sl->family_data;
        int i, min_page, max_page;
 #else
@@ -107,7 +107,7 @@ static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off,
 
        mutex_lock(&sl->master->mutex);
 
-#ifdef CONFIG_W1_F23_CRC
+#ifdef CONFIG_W1_SLAVE_DS2433_CRC
 
        min_page = (off >> W1_PAGE_BITS);
        max_page = (off + count - 1) >> W1_PAGE_BITS;
@@ -119,7 +119,7 @@ static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off,
        }
        memcpy(buf, &data->memory[off], count);
 
-#else  /* CONFIG_W1_F23_CRC */
+#else  /* CONFIG_W1_SLAVE_DS2433_CRC */
 
        /* read directly from the EEPROM */
        if (w1_reset_select_slave(sl)) {
@@ -133,7 +133,7 @@ static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off,
        w1_write_block(sl->master, wrbuf, 3);
        w1_read_block(sl->master, buf, count);
 
-#endif /* CONFIG_W1_F23_CRC */
+#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
 
 out_up:
        mutex_unlock(&sl->master->mutex);
@@ -208,7 +208,7 @@ static ssize_t w1_f23_write_bin(struct kobject *kobj, char *buf, loff_t off,
        if ((count = w1_f23_fix_count(off, count, W1_EEPROM_SIZE)) == 0)
                return 0;
 
-#ifdef CONFIG_W1_F23_CRC
+#ifdef CONFIG_W1_SLAVE_DS2433_CRC
        /* can only write full blocks in cached mode */
        if ((off & W1_PAGE_MASK) || (count & W1_PAGE_MASK)) {
                dev_err(&sl->dev, "invalid offset/count off=%d cnt=%zd\n",
@@ -223,7 +223,7 @@ static ssize_t w1_f23_write_bin(struct kobject *kobj, char *buf, loff_t off,
                        return -EINVAL;
                }
        }
-#endif /* CONFIG_W1_F23_CRC */
+#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
 
        mutex_lock(&sl->master->mutex);
 
@@ -262,7 +262,7 @@ static struct bin_attribute w1_f23_bin_attr = {
 static int w1_f23_add_slave(struct w1_slave *sl)
 {
        int err;
-#ifdef CONFIG_W1_F23_CRC
+#ifdef CONFIG_W1_SLAVE_DS2433_CRC
        struct w1_f23_data *data;
 
        data = kmalloc(sizeof(struct w1_f23_data), GFP_KERNEL);
@@ -271,24 +271,24 @@ static int w1_f23_add_slave(struct w1_slave *sl)
        memset(data, 0, sizeof(struct w1_f23_data));
        sl->family_data = data;
 
-#endif /* CONFIG_W1_F23_CRC */
+#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
 
        err = sysfs_create_bin_file(&sl->dev.kobj, &w1_f23_bin_attr);
 
-#ifdef CONFIG_W1_F23_CRC
+#ifdef CONFIG_W1_SLAVE_DS2433_CRC
        if (err)
                kfree(data);
-#endif /* CONFIG_W1_F23_CRC */
+#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
 
        return err;
 }
 
 static void w1_f23_remove_slave(struct w1_slave *sl)
 {
-#ifdef CONFIG_W1_F23_CRC
+#ifdef CONFIG_W1_SLAVE_DS2433_CRC
        kfree(sl->family_data);
        sl->family_data = NULL;
-#endif /* CONFIG_W1_F23_CRC */
+#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
        sysfs_remove_bin_file(&sl->dev.kobj, &w1_f23_bin_attr);
 }
 
index de3e9791f80d72fe8916b64286ab32d487ae96f1..63c07243993c1b1b50c007ffc6773eccf2e98441 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/kthread.h>
+#include <linux/freezer.h>
 
 #include <asm/atomic.h>
 
index 7aa2d3de6d37d3378a96378c520c2ac5fef276a2..60b05bc1564254ab49af9c6b284d96888828e7bb 100644 (file)
@@ -47,7 +47,7 @@ proc_bus_zorro_lseek(struct file *file, loff_t off, int whence)
 static ssize_t
 proc_bus_zorro_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
 {
-       struct inode *ino = file->f_dentry->d_inode;
+       struct inode *ino = file->f_path.dentry->d_inode;
        struct proc_dir_entry *dp = PDE(ino);
        struct zorro_dev *z = dp->data;
        struct ConfigDev cd;
index 9dfd259a70b477c4f0bb67d33c4ed2311fde405c..cc24abf232d5818c375836b744759916b88f24ac 100644 (file)
@@ -54,7 +54,7 @@ static int v9fs_vfs_readpage(struct file *filp, struct page *page)
        int retval = -EIO;
        loff_t offset = page_offset(page);
        int count = PAGE_CACHE_SIZE;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode);
        int rsize = v9ses->maxdata - V9FS_IOHDRSZ;
        struct v9fs_fid *v9f = filp->private_data;
index 905c882f4e2f54f836f2c7436891e72e78d3f106..3129688143ea96e4eaa9c6738a4cf19533993a66 100644 (file)
@@ -71,7 +71,7 @@ static inline int dt_type(struct v9fs_stat *mistat)
 static int v9fs_dir_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
        struct v9fs_fcall *fcall = NULL;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode);
        struct v9fs_fid *file = filp->private_data;
        unsigned int i, n, s;
@@ -80,7 +80,7 @@ static int v9fs_dir_readdir(struct file *filp, void *dirent, filldir_t filldir)
        struct v9fs_stat stat;
        int over = 0;
 
-       dprintk(DEBUG_VFS, "name %s\n", filp->f_dentry->d_name.name);
+       dprintk(DEBUG_VFS, "name %s\n", filp->f_path.dentry->d_name.name);
 
        fid = file->fid;
 
index 79e6f9cd7340fecdc7e3e5b94a8075f2c38d302b..e86a07151280e2acc32a8d33d652d63249382195 100644 (file)
@@ -60,7 +60,7 @@ int v9fs_file_open(struct inode *inode, struct file *file)
 
        dprintk(DEBUG_VFS, "inode: %p file: %p \n", inode, file);
 
-       vfid = v9fs_fid_lookup(file->f_dentry);
+       vfid = v9fs_fid_lookup(file->f_path.dentry);
        if (!vfid) {
                dprintk(DEBUG_ERROR, "Couldn't resolve fid from dentry\n");
                return -EBADF;
@@ -133,7 +133,7 @@ free_fcall:
 static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl)
 {
        int res = 0;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
 
        dprintk(DEBUG_VFS, "filp: %p lock: %p\n", filp, fl);
 
@@ -161,7 +161,7 @@ static ssize_t
 v9fs_file_read(struct file *filp, char __user * data, size_t count,
               loff_t * offset)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode);
        struct v9fs_fid *v9f = filp->private_data;
        struct v9fs_fcall *fcall = NULL;
@@ -225,7 +225,7 @@ static ssize_t
 v9fs_file_write(struct file *filp, const char __user * data,
                size_t count, loff_t * offset)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode);
        struct v9fs_fid *v9fid = filp->private_data;
        struct v9fs_fcall *fcall;
index 5241c600ce28be2f00f0eb454b41db882beab1a8..18f26cdfd882792fecc12113c83e129dc7bcab9e 100644 (file)
@@ -256,7 +256,7 @@ static int
 v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name, u32 perm,
        u8 mode, char *extension, u32 *fidp, struct v9fs_qid *qid, u32 *iounit)
 {
-       u32 fid;
+       int fid;
        int err;
        struct v9fs_fcall *fcall;
 
@@ -310,7 +310,7 @@ static struct v9fs_fid*
 v9fs_clone_walk(struct v9fs_session_info *v9ses, u32 fid, struct dentry *dentry)
 {
        int err;
-       u32 nfid;
+       int nfid;
        struct v9fs_fid *ret;
        struct v9fs_fcall *fcall;
 
index 9a5ce9323bfd0c65ffed56f597294b29db75efa9..b9ffa63f77fc266afde9a7d0c43daebcef4bca16 100644 (file)
@@ -10,7 +10,8 @@ obj-y :=      open.o read_write.o file_table.o super.o \
                ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \
                attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \
                seq_file.o xattr.o libfs.o fs-writeback.o \
-               pnode.o drop_caches.o splice.o sync.o utimes.o
+               pnode.o drop_caches.o splice.o sync.o utimes.o \
+               stack.o
 
 ifeq ($(CONFIG_BLOCK),y)
 obj-y +=       buffer.o bio.o block_dev.o direct-io.o mpage.o ioprio.o
index d3c7905b2ddc007decc5084e5a5a6761ac52b43a..2b8903893d3f76be76ec4aa564b506b79c00d503 100644 (file)
@@ -28,7 +28,7 @@ static DEFINE_RWLOCK(adfs_dir_lock);
 static int
 adfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct super_block *sb = inode->i_sb;
        struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir;
        struct object_info obj;
index 9ade139086fcebb7c48206a686ac06011edea40c..5023351a7afe652fcd9af92e9201b7cc2029081c 100644 (file)
@@ -36,7 +36,7 @@ void __adfs_error(struct super_block *sb, const char *function, const char *fmt,
        va_list args;
 
        va_start(args, fmt);
-       vsprintf(error_buf, fmt, args);
+       vsnprintf(error_buf, sizeof(error_buf), fmt, args);
        va_end(args);
 
        printk(KERN_CRIT "ADFS-fs error (device %s)%s%s: %s\n",
@@ -212,12 +212,12 @@ static int adfs_statfs(struct dentry *dentry, struct kstatfs *buf)
        return 0;
 }
 
-static kmem_cache_t *adfs_inode_cachep;
+static struct kmem_cache *adfs_inode_cachep;
 
 static struct inode *adfs_alloc_inode(struct super_block *sb)
 {
        struct adfs_inode_info *ei;
-       ei = (struct adfs_inode_info *)kmem_cache_alloc(adfs_inode_cachep, SLAB_KERNEL);
+       ei = (struct adfs_inode_info *)kmem_cache_alloc(adfs_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        return &ei->vfs_inode;
@@ -228,7 +228,7 @@ static void adfs_destroy_inode(struct inode *inode)
        kmem_cache_free(adfs_inode_cachep, ADFS_I(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct adfs_inode_info *ei = (struct adfs_inode_info *) foo;
 
index ccd624ef4272d742b0f98413aa741064d4b6d09d..f4de4b98004fa1f9f08cbe2c6310eb805aaafd1d 100644 (file)
@@ -445,7 +445,7 @@ affs_error(struct super_block *sb, const char *function, const char *fmt, ...)
        va_list  args;
 
        va_start(args,fmt);
-       vsprintf(ErrorBuffer,fmt,args);
+       vsnprintf(ErrorBuffer,sizeof(ErrorBuffer),fmt,args);
        va_end(args);
 
        printk(KERN_CRIT "AFFS error (device %s): %s(): %s\n", sb->s_id,
@@ -461,7 +461,7 @@ affs_warning(struct super_block *sb, const char *function, const char *fmt, ...)
        va_list  args;
 
        va_start(args,fmt);
-       vsprintf(ErrorBuffer,fmt,args);
+       vsnprintf(ErrorBuffer,sizeof(ErrorBuffer),fmt,args);
        va_end(args);
 
        printk(KERN_WARNING "AFFS warning (device %s): %s(): %s\n", sb->s_id,
index b0b953683c1a81da13141bbc6de13d0ba09aea33..b330009fe42dbdb02ca987169981a9e67706e7e4 100644 (file)
@@ -289,12 +289,11 @@ int affs_init_bitmap(struct super_block *sb, int *flags)
        sbi->s_bmap_count = (sbi->s_partition_size - sbi->s_reserved +
                                 sbi->s_bmap_bits - 1) / sbi->s_bmap_bits;
        size = sbi->s_bmap_count * sizeof(*bm);
-       bm = sbi->s_bitmap = kmalloc(size, GFP_KERNEL);
+       bm = sbi->s_bitmap = kzalloc(size, GFP_KERNEL);
        if (!sbi->s_bitmap) {
                printk(KERN_ERR "AFFS: Bitmap allocation failed\n");
                return -ENOMEM;
        }
-       memset(sbi->s_bitmap, 0, size);
 
        bmap_blk = (__be32 *)sbi->s_root_bh->b_data;
        blk = sb->s_blocksize / 4 - 49;
index 5d9649fa1814c1ab8d2d4f91f4dd24aa6a81ce55..cad3ee340063238177b3f9c0976b20994c9b0820 100644 (file)
@@ -41,7 +41,7 @@ struct inode_operations affs_dir_inode_operations = {
 static int
 affs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct inode            *inode = filp->f_dentry->d_inode;
+       struct inode            *inode = filp->f_path.dentry->d_inode;
        struct super_block      *sb = inode->i_sb;
        struct buffer_head      *dir_bh;
        struct buffer_head      *fh_bh;
@@ -71,7 +71,7 @@ affs_readdir(struct file *filp, void *dirent, filldir_t filldir)
                stored++;
        }
        if (f_pos == 1) {
-               if (filldir(dirent, "..", 2, f_pos, parent_ino(filp->f_dentry), DT_DIR) < 0)
+               if (filldir(dirent, "..", 2, f_pos, parent_ino(filp->f_path.dentry), DT_DIR) < 0)
                        return stored;
                filp->f_pos = f_pos = 2;
                stored++;
index 5ea72c3a16c3b52d4654d9a65223a09b6c87cbb4..3de93e799949cc9289ece4a0b13486221d2a136b 100644 (file)
@@ -66,12 +66,12 @@ affs_write_super(struct super_block *sb)
        pr_debug("AFFS: write_super() at %lu, clean=%d\n", get_seconds(), clean);
 }
 
-static kmem_cache_t * affs_inode_cachep;
+static struct kmem_cache * affs_inode_cachep;
 
 static struct inode *affs_alloc_inode(struct super_block *sb)
 {
        struct affs_inode_info *ei;
-       ei = (struct affs_inode_info *)kmem_cache_alloc(affs_inode_cachep, SLAB_KERNEL);
+       ei = (struct affs_inode_info *)kmem_cache_alloc(affs_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        ei->vfs_inode.i_version = 1;
@@ -83,7 +83,7 @@ static void affs_destroy_inode(struct inode *inode)
        kmem_cache_free(affs_inode_cachep, AFFS_I(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct affs_inode_info *ei = (struct affs_inode_info *) foo;
 
index a6ec75c56fcf76cf44b12f28969180e588eee966..4acd0413405568c6d6f9623bbdfd755637574b14 100644 (file)
@@ -392,10 +392,10 @@ static int afs_dir_readdir(struct file *file, void *cookie, filldir_t filldir)
        unsigned fpos;
        int ret;
 
-       _enter("{%Ld,{%lu}}", file->f_pos, file->f_dentry->d_inode->i_ino);
+       _enter("{%Ld,{%lu}}", file->f_pos, file->f_path.dentry->d_inode->i_ino);
 
        fpos = file->f_pos;
-       ret = afs_dir_iterate(file->f_dentry->d_inode, &fpos, cookie, filldir);
+       ret = afs_dir_iterate(file->f_path.dentry->d_inode, &fpos, cookie, filldir);
        file->f_pos = fpos;
 
        _leave(" = %d", ret);
index f09a794f248e33a4b8ad192acbf957aec2dd399b..615df2407cb2ec5f166d81e3e4dbe9837c38506c 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/completion.h>
+#include <linux/freezer.h>
 #include "cell.h"
 #include "server.h"
 #include "volume.h"
index 65bc05ab81826b417513f203a5b7e930d7b9fed7..694344e4d3c7503ca03750549495bc6cad8fef1a 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/completion.h>
+#include <linux/freezer.h>
 #include "cell.h"
 #include "volume.h"
 #include "kafstimod.h"
index 99785a79d0431cf88224e3acd4b5a3592254f6ec..8f74e845082659fd1efc291f7f37f6f1026ef274 100644 (file)
@@ -18,7 +18,7 @@
 #include <linux/pagemap.h>
 #include <linux/mount.h>
 #include <linux/namei.h>
-#include <linux/namespace.h>
+#include <linux/mnt_namespace.h>
 #include "super.h"
 #include "cell.h"
 #include "volume.h"
@@ -136,11 +136,11 @@ static int afs_mntpt_open(struct inode *inode, struct file *file)
 {
        kenter("%p,%p{%p{%s},%s}",
               inode, file,
-              file->f_dentry->d_parent,
-              file->f_dentry->d_parent ?
-              file->f_dentry->d_parent->d_name.name :
+              file->f_path.dentry->d_parent,
+              file->f_path.dentry->d_parent ?
+              file->f_path.dentry->d_parent->d_name.name :
               (const unsigned char *) "",
-              file->f_dentry->d_name.name);
+              file->f_path.dentry->d_name.name);
 
        return -EREMOTE;
 } /* end afs_mntpt_open() */
index 22afaae1a4ce53417d3e52900817d25245f99395..44aff81dc6a74fa4cf924a32586e2c91d2f2febf 100644 (file)
@@ -55,13 +55,12 @@ int afs_server_lookup(struct afs_cell *cell, const struct in_addr *addr,
        _enter("%p,%08x,", cell, ntohl(addr->s_addr));
 
        /* allocate and initialise a server record */
-       server = kmalloc(sizeof(struct afs_server), GFP_KERNEL);
+       server = kzalloc(sizeof(struct afs_server), GFP_KERNEL);
        if (!server) {
                _leave(" = -ENOMEM");
                return -ENOMEM;
        }
 
-       memset(server, 0, sizeof(struct afs_server));
        atomic_set(&server->usage, 1);
 
        INIT_LIST_HEAD(&server->link);
index 67d1f5c819eccc08936e9c11ad0b0bef58c7118f..18d9b77ba40fe5ff081da9d95de551dd4978071a 100644 (file)
@@ -35,7 +35,7 @@ struct afs_mount_params {
        struct afs_volume       *volume;
 };
 
-static void afs_i_init_once(void *foo, kmem_cache_t *cachep,
+static void afs_i_init_once(void *foo, struct kmem_cache *cachep,
                            unsigned long flags);
 
 static int afs_get_sb(struct file_system_type *fs_type,
@@ -65,7 +65,7 @@ static struct super_operations afs_super_ops = {
        .put_super      = afs_put_super,
 };
 
-static kmem_cache_t *afs_inode_cachep;
+static struct kmem_cache *afs_inode_cachep;
 static atomic_t afs_count_active_inodes;
 
 /*****************************************************************************/
@@ -242,14 +242,12 @@ static int afs_fill_super(struct super_block *sb, void *data, int silent)
        kenter("");
 
        /* allocate a superblock info record */
-       as = kmalloc(sizeof(struct afs_super_info), GFP_KERNEL);
+       as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
        if (!as) {
                _leave(" = -ENOMEM");
                return -ENOMEM;
        }
 
-       memset(as, 0, sizeof(struct afs_super_info));
-
        afs_get_volume(params->volume);
        as->volume = params->volume;
 
@@ -384,7 +382,7 @@ static void afs_put_super(struct super_block *sb)
 /*
  * initialise an inode cache slab element prior to any use
  */
-static void afs_i_init_once(void *_vnode, kmem_cache_t *cachep,
+static void afs_i_init_once(void *_vnode, struct kmem_cache *cachep,
                            unsigned long flags)
 {
        struct afs_vnode *vnode = (struct afs_vnode *) _vnode;
@@ -412,7 +410,7 @@ static struct inode *afs_alloc_inode(struct super_block *sb)
        struct afs_vnode *vnode;
 
        vnode = (struct afs_vnode *)
-               kmem_cache_alloc(afs_inode_cachep, SLAB_KERNEL);
+               kmem_cache_alloc(afs_inode_cachep, GFP_KERNEL);
        if (!vnode)
                return NULL;
 
index 287a1bc7a1828c16c118e811b050390e74556771..d3a6ec2c9627e1e58a769c93398f2a3787bdfda8 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -47,8 +47,8 @@ unsigned long aio_nr;         /* current system wide number of aio requests */
 unsigned long aio_max_nr = 0x10000; /* system wide maximum number of aio requests */
 /*----end sysctl variables---*/
 
-static kmem_cache_t    *kiocb_cachep;
-static kmem_cache_t    *kioctx_cachep;
+static struct kmem_cache       *kiocb_cachep;
+static struct kmem_cache       *kioctx_cachep;
 
 static struct workqueue_struct *aio_wq;
 
@@ -666,17 +666,6 @@ static ssize_t aio_run_iocb(struct kiocb *iocb)
        ssize_t (*retry)(struct kiocb *);
        ssize_t ret;
 
-       if (iocb->ki_retried++ > 1024*1024) {
-               printk("Maximal retry count.  Bytes done %Zd\n",
-                       iocb->ki_nbytes - iocb->ki_left);
-               return -EAGAIN;
-       }
-
-       if (!(iocb->ki_retried & 0xff)) {
-               pr_debug("%ld retry: %zd of %zd\n", iocb->ki_retried,
-                       iocb->ki_nbytes - iocb->ki_left, iocb->ki_nbytes);
-       }
-
        if (!(retry = iocb->ki_retry)) {
                printk("aio_run_iocb: iocb->ki_retry = NULL\n");
                return 0;
@@ -1005,9 +994,6 @@ int fastcall aio_complete(struct kiocb *iocb, long res, long res2)
        kunmap_atomic(ring, KM_IRQ1);
 
        pr_debug("added to ring %p at [%lu]\n", iocb, tail);
-
-       pr_debug("%ld retries: %zd of %zd\n", iocb->ki_retried,
-               iocb->ki_nbytes - iocb->ki_left, iocb->ki_nbytes);
 put_rq:
        /* everything turned out well, dispose of the aiocb. */
        ret = __aio_put_req(ctx, iocb);
@@ -1413,7 +1399,6 @@ static ssize_t aio_setup_single_vector(struct kiocb *kiocb)
        kiocb->ki_iovec->iov_len = kiocb->ki_left;
        kiocb->ki_nr_segs = 1;
        kiocb->ki_cur_seg = 0;
-       kiocb->ki_nbytes = kiocb->ki_left;
        return 0;
 }
 
@@ -1591,7 +1576,6 @@ int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
        req->ki_opcode = iocb->aio_lio_opcode;
        init_waitqueue_func_entry(&req->ki_wait, aio_wake_function);
        INIT_LIST_HEAD(&req->ki_wait.task_list);
-       req->ki_retried = 0;
 
        ret = aio_setup_iocb(req);
 
index 38ede5c9d6fd412c8cddfed701afae9ae46cfa14..f968d134280807bf7aaafb50d6aeb22a6a45d304 100644 (file)
@@ -28,10 +28,11 @@ void autofs_kill_sb(struct super_block *sb)
        /*
         * In the event of a failure in get_sb_nodev the superblock
         * info is not present so nothing else has been setup, so
-        * just exit when we are called from deactivate_super.
+        * just call kill_anon_super when we are called from
+        * deactivate_super.
         */
        if (!sbi)
-               return;
+               goto out_kill_sb;
 
        if ( !sbi->catatonic )
                autofs_catatonic_mode(sbi); /* Free wait queues, close pipe */
@@ -44,6 +45,7 @@ void autofs_kill_sb(struct super_block *sb)
 
        kfree(sb->s_fs_info);
 
+out_kill_sb:
        DPRINTK(("autofs: shutting down\n"));
        kill_anon_super(sb);
 }
@@ -209,7 +211,6 @@ fail_iput:
 fail_free:
        kfree(sbi);
        s->s_fs_info = NULL;
-       kill_anon_super(s);
 fail_unlock:
        return -EINVAL;
 }
index 368a1c33a3c824effc61b722bdcebc0f35e62f3d..e698c51d2b02f167b151dfb04e515870b8dd2c31 100644 (file)
@@ -45,7 +45,7 @@ static int autofs_root_readdir(struct file *filp, void *dirent, filldir_t filldi
        struct autofs_dir_ent *ent = NULL;
        struct autofs_dirhash *dirhash;
        struct autofs_sb_info *sbi;
-       struct inode * inode = filp->f_dentry->d_inode;
+       struct inode * inode = filp->f_path.dentry->d_inode;
        off_t onr, nr;
 
        lock_kernel();
@@ -557,7 +557,7 @@ static int autofs_root_ioctl(struct inode *inode, struct file *filp,
        case AUTOFS_IOC_SETTIMEOUT:
                return autofs_get_set_timeout(sbi, argp);
        case AUTOFS_IOC_EXPIRE:
-               return autofs_expire_run(inode->i_sb, sbi, filp->f_vfsmnt,
+               return autofs_expire_run(inode->i_sb, sbi, filp->f_path.mnt,
                                         argp);
        default:
                return -ENOSYS;
index b13f32c8aeeea26914163e35e7b45a9782e779eb..216b1a364ccb76dc782573d87c85eaa72b89588c 100644 (file)
@@ -150,7 +150,8 @@ static inline int autofs4_ispending(struct dentry *dentry)
 
 static inline void autofs4_copy_atime(struct file *src, struct file *dst)
 {
-       dst->f_dentry->d_inode->i_atime = src->f_dentry->d_inode->i_atime;
+       dst->f_path.dentry->d_inode->i_atime =
+               src->f_path.dentry->d_inode->i_atime;
        return;
 }
 
index ce7c0f1dd529211b2f4e5eca8feba0c87428c33f..9c48250fd726406fc040816c96b4fa42e8d305ce 100644 (file)
@@ -152,10 +152,11 @@ void autofs4_kill_sb(struct super_block *sb)
        /*
         * In the event of a failure in get_sb_nodev the superblock
         * info is not present so nothing else has been setup, so
-        * just exit when we are called from deactivate_super.
+        * just call kill_anon_super when we are called from
+        * deactivate_super.
         */
        if (!sbi)
-               return;
+               goto out_kill_sb;
 
        sb->s_fs_info = NULL;
 
@@ -167,6 +168,7 @@ void autofs4_kill_sb(struct super_block *sb)
 
        kfree(sbi);
 
+out_kill_sb:
        DPRINTK("shutting down");
        kill_anon_super(sb);
 }
@@ -426,7 +428,6 @@ fail_ino:
 fail_free:
        kfree(sbi);
        s->s_fs_info = NULL;
-       kill_anon_super(s);
 fail_unlock:
        return -EINVAL;
 }
index c1493524da4d614da928caec7abbfc845c417c0c..8d05b9f7578dc8dcaf65dcaa4bbb71a0d69e3191 100644 (file)
@@ -74,7 +74,7 @@ struct inode_operations autofs4_dir_inode_operations = {
 static int autofs4_root_readdir(struct file *file, void *dirent,
                                filldir_t filldir)
 {
-       struct autofs_sb_info *sbi = autofs4_sbi(file->f_dentry->d_sb);
+       struct autofs_sb_info *sbi = autofs4_sbi(file->f_path.dentry->d_sb);
        int oz_mode = autofs4_oz_mode(sbi);
 
        DPRINTK("called, filp->f_pos = %lld", file->f_pos);
@@ -95,8 +95,8 @@ static int autofs4_root_readdir(struct file *file, void *dirent,
 
 static int autofs4_dir_open(struct inode *inode, struct file *file)
 {
-       struct dentry *dentry = file->f_dentry;
-       struct vfsmount *mnt = file->f_vfsmnt;
+       struct dentry *dentry = file->f_path.dentry;
+       struct vfsmount *mnt = file->f_path.mnt;
        struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
        struct dentry *cursor;
        int status;
@@ -172,7 +172,7 @@ out:
 
 static int autofs4_dir_close(struct inode *inode, struct file *file)
 {
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
        struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
        struct dentry *cursor = file->private_data;
        int status = 0;
@@ -204,7 +204,7 @@ out:
 
 static int autofs4_dir_readdir(struct file *file, void *dirent, filldir_t filldir)
 {
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
        struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
        struct dentry *cursor = file->private_data;
        int status;
@@ -858,14 +858,14 @@ static int autofs4_root_ioctl(struct inode *inode, struct file *filp,
                return autofs4_ask_reghost(sbi, p);
 
        case AUTOFS_IOC_ASKUMOUNT:
-               return autofs4_ask_umount(filp->f_vfsmnt, p);
+               return autofs4_ask_umount(filp->f_path.mnt, p);
 
        /* return a single thing to expire */
        case AUTOFS_IOC_EXPIRE:
-               return autofs4_expire_run(inode->i_sb,filp->f_vfsmnt,sbi, p);
+               return autofs4_expire_run(inode->i_sb,filp->f_path.mnt,sbi, p);
        /* same as above, but can send multiple expires through pipe */
        case AUTOFS_IOC_EXPIRE_MULTI:
-               return autofs4_expire_multi(inode->i_sb,filp->f_vfsmnt,sbi, p);
+               return autofs4_expire_multi(inode->i_sb,filp->f_path.mnt,sbi, p);
 
        default:
                return -ENOSYS;
index 07f7144f0e2e942feb736e33b315c8baae03cb20..481e59b9d91cda482d5e89a4a7990c5b1c8b51b2 100644 (file)
@@ -61,7 +61,7 @@ static const struct super_operations befs_sops = {
 };
 
 /* slab cache for befs_inode_info objects */
-static kmem_cache_t *befs_inode_cachep;
+static struct kmem_cache *befs_inode_cachep;
 
 static const struct file_operations befs_dir_operations = {
        .read           = generic_read_dir,
@@ -212,7 +212,7 @@ befs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
 static int
 befs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct super_block *sb = inode->i_sb;
        befs_data_stream *ds = &BEFS_I(inode)->i_data.ds;
        befs_off_t value;
@@ -222,7 +222,7 @@ befs_readdir(struct file *filp, void *dirent, filldir_t filldir)
        char keybuf[BEFS_NAME_LEN + 1];
        char *nlsname;
        int nlsnamelen;
-       const char *dirname = filp->f_dentry->d_name.name;
+       const char *dirname = filp->f_path.dentry->d_name.name;
 
        befs_debug(sb, "---> befs_readdir() "
                   "name %s, inode %ld, filp->f_pos %Ld",
@@ -277,7 +277,7 @@ befs_alloc_inode(struct super_block *sb)
 {
         struct befs_inode_info *bi;
         bi = (struct befs_inode_info *)kmem_cache_alloc(befs_inode_cachep,
-                                                       SLAB_KERNEL);
+                                                       GFP_KERNEL);
         if (!bi)
                 return NULL;
         return &bi->vfs_inode;
@@ -289,7 +289,7 @@ befs_destroy_inode(struct inode *inode)
         kmem_cache_free(befs_inode_cachep, BEFS_I(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
         struct befs_inode_info *bi = (struct befs_inode_info *) foo;
        
index a650f1d0b85ea815860ef528d0177ceefa51655e..2a746e688df556519b8d597c999ab2205562ab9f 100644 (file)
@@ -27,7 +27,7 @@ static struct buffer_head * bfs_find_entry(struct inode * dir,
 
 static int bfs_readdir(struct file * f, void * dirent, filldir_t filldir)
 {
-       struct inode * dir = f->f_dentry->d_inode;
+       struct inode * dir = f->f_path.dentry->d_inode;
        struct buffer_head * bh;
        struct bfs_dirent * de;
        unsigned int offset;
index ed27ffb3459e9ea73ea23b476b27cf1bf95d0320..eac175ed9f445d999b3f8e5458f3a395de4c4a06 100644 (file)
@@ -228,12 +228,12 @@ static void bfs_write_super(struct super_block *s)
        unlock_kernel();
 }
 
-static kmem_cache_t * bfs_inode_cachep;
+static struct kmem_cache * bfs_inode_cachep;
 
 static struct inode *bfs_alloc_inode(struct super_block *sb)
 {
        struct bfs_inode_info *bi;
-       bi = kmem_cache_alloc(bfs_inode_cachep, SLAB_KERNEL);
+       bi = kmem_cache_alloc(bfs_inode_cachep, GFP_KERNEL);
        if (!bi)
                return NULL;
        return &bi->vfs_inode;
@@ -244,7 +244,7 @@ static void bfs_destroy_inode(struct inode *inode)
        kmem_cache_free(bfs_inode_cachep, BFS_I(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct bfs_inode_info *bi = foo;
 
index 517e111bb7ef4acbb94f95fb560cb4c2734f4d5b..813a887cd2b3257d4b4b039091d0194c3a232721 100644 (file)
@@ -274,7 +274,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
        if ((N_MAGIC(ex) != ZMAGIC && N_MAGIC(ex) != OMAGIC &&
             N_MAGIC(ex) != QMAGIC && N_MAGIC(ex) != NMAGIC) ||
            N_TRSIZE(ex) || N_DRSIZE(ex) ||
-           i_size_read(bprm->file->f_dentry->d_inode) < ex.a_text+ex.a_data+N_SYMSIZE(ex)+N_TXTOFF(ex)) {
+           i_size_read(bprm->file->f_path.dentry->d_inode) < ex.a_text+ex.a_data+N_SYMSIZE(ex)+N_TXTOFF(ex)) {
                return -ENOEXEC;
        }
 
@@ -389,7 +389,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
                {
                        printk(KERN_WARNING 
                               "fd_offset is not page aligned. Please convert program: %s\n",
-                              bprm->file->f_dentry->d_name.name);
+                              bprm->file->f_path.dentry->d_name.name);
                        error_time = jiffies;
                }
 
@@ -469,7 +469,7 @@ static int load_aout_library(struct file *file)
        int retval;
        struct exec ex;
 
-       inode = file->f_dentry->d_inode;
+       inode = file->f_path.dentry->d_inode;
 
        retval = -ENOEXEC;
        error = kernel_read(file, 0, (char *) &ex, sizeof(ex));
@@ -506,7 +506,7 @@ static int load_aout_library(struct file *file)
                {
                        printk(KERN_WARNING 
                               "N_TXTOFF is not page aligned. Please convert library: %s\n",
-                              file->f_dentry->d_name.name);
+                              file->f_path.dentry->d_name.name);
                        error_time = jiffies;
                }
                down_write(&current->mm->mmap_sem);
index cc72bb43061d991edb60f809581f307b31bbd268..d3adfd353ff99eec4277b672088024eee9da22ac 100644 (file)
@@ -47,10 +47,6 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs);
 static int load_elf_library(struct file *);
 static unsigned long elf_map (struct file *, unsigned long, struct elf_phdr *, int, int);
 
-#ifndef elf_addr_t
-#define elf_addr_t unsigned long
-#endif
-
 /*
  * If we don't support core dumping, then supply a NULL so we
  * don't even try.
@@ -243,8 +239,9 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
        if (interp_aout) {
                argv = sp + 2;
                envp = argv + argc + 1;
-               __put_user((elf_addr_t)(unsigned long)argv, sp++);
-               __put_user((elf_addr_t)(unsigned long)envp, sp++);
+               if (__put_user((elf_addr_t)(unsigned long)argv, sp++) ||
+                   __put_user((elf_addr_t)(unsigned long)envp, sp++))
+                       return -EFAULT;
        } else {
                argv = sp;
                envp = argv + argc + 1;
@@ -254,7 +251,8 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
        p = current->mm->arg_end = current->mm->arg_start;
        while (argc-- > 0) {
                size_t len;
-               __put_user((elf_addr_t)p, argv++);
+               if (__put_user((elf_addr_t)p, argv++))
+                       return -EFAULT;
                len = strnlen_user((void __user *)p, PAGE_SIZE*MAX_ARG_PAGES);
                if (!len || len > PAGE_SIZE*MAX_ARG_PAGES)
                        return 0;
@@ -265,7 +263,8 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
        current->mm->arg_end = current->mm->env_start = p;
        while (envc-- > 0) {
                size_t len;
-               __put_user((elf_addr_t)p, envp++);
+               if (__put_user((elf_addr_t)p, envp++))
+                       return -EFAULT;
                len = strnlen_user((void __user *)p, PAGE_SIZE*MAX_ARG_PAGES);
                if (!len || len > PAGE_SIZE*MAX_ARG_PAGES)
                        return 0;
@@ -545,7 +544,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
        unsigned long reloc_func_desc = 0;
        char passed_fileno[6];
        struct files_struct *files;
-       int have_pt_gnu_stack, executable_stack = EXSTACK_DEFAULT;
+       int executable_stack = EXSTACK_DEFAULT;
        unsigned long def_flags = 0;
        struct {
                struct elfhdr elf_ex;
@@ -708,7 +707,6 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
                                executable_stack = EXSTACK_DISABLE_X;
                        break;
                }
-       have_pt_gnu_stack = (i < loc->elf_ex.e_phnum);
 
        /* Some simple consistency checks for the interpreter */
        if (elf_interpreter) {
@@ -856,7 +854,13 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
                         * default mmap base, as well as whatever program they
                         * might try to exec.  This is because the brk will
                         * follow the loader, and is not movable.  */
-                       load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
+                       if (current->flags & PF_RANDOMIZE)
+                               load_bias = randomize_range(0x10000,
+                                                           ELF_ET_DYN_BASE,
+                                                           0);
+                       else
+                               load_bias = ELF_ET_DYN_BASE;
+                       load_bias = ELF_PAGESTART(load_bias - vaddr);
                }
 
                error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
@@ -1186,7 +1190,7 @@ static int maydump(struct vm_area_struct *vma)
 
        /* Dump shared memory only if mapped from an anonymous file. */
        if (vma->vm_flags & VM_SHARED)
-               return vma->vm_file->f_dentry->d_inode->i_nlink == 0;
+               return vma->vm_file->f_path.dentry->d_inode->i_nlink == 0;
 
        /* If it hasn't been written to, don't write it out */
        if (!vma->anon_vma)
@@ -1313,7 +1317,7 @@ static void fill_prstatus(struct elf_prstatus *prstatus,
        prstatus->pr_pid = p->pid;
        prstatus->pr_ppid = p->parent->pid;
        prstatus->pr_pgrp = process_group(p);
-       prstatus->pr_sid = p->signal->session;
+       prstatus->pr_sid = process_session(p);
        if (thread_group_leader(p)) {
                /*
                 * This is the record for the group leader.  Add in the
@@ -1359,7 +1363,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
        psinfo->pr_pid = p->pid;
        psinfo->pr_ppid = p->parent->pid;
        psinfo->pr_pgrp = process_group(p);
-       psinfo->pr_sid = p->signal->session;
+       psinfo->pr_sid = process_session(p);
 
        i = p->state ? ffz(~p->state) + 1 : 0;
        psinfo->pr_state = i;
index f86d5c9ce5ebda5eaf4c94fbd441dd770a24b9c4..76f06f6bc2f6caee3579092b5cc938b40ce1faed 100644 (file)
@@ -40,9 +40,6 @@
 #include <asm/pgalloc.h>
 
 typedef char *elf_caddr_t;
-#ifndef elf_addr_t
-#define elf_addr_t unsigned long
-#endif
 
 #if 0
 #define kdebug(fmt, ...) printk("FDPIC "fmt"\n" ,##__VA_ARGS__ )
@@ -858,7 +855,7 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
 
 dynamic_error:
        printk("ELF FDPIC %s with invalid DYNAMIC section (inode=%lu)\n",
-              what, file->f_dentry->d_inode->i_ino);
+              what, file->f_path.dentry->d_inode->i_ino);
        return -ELIBBAD;
 }
 
@@ -1189,7 +1186,7 @@ static int maydump(struct vm_area_struct *vma)
 
        /* Dump shared memory only if mapped from an anonymous file. */
        if (vma->vm_flags & VM_SHARED) {
-               if (vma->vm_file->f_dentry->d_inode->i_nlink == 0) {
+               if (vma->vm_file->f_path.dentry->d_inode->i_nlink == 0) {
                        kdcore("%08lx: %08lx: no (share)", vma->vm_start, vma->vm_flags);
                        return 1;
                }
@@ -1325,7 +1322,7 @@ static void fill_prstatus(struct elf_prstatus *prstatus,
        prstatus->pr_pid = p->pid;
        prstatus->pr_ppid = p->parent->pid;
        prstatus->pr_pgrp = process_group(p);
-       prstatus->pr_sid = p->signal->session;
+       prstatus->pr_sid = process_session(p);
        if (thread_group_leader(p)) {
                /*
                 * This is the record for the group leader.  Add in the
@@ -1374,7 +1371,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
        psinfo->pr_pid = p->pid;
        psinfo->pr_ppid = p->parent->pid;
        psinfo->pr_pgrp = process_group(p);
-       psinfo->pr_sid = p->signal->session;
+       psinfo->pr_sid = process_session(p);
 
        i = p->state ? ffz(~p->state) + 1 : 0;
        psinfo->pr_state = i;
index a62fd4018a201199fcb113d37920f3a643c3d321..ae8595d498569a72c6be2f4ce45d956326d33a9a 100644 (file)
@@ -429,7 +429,7 @@ static int load_flat_file(struct linux_binprm * bprm,
        int ret;
 
        hdr = ((struct flat_hdr *) bprm->buf);          /* exec-header */
-       inode = bprm->file->f_dentry->d_inode;
+       inode = bprm->file->f_path.dentry->d_inode;
 
        text_len  = ntohl(hdr->data_start);
        data_len  = ntohl(hdr->data_end) - ntohl(hdr->data_start);
index 1713c48fef5494e5e8ef361a83b5795ecaae4ce9..00687ea627385b11f0d03249b8bd038b380165ca 100644 (file)
@@ -542,7 +542,7 @@ static void kill_node(Node *e)
 static ssize_t
 bm_entry_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos)
 {
-       Node *e = file->f_dentry->d_inode->i_private;
+       Node *e = file->f_path.dentry->d_inode->i_private;
        loff_t pos = *ppos;
        ssize_t res;
        char *page;
@@ -576,7 +576,7 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
                                size_t count, loff_t *ppos)
 {
        struct dentry *root;
-       Node *e = file->f_dentry->d_inode->i_private;
+       Node *e = file->f_path.dentry->d_inode->i_private;
        int res = parse_command(buffer, count);
 
        switch (res) {
@@ -584,7 +584,7 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
                        break;
                case 2: set_bit(Enabled, &e->flags);
                        break;
-               case 3: root = dget(file->f_vfsmnt->mnt_sb->s_root);
+               case 3: root = dget(file->f_path.mnt->mnt_sb->s_root);
                        mutex_lock(&root->d_inode->i_mutex);
 
                        kill_node(e);
@@ -610,7 +610,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
        Node *e;
        struct inode *inode;
        struct dentry *root, *dentry;
-       struct super_block *sb = file->f_vfsmnt->mnt_sb;
+       struct super_block *sb = file->f_path.mnt->mnt_sb;
        int err = 0;
 
        e = create_entry(buffer, count);
@@ -699,7 +699,7 @@ static ssize_t bm_status_write(struct file * file, const char __user * buffer,
        switch (res) {
                case 1: enabled = 0; break;
                case 2: enabled = 1; break;
-               case 3: root = dget(file->f_vfsmnt->mnt_sb->s_root);
+               case 3: root = dget(file->f_path.mnt->mnt_sb->s_root);
                        mutex_lock(&root->d_inode->i_mutex);
 
                        while (!list_empty(&entries))
index 50c40ce2cead2078d528d48112d09b062fb32eb0..7ec737eda72bba71718d433820eae4e0c0d6a489 100644 (file)
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -30,7 +30,7 @@
 
 #define BIO_POOL_SIZE 256
 
-static kmem_cache_t *bio_slab __read_mostly;
+static struct kmem_cache *bio_slab __read_mostly;
 
 #define BIOVEC_NR_POOLS 6
 
@@ -44,7 +44,7 @@ mempool_t *bio_split_pool __read_mostly;
 struct biovec_slab {
        int nr_vecs;
        char *name; 
-       kmem_cache_t *slab;
+       struct kmem_cache *slab;
 };
 
 /*
index 36c0e7af9d0f18df487aab2420414fd95b1f1302..197f9392184741809013cd85828e654bb8b1ab14 100644 (file)
@@ -190,7 +190,7 @@ static int blkdev_commit_write(struct file *file, struct page *page, unsigned fr
 
 /*
  * private llseek:
- * for a block special file file->f_dentry->d_inode->i_size is zero
+ * for a block special file file->f_path.dentry->d_inode->i_size is zero
  * so we compute the size by hand (just as in block_read/write above)
  */
 static loff_t block_llseek(struct file *file, loff_t offset, int origin)
@@ -235,11 +235,11 @@ static int block_fsync(struct file *filp, struct dentry *dentry, int datasync)
  */
 
 static  __cacheline_aligned_in_smp DEFINE_SPINLOCK(bdev_lock);
-static kmem_cache_t * bdev_cachep __read_mostly;
+static struct kmem_cache * bdev_cachep __read_mostly;
 
 static struct inode *bdev_alloc_inode(struct super_block *sb)
 {
-       struct bdev_inode *ei = kmem_cache_alloc(bdev_cachep, SLAB_KERNEL);
+       struct bdev_inode *ei = kmem_cache_alloc(bdev_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        return &ei->vfs_inode;
@@ -253,7 +253,7 @@ static void bdev_destroy_inode(struct inode *inode)
        kmem_cache_free(bdev_cachep, bdi);
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct bdev_inode *ei = (struct bdev_inode *) foo;
        struct block_device *bdev = &ei->bdev;
@@ -762,7 +762,7 @@ static int bd_claim_by_kobject(struct block_device *bdev, void *holder,
        if (!bo)
                return -ENOMEM;
 
-       mutex_lock_nested(&bdev->bd_mutex, BD_MUTEX_PARTITION);
+       mutex_lock(&bdev->bd_mutex);
        res = bd_claim(bdev, holder);
        if (res == 0) {
                found = find_bd_holder(bdev, bo);
@@ -796,7 +796,7 @@ static void bd_release_from_kobject(struct block_device *bdev,
        if (!kobj)
                return;
 
-       mutex_lock_nested(&bdev->bd_mutex, BD_MUTEX_PARTITION);
+       mutex_lock(&bdev->bd_mutex);
        bd_release(bdev);
        if ((bo = del_bd_holder(bdev, kobj)))
                free_bd_holder(bo);
@@ -854,22 +854,6 @@ struct block_device *open_by_devnum(dev_t dev, unsigned mode)
 
 EXPORT_SYMBOL(open_by_devnum);
 
-static int
-blkdev_get_partition(struct block_device *bdev, mode_t mode, unsigned flags);
-
-struct block_device *open_partition_by_devnum(dev_t dev, unsigned mode)
-{
-       struct block_device *bdev = bdget(dev);
-       int err = -ENOMEM;
-       int flags = mode & FMODE_WRITE ? O_RDWR : O_RDONLY;
-       if (bdev)
-               err = blkdev_get_partition(bdev, mode, flags);
-       return err ? ERR_PTR(err) : bdev;
-}
-
-EXPORT_SYMBOL(open_partition_by_devnum);
-
-
 /*
  * This routine checks whether a removable media has been changed,
  * and invalidates all buffer-cache-entries in that case. This
@@ -916,66 +900,11 @@ void bd_set_size(struct block_device *bdev, loff_t size)
 }
 EXPORT_SYMBOL(bd_set_size);
 
-static int __blkdev_put(struct block_device *bdev, unsigned int subclass)
-{
-       int ret = 0;
-       struct inode *bd_inode = bdev->bd_inode;
-       struct gendisk *disk = bdev->bd_disk;
-
-       mutex_lock_nested(&bdev->bd_mutex, subclass);
-       lock_kernel();
-       if (!--bdev->bd_openers) {
-               sync_blockdev(bdev);
-               kill_bdev(bdev);
-       }
-       if (bdev->bd_contains == bdev) {
-               if (disk->fops->release)
-                       ret = disk->fops->release(bd_inode, NULL);
-       } else {
-               mutex_lock_nested(&bdev->bd_contains->bd_mutex,
-                                 subclass + 1);
-               bdev->bd_contains->bd_part_count--;
-               mutex_unlock(&bdev->bd_contains->bd_mutex);
-       }
-       if (!bdev->bd_openers) {
-               struct module *owner = disk->fops->owner;
-
-               put_disk(disk);
-               module_put(owner);
-
-               if (bdev->bd_contains != bdev) {
-                       kobject_put(&bdev->bd_part->kobj);
-                       bdev->bd_part = NULL;
-               }
-               bdev->bd_disk = NULL;
-               bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info;
-               if (bdev != bdev->bd_contains)
-                       __blkdev_put(bdev->bd_contains, subclass + 1);
-               bdev->bd_contains = NULL;
-       }
-       unlock_kernel();
-       mutex_unlock(&bdev->bd_mutex);
-       bdput(bdev);
-       return ret;
-}
-
-int blkdev_put(struct block_device *bdev)
-{
-       return __blkdev_put(bdev, BD_MUTEX_NORMAL);
-}
-EXPORT_SYMBOL(blkdev_put);
-
-int blkdev_put_partition(struct block_device *bdev)
-{
-       return __blkdev_put(bdev, BD_MUTEX_PARTITION);
-}
-EXPORT_SYMBOL(blkdev_put_partition);
+static int __blkdev_get(struct block_device *bdev, mode_t mode, unsigned flags,
+                       int for_part);
+static int __blkdev_put(struct block_device *bdev, int for_part);
 
-static int
-blkdev_get_whole(struct block_device *bdev, mode_t mode, unsigned flags);
-
-static int
-do_open(struct block_device *bdev, struct file *file, unsigned int subclass)
+static int do_open(struct block_device *bdev, struct file *file, int for_part)
 {
        struct module *owner = NULL;
        struct gendisk *disk;
@@ -992,8 +921,7 @@ do_open(struct block_device *bdev, struct file *file, unsigned int subclass)
        }
        owner = disk->fops->owner;
 
-       mutex_lock_nested(&bdev->bd_mutex, subclass);
-
+       mutex_lock_nested(&bdev->bd_mutex, for_part);
        if (!bdev->bd_openers) {
                bdev->bd_disk = disk;
                bdev->bd_contains = bdev;
@@ -1020,25 +948,21 @@ do_open(struct block_device *bdev, struct file *file, unsigned int subclass)
                        ret = -ENOMEM;
                        if (!whole)
                                goto out_first;
-                       ret = blkdev_get_whole(whole, file->f_mode, file->f_flags);
+                       BUG_ON(for_part);
+                       ret = __blkdev_get(whole, file->f_mode, file->f_flags, 1);
                        if (ret)
                                goto out_first;
                        bdev->bd_contains = whole;
-                       mutex_lock_nested(&whole->bd_mutex, BD_MUTEX_WHOLE);
-                       whole->bd_part_count++;
                        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 || !p->nr_sects) {
-                               whole->bd_part_count--;
-                               mutex_unlock(&whole->bd_mutex);
                                ret = -ENXIO;
                                goto out_first;
                        }
                        kobject_get(&p->kobj);
                        bdev->bd_part = p;
                        bd_set_size(bdev, (loff_t) p->nr_sects << 9);
-                       mutex_unlock(&whole->bd_mutex);
                }
        } else {
                put_disk(disk);
@@ -1051,14 +975,11 @@ do_open(struct block_device *bdev, struct file *file, unsigned int subclass)
                        }
                        if (bdev->bd_invalidated)
                                rescan_partitions(bdev->bd_disk, bdev);
-               } else {
-                       mutex_lock_nested(&bdev->bd_contains->bd_mutex,
-                                         BD_MUTEX_WHOLE);
-                       bdev->bd_contains->bd_part_count++;
-                       mutex_unlock(&bdev->bd_contains->bd_mutex);
                }
        }
        bdev->bd_openers++;
+       if (for_part)
+               bdev->bd_part_count++;
        mutex_unlock(&bdev->bd_mutex);
        unlock_kernel();
        return 0;
@@ -1067,7 +988,7 @@ out_first:
        bdev->bd_disk = NULL;
        bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info;
        if (bdev != bdev->bd_contains)
-               __blkdev_put(bdev->bd_contains, BD_MUTEX_WHOLE);
+               __blkdev_put(bdev->bd_contains, 1);
        bdev->bd_contains = NULL;
        put_disk(disk);
        module_put(owner);
@@ -1079,7 +1000,8 @@ out:
        return ret;
 }
 
-int blkdev_get(struct block_device *bdev, mode_t mode, unsigned flags)
+static int __blkdev_get(struct block_device *bdev, mode_t mode, unsigned flags,
+                       int for_part)
 {
        /*
         * This crockload is due to bad choice of ->open() type.
@@ -1091,51 +1013,17 @@ int blkdev_get(struct block_device *bdev, mode_t mode, unsigned flags)
        struct dentry fake_dentry = {};
        fake_file.f_mode = mode;
        fake_file.f_flags = flags;
-       fake_file.f_dentry = &fake_dentry;
+       fake_file.f_path.dentry = &fake_dentry;
        fake_dentry.d_inode = bdev->bd_inode;
 
-       return do_open(bdev, &fake_file, BD_MUTEX_NORMAL);
+       return do_open(bdev, &fake_file, for_part);
 }
 
-EXPORT_SYMBOL(blkdev_get);
-
-static int
-blkdev_get_whole(struct block_device *bdev, mode_t mode, unsigned flags)
-{
-       /*
-        * This crockload is due to bad choice of ->open() type.
-        * It will go away.
-        * For now, block device ->open() routine must _not_
-        * examine anything in 'inode' argument except ->i_rdev.
-        */
-       struct file fake_file = {};
-       struct dentry fake_dentry = {};
-       fake_file.f_mode = mode;
-       fake_file.f_flags = flags;
-       fake_file.f_dentry = &fake_dentry;
-       fake_dentry.d_inode = bdev->bd_inode;
-
-       return do_open(bdev, &fake_file, BD_MUTEX_WHOLE);
-}
-
-static int
-blkdev_get_partition(struct block_device *bdev, mode_t mode, unsigned flags)
+int blkdev_get(struct block_device *bdev, mode_t mode, unsigned flags)
 {
-       /*
-        * This crockload is due to bad choice of ->open() type.
-        * It will go away.
-        * For now, block device ->open() routine must _not_
-        * examine anything in 'inode' argument except ->i_rdev.
-        */
-       struct file fake_file = {};
-       struct dentry fake_dentry = {};
-       fake_file.f_mode = mode;
-       fake_file.f_flags = flags;
-       fake_file.f_dentry = &fake_dentry;
-       fake_dentry.d_inode = bdev->bd_inode;
-
-       return do_open(bdev, &fake_file, BD_MUTEX_PARTITION);
+       return __blkdev_get(bdev, mode, flags, 0);
 }
+EXPORT_SYMBOL(blkdev_get);
 
 static int blkdev_open(struct inode * inode, struct file * filp)
 {
@@ -1154,7 +1042,7 @@ static int blkdev_open(struct inode * inode, struct file * filp)
        if (bdev == NULL)
                return -ENOMEM;
 
-       res = do_open(bdev, filp, BD_MUTEX_NORMAL);
+       res = do_open(bdev, filp, 0);
        if (res)
                return res;
 
@@ -1168,6 +1056,56 @@ static int blkdev_open(struct inode * inode, struct file * filp)
        return res;
 }
 
+static int __blkdev_put(struct block_device *bdev, int for_part)
+{
+       int ret = 0;
+       struct inode *bd_inode = bdev->bd_inode;
+       struct gendisk *disk = bdev->bd_disk;
+       struct block_device *victim = NULL;
+
+       mutex_lock_nested(&bdev->bd_mutex, for_part);
+       lock_kernel();
+       if (for_part)
+               bdev->bd_part_count--;
+
+       if (!--bdev->bd_openers) {
+               sync_blockdev(bdev);
+               kill_bdev(bdev);
+       }
+       if (bdev->bd_contains == bdev) {
+               if (disk->fops->release)
+                       ret = disk->fops->release(bd_inode, NULL);
+       }
+       if (!bdev->bd_openers) {
+               struct module *owner = disk->fops->owner;
+
+               put_disk(disk);
+               module_put(owner);
+
+               if (bdev->bd_contains != bdev) {
+                       kobject_put(&bdev->bd_part->kobj);
+                       bdev->bd_part = NULL;
+               }
+               bdev->bd_disk = NULL;
+               bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info;
+               if (bdev != bdev->bd_contains)
+                       victim = bdev->bd_contains;
+               bdev->bd_contains = NULL;
+       }
+       unlock_kernel();
+       mutex_unlock(&bdev->bd_mutex);
+       bdput(bdev);
+       if (victim)
+               __blkdev_put(victim, 1);
+       return ret;
+}
+
+int blkdev_put(struct block_device *bdev)
+{
+       return __blkdev_put(bdev, 0);
+}
+EXPORT_SYMBOL(blkdev_put);
+
 static int blkdev_close(struct inode * inode, struct file * filp)
 {
        struct block_device *bdev = I_BDEV(filp->f_mapping->host);
index 35527dca1dbcc415d95d76780537c577808df9ff..517860f2d75b0d575e65af71f54745840a3a28ad 100644 (file)
@@ -2908,7 +2908,7 @@ asmlinkage long sys_bdflush(int func, long data)
 /*
  * Buffer-head allocation
  */
-static kmem_cache_t *bh_cachep;
+static struct kmem_cache *bh_cachep;
 
 /*
  * Once the number of bh's in the machine exceeds this level, we start
@@ -2961,7 +2961,7 @@ void free_buffer_head(struct buffer_head *bh)
 EXPORT_SYMBOL(free_buffer_head);
 
 static void
-init_buffer_head(void *data, kmem_cache_t *cachep, unsigned long flags)
+init_buffer_head(void *data, struct kmem_cache *cachep, unsigned long flags)
 {
        if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
                            SLAB_CTOR_CONSTRUCTOR) {
@@ -2972,7 +2972,6 @@ init_buffer_head(void *data, kmem_cache_t *cachep, unsigned long flags)
        }
 }
 
-#ifdef CONFIG_HOTPLUG_CPU
 static void buffer_exit_cpu(int cpu)
 {
        int i;
@@ -2994,7 +2993,6 @@ static int buffer_cpu_notify(struct notifier_block *self,
                buffer_exit_cpu((unsigned long)hcpu);
        return NOTIFY_OK;
 }
-#endif /* CONFIG_HOTPLUG_CPU */
 
 void __init buffer_init(void)
 {
index 0b3c37ef52e0fec42a32feee445e4a915a3d046b..3539d6ef96114b53350e42274b1f83deda6e52a3 100644 (file)
@@ -5,7 +5,8 @@ Allow null user to be specified on mount ("username="). Do not return
 EINVAL on readdir when filldir fails due to overwritten blocksize
 (fixes FC problem).  Return error in rename 2nd attempt retry (ie report
 if rename by handle also fails, after rename by path fails, we were
-not reporting whether the retry worked or not).
+not reporting whether the retry worked or not). Fix NTLMv2 to
+work to Windows servers (mount with option "sec=ntlmv2").
 
 Version 1.45
 ------------
index 4bc250b2d9fc19aa27aea309b900b186b95a2602..fdeda519eace6263c6d975a9c1f8836ac5c32d56 100644 (file)
@@ -372,8 +372,10 @@ void setup_ntlmv2_rsp(struct cifsSesInfo * ses, char * resp_buf,
        buf->time = cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
        get_random_bytes(&buf->client_chal, sizeof(buf->client_chal));
        buf->reserved2 = 0;
-       buf->names[0].type = 0;
+       buf->names[0].type = cpu_to_le16(NTLMSSP_DOMAIN_TYPE);
        buf->names[0].length = 0;
+       buf->names[1].type = 0;
+       buf->names[1].length = 0;
 
        /* calculate buf->ntlmv2_hash */
        rc = calc_ntlmv2_hash(ses, nls_cp);
index 84976cdbe7136c4b76ad0777c924d44fd4b613cd..10c90294cd1821c9fd273f688c50f6f85889d4cd 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/mempool.h>
 #include <linux/delay.h>
 #include <linux/kthread.h>
+#include <linux/freezer.h>
 #include "cifsfs.h"
 #include "cifspdu.h"
 #define DECLARE_GLOBALS_HERE
@@ -81,7 +82,7 @@ extern mempool_t *cifs_sm_req_poolp;
 extern mempool_t *cifs_req_poolp;
 extern mempool_t *cifs_mid_poolp;
 
-extern kmem_cache_t *cifs_oplock_cachep;
+extern struct kmem_cache *cifs_oplock_cachep;
 
 static int
 cifs_read_super(struct super_block *sb, void *data,
@@ -232,11 +233,11 @@ static int cifs_permission(struct inode * inode, int mask, struct nameidata *nd)
                return generic_permission(inode, mask, NULL);
 }
 
-static kmem_cache_t *cifs_inode_cachep;
-static kmem_cache_t *cifs_req_cachep;
-static kmem_cache_t *cifs_mid_cachep;
-kmem_cache_t *cifs_oplock_cachep;
-static kmem_cache_t *cifs_sm_req_cachep;
+static struct kmem_cache *cifs_inode_cachep;
+static struct kmem_cache *cifs_req_cachep;
+static struct kmem_cache *cifs_mid_cachep;
+struct kmem_cache *cifs_oplock_cachep;
+static struct kmem_cache *cifs_sm_req_cachep;
 mempool_t *cifs_sm_req_poolp;
 mempool_t *cifs_req_poolp;
 mempool_t *cifs_mid_poolp;
@@ -245,7 +246,7 @@ static struct inode *
 cifs_alloc_inode(struct super_block *sb)
 {
        struct cifsInodeInfo *cifs_inode;
-       cifs_inode = kmem_cache_alloc(cifs_inode_cachep, SLAB_KERNEL);
+       cifs_inode = kmem_cache_alloc(cifs_inode_cachep, GFP_KERNEL);
        if (!cifs_inode)
                return NULL;
        cifs_inode->cifsAttrs = 0x20;   /* default */
@@ -497,7 +498,7 @@ cifs_get_sb(struct file_system_type *fs_type,
 static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
                                   unsigned long nr_segs, loff_t pos)
 {
-       struct inode *inode = iocb->ki_filp->f_dentry->d_inode;
+       struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode;
        ssize_t written;
 
        written = generic_file_aio_write(iocb, iov, nr_segs, pos);
@@ -510,7 +511,7 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
 {
        /* origin == SEEK_END => we must revalidate the cached file length */
        if (origin == SEEK_END) {
-               int retval = cifs_revalidate(file->f_dentry);
+               int retval = cifs_revalidate(file->f_path.dentry);
                if (retval < 0)
                        return (loff_t)retval;
        }
@@ -668,7 +669,7 @@ const struct file_operations cifs_dir_ops = {
 };
 
 static void
-cifs_init_once(void *inode, kmem_cache_t * cachep, unsigned long flags)
+cifs_init_once(void *inode, struct kmem_cache * cachep, unsigned long flags)
 {
        struct cifsInodeInfo *cifsi = inode;
 
index 6df9dadba647035ad58f719a5e322bca1b9ac8de..068ef51edbf710c08a4793ec3b78033a5df675d9 100644 (file)
@@ -580,6 +580,12 @@ typedef union smb_com_session_setup_andx {
 
 /* format of NLTMv2 Response ie "case sensitive password" hash when NTLMv2 */
 
+#define NTLMSSP_SERVER_TYPE    1
+#define NTLMSSP_DOMAIN_TYPE    2
+#define NTLMSSP_FQ_DOMAIN_TYPE 3
+#define NTLMSSP_DNS_DOMAIN_TYPE        4
+#define NTLMSSP_DNS_PARENT_TYPE        5
+
 struct ntlmssp2_name {
        __le16 type;
        __le16 length;
@@ -593,7 +599,7 @@ struct ntlmv2_resp {
        __le64  time;
        __u64  client_chal; /* random */
        __u32  reserved2;
-       struct ntlmssp2_name names[1];
+       struct ntlmssp2_name names[2];
        /* array of name entries could follow ending in minimum 4 byte struct */
 } __attribute__((packed));
 
index 71f77914ce9334e3134c3400385e62b92efd8e96..2caca06b4bae214327c3fccc7a046f6a0269ac37 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/delay.h>
 #include <linux/completion.h>
 #include <linux/pagevec.h>
+#include <linux/freezer.h>
 #include <asm/uaccess.h>
 #include <asm/processor.h>
 #include "cifspdu.h"
index d91a3d44e9e30ce1f36b67b650482212355d8629..da12b482ebe5364d1bc4e6dba9bba25ffa25e12c 100644 (file)
@@ -83,10 +83,10 @@ int cifs_dir_notify(struct file * file, unsigned long arg)
                return 0;
 
        xid = GetXid();
-       cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+       cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
        pTcon = cifs_sb->tcon;
 
-       full_path = build_path_from_dentry(file->f_dentry);
+       full_path = build_path_from_dentry(file->f_path.dentry);
 
        if(full_path == NULL) {
                rc = -ENOMEM;
index 2436ed8fc8400e2d86b4e5bbb569b122ac013e34..1aa95a50cac25baf08cf856ecdd0bf60e662344c 100644 (file)
@@ -122,34 +122,34 @@ static inline int cifs_open_inode_helper(struct inode *inode, struct file *file,
        /* if not oplocked, invalidate inode pages if mtime or file
           size changed */
        temp = cifs_NTtimeToUnix(le64_to_cpu(buf->LastWriteTime));
-       if (timespec_equal(&file->f_dentry->d_inode->i_mtime, &temp) && 
-                          (file->f_dentry->d_inode->i_size == 
+       if (timespec_equal(&file->f_path.dentry->d_inode->i_mtime, &temp) &&
+                          (file->f_path.dentry->d_inode->i_size ==
                            (loff_t)le64_to_cpu(buf->EndOfFile))) {
                cFYI(1, ("inode unchanged on server"));
        } else {
-               if (file->f_dentry->d_inode->i_mapping) {
+               if (file->f_path.dentry->d_inode->i_mapping) {
                /* BB no need to lock inode until after invalidate
                   since namei code should already have it locked? */
-                       filemap_write_and_wait(file->f_dentry->d_inode->i_mapping);
+                       filemap_write_and_wait(file->f_path.dentry->d_inode->i_mapping);
                }
                cFYI(1, ("invalidating remote inode since open detected it "
                         "changed"));
-               invalidate_remote_inode(file->f_dentry->d_inode);
+               invalidate_remote_inode(file->f_path.dentry->d_inode);
        }
 
 client_can_cache:
        if (pTcon->ses->capabilities & CAP_UNIX)
-               rc = cifs_get_inode_info_unix(&file->f_dentry->d_inode,
+               rc = cifs_get_inode_info_unix(&file->f_path.dentry->d_inode,
                        full_path, inode->i_sb, xid);
        else
-               rc = cifs_get_inode_info(&file->f_dentry->d_inode,
+               rc = cifs_get_inode_info(&file->f_path.dentry->d_inode,
                        full_path, buf, inode->i_sb, xid);
 
        if ((*oplock & 0xF) == OPLOCK_EXCLUSIVE) {
                pCifsInode->clientCanCacheAll = TRUE;
                pCifsInode->clientCanCacheRead = TRUE;
                cFYI(1, ("Exclusive Oplock granted on inode %p",
-                        file->f_dentry->d_inode));
+                        file->f_path.dentry->d_inode));
        } else if ((*oplock & 0xF) == OPLOCK_READ)
                pCifsInode->clientCanCacheRead = TRUE;
 
@@ -178,7 +178,7 @@ int cifs_open(struct inode *inode, struct file *file)
 
        if (file->f_flags & O_CREAT) {
                /* search inode for this file and fill in file->private_data */
-               pCifsInode = CIFS_I(file->f_dentry->d_inode);
+               pCifsInode = CIFS_I(file->f_path.dentry->d_inode);
                read_lock(&GlobalSMBSeslock);
                list_for_each(tmp, &pCifsInode->openFileList) {
                        pCifsFile = list_entry(tmp, struct cifsFileInfo,
@@ -206,7 +206,7 @@ int cifs_open(struct inode *inode, struct file *file)
                }
        }
 
-       full_path = build_path_from_dentry(file->f_dentry);
+       full_path = build_path_from_dentry(file->f_path.dentry);
        if (full_path == NULL) {
                FreeXid(xid);
                return -ENOMEM;
@@ -291,7 +291,7 @@ int cifs_open(struct inode *inode, struct file *file)
        write_lock(&GlobalSMBSeslock);
        list_add(&pCifsFile->tlist, &pTcon->openFileList);
 
-       pCifsInode = CIFS_I(file->f_dentry->d_inode);
+       pCifsInode = CIFS_I(file->f_path.dentry->d_inode);
        if (pCifsInode) {
                rc = cifs_open_inode_helper(inode, file, pCifsInode,
                                            pCifsFile, pTcon,
@@ -366,7 +366,7 @@ static int cifs_reopen_file(struct inode *inode, struct file *file,
                return 0;
        }
 
-       if (file->f_dentry == NULL) {
+       if (file->f_path.dentry == NULL) {
                up(&pCifsFile->fh_sem);
                cFYI(1, ("failed file reopen, no valid name if dentry freed"));
                FreeXid(xid);
@@ -378,7 +378,7 @@ static int cifs_reopen_file(struct inode *inode, struct file *file,
    those that already have the rename sem can end up causing writepage
    to get called and if the server was down that means we end up here,
    and we can never tell if the caller already has the rename_sem */
-       full_path = build_path_from_dentry(file->f_dentry);
+       full_path = build_path_from_dentry(file->f_path.dentry);
        if (full_path == NULL) {
                up(&pCifsFile->fh_sem);
                FreeXid(xid);
@@ -444,7 +444,7 @@ static int cifs_reopen_file(struct inode *inode, struct file *file,
                                pCifsInode->clientCanCacheAll = TRUE;
                                pCifsInode->clientCanCacheRead = TRUE;
                                cFYI(1, ("Exclusive Oplock granted on inode %p",
-                                        file->f_dentry->d_inode));
+                                        file->f_path.dentry->d_inode));
                        } else if ((oplock & 0xF) == OPLOCK_READ) {
                                pCifsInode->clientCanCacheRead = TRUE;
                                pCifsInode->clientCanCacheAll = FALSE;
@@ -551,7 +551,7 @@ int cifs_closedir(struct inode *inode, struct file *file)
 
        if (pCFileStruct) {
                struct cifsTconInfo *pTcon;
-               struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+               struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
 
                pTcon = cifs_sb->tcon;
 
@@ -664,7 +664,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
        } else
                cFYI(1, ("Unknown type of lock"));
 
-       cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+       cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
        pTcon = cifs_sb->tcon;
 
        if (file->private_data == NULL) {
@@ -791,10 +791,10 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
        int xid, long_op;
        struct cifsFileInfo *open_file;
 
-       if (file->f_dentry == NULL)
+       if (file->f_path.dentry == NULL)
                return -EBADF;
 
-       cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+       cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
        if (cifs_sb == NULL)
                return -EBADF;
 
@@ -802,7 +802,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
 
        /* cFYI(1,
           (" write %d bytes to offset %lld of %s", write_size,
-          *poffset, file->f_dentry->d_name.name)); */
+          *poffset, file->f_path.dentry->d_name.name)); */
 
        if (file->private_data == NULL)
                return -EBADF;
@@ -810,12 +810,12 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
                open_file = (struct cifsFileInfo *) file->private_data;
        
        xid = GetXid();
-       if (file->f_dentry->d_inode == NULL) {
+       if (file->f_path.dentry->d_inode == NULL) {
                FreeXid(xid);
                return -EBADF;
        }
 
-       if (*poffset > file->f_dentry->d_inode->i_size)
+       if (*poffset > file->f_path.dentry->d_inode->i_size)
                long_op = 2; /* writes past end of file can take a long time */
        else
                long_op = 1;
@@ -840,8 +840,8 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
                                        return -EBADF;
                        }
                        if (open_file->invalidHandle) {
-                               if ((file->f_dentry == NULL) ||
-                                   (file->f_dentry->d_inode == NULL)) {
+                               if ((file->f_path.dentry == NULL) ||
+                                   (file->f_path.dentry->d_inode == NULL)) {
                                        FreeXid(xid);
                                        return total_written;
                                }
@@ -849,7 +849,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
                                   filemap_fdatawait from here so tell
                                   reopen_file not to flush data to server
                                   now */
-                               rc = cifs_reopen_file(file->f_dentry->d_inode,
+                               rc = cifs_reopen_file(file->f_path.dentry->d_inode,
                                        file, FALSE);
                                if (rc != 0)
                                        break;
@@ -878,17 +878,17 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
        cifs_stats_bytes_written(pTcon, total_written);
 
        /* since the write may have blocked check these pointers again */
-       if (file->f_dentry) {
-               if (file->f_dentry->d_inode) {
-                       struct inode *inode = file->f_dentry->d_inode;
+       if (file->f_path.dentry) {
+               if (file->f_path.dentry->d_inode) {
+                       struct inode *inode = file->f_path.dentry->d_inode;
                        inode->i_ctime = inode->i_mtime =
                                current_fs_time(inode->i_sb);
                        if (total_written > 0) {
-                               if (*poffset > file->f_dentry->d_inode->i_size)
-                                       i_size_write(file->f_dentry->d_inode,
+                               if (*poffset > file->f_path.dentry->d_inode->i_size)
+                                       i_size_write(file->f_path.dentry->d_inode,
                                        *poffset);
                        }
-                       mark_inode_dirty_sync(file->f_dentry->d_inode);
+                       mark_inode_dirty_sync(file->f_path.dentry->d_inode);
                }
        }
        FreeXid(xid);
@@ -906,17 +906,17 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
        int xid, long_op;
        struct cifsFileInfo *open_file;
 
-       if (file->f_dentry == NULL)
+       if (file->f_path.dentry == NULL)
                return -EBADF;
 
-       cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+       cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
        if (cifs_sb == NULL)
                return -EBADF;
 
        pTcon = cifs_sb->tcon;
 
        cFYI(1,("write %zd bytes to offset %lld of %s", write_size,
-          *poffset, file->f_dentry->d_name.name));
+          *poffset, file->f_path.dentry->d_name.name));
 
        if (file->private_data == NULL)
                return -EBADF;
@@ -924,12 +924,12 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
                open_file = (struct cifsFileInfo *)file->private_data;
        
        xid = GetXid();
-       if (file->f_dentry->d_inode == NULL) {
+       if (file->f_path.dentry->d_inode == NULL) {
                FreeXid(xid);
                return -EBADF;
        }
 
-       if (*poffset > file->f_dentry->d_inode->i_size)
+       if (*poffset > file->f_path.dentry->d_inode->i_size)
                long_op = 2; /* writes past end of file can take a long time */
        else
                long_op = 1;
@@ -955,8 +955,8 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
                                        return -EBADF;
                        }
                        if (open_file->invalidHandle) {
-                               if ((file->f_dentry == NULL) ||
-                                  (file->f_dentry->d_inode == NULL)) {
+                               if ((file->f_path.dentry == NULL) ||
+                                  (file->f_path.dentry->d_inode == NULL)) {
                                        FreeXid(xid);
                                        return total_written;
                                }
@@ -964,7 +964,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
                                   filemap_fdatawait from here so tell
                                   reopen_file not to flush data to 
                                   server now */
-                               rc = cifs_reopen_file(file->f_dentry->d_inode,
+                               rc = cifs_reopen_file(file->f_path.dentry->d_inode,
                                        file, FALSE);
                                if (rc != 0)
                                        break;
@@ -1011,16 +1011,16 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
        cifs_stats_bytes_written(pTcon, total_written);
 
        /* since the write may have blocked check these pointers again */
-       if (file->f_dentry) {
-               if (file->f_dentry->d_inode) {
-                       file->f_dentry->d_inode->i_ctime = 
-                       file->f_dentry->d_inode->i_mtime = CURRENT_TIME;
+       if (file->f_path.dentry) {
+               if (file->f_path.dentry->d_inode) {
+                       file->f_path.dentry->d_inode->i_ctime =
+                       file->f_path.dentry->d_inode->i_mtime = CURRENT_TIME;
                        if (total_written > 0) {
-                               if (*poffset > file->f_dentry->d_inode->i_size)
-                                       i_size_write(file->f_dentry->d_inode, 
+                               if (*poffset > file->f_path.dentry->d_inode->i_size)
+                                       i_size_write(file->f_path.dentry->d_inode,
                                                     *poffset);
                        }
-                       mark_inode_dirty_sync(file->f_dentry->d_inode);
+                       mark_inode_dirty_sync(file->f_path.dentry->d_inode);
                }
        }
        FreeXid(xid);
@@ -1384,7 +1384,7 @@ static int cifs_commit_write(struct file *file, struct page *page,
                                if ((open_file->invalidHandle) && 
                                    (!open_file->closePend)) {
                                        rc = cifs_reopen_file(
-                                               file->f_dentry->d_inode, file);
+                                               file->f_path.dentry->d_inode, file);
                                        if (rc != 0)
                                                break;
                                }
@@ -1434,7 +1434,7 @@ int cifs_fsync(struct file *file, struct dentry *dentry, int datasync)
 {
        int xid;
        int rc = 0;
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
 
        xid = GetXid();
 
@@ -1482,7 +1482,7 @@ int cifs_fsync(struct file *file, struct dentry *dentry, int datasync)
  */
 int cifs_flush(struct file *file, fl_owner_t id)
 {
-       struct inode * inode = file->f_dentry->d_inode;
+       struct inode * inode = file->f_path.dentry->d_inode;
        int rc = 0;
 
        /* Rather than do the steps manually:
@@ -1519,7 +1519,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
        struct smb_com_read_rsp *pSMBr;
 
        xid = GetXid();
-       cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+       cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
        pTcon = cifs_sb->tcon;
 
        if (file->private_data == NULL) {
@@ -1542,7 +1542,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
                        int buf_type = CIFS_NO_BUFFER;
                        if ((open_file->invalidHandle) && 
                            (!open_file->closePend)) {
-                               rc = cifs_reopen_file(file->f_dentry->d_inode,
+                               rc = cifs_reopen_file(file->f_path.dentry->d_inode,
                                        file, TRUE);
                                if (rc != 0)
                                        break;
@@ -1601,7 +1601,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
        int buf_type = CIFS_NO_BUFFER;
 
        xid = GetXid();
-       cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+       cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
        pTcon = cifs_sb->tcon;
 
        if (file->private_data == NULL) {
@@ -1629,7 +1629,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
                while (rc == -EAGAIN) {
                        if ((open_file->invalidHandle) && 
                            (!open_file->closePend)) {
-                               rc = cifs_reopen_file(file->f_dentry->d_inode,
+                               rc = cifs_reopen_file(file->f_path.dentry->d_inode,
                                        file, TRUE);
                                if (rc != 0)
                                        break;
@@ -1658,7 +1658,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
 
 int cifs_file_mmap(struct file *file, struct vm_area_struct *vma)
 {
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
        int rc, xid;
 
        xid = GetXid();
@@ -1744,7 +1744,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
                return -EBADF;
        }
        open_file = (struct cifsFileInfo *)file->private_data;
-       cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+       cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
        pTcon = cifs_sb->tcon;
 
        pagevec_init(&lru_pvec, 0);
@@ -1786,7 +1786,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
                while (rc == -EAGAIN) {
                        if ((open_file->invalidHandle) && 
                            (!open_file->closePend)) {
-                               rc = cifs_reopen_file(file->f_dentry->d_inode,
+                               rc = cifs_reopen_file(file->f_path.dentry->d_inode,
                                        file, TRUE);
                                if (rc != 0)
                                        break;
@@ -1880,8 +1880,8 @@ static int cifs_readpage_worker(struct file *file, struct page *page,
        else
                cFYI(1, ("Bytes read %d",rc));
                                                                                                                            
-       file->f_dentry->d_inode->i_atime =
-               current_fs_time(file->f_dentry->d_inode->i_sb);
+       file->f_path.dentry->d_inode->i_atime =
+               current_fs_time(file->f_path.dentry->d_inode->i_sb);
                                                                                                                            
        if (PAGE_CACHE_SIZE > rc)
                memset(read_data + rc, 0, PAGE_CACHE_SIZE - rc);
index bbc9cd34b6ea42f02d85e9e31c140824b4ab5dd8..aedf683f011fe42606f7d58bb5005d1744dae543 100644 (file)
@@ -153,7 +153,7 @@ cifs_buf_get(void)
    albeit slightly larger than necessary and maxbuffersize 
    defaults to this and can not be bigger */
        ret_buf =
-           (struct smb_hdr *) mempool_alloc(cifs_req_poolp, SLAB_KERNEL | SLAB_NOFS);
+           (struct smb_hdr *) mempool_alloc(cifs_req_poolp, GFP_KERNEL | GFP_NOFS);
 
        /* clear the first few header bytes */
        /* for most paths, more is cleared in header_assemble */
@@ -192,7 +192,7 @@ cifs_small_buf_get(void)
    albeit slightly larger than necessary and maxbuffersize 
    defaults to this and can not be bigger */
        ret_buf =
-           (struct smb_hdr *) mempool_alloc(cifs_sm_req_poolp, SLAB_KERNEL | SLAB_NOFS);
+           (struct smb_hdr *) mempool_alloc(cifs_sm_req_poolp, GFP_KERNEL | GFP_NOFS);
        if (ret_buf) {
        /* No need to clear memory here, cleared in header assemble */
        /*      memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
index ed18c3965f7b5e7f49d43b6bb944a70ca6dca5bd..99dfb5337e3169d8e38cf062a509326694b24a0d 100644 (file)
@@ -68,30 +68,30 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
        int rc = 0;
 
        cFYI(1, ("For %s", qstring->name));
-       cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+       cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
        pTcon = cifs_sb->tcon;
 
        qstring->hash = full_name_hash(qstring->name, qstring->len);
-       tmp_dentry = d_lookup(file->f_dentry, qstring);
+       tmp_dentry = d_lookup(file->f_path.dentry, qstring);
        if (tmp_dentry) {
                cFYI(0, ("existing dentry with inode 0x%p", tmp_dentry->d_inode));
                *ptmp_inode = tmp_dentry->d_inode;
 /* BB overwrite old name? i.e. tmp_dentry->d_name and tmp_dentry->d_name.len??*/
                if(*ptmp_inode == NULL) {
-                       *ptmp_inode = new_inode(file->f_dentry->d_sb);
+                       *ptmp_inode = new_inode(file->f_path.dentry->d_sb);
                        if(*ptmp_inode == NULL)
                                return rc;
                        rc = 1;
                }
        } else {
-               tmp_dentry = d_alloc(file->f_dentry, qstring);
+               tmp_dentry = d_alloc(file->f_path.dentry, qstring);
                if(tmp_dentry == NULL) {
                        cERROR(1,("Failed allocating dentry"));
                        *ptmp_inode = NULL;
                        return rc;
                }
 
-               *ptmp_inode = new_inode(file->f_dentry->d_sb);
+               *ptmp_inode = new_inode(file->f_path.dentry->d_sb);
                if (pTcon->nocase)
                        tmp_dentry->d_op = &cifs_ci_dentry_ops;
                else
@@ -432,10 +432,10 @@ static int initiate_cifs_search(const int xid, struct file *file)
        cifsFile->invalidHandle = TRUE;
        cifsFile->srch_inf.endOfSearch = FALSE;
 
-       if(file->f_dentry == NULL)
+       if(file->f_path.dentry == NULL)
                return -ENOENT;
 
-       cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+       cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
        if(cifs_sb == NULL)
                return -EINVAL;
 
@@ -443,7 +443,7 @@ static int initiate_cifs_search(const int xid, struct file *file)
        if(pTcon == NULL)
                return -EINVAL;
 
-       full_path = build_path_from_dentry(file->f_dentry);
+       full_path = build_path_from_dentry(file->f_path.dentry);
 
        if(full_path == NULL) {
                return -ENOMEM;
@@ -609,10 +609,10 @@ static int is_dir_changed(struct file * file)
        struct inode * inode;
        struct cifsInodeInfo *cifsInfo;
 
-       if(file->f_dentry == NULL)
+       if(file->f_path.dentry == NULL)
                return 0;
 
-       inode = file->f_dentry->d_inode;
+       inode = file->f_path.dentry->d_inode;
 
        if(inode == NULL)
                return 0;
@@ -839,7 +839,7 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
        if((scratch_buf == NULL) || (pfindEntry == NULL) || (pCifsF == NULL))
                return -ENOENT;
 
-       if(file->f_dentry == NULL)
+       if(file->f_path.dentry == NULL)
                return -ENOENT;
 
        rc = cifs_entry_is_dot(pfindEntry,pCifsF);
@@ -847,7 +847,7 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
        if(rc != 0) 
                return 0;
 
-       cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+       cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
 
        qstring.name = scratch_buf;
        rc = cifs_get_name_from_search_buf(&qstring,pfindEntry,
@@ -985,12 +985,12 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
 
        xid = GetXid();
 
-       if(file->f_dentry == NULL) {
+       if(file->f_path.dentry == NULL) {
                FreeXid(xid);
                return -EIO;
        }
 
-       cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+       cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
        pTcon = cifs_sb->tcon;
        if(pTcon == NULL)
                return -EINVAL;
@@ -998,7 +998,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
        switch ((int) file->f_pos) {
        case 0:
                if (filldir(direntry, ".", 1, file->f_pos,
-                    file->f_dentry->d_inode->i_ino, DT_DIR) < 0) {
+                    file->f_path.dentry->d_inode->i_ino, DT_DIR) < 0) {
                        cERROR(1, ("Filldir for current dir failed"));
                        rc = -ENOMEM;
                        break;
@@ -1006,7 +1006,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
                file->f_pos++;
        case 1:
                if (filldir(direntry, "..", 2, file->f_pos,
-                    file->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) {
+                    file->f_path.dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) {
                        cERROR(1, ("Filldir for parent dir failed"));
                        rc = -ENOMEM;
                        break;
index 48d47b46b1fb05597d662e88a9b342a883cc21b9..f80007eaebf4100c67224e4ffa524d2c6c517517 100644 (file)
@@ -34,7 +34,7 @@
 #include "cifs_debug.h"
   
 extern mempool_t *cifs_mid_poolp;
-extern kmem_cache_t *cifs_oplock_cachep;
+extern struct kmem_cache *cifs_oplock_cachep;
 
 static struct mid_q_entry *
 AllocMidQEntry(const struct smb_hdr *smb_buffer, struct cifsSesInfo *ses)
@@ -51,7 +51,7 @@ AllocMidQEntry(const struct smb_hdr *smb_buffer, struct cifsSesInfo *ses)
        }
        
        temp = (struct mid_q_entry *) mempool_alloc(cifs_mid_poolp,
-                                                   SLAB_KERNEL | SLAB_NOFS);
+                                                   GFP_KERNEL | GFP_NOFS);
        if (temp == NULL)
                return temp;
        else {
@@ -118,7 +118,7 @@ AllocOplockQEntry(struct inode * pinode, __u16 fid, struct cifsTconInfo * tcon)
                return NULL;
        }
        temp = (struct oplock_q_entry *) kmem_cache_alloc(cifs_oplock_cachep,
-                                                      SLAB_KERNEL);
+                                                      GFP_KERNEL);
        if (temp == NULL)
                return temp;
        else {
index 0102b28a15fb5f8230eea9904d04f481d3e4068c..0c6f7f3b3dd7c36d9ba646b08cac3dc02cbae81f 100644 (file)
@@ -441,7 +441,7 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry,
 /* file operations for directories */
 int coda_readdir(struct file *coda_file, void *dirent, filldir_t filldir)
 {
-       struct dentry *coda_dentry = coda_file->f_dentry;
+       struct dentry *coda_dentry = coda_file->f_path.dentry;
        struct coda_file_info *cfi;
        struct file *host_file;
        struct inode *host_inode;
@@ -453,7 +453,7 @@ int coda_readdir(struct file *coda_file, void *dirent, filldir_t filldir)
 
        coda_vfs_stat.readdir++;
 
-       host_inode = host_file->f_dentry->d_inode;
+       host_inode = host_file->f_path.dentry->d_inode;
        mutex_lock(&host_inode->i_mutex);
        host_file->f_pos = coda_file->f_pos;
 
@@ -544,14 +544,14 @@ static int coda_venus_readdir(struct file *filp, filldir_t filldir,
                /* catch truncated reads */
                if (ret < vdir_size || ret < vdir_size + vdir->d_namlen) {
                        printk("coda_venus_readdir: short read: %ld\n",
-                              filp->f_dentry->d_inode->i_ino);
+                              filp->f_path.dentry->d_inode->i_ino);
                        ret = -EBADF;
                        break;
                }
                /* validate whether the directory file actually makes sense */
                if (vdir->d_reclen < vdir_size + vdir->d_namlen) {
                        printk("coda_venus_readdir: Invalid dir: %ld\n",
-                              filp->f_dentry->d_inode->i_ino);
+                              filp->f_path.dentry->d_inode->i_ino);
                        ret = -EBADF;
                        break;
                }
index dbfbcfa5b3c064855f377949a9470bd6aab63a2e..5ef2b609ec7dd3164f3f70bfac44a281105f2691 100644 (file)
@@ -66,7 +66,7 @@ coda_file_sendfile(struct file *coda_file, loff_t *ppos, size_t count,
 static ssize_t
 coda_file_write(struct file *coda_file, const char __user *buf, size_t count, loff_t *ppos)
 {
-       struct inode *host_inode, *coda_inode = coda_file->f_dentry->d_inode;
+       struct inode *host_inode, *coda_inode = coda_file->f_path.dentry->d_inode;
        struct coda_file_info *cfi;
        struct file *host_file;
        ssize_t ret;
@@ -78,7 +78,7 @@ coda_file_write(struct file *coda_file, const char __user *buf, size_t count, lo
        if (!host_file->f_op || !host_file->f_op->write)
                return -EINVAL;
 
-       host_inode = host_file->f_dentry->d_inode;
+       host_inode = host_file->f_path.dentry->d_inode;
        mutex_lock(&coda_inode->i_mutex);
 
        ret = host_file->f_op->write(host_file, buf, count, ppos);
@@ -106,8 +106,8 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma)
        if (!host_file->f_op || !host_file->f_op->mmap)
                return -ENODEV;
 
-       coda_inode = coda_file->f_dentry->d_inode;
-       host_inode = host_file->f_dentry->d_inode;
+       coda_inode = coda_file->f_path.dentry->d_inode;
+       host_inode = host_file->f_path.dentry->d_inode;
        coda_file->f_mapping = host_file->f_mapping;
        if (coda_inode->i_mapping == &coda_inode->i_data)
                coda_inode->i_mapping = host_inode->i_mapping;
@@ -190,7 +190,7 @@ int coda_flush(struct file *coda_file, fl_owner_t id)
        cfi = CODA_FTOC(coda_file);
        BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
 
-       coda_inode = coda_file->f_dentry->d_inode;
+       coda_inode = coda_file->f_path.dentry->d_inode;
 
        err = venus_store(coda_inode->i_sb, coda_i2f(coda_inode), coda_flags,
                          coda_file->f_uid);
@@ -233,7 +233,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file)
                err = venus_close(coda_inode->i_sb, coda_i2f(coda_inode),
                                  coda_flags, coda_file->f_uid);
 
-       host_inode = cfi->cfi_container->f_dentry->d_inode;
+       host_inode = cfi->cfi_container->f_path.dentry->d_inode;
        cii = ITOC(coda_inode);
 
        /* did we mmap this file? */
@@ -270,7 +270,7 @@ int coda_fsync(struct file *coda_file, struct dentry *coda_dentry, int datasync)
        coda_vfs_stat.fsync++;
 
        if (host_file->f_op && host_file->f_op->fsync) {
-               host_dentry = host_file->f_dentry;
+               host_dentry = host_file->f_path.dentry;
                host_inode = host_dentry->d_inode;
                mutex_lock(&host_inode->i_mutex);
                err = host_file->f_op->fsync(host_file, host_dentry, datasync);
index 88d12332116489bd6dc2cb475dc8727cffe88a18..01395defed85becda2176a54dfc089721f80a266 100644 (file)
@@ -38,12 +38,12 @@ static void coda_clear_inode(struct inode *);
 static void coda_put_super(struct super_block *);
 static int coda_statfs(struct dentry *dentry, struct kstatfs *buf);
 
-static kmem_cache_t * coda_inode_cachep;
+static struct kmem_cache * coda_inode_cachep;
 
 static struct inode *coda_alloc_inode(struct super_block *sb)
 {
        struct coda_inode_info *ei;
-       ei = (struct coda_inode_info *)kmem_cache_alloc(coda_inode_cachep, SLAB_KERNEL);
+       ei = (struct coda_inode_info *)kmem_cache_alloc(coda_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        memset(&ei->c_fid, 0, sizeof(struct CodaFid));
@@ -58,7 +58,7 @@ static void coda_destroy_inode(struct inode *inode)
        kmem_cache_free(coda_inode_cachep, ITOC(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct coda_inode_info *ei = (struct coda_inode_info *) foo;
 
@@ -119,7 +119,7 @@ static int get_device_index(struct coda_mount_data *data)
        file = fget(data->fd);
        inode = NULL;
        if(file)
-               inode = file->f_dentry->d_inode;
+               inode = file->f_path.dentry->d_inode;
        
        if(!inode || !S_ISCHR(inode->i_mode) ||
           imajor(inode) != CODA_PSDEV_MAJOR) {
index 06dad665b88fce8f412dc10303a527fefeb2278a..b766964a625c6f8c4be2a194fddf286a969d13a2 100644 (file)
@@ -232,7 +232,7 @@ asmlinkage long compat_sys_fstatfs(unsigned int fd, struct compat_statfs __user
        file = fget(fd);
        if (!file)
                goto out;
-       error = vfs_statfs(file->f_dentry, &tmp);
+       error = vfs_statfs(file->f_path.dentry, &tmp);
        if (!error)
                error = put_compat_statfs(buf, &tmp);
        fput(file);
@@ -303,7 +303,7 @@ asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct c
        file = fget(fd);
        if (!file)
                goto out;
-       error = vfs_statfs(file->f_dentry, &tmp);
+       error = vfs_statfs(file->f_path.dentry, &tmp);
        if (!error)
                error = put_compat_statfs64(buf, &tmp);
        fput(file);
@@ -365,7 +365,7 @@ static void compat_ioctl_error(struct file *filp, unsigned int fd,
        /* find the name of the device. */
        path = (char *)__get_free_page(GFP_KERNEL);
        if (path) {
-               fn = d_path(filp->f_dentry, filp->f_vfsmnt, path, PAGE_SIZE);
+               fn = d_path(filp->f_path.dentry, filp->f_path.mnt, path, PAGE_SIZE);
                if (IS_ERR(fn))
                        fn = "?";
        }
@@ -416,7 +416,7 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
        case FIBMAP:
        case FIGETBSZ:
        case FIONREAD:
-               if (S_ISREG(filp->f_dentry->d_inode->i_mode))
+               if (S_ISREG(filp->f_path.dentry->d_inode->i_mode))
                        break;
                /*FALL THROUGH*/
 
@@ -438,7 +438,7 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
                        goto found_handler;
        }
 
-       if (S_ISSOCK(filp->f_dentry->d_inode->i_mode) &&
+       if (S_ISSOCK(filp->f_path.dentry->d_inode->i_mode) &&
            cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) {
                error = siocdevprivate_ioctl(fd, cmd, arg);
        } else {
@@ -871,7 +871,7 @@ asmlinkage long compat_sys_mount(char __user * dev_name, char __user * dir_name,
 
        retval = -EINVAL;
 
-       if (type_page) {
+       if (type_page && data_page) {
                if (!strcmp((char *)type_page, SMBFS_NAME)) {
                        do_smb_super_data_conv((void *)data_page);
                } else if (!strcmp((char *)type_page, NCPFS_NAME)) {
@@ -1144,7 +1144,9 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
        lastdirent = buf.previous;
        if (lastdirent) {
                typeof(lastdirent->d_off) d_off = file->f_pos;
-               __put_user_unaligned(d_off, &lastdirent->d_off);
+               error = -EFAULT;
+               if (__put_user_unaligned(d_off, &lastdirent->d_off))
+                       goto out_putf;
                error = count - buf.count;
        }
 
@@ -1257,7 +1259,7 @@ out:
        if (iov != iovstack)
                kfree(iov);
        if ((ret + (type == READ)) > 0) {
-               struct dentry *dentry = file->f_dentry;
+               struct dentry *dentry = file->f_path.dentry;
                if (type == READ)
                        fsnotify_access(dentry);
                else
@@ -1611,14 +1613,14 @@ int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
                nr &= ~1UL;
                while (nr) {
                        unsigned long h, l;
-                       __get_user(l, ufdset);
-                       __get_user(h, ufdset+1);
+                       if (__get_user(l, ufdset) || __get_user(h, ufdset+1))
+                               return -EFAULT;
                        ufdset += 2;
                        *fdset++ = h << 32 | l;
                        nr -= 2;
                }
-               if (odd)
-                       __get_user(*fdset, ufdset);
+               if (odd && __get_user(*fdset, ufdset))
+                       return -EFAULT;
        } else {
                /* Tricky, must clear full unsigned long in the
                 * kernel fdset at the end, this makes sure that
@@ -1630,14 +1632,14 @@ int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
 }
 
 static
-void compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
-                       unsigned long *fdset)
+int compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
+                     unsigned long *fdset)
 {
        unsigned long odd;
        nr = ROUND_UP(nr, __COMPAT_NFDBITS);
 
        if (!ufdset)
-               return;
+               return 0;
 
        odd = nr & 1UL;
        nr &= ~1UL;
@@ -1645,13 +1647,14 @@ void compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
                unsigned long h, l;
                l = *fdset++;
                h = l >> 32;
-               __put_user(l, ufdset);
-               __put_user(h, ufdset+1);
+               if (__put_user(l, ufdset) || __put_user(h, ufdset+1))
+                       return -EFAULT;
                ufdset += 2;
                nr -= 2;
        }
-       if (odd)
-               __put_user(*fdset, ufdset);
+       if (odd && __put_user(*fdset, ufdset))
+               return -EFAULT;
+       return 0;
 }
 
 
@@ -1726,10 +1729,10 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp,
                ret = 0;
        }
 
-       compat_set_fd_set(n, inp, fds.res_in);
-       compat_set_fd_set(n, outp, fds.res_out);
-       compat_set_fd_set(n, exp, fds.res_ex);
-
+       if (compat_set_fd_set(n, inp, fds.res_in) ||
+           compat_set_fd_set(n, outp, fds.res_out) ||
+           compat_set_fd_set(n, exp, fds.res_ex))
+               ret = -EFAULT;
 out:
        kfree(bits);
 out_nofds:
index a91f2628c981328e41a1b93a5b9c22cc7b0f913a..c81c958b3e1d00c4ad22909b43d1d084961aadd3 100644 (file)
@@ -211,8 +211,10 @@ static int do_video_stillpicture(unsigned int fd, unsigned int cmd, unsigned lon
        up_native =
                compat_alloc_user_space(sizeof(struct video_still_picture));
 
-       put_user(compat_ptr(fp), &up_native->iFrame);
-       put_user(size, &up_native->size);
+       err =  put_user(compat_ptr(fp), &up_native->iFrame);
+       err |= put_user(size, &up_native->size);
+       if (err)
+               return -EFAULT;
 
        err = sys_ioctl(fd, cmd, (unsigned long) up_native);
 
@@ -236,8 +238,10 @@ static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned
        err |= get_user(length, &up->length);
 
        up_native = compat_alloc_user_space(sizeof(struct video_spu_palette));
-       put_user(compat_ptr(palp), &up_native->palette);
-       put_user(length, &up_native->length);
+       err  = put_user(compat_ptr(palp), &up_native->palette);
+       err |= put_user(length, &up_native->length);
+       if (err)
+               return -EFAULT;
 
        err = sys_ioctl(fd, cmd, (unsigned long) up_native);
 
@@ -1173,7 +1177,7 @@ static int cdrom_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long ar
 static int vt_check(struct file *file)
 {
        struct tty_struct *tty;
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        
        if (file->f_op->ioctl != tty_ioctl)
                return -EINVAL;
@@ -2043,16 +2047,19 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
         struct serial_struct ss;
         mm_segment_t oldseg = get_fs();
         __u32 udata;
+       unsigned int base;
 
         if (cmd == TIOCSSERIAL) {
                 if (!access_ok(VERIFY_READ, ss32, sizeof(SS32)))
                         return -EFAULT;
                 if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base)))
                        return -EFAULT;
-                __get_user(udata, &ss32->iomem_base);
+                if (__get_user(udata, &ss32->iomem_base))
+                       return -EFAULT;
                 ss.iomem_base = compat_ptr(udata);
-                __get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift);
-                __get_user(ss.port_high, &ss32->port_high);
+                if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
+                   __get_user(ss.port_high, &ss32->port_high))
+                       return -EFAULT;
                 ss.iomap_base = 0UL;
         }
         set_fs(KERNEL_DS);
@@ -2063,12 +2070,12 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
                         return -EFAULT;
                 if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base)))
                        return -EFAULT;
-                __put_user((unsigned long)ss.iomem_base  >> 32 ?
-                            0xffffffff : (unsigned)(unsigned long)ss.iomem_base,
-                            &ss32->iomem_base);
-                __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift);
-                __put_user(ss.port_high, &ss32->port_high);
-
+               base = (unsigned long)ss.iomem_base  >> 32 ?
+                       0xffffffff : (unsigned)(unsigned long)ss.iomem_base;
+               if (__put_user(base, &ss32->iomem_base) ||
+                   __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
+                   __put_user(ss.port_high, &ss32->port_high))
+                       return -EFAULT;
         }
         return err;
 }
@@ -2397,6 +2404,7 @@ HANDLE_IOCTL(SIOCGIFMAP, dev_ifsioc)
 HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc)
 HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc)
 HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc)
+HANDLE_IOCTL(SIOCSIFHWBROADCAST, dev_ifsioc)
 
 /* ioctls used by appletalk ddp.c */
 HANDLE_IOCTL(SIOCATALKDIFADDR, dev_ifsioc)
index 3f4ff7a242b9ebf746bf93f1ea67beb0622d1cf4..f92cd303d2c9599a2837ee012814aabc15153891 100644 (file)
@@ -49,7 +49,7 @@ struct configfs_dirent {
 #define CONFIGFS_NOT_PINNED    (CONFIGFS_ITEM_ATTR)
 
 extern struct vfsmount * configfs_mount;
-extern kmem_cache_t *configfs_dir_cachep;
+extern struct kmem_cache *configfs_dir_cachep;
 
 extern int configfs_is_root(struct config_item *item);
 
index c398861f78a52fa72cd9cde3079c9f3593d033f5..1814ba446809ac79ea6ab911a60ac42d1e36d33d 100644 (file)
@@ -980,7 +980,7 @@ int configfs_rename_dir(struct config_item * item, const char *new_name)
 
 static int configfs_dir_open(struct inode *inode, struct file *file)
 {
-       struct dentry * dentry = file->f_dentry;
+       struct dentry * dentry = file->f_path.dentry;
        struct configfs_dirent * parent_sd = dentry->d_fsdata;
 
        mutex_lock(&dentry->d_inode->i_mutex);
@@ -993,7 +993,7 @@ static int configfs_dir_open(struct inode *inode, struct file *file)
 
 static int configfs_dir_close(struct inode *inode, struct file *file)
 {
-       struct dentry * dentry = file->f_dentry;
+       struct dentry * dentry = file->f_path.dentry;
        struct configfs_dirent * cursor = file->private_data;
 
        mutex_lock(&dentry->d_inode->i_mutex);
@@ -1013,7 +1013,7 @@ static inline unsigned char dt_type(struct configfs_dirent *sd)
 
 static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
 {
-       struct dentry *dentry = filp->f_dentry;
+       struct dentry *dentry = filp->f_path.dentry;
        struct configfs_dirent * parent_sd = dentry->d_fsdata;
        struct configfs_dirent *cursor = filp->private_data;
        struct list_head *p, *q = &cursor->s_sibling;
@@ -1070,7 +1070,7 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
 
 static loff_t configfs_dir_lseek(struct file * file, loff_t offset, int origin)
 {
-       struct dentry * dentry = file->f_dentry;
+       struct dentry * dentry = file->f_path.dentry;
 
        mutex_lock(&dentry->d_inode->i_mutex);
        switch (origin) {
@@ -1080,7 +1080,7 @@ static loff_t configfs_dir_lseek(struct file * file, loff_t offset, int origin)
                        if (offset >= 0)
                                break;
                default:
-                       mutex_unlock(&file->f_dentry->d_inode->i_mutex);
+                       mutex_unlock(&file->f_path.dentry->d_inode->i_mutex);
                        return -EINVAL;
        }
        if (offset != file->f_pos) {
index cf33fac68c840cccc21ac91c617064ac36f90097..2a7cb086e80cf611ed9e53c1aba9cedbe63476b6 100644 (file)
@@ -134,7 +134,7 @@ configfs_read_file(struct file *file, char __user *buf, size_t count, loff_t *pp
 
        down(&buffer->sem);
        if (buffer->needs_read_fill) {
-               if ((retval = fill_read_buffer(file->f_dentry,buffer)))
+               if ((retval = fill_read_buffer(file->f_path.dentry,buffer)))
                        goto out;
        }
        pr_debug("%s: count = %zd, ppos = %lld, buf = %s\n",
@@ -222,7 +222,7 @@ configfs_write_file(struct file *file, const char __user *buf, size_t count, lof
        down(&buffer->sem);
        len = fill_write_buffer(buffer, buf, count);
        if (len > 0)
-               len = flush_write_buffer(file->f_dentry, buffer, count);
+               len = flush_write_buffer(file->f_path.dentry, buffer, count);
        if (len > 0)
                *ppos += len;
        up(&buffer->sem);
@@ -231,8 +231,8 @@ configfs_write_file(struct file *file, const char __user *buf, size_t count, lof
 
 static int check_perm(struct inode * inode, struct file * file)
 {
-       struct config_item *item = configfs_get_config_item(file->f_dentry->d_parent);
-       struct configfs_attribute * attr = to_attr(file->f_dentry);
+       struct config_item *item = configfs_get_config_item(file->f_path.dentry->d_parent);
+       struct configfs_attribute * attr = to_attr(file->f_path.dentry);
        struct configfs_buffer * buffer;
        struct configfs_item_operations * ops = NULL;
        int error = 0;
@@ -305,8 +305,8 @@ static int configfs_open_file(struct inode * inode, struct file * filp)
 
 static int configfs_release(struct inode * inode, struct file * filp)
 {
-       struct config_item * item = to_item(filp->f_dentry->d_parent);
-       struct configfs_attribute * attr = to_attr(filp->f_dentry);
+       struct config_item * item = to_item(filp->f_path.dentry->d_parent);
+       struct configfs_attribute * attr = to_attr(filp->f_path.dentry);
        struct module * owner = attr->ca_owner;
        struct configfs_buffer * buffer = filp->private_data;
 
index 68bd5c93ca524a089d1881bbcb9b5da4ef563b74..ed678529ebb2a8b58fdc86c277e3eea83aca96c9 100644 (file)
@@ -38,7 +38,7 @@
 
 struct vfsmount * configfs_mount = NULL;
 struct super_block * configfs_sb = NULL;
-kmem_cache_t *configfs_dir_cachep;
+struct kmem_cache *configfs_dir_cachep;
 static int configfs_mnt_count = 0;
 
 static struct super_operations configfs_ops = {
index a624c3ec81892870545cd80bea3f22c91069c2ab..6db03fb089dcaa3fdd2dc43d1784e158e3ec4ea7 100644 (file)
@@ -338,7 +338,7 @@ static int cramfs_statfs(struct dentry *dentry, struct kstatfs *buf)
  */
 static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct super_block *sb = inode->i_sb;
        char *buf;
        unsigned int offset;
@@ -481,6 +481,8 @@ static int cramfs_readpage(struct file *file, struct page * page)
                pgdata = kmap(page);
                if (compr_len == 0)
                        ; /* hole */
+               else if (compr_len > (PAGE_CACHE_SIZE << 1))
+                       printk(KERN_ERR "cramfs: bad compressed blocksize %u\n", compr_len);
                else {
                        mutex_lock(&read_mutex);
                        bytes_filled = cramfs_uncompress_block(pgdata,
index fd4a428998efe1152c01129defec0691ac87a465..d68631f18df122824a0d36a307c647f15931c7bd 100644 (file)
@@ -43,7 +43,7 @@ static __cacheline_aligned_in_smp DEFINE_SEQLOCK(rename_lock);
 
 EXPORT_SYMBOL(dcache_lock);
 
-static kmem_cache_t *dentry_cache __read_mostly;
+static struct kmem_cache *dentry_cache __read_mostly;
 
 #define DNAME_INLINE_LEN (sizeof(struct dentry)-offsetof(struct dentry,d_iname))
 
@@ -68,15 +68,19 @@ struct dentry_stat_t dentry_stat = {
        .age_limit = 45,
 };
 
-static void d_callback(struct rcu_head *head)
+static void __d_free(struct dentry *dentry)
 {
-       struct dentry * dentry = container_of(head, struct dentry, d_u.d_rcu);
-
        if (dname_external(dentry))
                kfree(dentry->d_name.name);
        kmem_cache_free(dentry_cache, dentry); 
 }
 
+static void d_callback(struct rcu_head *head)
+{
+       struct dentry * dentry = container_of(head, struct dentry, d_u.d_rcu);
+       __d_free(dentry);
+}
+
 /*
  * no dcache_lock, please.  The caller must decrement dentry_stat.nr_dentry
  * inside dcache_lock.
@@ -85,7 +89,11 @@ static void d_free(struct dentry *dentry)
 {
        if (dentry->d_op && dentry->d_op->d_release)
                dentry->d_op->d_release(dentry);
-       call_rcu(&dentry->d_u.d_rcu, d_callback);
+       /* if dentry was never inserted into hash, immediate free is OK */
+       if (dentry->d_hash.pprev == NULL)
+               __d_free(dentry);
+       else
+               call_rcu(&dentry->d_u.d_rcu, d_callback);
 }
 
 /*
@@ -2072,10 +2080,10 @@ static void __init dcache_init(unsigned long mempages)
 }
 
 /* SLAB cache for __getname() consumers */
-kmem_cache_t *names_cachep __read_mostly;
+struct kmem_cache *names_cachep __read_mostly;
 
 /* SLAB cache for file structures */
-kmem_cache_t *filp_cachep __read_mostly;
+struct kmem_cache *filp_cachep __read_mostly;
 
 EXPORT_SYMBOL(d_genocide);
 
index 0c4b0674854bbe0a47506a00ea1b5ef4b2529e4d..21af1629f9bcc2ebd6eda9d701bb31b1e03feb49 100644 (file)
@@ -37,7 +37,7 @@ struct dcookie_struct {
 
 static LIST_HEAD(dcookie_users);
 static DEFINE_MUTEX(dcookie_mutex);
-static kmem_cache_t *dcookie_cache __read_mostly;
+static struct kmem_cache *dcookie_cache __read_mostly;
 static struct list_head *dcookie_hashtable __read_mostly;
 static size_t hash_size __read_mostly;
 
index 81b2c6465eeb26dd21f23746209162eee8169b22..b5654a284fef1283b1186d7e39dcc1e0b3426396 100644 (file)
@@ -1,14 +1,32 @@
 menu "Distributed Lock Manager"
-       depends on INET && IP_SCTP && EXPERIMENTAL
+       depends on EXPERIMENTAL && INET
 
 config DLM
        tristate "Distributed Lock Manager (DLM)"
        depends on IPV6 || IPV6=n
        select CONFIGFS_FS
+       select IP_SCTP if DLM_SCTP
        help
        A general purpose distributed lock manager for kernel or userspace
        applications.
 
+choice
+       prompt "Select DLM communications protocol"
+       depends on DLM
+       default DLM_TCP
+       help
+       The DLM Can use TCP or SCTP for it's network communications.
+       SCTP supports multi-homed operations whereas TCP doesn't.
+       However, SCTP seems to have stability problems at the moment.
+
+config DLM_TCP
+       bool "TCP/IP"
+
+config DLM_SCTP
+       bool "SCTP"
+
+endchoice
+
 config DLM_DEBUG
        bool "DLM debugging"
        depends on DLM
index 1832e0297f7d828b34b146bb5784dad2c33f3f7c..65388944eba0e8a5507842ffe23bcde8d0d39866 100644 (file)
@@ -4,7 +4,6 @@ dlm-y :=                        ast.o \
                                dir.o \
                                lock.o \
                                lockspace.o \
-                               lowcomms.o \
                                main.o \
                                member.o \
                                memory.o \
@@ -17,3 +16,6 @@ dlm-y :=                      ast.o \
                                util.o
 dlm-$(CONFIG_DLM_DEBUG) +=     debug_fs.o
 
+dlm-$(CONFIG_DLM_TCP)   += lowcomms-tcp.o
+
+dlm-$(CONFIG_DLM_SCTP)  += lowcomms-sctp.o
\ No newline at end of file
index 1e5cd67e1b7ad27c36c8fb9b243547272c41403b..1ee8195e6fc0c17a34fcd351b9248f64d5171025 100644 (file)
@@ -471,6 +471,7 @@ struct dlm_ls {
        char                    *ls_recover_buf;
        int                     ls_recover_nodeid; /* for debugging */
        uint64_t                ls_rcom_seq;
+       spinlock_t              ls_rcom_spin;
        struct list_head        ls_recover_list;
        spinlock_t              ls_recover_list_lock;
        int                     ls_recover_list_count;
@@ -488,7 +489,8 @@ struct dlm_ls {
 #define LSFL_RUNNING           1
 #define LSFL_RECOVERY_STOP     2
 #define LSFL_RCOM_READY                3
-#define LSFL_UEVENT_WAIT       4
+#define LSFL_RCOM_WAIT         4
+#define LSFL_UEVENT_WAIT       5
 
 /* much of this is just saving user space pointers associated with the
    lock that we pass back to the user lib with an ast */
index 3f2befa4797b9a983914dfc16b84c2f3bf852481..30878defaeb6d23a92378233d260f6cee082f7ea 100644 (file)
@@ -2372,6 +2372,7 @@ static int send_lookup_reply(struct dlm_ls *ls, struct dlm_message *ms_in,
 static void receive_flags(struct dlm_lkb *lkb, struct dlm_message *ms)
 {
        lkb->lkb_exflags = ms->m_exflags;
+       lkb->lkb_sbflags = ms->m_sbflags;
        lkb->lkb_flags = (lkb->lkb_flags & 0xFFFF0000) |
                         (ms->m_flags & 0x0000FFFF);
 }
@@ -3028,10 +3029,17 @@ int dlm_receive_message(struct dlm_header *hd, int nodeid, int recovery)
 
        while (1) {
                if (dlm_locking_stopped(ls)) {
-                       if (!recovery)
-                               dlm_add_requestqueue(ls, nodeid, hd);
-                       error = -EINTR;
-                       goto out;
+                       if (recovery) {
+                               error = -EINTR;
+                               goto out;
+                       }
+                       error = dlm_add_requestqueue(ls, nodeid, hd);
+                       if (error == -EAGAIN)
+                               continue;
+                       else {
+                               error = -EINTR;
+                               goto out;
+                       }
                }
 
                if (lock_recovery_try(ls))
index f8842ca443c24dda7e24344ee38a5a61e560acf3..59012b089e8d68ba77444a8ef0fd82f8743f5ca6 100644 (file)
@@ -22,6 +22,7 @@
 #include "memory.h"
 #include "lock.h"
 #include "recover.h"
+#include "requestqueue.h"
 
 #ifdef CONFIG_DLM_DEBUG
 int dlm_create_debug_file(struct dlm_ls *ls);
@@ -478,6 +479,8 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
        ls->ls_recoverd_task = NULL;
        mutex_init(&ls->ls_recoverd_active);
        spin_lock_init(&ls->ls_recover_lock);
+       spin_lock_init(&ls->ls_rcom_spin);
+       get_random_bytes(&ls->ls_rcom_seq, sizeof(uint64_t));
        ls->ls_recover_status = 0;
        ls->ls_recover_seq = 0;
        ls->ls_recover_args = NULL;
@@ -684,6 +687,7 @@ static int release_lockspace(struct dlm_ls *ls, int force)
         * Free structures on any other lists
         */
 
+       dlm_purge_requestqueue(ls);
        kfree(ls->ls_recover_args);
        dlm_clear_free_entries(ls);
        dlm_clear_members(ls);
similarity index 87%
rename from fs/dlm/lowcomms.c
rename to fs/dlm/lowcomms-sctp.c
index 6da6b14d5a61b40a83e904e6f56cc19d12865ad2..fe158d7a92853074da36daa33dcbcbabaae00ec7 100644 (file)
@@ -2,7 +2,7 @@
 *******************************************************************************
 **
 **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
-**  Copyright (C) 2004-2005 Red Hat, Inc.  All rights reserved.
+**  Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
 **
 **  This copyrighted material is made available to anyone wishing to use,
 **  modify, copy, or redistribute it subject to the terms and conditions
@@ -75,13 +75,13 @@ struct nodeinfo {
 };
 
 static DEFINE_IDR(nodeinfo_idr);
-static struct rw_semaphore     nodeinfo_lock;
-static int                     max_nodeid;
+static DECLARE_RWSEM(nodeinfo_lock);
+static int max_nodeid;
 
 struct cbuf {
-       unsigned                base;
-       unsigned                len;
-       unsigned                mask;
+       unsigned int base;
+       unsigned int len;
+       unsigned int mask;
 };
 
 /* Just the one of these, now. But this struct keeps
@@ -90,9 +90,9 @@ struct cbuf {
 #define CF_READ_PENDING 1
 
 struct connection {
-       struct socket          *sock;
+       struct socket           *sock;
        unsigned long           flags;
-       struct page            *rx_page;
+       struct page             *rx_page;
        atomic_t                waiting_requests;
        struct cbuf             cb;
        int                     eagain_flag;
@@ -102,36 +102,40 @@ struct connection {
 
 struct writequeue_entry {
        struct list_head        list;
-       struct page            *page;
+       struct page             *page;
        int                     offset;
        int                     len;
        int                     end;
        int                     users;
-       struct nodeinfo        *ni;
+       struct nodeinfo         *ni;
 };
 
-#define CBUF_ADD(cb, n) do { (cb)->len += n; } while(0)
-#define CBUF_EMPTY(cb) ((cb)->len == 0)
-#define CBUF_MAY_ADD(cb, n) (((cb)->len + (n)) < ((cb)->mask + 1))
-#define CBUF_DATA(cb) (((cb)->base + (cb)->len) & (cb)->mask)
+static void cbuf_add(struct cbuf *cb, int n)
+{
+       cb->len += n;
+}
 
-#define CBUF_INIT(cb, size) \
-do { \
-       (cb)->base = (cb)->len = 0; \
-       (cb)->mask = ((size)-1); \
-} while(0)
+static int cbuf_data(struct cbuf *cb)
+{
+       return ((cb->base + cb->len) & cb->mask);
+}
 
-#define CBUF_EAT(cb, n) \
-do { \
-       (cb)->len  -= (n); \
-       (cb)->base += (n); \
-       (cb)->base &= (cb)->mask; \
-} while(0)
+static void cbuf_init(struct cbuf *cb, int size)
+{
+       cb->base = cb->len = 0;
+       cb->mask = size-1;
+}
 
+static void cbuf_eat(struct cbuf *cb, int n)
+{
+       cb->len  -= n;
+       cb->base += n;
+       cb->base &= cb->mask;
+}
 
 /* List of nodes which have writes pending */
-static struct list_head write_nodes;
-static spinlock_t write_nodes_lock;
+static LIST_HEAD(write_nodes);
+static DEFINE_SPINLOCK(write_nodes_lock);
 
 /* Maximum number of incoming messages to process before
  * doing a schedule()
@@ -141,8 +145,7 @@ static spinlock_t write_nodes_lock;
 /* Manage daemons */
 static struct task_struct *recv_task;
 static struct task_struct *send_task;
-static wait_queue_head_t lowcomms_recv_wait;
-static atomic_t accepting;
+static DECLARE_WAIT_QUEUE_HEAD(lowcomms_recv_wait);
 
 /* The SCTP connection */
 static struct connection sctp_con;
@@ -161,11 +164,11 @@ static int nodeid_to_addr(int nodeid, struct sockaddr *retaddr)
                return error;
 
        if (dlm_local_addr[0]->ss_family == AF_INET) {
-               struct sockaddr_in *in4  = (struct sockaddr_in *) &addr;
+               struct sockaddr_in *in4  = (struct sockaddr_in *) &addr;
                struct sockaddr_in *ret4 = (struct sockaddr_in *) retaddr;
                ret4->sin_addr.s_addr = in4->sin_addr.s_addr;
        } else {
-               struct sockaddr_in6 *in6  = (struct sockaddr_in6 *) &addr;
+               struct sockaddr_in6 *in6  = (struct sockaddr_in6 *) &addr;
                struct sockaddr_in6 *ret6 = (struct sockaddr_in6 *) retaddr;
                memcpy(&ret6->sin6_addr, &in6->sin6_addr,
                       sizeof(in6->sin6_addr));
@@ -174,6 +177,8 @@ static int nodeid_to_addr(int nodeid, struct sockaddr *retaddr)
        return 0;
 }
 
+/* If alloc is 0 here we will not attempt to allocate a new
+   nodeinfo struct */
 static struct nodeinfo *nodeid2nodeinfo(int nodeid, gfp_t alloc)
 {
        struct nodeinfo *ni;
@@ -184,44 +189,45 @@ static struct nodeinfo *nodeid2nodeinfo(int nodeid, gfp_t alloc)
        ni = idr_find(&nodeinfo_idr, nodeid);
        up_read(&nodeinfo_lock);
 
-       if (!ni && alloc) {
-               down_write(&nodeinfo_lock);
+       if (ni || !alloc)
+               return ni;
 
-               ni = idr_find(&nodeinfo_idr, nodeid);
-               if (ni)
-                       goto out_up;
+       down_write(&nodeinfo_lock);
 
-               r = idr_pre_get(&nodeinfo_idr, alloc);
-               if (!r)
-                       goto out_up;
+       ni = idr_find(&nodeinfo_idr, nodeid);
+       if (ni)
+               goto out_up;
 
-               ni = kmalloc(sizeof(struct nodeinfo), alloc);
-               if (!ni)
-                       goto out_up;
+       r = idr_pre_get(&nodeinfo_idr, alloc);
+       if (!r)
+               goto out_up;
 
-               r = idr_get_new_above(&nodeinfo_idr, ni, nodeid, &n);
-               if (r) {
-                       kfree(ni);
-                       ni = NULL;
-                       goto out_up;
-               }
-               if (n != nodeid) {
-                       idr_remove(&nodeinfo_idr, n);
-                       kfree(ni);
-                       ni = NULL;
-                       goto out_up;
-               }
-               memset(ni, 0, sizeof(struct nodeinfo));
-               spin_lock_init(&ni->lock);
-               INIT_LIST_HEAD(&ni->writequeue);
-               spin_lock_init(&ni->writequeue_lock);
-               ni->nodeid = nodeid;
-
-               if (nodeid > max_nodeid)
-                       max_nodeid = nodeid;
-       out_up:
-               up_write(&nodeinfo_lock);
+       ni = kmalloc(sizeof(struct nodeinfo), alloc);
+       if (!ni)
+               goto out_up;
+
+       r = idr_get_new_above(&nodeinfo_idr, ni, nodeid, &n);
+       if (r) {
+               kfree(ni);
+               ni = NULL;
+               goto out_up;
        }
+       if (n != nodeid) {
+               idr_remove(&nodeinfo_idr, n);
+               kfree(ni);
+               ni = NULL;
+               goto out_up;
+       }
+       memset(ni, 0, sizeof(struct nodeinfo));
+       spin_lock_init(&ni->lock);
+       INIT_LIST_HEAD(&ni->writequeue);
+       spin_lock_init(&ni->writequeue_lock);
+       ni->nodeid = nodeid;
+
+       if (nodeid > max_nodeid)
+               max_nodeid = nodeid;
+out_up:
+       up_write(&nodeinfo_lock);
 
        return ni;
 }
@@ -279,13 +285,13 @@ static void make_sockaddr(struct sockaddr_storage *saddr, uint16_t port,
                in4_addr->sin_port = cpu_to_be16(port);
                memset(&in4_addr->sin_zero, 0, sizeof(in4_addr->sin_zero));
                memset(in4_addr+1, 0, sizeof(struct sockaddr_storage) -
-                                     sizeof(struct sockaddr_in));
+                      sizeof(struct sockaddr_in));
                *addr_len = sizeof(struct sockaddr_in);
        } else {
                struct sockaddr_in6 *in6_addr = (struct sockaddr_in6 *)saddr;
                in6_addr->sin6_port = cpu_to_be16(port);
                memset(in6_addr+1, 0, sizeof(struct sockaddr_storage) -
-                                     sizeof(struct sockaddr_in6));
+                      sizeof(struct sockaddr_in6));
                *addr_len = sizeof(struct sockaddr_in6);
        }
 }
@@ -324,7 +330,7 @@ static void send_shutdown(sctp_assoc_t associd)
        cmsg->cmsg_type = SCTP_SNDRCV;
        cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
        outmessage.msg_controllen = cmsg->cmsg_len;
-       sinfo = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg);
+       sinfo = CMSG_DATA(cmsg);
        memset(sinfo, 0x00, sizeof(struct sctp_sndrcvinfo));
 
        sinfo->sinfo_flags |= MSG_EOF;
@@ -387,7 +393,7 @@ static void process_sctp_notification(struct msghdr *msg, char *buf)
 
                        if ((int)sn->sn_assoc_change.sac_assoc_id <= 0) {
                                log_print("COMM_UP for invalid assoc ID %d",
-                                        (int)sn->sn_assoc_change.sac_assoc_id);
+                                         (int)sn->sn_assoc_change.sac_assoc_id);
                                init_failed();
                                return;
                        }
@@ -398,15 +404,18 @@ static void process_sctp_notification(struct msghdr *msg, char *buf)
                        fs = get_fs();
                        set_fs(get_ds());
                        ret = sctp_con.sock->ops->getsockopt(sctp_con.sock,
-                                               IPPROTO_SCTP, SCTP_PRIMARY_ADDR,
-                                               (char*)&prim, &prim_len);
+                                                            IPPROTO_SCTP,
+                                                            SCTP_PRIMARY_ADDR,
+                                                            (char*)&prim,
+                                                            &prim_len);
                        set_fs(fs);
                        if (ret < 0) {
                                struct nodeinfo *ni;
 
                                log_print("getsockopt/sctp_primary_addr on "
                                          "new assoc %d failed : %d",
-                                   (int)sn->sn_assoc_change.sac_assoc_id, ret);
+                                         (int)sn->sn_assoc_change.sac_assoc_id,
+                                         ret);
 
                                /* Retry INIT later */
                                ni = assoc2nodeinfo(sn->sn_assoc_change.sac_assoc_id);
@@ -426,12 +435,10 @@ static void process_sctp_notification(struct msghdr *msg, char *buf)
                                return;
 
                        /* Save the assoc ID */
-                       spin_lock(&ni->lock);
                        ni->assoc_id = sn->sn_assoc_change.sac_assoc_id;
-                       spin_unlock(&ni->lock);
 
                        log_print("got new/restarted association %d nodeid %d",
-                              (int)sn->sn_assoc_change.sac_assoc_id, nodeid);
+                                 (int)sn->sn_assoc_change.sac_assoc_id, nodeid);
 
                        /* Send any pending writes */
                        clear_bit(NI_INIT_PENDING, &ni->flags);
@@ -507,13 +514,12 @@ static int receive_from_sock(void)
                sctp_con.rx_page = alloc_page(GFP_ATOMIC);
                if (sctp_con.rx_page == NULL)
                        goto out_resched;
-               CBUF_INIT(&sctp_con.cb, PAGE_CACHE_SIZE);
+               cbuf_init(&sctp_con.cb, PAGE_CACHE_SIZE);
        }
 
        memset(&incmsg, 0, sizeof(incmsg));
        memset(&msgname, 0, sizeof(msgname));
 
-       memset(incmsg, 0, sizeof(incmsg));
        msg.msg_name = &msgname;
        msg.msg_namelen = sizeof(msgname);
        msg.msg_flags = 0;
@@ -532,17 +538,17 @@ static int receive_from_sock(void)
         * iov[0] is the bit of the circular buffer between the current end
         * point (cb.base + cb.len) and the end of the buffer.
         */
-       iov[0].iov_len = sctp_con.cb.base - CBUF_DATA(&sctp_con.cb);
+       iov[0].iov_len = sctp_con.cb.base - cbuf_data(&sctp_con.cb);
        iov[0].iov_base = page_address(sctp_con.rx_page) +
-                         CBUF_DATA(&sctp_con.cb);
+               cbuf_data(&sctp_con.cb);
        iov[1].iov_len = 0;
 
        /*
         * iov[1] is the bit of the circular buffer between the start of the
         * buffer and the start of the currently used section (cb.base)
         */
-       if (CBUF_DATA(&sctp_con.cb) >= sctp_con.cb.base) {
-               iov[0].iov_len = PAGE_CACHE_SIZE - CBUF_DATA(&sctp_con.cb);
+       if (cbuf_data(&sctp_con.cb) >= sctp_con.cb.base) {
+               iov[0].iov_len = PAGE_CACHE_SIZE - cbuf_data(&sctp_con.cb);
                iov[1].iov_len = sctp_con.cb.base;
                iov[1].iov_base = page_address(sctp_con.rx_page);
                msg.msg_iovlen = 2;
@@ -557,7 +563,7 @@ static int receive_from_sock(void)
        msg.msg_control = incmsg;
        msg.msg_controllen = sizeof(incmsg);
        cmsg = CMSG_FIRSTHDR(&msg);
-       sinfo = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg);
+       sinfo = CMSG_DATA(cmsg);
 
        if (msg.msg_flags & MSG_NOTIFICATION) {
                process_sctp_notification(&msg, page_address(sctp_con.rx_page));
@@ -583,29 +589,29 @@ static int receive_from_sock(void)
        if (r == 1)
                return 0;
 
-       CBUF_ADD(&sctp_con.cb, ret);
+       cbuf_add(&sctp_con.cb, ret);
        ret = dlm_process_incoming_buffer(cpu_to_le32(sinfo->sinfo_ppid),
                                          page_address(sctp_con.rx_page),
                                          sctp_con.cb.base, sctp_con.cb.len,
                                          PAGE_CACHE_SIZE);
        if (ret < 0)
                goto out_close;
-       CBUF_EAT(&sctp_con.cb, ret);
+       cbuf_eat(&sctp_con.cb, ret);
 
-      out:
+out:
        ret = 0;
        goto out_ret;
 
-      out_resched:
+out_resched:
        lowcomms_data_ready(sctp_con.sock->sk, 0);
        ret = 0;
-       schedule();
+       cond_resched();
        goto out_ret;
 
-      out_close:
+out_close:
        if (ret != -EAGAIN)
                log_print("error reading from sctp socket: %d", ret);
-      out_ret:
+out_ret:
        return ret;
 }
 
@@ -619,10 +625,12 @@ static int add_bind_addr(struct sockaddr_storage *addr, int addr_len, int num)
        set_fs(get_ds());
        if (num == 1)
                result = sctp_con.sock->ops->bind(sctp_con.sock,
-                                       (struct sockaddr *) addr, addr_len);
+                                                 (struct sockaddr *) addr,
+                                                 addr_len);
        else
                result = sctp_con.sock->ops->setsockopt(sctp_con.sock, SOL_SCTP,
-                               SCTP_SOCKOPT_BINDX_ADD, (char *)addr, addr_len);
+                                                       SCTP_SOCKOPT_BINDX_ADD,
+                                                       (char *)addr, addr_len);
        set_fs(fs);
 
        if (result < 0)
@@ -719,10 +727,10 @@ static int init_sock(void)
 
        return 0;
 
- create_delsock:
+create_delsock:
        sock_release(sock);
        sctp_con.sock = NULL;
- out:
+out:
        return result;
 }
 
@@ -756,16 +764,13 @@ void *dlm_lowcomms_get_buffer(int nodeid, int len, gfp_t allocation, char **ppc)
        int users = 0;
        struct nodeinfo *ni;
 
-       if (!atomic_read(&accepting))
-               return NULL;
-
        ni = nodeid2nodeinfo(nodeid, allocation);
        if (!ni)
                return NULL;
 
        spin_lock(&ni->writequeue_lock);
        e = list_entry(ni->writequeue.prev, struct writequeue_entry, list);
-       if (((struct list_head *) e == &ni->writequeue) ||
+       if ((&e->list == &ni->writequeue) ||
            (PAGE_CACHE_SIZE - e->end < len)) {
                e = NULL;
        } else {
@@ -776,7 +781,7 @@ void *dlm_lowcomms_get_buffer(int nodeid, int len, gfp_t allocation, char **ppc)
        spin_unlock(&ni->writequeue_lock);
 
        if (e) {
-             got_one:
+       got_one:
                if (users == 0)
                        kmap(e->page);
                *ppc = page_address(e->page) + offset;
@@ -803,9 +808,6 @@ void dlm_lowcomms_commit_buffer(void *arg)
        int users;
        struct nodeinfo *ni = e->ni;
 
-       if (!atomic_read(&accepting))
-               return;
-
        spin_lock(&ni->writequeue_lock);
        users = --e->users;
        if (users)
@@ -822,7 +824,7 @@ void dlm_lowcomms_commit_buffer(void *arg)
        }
        return;
 
-      out:
+out:
        spin_unlock(&ni->writequeue_lock);
        return;
 }
@@ -878,7 +880,7 @@ static void initiate_association(int nodeid)
        cmsg->cmsg_level = IPPROTO_SCTP;
        cmsg->cmsg_type = SCTP_SNDRCV;
        cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
-       sinfo = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg);
+       sinfo = CMSG_DATA(cmsg);
        memset(sinfo, 0x00, sizeof(struct sctp_sndrcvinfo));
        sinfo->sinfo_ppid = cpu_to_le32(dlm_local_nodeid);
 
@@ -892,7 +894,7 @@ static void initiate_association(int nodeid)
 }
 
 /* Send a message */
-static int send_to_sock(struct nodeinfo *ni)
+static void send_to_sock(struct nodeinfo *ni)
 {
        int ret = 0;
        struct writequeue_entry *e;
@@ -903,13 +905,13 @@ static int send_to_sock(struct nodeinfo *ni)
        struct sctp_sndrcvinfo *sinfo;
        struct kvec iov;
 
-        /* See if we need to init an association before we start
+       /* See if we need to init an association before we start
           sending precious messages */
        spin_lock(&ni->lock);
        if (!ni->assoc_id && !test_and_set_bit(NI_INIT_PENDING, &ni->flags)) {
                spin_unlock(&ni->lock);
                initiate_association(ni->nodeid);
-               return 0;
+               return;
        }
        spin_unlock(&ni->lock);
 
@@ -923,7 +925,7 @@ static int send_to_sock(struct nodeinfo *ni)
        cmsg->cmsg_level = IPPROTO_SCTP;
        cmsg->cmsg_type = SCTP_SNDRCV;
        cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
-       sinfo = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg);
+       sinfo = CMSG_DATA(cmsg);
        memset(sinfo, 0x00, sizeof(struct sctp_sndrcvinfo));
        sinfo->sinfo_ppid = cpu_to_le32(dlm_local_nodeid);
        sinfo->sinfo_assoc_id = ni->assoc_id;
@@ -955,7 +957,7 @@ static int send_to_sock(struct nodeinfo *ni)
                                goto send_error;
                } else {
                        /* Don't starve people filling buffers */
-                       schedule();
+                       cond_resched();
                }
 
                spin_lock(&ni->writequeue_lock);
@@ -964,15 +966,16 @@ static int send_to_sock(struct nodeinfo *ni)
 
                if (e->len == 0 && e->users == 0) {
                        list_del(&e->list);
+                       kunmap(e->page);
                        free_entry(e);
                        continue;
                }
        }
        spin_unlock(&ni->writequeue_lock);
- out:
-       return ret;
+out:
+       return;
 
- send_error:
+send_error:
        log_print("Error sending to node %d %d", ni->nodeid, ret);
        spin_lock(&ni->lock);
        if (!test_and_set_bit(NI_INIT_PENDING, &ni->flags)) {
@@ -982,7 +985,7 @@ static int send_to_sock(struct nodeinfo *ni)
        } else
                spin_unlock(&ni->lock);
 
-       return ret;
+       return;
 }
 
 /* Try to send any messages that are pending */
@@ -994,7 +997,7 @@ static void process_output_queue(void)
        spin_lock_bh(&write_nodes_lock);
        list_for_each_safe(list, temp, &write_nodes) {
                struct nodeinfo *ni =
-                   list_entry(list, struct nodeinfo, write_list);
+                       list_entry(list, struct nodeinfo, write_list);
                clear_bit(NI_WRITE_PENDING, &ni->flags);
                list_del(&ni->write_list);
 
@@ -1106,7 +1109,7 @@ static int dlm_recvd(void *data)
                set_current_state(TASK_INTERRUPTIBLE);
                add_wait_queue(&lowcomms_recv_wait, &wait);
                if (!test_bit(CF_READ_PENDING, &sctp_con.flags))
-                       schedule();
+                       cond_resched();
                remove_wait_queue(&lowcomms_recv_wait, &wait);
                set_current_state(TASK_RUNNING);
 
@@ -1118,12 +1121,12 @@ static int dlm_recvd(void *data)
 
                                /* Don't starve out everyone else */
                                if (++count >= MAX_RX_MSG_COUNT) {
-                                       schedule();
+                                       cond_resched();
                                        count = 0;
                                }
                        } while (!kthread_should_stop() && ret >=0);
                }
-               schedule();
+               cond_resched();
        }
 
        return 0;
@@ -1138,7 +1141,7 @@ static int dlm_sendd(void *data)
        while (!kthread_should_stop()) {
                set_current_state(TASK_INTERRUPTIBLE);
                if (write_list_empty())
-                       schedule();
+                       cond_resched();
                set_current_state(TASK_RUNNING);
 
                if (sctp_con.eagain_flag) {
@@ -1166,7 +1169,7 @@ static int daemons_start(void)
 
        p = kthread_run(dlm_recvd, NULL, "dlm_recvd");
        error = IS_ERR(p);
-               if (error) {
+       if (error) {
                log_print("can't start dlm_recvd %d", error);
                return error;
        }
@@ -1174,7 +1177,7 @@ static int daemons_start(void)
 
        p = kthread_run(dlm_sendd, NULL, "dlm_sendd");
        error = IS_ERR(p);
-               if (error) {
+       if (error) {
                log_print("can't start dlm_sendd %d", error);
                kthread_stop(recv_task);
                return error;
@@ -1197,43 +1200,28 @@ int dlm_lowcomms_start(void)
        error = daemons_start();
        if (error)
                goto fail_sock;
-       atomic_set(&accepting, 1);
        return 0;
 
- fail_sock:
+fail_sock:
        close_connection();
        return error;
 }
 
-/* Set all the activity flags to prevent any socket activity. */
-
 void dlm_lowcomms_stop(void)
 {
-       atomic_set(&accepting, 0);
+       int i;
+
        sctp_con.flags = 0x7;
        daemons_stop();
        clean_writequeues();
        close_connection();
        dealloc_nodeinfo();
        max_nodeid = 0;
-}
 
-int dlm_lowcomms_init(void)
-{
-       init_waitqueue_head(&lowcomms_recv_wait);
-       spin_lock_init(&write_nodes_lock);
-       INIT_LIST_HEAD(&write_nodes);
-       init_rwsem(&nodeinfo_lock);
-       return 0;
-}
-
-void dlm_lowcomms_exit(void)
-{
-       int i;
+       dlm_local_count = 0;
+       dlm_local_nodeid = 0;
 
        for (i = 0; i < dlm_local_count; i++)
                kfree(dlm_local_addr[i]);
-       dlm_local_count = 0;
-       dlm_local_nodeid = 0;
 }
 
diff --git a/fs/dlm/lowcomms-tcp.c b/fs/dlm/lowcomms-tcp.c
new file mode 100644 (file)
index 0000000..8f2791f
--- /dev/null
@@ -0,0 +1,1189 @@
+/******************************************************************************
+*******************************************************************************
+**
+**  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
+**  Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
+**
+**  This copyrighted material is made available to anyone wishing to use,
+**  modify, copy, or redistribute it subject to the terms and conditions
+**  of the GNU General Public License v.2.
+**
+*******************************************************************************
+******************************************************************************/
+
+/*
+ * lowcomms.c
+ *
+ * This is the "low-level" comms layer.
+ *
+ * It is responsible for sending/receiving messages
+ * from other nodes in the cluster.
+ *
+ * Cluster nodes are referred to by their nodeids. nodeids are
+ * simply 32 bit numbers to the locking module - if they need to
+ * be expanded for the cluster infrastructure then that is it's
+ * responsibility. It is this layer's
+ * responsibility to resolve these into IP address or
+ * whatever it needs for inter-node communication.
+ *
+ * The comms level is two kernel threads that deal mainly with
+ * the receiving of messages from other nodes and passing them
+ * up to the mid-level comms layer (which understands the
+ * message format) for execution by the locking core, and
+ * a send thread which does all the setting up of connections
+ * to remote nodes and the sending of data. Threads are not allowed
+ * to send their own data because it may cause them to wait in times
+ * of high load. Also, this way, the sending thread can collect together
+ * messages bound for one node and send them in one block.
+ *
+ * I don't see any problem with the recv thread executing the locking
+ * code on behalf of remote processes as the locking code is
+ * short, efficient and never waits.
+ *
+ */
+
+
+#include <asm/ioctls.h>
+#include <net/sock.h>
+#include <net/tcp.h>
+#include <linux/pagemap.h>
+
+#include "dlm_internal.h"
+#include "lowcomms.h"
+#include "midcomms.h"
+#include "config.h"
+
+struct cbuf {
+       unsigned int base;
+       unsigned int len;
+       unsigned int mask;
+};
+
+#define NODE_INCREMENT 32
+static void cbuf_add(struct cbuf *cb, int n)
+{
+       cb->len += n;
+}
+
+static int cbuf_data(struct cbuf *cb)
+{
+       return ((cb->base + cb->len) & cb->mask);
+}
+
+static void cbuf_init(struct cbuf *cb, int size)
+{
+       cb->base = cb->len = 0;
+       cb->mask = size-1;
+}
+
+static void cbuf_eat(struct cbuf *cb, int n)
+{
+       cb->len  -= n;
+       cb->base += n;
+       cb->base &= cb->mask;
+}
+
+static bool cbuf_empty(struct cbuf *cb)
+{
+       return cb->len == 0;
+}
+
+/* Maximum number of incoming messages to process before
+   doing a cond_resched()
+*/
+#define MAX_RX_MSG_COUNT 25
+
+struct connection {
+       struct socket *sock;    /* NULL if not connected */
+       uint32_t nodeid;        /* So we know who we are in the list */
+       struct rw_semaphore sock_sem; /* Stop connect races */
+       struct list_head read_list;   /* On this list when ready for reading */
+       struct list_head write_list;  /* On this list when ready for writing */
+       struct list_head state_list;  /* On this list when ready to connect */
+       unsigned long flags;    /* bit 1,2 = We are on the read/write lists */
+#define CF_READ_PENDING 1
+#define CF_WRITE_PENDING 2
+#define CF_CONNECT_PENDING 3
+#define CF_IS_OTHERCON 4
+       struct list_head writequeue;  /* List of outgoing writequeue_entries */
+       struct list_head listenlist;  /* List of allocated listening sockets */
+       spinlock_t writequeue_lock;
+       int (*rx_action) (struct connection *); /* What to do when active */
+       struct page *rx_page;
+       struct cbuf cb;
+       int retries;
+       atomic_t waiting_requests;
+#define MAX_CONNECT_RETRIES 3
+       struct connection *othercon;
+};
+#define sock2con(x) ((struct connection *)(x)->sk_user_data)
+
+/* An entry waiting to be sent */
+struct writequeue_entry {
+       struct list_head list;
+       struct page *page;
+       int offset;
+       int len;
+       int end;
+       int users;
+       struct connection *con;
+};
+
+static struct sockaddr_storage dlm_local_addr;
+
+/* Manage daemons */
+static struct task_struct *recv_task;
+static struct task_struct *send_task;
+
+static wait_queue_t lowcomms_send_waitq_head;
+static DECLARE_WAIT_QUEUE_HEAD(lowcomms_send_waitq);
+static wait_queue_t lowcomms_recv_waitq_head;
+static DECLARE_WAIT_QUEUE_HEAD(lowcomms_recv_waitq);
+
+/* An array of pointers to connections, indexed by NODEID */
+static struct connection **connections;
+static DECLARE_MUTEX(connections_lock);
+static kmem_cache_t *con_cache;
+static int conn_array_size;
+
+/* List of sockets that have reads pending */
+static LIST_HEAD(read_sockets);
+static DEFINE_SPINLOCK(read_sockets_lock);
+
+/* List of sockets which have writes pending */
+static LIST_HEAD(write_sockets);
+static DEFINE_SPINLOCK(write_sockets_lock);
+
+/* List of sockets which have connects pending */
+static LIST_HEAD(state_sockets);
+static DEFINE_SPINLOCK(state_sockets_lock);
+
+static struct connection *nodeid2con(int nodeid, gfp_t allocation)
+{
+       struct connection *con = NULL;
+
+       down(&connections_lock);
+       if (nodeid >= conn_array_size) {
+               int new_size = nodeid + NODE_INCREMENT;
+               struct connection **new_conns;
+
+               new_conns = kzalloc(sizeof(struct connection *) *
+                                   new_size, allocation);
+               if (!new_conns)
+                       goto finish;
+
+               memcpy(new_conns, connections,  sizeof(struct connection *) * conn_array_size);
+               conn_array_size = new_size;
+               kfree(connections);
+               connections = new_conns;
+
+       }
+
+       con = connections[nodeid];
+       if (con == NULL && allocation) {
+               con = kmem_cache_zalloc(con_cache, allocation);
+               if (!con)
+                       goto finish;
+
+               con->nodeid = nodeid;
+               init_rwsem(&con->sock_sem);
+               INIT_LIST_HEAD(&con->writequeue);
+               spin_lock_init(&con->writequeue_lock);
+
+               connections[nodeid] = con;
+       }
+
+finish:
+       up(&connections_lock);
+       return con;
+}
+
+/* Data available on socket or listen socket received a connect */
+static void lowcomms_data_ready(struct sock *sk, int count_unused)
+{
+       struct connection *con = sock2con(sk);
+
+       atomic_inc(&con->waiting_requests);
+       if (test_and_set_bit(CF_READ_PENDING, &con->flags))
+               return;
+
+       spin_lock_bh(&read_sockets_lock);
+       list_add_tail(&con->read_list, &read_sockets);
+       spin_unlock_bh(&read_sockets_lock);
+
+       wake_up_interruptible(&lowcomms_recv_waitq);
+}
+
+static void lowcomms_write_space(struct sock *sk)
+{
+       struct connection *con = sock2con(sk);
+
+       if (test_and_set_bit(CF_WRITE_PENDING, &con->flags))
+               return;
+
+       spin_lock_bh(&write_sockets_lock);
+       list_add_tail(&con->write_list, &write_sockets);
+       spin_unlock_bh(&write_sockets_lock);
+
+       wake_up_interruptible(&lowcomms_send_waitq);
+}
+
+static inline void lowcomms_connect_sock(struct connection *con)
+{
+       if (test_and_set_bit(CF_CONNECT_PENDING, &con->flags))
+               return;
+
+       spin_lock_bh(&state_sockets_lock);
+       list_add_tail(&con->state_list, &state_sockets);
+       spin_unlock_bh(&state_sockets_lock);
+
+       wake_up_interruptible(&lowcomms_send_waitq);
+}
+
+static void lowcomms_state_change(struct sock *sk)
+{
+       if (sk->sk_state == TCP_ESTABLISHED)
+               lowcomms_write_space(sk);
+}
+
+/* Make a socket active */
+static int add_sock(struct socket *sock, struct connection *con)
+{
+       con->sock = sock;
+
+       /* Install a data_ready callback */
+       con->sock->sk->sk_data_ready = lowcomms_data_ready;
+       con->sock->sk->sk_write_space = lowcomms_write_space;
+       con->sock->sk->sk_state_change = lowcomms_state_change;
+
+       return 0;
+}
+
+/* Add the port number to an IP6 or 4 sockaddr and return the address
+   length */
+static void make_sockaddr(struct sockaddr_storage *saddr, uint16_t port,
+                         int *addr_len)
+{
+       saddr->ss_family =  dlm_local_addr.ss_family;
+       if (saddr->ss_family == AF_INET) {
+               struct sockaddr_in *in4_addr = (struct sockaddr_in *)saddr;
+               in4_addr->sin_port = cpu_to_be16(port);
+               *addr_len = sizeof(struct sockaddr_in);
+       } else {
+               struct sockaddr_in6 *in6_addr = (struct sockaddr_in6 *)saddr;
+               in6_addr->sin6_port = cpu_to_be16(port);
+               *addr_len = sizeof(struct sockaddr_in6);
+       }
+}
+
+/* Close a remote connection and tidy up */
+static void close_connection(struct connection *con, bool and_other)
+{
+       down_write(&con->sock_sem);
+
+       if (con->sock) {
+               sock_release(con->sock);
+               con->sock = NULL;
+       }
+       if (con->othercon && and_other) {
+               /* Will only re-enter once. */
+               close_connection(con->othercon, false);
+       }
+       if (con->rx_page) {
+               __free_page(con->rx_page);
+               con->rx_page = NULL;
+       }
+       con->retries = 0;
+       up_write(&con->sock_sem);
+}
+
+/* Data received from remote end */
+static int receive_from_sock(struct connection *con)
+{
+       int ret = 0;
+       struct msghdr msg;
+       struct iovec iov[2];
+       mm_segment_t fs;
+       unsigned len;
+       int r;
+       int call_again_soon = 0;
+
+       down_read(&con->sock_sem);
+
+       if (con->sock == NULL)
+               goto out;
+       if (con->rx_page == NULL) {
+               /*
+                * This doesn't need to be atomic, but I think it should
+                * improve performance if it is.
+                */
+               con->rx_page = alloc_page(GFP_ATOMIC);
+               if (con->rx_page == NULL)
+                       goto out_resched;
+               cbuf_init(&con->cb, PAGE_CACHE_SIZE);
+       }
+
+       msg.msg_control = NULL;
+       msg.msg_controllen = 0;
+       msg.msg_iovlen = 1;
+       msg.msg_iov = iov;
+       msg.msg_name = NULL;
+       msg.msg_namelen = 0;
+       msg.msg_flags = 0;
+
+       /*
+        * iov[0] is the bit of the circular buffer between the current end
+        * point (cb.base + cb.len) and the end of the buffer.
+        */
+       iov[0].iov_len = con->cb.base - cbuf_data(&con->cb);
+       iov[0].iov_base = page_address(con->rx_page) + cbuf_data(&con->cb);
+       iov[1].iov_len = 0;
+
+       /*
+        * iov[1] is the bit of the circular buffer between the start of the
+        * buffer and the start of the currently used section (cb.base)
+        */
+       if (cbuf_data(&con->cb) >= con->cb.base) {
+               iov[0].iov_len = PAGE_CACHE_SIZE - cbuf_data(&con->cb);
+               iov[1].iov_len = con->cb.base;
+               iov[1].iov_base = page_address(con->rx_page);
+               msg.msg_iovlen = 2;
+       }
+       len = iov[0].iov_len + iov[1].iov_len;
+
+       fs = get_fs();
+       set_fs(get_ds());
+       r = ret = sock_recvmsg(con->sock, &msg, len,
+                              MSG_DONTWAIT | MSG_NOSIGNAL);
+       set_fs(fs);
+
+       if (ret <= 0)
+               goto out_close;
+       if (ret == len)
+               call_again_soon = 1;
+       cbuf_add(&con->cb, ret);
+       ret = dlm_process_incoming_buffer(con->nodeid,
+                                         page_address(con->rx_page),
+                                         con->cb.base, con->cb.len,
+                                         PAGE_CACHE_SIZE);
+       if (ret == -EBADMSG) {
+               printk(KERN_INFO "dlm: lowcomms: addr=%p, base=%u, len=%u, "
+                      "iov_len=%u, iov_base[0]=%p, read=%d\n",
+                      page_address(con->rx_page), con->cb.base, con->cb.len,
+                      len, iov[0].iov_base, r);
+       }
+       if (ret < 0)
+               goto out_close;
+       cbuf_eat(&con->cb, ret);
+
+       if (cbuf_empty(&con->cb) && !call_again_soon) {
+               __free_page(con->rx_page);
+               con->rx_page = NULL;
+       }
+
+out:
+       if (call_again_soon)
+               goto out_resched;
+       up_read(&con->sock_sem);
+       return 0;
+
+out_resched:
+       lowcomms_data_ready(con->sock->sk, 0);
+       up_read(&con->sock_sem);
+       cond_resched();
+       return 0;
+
+out_close:
+       up_read(&con->sock_sem);
+       if (ret != -EAGAIN && !test_bit(CF_IS_OTHERCON, &con->flags)) {
+               close_connection(con, false);
+               /* Reconnect when there is something to send */
+       }
+
+       return ret;
+}
+
+/* Listening socket is busy, accept a connection */
+static int accept_from_sock(struct connection *con)
+{
+       int result;
+       struct sockaddr_storage peeraddr;
+       struct socket *newsock;
+       int len;
+       int nodeid;
+       struct connection *newcon;
+
+       memset(&peeraddr, 0, sizeof(peeraddr));
+       result = sock_create_kern(dlm_local_addr.ss_family, SOCK_STREAM,
+                                 IPPROTO_TCP, &newsock);
+       if (result < 0)
+               return -ENOMEM;
+
+       down_read(&con->sock_sem);
+
+       result = -ENOTCONN;
+       if (con->sock == NULL)
+               goto accept_err;
+
+       newsock->type = con->sock->type;
+       newsock->ops = con->sock->ops;
+
+       result = con->sock->ops->accept(con->sock, newsock, O_NONBLOCK);
+       if (result < 0)
+               goto accept_err;
+
+       /* Get the connected socket's peer */
+       memset(&peeraddr, 0, sizeof(peeraddr));
+       if (newsock->ops->getname(newsock, (struct sockaddr *)&peeraddr,
+                                 &len, 2)) {
+               result = -ECONNABORTED;
+               goto accept_err;
+       }
+
+       /* Get the new node's NODEID */
+       make_sockaddr(&peeraddr, 0, &len);
+       if (dlm_addr_to_nodeid(&peeraddr, &nodeid)) {
+               printk("dlm: connect from non cluster node\n");
+               sock_release(newsock);
+               up_read(&con->sock_sem);
+               return -1;
+       }
+
+       log_print("got connection from %d", nodeid);
+
+       /*  Check to see if we already have a connection to this node. This
+        *  could happen if the two nodes initiate a connection at roughly
+        *  the same time and the connections cross on the wire.
+        * TEMPORARY FIX:
+        *  In this case we store the incoming one in "othercon"
+        */
+       newcon = nodeid2con(nodeid, GFP_KERNEL);
+       if (!newcon) {
+               result = -ENOMEM;
+               goto accept_err;
+       }
+       down_write(&newcon->sock_sem);
+       if (newcon->sock) {
+               struct connection *othercon = newcon->othercon;
+
+               if (!othercon) {
+                       othercon = kmem_cache_zalloc(con_cache, GFP_KERNEL);
+                       if (!othercon) {
+                               printk("dlm: failed to allocate incoming socket\n");
+                               up_write(&newcon->sock_sem);
+                               result = -ENOMEM;
+                               goto accept_err;
+                       }
+                       othercon->nodeid = nodeid;
+                       othercon->rx_action = receive_from_sock;
+                       init_rwsem(&othercon->sock_sem);
+                       set_bit(CF_IS_OTHERCON, &othercon->flags);
+                       newcon->othercon = othercon;
+               }
+               othercon->sock = newsock;
+               newsock->sk->sk_user_data = othercon;
+               add_sock(newsock, othercon);
+       }
+       else {
+               newsock->sk->sk_user_data = newcon;
+               newcon->rx_action = receive_from_sock;
+               add_sock(newsock, newcon);
+
+       }
+
+       up_write(&newcon->sock_sem);
+
+       /*
+        * Add it to the active queue in case we got data
+        * beween processing the accept adding the socket
+        * to the read_sockets list
+        */
+       lowcomms_data_ready(newsock->sk, 0);
+       up_read(&con->sock_sem);
+
+       return 0;
+
+accept_err:
+       up_read(&con->sock_sem);
+       sock_release(newsock);
+
+       if (result != -EAGAIN)
+               printk("dlm: error accepting connection from node: %d\n", result);
+       return result;
+}
+
+/* Connect a new socket to its peer */
+static void connect_to_sock(struct connection *con)
+{
+       int result = -EHOSTUNREACH;
+       struct sockaddr_storage saddr;
+       int addr_len;
+       struct socket *sock;
+
+       if (con->nodeid == 0) {
+               log_print("attempt to connect sock 0 foiled");
+               return;
+       }
+
+       down_write(&con->sock_sem);
+       if (con->retries++ > MAX_CONNECT_RETRIES)
+               goto out;
+
+       /* Some odd races can cause double-connects, ignore them */
+       if (con->sock) {
+               result = 0;
+               goto out;
+       }
+
+       /* Create a socket to communicate with */
+       result = sock_create_kern(dlm_local_addr.ss_family, SOCK_STREAM,
+                                 IPPROTO_TCP, &sock);
+       if (result < 0)
+               goto out_err;
+
+       memset(&saddr, 0, sizeof(saddr));
+       if (dlm_nodeid_to_addr(con->nodeid, &saddr))
+               goto out_err;
+
+       sock->sk->sk_user_data = con;
+       con->rx_action = receive_from_sock;
+
+       make_sockaddr(&saddr, dlm_config.tcp_port, &addr_len);
+
+       add_sock(sock, con);
+
+       log_print("connecting to %d", con->nodeid);
+       result =
+               sock->ops->connect(sock, (struct sockaddr *)&saddr, addr_len,
+                                  O_NONBLOCK);
+       if (result == -EINPROGRESS)
+               result = 0;
+       if (result == 0)
+               goto out;
+
+out_err:
+       if (con->sock) {
+               sock_release(con->sock);
+               con->sock = NULL;
+       }
+       /*
+        * Some errors are fatal and this list might need adjusting. For other
+        * errors we try again until the max number of retries is reached.
+        */
+       if (result != -EHOSTUNREACH && result != -ENETUNREACH &&
+           result != -ENETDOWN && result != EINVAL
+           && result != -EPROTONOSUPPORT) {
+               lowcomms_connect_sock(con);
+               result = 0;
+       }
+out:
+       up_write(&con->sock_sem);
+       return;
+}
+
+static struct socket *create_listen_sock(struct connection *con,
+                                        struct sockaddr_storage *saddr)
+{
+       struct socket *sock = NULL;
+       mm_segment_t fs;
+       int result = 0;
+       int one = 1;
+       int addr_len;
+
+       if (dlm_local_addr.ss_family == AF_INET)
+               addr_len = sizeof(struct sockaddr_in);
+       else
+               addr_len = sizeof(struct sockaddr_in6);
+
+       /* Create a socket to communicate with */
+       result = sock_create_kern(dlm_local_addr.ss_family, SOCK_STREAM, IPPROTO_TCP, &sock);
+       if (result < 0) {
+               printk("dlm: Can't create listening comms socket\n");
+               goto create_out;
+       }
+
+       fs = get_fs();
+       set_fs(get_ds());
+       result = sock_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
+                                (char *)&one, sizeof(one));
+       set_fs(fs);
+       if (result < 0) {
+               printk("dlm: Failed to set SO_REUSEADDR on socket: result=%d\n",
+                      result);
+       }
+       sock->sk->sk_user_data = con;
+       con->rx_action = accept_from_sock;
+       con->sock = sock;
+
+       /* Bind to our port */
+       make_sockaddr(saddr, dlm_config.tcp_port, &addr_len);
+       result = sock->ops->bind(sock, (struct sockaddr *) saddr, addr_len);
+       if (result < 0) {
+               printk("dlm: Can't bind to port %d\n", dlm_config.tcp_port);
+               sock_release(sock);
+               sock = NULL;
+               con->sock = NULL;
+               goto create_out;
+       }
+
+       fs = get_fs();
+       set_fs(get_ds());
+
+       result = sock_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
+                                (char *)&one, sizeof(one));
+       set_fs(fs);
+       if (result < 0) {
+               printk("dlm: Set keepalive failed: %d\n", result);
+       }
+
+       result = sock->ops->listen(sock, 5);
+       if (result < 0) {
+               printk("dlm: Can't listen on port %d\n", dlm_config.tcp_port);
+               sock_release(sock);
+               sock = NULL;
+               goto create_out;
+       }
+
+create_out:
+       return sock;
+}
+
+
+/* Listen on all interfaces */
+static int listen_for_all(void)
+{
+       struct socket *sock = NULL;
+       struct connection *con = nodeid2con(0, GFP_KERNEL);
+       int result = -EINVAL;
+
+       /* We don't support multi-homed hosts */
+       set_bit(CF_IS_OTHERCON, &con->flags);
+
+       sock = create_listen_sock(con, &dlm_local_addr);
+       if (sock) {
+               add_sock(sock, con);
+               result = 0;
+       }
+       else {
+               result = -EADDRINUSE;
+       }
+
+       return result;
+}
+
+
+
+static struct writequeue_entry *new_writequeue_entry(struct connection *con,
+                                                    gfp_t allocation)
+{
+       struct writequeue_entry *entry;
+
+       entry = kmalloc(sizeof(struct writequeue_entry), allocation);
+       if (!entry)
+               return NULL;
+
+       entry->page = alloc_page(allocation);
+       if (!entry->page) {
+               kfree(entry);
+               return NULL;
+       }
+
+       entry->offset = 0;
+       entry->len = 0;
+       entry->end = 0;
+       entry->users = 0;
+       entry->con = con;
+
+       return entry;
+}
+
+void *dlm_lowcomms_get_buffer(int nodeid, int len,
+                             gfp_t allocation, char **ppc)
+{
+       struct connection *con;
+       struct writequeue_entry *e;
+       int offset = 0;
+       int users = 0;
+
+       con = nodeid2con(nodeid, allocation);
+       if (!con)
+               return NULL;
+
+       e = list_entry(con->writequeue.prev, struct writequeue_entry, list);
+       if ((&e->list == &con->writequeue) ||
+           (PAGE_CACHE_SIZE - e->end < len)) {
+               e = NULL;
+       } else {
+               offset = e->end;
+               e->end += len;
+               users = e->users++;
+       }
+       spin_unlock(&con->writequeue_lock);
+
+       if (e) {
+       got_one:
+               if (users == 0)
+                       kmap(e->page);
+               *ppc = page_address(e->page) + offset;
+               return e;
+       }
+
+       e = new_writequeue_entry(con, allocation);
+       if (e) {
+               spin_lock(&con->writequeue_lock);
+               offset = e->end;
+               e->end += len;
+               users = e->users++;
+               list_add_tail(&e->list, &con->writequeue);
+               spin_unlock(&con->writequeue_lock);
+               goto got_one;
+       }
+       return NULL;
+}
+
+void dlm_lowcomms_commit_buffer(void *mh)
+{
+       struct writequeue_entry *e = (struct writequeue_entry *)mh;
+       struct connection *con = e->con;
+       int users;
+
+       users = --e->users;
+       if (users)
+               goto out;
+       e->len = e->end - e->offset;
+       kunmap(e->page);
+       spin_unlock(&con->writequeue_lock);
+
+       if (test_and_set_bit(CF_WRITE_PENDING, &con->flags) == 0) {
+               spin_lock_bh(&write_sockets_lock);
+               list_add_tail(&con->write_list, &write_sockets);
+               spin_unlock_bh(&write_sockets_lock);
+
+               wake_up_interruptible(&lowcomms_send_waitq);
+       }
+       return;
+
+out:
+       spin_unlock(&con->writequeue_lock);
+       return;
+}
+
+static void free_entry(struct writequeue_entry *e)
+{
+       __free_page(e->page);
+       kfree(e);
+}
+
+/* Send a message */
+static void send_to_sock(struct connection *con)
+{
+       int ret = 0;
+       ssize_t(*sendpage) (struct socket *, struct page *, int, size_t, int);
+       const int msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL;
+       struct writequeue_entry *e;
+       int len, offset;
+
+       down_read(&con->sock_sem);
+       if (con->sock == NULL)
+               goto out_connect;
+
+       sendpage = con->sock->ops->sendpage;
+
+       spin_lock(&con->writequeue_lock);
+       for (;;) {
+               e = list_entry(con->writequeue.next, struct writequeue_entry,
+                              list);
+               if ((struct list_head *) e == &con->writequeue)
+                       break;
+
+               len = e->len;
+               offset = e->offset;
+               BUG_ON(len == 0 && e->users == 0);
+               spin_unlock(&con->writequeue_lock);
+
+               ret = 0;
+               if (len) {
+                       ret = sendpage(con->sock, e->page, offset, len,
+                                      msg_flags);
+                       if (ret == -EAGAIN || ret == 0)
+                               goto out;
+                       if (ret <= 0)
+                               goto send_error;
+               }
+               else {
+                       /* Don't starve people filling buffers */
+                       cond_resched();
+               }
+
+               spin_lock(&con->writequeue_lock);
+               e->offset += ret;
+               e->len -= ret;
+
+               if (e->len == 0 && e->users == 0) {
+                       list_del(&e->list);
+                       kunmap(e->page);
+                       free_entry(e);
+                       continue;
+               }
+       }
+       spin_unlock(&con->writequeue_lock);
+out:
+       up_read(&con->sock_sem);
+       return;
+
+send_error:
+       up_read(&con->sock_sem);
+       close_connection(con, false);
+       lowcomms_connect_sock(con);
+       return;
+
+out_connect:
+       up_read(&con->sock_sem);
+       lowcomms_connect_sock(con);
+       return;
+}
+
+static void clean_one_writequeue(struct connection *con)
+{
+       struct list_head *list;
+       struct list_head *temp;
+
+       spin_lock(&con->writequeue_lock);
+       list_for_each_safe(list, temp, &con->writequeue) {
+               struct writequeue_entry *e =
+                       list_entry(list, struct writequeue_entry, list);
+               list_del(&e->list);
+               free_entry(e);
+       }
+       spin_unlock(&con->writequeue_lock);
+}
+
+/* Called from recovery when it knows that a node has
+   left the cluster */
+int dlm_lowcomms_close(int nodeid)
+{
+       struct connection *con;
+
+       if (!connections)
+               goto out;
+
+       log_print("closing connection to node %d", nodeid);
+       con = nodeid2con(nodeid, 0);
+       if (con) {
+               clean_one_writequeue(con);
+               close_connection(con, true);
+               atomic_set(&con->waiting_requests, 0);
+       }
+       return 0;
+
+out:
+       return -1;
+}
+
+/* API send message call, may queue the request */
+/* N.B. This is the old interface - use the new one for new calls */
+int lowcomms_send_message(int nodeid, char *buf, int len, gfp_t allocation)
+{
+       struct writequeue_entry *e;
+       char *b;
+
+       e = dlm_lowcomms_get_buffer(nodeid, len, allocation, &b);
+       if (e) {
+               memcpy(b, buf, len);
+               dlm_lowcomms_commit_buffer(e);
+               return 0;
+       }
+       return -ENOBUFS;
+}
+
+/* Look for activity on active sockets */
+static void process_sockets(void)
+{
+       struct list_head *list;
+       struct list_head *temp;
+       int count = 0;
+
+       spin_lock_bh(&read_sockets_lock);
+       list_for_each_safe(list, temp, &read_sockets) {
+
+               struct connection *con =
+                       list_entry(list, struct connection, read_list);
+               list_del(&con->read_list);
+               clear_bit(CF_READ_PENDING, &con->flags);
+
+               spin_unlock_bh(&read_sockets_lock);
+
+               /* This can reach zero if we are processing requests
+                * as they come in.
+                */
+               if (atomic_read(&con->waiting_requests) == 0) {
+                       spin_lock_bh(&read_sockets_lock);
+                       continue;
+               }
+
+               do {
+                       con->rx_action(con);
+
+                       /* Don't starve out everyone else */
+                       if (++count >= MAX_RX_MSG_COUNT) {
+                               cond_resched();
+                               count = 0;
+                       }
+
+               } while (!atomic_dec_and_test(&con->waiting_requests) &&
+                        !kthread_should_stop());
+
+               spin_lock_bh(&read_sockets_lock);
+       }
+       spin_unlock_bh(&read_sockets_lock);
+}
+
+/* Try to send any messages that are pending
+ */
+static void process_output_queue(void)
+{
+       struct list_head *list;
+       struct list_head *temp;
+
+       spin_lock_bh(&write_sockets_lock);
+       list_for_each_safe(list, temp, &write_sockets) {
+               struct connection *con =
+                       list_entry(list, struct connection, write_list);
+               clear_bit(CF_WRITE_PENDING, &con->flags);
+               list_del(&con->write_list);
+
+               spin_unlock_bh(&write_sockets_lock);
+               send_to_sock(con);
+               spin_lock_bh(&write_sockets_lock);
+       }
+       spin_unlock_bh(&write_sockets_lock);
+}
+
+static void process_state_queue(void)
+{
+       struct list_head *list;
+       struct list_head *temp;
+
+       spin_lock_bh(&state_sockets_lock);
+       list_for_each_safe(list, temp, &state_sockets) {
+               struct connection *con =
+                       list_entry(list, struct connection, state_list);
+               list_del(&con->state_list);
+               clear_bit(CF_CONNECT_PENDING, &con->flags);
+               spin_unlock_bh(&state_sockets_lock);
+
+               connect_to_sock(con);
+               spin_lock_bh(&state_sockets_lock);
+       }
+       spin_unlock_bh(&state_sockets_lock);
+}
+
+
+/* Discard all entries on the write queues */
+static void clean_writequeues(void)
+{
+       int nodeid;
+
+       for (nodeid = 1; nodeid < conn_array_size; nodeid++) {
+               struct connection *con = nodeid2con(nodeid, 0);
+
+               if (con)
+                       clean_one_writequeue(con);
+       }
+}
+
+static int read_list_empty(void)
+{
+       int status;
+
+       spin_lock_bh(&read_sockets_lock);
+       status = list_empty(&read_sockets);
+       spin_unlock_bh(&read_sockets_lock);
+
+       return status;
+}
+
+/* DLM Transport comms receive daemon */
+static int dlm_recvd(void *data)
+{
+       init_waitqueue_entry(&lowcomms_recv_waitq_head, current);
+       add_wait_queue(&lowcomms_recv_waitq, &lowcomms_recv_waitq_head);
+
+       while (!kthread_should_stop()) {
+               set_current_state(TASK_INTERRUPTIBLE);
+               if (read_list_empty())
+                       cond_resched();
+               set_current_state(TASK_RUNNING);
+
+               process_sockets();
+       }
+
+       return 0;
+}
+
+static int write_and_state_lists_empty(void)
+{
+       int status;
+
+       spin_lock_bh(&write_sockets_lock);
+       status = list_empty(&write_sockets);
+       spin_unlock_bh(&write_sockets_lock);
+
+       spin_lock_bh(&state_sockets_lock);
+       if (list_empty(&state_sockets) == 0)
+               status = 0;
+       spin_unlock_bh(&state_sockets_lock);
+
+       return status;
+}
+
+/* DLM Transport send daemon */
+static int dlm_sendd(void *data)
+{
+       init_waitqueue_entry(&lowcomms_send_waitq_head, current);
+       add_wait_queue(&lowcomms_send_waitq, &lowcomms_send_waitq_head);
+
+       while (!kthread_should_stop()) {
+               set_current_state(TASK_INTERRUPTIBLE);
+               if (write_and_state_lists_empty())
+                       cond_resched();
+               set_current_state(TASK_RUNNING);
+
+               process_state_queue();
+               process_output_queue();
+       }
+
+       return 0;
+}
+
+static void daemons_stop(void)
+{
+       kthread_stop(recv_task);
+       kthread_stop(send_task);
+}
+
+static int daemons_start(void)
+{
+       struct task_struct *p;
+       int error;
+
+       p = kthread_run(dlm_recvd, NULL, "dlm_recvd");
+       error = IS_ERR(p);
+       if (error) {
+               log_print("can't start dlm_recvd %d", error);
+               return error;
+       }
+       recv_task = p;
+
+       p = kthread_run(dlm_sendd, NULL, "dlm_sendd");
+       error = IS_ERR(p);
+       if (error) {
+               log_print("can't start dlm_sendd %d", error);
+               kthread_stop(recv_task);
+               return error;
+       }
+       send_task = p;
+
+       return 0;
+}
+
+/*
+ * Return the largest buffer size we can cope with.
+ */
+int lowcomms_max_buffer_size(void)
+{
+       return PAGE_CACHE_SIZE;
+}
+
+void dlm_lowcomms_stop(void)
+{
+       int i;
+
+       /* Set all the flags to prevent any
+          socket activity.
+       */
+       for (i = 0; i < conn_array_size; i++) {
+               if (connections[i])
+                       connections[i]->flags |= 0xFF;
+       }
+
+       daemons_stop();
+       clean_writequeues();
+
+       for (i = 0; i < conn_array_size; i++) {
+               if (connections[i]) {
+                       close_connection(connections[i], true);
+                       if (connections[i]->othercon)
+                               kmem_cache_free(con_cache, connections[i]->othercon);
+                       kmem_cache_free(con_cache, connections[i]);
+               }
+       }
+
+       kfree(connections);
+       connections = NULL;
+
+       kmem_cache_destroy(con_cache);
+}
+
+/* This is quite likely to sleep... */
+int dlm_lowcomms_start(void)
+{
+       int error = 0;
+
+       error = -ENOMEM;
+       connections = kzalloc(sizeof(struct connection *) *
+                             NODE_INCREMENT, GFP_KERNEL);
+       if (!connections)
+               goto out;
+
+       conn_array_size = NODE_INCREMENT;
+
+       if (dlm_our_addr(&dlm_local_addr, 0)) {
+               log_print("no local IP address has been set");
+               goto fail_free_conn;
+       }
+       if (!dlm_our_addr(&dlm_local_addr, 1)) {
+               log_print("This dlm comms module does not support multi-homed clustering");
+               goto fail_free_conn;
+       }
+
+       con_cache = kmem_cache_create("dlm_conn", sizeof(struct connection),
+                                     __alignof__(struct connection), 0,
+                                     NULL, NULL);
+       if (!con_cache)
+               goto fail_free_conn;
+
+
+       /* Start listening */
+       error = listen_for_all();
+       if (error)
+               goto fail_unlisten;
+
+       error = daemons_start();
+       if (error)
+               goto fail_unlisten;
+
+       return 0;
+
+fail_unlisten:
+       close_connection(connections[0], false);
+       kmem_cache_free(con_cache, connections[0]);
+       kmem_cache_destroy(con_cache);
+
+fail_free_conn:
+       kfree(connections);
+
+out:
+       return error;
+}
+
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * Emacs will notice this stuff at the end of the file and automatically
+ * adjust the settings for this buffer only.  This must remain at the end
+ * of the file.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-file-style: "linux"
+ * End:
+ */
index 2d045e0daae1f6a0d2c07e8e82b74b2004ed5602..a9a9618c0d3f2bcea8063a7217a7e2e036ed76fe 100644 (file)
@@ -14,8 +14,6 @@
 #ifndef __LOWCOMMS_DOT_H__
 #define __LOWCOMMS_DOT_H__
 
-int dlm_lowcomms_init(void);
-void dlm_lowcomms_exit(void);
 int dlm_lowcomms_start(void);
 void dlm_lowcomms_stop(void);
 int dlm_lowcomms_close(int nodeid);
index a8da8dc36b2eee898551cc0dc9a6492dfa56fca8..162fbae58fe556df3150f96a8423718e47261d9a 100644 (file)
@@ -16,7 +16,6 @@
 #include "lock.h"
 #include "user.h"
 #include "memory.h"
-#include "lowcomms.h"
 #include "config.h"
 
 #ifdef CONFIG_DLM_DEBUG
@@ -47,20 +46,14 @@ static int __init init_dlm(void)
        if (error)
                goto out_config;
 
-       error = dlm_lowcomms_init();
-       if (error)
-               goto out_debug;
-
        error = dlm_user_init();
        if (error)
-               goto out_lowcomms;
+               goto out_debug;
 
        printk("DLM (built %s %s) installed\n", __DATE__, __TIME__);
 
        return 0;
 
- out_lowcomms:
-       dlm_lowcomms_exit();
  out_debug:
        dlm_unregister_debugfs();
  out_config:
@@ -76,7 +69,6 @@ static int __init init_dlm(void)
 static void __exit exit_dlm(void)
 {
        dlm_user_exit();
-       dlm_lowcomms_exit();
        dlm_config_exit();
        dlm_memory_exit();
        dlm_lockspace_exit();
index a3f7de7f3a8f969b9500875203297f4b8d6872ef..85e2897bd7400fc4155948fc8eb1c81cb1ff8e01 100644 (file)
@@ -186,6 +186,14 @@ int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out)
        struct dlm_member *memb, *safe;
        int i, error, found, pos = 0, neg = 0, low = -1;
 
+       /* previously removed members that we've not finished removing need to
+          count as a negative change so the "neg" recovery steps will happen */
+
+       list_for_each_entry(memb, &ls->ls_nodes_gone, list) {
+               log_debug(ls, "prev removed member %d", memb->nodeid);
+               neg++;
+       }
+
        /* move departed members from ls_nodes to ls_nodes_gone */
 
        list_for_each_entry_safe(memb, safe, &ls->ls_nodes, list) {
index 989b608fd83603dfc193f540c91fc452be4cabc9..5352b03ff5aa81f9af31c081965f7ae8dd81f90e 100644 (file)
@@ -15,7 +15,7 @@
 #include "config.h"
 #include "memory.h"
 
-static kmem_cache_t *lkb_cache;
+static struct kmem_cache *lkb_cache;
 
 
 int dlm_memory_init(void)
index 518239a8b1e90f00dc6c33c3b834c004d402e5dd..4cc31be9cd9d849c69e986397451f54387c03236 100644 (file)
@@ -90,13 +90,28 @@ static int check_config(struct dlm_ls *ls, struct rcom_config *rf, int nodeid)
        return 0;
 }
 
+static void allow_sync_reply(struct dlm_ls *ls, uint64_t *new_seq)
+{
+       spin_lock(&ls->ls_rcom_spin);
+       *new_seq = ++ls->ls_rcom_seq;
+       set_bit(LSFL_RCOM_WAIT, &ls->ls_flags);
+       spin_unlock(&ls->ls_rcom_spin);
+}
+
+static void disallow_sync_reply(struct dlm_ls *ls)
+{
+       spin_lock(&ls->ls_rcom_spin);
+       clear_bit(LSFL_RCOM_WAIT, &ls->ls_flags);
+       clear_bit(LSFL_RCOM_READY, &ls->ls_flags);
+       spin_unlock(&ls->ls_rcom_spin);
+}
+
 int dlm_rcom_status(struct dlm_ls *ls, int nodeid)
 {
        struct dlm_rcom *rc;
        struct dlm_mhandle *mh;
        int error = 0;
 
-       memset(ls->ls_recover_buf, 0, dlm_config.buffer_size);
        ls->ls_recover_nodeid = nodeid;
 
        if (nodeid == dlm_our_nodeid()) {
@@ -108,12 +123,14 @@ int dlm_rcom_status(struct dlm_ls *ls, int nodeid)
        error = create_rcom(ls, nodeid, DLM_RCOM_STATUS, 0, &rc, &mh);
        if (error)
                goto out;
-       rc->rc_id = ++ls->ls_rcom_seq;
+
+       allow_sync_reply(ls, &rc->rc_id);
+       memset(ls->ls_recover_buf, 0, dlm_config.buffer_size);
 
        send_rcom(ls, mh, rc);
 
        error = dlm_wait_function(ls, &rcom_response);
-       clear_bit(LSFL_RCOM_READY, &ls->ls_flags);
+       disallow_sync_reply(ls);
        if (error)
                goto out;
 
@@ -150,14 +167,21 @@ static void receive_rcom_status(struct dlm_ls *ls, struct dlm_rcom *rc_in)
 
 static void receive_sync_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in)
 {
-       if (rc_in->rc_id != ls->ls_rcom_seq) {
-               log_debug(ls, "reject old reply %d got %llx wanted %llx",
-                         rc_in->rc_type, rc_in->rc_id, ls->ls_rcom_seq);
-               return;
+       spin_lock(&ls->ls_rcom_spin);
+       if (!test_bit(LSFL_RCOM_WAIT, &ls->ls_flags) ||
+           rc_in->rc_id != ls->ls_rcom_seq) {
+               log_debug(ls, "reject reply %d from %d seq %llx expect %llx",
+                         rc_in->rc_type, rc_in->rc_header.h_nodeid,
+                         (unsigned long long)rc_in->rc_id,
+                         (unsigned long long)ls->ls_rcom_seq);
+               goto out;
        }
        memcpy(ls->ls_recover_buf, rc_in, rc_in->rc_header.h_length);
        set_bit(LSFL_RCOM_READY, &ls->ls_flags);
+       clear_bit(LSFL_RCOM_WAIT, &ls->ls_flags);
        wake_up(&ls->ls_wait_general);
+ out:
+       spin_unlock(&ls->ls_rcom_spin);
 }
 
 static void receive_rcom_status_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in)
@@ -171,7 +195,6 @@ int dlm_rcom_names(struct dlm_ls *ls, int nodeid, char *last_name, int last_len)
        struct dlm_mhandle *mh;
        int error = 0, len = sizeof(struct dlm_rcom);
 
-       memset(ls->ls_recover_buf, 0, dlm_config.buffer_size);
        ls->ls_recover_nodeid = nodeid;
 
        if (nodeid == dlm_our_nodeid()) {
@@ -185,12 +208,14 @@ int dlm_rcom_names(struct dlm_ls *ls, int nodeid, char *last_name, int last_len)
        if (error)
                goto out;
        memcpy(rc->rc_buf, last_name, last_len);
-       rc->rc_id = ++ls->ls_rcom_seq;
+
+       allow_sync_reply(ls, &rc->rc_id);
+       memset(ls->ls_recover_buf, 0, dlm_config.buffer_size);
 
        send_rcom(ls, mh, rc);
 
        error = dlm_wait_function(ls, &rcom_response);
-       clear_bit(LSFL_RCOM_READY, &ls->ls_flags);
+       disallow_sync_reply(ls);
  out:
        return error;
 }
@@ -370,9 +395,10 @@ static void receive_rcom_lock_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in)
 static int send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in)
 {
        struct dlm_rcom *rc;
+       struct rcom_config *rf;
        struct dlm_mhandle *mh;
        char *mb;
-       int mb_len = sizeof(struct dlm_rcom);
+       int mb_len = sizeof(struct dlm_rcom) + sizeof(struct rcom_config);
 
        mh = dlm_lowcomms_get_buffer(nodeid, mb_len, GFP_KERNEL, &mb);
        if (!mh)
@@ -391,6 +417,9 @@ static int send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in)
        rc->rc_id = rc_in->rc_id;
        rc->rc_result = -ESRCH;
 
+       rf = (struct rcom_config *) rc->rc_buf;
+       rf->rf_lvblen = -1;
+
        dlm_rcom_out(rc);
        dlm_lowcomms_commit_buffer(mh);
 
@@ -412,9 +441,10 @@ void dlm_receive_rcom(struct dlm_header *hd, int nodeid)
 
        ls = dlm_find_lockspace_global(hd->h_lockspace);
        if (!ls) {
-               log_print("lockspace %x from %d not found",
-                         hd->h_lockspace, nodeid);
-               send_ls_not_ready(nodeid, rc);
+               log_print("lockspace %x from %d type %x not found",
+                         hd->h_lockspace, nodeid, rc->rc_type);
+               if (rc->rc_type == DLM_RCOM_STATUS)
+                       send_ls_not_ready(nodeid, rc);
                return;
        }
 
index a5e6d184872e0576301b72acb2f765aba3bac24e..cf9f6831bab57c34e9c733e4328a0c1a38ea534f 100644 (file)
@@ -252,6 +252,7 @@ static void recover_list_clear(struct dlm_ls *ls)
        spin_lock(&ls->ls_recover_list_lock);
        list_for_each_entry_safe(r, s, &ls->ls_recover_list, res_recover_list) {
                list_del_init(&r->res_recover_list);
+               r->res_recover_locks_count = 0;
                dlm_put_rsb(r);
                ls->ls_recover_list_count--;
        }
index 362e3eff4dc9afef2e8bd02777ed87591636fcfe..650536aa513930948a1c5b5eaf6250aa68c837a2 100644 (file)
@@ -45,7 +45,7 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
        unsigned long start;
        int error, neg = 0;
 
-       log_debug(ls, "recover %llx", rv->seq);
+       log_debug(ls, "recover %llx", (unsigned long long)rv->seq);
 
        mutex_lock(&ls->ls_recoverd_active);
 
@@ -93,14 +93,6 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
                goto fail;
        }
 
-       /*
-        * Purge directory-related requests that are saved in requestqueue.
-        * All dir requests from before recovery are invalid now due to the dir
-        * rebuild and will be resent by the requesting nodes.
-        */
-
-       dlm_purge_requestqueue(ls);
-
        /*
         * Wait for all nodes to complete directory rebuild.
         */
@@ -164,10 +156,31 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
                 */
 
                dlm_recover_rsbs(ls);
+       } else {
+               /*
+                * Other lockspace members may be going through the "neg" steps
+                * while also adding us to the lockspace, in which case they'll
+                * be doing the recover_locks (RS_LOCKS) barrier.
+                */
+               dlm_set_recover_status(ls, DLM_RS_LOCKS);
+
+               error = dlm_recover_locks_wait(ls);
+               if (error) {
+                       log_error(ls, "recover_locks_wait failed %d", error);
+                       goto fail;
+               }
        }
 
        dlm_release_root_list(ls);
 
+       /*
+        * Purge directory-related requests that are saved in requestqueue.
+        * All dir requests from before recovery are invalid now due to the dir
+        * rebuild and will be resent by the requesting nodes.
+        */
+
+       dlm_purge_requestqueue(ls);
+
        dlm_set_recover_status(ls, DLM_RS_DONE);
        error = dlm_recover_done_wait(ls);
        if (error) {
@@ -199,7 +212,8 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
 
        dlm_astd_wake();
 
-       log_debug(ls, "recover %llx done: %u ms", rv->seq,
+       log_debug(ls, "recover %llx done: %u ms",
+                 (unsigned long long)rv->seq,
                  jiffies_to_msecs(jiffies - start));
        mutex_unlock(&ls->ls_recoverd_active);
 
@@ -207,11 +221,16 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
 
  fail:
        dlm_release_root_list(ls);
-       log_debug(ls, "recover %llx error %d", rv->seq, error);
+       log_debug(ls, "recover %llx error %d",
+                 (unsigned long long)rv->seq, error);
        mutex_unlock(&ls->ls_recoverd_active);
        return error;
 }
 
+/* The dlm_ls_start() that created the rv we take here may already have been
+   stopped via dlm_ls_stop(); in that case we need to leave the RECOVERY_STOP
+   flag set. */
+
 static void do_ls_recovery(struct dlm_ls *ls)
 {
        struct dlm_recover *rv = NULL;
@@ -219,7 +238,8 @@ static void do_ls_recovery(struct dlm_ls *ls)
        spin_lock(&ls->ls_recover_lock);
        rv = ls->ls_recover_args;
        ls->ls_recover_args = NULL;
-       clear_bit(LSFL_RECOVERY_STOP, &ls->ls_flags);
+       if (rv && ls->ls_recover_seq == rv->seq)
+               clear_bit(LSFL_RECOVERY_STOP, &ls->ls_flags);
        spin_unlock(&ls->ls_recover_lock);
 
        if (rv) {
index 7b2b089634a2df67d7253a0b316a97294a6f86c6..65008d79c96d2e651091dbd7bcbe47f1e17221ec 100644 (file)
@@ -30,26 +30,36 @@ struct rq_entry {
  * lockspace is enabled on some while still suspended on others.
  */
 
-void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_header *hd)
+int dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_header *hd)
 {
        struct rq_entry *e;
        int length = hd->h_length;
-
-       if (dlm_is_removed(ls, nodeid))
-               return;
+       int rv = 0;
 
        e = kmalloc(sizeof(struct rq_entry) + length, GFP_KERNEL);
        if (!e) {
                log_print("dlm_add_requestqueue: out of memory\n");
-               return;
+               return 0;
        }
 
        e->nodeid = nodeid;
        memcpy(e->request, hd, length);
 
+       /* We need to check dlm_locking_stopped() after taking the mutex to
+          avoid a race where dlm_recoverd enables locking and runs
+          process_requestqueue between our earlier dlm_locking_stopped check
+          and this addition to the requestqueue. */
+
        mutex_lock(&ls->ls_requestqueue_mutex);
-       list_add_tail(&e->list, &ls->ls_requestqueue);
+       if (dlm_locking_stopped(ls))
+               list_add_tail(&e->list, &ls->ls_requestqueue);
+       else {
+               log_debug(ls, "dlm_add_requestqueue skip from %d", nodeid);
+               kfree(e);
+               rv = -EAGAIN;
+       }
        mutex_unlock(&ls->ls_requestqueue_mutex);
+       return rv;
 }
 
 int dlm_process_requestqueue(struct dlm_ls *ls)
@@ -120,6 +130,10 @@ static int purge_request(struct dlm_ls *ls, struct dlm_message *ms, int nodeid)
 {
        uint32_t type = ms->m_type;
 
+       /* the ls is being cleaned up and freed by release_lockspace */
+       if (!ls->ls_count)
+               return 1;
+
        if (dlm_is_removed(ls, nodeid))
                return 1;
 
index 349f0d292d95ec22688d525cfa3d9301dc903148..6a53ea03335dae50b9d22f1c0c156ff01dfd581d 100644 (file)
@@ -13,7 +13,7 @@
 #ifndef __REQUESTQUEUE_DOT_H__
 #define __REQUESTQUEUE_DOT_H__
 
-void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_header *hd);
+int dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_header *hd);
 int dlm_process_requestqueue(struct dlm_ls *ls);
 void dlm_wait_requestqueue(struct dlm_ls *ls);
 void dlm_purge_requestqueue(struct dlm_ls *ls);
index 2b0442db67e05cb7b0a275dafd0f7c762d86e050..936409fcd9397a9909e74fd7547d609ee1e57986 100644 (file)
@@ -23,7 +23,7 @@
 
 int dir_notify_enable __read_mostly = 1;
 
-static kmem_cache_t *dn_cache __read_mostly;
+static struct kmem_cache *dn_cache __read_mostly;
 
 static void redo_inode_mask(struct inode *inode)
 {
@@ -42,7 +42,7 @@ void dnotify_flush(struct file *filp, fl_owner_t id)
        struct dnotify_struct **prev;
        struct inode *inode;
 
-       inode = filp->f_dentry->d_inode;
+       inode = filp->f_path.dentry->d_inode;
        if (!S_ISDIR(inode->i_mode))
                return;
        spin_lock(&inode->i_lock);
@@ -74,10 +74,10 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
        }
        if (!dir_notify_enable)
                return -EINVAL;
-       inode = filp->f_dentry->d_inode;
+       inode = filp->f_path.dentry->d_inode;
        if (!S_ISDIR(inode->i_mode))
                return -ENOTDIR;
-       dn = kmem_cache_alloc(dn_cache, SLAB_KERNEL);
+       dn = kmem_cache_alloc(dn_cache, GFP_KERNEL);
        if (dn == NULL)
                return -ENOMEM;
        spin_lock(&inode->i_lock);
index 9af789567e513b4575c9066711b8b6f595c949c7..0952cc474d9a57e08b495315200a73d9c93889e7 100644 (file)
@@ -131,7 +131,7 @@ static struct quota_format_type *quota_formats;     /* List of registered formats */
 static struct quota_module_name module_names[] = INIT_QUOTA_MODULE_NAMES;
 
 /* SLAB cache for dquot structures */
-static kmem_cache_t *dquot_cachep;
+static struct kmem_cache *dquot_cachep;
 
 int register_quota_format(struct quota_format_type *fmt)
 {
@@ -600,7 +600,7 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
 {
        struct dquot *dquot;
 
-       dquot = kmem_cache_alloc(dquot_cachep, SLAB_NOFS);
+       dquot = kmem_cache_alloc(dquot_cachep, GFP_NOFS);
        if(!dquot)
                return NODQUOT;
 
@@ -694,9 +694,9 @@ restart:
        file_list_lock();
        list_for_each(p, &sb->s_files) {
                struct file *filp = list_entry(p, struct file, f_u.fu_list);
-               struct inode *inode = filp->f_dentry->d_inode;
+               struct inode *inode = filp->f_path.dentry->d_inode;
                if (filp->f_mode & FMODE_WRITE && dqinit_needed(inode, type)) {
-                       struct dentry *dentry = dget(filp->f_dentry);
+                       struct dentry *dentry = dget(filp->f_path.dentry);
                        file_list_unlock();
                        sb->dq_op->initialize(inode, type);
                        dput(dentry);
@@ -828,6 +828,7 @@ static inline int need_print_warning(struct dquot *dquot)
 static void print_warning(struct dquot *dquot, const char warntype)
 {
        char *msg = NULL;
+       struct tty_struct *tty;
        int flag = (warntype == BHARDWARN || warntype == BSOFTLONGWARN) ? DQ_BLKS_B :
          ((warntype == IHARDWARN || warntype == ISOFTLONGWARN) ? DQ_INODES_B : 0);
 
@@ -835,14 +836,15 @@ static void print_warning(struct dquot *dquot, const char warntype)
                return;
 
        mutex_lock(&tty_mutex);
-       if (!current->signal->tty)
+       tty = get_current_tty();
+       if (!tty)
                goto out_lock;
-       tty_write_message(current->signal->tty, dquot->dq_sb->s_id);
+       tty_write_message(tty, dquot->dq_sb->s_id);
        if (warntype == ISOFTWARN || warntype == BSOFTWARN)
-               tty_write_message(current->signal->tty, ": warning, ");
+               tty_write_message(tty, ": warning, ");
        else
-               tty_write_message(current->signal->tty, ": write failed, ");
-       tty_write_message(current->signal->tty, quotatypes[dquot->dq_type]);
+               tty_write_message(tty, ": write failed, ");
+       tty_write_message(tty, quotatypes[dquot->dq_type]);
        switch (warntype) {
                case IHARDWARN:
                        msg = " file limit reached.\r\n";
@@ -863,7 +865,7 @@ static void print_warning(struct dquot *dquot, const char warntype)
                        msg = " block quota exceeded.\r\n";
                        break;
        }
-       tty_write_message(current->signal->tty, msg);
+       tty_write_message(tty, msg);
 out_lock:
        mutex_unlock(&tty_mutex);
 }
index f63a7755fe8697ea7469182b1baa487fd1b48c7a..7196f50fe152f630f8d5b839fdfa32e3d2c4a5fd 100644 (file)
@@ -628,7 +628,7 @@ int ecryptfs_decrypt_page(struct file *file, struct page *page)
        num_extents_per_page = PAGE_CACHE_SIZE / crypt_stat->extent_size;
        base_extent = (page->index * num_extents_per_page);
        lower_page_virt = kmem_cache_alloc(ecryptfs_lower_page_cache,
-                                          SLAB_KERNEL);
+                                          GFP_KERNEL);
        if (!lower_page_virt) {
                rc = -ENOMEM;
                ecryptfs_printk(KERN_ERR, "Error getting page for encrypted "
@@ -1334,7 +1334,7 @@ int ecryptfs_write_headers(struct dentry *ecryptfs_dentry,
                goto out;
        }
        /* Released in this function */
-       page_virt = kmem_cache_alloc(ecryptfs_header_cache_0, SLAB_USER);
+       page_virt = kmem_cache_alloc(ecryptfs_header_cache_0, GFP_USER);
        if (!page_virt) {
                ecryptfs_printk(KERN_ERR, "Out of memory\n");
                rc = -ENOMEM;
@@ -1493,7 +1493,7 @@ int ecryptfs_read_headers(struct dentry *ecryptfs_dentry,
            &ecryptfs_inode_to_private(ecryptfs_dentry->d_inode)->crypt_stat;
 
        /* Read the first page from the underlying file */
-       page_virt = kmem_cache_alloc(ecryptfs_header_cache_1, SLAB_USER);
+       page_virt = kmem_cache_alloc(ecryptfs_header_cache_1, GFP_USER);
        if (!page_virt) {
                rc = -ENOMEM;
                ecryptfs_printk(KERN_ERR, "Unable to allocate page_virt\n");
index 52d1e36dc746a54182c2a68bf8aad19b1e1b0dbc..329efcd3d8c9d672a66799390d5adeceb5150604 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/dcache.h>
 #include <linux/namei.h>
 #include <linux/mount.h>
+#include <linux/fs_stack.h>
 #include "ecryptfs_kernel.h"
 
 /**
@@ -61,7 +62,7 @@ static int ecryptfs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
                struct inode *lower_inode =
                        ecryptfs_inode_to_lower(dentry->d_inode);
 
-               ecryptfs_copy_attr_all(dentry->d_inode, lower_inode);
+               fsstack_copy_attr_all(dentry->d_inode, lower_inode, NULL);
        }
 out:
        return rc;
index f992533d1692b7a47d58f0f004712adc22efb01c..afb64bdbe6ad85d8faa5079f16c2c97cc098acba 100644 (file)
@@ -28,6 +28,8 @@
 
 #include <keys/user-type.h>
 #include <linux/fs.h>
+#include <linux/fs_stack.h>
+#include <linux/namei.h>
 #include <linux/scatterlist.h>
 
 /* Version verification for shared data structures w/ userspace */
@@ -227,8 +229,7 @@ struct ecryptfs_inode_info {
 /* dentry private data. Each dentry must keep track of a lower
  * vfsmount too. */
 struct ecryptfs_dentry_info {
-       struct dentry *wdi_dentry;
-       struct vfsmount *lower_mnt;
+       struct path lower_path;
        struct ecryptfs_crypt_stat *crypt_stat;
 };
 
@@ -355,26 +356,26 @@ ecryptfs_set_dentry_private(struct dentry *dentry,
 static inline struct dentry *
 ecryptfs_dentry_to_lower(struct dentry *dentry)
 {
-       return ((struct ecryptfs_dentry_info *)dentry->d_fsdata)->wdi_dentry;
+       return ((struct ecryptfs_dentry_info *)dentry->d_fsdata)->lower_path.dentry;
 }
 
 static inline void
 ecryptfs_set_dentry_lower(struct dentry *dentry, struct dentry *lower_dentry)
 {
-       ((struct ecryptfs_dentry_info *)dentry->d_fsdata)->wdi_dentry =
+       ((struct ecryptfs_dentry_info *)dentry->d_fsdata)->lower_path.dentry =
                lower_dentry;
 }
 
 static inline struct vfsmount *
 ecryptfs_dentry_to_lower_mnt(struct dentry *dentry)
 {
-       return ((struct ecryptfs_dentry_info *)dentry->d_fsdata)->lower_mnt;
+       return ((struct ecryptfs_dentry_info *)dentry->d_fsdata)->lower_path.mnt;
 }
 
 static inline void
 ecryptfs_set_dentry_lower_mnt(struct dentry *dentry, struct vfsmount *lower_mnt)
 {
-       ((struct ecryptfs_dentry_info *)dentry->d_fsdata)->lower_mnt =
+       ((struct ecryptfs_dentry_info *)dentry->d_fsdata)->lower_path.mnt =
                lower_mnt;
 }
 
@@ -413,9 +414,6 @@ int ecryptfs_encode_filename(struct ecryptfs_crypt_stat *crypt_stat,
                             const char *name, int length,
                             char **encoded_name);
 struct dentry *ecryptfs_lower_dentry(struct dentry *this_dentry);
-void ecryptfs_copy_attr_atime(struct inode *dest, const struct inode *src);
-void ecryptfs_copy_attr_all(struct inode *dest, const struct inode *src);
-void ecryptfs_copy_inode_size(struct inode *dst, const struct inode *src);
 void ecryptfs_dump_hex(char *data, int bytes);
 int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg,
                        int sg_size);
index a92ef05eff8f3d1ba52bdf481d14c728f9591eb1..c5a2e5298f155c0744f653ba8bbc6018f03179ed 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/security.h>
 #include <linux/smp_lock.h>
 #include <linux/compat.h>
+#include <linux/fs_stack.h>
 #include "ecryptfs_kernel.h"
 
 /**
@@ -75,7 +76,7 @@ static loff_t ecryptfs_llseek(struct file *file, loff_t offset, int origin)
        }
        ecryptfs_printk(KERN_DEBUG, "new_end_pos = [0x%.16x]\n", new_end_pos);
        if (expanding_file) {
-               rc = ecryptfs_truncate(file->f_dentry, new_end_pos);
+               rc = ecryptfs_truncate(file->f_path.dentry, new_end_pos);
                if (rc) {
                        rv = rc;
                        ecryptfs_printk(KERN_ERR, "Error on attempt to "
@@ -116,8 +117,8 @@ static ssize_t ecryptfs_read_update_atime(struct kiocb *iocb,
        if (-EIOCBQUEUED == rc)
                rc = wait_on_sync_kiocb(iocb);
        if (rc >= 0) {
-               lower_dentry = ecryptfs_dentry_to_lower(file->f_dentry);
-               lower_vfsmount = ecryptfs_dentry_to_lower_mnt(file->f_dentry);
+               lower_dentry = ecryptfs_dentry_to_lower(file->f_path.dentry);
+               lower_vfsmount = ecryptfs_dentry_to_lower_mnt(file->f_path.dentry);
                touch_atime(lower_vfsmount, lower_dentry);
        }
        return rc;
@@ -176,10 +177,10 @@ static int ecryptfs_readdir(struct file *file, void *dirent, filldir_t filldir)
 
        lower_file = ecryptfs_file_to_lower(file);
        lower_file->f_pos = file->f_pos;
-       inode = file->f_dentry->d_inode;
+       inode = file->f_path.dentry->d_inode;
        memset(&buf, 0, sizeof(buf));
        buf.dirent = dirent;
-       buf.dentry = file->f_dentry;
+       buf.dentry = file->f_path.dentry;
        buf.filldir = filldir;
 retry:
        buf.filldir_called = 0;
@@ -192,7 +193,7 @@ retry:
                goto retry;
        file->f_pos = lower_file->f_pos;
        if (rc >= 0)
-               ecryptfs_copy_attr_atime(inode, lower_file->f_dentry->d_inode);
+               fsstack_copy_attr_atime(inode, lower_file->f_path.dentry->d_inode);
        return rc;
 }
 
@@ -239,7 +240,7 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
        int rc = 0;
        struct ecryptfs_crypt_stat *crypt_stat = NULL;
        struct ecryptfs_mount_crypt_stat *mount_crypt_stat;
-       struct dentry *ecryptfs_dentry = file->f_dentry;
+       struct dentry *ecryptfs_dentry = file->f_path.dentry;
        /* Private value of ecryptfs_dentry allocated in
         * ecryptfs_lookup() */
        struct dentry *lower_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry);
@@ -250,7 +251,7 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
        int lower_flags;
 
        /* Released in ecryptfs_release or end of function if failure */
-       file_info = kmem_cache_alloc(ecryptfs_file_info_cache, SLAB_KERNEL);
+       file_info = kmem_cache_alloc(ecryptfs_file_info_cache, GFP_KERNEL);
        ecryptfs_set_file_private(file, file_info);
        if (!file_info) {
                ecryptfs_printk(KERN_ERR,
index dfcc68484f47068ccb3d256283cfea67857518f6..11f5e5076aefdfc28ab40359b0fee3cca291e871 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/namei.h>
 #include <linux/mount.h>
 #include <linux/crypto.h>
+#include <linux/fs_stack.h>
 #include "ecryptfs_kernel.h"
 
 static struct dentry *lock_parent(struct dentry *dentry)
@@ -53,48 +54,6 @@ static void unlock_dir(struct dentry *dir)
        dput(dir);
 }
 
-void ecryptfs_copy_inode_size(struct inode *dst, const struct inode *src)
-{
-       i_size_write(dst, i_size_read((struct inode *)src));
-       dst->i_blocks = src->i_blocks;
-}
-
-void ecryptfs_copy_attr_atime(struct inode *dest, const struct inode *src)
-{
-       dest->i_atime = src->i_atime;
-}
-
-static void ecryptfs_copy_attr_times(struct inode *dest,
-                                    const struct inode *src)
-{
-       dest->i_atime = src->i_atime;
-       dest->i_mtime = src->i_mtime;
-       dest->i_ctime = src->i_ctime;
-}
-
-static void ecryptfs_copy_attr_timesizes(struct inode *dest,
-                                        const struct inode *src)
-{
-       dest->i_atime = src->i_atime;
-       dest->i_mtime = src->i_mtime;
-       dest->i_ctime = src->i_ctime;
-       ecryptfs_copy_inode_size(dest, src);
-}
-
-void ecryptfs_copy_attr_all(struct inode *dest, const struct inode *src)
-{
-       dest->i_mode = src->i_mode;
-       dest->i_nlink = src->i_nlink;
-       dest->i_uid = src->i_uid;
-       dest->i_gid = src->i_gid;
-       dest->i_rdev = src->i_rdev;
-       dest->i_atime = src->i_atime;
-       dest->i_mtime = src->i_mtime;
-       dest->i_ctime = src->i_ctime;
-       dest->i_blkbits = src->i_blkbits;
-       dest->i_flags = src->i_flags;
-}
-
 /**
  * ecryptfs_create_underlying_file
  * @lower_dir_inode: inode of the parent in the lower fs of the new file
@@ -171,8 +130,8 @@ ecryptfs_do_create(struct inode *directory_inode,
                ecryptfs_printk(KERN_ERR, "Failure in ecryptfs_interpose\n");
                goto out_lock;
        }
-       ecryptfs_copy_attr_timesizes(directory_inode,
-                                    lower_dir_dentry->d_inode);
+       fsstack_copy_attr_times(directory_inode, lower_dir_dentry->d_inode);
+       fsstack_copy_inode_size(directory_inode, lower_dir_dentry->d_inode);
 out_lock:
        unlock_dir(lower_dir_dentry);
 out:
@@ -196,7 +155,7 @@ static int grow_file(struct dentry *ecryptfs_dentry, struct file *lower_file,
        struct ecryptfs_file_info tmp_file_info;
 
        memset(&fake_file, 0, sizeof(fake_file));
-       fake_file.f_dentry = ecryptfs_dentry;
+       fake_file.f_path.dentry = ecryptfs_dentry;
        memset(&tmp_file_info, 0, sizeof(tmp_file_info));
        ecryptfs_set_file_private(&fake_file, &tmp_file_info);
        ecryptfs_set_file_lower(&fake_file, lower_file);
@@ -365,11 +324,11 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
                        "d_name.name = [%s]\n", lower_dentry,
                lower_dentry->d_name.name);
        lower_inode = lower_dentry->d_inode;
-       ecryptfs_copy_attr_atime(dir, lower_dir_dentry->d_inode);
+       fsstack_copy_attr_atime(dir, lower_dir_dentry->d_inode);
        BUG_ON(!atomic_read(&lower_dentry->d_count));
        ecryptfs_set_dentry_private(dentry,
                                    kmem_cache_alloc(ecryptfs_dentry_info_cache,
-                                                    SLAB_KERNEL));
+                                                    GFP_KERNEL));
        if (!ecryptfs_dentry_to_private(dentry)) {
                rc = -ENOMEM;
                ecryptfs_printk(KERN_ERR, "Out of memory whilst attempting "
@@ -404,7 +363,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
        /* Released in this function */
        page_virt =
            (char *)kmem_cache_alloc(ecryptfs_header_cache_2,
-                                    SLAB_USER);
+                                    GFP_USER);
        if (!page_virt) {
                rc = -ENOMEM;
                ecryptfs_printk(KERN_ERR,
@@ -462,7 +421,8 @@ static int ecryptfs_link(struct dentry *old_dentry, struct inode *dir,
        rc = ecryptfs_interpose(lower_new_dentry, new_dentry, dir->i_sb, 0);
        if (rc)
                goto out_lock;
-       ecryptfs_copy_attr_timesizes(dir, lower_new_dentry->d_inode);
+       fsstack_copy_attr_times(dir, lower_new_dentry->d_inode);
+       fsstack_copy_inode_size(dir, lower_new_dentry->d_inode);
        old_dentry->d_inode->i_nlink =
                ecryptfs_inode_to_lower(old_dentry->d_inode)->i_nlink;
        i_size_write(new_dentry->d_inode, file_size_save);
@@ -488,7 +448,7 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
                printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc);
                goto out_unlock;
        }
-       ecryptfs_copy_attr_times(dir, lower_dir_inode);
+       fsstack_copy_attr_times(dir, lower_dir_inode);
        dentry->d_inode->i_nlink =
                ecryptfs_inode_to_lower(dentry->d_inode)->i_nlink;
        dentry->d_inode->i_ctime = dir->i_ctime;
@@ -527,7 +487,8 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry,
        rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
        if (rc)
                goto out_lock;
-       ecryptfs_copy_attr_timesizes(dir, lower_dir_dentry->d_inode);
+       fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
+       fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode);
 out_lock:
        unlock_dir(lower_dir_dentry);
        dput(lower_dentry);
@@ -550,7 +511,8 @@ static int ecryptfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
        rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
        if (rc)
                goto out;
-       ecryptfs_copy_attr_timesizes(dir, lower_dir_dentry->d_inode);
+       fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
+       fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode);
        dir->i_nlink = lower_dir_dentry->d_inode->i_nlink;
 out:
        unlock_dir(lower_dir_dentry);
@@ -573,7 +535,7 @@ static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry)
        dput(lower_dentry);
        if (!rc)
                d_delete(lower_dentry);
-       ecryptfs_copy_attr_times(dir, lower_dir_dentry->d_inode);
+       fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
        dir->i_nlink = lower_dir_dentry->d_inode->i_nlink;
        unlock_dir(lower_dir_dentry);
        if (!rc)
@@ -597,7 +559,8 @@ ecryptfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
        rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
        if (rc)
                goto out;
-       ecryptfs_copy_attr_timesizes(dir, lower_dir_dentry->d_inode);
+       fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
+       fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode);
 out:
        unlock_dir(lower_dir_dentry);
        if (!dentry->d_inode)
@@ -626,9 +589,9 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                        lower_new_dir_dentry->d_inode, lower_new_dentry);
        if (rc)
                goto out_lock;
-       ecryptfs_copy_attr_all(new_dir, lower_new_dir_dentry->d_inode);
+       fsstack_copy_attr_all(new_dir, lower_new_dir_dentry->d_inode, NULL);
        if (new_dir != old_dir)
-               ecryptfs_copy_attr_all(old_dir, lower_old_dir_dentry->d_inode);
+               fsstack_copy_attr_all(old_dir, lower_old_dir_dentry->d_inode, NULL);
 out_lock:
        unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
        dput(lower_new_dentry->d_parent);
@@ -684,8 +647,8 @@ ecryptfs_readlink(struct dentry *dentry, char __user * buf, int bufsiz)
                                rc = -EFAULT;
                }
                kfree(decoded_name);
-               ecryptfs_copy_attr_atime(dentry->d_inode,
-                                        lower_dentry->d_inode);
+               fsstack_copy_attr_atime(dentry->d_inode,
+                                       lower_dentry->d_inode);
        }
 out_free_lower_buf:
        kfree(lower_buf);
@@ -791,11 +754,11 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length)
         * the file in the underlying filesystem so that the
         * truncation has an effect there as well. */
        memset(&fake_ecryptfs_file, 0, sizeof(fake_ecryptfs_file));
-       fake_ecryptfs_file.f_dentry = dentry;
+       fake_ecryptfs_file.f_path.dentry = dentry;
        /* Released at out_free: label */
        ecryptfs_set_file_private(&fake_ecryptfs_file,
                                  kmem_cache_alloc(ecryptfs_file_info_cache,
-                                                  SLAB_KERNEL));
+                                                  GFP_KERNEL));
        if (unlikely(!ecryptfs_file_to_private(&fake_ecryptfs_file))) {
                rc = -ENOMEM;
                goto out;
@@ -915,7 +878,7 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)
        }
        rc = notify_change(lower_dentry, ia);
 out:
-       ecryptfs_copy_attr_all(inode, lower_inode);
+       fsstack_copy_attr_all(inode, lower_inode, NULL);
        return rc;
 }
 
index c3746f56d1627ab2246d5086731103353f9537d3..745c0f1bfbbdcbd1a2bd4ff2db8848bc572df1fe 100644 (file)
@@ -207,7 +207,7 @@ parse_tag_3_packet(struct ecryptfs_crypt_stat *crypt_stat,
        /* Released: wipe_auth_tok_list called in ecryptfs_parse_packet_set or
         * at end of function upon failure */
        auth_tok_list_item =
-           kmem_cache_alloc(ecryptfs_auth_tok_list_item_cache, SLAB_KERNEL);
+           kmem_cache_alloc(ecryptfs_auth_tok_list_item_cache, GFP_KERNEL);
        if (!auth_tok_list_item) {
                ecryptfs_printk(KERN_ERR, "Unable to allocate memory\n");
                rc = -ENOMEM;
index a78d87d14bafb2256313753cc8aeaeeb6c0b381f..d0541ae8faba9f4df3c6420aba382a5a497baf51 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/pagemap.h>
 #include <linux/key.h>
 #include <linux/parser.h>
+#include <linux/fs_stack.h>
 #include "ecryptfs_kernel.h"
 
 /**
@@ -112,10 +113,10 @@ int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry,
                d_add(dentry, inode);
        else
                d_instantiate(dentry, inode);
-       ecryptfs_copy_attr_all(inode, lower_inode);
+       fsstack_copy_attr_all(inode, lower_inode, NULL);
        /* This size will be overwritten for real files w/ headers and
         * other metadata */
-       ecryptfs_copy_inode_size(inode, lower_inode);
+       fsstack_copy_inode_size(inode, lower_inode);
 out:
        return rc;
 }
@@ -378,7 +379,7 @@ ecryptfs_fill_super(struct super_block *sb, void *raw_data, int silent)
        /* Released in ecryptfs_put_super() */
        ecryptfs_set_superblock_private(sb,
                                        kmem_cache_alloc(ecryptfs_sb_info_cache,
-                                                        SLAB_KERNEL));
+                                                        GFP_KERNEL));
        if (!ecryptfs_superblock_to_private(sb)) {
                ecryptfs_printk(KERN_WARNING, "Out of memory\n");
                rc = -ENOMEM;
@@ -402,7 +403,7 @@ ecryptfs_fill_super(struct super_block *sb, void *raw_data, int silent)
        /* through deactivate_super(sb) from get_sb_nodev() */
        ecryptfs_set_dentry_private(sb->s_root,
                                    kmem_cache_alloc(ecryptfs_dentry_info_cache,
-                                                    SLAB_KERNEL));
+                                                    GFP_KERNEL));
        if (!ecryptfs_dentry_to_private(sb->s_root)) {
                ecryptfs_printk(KERN_ERR,
                                "dentry_info_cache alloc failed\n");
@@ -546,7 +547,7 @@ inode_info_init_once(void *vptr, struct kmem_cache *cachep, unsigned long flags)
 }
 
 static struct ecryptfs_cache_info {
-       kmem_cache_t **cache;
+       struct kmem_cache **cache;
        const char *name;
        size_t size;
        void (*ctor)(void*, struct kmem_cache *, unsigned long);
@@ -691,7 +692,7 @@ static ssize_t version_show(struct ecryptfs_obj *obj, char *buff)
 
 static struct ecryptfs_attribute sysfs_attr_version = __ATTR_RO(version);
 
-struct ecryptfs_version_str_map_elem {
+static struct ecryptfs_version_str_map_elem {
        u32 flag;
        char *str;
 } ecryptfs_version_str_map[] = {
index 924dd90a4cf5148c0d69c388f62b64332760ea78..06843d24f2398de852b6e6b0d4fec9b7c30e58fb 100644 (file)
@@ -51,7 +51,7 @@ static struct page *ecryptfs_get1page(struct file *file, int index)
        struct inode *inode;
        struct address_space *mapping;
 
-       dentry = file->f_dentry;
+       dentry = file->f_path.dentry;
        inode = dentry->d_inode;
        mapping = inode->i_mapping;
        page = read_cache_page(mapping, index,
@@ -84,7 +84,7 @@ int write_zeros(struct file *file, pgoff_t index, int start, int num_zeros);
 int ecryptfs_fill_zeros(struct file *file, loff_t new_length)
 {
        int rc = 0;
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        pgoff_t old_end_page_index = 0;
        pgoff_t index = old_end_page_index;
@@ -218,7 +218,7 @@ int ecryptfs_do_readpage(struct file *file, struct page *page,
        char *lower_page_data;
        const struct address_space_operations *lower_a_ops;
 
-       dentry = file->f_dentry;
+       dentry = file->f_path.dentry;
        lower_file = ecryptfs_file_to_lower(file);
        lower_dentry = ecryptfs_dentry_to_lower(dentry);
        inode = dentry->d_inode;
@@ -275,9 +275,9 @@ static int ecryptfs_readpage(struct file *file, struct page *page)
        int rc = 0;
        struct ecryptfs_crypt_stat *crypt_stat;
 
-       BUG_ON(!(file && file->f_dentry && file->f_dentry->d_inode));
-       crypt_stat =
-               &ecryptfs_inode_to_private(file->f_dentry->d_inode)->crypt_stat;
+       BUG_ON(!(file && file->f_path.dentry && file->f_path.dentry->d_inode));
+       crypt_stat = &ecryptfs_inode_to_private(file->f_path.dentry->d_inode)
+                       ->crypt_stat;
        if (!crypt_stat
            || !ECRYPTFS_CHECK_FLAG(crypt_stat->flags, ECRYPTFS_ENCRYPTED)
            || ECRYPTFS_CHECK_FLAG(crypt_stat->flags, ECRYPTFS_NEW_FILE)) {
@@ -638,8 +638,8 @@ static int ecryptfs_commit_write(struct file *file, struct page *page,
        lower_inode = ecryptfs_inode_to_lower(inode);
        lower_file = ecryptfs_file_to_lower(file);
        mutex_lock(&lower_inode->i_mutex);
-       crypt_stat =
-               &ecryptfs_inode_to_private(file->f_dentry->d_inode)->crypt_stat;
+       crypt_stat = &ecryptfs_inode_to_private(file->f_path.dentry->d_inode)
+                               ->crypt_stat;
        if (ECRYPTFS_CHECK_FLAG(crypt_stat->flags, ECRYPTFS_NEW_FILE)) {
                ecryptfs_printk(KERN_DEBUG, "ECRYPTFS_NEW_FILE flag set in "
                        "crypt_stat at memory location [%p]\n", crypt_stat);
index 825757ae48676d6a488f64413316a7429b55fbbc..eaa5daaf106eec9aebb1271a1e3ae554a813c0a1 100644 (file)
@@ -50,7 +50,7 @@ static struct inode *ecryptfs_alloc_inode(struct super_block *sb)
        struct inode *inode = NULL;
 
        ecryptfs_inode = kmem_cache_alloc(ecryptfs_inode_info_cache,
-                                         SLAB_KERNEL);
+                                         GFP_KERNEL);
        if (unlikely(!ecryptfs_inode))
                goto out;
        ecryptfs_init_crypt_stat(&ecryptfs_inode->crypt_stat);
index 17f5b2d3c16a7071a18010926d574a26046569b1..b46c488eefc881d707a99c375b77a741ffbb3b0d 100644 (file)
@@ -20,7 +20,7 @@ struct inode_operations efs_dir_inode_operations = {
 };
 
 static int efs_readdir(struct file *filp, void *dirent, filldir_t filldir) {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct buffer_head *bh;
 
        struct efs_dir          *dirblock;
index b3f50651eb6bd1a979a2d2442c4294b48141780b..dfebf21289f4904a7ae784e1ab4c57ce97bafd6e 100644 (file)
@@ -52,12 +52,12 @@ static struct pt_types sgi_pt_types[] = {
 };
 
 
-static kmem_cache_t * efs_inode_cachep;
+static struct kmem_cache * efs_inode_cachep;
 
 static struct inode *efs_alloc_inode(struct super_block *sb)
 {
        struct efs_inode_info *ei;
-       ei = (struct efs_inode_info *)kmem_cache_alloc(efs_inode_cachep, SLAB_KERNEL);
+       ei = (struct efs_inode_info *)kmem_cache_alloc(efs_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        return &ei->vfs_inode;
@@ -68,7 +68,7 @@ static void efs_destroy_inode(struct inode *inode)
        kmem_cache_free(efs_inode_cachep, INODE_INFO(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct efs_inode_info *ei = (struct efs_inode_info *) foo;
 
index ae228ec54e948a63b25bb39f34577baa22fd06ed..3ae644e7e8606cddcdc1cb02791e51dfc73cb941 100644 (file)
@@ -283,10 +283,10 @@ static struct mutex epmutex;
 static struct poll_safewake psw;
 
 /* Slab cache used to allocate "struct epitem" */
-static kmem_cache_t *epi_cache __read_mostly;
+static struct kmem_cache *epi_cache __read_mostly;
 
 /* Slab cache used to allocate "struct eppoll_entry" */
-static kmem_cache_t *pwq_cache __read_mostly;
+static struct kmem_cache *pwq_cache __read_mostly;
 
 /* Virtual fs used to allocate inodes for eventpoll files */
 static struct vfsmount *eventpoll_mnt __read_mostly;
@@ -795,8 +795,8 @@ static int ep_getfd(int *efd, struct inode **einode, struct file **efile,
                goto eexit_4;
        dentry->d_op = &eventpollfs_dentry_operations;
        d_add(dentry, inode);
-       file->f_vfsmnt = mntget(eventpoll_mnt);
-       file->f_dentry = dentry;
+       file->f_path.mnt = mntget(eventpoll_mnt);
+       file->f_path.dentry = dentry;
        file->f_mapping = inode->i_mapping;
 
        file->f_pos = 0;
@@ -961,7 +961,7 @@ static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead,
        struct epitem *epi = ep_item_from_epqueue(pt);
        struct eppoll_entry *pwq;
 
-       if (epi->nwait >= 0 && (pwq = kmem_cache_alloc(pwq_cache, SLAB_KERNEL))) {
+       if (epi->nwait >= 0 && (pwq = kmem_cache_alloc(pwq_cache, GFP_KERNEL))) {
                init_waitqueue_func_entry(&pwq->wait, ep_poll_callback);
                pwq->whead = whead;
                pwq->base = epi;
@@ -1004,7 +1004,7 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event,
        struct ep_pqueue epq;
 
        error = -ENOMEM;
-       if (!(epi = kmem_cache_alloc(epi_cache, SLAB_KERNEL)))
+       if (!(epi = kmem_cache_alloc(epi_cache, GFP_KERNEL)))
                goto eexit_1;
 
        /* Item initialization follow here ... */
index d993ea1a81aee7b60cdc11ffc9ee18dd09a8658d..12d8cd461b412378fe8d16b8e39c7a330770a649 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -38,6 +38,7 @@
 #include <linux/binfmts.h>
 #include <linux/swap.h>
 #include <linux/utsname.h>
+#include <linux/pid_namespace.h>
 #include <linux/module.h>
 #include <linux/namei.h>
 #include <linux/proc_fs.h>
@@ -404,7 +405,7 @@ int setup_arg_pages(struct linux_binprm *bprm,
                bprm->loader += stack_base;
        bprm->exec += stack_base;
 
-       mpnt = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+       mpnt = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
        if (!mpnt)
                return -ENOMEM;
 
@@ -620,8 +621,8 @@ static int de_thread(struct task_struct *tsk)
         * Reparenting needs write_lock on tasklist_lock,
         * so it is safe to do it under read_lock.
         */
-       if (unlikely(tsk->group_leader == child_reaper))
-               child_reaper = tsk;
+       if (unlikely(tsk->group_leader == child_reaper(tsk)))
+               tsk->nsproxy->pid_ns->child_reaper = tsk;
 
        zap_other_threads(tsk);
        read_unlock(&tasklist_lock);
@@ -912,7 +913,7 @@ EXPORT_SYMBOL(flush_old_exec);
 int prepare_binprm(struct linux_binprm *bprm)
 {
        int mode;
-       struct inode * inode = bprm->file->f_dentry->d_inode;
+       struct inode * inode = bprm->file->f_path.dentry->d_inode;
        int retval;
 
        mode = inode->i_mode;
@@ -922,7 +923,7 @@ int prepare_binprm(struct linux_binprm *bprm)
        bprm->e_uid = current->euid;
        bprm->e_gid = current->egid;
 
-       if(!(bprm->file->f_vfsmnt->mnt_flags & MNT_NOSUID)) {
+       if(!(bprm->file->f_path.mnt->mnt_flags & MNT_NOSUID)) {
                /* Set-uid? */
                if (mode & S_ISUID) {
                        current->personality &= ~PER_CLEAR_ON_SETID;
@@ -1515,13 +1516,14 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
                ispipe = 1;
        } else
                file = filp_open(corename,
-                                O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE, 0600);
+                                O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag,
+                                0600);
        if (IS_ERR(file))
                goto fail_unlock;
-       inode = file->f_dentry->d_inode;
+       inode = file->f_path.dentry->d_inode;
        if (inode->i_nlink > 1)
                goto close_fail;        /* multiple links - don't dump */
-       if (!ispipe && d_unhashed(file->f_dentry))
+       if (!ispipe && d_unhashed(file->f_path.dentry))
                goto close_fail;
 
        /* AK: actually i see no reason to not allow this for named pipes etc.,
@@ -1532,7 +1534,7 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
                goto close_fail;
        if (!file->f_op->write)
                goto close_fail;
-       if (!ispipe && do_truncate(file->f_dentry, 0, 0, file) != 0)
+       if (!ispipe && do_truncate(file->f_path.dentry, 0, 0, file) != 0)
                goto close_fail;
 
        retval = binfmt->core_dump(signr, regs, file);
index 3e7a84a1e509a4aad71656e7bfeb8432d8a61460..0b02ba9642d2e817cb908f0ae10a37c6ae8366c4 100644 (file)
@@ -248,7 +248,7 @@ static int
 ext2_readdir (struct file * filp, void * dirent, filldir_t filldir)
 {
        loff_t pos = filp->f_pos;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct super_block *sb = inode->i_sb;
        unsigned int offset = pos & ~PAGE_CACHE_MASK;
        unsigned long n = pos >> PAGE_CACHE_SHIFT;
index 1dfba77eab10dc348e0ac3c4fa4e23d2448ac281..4b099d3107128bff377fff8d4774ca97e9d27cb4 100644 (file)
@@ -44,6 +44,7 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
                if (!S_ISDIR(inode->i_mode))
                        flags &= ~EXT2_DIRSYNC_FL;
 
+               mutex_lock(&inode->i_mutex);
                oldflags = ei->i_flags;
 
                /*
@@ -53,13 +54,16 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
                 * This test looks nicer. Thanks to Pauline Middelink
                 */
                if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
-                       if (!capable(CAP_LINUX_IMMUTABLE))
+                       if (!capable(CAP_LINUX_IMMUTABLE)) {
+                               mutex_unlock(&inode->i_mutex);
                                return -EPERM;
+                       }
                }
 
                flags = flags & EXT2_FL_USER_MODIFIABLE;
                flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
                ei->i_flags = flags;
+               mutex_unlock(&inode->i_mutex);
 
                ext2_set_inode_flags(inode);
                inode->i_ctime = CURRENT_TIME_SEC;
@@ -86,7 +90,7 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
 #ifdef CONFIG_COMPAT
 long ext2_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int ret;
 
        /* These are just misnamed, they actually get/put from/to user an int */
index d8b9abd95d07e4bf2fa81020856cd4026b766790..6347c2dbdd819ad405082e83cbaa2966be185d77 100644 (file)
@@ -135,12 +135,12 @@ static void ext2_put_super (struct super_block * sb)
        return;
 }
 
-static kmem_cache_t * ext2_inode_cachep;
+static struct kmem_cache * ext2_inode_cachep;
 
 static struct inode *ext2_alloc_inode(struct super_block *sb)
 {
        struct ext2_inode_info *ei;
-       ei = (struct ext2_inode_info *)kmem_cache_alloc(ext2_inode_cachep, SLAB_KERNEL);
+       ei = (struct ext2_inode_info *)kmem_cache_alloc(ext2_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
 #ifdef CONFIG_EXT2_FS_POSIX_ACL
@@ -156,7 +156,7 @@ static void ext2_destroy_inode(struct inode *inode)
        kmem_cache_free(ext2_inode_cachep, EXT2_I(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct ext2_inode_info *ei = (struct ext2_inode_info *) foo;
 
@@ -597,8 +597,6 @@ static int ext2_check_descriptors (struct super_block * sb)
        return 1;
 }
 
-#define log2(n) ffz(~(n))
 /*
  * Maximal file size.  There is a direct, and {,double-,triple-}indirect
  * block limit, and also a limit of (2^32 - 1) 512-byte sectors in i_blocks.
@@ -834,9 +832,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
        sbi->s_sbh = bh;
        sbi->s_mount_state = le16_to_cpu(es->s_state);
        sbi->s_addr_per_block_bits =
-               log2 (EXT2_ADDR_PER_BLOCK(sb));
+               ilog2 (EXT2_ADDR_PER_BLOCK(sb));
        sbi->s_desc_per_block_bits =
-               log2 (EXT2_DESC_PER_BLOCK(sb));
+               ilog2 (EXT2_DESC_PER_BLOCK(sb));
 
        if (sb->s_magic != EXT2_SUPER_MAGIC)
                goto cantfind_ext2;
@@ -1090,8 +1088,10 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
 {
        struct super_block *sb = dentry->d_sb;
        struct ext2_sb_info *sbi = EXT2_SB(sb);
+       struct ext2_super_block *es = sbi->s_es;
        unsigned long overhead;
        int i;
+       u64 fsid;
 
        if (test_opt (sb, MINIX_DF))
                overhead = 0;
@@ -1104,7 +1104,7 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
                 * All of the blocks before first_data_block are
                 * overhead
                 */
-               overhead = le32_to_cpu(sbi->s_es->s_first_data_block);
+               overhead = le32_to_cpu(es->s_first_data_block);
 
                /*
                 * Add the overhead attributed to the superblock and
@@ -1125,14 +1125,18 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
 
        buf->f_type = EXT2_SUPER_MAGIC;
        buf->f_bsize = sb->s_blocksize;
-       buf->f_blocks = le32_to_cpu(sbi->s_es->s_blocks_count) - overhead;
+       buf->f_blocks = le32_to_cpu(es->s_blocks_count) - overhead;
        buf->f_bfree = ext2_count_free_blocks(sb);
-       buf->f_bavail = buf->f_bfree - le32_to_cpu(sbi->s_es->s_r_blocks_count);
-       if (buf->f_bfree < le32_to_cpu(sbi->s_es->s_r_blocks_count))
+       buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count);
+       if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count))
                buf->f_bavail = 0;
-       buf->f_files = le32_to_cpu(sbi->s_es->s_inodes_count);
-       buf->f_ffree = ext2_count_free_inodes (sb);
+       buf->f_files = le32_to_cpu(es->s_inodes_count);
+       buf->f_ffree = ext2_count_free_inodes(sb);
        buf->f_namelen = EXT2_NAME_LEN;
+       fsid = le64_to_cpup((void *)es->s_uuid) ^
+              le64_to_cpup((void *)es->s_uuid + sizeof(u64));
+       buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
+       buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
        return 0;
 }
 
index af52a7f8b291d0baf3542246fb90703032cfbecc..247efd0b51d694e1206709672d8234e40b5405ed 100644 (file)
@@ -342,12 +342,9 @@ static void ext2_xattr_update_super_block(struct super_block *sb)
        if (EXT2_HAS_COMPAT_FEATURE(sb, EXT2_FEATURE_COMPAT_EXT_ATTR))
                return;
 
-       lock_super(sb);
-       EXT2_SB(sb)->s_es->s_feature_compat |=
-               cpu_to_le32(EXT2_FEATURE_COMPAT_EXT_ATTR);
+       EXT2_SET_COMPAT_FEATURE(sb, EXT2_FEATURE_COMPAT_EXT_ATTR);
        sb->s_dirt = 1;
        mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
-       unlock_super(sb);
 }
 
 /*
index 704cd44a40c256e10ccc097aae36f35dd32309ab..e77766a8b3f07a8f3e37f7f66ce917b5e79ea061 100644 (file)
@@ -5,7 +5,7 @@
 obj-$(CONFIG_EXT3_FS) += ext3.o
 
 ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
-          ioctl.o namei.o super.o symlink.o hash.o resize.o
+          ioctl.o namei.o super.o symlink.o hash.o resize.o ext3_jbd.o
 
 ext3-$(CONFIG_EXT3_FS_XATTR)    += xattr.o xattr_user.o xattr_trusted.o
 ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o
index b41a7d7e20f006bc7e85a6e4b2315cf38ee2fdc9..22161740ba295e7e1e650c571544cb9e6c2b5f3b 100644 (file)
@@ -144,7 +144,7 @@ restart:
 
        printk("Block Allocation Reservation Windows Map (%s):\n", fn);
        while (n) {
-               rsv = list_entry(n, struct ext3_reserve_window_node, rsv_node);
+               rsv = rb_entry(n, struct ext3_reserve_window_node, rsv_node);
                if (verbose)
                        printk("reservation window 0x%p "
                               "start:  %lu, end:  %lu\n",
@@ -730,7 +730,7 @@ find_next_usable_block(ext3_grpblk_t start, struct buffer_head *bh,
                here = 0;
 
        p = ((char *)bh->b_data) + (here >> 3);
-       r = memscan(p, 0, (maxblocks - here + 7) >> 3);
+       r = memscan(p, 0, ((maxblocks + 7) >> 3) - (here >> 3));
        next = (r - ((char *)bh->b_data)) << 3;
 
        if (next < maxblocks && next >= start && ext3_test_allocatable(next, bh))
@@ -949,7 +949,7 @@ static int find_next_reservable_window(
 
                prev = rsv;
                next = rb_next(&rsv->rsv_node);
-               rsv = list_entry(next,struct ext3_reserve_window_node,rsv_node);
+               rsv = rb_entry(next,struct ext3_reserve_window_node,rsv_node);
 
                /*
                 * Reached the last reservation, we can just append to the
@@ -1148,7 +1148,7 @@ retry:
         * check if the first free block is within the
         * free space we just reserved
         */
-       if (start_block >= my_rsv->rsv_start && start_block < my_rsv->rsv_end)
+       if (start_block >= my_rsv->rsv_start && start_block <= my_rsv->rsv_end)
                return 0;               /* success */
        /*
         * if the first free bit we found is out of the reservable space
@@ -1193,7 +1193,7 @@ static void try_to_extend_reservation(struct ext3_reserve_window_node *my_rsv,
        if (!next)
                my_rsv->rsv_end += size;
        else {
-               next_rsv = list_entry(next, struct ext3_reserve_window_node, rsv_node);
+               next_rsv = rb_entry(next, struct ext3_reserve_window_node, rsv_node);
 
                if ((next_rsv->rsv_start - my_rsv->rsv_end - 1) >= size)
                        my_rsv->rsv_end += size;
@@ -1271,7 +1271,7 @@ ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
        }
        /*
         * grp_goal is a group relative block number (if there is a goal)
-        * 0 < grp_goal < EXT3_BLOCKS_PER_GROUP(sb)
+        * 0 <= grp_goal < EXT3_BLOCKS_PER_GROUP(sb)
         * first block is a filesystem wide block number
         * first block is the block number of the first block in this group
         */
@@ -1307,10 +1307,14 @@ ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
                        if (!goal_in_my_reservation(&my_rsv->rsv_window,
                                                        grp_goal, group, sb))
                                grp_goal = -1;
-               } else if (grp_goal > 0 &&
-                         (my_rsv->rsv_end-grp_goal+1) < *count)
-                       try_to_extend_reservation(my_rsv, sb,
-                                       *count-my_rsv->rsv_end + grp_goal - 1);
+               } else if (grp_goal >= 0) {
+                       int curr = my_rsv->rsv_end -
+                                       (grp_goal + group_first_block) + 1;
+
+                       if (curr < *count)
+                               try_to_extend_reservation(my_rsv, sb,
+                                                       *count - curr);
+               }
 
                if ((my_rsv->rsv_start > group_last_block) ||
                                (my_rsv->rsv_end < group_first_block)) {
@@ -1511,10 +1515,8 @@ retry_alloc:
                if (group_no >= ngroups)
                        group_no = 0;
                gdp = ext3_get_group_desc(sb, group_no, &gdp_bh);
-               if (!gdp) {
-                       *errp = -EIO;
-                       goto out;
-               }
+               if (!gdp)
+                       goto io_error;
                free_blocks = le16_to_cpu(gdp->bg_free_blocks_count);
                /*
                 * skip this group if the number of
@@ -1548,6 +1550,7 @@ retry_alloc:
         */
        if (my_rsv) {
                my_rsv = NULL;
+               windowsz = 0;
                group_no = goal_group;
                goto retry_alloc;
        }
index d0b54f30b914e5304f367252e5f6a3bd96ac8d38..665adee99b311fbfce6ada8fb94ee163b4969bc4 100644 (file)
@@ -103,7 +103,7 @@ static int ext3_readdir(struct file * filp,
        struct ext3_dir_entry_2 *de;
        struct super_block *sb;
        int err;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        int ret = 0;
 
        sb = inode->i_sb;
@@ -122,7 +122,7 @@ static int ext3_readdir(struct file * filp,
                 * We don't set the inode dirty flag since it's not
                 * critical that it get flushed back to the disk.
                 */
-               EXT3_I(filp->f_dentry->d_inode)->i_flags &= ~EXT3_INDEX_FL;
+               EXT3_I(filp->f_path.dentry->d_inode)->i_flags &= ~EXT3_INDEX_FL;
        }
 #endif
        stored = 0;
@@ -154,6 +154,9 @@ static int ext3_readdir(struct file * filp,
                        ext3_error (sb, "ext3_readdir",
                                "directory #%lu contains a hole at offset %lu",
                                inode->i_ino, (unsigned long)filp->f_pos);
+                       /* corrupt size?  Maybe no more blocks to read */
+                       if (filp->f_pos > inode->i_blocks << 9)
+                               break;
                        filp->f_pos += sb->s_blocksize - offset;
                        continue;
                }
@@ -399,7 +402,7 @@ static int call_filldir(struct file * filp, void * dirent,
 {
        struct dir_private_info *info = filp->private_data;
        loff_t  curr_pos;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct super_block * sb;
        int error;
 
@@ -429,7 +432,7 @@ static int ext3_dx_readdir(struct file * filp,
                         void * dirent, filldir_t filldir)
 {
        struct dir_private_info *info = filp->private_data;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct fname *fname;
        int     ret;
 
diff --git a/fs/ext3/ext3_jbd.c b/fs/ext3/ext3_jbd.c
new file mode 100644 (file)
index 0000000..e1f91fd
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Interface between ext3 and JBD
+ */
+
+#include <linux/ext3_jbd.h>
+
+int __ext3_journal_get_undo_access(const char *where, handle_t *handle,
+                               struct buffer_head *bh)
+{
+       int err = journal_get_undo_access(handle, bh);
+       if (err)
+               ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+       return err;
+}
+
+int __ext3_journal_get_write_access(const char *where, handle_t *handle,
+                               struct buffer_head *bh)
+{
+       int err = journal_get_write_access(handle, bh);
+       if (err)
+               ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+       return err;
+}
+
+int __ext3_journal_forget(const char *where, handle_t *handle,
+                               struct buffer_head *bh)
+{
+       int err = journal_forget(handle, bh);
+       if (err)
+               ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+       return err;
+}
+
+int __ext3_journal_revoke(const char *where, handle_t *handle,
+                               unsigned long blocknr, struct buffer_head *bh)
+{
+       int err = journal_revoke(handle, blocknr, bh);
+       if (err)
+               ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+       return err;
+}
+
+int __ext3_journal_get_create_access(const char *where,
+                               handle_t *handle, struct buffer_head *bh)
+{
+       int err = journal_get_create_access(handle, bh);
+       if (err)
+               ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+       return err;
+}
+
+int __ext3_journal_dirty_metadata(const char *where,
+                               handle_t *handle, struct buffer_head *bh)
+{
+       int err = journal_dirty_metadata(handle, bh);
+       if (err)
+               ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+       return err;
+}
index e96c388047e09a0a89e1595b01ddc079745e9a0f..881f6365c41a329724b0a93fec4028eebec66d29 100644 (file)
@@ -52,7 +52,7 @@ ext3_file_write(struct kiocb *iocb, const struct iovec *iov,
                unsigned long nr_segs, loff_t pos)
 {
        struct file *file = iocb->ki_filp;
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        ssize_t ret;
        int err;
 
index 03ba5bcab18633725372096cd94c9e52b6aa83cc..beaf25f5112fd9f427a393bac3b9f12b634e14de 100644 (file)
@@ -1148,37 +1148,102 @@ static int do_journal_get_write_access(handle_t *handle,
        return ext3_journal_get_write_access(handle, bh);
 }
 
+/*
+ * The idea of this helper function is following:
+ * if prepare_write has allocated some blocks, but not all of them, the
+ * transaction must include the content of the newly allocated blocks.
+ * This content is expected to be set to zeroes by block_prepare_write().
+ * 2006/10/14  SAW
+ */
+static int ext3_prepare_failure(struct file *file, struct page *page,
+                               unsigned from, unsigned to)
+{
+       struct address_space *mapping;
+       struct buffer_head *bh, *head, *next;
+       unsigned block_start, block_end;
+       unsigned blocksize;
+       int ret;
+       handle_t *handle = ext3_journal_current_handle();
+
+       mapping = page->mapping;
+       if (ext3_should_writeback_data(mapping->host)) {
+               /* optimization: no constraints about data */
+skip:
+               return ext3_journal_stop(handle);
+       }
+
+       head = page_buffers(page);
+       blocksize = head->b_size;
+       for (   bh = head, block_start = 0;
+               bh != head || !block_start;
+               block_start = block_end, bh = next)
+       {
+               next = bh->b_this_page;
+               block_end = block_start + blocksize;
+               if (block_end <= from)
+                       continue;
+               if (block_start >= to) {
+                       block_start = to;
+                       break;
+               }
+               if (!buffer_mapped(bh))
+               /* prepare_write failed on this bh */
+                       break;
+               if (ext3_should_journal_data(mapping->host)) {
+                       ret = do_journal_get_write_access(handle, bh);
+                       if (ret) {
+                               ext3_journal_stop(handle);
+                               return ret;
+                       }
+               }
+       /*
+        * block_start here becomes the first block where the current iteration
+        * of prepare_write failed.
+        */
+       }
+       if (block_start <= from)
+               goto skip;
+
+       /* commit allocated and zeroed buffers */
+       return mapping->a_ops->commit_write(file, page, from, block_start);
+}
+
 static int ext3_prepare_write(struct file *file, struct page *page,
                              unsigned from, unsigned to)
 {
        struct inode *inode = page->mapping->host;
-       int ret, needed_blocks = ext3_writepage_trans_blocks(inode);
+       int ret, ret2;
+       int needed_blocks = ext3_writepage_trans_blocks(inode);
        handle_t *handle;
        int retries = 0;
 
 retry:
        handle = ext3_journal_start(inode, needed_blocks);
-       if (IS_ERR(handle)) {
-               ret = PTR_ERR(handle);
-               goto out;
-       }
+       if (IS_ERR(handle))
+               return PTR_ERR(handle);
        if (test_opt(inode->i_sb, NOBH) && ext3_should_writeback_data(inode))
                ret = nobh_prepare_write(page, from, to, ext3_get_block);
        else
                ret = block_prepare_write(page, from, to, ext3_get_block);
        if (ret)
-               goto prepare_write_failed;
+               goto failure;
 
        if (ext3_should_journal_data(inode)) {
                ret = walk_page_buffers(handle, page_buffers(page),
                                from, to, NULL, do_journal_get_write_access);
+               if (ret)
+                       /* fatal error, just put the handle and return */
+                       journal_stop(handle);
        }
-prepare_write_failed:
-       if (ret)
-               ext3_journal_stop(handle);
+       return ret;
+
+failure:
+       ret2 = ext3_prepare_failure(file, page, from, to);
+       if (ret2 < 0)
+               return ret2;
        if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries))
                goto retry;
-out:
+       /* retry number exceeded, or other error like -EDQUOT */
        return ret;
 }
 
index 12daa68695721ffaf4a06bfa087d2018fceeb845..9b8090d94e6c4c1702914478a6ba859c93e2ed22 100644 (file)
@@ -257,7 +257,7 @@ flags_err:
 #ifdef CONFIG_COMPAT
 long ext3_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int ret;
 
        /* These are just misnamed, they actually get/put from/to user an int */
index 906731a20f1ae37c4f7be8999d72d7986cbabadd..4df39c4315e170c64e12ca6755f456d6b19b1e39 100644 (file)
@@ -552,6 +552,15 @@ static int htree_dirblock_to_tree(struct file *dir_file,
                                           dir->i_sb->s_blocksize -
                                           EXT3_DIR_REC_LEN(0));
        for (; de < top; de = ext3_next_entry(de)) {
+               if (!ext3_check_dir_entry("htree_dirblock_to_tree", dir, de, bh,
+                                       (block<<EXT3_BLOCK_SIZE_BITS(dir->i_sb))
+                                               +((char *)de - bh->b_data))) {
+                       /* On error, skip the f_pos to the next block. */
+                       dir_file->f_pos = (dir_file->f_pos |
+                                       (dir->i_sb->s_blocksize - 1)) + 1;
+                       brelse (bh);
+                       return count;
+               }
                ext3fs_dirhash(de->name, de->name_len, hinfo);
                if ((hinfo->hash < start_hash) ||
                    ((hinfo->hash == start_hash) &&
@@ -593,7 +602,7 @@ int ext3_htree_fill_tree(struct file *dir_file, __u32 start_hash,
 
        dxtrace(printk("In htree_fill_tree, start hash: %x:%x\n", start_hash,
                       start_minor_hash));
-       dir = dir_file->f_dentry->d_inode;
+       dir = dir_file->f_path.dentry->d_inode;
        if (!(EXT3_I(dir)->i_flags & EXT3_INDEX_FL)) {
                hinfo.hash_version = EXT3_SB(dir->i_sb)->s_def_hash_version;
                hinfo.seed = EXT3_SB(dir->i_sb)->s_hash_seed;
@@ -604,7 +613,7 @@ int ext3_htree_fill_tree(struct file *dir_file, __u32 start_hash,
        }
        hinfo.hash = start_hash;
        hinfo.minor_hash = 0;
-       frame = dx_probe(NULL, dir_file->f_dentry->d_inode, &hinfo, frames, &err);
+       frame = dx_probe(NULL, dir_file->f_path.dentry->d_inode, &hinfo, frames, &err);
        if (!frame)
                return err;
 
index afc2d4f42d7782800f6d65dfc49c6aebc1925169..b34886734a44d0417221231ba454bd6aa5aba2a5 100644 (file)
@@ -436,7 +436,7 @@ static void ext3_put_super (struct super_block * sb)
        return;
 }
 
-static kmem_cache_t *ext3_inode_cachep;
+static struct kmem_cache *ext3_inode_cachep;
 
 /*
  * Called inside transaction, so use GFP_NOFS
@@ -445,7 +445,7 @@ static struct inode *ext3_alloc_inode(struct super_block *sb)
 {
        struct ext3_inode_info *ei;
 
-       ei = kmem_cache_alloc(ext3_inode_cachep, SLAB_NOFS);
+       ei = kmem_cache_alloc(ext3_inode_cachep, GFP_NOFS);
        if (!ei)
                return NULL;
 #ifdef CONFIG_EXT3_FS_POSIX_ACL
@@ -462,7 +462,7 @@ static void ext3_destroy_inode(struct inode *inode)
        kmem_cache_free(ext3_inode_cachep, EXT3_I(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct ext3_inode_info *ei = (struct ext3_inode_info *) foo;
 
@@ -1264,6 +1264,12 @@ static void ext3_orphan_cleanup (struct super_block * sb,
                return;
        }
 
+       if (bdev_read_only(sb->s_bdev)) {
+               printk(KERN_ERR "EXT3-fs: write access "
+                       "unavailable, skipping orphan cleanup.\n");
+               return;
+       }
+
        if (EXT3_SB(sb)->s_mount_state & EXT3_ERROR_FS) {
                if (es->s_last_orphan)
                        jbd_debug(1, "Errors on filesystem, "
@@ -1341,8 +1347,6 @@ static void ext3_orphan_cleanup (struct super_block * sb,
        sb->s_flags = s_flags; /* Restore MS_RDONLY status */
 }
 
-#define log2(n) ffz(~(n))
-
 /*
  * Maximal file size.  There is a direct, and {,double-,triple-}indirect
  * block limit, and also a limit of (2^32 - 1) 512-byte sectors in i_blocks.
@@ -1591,8 +1595,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
        sbi->s_desc_per_block = blocksize / sizeof(struct ext3_group_desc);
        sbi->s_sbh = bh;
        sbi->s_mount_state = le16_to_cpu(es->s_state);
-       sbi->s_addr_per_block_bits = log2(EXT3_ADDR_PER_BLOCK(sb));
-       sbi->s_desc_per_block_bits = log2(EXT3_DESC_PER_BLOCK(sb));
+       sbi->s_addr_per_block_bits = ilog2(EXT3_ADDR_PER_BLOCK(sb));
+       sbi->s_desc_per_block_bits = ilog2(EXT3_DESC_PER_BLOCK(sb));
        for (i=0; i < 4; i++)
                sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]);
        sbi->s_def_hash_version = es->s_def_hash_version;
@@ -2387,6 +2391,7 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf)
        struct ext3_super_block *es = sbi->s_es;
        ext3_fsblk_t overhead;
        int i;
+       u64 fsid;
 
        if (test_opt (sb, MINIX_DF))
                overhead = 0;
@@ -2433,6 +2438,10 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf)
        buf->f_files = le32_to_cpu(es->s_inodes_count);
        buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter);
        buf->f_namelen = EXT3_NAME_LEN;
+       fsid = le64_to_cpup((void *)es->s_uuid) ^
+              le64_to_cpup((void *)es->s_uuid + sizeof(u64));
+       buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
+       buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
        return 0;
 }
 
index f86f2482f01df3a87b8a25ef9941fcc5a3a68b93..99857a400f4be217dcf92e5f16ac6c62783b62e2 100644 (file)
@@ -459,14 +459,11 @@ static void ext3_xattr_update_super_block(handle_t *handle,
        if (EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_EXT_ATTR))
                return;
 
-       lock_super(sb);
        if (ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh) == 0) {
-               EXT3_SB(sb)->s_es->s_feature_compat |=
-                       cpu_to_le32(EXT3_FEATURE_COMPAT_EXT_ATTR);
+               EXT3_SET_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_EXT_ATTR);
                sb->s_dirt = 1;
                ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
        }
-       unlock_super(sb);
 }
 
 /*
index a6acb96ebeb9b004324632cb867412850f75938d..ae6e7e502ac9c0d5585370ba0c051410ab766ad8 100644 (file)
@@ -5,7 +5,8 @@
 obj-$(CONFIG_EXT4DEV_FS) += ext4dev.o
 
 ext4dev-y      := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
-          ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o
+                  ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o \
+                  ext4_jbd2.o
 
 ext4dev-$(CONFIG_EXT4DEV_FS_XATTR)     += xattr.o xattr_user.o xattr_trusted.o
 ext4dev-$(CONFIG_EXT4DEV_FS_POSIX_ACL) += acl.o
index 5d45582f9517e35bacb67405d737190aaef128be..c4dd1103ccf1033f70af475bbf26ff3a2c107cc8 100644 (file)
@@ -165,7 +165,7 @@ restart:
 
        printk("Block Allocation Reservation Windows Map (%s):\n", fn);
        while (n) {
-               rsv = list_entry(n, struct ext4_reserve_window_node, rsv_node);
+               rsv = rb_entry(n, struct ext4_reserve_window_node, rsv_node);
                if (verbose)
                        printk("reservation window 0x%p "
                               "start:  %llu, end:  %llu\n",
@@ -747,7 +747,7 @@ find_next_usable_block(ext4_grpblk_t start, struct buffer_head *bh,
                here = 0;
 
        p = ((char *)bh->b_data) + (here >> 3);
-       r = memscan(p, 0, (maxblocks - here + 7) >> 3);
+       r = memscan(p, 0, ((maxblocks + 7) >> 3) - (here >> 3));
        next = (r - ((char *)bh->b_data)) << 3;
 
        if (next < maxblocks && next >= start && ext4_test_allocatable(next, bh))
@@ -966,7 +966,7 @@ static int find_next_reservable_window(
 
                prev = rsv;
                next = rb_next(&rsv->rsv_node);
-               rsv = list_entry(next,struct ext4_reserve_window_node,rsv_node);
+               rsv = rb_entry(next,struct ext4_reserve_window_node,rsv_node);
 
                /*
                 * Reached the last reservation, we can just append to the
@@ -1165,7 +1165,7 @@ retry:
         * check if the first free block is within the
         * free space we just reserved
         */
-       if (start_block >= my_rsv->rsv_start && start_block < my_rsv->rsv_end)
+       if (start_block >= my_rsv->rsv_start && start_block <= my_rsv->rsv_end)
                return 0;               /* success */
        /*
         * if the first free bit we found is out of the reservable space
@@ -1210,7 +1210,7 @@ static void try_to_extend_reservation(struct ext4_reserve_window_node *my_rsv,
        if (!next)
                my_rsv->rsv_end += size;
        else {
-               next_rsv = list_entry(next, struct ext4_reserve_window_node, rsv_node);
+               next_rsv = rb_entry(next, struct ext4_reserve_window_node, rsv_node);
 
                if ((next_rsv->rsv_start - my_rsv->rsv_end - 1) >= size)
                        my_rsv->rsv_end += size;
@@ -1288,7 +1288,7 @@ ext4_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
        }
        /*
         * grp_goal is a group relative block number (if there is a goal)
-        * 0 < grp_goal < EXT4_BLOCKS_PER_GROUP(sb)
+        * 0 <= grp_goal < EXT4_BLOCKS_PER_GROUP(sb)
         * first block is a filesystem wide block number
         * first block is the block number of the first block in this group
         */
@@ -1324,10 +1324,14 @@ ext4_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
                        if (!goal_in_my_reservation(&my_rsv->rsv_window,
                                                        grp_goal, group, sb))
                                grp_goal = -1;
-               } else if (grp_goal > 0 &&
-                         (my_rsv->rsv_end-grp_goal+1) < *count)
-                       try_to_extend_reservation(my_rsv, sb,
-                                       *count-my_rsv->rsv_end + grp_goal - 1);
+               } else if (grp_goal >= 0) {
+                       int curr = my_rsv->rsv_end -
+                                       (grp_goal + group_first_block) + 1;
+
+                       if (curr < *count)
+                               try_to_extend_reservation(my_rsv, sb,
+                                                       *count - curr);
+               }
 
                if ((my_rsv->rsv_start > group_last_block) ||
                                (my_rsv->rsv_end < group_first_block)) {
@@ -1525,10 +1529,8 @@ retry_alloc:
                if (group_no >= ngroups)
                        group_no = 0;
                gdp = ext4_get_group_desc(sb, group_no, &gdp_bh);
-               if (!gdp) {
-                       *errp = -EIO;
-                       goto out;
-               }
+               if (!gdp)
+                       goto io_error;
                free_blocks = le16_to_cpu(gdp->bg_free_blocks_count);
                /*
                 * skip this group if the number of
@@ -1562,6 +1564,7 @@ retry_alloc:
         */
        if (my_rsv) {
                my_rsv = NULL;
+               windowsz = 0;
                group_no = goal_group;
                goto retry_alloc;
        }
index f8595787a70e0d70fb570f05fd887e70fa91027a..da80368b66f0f7ca4310b03ccb59b359ff80118e 100644 (file)
@@ -103,7 +103,7 @@ static int ext4_readdir(struct file * filp,
        struct ext4_dir_entry_2 *de;
        struct super_block *sb;
        int err;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        int ret = 0;
 
        sb = inode->i_sb;
@@ -122,7 +122,7 @@ static int ext4_readdir(struct file * filp,
                 * We don't set the inode dirty flag since it's not
                 * critical that it get flushed back to the disk.
                 */
-               EXT4_I(filp->f_dentry->d_inode)->i_flags &= ~EXT4_INDEX_FL;
+               EXT4_I(filp->f_path.dentry->d_inode)->i_flags &= ~EXT4_INDEX_FL;
        }
 #endif
        stored = 0;
@@ -153,6 +153,9 @@ static int ext4_readdir(struct file * filp,
                        ext4_error (sb, "ext4_readdir",
                                "directory #%lu contains a hole at offset %lu",
                                inode->i_ino, (unsigned long)filp->f_pos);
+                       /* corrupt size?  Maybe no more blocks to read */
+                       if (filp->f_pos > inode->i_blocks << 9)
+                               break;
                        filp->f_pos += sb->s_blocksize - offset;
                        continue;
                }
@@ -399,7 +402,7 @@ static int call_filldir(struct file * filp, void * dirent,
 {
        struct dir_private_info *info = filp->private_data;
        loff_t  curr_pos;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct super_block * sb;
        int error;
 
@@ -429,7 +432,7 @@ static int ext4_dx_readdir(struct file * filp,
                         void * dirent, filldir_t filldir)
 {
        struct dir_private_info *info = filp->private_data;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct fname *fname;
        int     ret;
 
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
new file mode 100644 (file)
index 0000000..d6afe4e
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Interface between ext4 and JBD
+ */
+
+#include <linux/ext4_jbd2.h>
+
+int __ext4_journal_get_undo_access(const char *where, handle_t *handle,
+                               struct buffer_head *bh)
+{
+       int err = jbd2_journal_get_undo_access(handle, bh);
+       if (err)
+               ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+       return err;
+}
+
+int __ext4_journal_get_write_access(const char *where, handle_t *handle,
+                               struct buffer_head *bh)
+{
+       int err = jbd2_journal_get_write_access(handle, bh);
+       if (err)
+               ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+       return err;
+}
+
+int __ext4_journal_forget(const char *where, handle_t *handle,
+                               struct buffer_head *bh)
+{
+       int err = jbd2_journal_forget(handle, bh);
+       if (err)
+               ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+       return err;
+}
+
+int __ext4_journal_revoke(const char *where, handle_t *handle,
+                               ext4_fsblk_t blocknr, struct buffer_head *bh)
+{
+       int err = jbd2_journal_revoke(handle, blocknr, bh);
+       if (err)
+               ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+       return err;
+}
+
+int __ext4_journal_get_create_access(const char *where,
+                               handle_t *handle, struct buffer_head *bh)
+{
+       int err = jbd2_journal_get_create_access(handle, bh);
+       if (err)
+               ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+       return err;
+}
+
+int __ext4_journal_dirty_metadata(const char *where,
+                               handle_t *handle, struct buffer_head *bh)
+{
+       int err = jbd2_journal_dirty_metadata(handle, bh);
+       if (err)
+               ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+       return err;
+}
index 2608dce18f3e7f50461e1fe84225a24555b1da26..dc2724fa7622b2b1492d0d547425e6dcc1e7e35c 100644 (file)
@@ -48,7 +48,7 @@
  * ext_pblock:
  * combine low and high parts of physical block number into ext4_fsblk_t
  */
-static inline ext4_fsblk_t ext_pblock(struct ext4_extent *ex)
+static ext4_fsblk_t ext_pblock(struct ext4_extent *ex)
 {
        ext4_fsblk_t block;
 
@@ -61,7 +61,7 @@ static inline ext4_fsblk_t ext_pblock(struct ext4_extent *ex)
  * idx_pblock:
  * combine low and high parts of a leaf physical block number into ext4_fsblk_t
  */
-static inline ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix)
+static ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix)
 {
        ext4_fsblk_t block;
 
@@ -75,7 +75,7 @@ static inline ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix)
  * stores a large physical block number into an extent struct,
  * breaking it into parts
  */
-static inline void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb)
+static void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb)
 {
        ex->ee_start = cpu_to_le32((unsigned long) (pb & 0xffffffff));
        ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
@@ -86,7 +86,7 @@ static inline void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb
  * stores a large physical block number into an index struct,
  * breaking it into parts
  */
-static inline void ext4_idx_store_pblock(struct ext4_extent_idx *ix, ext4_fsblk_t pb)
+static void ext4_idx_store_pblock(struct ext4_extent_idx *ix, ext4_fsblk_t pb)
 {
        ix->ei_leaf = cpu_to_le32((unsigned long) (pb & 0xffffffff));
        ix->ei_leaf_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
@@ -186,7 +186,8 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode,
                depth = path->p_depth;
 
                /* try to predict block placement */
-               if ((ex = path[depth].p_ext))
+               ex = path[depth].p_ext;
+               if (ex)
                        return ext_pblock(ex)+(block-le32_to_cpu(ex->ee_block));
 
                /* it looks like index is empty;
@@ -215,7 +216,7 @@ ext4_ext_new_block(handle_t *handle, struct inode *inode,
        return newblock;
 }
 
-static inline int ext4_ext_space_block(struct inode *inode)
+static int ext4_ext_space_block(struct inode *inode)
 {
        int size;
 
@@ -228,7 +229,7 @@ static inline int ext4_ext_space_block(struct inode *inode)
        return size;
 }
 
-static inline int ext4_ext_space_block_idx(struct inode *inode)
+static int ext4_ext_space_block_idx(struct inode *inode)
 {
        int size;
 
@@ -241,7 +242,7 @@ static inline int ext4_ext_space_block_idx(struct inode *inode)
        return size;
 }
 
-static inline int ext4_ext_space_root(struct inode *inode)
+static int ext4_ext_space_root(struct inode *inode)
 {
        int size;
 
@@ -255,7 +256,7 @@ static inline int ext4_ext_space_root(struct inode *inode)
        return size;
 }
 
-static inline int ext4_ext_space_root_idx(struct inode *inode)
+static int ext4_ext_space_root_idx(struct inode *inode)
 {
        int size;
 
@@ -476,13 +477,12 @@ ext4_ext_find_extent(struct inode *inode, int block, struct ext4_ext_path *path)
 
        /* account possible depth increase */
        if (!path) {
-               path = kmalloc(sizeof(struct ext4_ext_path) * (depth + 2),
+               path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 2),
                                GFP_NOFS);
                if (!path)
                        return ERR_PTR(-ENOMEM);
                alloc = 1;
        }
-       memset(path, 0, sizeof(struct ext4_ext_path) * (depth + 1));
        path[0].p_hdr = eh;
 
        /* walk through the tree */
@@ -543,7 +543,8 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
        struct ext4_extent_idx *ix;
        int len, err;
 
-       if ((err = ext4_ext_get_access(handle, inode, curp)))
+       err = ext4_ext_get_access(handle, inode, curp);
+       if (err)
                return err;
 
        BUG_ON(logical == le32_to_cpu(curp->p_idx->ei_block));
@@ -641,10 +642,9 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
         * We need this to handle errors and free blocks
         * upon them.
         */
-       ablocks = kmalloc(sizeof(ext4_fsblk_t) * depth, GFP_NOFS);
+       ablocks = kzalloc(sizeof(ext4_fsblk_t) * depth, GFP_NOFS);
        if (!ablocks)
                return -ENOMEM;
-       memset(ablocks, 0, sizeof(ext4_fsblk_t) * depth);
 
        /* allocate all needed blocks */
        ext_debug("allocate %d blocks for indexes/leaf\n", depth - at);
@@ -665,7 +665,8 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
        }
        lock_buffer(bh);
 
-       if ((err = ext4_journal_get_create_access(handle, bh)))
+       err = ext4_journal_get_create_access(handle, bh);
+       if (err)
                goto cleanup;
 
        neh = ext_block_hdr(bh);
@@ -702,18 +703,21 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
        set_buffer_uptodate(bh);
        unlock_buffer(bh);
 
-       if ((err = ext4_journal_dirty_metadata(handle, bh)))
+       err = ext4_journal_dirty_metadata(handle, bh);
+       if (err)
                goto cleanup;
        brelse(bh);
        bh = NULL;
 
        /* correct old leaf */
        if (m) {
-               if ((err = ext4_ext_get_access(handle, inode, path + depth)))
+               err = ext4_ext_get_access(handle, inode, path + depth);
+               if (err)
                        goto cleanup;
                path[depth].p_hdr->eh_entries =
                     cpu_to_le16(le16_to_cpu(path[depth].p_hdr->eh_entries)-m);
-               if ((err = ext4_ext_dirty(handle, inode, path + depth)))
+               err = ext4_ext_dirty(handle, inode, path + depth);
+               if (err)
                        goto cleanup;
 
        }
@@ -736,7 +740,8 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
                }
                lock_buffer(bh);
 
-               if ((err = ext4_journal_get_create_access(handle, bh)))
+               err = ext4_journal_get_create_access(handle, bh);
+               if (err)
                        goto cleanup;
 
                neh = ext_block_hdr(bh);
@@ -780,7 +785,8 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
                set_buffer_uptodate(bh);
                unlock_buffer(bh);
 
-               if ((err = ext4_journal_dirty_metadata(handle, bh)))
+               err = ext4_journal_dirty_metadata(handle, bh);
+               if (err)
                        goto cleanup;
                brelse(bh);
                bh = NULL;
@@ -800,9 +806,6 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
        }
 
        /* insert new index */
-       if (err)
-               goto cleanup;
-
        err = ext4_ext_insert_index(handle, inode, path + at,
                                    le32_to_cpu(border), newblock);
 
@@ -857,7 +860,8 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
        }
        lock_buffer(bh);
 
-       if ((err = ext4_journal_get_create_access(handle, bh))) {
+       err = ext4_journal_get_create_access(handle, bh);
+       if (err) {
                unlock_buffer(bh);
                goto out;
        }
@@ -877,11 +881,13 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
        set_buffer_uptodate(bh);
        unlock_buffer(bh);
 
-       if ((err = ext4_journal_dirty_metadata(handle, bh)))
+       err = ext4_journal_dirty_metadata(handle, bh);
+       if (err)
                goto out;
 
        /* create index in new top-level index: num,max,pointer */
-       if ((err = ext4_ext_get_access(handle, inode, curp)))
+       err = ext4_ext_get_access(handle, inode, curp);
+       if (err)
                goto out;
 
        curp->p_hdr->eh_magic = EXT4_EXT_MAGIC;
@@ -1073,27 +1079,31 @@ int ext4_ext_correct_indexes(handle_t *handle, struct inode *inode,
         */
        k = depth - 1;
        border = path[depth].p_ext->ee_block;
-       if ((err = ext4_ext_get_access(handle, inode, path + k)))
+       err = ext4_ext_get_access(handle, inode, path + k);
+       if (err)
                return err;
        path[k].p_idx->ei_block = border;
-       if ((err = ext4_ext_dirty(handle, inode, path + k)))
+       err = ext4_ext_dirty(handle, inode, path + k);
+       if (err)
                return err;
 
        while (k--) {
                /* change all left-side indexes */
                if (path[k+1].p_idx != EXT_FIRST_INDEX(path[k+1].p_hdr))
                        break;
-               if ((err = ext4_ext_get_access(handle, inode, path + k)))
+               err = ext4_ext_get_access(handle, inode, path + k);
+               if (err)
                        break;
                path[k].p_idx->ei_block = border;
-               if ((err = ext4_ext_dirty(handle, inode, path + k)))
+               err = ext4_ext_dirty(handle, inode, path + k);
+               if (err)
                        break;
        }
 
        return err;
 }
 
-static int inline
+static int
 ext4_can_extents_be_merged(struct inode *inode, struct ext4_extent *ex1,
                                struct ext4_extent *ex2)
 {
@@ -1145,7 +1155,8 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode,
                                le16_to_cpu(newext->ee_len),
                                le32_to_cpu(ex->ee_block),
                                le16_to_cpu(ex->ee_len), ext_pblock(ex));
-               if ((err = ext4_ext_get_access(handle, inode, path + depth)))
+               err = ext4_ext_get_access(handle, inode, path + depth);
+               if (err)
                        return err;
                ex->ee_len = cpu_to_le16(le16_to_cpu(ex->ee_len)
                                         + le16_to_cpu(newext->ee_len));
@@ -1195,7 +1206,8 @@ repeat:
 has_space:
        nearex = path[depth].p_ext;
 
-       if ((err = ext4_ext_get_access(handle, inode, path + depth)))
+       err = ext4_ext_get_access(handle, inode, path + depth);
+       if (err)
                goto cleanup;
 
        if (!nearex) {
@@ -1383,7 +1395,7 @@ int ext4_ext_walk_space(struct inode *inode, unsigned long block,
        return err;
 }
 
-static inline void
+static void
 ext4_ext_put_in_cache(struct inode *inode, __u32 block,
                        __u32 len, __u32 start, int type)
 {
@@ -1401,7 +1413,7 @@ ext4_ext_put_in_cache(struct inode *inode, __u32 block,
  * calculate boundaries of the gap that the requested block fits into
  * and cache this gap
  */
-static inline void
+static void
 ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path,
                                unsigned long block)
 {
@@ -1442,7 +1454,7 @@ ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path,
        ext4_ext_put_in_cache(inode, lblock, len, 0, EXT4_EXT_CACHE_GAP);
 }
 
-static inline int
+static int
 ext4_ext_in_cache(struct inode *inode, unsigned long block,
                        struct ext4_extent *ex)
 {
@@ -1489,10 +1501,12 @@ int ext4_ext_rm_idx(handle_t *handle, struct inode *inode,
        path--;
        leaf = idx_pblock(path->p_idx);
        BUG_ON(path->p_hdr->eh_entries == 0);
-       if ((err = ext4_ext_get_access(handle, inode, path)))
+       err = ext4_ext_get_access(handle, inode, path);
+       if (err)
                return err;
        path->p_hdr->eh_entries = cpu_to_le16(le16_to_cpu(path->p_hdr->eh_entries)-1);
-       if ((err = ext4_ext_dirty(handle, inode, path)))
+       err = ext4_ext_dirty(handle, inode, path);
+       if (err)
                return err;
        ext_debug("index is empty, remove it, free block %llu\n", leaf);
        bh = sb_find_get_block(inode->i_sb, leaf);
@@ -1509,7 +1523,7 @@ int ext4_ext_rm_idx(handle_t *handle, struct inode *inode,
  * the caller should calculate credits under truncate_mutex and
  * pass the actual path.
  */
-int inline ext4_ext_calc_credits_for_insert(struct inode *inode,
+int ext4_ext_calc_credits_for_insert(struct inode *inode,
                                                struct ext4_ext_path *path)
 {
        int depth, needed;
@@ -1534,16 +1548,17 @@ int inline ext4_ext_calc_credits_for_insert(struct inode *inode,
 
        /*
         * tree can be full, so it would need to grow in depth:
-        * allocation + old root + new root
+        * we need one credit to modify old root, credits for
+        * new root will be added in split accounting
         */
-       needed += 2 + 1 + 1;
+       needed += 1;
 
        /*
         * Index split can happen, we would need:
         *    allocate intermediate indexes (bitmap + group)
         *  + change two blocks at each level, but root (already included)
         */
-       needed = (depth * 2) + (depth * 2);
+       needed += (depth * 2) + (depth * 2);
 
        /* any allocation modifies superblock */
        needed += 1;
@@ -1718,7 +1733,7 @@ out:
  * ext4_ext_more_to_rm:
  * returns 1 if current index has to be freed (even partial)
  */
-static int inline
+static int
 ext4_ext_more_to_rm(struct ext4_ext_path *path)
 {
        BUG_ON(path->p_idx == NULL);
@@ -1756,12 +1771,11 @@ int ext4_ext_remove_space(struct inode *inode, unsigned long start)
         * We start scanning from right side, freeing all the blocks
         * after i_size and walking into the tree depth-wise.
         */
-       path = kmalloc(sizeof(struct ext4_ext_path) * (depth + 1), GFP_KERNEL);
+       path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1), GFP_KERNEL);
        if (path == NULL) {
                ext4_journal_stop(handle);
                return -ENOMEM;
        }
-       memset(path, 0, sizeof(struct ext4_ext_path) * (depth + 1));
        path[0].p_hdr = ext_inode_hdr(inode);
        if (ext4_ext_check_header(__FUNCTION__, inode, path[0].p_hdr)) {
                err = -EIO;
@@ -1932,7 +1946,8 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
        mutex_lock(&EXT4_I(inode)->truncate_mutex);
 
        /* check in cache */
-       if ((goal = ext4_ext_in_cache(inode, iblock, &newex))) {
+       goal = ext4_ext_in_cache(inode, iblock, &newex);
+       if (goal) {
                if (goal == EXT4_EXT_CACHE_GAP) {
                        if (!create) {
                                /* block isn't allocated yet and
@@ -1971,7 +1986,8 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
         */
        BUG_ON(path[depth].p_ext == NULL && depth != 0);
 
-       if ((ex = path[depth].p_ext)) {
+       ex = path[depth].p_ext;
+       if (ex) {
                unsigned long ee_block = le32_to_cpu(ex->ee_block);
                ext4_fsblk_t ee_start = ext_pblock(ex);
                unsigned short ee_len  = le16_to_cpu(ex->ee_len);
index 0b622c0624b71ad288d1b56257ca59d942f70f86..3bbc24b587858b97f6ebb0b492b65091158b77c2 100644 (file)
@@ -52,7 +52,7 @@ ext4_file_write(struct kiocb *iocb, const struct iovec *iov,
                unsigned long nr_segs, loff_t pos)
 {
        struct file *file = iocb->ki_filp;
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        ssize_t ret;
        int err;
 
index 0a60ec5a16dbc4bb92645dfafcd644e895d05161..a127cc03c9fa2868739ded1b98c7cd6d0d7ecc8b 100644 (file)
@@ -1147,37 +1147,102 @@ static int do_journal_get_write_access(handle_t *handle,
        return ext4_journal_get_write_access(handle, bh);
 }
 
+/*
+ * The idea of this helper function is following:
+ * if prepare_write has allocated some blocks, but not all of them, the
+ * transaction must include the content of the newly allocated blocks.
+ * This content is expected to be set to zeroes by block_prepare_write().
+ * 2006/10/14  SAW
+ */
+static int ext4_prepare_failure(struct file *file, struct page *page,
+                               unsigned from, unsigned to)
+{
+       struct address_space *mapping;
+       struct buffer_head *bh, *head, *next;
+       unsigned block_start, block_end;
+       unsigned blocksize;
+       int ret;
+       handle_t *handle = ext4_journal_current_handle();
+
+       mapping = page->mapping;
+       if (ext4_should_writeback_data(mapping->host)) {
+               /* optimization: no constraints about data */
+skip:
+               return ext4_journal_stop(handle);
+       }
+
+       head = page_buffers(page);
+       blocksize = head->b_size;
+       for (   bh = head, block_start = 0;
+               bh != head || !block_start;
+               block_start = block_end, bh = next)
+       {
+               next = bh->b_this_page;
+               block_end = block_start + blocksize;
+               if (block_end <= from)
+                       continue;
+               if (block_start >= to) {
+                       block_start = to;
+                       break;
+               }
+               if (!buffer_mapped(bh))
+               /* prepare_write failed on this bh */
+                       break;
+               if (ext4_should_journal_data(mapping->host)) {
+                       ret = do_journal_get_write_access(handle, bh);
+                       if (ret) {
+                               ext4_journal_stop(handle);
+                               return ret;
+                       }
+               }
+       /*
+        * block_start here becomes the first block where the current iteration
+        * of prepare_write failed.
+        */
+       }
+       if (block_start <= from)
+               goto skip;
+
+       /* commit allocated and zeroed buffers */
+       return mapping->a_ops->commit_write(file, page, from, block_start);
+}
+
 static int ext4_prepare_write(struct file *file, struct page *page,
                              unsigned from, unsigned to)
 {
        struct inode *inode = page->mapping->host;
-       int ret, needed_blocks = ext4_writepage_trans_blocks(inode);
+       int ret, ret2;
+       int needed_blocks = ext4_writepage_trans_blocks(inode);
        handle_t *handle;
        int retries = 0;
 
 retry:
        handle = ext4_journal_start(inode, needed_blocks);
-       if (IS_ERR(handle)) {
-               ret = PTR_ERR(handle);
-               goto out;
-       }
+       if (IS_ERR(handle))
+               return PTR_ERR(handle);
        if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode))
                ret = nobh_prepare_write(page, from, to, ext4_get_block);
        else
                ret = block_prepare_write(page, from, to, ext4_get_block);
        if (ret)
-               goto prepare_write_failed;
+               goto failure;
 
        if (ext4_should_journal_data(inode)) {
                ret = walk_page_buffers(handle, page_buffers(page),
                                from, to, NULL, do_journal_get_write_access);
+               if (ret)
+                       /* fatal error, just put the handle and return */
+                       ext4_journal_stop(handle);
        }
-prepare_write_failed:
-       if (ret)
-               ext4_journal_stop(handle);
+       return ret;
+
+failure:
+       ret2 = ext4_prepare_failure(file, page, from, to);
+       if (ret2 < 0)
+               return ret2;
        if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
                goto retry;
-out:
+       /* retry number exceeded, or other error like -EDQUOT */
        return ret;
 }
 
index 22a737c306c7846693e4b032f2ca71091ec1113c..500567dd53b6fd9752096c014162927a730748f0 100644 (file)
@@ -256,7 +256,7 @@ flags_err:
 #ifdef CONFIG_COMPAT
 long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int ret;
 
        /* These are just misnamed, they actually get/put from/to user an int */
index 8b1bd03d20f5d6dee84a89001d653810ef3e6706..e5a74a5ac261f228ffaf4b057857f8d03f7a62c2 100644 (file)
@@ -552,6 +552,15 @@ static int htree_dirblock_to_tree(struct file *dir_file,
                                           dir->i_sb->s_blocksize -
                                           EXT4_DIR_REC_LEN(0));
        for (; de < top; de = ext4_next_entry(de)) {
+               if (!ext4_check_dir_entry("htree_dirblock_to_tree", dir, de, bh,
+                                       (block<<EXT4_BLOCK_SIZE_BITS(dir->i_sb))
+                                               +((char *)de - bh->b_data))) {
+                       /* On error, skip the f_pos to the next block. */
+                       dir_file->f_pos = (dir_file->f_pos |
+                                       (dir->i_sb->s_blocksize - 1)) + 1;
+                       brelse (bh);
+                       return count;
+               }
                ext4fs_dirhash(de->name, de->name_len, hinfo);
                if ((hinfo->hash < start_hash) ||
                    ((hinfo->hash == start_hash) &&
@@ -593,7 +602,7 @@ int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
 
        dxtrace(printk("In htree_fill_tree, start hash: %x:%x\n", start_hash,
                       start_minor_hash));
-       dir = dir_file->f_dentry->d_inode;
+       dir = dir_file->f_path.dentry->d_inode;
        if (!(EXT4_I(dir)->i_flags & EXT4_INDEX_FL)) {
                hinfo.hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version;
                hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed;
@@ -604,7 +613,7 @@ int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
        }
        hinfo.hash = start_hash;
        hinfo.minor_hash = 0;
-       frame = dx_probe(NULL, dir_file->f_dentry->d_inode, &hinfo, frames, &err);
+       frame = dx_probe(NULL, dir_file->f_path.dentry->d_inode, &hinfo, frames, &err);
        if (!frame)
                return err;
 
index b4b022aa2bc26c23d923df3fa3641a9665c55ba8..486a641ca71b94fa0ed745a246d57285d01611e1 100644 (file)
@@ -486,7 +486,7 @@ static void ext4_put_super (struct super_block * sb)
        return;
 }
 
-static kmem_cache_t *ext4_inode_cachep;
+static struct kmem_cache *ext4_inode_cachep;
 
 /*
  * Called inside transaction, so use GFP_NOFS
@@ -495,7 +495,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
 {
        struct ext4_inode_info *ei;
 
-       ei = kmem_cache_alloc(ext4_inode_cachep, SLAB_NOFS);
+       ei = kmem_cache_alloc(ext4_inode_cachep, GFP_NOFS);
        if (!ei)
                return NULL;
 #ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
@@ -513,7 +513,7 @@ static void ext4_destroy_inode(struct inode *inode)
        kmem_cache_free(ext4_inode_cachep, EXT4_I(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct ext4_inode_info *ei = (struct ext4_inode_info *) foo;
 
@@ -1321,6 +1321,12 @@ static void ext4_orphan_cleanup (struct super_block * sb,
                return;
        }
 
+       if (bdev_read_only(sb->s_bdev)) {
+               printk(KERN_ERR "EXT4-fs: write access "
+                       "unavailable, skipping orphan cleanup.\n");
+               return;
+       }
+
        if (EXT4_SB(sb)->s_mount_state & EXT4_ERROR_FS) {
                if (es->s_last_orphan)
                        jbd_debug(1, "Errors on filesystem, "
@@ -2460,6 +2466,7 @@ static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf)
        struct ext4_super_block *es = sbi->s_es;
        ext4_fsblk_t overhead;
        int i;
+       u64 fsid;
 
        if (test_opt (sb, MINIX_DF))
                overhead = 0;
@@ -2506,6 +2513,10 @@ static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf)
        buf->f_files = le32_to_cpu(es->s_inodes_count);
        buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter);
        buf->f_namelen = EXT4_NAME_LEN;
+       fsid = le64_to_cpup((void *)es->s_uuid) ^
+              le64_to_cpup((void *)es->s_uuid + sizeof(u64));
+       buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
+       buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
        return 0;
 }
 
index 63233cd946a7333bc8079795a1f3d7c32c1b2485..dc969c357aa1d4ef9e207054e506053b8efdc0c6 100644 (file)
@@ -459,14 +459,11 @@ static void ext4_xattr_update_super_block(handle_t *handle,
        if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR))
                return;
 
-       lock_super(sb);
        if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) {
-               EXT4_SB(sb)->s_es->s_feature_compat |=
-                       cpu_to_le32(EXT4_FEATURE_COMPAT_EXT_ATTR);
+               EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR);
                sb->s_dirt = 1;
                ext4_journal_dirty_metadata(handle, EXT4_SB(sb)->s_sbh);
        }
-       unlock_super(sb);
 }
 
 /*
index 82cc4f59e3bae3302abd291b392eccb90f4e1be4..05c2941c74f28e98073a531d9524aa9bf0664d69 100644 (file)
@@ -34,9 +34,9 @@ static inline int fat_max_cache(struct inode *inode)
        return FAT_MAX_CACHE;
 }
 
-static kmem_cache_t *fat_cache_cachep;
+static struct kmem_cache *fat_cache_cachep;
 
-static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags)
+static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
 {
        struct fat_cache *cache = (struct fat_cache *)foo;
 
@@ -63,7 +63,7 @@ void fat_cache_destroy(void)
 
 static inline struct fat_cache *fat_cache_alloc(struct inode *inode)
 {
-       return kmem_cache_alloc(fat_cache_cachep, SLAB_KERNEL);
+       return kmem_cache_alloc(fat_cache_cachep, GFP_KERNEL);
 }
 
 static inline void fat_cache_free(struct fat_cache *cache)
index 69c439f443877be9bf72e28760d939581b5a00d5..c16af246d245ddd45daf90a59ef0612fe5904dac 100644 (file)
@@ -579,7 +579,7 @@ parse_record:
        if (!memcmp(de->name, MSDOS_DOT, MSDOS_NAME))
                inum = inode->i_ino;
        else if (!memcmp(de->name, MSDOS_DOTDOT, MSDOS_NAME)) {
-               inum = parent_ino(filp->f_dentry);
+               inum = parent_ino(filp->f_path.dentry);
        } else {
                loff_t i_pos = fat_make_i_pos(sb, bh, de);
                struct inode *tmp = fat_iget(sb, i_pos);
@@ -643,7 +643,7 @@ out:
 
 static int fat_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        return __fat_readdir(inode, filp, dirent, filldir, 0, 0);
 }
 
@@ -782,7 +782,7 @@ static long fat_compat_dir_ioctl(struct file *file, unsigned cmd,
 
        set_fs(KERNEL_DS);
        lock_kernel();
-       ret = fat_dir_ioctl(file->f_dentry->d_inode, file,
+       ret = fat_dir_ioctl(file->f_path.dentry->d_inode, file,
                            cmd, (unsigned long) &d);
        unlock_kernel();
        set_fs(oldfs);
index 0aa813d944a67fec2e7955eadeb3e781b66915c9..c1237b70c1fee7c11f06182f67d20b5a9f6a700f 100644 (file)
@@ -92,7 +92,7 @@ int fat_generic_ioctl(struct inode *inode, struct file *filp,
                }
 
                /* This MUST be done before doing anything irreversible... */
-               err = notify_change(filp->f_dentry, &ia);
+               err = notify_change(filp->f_path.dentry, &ia);
                if (err)
                        goto up;
 
index 78945b53b0f827fed88da656666ec1dd6fa9aaa9..a9e4688582a2599a7c1df7f3579aa15fe4632a87 100644 (file)
@@ -477,12 +477,12 @@ static void fat_put_super(struct super_block *sb)
        kfree(sbi);
 }
 
-static kmem_cache_t *fat_inode_cachep;
+static struct kmem_cache *fat_inode_cachep;
 
 static struct inode *fat_alloc_inode(struct super_block *sb)
 {
        struct msdos_inode_info *ei;
-       ei = kmem_cache_alloc(fat_inode_cachep, SLAB_KERNEL);
+       ei = kmem_cache_alloc(fat_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        return &ei->vfs_inode;
@@ -493,7 +493,7 @@ static void fat_destroy_inode(struct inode *inode)
        kmem_cache_free(fat_inode_cachep, MSDOS_I(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct msdos_inode_info *ei = (struct msdos_inode_info *)foo;
 
index e4f26165f12a22567526a74d2f463aa6d6798547..2bdaef35da5479a406aa1eb658eba498c145c4c7 100644 (file)
@@ -204,7 +204,7 @@ asmlinkage long sys_dup(unsigned int fildes)
 
 static int setfl(int fd, struct file * filp, unsigned long arg)
 {
-       struct inode * inode = filp->f_dentry->d_inode;
+       struct inode * inode = filp->f_path.dentry->d_inode;
        int error = 0;
 
        /*
@@ -553,7 +553,7 @@ int send_sigurg(struct fown_struct *fown)
 }
 
 static DEFINE_RWLOCK(fasync_lock);
-static kmem_cache_t *fasync_cache __read_mostly;
+static struct kmem_cache *fasync_cache __read_mostly;
 
 /*
  * fasync_helper() is used by some character device drivers (mainly mice)
@@ -567,7 +567,7 @@ int fasync_helper(int fd, struct file * filp, int on, struct fasync_struct **fap
        int result = 0;
 
        if (on) {
-               new = kmem_cache_alloc(fasync_cache, SLAB_KERNEL);
+               new = kmem_cache_alloc(fasync_cache, GFP_KERNEL);
                if (!new)
                        return -ENOMEM;
        }
index 3787e82f54c19f55592a6f7e8dcb3abf8f392dfe..51aef675470fb64984733fe9a710adc7cb6b980a 100644 (file)
--- a/fs/file.c
+++ b/fs/file.c
@@ -21,7 +21,6 @@
 struct fdtable_defer {
        spinlock_t lock;
        struct work_struct wq;
-       struct timer_list timer;
        struct fdtable *next;
 };
 
@@ -75,22 +74,6 @@ static void __free_fdtable(struct fdtable *fdt)
        kfree(fdt);
 }
 
-static void fdtable_timer(unsigned long data)
-{
-       struct fdtable_defer *fddef = (struct fdtable_defer *)data;
-
-       spin_lock(&fddef->lock);
-       /*
-        * If someone already emptied the queue return.
-        */
-       if (!fddef->next)
-               goto out;
-       if (!schedule_work(&fddef->wq))
-               mod_timer(&fddef->timer, 5);
-out:
-       spin_unlock(&fddef->lock);
-}
-
 static void free_fdtable_work(struct work_struct *work)
 {
        struct fdtable_defer *f =
@@ -144,13 +127,8 @@ static void free_fdtable_rcu(struct rcu_head *rcu)
                spin_lock(&fddef->lock);
                fdt->next = fddef->next;
                fddef->next = fdt;
-               /*
-                * vmallocs are handled from the workqueue context.
-                * If the per-cpu workqueue is running, then we
-                * defer work scheduling through a timer.
-                */
-               if (!schedule_work(&fddef->wq))
-                       mod_timer(&fddef->timer, 5);
+               /* vmallocs are handled from the workqueue context */
+               schedule_work(&fddef->wq);
                spin_unlock(&fddef->lock);
                put_cpu_var(fdtable_defer_list);
        }
@@ -354,9 +332,6 @@ static void __devinit fdtable_defer_list_init(int cpu)
        struct fdtable_defer *fddef = &per_cpu(fdtable_defer_list, cpu);
        spin_lock_init(&fddef->lock);
        INIT_WORK(&fddef->wq, free_fdtable_work);
-       init_timer(&fddef->timer);
-       fddef->timer.data = (unsigned long)fddef;
-       fddef->timer.function = fdtable_timer;
        fddef->next = NULL;
 }
 
index 24f25a057d9c131f94f1f2eb2400739958d09a95..4c17a18d8c10c4889295d52250afb800aba9190b 100644 (file)
@@ -152,8 +152,8 @@ EXPORT_SYMBOL(fput);
  */
 void fastcall __fput(struct file *file)
 {
-       struct dentry *dentry = file->f_dentry;
-       struct vfsmount *mnt = file->f_vfsmnt;
+       struct dentry *dentry = file->f_path.dentry;
+       struct vfsmount *mnt = file->f_path.mnt;
        struct inode *inode = dentry->d_inode;
 
        might_sleep();
@@ -176,8 +176,8 @@ void fastcall __fput(struct file *file)
                put_write_access(inode);
        put_pid(file->f_owner.pid);
        file_kill(file);
-       file->f_dentry = NULL;
-       file->f_vfsmnt = NULL;
+       file->f_path.dentry = NULL;
+       file->f_path.mnt = NULL;
        file_free(file);
        dput(dentry);
        mntput(mnt);
@@ -271,7 +271,7 @@ int fs_may_remount_ro(struct super_block *sb)
        file_list_lock();
        list_for_each(p, &sb->s_files) {
                struct file *file = list_entry(p, struct file, f_u.fu_list);
-               struct inode *inode = file->f_dentry->d_inode;
+               struct inode *inode = file->f_path.dentry->d_inode;
 
                /* File with pending delete? */
                if (inode->i_nlink == 0)
index 4786d51ad3bd59faa1a7a93c7e944f2b6463fa71..0b7ae897cb781ab9c55beff17bda465dec9b6a48 100644 (file)
@@ -46,7 +46,7 @@ extern const struct address_space_operations vxfs_immed_aops;
 
 extern struct inode_operations vxfs_immed_symlink_iops;
 
-kmem_cache_t           *vxfs_inode_cachep;
+struct kmem_cache              *vxfs_inode_cachep;
 
 
 #ifdef DIAGNOSTIC
@@ -103,7 +103,7 @@ vxfs_blkiget(struct super_block *sbp, u_long extent, ino_t ino)
                struct vxfs_inode_info  *vip;
                struct vxfs_dinode      *dip;
 
-               if (!(vip = kmem_cache_alloc(vxfs_inode_cachep, SLAB_KERNEL)))
+               if (!(vip = kmem_cache_alloc(vxfs_inode_cachep, GFP_KERNEL)))
                        goto fail;
                dip = (struct vxfs_dinode *)(bp->b_data + offset);
                memcpy(vip, dip, sizeof(*vip));
@@ -145,7 +145,7 @@ __vxfs_iget(ino_t ino, struct inode *ilistp)
                struct vxfs_dinode      *dip;
                caddr_t                 kaddr = (char *)page_address(pp);
 
-               if (!(vip = kmem_cache_alloc(vxfs_inode_cachep, SLAB_KERNEL)))
+               if (!(vip = kmem_cache_alloc(vxfs_inode_cachep, GFP_KERNEL)))
                        goto fail;
                dip = (struct vxfs_dinode *)(kaddr + offset);
                memcpy(vip, dip, sizeof(*vip));
index 43886fa00a2a06a9a3423dc20c4d35f521a3a6a5..3995d7fbedab6b18be5a48d04c1f3edd446527f3 100644 (file)
@@ -240,7 +240,7 @@ vxfs_lookup(struct inode *dip, struct dentry *dp, struct nameidata *nd)
 static int
 vxfs_readdir(struct file *fp, void *retp, filldir_t filler)
 {
-       struct inode            *ip = fp->f_dentry->d_inode;
+       struct inode            *ip = fp->f_path.dentry->d_inode;
        struct super_block      *sbp = ip->i_sb;
        u_long                  bsize = sbp->s_blocksize;
        u_long                  page, npages, block, pblocks, nblocks, offset;
index 16b39c053d470c3d3cc71c3881c0f5c8c834864b..8c58bd4539936d536ada3b3b98596002db5badd8 100644 (file)
@@ -23,7 +23,7 @@ static struct fuse_conn *fuse_ctl_file_conn_get(struct file *file)
 {
        struct fuse_conn *fc;
        mutex_lock(&fuse_mutex);
-       fc = file->f_dentry->d_inode->i_private;
+       fc = file->f_path.dentry->d_inode->i_private;
        if (fc)
                fc = fuse_conn_get(fc);
        mutex_unlock(&fuse_mutex);
index 66571eafbb1eb88afd8acc0e3625bdc0342207df..357764d85ff1e0cc81723f4006f78479e5164fc8 100644 (file)
@@ -19,7 +19,7 @@
 
 MODULE_ALIAS_MISCDEV(FUSE_MINOR);
 
-static kmem_cache_t *fuse_req_cachep;
+static struct kmem_cache *fuse_req_cachep;
 
 static struct fuse_conn *fuse_get_conn(struct file *file)
 {
@@ -41,7 +41,7 @@ static void fuse_request_init(struct fuse_req *req)
 
 struct fuse_req *fuse_request_alloc(void)
 {
-       struct fuse_req *req = kmem_cache_alloc(fuse_req_cachep, SLAB_KERNEL);
+       struct fuse_req *req = kmem_cache_alloc(fuse_req_cachep, GFP_KERNEL);
        if (req)
                fuse_request_init(req);
        return req;
index c71a6c092ad9d4f372553dac847c1af91355d048..40080477ceb4fa5a2fed48f0da0c446c10614bb5 100644 (file)
@@ -141,9 +141,6 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd)
                struct fuse_req *forget_req;
                struct dentry *parent;
 
-               /* Doesn't hurt to "reset" the validity timeout */
-               fuse_invalidate_entry_cache(entry);
-
                /* For negative dentries, always do a fresh lookup */
                if (!inode)
                        return 0;
@@ -859,7 +856,7 @@ static int fuse_readdir(struct file *file, void *dstbuf, filldir_t filldir)
        int err;
        size_t nbytes;
        struct page *page;
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct fuse_conn *fc = get_fuse_conn(inode);
        struct fuse_req *req;
 
@@ -1027,6 +1024,8 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr)
        if (attr->ia_valid & ATTR_SIZE) {
                unsigned long limit;
                is_truncate = 1;
+               if (IS_SWAPFILE(inode))
+                       return -ETXTBSY;
                limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
                if (limit != RLIM_INFINITY && attr->ia_size > (loff_t) limit) {
                        send_sig(SIGXFSZ, current, 0);
index 763a50daf1c0a7cc7c336a0d2ba99a64e7baeb1c..1387749201b397a8d020dd1b137dd66b780600aa 100644 (file)
@@ -141,8 +141,8 @@ int fuse_release_common(struct inode *inode, struct file *file, int isdir)
                                        isdir ? FUSE_RELEASEDIR : FUSE_RELEASE);
 
                /* Hold vfsmount and dentry until release is finished */
-               req->vfsmount = mntget(file->f_vfsmnt);
-               req->dentry = dget(file->f_dentry);
+               req->vfsmount = mntget(file->f_path.mnt);
+               req->dentry = dget(file->f_path.dentry);
                request_send_background(fc, req);
        }
 
@@ -184,7 +184,7 @@ static u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id)
 
 static int fuse_flush(struct file *file, fl_owner_t id)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct fuse_conn *fc = get_fuse_conn(inode);
        struct fuse_file *ff = file->private_data;
        struct fuse_req *req;
@@ -533,7 +533,7 @@ static int fuse_get_user_pages(struct fuse_req *req, const char __user *buf,
 static ssize_t fuse_direct_io(struct file *file, const char __user *buf,
                              size_t count, loff_t *ppos, int write)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct fuse_conn *fc = get_fuse_conn(inode);
        size_t nmax = write ? fc->max_write : fc->max_read;
        loff_t pos = *ppos;
@@ -607,7 +607,7 @@ static ssize_t fuse_direct_read(struct file *file, char __user *buf,
 static ssize_t fuse_direct_write(struct file *file, const char __user *buf,
                                 size_t count, loff_t *ppos)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        ssize_t res;
        /* Don't allow parallel writes to the same file */
        mutex_lock(&inode->i_mutex);
@@ -662,7 +662,7 @@ static int convert_fuse_file_lock(const struct fuse_file_lock *ffl,
 static void fuse_lk_fill(struct fuse_req *req, struct file *file,
                         const struct file_lock *fl, int opcode, pid_t pid)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct fuse_conn *fc = get_fuse_conn(inode);
        struct fuse_file *ff = file->private_data;
        struct fuse_lk_in *arg = &req->misc.lk_in;
@@ -682,7 +682,7 @@ static void fuse_lk_fill(struct fuse_req *req, struct file *file,
 
 static int fuse_getlk(struct file *file, struct file_lock *fl)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct fuse_conn *fc = get_fuse_conn(inode);
        struct fuse_req *req;
        struct fuse_lk_out outarg;
@@ -707,7 +707,7 @@ static int fuse_getlk(struct file *file, struct file_lock *fl)
 
 static int fuse_setlk(struct file *file, struct file_lock *fl)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct fuse_conn *fc = get_fuse_conn(inode);
        struct fuse_req *req;
        int opcode = (fl->fl_flags & FL_SLEEP) ? FUSE_SETLKW : FUSE_SETLK;
@@ -734,7 +734,7 @@ static int fuse_setlk(struct file *file, struct file_lock *fl)
 
 static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct fuse_conn *fc = get_fuse_conn(inode);
        int err;
 
@@ -754,6 +754,42 @@ static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl)
        return err;
 }
 
+static sector_t fuse_bmap(struct address_space *mapping, sector_t block)
+{
+       struct inode *inode = mapping->host;
+       struct fuse_conn *fc = get_fuse_conn(inode);
+       struct fuse_req *req;
+       struct fuse_bmap_in inarg;
+       struct fuse_bmap_out outarg;
+       int err;
+
+       if (!inode->i_sb->s_bdev || fc->no_bmap)
+               return 0;
+
+       req = fuse_get_req(fc);
+       if (IS_ERR(req))
+               return 0;
+
+       memset(&inarg, 0, sizeof(inarg));
+       inarg.block = block;
+       inarg.blocksize = inode->i_sb->s_blocksize;
+       req->in.h.opcode = FUSE_BMAP;
+       req->in.h.nodeid = get_node_id(inode);
+       req->in.numargs = 1;
+       req->in.args[0].size = sizeof(inarg);
+       req->in.args[0].value = &inarg;
+       req->out.numargs = 1;
+       req->out.args[0].size = sizeof(outarg);
+       req->out.args[0].value = &outarg;
+       request_send(fc, req);
+       err = req->out.h.error;
+       fuse_put_request(fc, req);
+       if (err == -ENOSYS)
+               fc->no_bmap = 1;
+
+       return err ? 0 : outarg.block;
+}
+
 static const struct file_operations fuse_file_operations = {
        .llseek         = generic_file_llseek,
        .read           = do_sync_read,
@@ -787,6 +823,7 @@ static const struct address_space_operations fuse_file_aops  = {
        .commit_write   = fuse_commit_write,
        .readpages      = fuse_readpages,
        .set_page_dirty = fuse_set_page_dirty,
+       .bmap           = fuse_bmap,
 };
 
 void fuse_init_file_inode(struct inode *inode)
index 91edb8932d905890a342c1f66cbfe5dbdd04f828..b98b20de740562bd32dc81fcf8af415779496f97 100644 (file)
@@ -298,6 +298,9 @@ struct fuse_conn {
            reply, before any other request, and never cleared */
        unsigned conn_error : 1;
 
+       /** Connection successful.  Only set in INIT */
+       unsigned conn_init : 1;
+
        /** Do readpages asynchronously?  Only set in INIT */
        unsigned async_read : 1;
 
@@ -339,6 +342,9 @@ struct fuse_conn {
        /** Is interrupt not implemented by fs? */
        unsigned no_interrupt : 1;
 
+       /** Is bmap not implemented by fs? */
+       unsigned no_bmap : 1;
+
        /** The number of requests waiting for completion */
        atomic_t num_waiting;
 
@@ -365,6 +371,9 @@ struct fuse_conn {
 
        /** Key for lock owner ID scrambling */
        u32 scramble_key[4];
+
+       /** Reserved request for the DESTROY message */
+       struct fuse_req *destroy_req;
 };
 
 static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb)
index fc42035703702813266c14c66d784ee1ec7e1c20..12450d2b320e771b13b7191403e9c4dd1f8dbf82 100644 (file)
@@ -22,7 +22,7 @@ MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");
 MODULE_DESCRIPTION("Filesystem in Userspace");
 MODULE_LICENSE("GPL");
 
-static kmem_cache_t *fuse_inode_cachep;
+static struct kmem_cache *fuse_inode_cachep;
 struct list_head fuse_conn_list;
 DEFINE_MUTEX(fuse_mutex);
 
@@ -39,6 +39,7 @@ struct fuse_mount_data {
        unsigned group_id_present : 1;
        unsigned flags;
        unsigned max_read;
+       unsigned blksize;
 };
 
 static struct inode *fuse_alloc_inode(struct super_block *sb)
@@ -46,7 +47,7 @@ static struct inode *fuse_alloc_inode(struct super_block *sb)
        struct inode *inode;
        struct fuse_inode *fi;
 
-       inode = kmem_cache_alloc(fuse_inode_cachep, SLAB_KERNEL);
+       inode = kmem_cache_alloc(fuse_inode_cachep, GFP_KERNEL);
        if (!inode)
                return NULL;
 
@@ -205,10 +206,23 @@ static void fuse_umount_begin(struct vfsmount *vfsmnt, int flags)
                fuse_abort_conn(get_fuse_conn_super(vfsmnt->mnt_sb));
 }
 
+static void fuse_send_destroy(struct fuse_conn *fc)
+{
+       struct fuse_req *req = fc->destroy_req;
+       if (req && fc->conn_init) {
+               fc->destroy_req = NULL;
+               req->in.h.opcode = FUSE_DESTROY;
+               req->force = 1;
+               request_send(fc, req);
+               fuse_put_request(fc, req);
+       }
+}
+
 static void fuse_put_super(struct super_block *sb)
 {
        struct fuse_conn *fc = get_fuse_conn_super(sb);
 
+       fuse_send_destroy(fc);
        spin_lock(&fc->lock);
        fc->connected = 0;
        fc->blocked = 0;
@@ -274,6 +288,7 @@ enum {
        OPT_DEFAULT_PERMISSIONS,
        OPT_ALLOW_OTHER,
        OPT_MAX_READ,
+       OPT_BLKSIZE,
        OPT_ERR
 };
 
@@ -285,14 +300,16 @@ static match_table_t tokens = {
        {OPT_DEFAULT_PERMISSIONS,       "default_permissions"},
        {OPT_ALLOW_OTHER,               "allow_other"},
        {OPT_MAX_READ,                  "max_read=%u"},
+       {OPT_BLKSIZE,                   "blksize=%u"},
        {OPT_ERR,                       NULL}
 };
 
-static int parse_fuse_opt(char *opt, struct fuse_mount_data *d)
+static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev)
 {
        char *p;
        memset(d, 0, sizeof(struct fuse_mount_data));
        d->max_read = ~0;
+       d->blksize = 512;
 
        while ((p = strsep(&opt, ",")) != NULL) {
                int token;
@@ -345,6 +362,12 @@ static int parse_fuse_opt(char *opt, struct fuse_mount_data *d)
                        d->max_read = value;
                        break;
 
+               case OPT_BLKSIZE:
+                       if (!is_bdev || match_int(&args[0], &value))
+                               return 0;
+                       d->blksize = value;
+                       break;
+
                default:
                        return 0;
                }
@@ -400,6 +423,8 @@ static struct fuse_conn *new_conn(void)
 void fuse_conn_put(struct fuse_conn *fc)
 {
        if (atomic_dec_and_test(&fc->count)) {
+               if (fc->destroy_req)
+                       fuse_request_free(fc->destroy_req);
                mutex_destroy(&fc->inst_mutex);
                kfree(fc);
        }
@@ -456,6 +481,7 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
                fc->bdi.ra_pages = min(fc->bdi.ra_pages, ra_pages);
                fc->minor = arg->minor;
                fc->max_write = arg->minor < 5 ? 4096 : arg->max_write;
+               fc->conn_init = 1;
        }
        fuse_put_request(fc, req);
        fc->blocked = 0;
@@ -500,15 +526,23 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
        struct dentry *root_dentry;
        struct fuse_req *init_req;
        int err;
+       int is_bdev = sb->s_bdev != NULL;
 
        if (sb->s_flags & MS_MANDLOCK)
                return -EINVAL;
 
-       if (!parse_fuse_opt((char *) data, &d))
+       if (!parse_fuse_opt((char *) data, &d, is_bdev))
                return -EINVAL;
 
-       sb->s_blocksize = PAGE_CACHE_SIZE;
-       sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
+       if (is_bdev) {
+#ifdef CONFIG_BLOCK
+               if (!sb_set_blocksize(sb, d.blksize))
+                       return -EINVAL;
+#endif
+       } else {
+               sb->s_blocksize = PAGE_CACHE_SIZE;
+               sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
+       }
        sb->s_magic = FUSE_SUPER_MAGIC;
        sb->s_op = &fuse_super_operations;
        sb->s_maxbytes = MAX_LFS_FILESIZE;
@@ -547,6 +581,12 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
        if (!init_req)
                goto err_put_root;
 
+       if (is_bdev) {
+               fc->destroy_req = fuse_request_alloc();
+               if (!fc->destroy_req)
+                       goto err_put_root;
+       }
+
        mutex_lock(&fuse_mutex);
        err = -EINVAL;
        if (file->private_data)
@@ -598,10 +638,47 @@ static struct file_system_type fuse_fs_type = {
        .kill_sb        = kill_anon_super,
 };
 
+#ifdef CONFIG_BLOCK
+static int fuse_get_sb_blk(struct file_system_type *fs_type,
+                          int flags, const char *dev_name,
+                          void *raw_data, struct vfsmount *mnt)
+{
+       return get_sb_bdev(fs_type, flags, dev_name, raw_data, fuse_fill_super,
+                          mnt);
+}
+
+static struct file_system_type fuseblk_fs_type = {
+       .owner          = THIS_MODULE,
+       .name           = "fuseblk",
+       .get_sb         = fuse_get_sb_blk,
+       .kill_sb        = kill_block_super,
+       .fs_flags       = FS_REQUIRES_DEV,
+};
+
+static inline int register_fuseblk(void)
+{
+       return register_filesystem(&fuseblk_fs_type);
+}
+
+static inline void unregister_fuseblk(void)
+{
+       unregister_filesystem(&fuseblk_fs_type);
+}
+#else
+static inline int register_fuseblk(void)
+{
+       return 0;
+}
+
+static inline void unregister_fuseblk(void)
+{
+}
+#endif
+
 static decl_subsys(fuse, NULL, NULL);
 static decl_subsys(connections, NULL, NULL);
 
-static void fuse_inode_init_once(void *foo, kmem_cache_t *cachep,
+static void fuse_inode_init_once(void *foo, struct kmem_cache *cachep,
                                 unsigned long flags)
 {
        struct inode * inode = foo;
@@ -617,24 +694,34 @@ static int __init fuse_fs_init(void)
 
        err = register_filesystem(&fuse_fs_type);
        if (err)
-               printk("fuse: failed to register filesystem\n");
-       else {
-               fuse_inode_cachep = kmem_cache_create("fuse_inode",
-                                                     sizeof(struct fuse_inode),
-                                                     0, SLAB_HWCACHE_ALIGN,
-                                                     fuse_inode_init_once, NULL);
-               if (!fuse_inode_cachep) {
-                       unregister_filesystem(&fuse_fs_type);
-                       err = -ENOMEM;
-               }
-       }
+               goto out;
 
+       err = register_fuseblk();
+       if (err)
+               goto out_unreg;
+
+       fuse_inode_cachep = kmem_cache_create("fuse_inode",
+                                             sizeof(struct fuse_inode),
+                                             0, SLAB_HWCACHE_ALIGN,
+                                             fuse_inode_init_once, NULL);
+       err = -ENOMEM;
+       if (!fuse_inode_cachep)
+               goto out_unreg2;
+
+       return 0;
+
+ out_unreg2:
+       unregister_fuseblk();
+ out_unreg:
+       unregister_filesystem(&fuse_fs_type);
+ out:
        return err;
 }
 
 static void fuse_fs_cleanup(void)
 {
        unregister_filesystem(&fuse_fs_type);
+       unregister_fuseblk();
        kmem_cache_destroy(fuse_inode_cachep);
 }
 
index 8c27de8b95682134fcda8c33f7f1e687a4e8e28f..c0791cbacad91e614652be6e10a868099107098e 100644 (file)
@@ -2,6 +2,7 @@ config GFS2_FS
        tristate "GFS2 file system support"
        depends on EXPERIMENTAL
        select FS_POSIX_ACL
+       select CRC32
        help
        A cluster filesystem.
 
index 5f959b8ce4065dae9e240c3db24eb52f8ec3f589..6e80844367ee9b5edd81143bc659ab14834809a5 100644 (file)
@@ -74,11 +74,11 @@ int gfs2_acl_validate_remove(struct gfs2_inode *ip, int access)
 {
        if (!GFS2_SB(&ip->i_inode)->sd_args.ar_posix_acl)
                return -EOPNOTSUPP;
-       if (current->fsuid != ip->i_di.di_uid && !capable(CAP_FOWNER))
+       if (current->fsuid != ip->i_inode.i_uid && !capable(CAP_FOWNER))
                return -EPERM;
-       if (S_ISLNK(ip->i_di.di_mode))
+       if (S_ISLNK(ip->i_inode.i_mode))
                return -EOPNOTSUPP;
-       if (!access && !S_ISDIR(ip->i_di.di_mode))
+       if (!access && !S_ISDIR(ip->i_inode.i_mode))
                return -EACCES;
 
        return 0;
@@ -145,14 +145,14 @@ out:
 }
 
 /**
- * gfs2_check_acl_locked - Check an ACL to see if we're allowed to do something
+ * gfs2_check_acl - Check an ACL to see if we're allowed to do something
  * @inode: the file we want to do something to
  * @mask: what we want to do
  *
  * Returns: errno
  */
 
-int gfs2_check_acl_locked(struct inode *inode, int mask)
+int gfs2_check_acl(struct inode *inode, int mask)
 {
        struct posix_acl *acl = NULL;
        int error;
@@ -170,21 +170,6 @@ int gfs2_check_acl_locked(struct inode *inode, int mask)
        return -EAGAIN;
 }
 
-int gfs2_check_acl(struct inode *inode, int mask)
-{
-       struct gfs2_inode *ip = GFS2_I(inode);
-       struct gfs2_holder i_gh;
-       int error;
-
-       error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
-       if (!error) {
-               error = gfs2_check_acl_locked(inode, mask);
-               gfs2_glock_dq_uninit(&i_gh);
-       }
-
-       return error;
-}
-
 static int munge_mode(struct gfs2_inode *ip, mode_t mode)
 {
        struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
@@ -198,10 +183,10 @@ static int munge_mode(struct gfs2_inode *ip, mode_t mode)
        error = gfs2_meta_inode_buffer(ip, &dibh);
        if (!error) {
                gfs2_assert_withdraw(sdp,
-                               (ip->i_di.di_mode & S_IFMT) == (mode & S_IFMT));
-               ip->i_di.di_mode = mode;
+                               (ip->i_inode.i_mode & S_IFMT) == (mode & S_IFMT));
+               ip->i_inode.i_mode = mode;
                gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-               gfs2_dinode_out(&ip->i_di, dibh->b_data);
+               gfs2_dinode_out(ip, dibh->b_data);
                brelse(dibh);
        }
 
@@ -215,12 +200,12 @@ int gfs2_acl_create(struct gfs2_inode *dip, struct gfs2_inode *ip)
        struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
        struct posix_acl *acl = NULL, *clone;
        struct gfs2_ea_request er;
-       mode_t mode = ip->i_di.di_mode;
+       mode_t mode = ip->i_inode.i_mode;
        int error;
 
        if (!sdp->sd_args.ar_posix_acl)
                return 0;
-       if (S_ISLNK(ip->i_di.di_mode))
+       if (S_ISLNK(ip->i_inode.i_mode))
                return 0;
 
        memset(&er, 0, sizeof(struct gfs2_ea_request));
@@ -232,7 +217,7 @@ int gfs2_acl_create(struct gfs2_inode *dip, struct gfs2_inode *ip)
                return error;
        if (!acl) {
                mode &= ~current->fs->umask;
-               if (mode != ip->i_di.di_mode)
+               if (mode != ip->i_inode.i_mode)
                        error = munge_mode(ip, mode);
                return error;
        }
@@ -244,7 +229,7 @@ int gfs2_acl_create(struct gfs2_inode *dip, struct gfs2_inode *ip)
        posix_acl_release(acl);
        acl = clone;
 
-       if (S_ISDIR(ip->i_di.di_mode)) {
+       if (S_ISDIR(ip->i_inode.i_mode)) {
                er.er_name = GFS2_POSIX_ACL_DEFAULT;
                er.er_name_len = GFS2_POSIX_ACL_DEFAULT_LEN;
                error = gfs2_system_eaops.eo_set(ip, &er);
index 05c294fe0d780f9c28a4cef0d8ebdcfa2a5deffc..6751930bfb648e809eb90e028c0caa8458e1e5e8 100644 (file)
@@ -31,7 +31,6 @@ int gfs2_acl_validate_set(struct gfs2_inode *ip, int access,
                          struct gfs2_ea_request *er,
                          int *remove, mode_t *mode);
 int gfs2_acl_validate_remove(struct gfs2_inode *ip, int access);
-int gfs2_check_acl_locked(struct inode *inode, int mask);
 int gfs2_check_acl(struct inode *inode, int mask);
 int gfs2_acl_create(struct gfs2_inode *dip, struct gfs2_inode *ip);
 int gfs2_acl_chmod(struct gfs2_inode *ip, struct iattr *attr);
index 06e9a8cb45e959b89e744d64168da1dc4655f71b..8240c1ff94f4ef009151b7c1d9d4170c5a192553 100644 (file)
@@ -38,8 +38,8 @@ struct metapath {
 };
 
 typedef int (*block_call_t) (struct gfs2_inode *ip, struct buffer_head *dibh,
-                            struct buffer_head *bh, u64 *top,
-                            u64 *bottom, unsigned int height,
+                            struct buffer_head *bh, __be64 *top,
+                            __be64 *bottom, unsigned int height,
                             void *data);
 
 struct strip_mine {
@@ -163,6 +163,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
        if (ip->i_di.di_size) {
                *(__be64 *)(di + 1) = cpu_to_be64(block);
                ip->i_di.di_blocks++;
+               gfs2_set_inode_blocks(&ip->i_inode);
                di->di_blocks = cpu_to_be64(ip->i_di.di_blocks);
        }
 
@@ -230,7 +231,7 @@ static int build_height(struct inode *inode, unsigned height)
        struct buffer_head *blocks[GFS2_MAX_META_HEIGHT];
        struct gfs2_dinode *di;
        int error;
-       u64 *bp;
+       __be64 *bp;
        u64 bn;
        unsigned n;
 
@@ -255,7 +256,7 @@ static int build_height(struct inode *inode, unsigned height)
                                          GFS2_FORMAT_IN);
                        gfs2_buffer_clear_tail(blocks[n],
                                               sizeof(struct gfs2_meta_header));
-                       bp = (u64 *)(blocks[n]->b_data +
+                       bp = (__be64 *)(blocks[n]->b_data +
                                     sizeof(struct gfs2_meta_header));
                        *bp = cpu_to_be64(blocks[n+1]->b_blocknr);
                        brelse(blocks[n]);
@@ -272,6 +273,7 @@ static int build_height(struct inode *inode, unsigned height)
        *(__be64 *)(di + 1) = cpu_to_be64(bn);
        ip->i_di.di_height += new_height;
        ip->i_di.di_blocks += new_height;
+       gfs2_set_inode_blocks(&ip->i_inode);
        di->di_height = cpu_to_be16(ip->i_di.di_height);
        di->di_blocks = cpu_to_be64(ip->i_di.di_blocks);
        brelse(dibh);
@@ -360,15 +362,15 @@ static void find_metapath(struct gfs2_inode *ip, u64 block,
  * metadata tree.
  */
 
-static inline u64 *metapointer(struct buffer_head *bh, int *boundary,
+static inline __be64 *metapointer(struct buffer_head *bh, int *boundary,
                               unsigned int height, const struct metapath *mp)
 {
        unsigned int head_size = (height > 0) ?
                sizeof(struct gfs2_meta_header) : sizeof(struct gfs2_dinode);
-       u64 *ptr;
+       __be64 *ptr;
        *boundary = 0;
-       ptr = ((u64 *)(bh->b_data + head_size)) + mp->mp_list[height];
-       if (ptr + 1 == (u64 *)(bh->b_data + bh->b_size))
+       ptr = ((__be64 *)(bh->b_data + head_size)) + mp->mp_list[height];
+       if (ptr + 1 == (__be64 *)(bh->b_data + bh->b_size))
                *boundary = 1;
        return ptr;
 }
@@ -394,7 +396,7 @@ static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh,
                        int *new, u64 *block)
 {
        int boundary;
-       u64 *ptr = metapointer(bh, &boundary, height, mp);
+       __be64 *ptr = metapointer(bh, &boundary, height, mp);
 
        if (*ptr) {
                *block = be64_to_cpu(*ptr);
@@ -415,17 +417,35 @@ static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh,
 
        *ptr = cpu_to_be64(*block);
        ip->i_di.di_blocks++;
+       gfs2_set_inode_blocks(&ip->i_inode);
 
        *new = 1;
        return 0;
 }
 
+static inline void bmap_lock(struct inode *inode, int create)
+{
+       struct gfs2_inode *ip = GFS2_I(inode);
+       if (create)
+               down_write(&ip->i_rw_mutex);
+       else
+               down_read(&ip->i_rw_mutex);
+}
+
+static inline void bmap_unlock(struct inode *inode, int create)
+{
+       struct gfs2_inode *ip = GFS2_I(inode);
+       if (create)
+               up_write(&ip->i_rw_mutex);
+       else
+               up_read(&ip->i_rw_mutex);
+}
+
 /**
- * gfs2_block_pointers - Map a block from an inode to a disk block
+ * gfs2_block_map - Map a block from an inode to a disk block
  * @inode: The inode
  * @lblock: The logical block number
- * @map_bh: The bh to be mapped
- * @mp: metapath to use
+ * @bh_map: The bh to be mapped
  *
  * Find the block number on the current device which corresponds to an
  * inode's block. If the block had to be created, "new" will be set.
@@ -433,8 +453,8 @@ static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh,
  * Returns: errno
  */
 
-static int gfs2_block_pointers(struct inode *inode, u64 lblock, int create,
-                              struct buffer_head *bh_map, struct metapath *mp)
+int gfs2_block_map(struct inode *inode, u64 lblock, int create,
+                  struct buffer_head *bh_map)
 {
        struct gfs2_inode *ip = GFS2_I(inode);
        struct gfs2_sbd *sdp = GFS2_SB(inode);
@@ -448,57 +468,61 @@ static int gfs2_block_pointers(struct inode *inode, u64 lblock, int create,
        u64 dblock = 0;
        int boundary;
        unsigned int maxlen = bh_map->b_size >> inode->i_blkbits;
+       struct metapath mp;
+       u64 size;
 
        BUG_ON(maxlen == 0);
 
        if (gfs2_assert_warn(sdp, !gfs2_is_stuffed(ip)))
                return 0;
 
+       bmap_lock(inode, create);
+       clear_buffer_mapped(bh_map);
+       clear_buffer_new(bh_map);
+       clear_buffer_boundary(bh_map);
        bsize = gfs2_is_dir(ip) ? sdp->sd_jbsize : sdp->sd_sb.sb_bsize;
-
-       height = calc_tree_height(ip, (lblock + 1) * bsize);
-       if (ip->i_di.di_height < height) {
-               if (!create)
-                       return 0;
-
-               error = build_height(inode, height);
-               if (error)
-                       return error;
+       size = (lblock + 1) * bsize;
+
+       if (size > ip->i_di.di_size) {
+               height = calc_tree_height(ip, size);
+               if (ip->i_di.di_height < height) {
+                       if (!create)
+                               goto out_ok;
+       
+                       error = build_height(inode, height);
+                       if (error)
+                               goto out_fail;
+               }
        }
 
-       find_metapath(ip, lblock, mp);
+       find_metapath(ip, lblock, &mp);
        end_of_metadata = ip->i_di.di_height - 1;
-
        error = gfs2_meta_inode_buffer(ip, &bh);
        if (error)
-               return error;
+               goto out_fail;
 
        for (x = 0; x < end_of_metadata; x++) {
-               lookup_block(ip, bh, x, mp, create, &new, &dblock);
+               lookup_block(ip, bh, x, &mp, create, &new, &dblock);
                brelse(bh);
                if (!dblock)
-                       return 0;
+                       goto out_ok;
 
                error = gfs2_meta_indirect_buffer(ip, x+1, dblock, new, &bh);
                if (error)
-                       return error;
+                       goto out_fail;
        }
 
-       boundary = lookup_block(ip, bh, end_of_metadata, mp, create, &new, &dblock);
-       clear_buffer_mapped(bh_map);
-       clear_buffer_new(bh_map);
-       clear_buffer_boundary(bh_map);
-
+       boundary = lookup_block(ip, bh, end_of_metadata, &mp, create, &new, &dblock);
        if (dblock) {
                map_bh(bh_map, inode->i_sb, dblock);
                if (boundary)
-                       set_buffer_boundary(bh);
+                       set_buffer_boundary(bh_map);
                if (new) {
                        struct buffer_head *dibh;
                        error = gfs2_meta_inode_buffer(ip, &dibh);
                        if (!error) {
                                gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-                               gfs2_dinode_out(&ip->i_di, dibh->b_data);
+                               gfs2_dinode_out(ip, dibh->b_data);
                                brelse(dibh);
                        }
                        set_buffer_new(bh_map);
@@ -507,8 +531,8 @@ static int gfs2_block_pointers(struct inode *inode, u64 lblock, int create,
                while(--maxlen && !buffer_boundary(bh_map)) {
                        u64 eblock;
 
-                       mp->mp_list[end_of_metadata]++;
-                       boundary = lookup_block(ip, bh, end_of_metadata, mp, 0, &new, &eblock);
+                       mp.mp_list[end_of_metadata]++;
+                       boundary = lookup_block(ip, bh, end_of_metadata, &mp, 0, &new, &eblock);
                        if (eblock != ++dblock)
                                break;
                        bh_map->b_size += (1 << inode->i_blkbits);
@@ -518,43 +542,15 @@ static int gfs2_block_pointers(struct inode *inode, u64 lblock, int create,
        }
 out_brelse:
        brelse(bh);
-       return 0;
-}
-
-
-static inline void bmap_lock(struct inode *inode, int create)
-{
-       struct gfs2_inode *ip = GFS2_I(inode);
-       if (create)
-               down_write(&ip->i_rw_mutex);
-       else
-               down_read(&ip->i_rw_mutex);
-}
-
-static inline void bmap_unlock(struct inode *inode, int create)
-{
-       struct gfs2_inode *ip = GFS2_I(inode);
-       if (create)
-               up_write(&ip->i_rw_mutex);
-       else
-               up_read(&ip->i_rw_mutex);
-}
-
-int gfs2_block_map(struct inode *inode, u64 lblock, int create,
-                  struct buffer_head *bh)
-{
-       struct metapath mp;
-       int ret;
-
-       bmap_lock(inode, create);
-       ret = gfs2_block_pointers(inode, lblock, create, bh, &mp);
+out_ok:
+       error = 0;
+out_fail:
        bmap_unlock(inode, create);
-       return ret;
+       return error;
 }
 
 int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen)
 {
-       struct metapath mp;
        struct buffer_head bh = { .b_state = 0, .b_blocknr = 0 };
        int ret;
        int create = *new;
@@ -564,9 +560,7 @@ int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsi
        BUG_ON(!new);
 
        bh.b_size = 1 << (inode->i_blkbits + 5);
-       bmap_lock(inode, create);
-       ret = gfs2_block_pointers(inode, lblock, create, &bh, &mp);
-       bmap_unlock(inode, create);
+       ret = gfs2_block_map(inode, lblock, create, &bh);
        *extlen = bh.b_size >> inode->i_blkbits;
        *dblock = bh.b_blocknr;
        if (buffer_new(&bh))
@@ -600,7 +594,7 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh,
 {
        struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
        struct buffer_head *bh = NULL;
-       u64 *top, *bottom;
+       __be64 *top, *bottom;
        u64 bn;
        int error;
        int mh_size = sizeof(struct gfs2_meta_header);
@@ -611,17 +605,17 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh,
                        return error;
                dibh = bh;
 
-               top = (u64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + mp->mp_list[0];
-               bottom = (u64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + sdp->sd_diptrs;
+               top = (__be64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + mp->mp_list[0];
+               bottom = (__be64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + sdp->sd_diptrs;
        } else {
                error = gfs2_meta_indirect_buffer(ip, height, block, 0, &bh);
                if (error)
                        return error;
 
-               top = (u64 *)(bh->b_data + mh_size) +
+               top = (__be64 *)(bh->b_data + mh_size) +
                                  (first ? mp->mp_list[height] : 0);
 
-               bottom = (u64 *)(bh->b_data + mh_size) + sdp->sd_inptrs;
+               bottom = (__be64 *)(bh->b_data + mh_size) + sdp->sd_inptrs;
        }
 
        error = bc(ip, dibh, bh, top, bottom, height, data);
@@ -660,7 +654,7 @@ out:
  */
 
 static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
-                   struct buffer_head *bh, u64 *top, u64 *bottom,
+                   struct buffer_head *bh, __be64 *top, __be64 *bottom,
                    unsigned int height, void *data)
 {
        struct strip_mine *sm = data;
@@ -668,7 +662,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
        struct gfs2_rgrp_list rlist;
        u64 bn, bstart;
        u32 blen;
-       u64 *p;
+       __be64 *p;
        unsigned int rg_blocks = 0;
        int metadata;
        unsigned int revokes = 0;
@@ -770,6 +764,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
                if (!ip->i_di.di_blocks)
                        gfs2_consist_inode(ip);
                ip->i_di.di_blocks--;
+               gfs2_set_inode_blocks(&ip->i_inode);
        }
        if (bstart) {
                if (metadata)
@@ -778,9 +773,9 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
                        gfs2_free_data(ip, bstart, blen);
        }
 
-       ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds();
+       ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
 
-       gfs2_dinode_out(&ip->i_di, dibh->b_data);
+       gfs2_dinode_out(ip, dibh->b_data);
 
        up_write(&ip->i_rw_mutex);
 
@@ -819,7 +814,7 @@ static int do_grow(struct gfs2_inode *ip, u64 size)
        if (error)
                goto out;
 
-       error = gfs2_quota_check(ip, ip->i_di.di_uid, ip->i_di.di_gid);
+       error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
        if (error)
                goto out_gunlock_q;
 
@@ -853,14 +848,14 @@ static int do_grow(struct gfs2_inode *ip, u64 size)
        }
 
        ip->i_di.di_size = size;
-       ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds();
+       ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
 
        error = gfs2_meta_inode_buffer(ip, &dibh);
        if (error)
                goto out_end_trans;
 
        gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-       gfs2_dinode_out(&ip->i_di, dibh->b_data);
+       gfs2_dinode_out(ip, dibh->b_data);
        brelse(dibh);
 
 out_end_trans:
@@ -968,9 +963,9 @@ static int trunc_start(struct gfs2_inode *ip, u64 size)
 
        if (gfs2_is_stuffed(ip)) {
                ip->i_di.di_size = size;
-               ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds();
+               ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
                gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-               gfs2_dinode_out(&ip->i_di, dibh->b_data);
+               gfs2_dinode_out(ip, dibh->b_data);
                gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode) + size);
                error = 1;
 
@@ -980,10 +975,10 @@ static int trunc_start(struct gfs2_inode *ip, u64 size)
 
                if (!error) {
                        ip->i_di.di_size = size;
-                       ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds();
+                       ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
                        ip->i_di.di_flags |= GFS2_DIF_TRUNC_IN_PROG;
                        gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-                       gfs2_dinode_out(&ip->i_di, dibh->b_data);
+                       gfs2_dinode_out(ip, dibh->b_data);
                }
        }
 
@@ -1053,11 +1048,11 @@ static int trunc_end(struct gfs2_inode *ip)
                        ip->i_num.no_addr;
                gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
        }
-       ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds();
+       ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
        ip->i_di.di_flags &= ~GFS2_DIF_TRUNC_IN_PROG;
 
        gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-       gfs2_dinode_out(&ip->i_di, dibh->b_data);
+       gfs2_dinode_out(ip, dibh->b_data);
        brelse(dibh);
 
 out:
@@ -1109,7 +1104,7 @@ int gfs2_truncatei(struct gfs2_inode *ip, u64 size)
 {
        int error;
 
-       if (gfs2_assert_warn(GFS2_SB(&ip->i_inode), S_ISREG(ip->i_di.di_mode)))
+       if (gfs2_assert_warn(GFS2_SB(&ip->i_inode), S_ISREG(ip->i_inode.i_mode)))
                return -EINVAL;
 
        if (size > ip->i_di.di_size)
index cab1f68d468518ad9ed37f56b378c170bbab3710..683cb5bda870fc372e79500c105ddf16c9ab93b9 100644 (file)
@@ -112,6 +112,7 @@ int gfs2_logd(void *data)
        struct gfs2_sbd *sdp = data;
        struct gfs2_holder ji_gh;
        unsigned long t;
+       int need_flush;
 
        while (!kthread_should_stop()) {
                /* Advance the log tail */
@@ -120,8 +121,10 @@ int gfs2_logd(void *data)
                    gfs2_tune_get(sdp, gt_log_flush_secs) * HZ;
 
                gfs2_ail1_empty(sdp, DIO_ALL);
-
-               if (time_after_eq(jiffies, t)) {
+               gfs2_log_lock(sdp);
+               need_flush = sdp->sd_log_num_buf > gfs2_tune_get(sdp, gt_incore_log_blocks);
+               gfs2_log_unlock(sdp);
+               if (need_flush || time_after_eq(jiffies, t)) {
                        gfs2_log_flush(sdp, NULL);
                        sdp->sd_log_flush_time = jiffies;
                }
index e24af28b1a121e556ce19770682c4c9ae4df5fe1..0fdcb7713cd9378c1fe723b61b6eda9e7a1711ee 100644 (file)
@@ -131,8 +131,8 @@ static int gfs2_dir_write_stuffed(struct gfs2_inode *ip, const char *buf,
        memcpy(dibh->b_data + offset + sizeof(struct gfs2_dinode), buf, size);
        if (ip->i_di.di_size < offset + size)
                ip->i_di.di_size = offset + size;
-       ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds();
-       gfs2_dinode_out(&ip->i_di, dibh->b_data);
+       ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
+       gfs2_dinode_out(ip, dibh->b_data);
 
        brelse(dibh);
 
@@ -229,10 +229,10 @@ out:
 
        if (ip->i_di.di_size < offset + copied)
                ip->i_di.di_size = offset + copied;
-       ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds();
+       ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
 
        gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-       gfs2_dinode_out(&ip->i_di, dibh->b_data);
+       gfs2_dinode_out(ip, dibh->b_data);
        brelse(dibh);
 
        return copied;
@@ -340,10 +340,15 @@ fail:
        return (copied) ? copied : error;
 }
 
+static inline int gfs2_dirent_sentinel(const struct gfs2_dirent *dent)
+{
+       return dent->de_inum.no_addr == 0 || dent->de_inum.no_formal_ino == 0;
+}
+
 static inline int __gfs2_dirent_find(const struct gfs2_dirent *dent,
                                     const struct qstr *name, int ret)
 {
-       if (dent->de_inum.no_addr != 0 &&
+       if (!gfs2_dirent_sentinel(dent) &&
            be32_to_cpu(dent->de_hash) == name->hash &&
            be16_to_cpu(dent->de_name_len) == name->len &&
            memcmp(dent+1, name->name, name->len) == 0)
@@ -388,7 +393,7 @@ static int gfs2_dirent_find_space(const struct gfs2_dirent *dent,
        unsigned actual = GFS2_DIRENT_SIZE(be16_to_cpu(dent->de_name_len));
        unsigned totlen = be16_to_cpu(dent->de_rec_len);
 
-       if (!dent->de_inum.no_addr)
+       if (gfs2_dirent_sentinel(dent))
                actual = GFS2_DIRENT_SIZE(0);
        if (totlen - actual >= required)
                return 1;
@@ -405,7 +410,7 @@ static int gfs2_dirent_gather(const struct gfs2_dirent *dent,
                              void *opaque)
 {
        struct dirent_gather *g = opaque;
-       if (dent->de_inum.no_addr) {
+       if (!gfs2_dirent_sentinel(dent)) {
                g->pdent[g->offset++] = dent;
        }
        return 0;
@@ -433,10 +438,10 @@ static int gfs2_check_dirent(struct gfs2_dirent *dent, unsigned int offset,
        if (unlikely(offset + size > len))
                goto error;
        msg = "zero inode number";
-       if (unlikely(!first && !dent->de_inum.no_addr))
+       if (unlikely(!first && gfs2_dirent_sentinel(dent)))
                goto error;
        msg = "name length is greater than space in dirent";
-       if (dent->de_inum.no_addr &&
+       if (!gfs2_dirent_sentinel(dent) &&
            unlikely(sizeof(struct gfs2_dirent)+be16_to_cpu(dent->de_name_len) >
                     size))
                goto error;
@@ -598,7 +603,7 @@ static int dirent_next(struct gfs2_inode *dip, struct buffer_head *bh,
                return ret;
 
         /* Only the first dent could ever have de_inum.no_addr == 0 */
-       if (!tmp->de_inum.no_addr) {
+       if (gfs2_dirent_sentinel(tmp)) {
                gfs2_consist_inode(dip);
                return -EIO;
        }
@@ -621,7 +626,7 @@ static void dirent_del(struct gfs2_inode *dip, struct buffer_head *bh,
 {
        u16 cur_rec_len, prev_rec_len;
 
-       if (!cur->de_inum.no_addr) {
+       if (gfs2_dirent_sentinel(cur)) {
                gfs2_consist_inode(dip);
                return;
        }
@@ -633,7 +638,8 @@ static void dirent_del(struct gfs2_inode *dip, struct buffer_head *bh,
           out the inode number and return.  */
 
        if (!prev) {
-               cur->de_inum.no_addr = 0;       /* No endianess worries */
+               cur->de_inum.no_addr = 0;
+               cur->de_inum.no_formal_ino = 0;
                return;
        }
 
@@ -664,7 +670,7 @@ static struct gfs2_dirent *gfs2_init_dirent(struct inode *inode,
        struct gfs2_dirent *ndent;
        unsigned offset = 0, totlen;
 
-       if (dent->de_inum.no_addr)
+       if (!gfs2_dirent_sentinel(dent))
                offset = GFS2_DIRENT_SIZE(be16_to_cpu(dent->de_name_len));
        totlen = be16_to_cpu(dent->de_rec_len);
        BUG_ON(offset + name->len > totlen);
@@ -713,12 +719,12 @@ static int get_leaf(struct gfs2_inode *dip, u64 leaf_no,
 static int get_leaf_nr(struct gfs2_inode *dip, u32 index,
                       u64 *leaf_out)
 {
-       u64 leaf_no;
+       __be64 leaf_no;
        int error;
 
        error = gfs2_dir_read_data(dip, (char *)&leaf_no,
-                                   index * sizeof(u64),
-                                   sizeof(u64), 0);
+                                   index * sizeof(__be64),
+                                   sizeof(__be64), 0);
        if (error != sizeof(u64))
                return (error < 0) ? error : -EIO;
 
@@ -837,7 +843,8 @@ static int dir_make_exhash(struct inode *inode)
        struct gfs2_leaf *leaf;
        int y;
        u32 x;
-       u64 *lp, bn;
+       __be64 *lp;
+       u64 bn;
        int error;
 
        error = gfs2_meta_inode_buffer(dip, &dibh);
@@ -893,20 +900,20 @@ static int dir_make_exhash(struct inode *inode)
        gfs2_trans_add_bh(dip->i_gl, dibh, 1);
        gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
 
-       lp = (u64 *)(dibh->b_data + sizeof(struct gfs2_dinode));
+       lp = (__be64 *)(dibh->b_data + sizeof(struct gfs2_dinode));
 
        for (x = sdp->sd_hash_ptrs; x--; lp++)
                *lp = cpu_to_be64(bn);
 
        dip->i_di.di_size = sdp->sd_sb.sb_bsize / 2;
        dip->i_di.di_blocks++;
+       gfs2_set_inode_blocks(&dip->i_inode);
        dip->i_di.di_flags |= GFS2_DIF_EXHASH;
-       dip->i_di.di_payload_format = 0;
 
        for (x = sdp->sd_hash_ptrs, y = -1; x; x >>= 1, y++) ;
        dip->i_di.di_depth = y;
 
-       gfs2_dinode_out(&dip->i_di, dibh->b_data);
+       gfs2_dinode_out(dip, dibh->b_data);
 
        brelse(dibh);
 
@@ -929,7 +936,8 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
        struct gfs2_leaf *nleaf, *oleaf;
        struct gfs2_dirent *dent = NULL, *prev = NULL, *next = NULL, *new;
        u32 start, len, half_len, divider;
-       u64 bn, *lp, leaf_no;
+       u64 bn, leaf_no;
+       __be64 *lp;
        u32 index;
        int x, moved = 0;
        int error;
@@ -974,7 +982,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
        /* Change the pointers.
           Don't bother distinguishing stuffed from non-stuffed.
           This code is complicated enough already. */
-       lp = kmalloc(half_len * sizeof(u64), GFP_NOFS | __GFP_NOFAIL);
+       lp = kmalloc(half_len * sizeof(__be64), GFP_NOFS | __GFP_NOFAIL);
        /*  Change the pointers  */
        for (x = 0; x < half_len; x++)
                lp[x] = cpu_to_be64(bn);
@@ -1000,7 +1008,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
                if (dirent_next(dip, obh, &next))
                        next = NULL;
 
-               if (dent->de_inum.no_addr &&
+               if (!gfs2_dirent_sentinel(dent) &&
                    be32_to_cpu(dent->de_hash) < divider) {
                        struct qstr str;
                        str.name = (char*)(dent+1);
@@ -1037,7 +1045,8 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
        error = gfs2_meta_inode_buffer(dip, &dibh);
        if (!gfs2_assert_withdraw(GFS2_SB(&dip->i_inode), !error)) {
                dip->i_di.di_blocks++;
-               gfs2_dinode_out(&dip->i_di, dibh->b_data);
+               gfs2_set_inode_blocks(&dip->i_inode);
+               gfs2_dinode_out(dip, dibh->b_data);
                brelse(dibh);
        }
 
@@ -1117,7 +1126,7 @@ static int dir_double_exhash(struct gfs2_inode *dip)
        error = gfs2_meta_inode_buffer(dip, &dibh);
        if (!gfs2_assert_withdraw(sdp, !error)) {
                dip->i_di.di_depth++;
-               gfs2_dinode_out(&dip->i_di, dibh->b_data);
+               gfs2_dinode_out(dip, dibh->b_data);
                brelse(dibh);
        }
 
@@ -1194,7 +1203,7 @@ static int do_filldir_main(struct gfs2_inode *dip, u64 *offset,
                           int *copied)
 {
        const struct gfs2_dirent *dent, *dent_next;
-       struct gfs2_inum inum;
+       struct gfs2_inum_host inum;
        u64 off, off_next;
        unsigned int x, y;
        int run = 0;
@@ -1341,7 +1350,7 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque,
        u32 hsize, len = 0;
        u32 ht_offset, lp_offset, ht_offset_cur = -1;
        u32 hash, index;
-       u64 *lp;
+       __be64 *lp;
        int copied = 0;
        int error = 0;
        unsigned depth = 0;
@@ -1365,7 +1374,7 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque,
 
                if (ht_offset_cur != ht_offset) {
                        error = gfs2_dir_read_data(dip, (char *)lp,
-                                               ht_offset * sizeof(u64),
+                                               ht_offset * sizeof(__be64),
                                                sdp->sd_hash_bsize, 1);
                        if (error != sdp->sd_hash_bsize) {
                                if (error >= 0)
@@ -1456,7 +1465,7 @@ out:
  */
 
 int gfs2_dir_search(struct inode *dir, const struct qstr *name,
-                   struct gfs2_inum *inum, unsigned int *type)
+                   struct gfs2_inum_host *inum, unsigned int *type)
 {
        struct buffer_head *bh;
        struct gfs2_dirent *dent;
@@ -1515,7 +1524,8 @@ static int dir_new_leaf(struct inode *inode, const struct qstr *name)
                return error;
        gfs2_trans_add_bh(ip->i_gl, bh, 1);
        ip->i_di.di_blocks++;
-       gfs2_dinode_out(&ip->i_di, bh->b_data);
+       gfs2_set_inode_blocks(&ip->i_inode);
+       gfs2_dinode_out(ip, bh->b_data);
        brelse(bh);
        return 0;
 }
@@ -1531,7 +1541,7 @@ static int dir_new_leaf(struct inode *inode, const struct qstr *name)
  */
 
 int gfs2_dir_add(struct inode *inode, const struct qstr *name,
-                const struct gfs2_inum *inum, unsigned type)
+                const struct gfs2_inum_host *inum, unsigned type)
 {
        struct gfs2_inode *ip = GFS2_I(inode);
        struct buffer_head *bh;
@@ -1558,8 +1568,8 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
                                break;
                        gfs2_trans_add_bh(ip->i_gl, bh, 1);
                        ip->i_di.di_entries++;
-                       ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds();
-                       gfs2_dinode_out(&ip->i_di, bh->b_data);
+                       ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
+                       gfs2_dinode_out(ip, bh->b_data);
                        brelse(bh);
                        error = 0;
                        break;
@@ -1644,8 +1654,8 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name)
                gfs2_consist_inode(dip);
        gfs2_trans_add_bh(dip->i_gl, bh, 1);
        dip->i_di.di_entries--;
-       dip->i_di.di_mtime = dip->i_di.di_ctime = get_seconds();
-       gfs2_dinode_out(&dip->i_di, bh->b_data);
+       dip->i_inode.i_mtime.tv_sec = dip->i_inode.i_ctime.tv_sec = get_seconds();
+       gfs2_dinode_out(dip, bh->b_data);
        brelse(bh);
        mark_inode_dirty(&dip->i_inode);
 
@@ -1666,7 +1676,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name)
  */
 
 int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename,
-                  struct gfs2_inum *inum, unsigned int new_type)
+                  struct gfs2_inum_host *inum, unsigned int new_type)
 {
        struct buffer_head *bh;
        struct gfs2_dirent *dent;
@@ -1692,8 +1702,8 @@ int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename,
                gfs2_trans_add_bh(dip->i_gl, bh, 1);
        }
 
-       dip->i_di.di_mtime = dip->i_di.di_ctime = get_seconds();
-       gfs2_dinode_out(&dip->i_di, bh->b_data);
+       dip->i_inode.i_mtime.tv_sec = dip->i_inode.i_ctime.tv_sec = get_seconds();
+       gfs2_dinode_out(dip, bh->b_data);
        brelse(bh);
        return 0;
 }
@@ -1715,7 +1725,7 @@ static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data)
        u32 hsize, len;
        u32 ht_offset, lp_offset, ht_offset_cur = -1;
        u32 index = 0;
-       u64 *lp;
+       __be64 *lp;
        u64 leaf_no;
        int error = 0;
 
@@ -1735,7 +1745,7 @@ static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data)
 
                if (ht_offset_cur != ht_offset) {
                        error = gfs2_dir_read_data(dip, (char *)lp,
-                                               ht_offset * sizeof(u64),
+                                               ht_offset * sizeof(__be64),
                                                sdp->sd_hash_bsize, 1);
                        if (error != sdp->sd_hash_bsize) {
                                if (error >= 0)
@@ -1859,6 +1869,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
                if (!dip->i_di.di_blocks)
                        gfs2_consist_inode(dip);
                dip->i_di.di_blocks--;
+               gfs2_set_inode_blocks(&dip->i_inode);
        }
 
        error = gfs2_dir_write_data(dip, ht, index * sizeof(u64), size);
@@ -1873,7 +1884,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
                goto out_end_trans;
 
        gfs2_trans_add_bh(dip->i_gl, dibh, 1);
-       gfs2_dinode_out(&dip->i_di, dibh->b_data);
+       gfs2_dinode_out(dip, dibh->b_data);
        brelse(dibh);
 
 out_end_trans:
index 371233419b073026eb1a96e0066368d3bde6b0df..b21b33668a5bc4ee2ea29c7658c2f8f343232900 100644 (file)
@@ -31,17 +31,17 @@ struct gfs2_inum;
 typedef int (*gfs2_filldir_t) (void *opaque,
                              const char *name, unsigned int length,
                              u64 offset,
-                             struct gfs2_inum *inum, unsigned int type);
+                             struct gfs2_inum_host *inum, unsigned int type);
 
 int gfs2_dir_search(struct inode *dir, const struct qstr *filename,
-                   struct gfs2_inum *inum, unsigned int *type);
+                   struct gfs2_inum_host *inum, unsigned int *type);
 int gfs2_dir_add(struct inode *inode, const struct qstr *filename,
-                const struct gfs2_inum *inum, unsigned int type);
+                const struct gfs2_inum_host *inum, unsigned int type);
 int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *filename);
 int gfs2_dir_read(struct inode *inode, u64 * offset, void *opaque,
                  gfs2_filldir_t filldir);
 int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename,
-                  struct gfs2_inum *new_inum, unsigned int new_type);
+                  struct gfs2_inum_host *new_inum, unsigned int new_type);
 
 int gfs2_dir_exhash_dealloc(struct gfs2_inode *dip);
 
index 92c54e9b0dc3b8592cec55b33c0ba61d185ac37f..cd747c00f670363db6f2dbe41164858e56b4778f 100644 (file)
@@ -120,7 +120,7 @@ static int system_eo_set(struct gfs2_inode *ip, struct gfs2_ea_request *er)
 
        if (GFS2_ACL_IS_ACCESS(er->er_name, er->er_name_len)) {
                if (!(er->er_flags & GFS2_ERF_MODE)) {
-                       er->er_mode = ip->i_di.di_mode;
+                       er->er_mode = ip->i_inode.i_mode;
                        er->er_flags |= GFS2_ERF_MODE;
                }
                error = gfs2_acl_validate_set(ip, 1, er,
index a65a4ccfd4dd172c156e786dfb7648180c1362fc..ebebbdcd7057cf2b2dd1b700eb1ac18aadab5a92 100644 (file)
@@ -112,7 +112,7 @@ fail:
 static int ea_foreach(struct gfs2_inode *ip, ea_call_t ea_call, void *data)
 {
        struct buffer_head *bh, *eabh;
-       u64 *eablk, *end;
+       __be64 *eablk, *end;
        int error;
 
        error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr, DIO_WAIT, &bh);
@@ -129,7 +129,7 @@ static int ea_foreach(struct gfs2_inode *ip, ea_call_t ea_call, void *data)
                goto out;
        }
 
-       eablk = (u64 *)(bh->b_data + sizeof(struct gfs2_meta_header));
+       eablk = (__be64 *)(bh->b_data + sizeof(struct gfs2_meta_header));
        end = eablk + GFS2_SB(&ip->i_inode)->sd_inptrs;
 
        for (; eablk < end; eablk++) {
@@ -224,7 +224,8 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
        struct gfs2_rgrpd *rgd;
        struct gfs2_holder rg_gh;
        struct buffer_head *dibh;
-       u64 *dataptrs, bn = 0;
+       __be64 *dataptrs;
+       u64 bn = 0;
        u64 bstart = 0;
        unsigned int blen = 0;
        unsigned int blks = 0;
@@ -280,6 +281,7 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
                if (!ip->i_di.di_blocks)
                        gfs2_consist_inode(ip);
                ip->i_di.di_blocks--;
+               gfs2_set_inode_blocks(&ip->i_inode);
        }
        if (bstart)
                gfs2_free_meta(ip, bstart, blen);
@@ -299,9 +301,9 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
 
        error = gfs2_meta_inode_buffer(ip, &dibh);
        if (!error) {
-               ip->i_di.di_ctime = get_seconds();
+               ip->i_inode.i_ctime.tv_sec = get_seconds();
                gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-               gfs2_dinode_out(&ip->i_di, dibh->b_data);
+               gfs2_dinode_out(ip, dibh->b_data);
                brelse(dibh);
        }
 
@@ -444,7 +446,7 @@ static int ea_get_unstuffed(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
        struct buffer_head **bh;
        unsigned int amount = GFS2_EA_DATA_LEN(ea);
        unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize);
-       u64 *dataptrs = GFS2_EA2DATAPTRS(ea);
+       __be64 *dataptrs = GFS2_EA2DATAPTRS(ea);
        unsigned int x;
        int error = 0;
 
@@ -597,6 +599,7 @@ static int ea_alloc_blk(struct gfs2_inode *ip, struct buffer_head **bhp)
        ea->ea_num_ptrs = 0;
 
        ip->i_di.di_blocks++;
+       gfs2_set_inode_blocks(&ip->i_inode);
 
        return 0;
 }
@@ -629,7 +632,7 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
                ea->ea_num_ptrs = 0;
                memcpy(GFS2_EA2DATA(ea), er->er_data, er->er_data_len);
        } else {
-               u64 *dataptr = GFS2_EA2DATAPTRS(ea);
+               __be64 *dataptr = GFS2_EA2DATAPTRS(ea);
                const char *data = er->er_data;
                unsigned int data_len = er->er_data_len;
                unsigned int copy;
@@ -648,6 +651,7 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
                        gfs2_metatype_set(bh, GFS2_METATYPE_ED, GFS2_FORMAT_ED);
 
                        ip->i_di.di_blocks++;
+                       gfs2_set_inode_blocks(&ip->i_inode);
 
                        copy = data_len > sdp->sd_jbsize ? sdp->sd_jbsize :
                                                           data_len;
@@ -686,7 +690,7 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
        if (error)
                goto out;
 
-       error = gfs2_quota_check(ip, ip->i_di.di_uid, ip->i_di.di_gid);
+       error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
        if (error)
                goto out_gunlock_q;
 
@@ -710,13 +714,13 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
        if (!error) {
                if (er->er_flags & GFS2_ERF_MODE) {
                        gfs2_assert_withdraw(GFS2_SB(&ip->i_inode),
-                                           (ip->i_di.di_mode & S_IFMT) ==
+                                           (ip->i_inode.i_mode & S_IFMT) ==
                                            (er->er_mode & S_IFMT));
-                       ip->i_di.di_mode = er->er_mode;
+                       ip->i_inode.i_mode = er->er_mode;
                }
-               ip->i_di.di_ctime = get_seconds();
+               ip->i_inode.i_ctime.tv_sec = get_seconds();
                gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-               gfs2_dinode_out(&ip->i_di, dibh->b_data);
+               gfs2_dinode_out(ip, dibh->b_data);
                brelse(dibh);
        }
 
@@ -846,12 +850,12 @@ static int ea_set_simple_noalloc(struct gfs2_inode *ip, struct buffer_head *bh,
 
        if (er->er_flags & GFS2_ERF_MODE) {
                gfs2_assert_withdraw(GFS2_SB(&ip->i_inode),
-                       (ip->i_di.di_mode & S_IFMT) == (er->er_mode & S_IFMT));
-               ip->i_di.di_mode = er->er_mode;
+                       (ip->i_inode.i_mode & S_IFMT) == (er->er_mode & S_IFMT));
+               ip->i_inode.i_mode = er->er_mode;
        }
-       ip->i_di.di_ctime = get_seconds();
+       ip->i_inode.i_ctime.tv_sec = get_seconds();
        gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-       gfs2_dinode_out(&ip->i_di, dibh->b_data);
+       gfs2_dinode_out(ip, dibh->b_data);
        brelse(dibh);
 out:
        gfs2_trans_end(GFS2_SB(&ip->i_inode));
@@ -931,12 +935,12 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er,
 {
        struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
        struct buffer_head *indbh, *newbh;
-       u64 *eablk;
+       __be64 *eablk;
        int error;
        int mh_size = sizeof(struct gfs2_meta_header);
 
        if (ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT) {
-               u64 *end;
+               __be64 *end;
 
                error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr, DIO_WAIT,
                                       &indbh);
@@ -948,7 +952,7 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er,
                        goto out;
                }
 
-               eablk = (u64 *)(indbh->b_data + mh_size);
+               eablk = (__be64 *)(indbh->b_data + mh_size);
                end = eablk + sdp->sd_inptrs;
 
                for (; eablk < end; eablk++)
@@ -971,11 +975,12 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er,
                gfs2_metatype_set(indbh, GFS2_METATYPE_IN, GFS2_FORMAT_IN);
                gfs2_buffer_clear_tail(indbh, mh_size);
 
-               eablk = (u64 *)(indbh->b_data + mh_size);
+               eablk = (__be64 *)(indbh->b_data + mh_size);
                *eablk = cpu_to_be64(ip->i_di.di_eattr);
                ip->i_di.di_eattr = blk;
                ip->i_di.di_flags |= GFS2_DIF_EA_INDIRECT;
                ip->i_di.di_blocks++;
+               gfs2_set_inode_blocks(&ip->i_inode);
 
                eablk++;
        }
@@ -1129,9 +1134,9 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el)
 
        error = gfs2_meta_inode_buffer(ip, &dibh);
        if (!error) {
-               ip->i_di.di_ctime = get_seconds();
+               ip->i_inode.i_ctime.tv_sec = get_seconds();
                gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-               gfs2_dinode_out(&ip->i_di, dibh->b_data);
+               gfs2_dinode_out(ip, dibh->b_data);
                brelse(dibh);
        }
 
@@ -1202,7 +1207,7 @@ static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip,
        struct buffer_head **bh;
        unsigned int amount = GFS2_EA_DATA_LEN(ea);
        unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize);
-       u64 *dataptrs = GFS2_EA2DATAPTRS(ea);
+       __be64 *dataptrs = GFS2_EA2DATAPTRS(ea);
        unsigned int x;
        int error;
 
@@ -1284,9 +1289,8 @@ int gfs2_ea_acl_chmod(struct gfs2_inode *ip, struct gfs2_ea_location *el,
        if (!error) {
                error = inode_setattr(&ip->i_inode, attr);
                gfs2_assert_warn(GFS2_SB(&ip->i_inode), !error);
-               gfs2_inode_attr_out(ip);
                gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-               gfs2_dinode_out(&ip->i_di, dibh->b_data);
+               gfs2_dinode_out(ip, dibh->b_data);
                brelse(dibh);
        }
 
@@ -1300,7 +1304,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
        struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
        struct gfs2_rgrp_list rlist;
        struct buffer_head *indbh, *dibh;
-       u64 *eablk, *end;
+       __be64 *eablk, *end;
        unsigned int rg_blocks = 0;
        u64 bstart = 0;
        unsigned int blen = 0;
@@ -1319,7 +1323,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
                goto out;
        }
 
-       eablk = (u64 *)(indbh->b_data + sizeof(struct gfs2_meta_header));
+       eablk = (__be64 *)(indbh->b_data + sizeof(struct gfs2_meta_header));
        end = eablk + sdp->sd_inptrs;
 
        for (; eablk < end; eablk++) {
@@ -1363,7 +1367,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
 
        gfs2_trans_add_bh(ip->i_gl, indbh, 1);
 
-       eablk = (u64 *)(indbh->b_data + sizeof(struct gfs2_meta_header));
+       eablk = (__be64 *)(indbh->b_data + sizeof(struct gfs2_meta_header));
        bstart = 0;
        blen = 0;
 
@@ -1387,6 +1391,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
                if (!ip->i_di.di_blocks)
                        gfs2_consist_inode(ip);
                ip->i_di.di_blocks--;
+               gfs2_set_inode_blocks(&ip->i_inode);
        }
        if (bstart)
                gfs2_free_meta(ip, bstart, blen);
@@ -1396,7 +1401,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
        error = gfs2_meta_inode_buffer(ip, &dibh);
        if (!error) {
                gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-               gfs2_dinode_out(&ip->i_di, dibh->b_data);
+               gfs2_dinode_out(ip, dibh->b_data);
                brelse(dibh);
        }
 
@@ -1441,11 +1446,12 @@ static int ea_dealloc_block(struct gfs2_inode *ip)
        if (!ip->i_di.di_blocks)
                gfs2_consist_inode(ip);
        ip->i_di.di_blocks--;
+       gfs2_set_inode_blocks(&ip->i_inode);
 
        error = gfs2_meta_inode_buffer(ip, &dibh);
        if (!error) {
                gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-               gfs2_dinode_out(&ip->i_di, dibh->b_data);
+               gfs2_dinode_out(ip, dibh->b_data);
                brelse(dibh);
        }
 
index ffa65947d6869435330031873fcd8c3210ab8012..c82dbe01d7137f07d7bc1a90b59bb2ac22f5dd30 100644 (file)
@@ -19,7 +19,7 @@ struct iattr;
 #define GFS2_EA_SIZE(ea) \
 ALIGN(sizeof(struct gfs2_ea_header) + (ea)->ea_name_len + \
       ((GFS2_EA_IS_STUFFED(ea)) ? GFS2_EA_DATA_LEN(ea) : \
-                                  (sizeof(u64) * (ea)->ea_num_ptrs)), 8)
+                                  (sizeof(__be64) * (ea)->ea_num_ptrs)), 8)
 
 #define GFS2_EA_IS_STUFFED(ea) (!(ea)->ea_num_ptrs)
 #define GFS2_EA_IS_LAST(ea) ((ea)->ea_flags & GFS2_EAFLAG_LAST)
@@ -29,13 +29,13 @@ ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + (er)->er_data_len, 8)
 
 #define GFS2_EAREQ_SIZE_UNSTUFFED(sdp, er) \
 ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + \
-      sizeof(u64) * DIV_ROUND_UP((er)->er_data_len, (sdp)->sd_jbsize), 8)
+      sizeof(__be64) * DIV_ROUND_UP((er)->er_data_len, (sdp)->sd_jbsize), 8)
 
 #define GFS2_EA2NAME(ea) ((char *)((struct gfs2_ea_header *)(ea) + 1))
 #define GFS2_EA2DATA(ea) (GFS2_EA2NAME(ea) + (ea)->ea_name_len)
 
 #define GFS2_EA2DATAPTRS(ea) \
-((u64 *)(GFS2_EA2NAME(ea) + ALIGN((ea)->ea_name_len, 8)))
+((__be64 *)(GFS2_EA2NAME(ea) + ALIGN((ea)->ea_name_len, 8)))
 
 #define GFS2_EA2NEXT(ea) \
 ((struct gfs2_ea_header *)((char *)(ea) + GFS2_EA_REC_LEN(ea)))
index 55f5333dae99e2104eabd8025d7b03560fd9f154..438146904b5839727ac2c378c5df87f574cfedaa 100644 (file)
@@ -96,7 +96,7 @@ static inline rwlock_t *gl_lock_addr(unsigned int x)
        return &gl_hash_locks[x & (GL_HASH_LOCK_SZ-1)];
 }
 #else /* not SMP, so no spinlocks required */
-static inline rwlock_t *gl_lock_addr(x)
+static inline rwlock_t *gl_lock_addr(unsigned int x)
 {
        return NULL;
 }
@@ -769,7 +769,7 @@ restart:
        } else {
                spin_unlock(&gl->gl_spin);
 
-               new_gh = gfs2_holder_get(gl, state, LM_FLAG_TRY, GFP_KERNEL);
+               new_gh = gfs2_holder_get(gl, state, LM_FLAG_TRY, GFP_NOFS);
                if (!new_gh)
                        return;
                set_bit(HIF_DEMOTE, &new_gh->gh_iflags);
@@ -785,21 +785,6 @@ out:
                gfs2_holder_put(new_gh);
 }
 
-void gfs2_glock_inode_squish(struct inode *inode)
-{
-       struct gfs2_holder gh;
-       struct gfs2_glock *gl = GFS2_I(inode)->i_gl;
-       gfs2_holder_init(gl, LM_ST_UNLOCKED, 0, &gh);
-       set_bit(HIF_DEMOTE, &gh.gh_iflags);
-       spin_lock(&gl->gl_spin);
-       gfs2_assert(inode->i_sb->s_fs_info, list_empty(&gl->gl_holders));
-       list_add_tail(&gh.gh_list, &gl->gl_waiters2);
-       run_queue(gl);
-       spin_unlock(&gl->gl_spin);
-       wait_for_completion(&gh.gh_wait);
-       gfs2_holder_uninit(&gh);
-}
-
 /**
  * state_change - record that the glock is now in a different state
  * @gl: the glock
@@ -847,12 +832,12 @@ static void xmote_bh(struct gfs2_glock *gl, unsigned int ret)
 
        if (prev_state != LM_ST_UNLOCKED && !(ret & LM_OUT_CACHEABLE)) {
                if (glops->go_inval)
-                       glops->go_inval(gl, DIO_METADATA | DIO_DATA);
+                       glops->go_inval(gl, DIO_METADATA);
        } else if (gl->gl_state == LM_ST_DEFERRED) {
                /* We might not want to do this here.
                   Look at moving to the inode glops. */
                if (glops->go_inval)
-                       glops->go_inval(gl, DIO_DATA);
+                       glops->go_inval(gl, 0);
        }
 
        /*  Deal with each possible exit condition  */
@@ -954,7 +939,7 @@ void gfs2_glock_xmote_th(struct gfs2_glock *gl, unsigned int state, int flags)
        gfs2_assert_warn(sdp, state != gl->gl_state);
 
        if (gl->gl_state == LM_ST_EXCLUSIVE && glops->go_sync)
-               glops->go_sync(gl, DIO_METADATA | DIO_DATA | DIO_RELEASE);
+               glops->go_sync(gl);
 
        gfs2_glock_hold(gl);
        gl->gl_req_bh = xmote_bh;
@@ -995,7 +980,7 @@ static void drop_bh(struct gfs2_glock *gl, unsigned int ret)
        state_change(gl, LM_ST_UNLOCKED);
 
        if (glops->go_inval)
-               glops->go_inval(gl, DIO_METADATA | DIO_DATA);
+               glops->go_inval(gl, DIO_METADATA);
 
        if (gh) {
                spin_lock(&gl->gl_spin);
@@ -1041,7 +1026,7 @@ void gfs2_glock_drop_th(struct gfs2_glock *gl)
        gfs2_assert_warn(sdp, gl->gl_state != LM_ST_UNLOCKED);
 
        if (gl->gl_state == LM_ST_EXCLUSIVE && glops->go_sync)
-               glops->go_sync(gl, DIO_METADATA | DIO_DATA | DIO_RELEASE);
+               glops->go_sync(gl);
 
        gfs2_glock_hold(gl);
        gl->gl_req_bh = drop_bh;
@@ -1244,9 +1229,6 @@ restart:
 
        clear_bit(GLF_PREFETCH, &gl->gl_flags);
 
-       if (error == GLR_TRYFAILED && (gh->gh_flags & GL_DUMP))
-               dump_glock(gl);
-
        return error;
 }
 
@@ -1923,7 +1905,7 @@ out:
 
 static void scan_glock(struct gfs2_glock *gl)
 {
-       if (gl->gl_ops == &gfs2_inode_glops)
+       if (gl->gl_ops == &gfs2_inode_glops && gl->gl_object)
                return;
 
        if (gfs2_glmutex_trylock(gl)) {
@@ -2078,7 +2060,7 @@ static int dump_inode(struct gfs2_inode *ip)
        printk(KERN_INFO "    num = %llu %llu\n",
                    (unsigned long long)ip->i_num.no_formal_ino,
                    (unsigned long long)ip->i_num.no_addr);
-       printk(KERN_INFO "    type = %u\n", IF2DT(ip->i_di.di_mode));
+       printk(KERN_INFO "    type = %u\n", IF2DT(ip->i_inode.i_mode));
        printk(KERN_INFO "    i_flags =");
        for (x = 0; x < 32; x++)
                if (test_bit(x, &ip->i_flags))
index 2b2a889ee2cc9b516bbf8b9d1ac93a5421172c4c..fb39108fc05c2e378f6d349775ab808a986e3594 100644 (file)
@@ -27,8 +27,6 @@
 #define GL_ATIME               0x00000200
 #define GL_NOCACHE             0x00000400
 #define GL_NOCANCEL            0x00001000
-#define GL_AOP                 0x00004000
-#define GL_DUMP                        0x00008000
 
 #define GLR_TRYFAILED          13
 #define GLR_CANCELED           14
@@ -108,7 +106,6 @@ void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs);
 void gfs2_glock_prefetch_num(struct gfs2_sbd *sdp, u64 number,
                             const struct gfs2_glock_operations *glops,
                             unsigned int state, int flags);
-void gfs2_glock_inode_squish(struct inode *inode);
 
 /**
  * gfs2_glock_nq_init - intialize a holder and enqueue it on a glock
index 41a6b6818a505e1087ba5040d50c7018af6c64b2..b068d10bcb6e75b981eef0b977cd4ca912743960 100644 (file)
@@ -92,7 +92,7 @@ static void gfs2_pte_inval(struct gfs2_glock *gl)
 
        ip = gl->gl_object;
        inode = &ip->i_inode;
-       if (!ip || !S_ISREG(ip->i_di.di_mode))
+       if (!ip || !S_ISREG(inode->i_mode))
                return;
 
        if (!test_bit(GIF_PAGED, &ip->i_flags))
@@ -106,90 +106,21 @@ static void gfs2_pte_inval(struct gfs2_glock *gl)
        clear_bit(GIF_SW_PAGED, &ip->i_flags);
 }
 
-/**
- * gfs2_page_inval - Invalidate all pages associated with a glock
- * @gl: the glock
- *
- */
-
-static void gfs2_page_inval(struct gfs2_glock *gl)
-{
-       struct gfs2_inode *ip;
-       struct inode *inode;
-
-       ip = gl->gl_object;
-       inode = &ip->i_inode;
-       if (!ip || !S_ISREG(ip->i_di.di_mode))
-               return;
-
-       truncate_inode_pages(inode->i_mapping, 0);
-       gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), !inode->i_mapping->nrpages);
-       clear_bit(GIF_PAGED, &ip->i_flags);
-}
-
-/**
- * gfs2_page_wait - Wait for writeback of data
- * @gl: the glock
- *
- * Syncs data (not metadata) for a regular file.
- * No-op for all other types.
- */
-
-static void gfs2_page_wait(struct gfs2_glock *gl)
-{
-       struct gfs2_inode *ip = gl->gl_object;
-       struct inode *inode = &ip->i_inode;
-       struct address_space *mapping = inode->i_mapping;
-       int error;
-
-       if (!S_ISREG(ip->i_di.di_mode))
-               return;
-
-       error = filemap_fdatawait(mapping);
-
-       /* Put back any errors cleared by filemap_fdatawait()
-          so they can be caught by someone who can pass them
-          up to user space. */
-
-       if (error == -ENOSPC)
-               set_bit(AS_ENOSPC, &mapping->flags);
-       else if (error)
-               set_bit(AS_EIO, &mapping->flags);
-
-}
-
-static void gfs2_page_writeback(struct gfs2_glock *gl)
-{
-       struct gfs2_inode *ip = gl->gl_object;
-       struct inode *inode = &ip->i_inode;
-       struct address_space *mapping = inode->i_mapping;
-
-       if (!S_ISREG(ip->i_di.di_mode))
-               return;
-
-       filemap_fdatawrite(mapping);
-}
-
 /**
  * meta_go_sync - sync out the metadata for this glock
  * @gl: the glock
- * @flags: DIO_*
  *
  * Called when demoting or unlocking an EX glock.  We must flush
  * to disk all dirty buffers/pages relating to this glock, and must not
  * not return to caller to demote/unlock the glock until I/O is complete.
  */
 
-static void meta_go_sync(struct gfs2_glock *gl, int flags)
+static void meta_go_sync(struct gfs2_glock *gl)
 {
-       if (!(flags & DIO_METADATA))
-               return;
-
        if (test_and_clear_bit(GLF_DIRTY, &gl->gl_flags)) {
                gfs2_log_flush(gl->gl_sbd, gl);
                gfs2_meta_sync(gl);
-               if (flags & DIO_RELEASE)
-                       gfs2_ail_empty_gl(gl);
+               gfs2_ail_empty_gl(gl);
        }
 
 }
@@ -264,31 +195,31 @@ static void inode_go_drop_th(struct gfs2_glock *gl)
 /**
  * inode_go_sync - Sync the dirty data and/or metadata for an inode glock
  * @gl: the glock protecting the inode
- * @flags:
  *
  */
 
-static void inode_go_sync(struct gfs2_glock *gl, int flags)
+static void inode_go_sync(struct gfs2_glock *gl)
 {
-       int meta = (flags & DIO_METADATA);
-       int data = (flags & DIO_DATA);
+       struct gfs2_inode *ip = gl->gl_object;
+
+       if (ip && !S_ISREG(ip->i_inode.i_mode))
+               ip = NULL;
 
        if (test_bit(GLF_DIRTY, &gl->gl_flags)) {
-               if (meta && data) {
-                       gfs2_page_writeback(gl);
-                       gfs2_log_flush(gl->gl_sbd, gl);
-                       gfs2_meta_sync(gl);
-                       gfs2_page_wait(gl);
-                       clear_bit(GLF_DIRTY, &gl->gl_flags);
-               } else if (meta) {
-                       gfs2_log_flush(gl->gl_sbd, gl);
-                       gfs2_meta_sync(gl);
-               } else if (data) {
-                       gfs2_page_writeback(gl);
-                       gfs2_page_wait(gl);
+               gfs2_log_flush(gl->gl_sbd, gl);
+               if (ip)
+                       filemap_fdatawrite(ip->i_inode.i_mapping);
+               gfs2_meta_sync(gl);
+               if (ip) {
+                       struct address_space *mapping = ip->i_inode.i_mapping;
+                       int error = filemap_fdatawait(mapping);
+                       if (error == -ENOSPC)
+                               set_bit(AS_ENOSPC, &mapping->flags);
+                       else if (error)
+                               set_bit(AS_EIO, &mapping->flags);
                }
-               if (flags & DIO_RELEASE)
-                       gfs2_ail_empty_gl(gl);
+               clear_bit(GLF_DIRTY, &gl->gl_flags);
+               gfs2_ail_empty_gl(gl);
        }
 }
 
@@ -301,15 +232,20 @@ static void inode_go_sync(struct gfs2_glock *gl, int flags)
 
 static void inode_go_inval(struct gfs2_glock *gl, int flags)
 {
+       struct gfs2_inode *ip = gl->gl_object;
        int meta = (flags & DIO_METADATA);
-       int data = (flags & DIO_DATA);
 
        if (meta) {
                gfs2_meta_inval(gl);
-               gl->gl_vn++;
+               if (ip)
+                       set_bit(GIF_INVALID, &ip->i_flags);
+       }
+
+       if (ip && S_ISREG(ip->i_inode.i_mode)) {
+               truncate_inode_pages(ip->i_inode.i_mapping, 0);
+               gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), !ip->i_inode.i_mapping->nrpages);
+               clear_bit(GIF_PAGED, &ip->i_flags);
        }
-       if (data)
-               gfs2_page_inval(gl);
 }
 
 /**
@@ -351,11 +287,10 @@ static int inode_go_lock(struct gfs2_holder *gh)
        if (!ip)
                return 0;
 
-       if (ip->i_vn != gl->gl_vn) {
+       if (test_bit(GIF_INVALID, &ip->i_flags)) {
                error = gfs2_inode_refresh(ip);
                if (error)
                        return error;
-               gfs2_inode_attr_in(ip);
        }
 
        if ((ip->i_di.di_flags & GFS2_DIF_TRUNC_IN_PROG) &&
@@ -379,11 +314,8 @@ static void inode_go_unlock(struct gfs2_holder *gh)
        struct gfs2_glock *gl = gh->gh_gl;
        struct gfs2_inode *ip = gl->gl_object;
 
-       if (ip == NULL)
-               return;
-       if (test_bit(GLF_DIRTY, &gl->gl_flags))
-               gfs2_inode_attr_in(ip);
-       gfs2_meta_cache_flush(ip);
+       if (ip)
+               gfs2_meta_cache_flush(ip);
 }
 
 /**
@@ -491,13 +423,13 @@ static void trans_go_xmote_bh(struct gfs2_glock *gl)
        struct gfs2_sbd *sdp = gl->gl_sbd;
        struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode);
        struct gfs2_glock *j_gl = ip->i_gl;
-       struct gfs2_log_header head;
+       struct gfs2_log_header_host head;
        int error;
 
        if (gl->gl_state != LM_ST_UNLOCKED &&
            test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) {
                gfs2_meta_cache_flush(GFS2_I(sdp->sd_jdesc->jd_inode));
-               j_gl->gl_ops->go_inval(j_gl, DIO_METADATA | DIO_DATA);
+               j_gl->gl_ops->go_inval(j_gl, DIO_METADATA);
 
                error = gfs2_find_jhead(sdp->sd_jdesc, &head);
                if (error)
index 118dc693d1117d178883c3283c19ce9ad0faeb55..734421edae85a21ac02bf00e6735228208965919 100644 (file)
@@ -14,8 +14,6 @@
 
 #define DIO_WAIT       0x00000010
 #define DIO_METADATA   0x00000020
-#define DIO_DATA       0x00000040
-#define DIO_RELEASE    0x00000080
 #define DIO_ALL                0x00000100
 
 struct gfs2_log_operations;
@@ -41,7 +39,7 @@ struct gfs2_log_operations {
        void (*lo_before_commit) (struct gfs2_sbd *sdp);
        void (*lo_after_commit) (struct gfs2_sbd *sdp, struct gfs2_ail *ai);
        void (*lo_before_scan) (struct gfs2_jdesc *jd,
-                               struct gfs2_log_header *head, int pass);
+                               struct gfs2_log_header_host *head, int pass);
        int (*lo_scan_elements) (struct gfs2_jdesc *jd, unsigned int start,
                                 struct gfs2_log_descriptor *ld, __be64 *ptr,
                                 int pass);
@@ -67,8 +65,8 @@ struct gfs2_rgrpd {
        struct list_head rd_list_mru;
        struct list_head rd_recent;     /* Recently used rgrps */
        struct gfs2_glock *rd_gl;       /* Glock for this rgrp */
-       struct gfs2_rindex rd_ri;
-       struct gfs2_rgrp rd_rg;
+       struct gfs2_rindex_host rd_ri;
+       struct gfs2_rgrp_host rd_rg;
        u64 rd_rg_vn;
        struct gfs2_bitmap *rd_bits;
        unsigned int rd_bh_count;
@@ -103,18 +101,17 @@ struct gfs2_bufdata {
 };
 
 struct gfs2_glock_operations {
-       void (*go_xmote_th) (struct gfs2_glock * gl, unsigned int state,
-                            int flags);
-       void (*go_xmote_bh) (struct gfs2_glock * gl);
-       void (*go_drop_th) (struct gfs2_glock * gl);
-       void (*go_drop_bh) (struct gfs2_glock * gl);
-       void (*go_sync) (struct gfs2_glock * gl, int flags);
-       void (*go_inval) (struct gfs2_glock * gl, int flags);
-       int (*go_demote_ok) (struct gfs2_glock * gl);
-       int (*go_lock) (struct gfs2_holder * gh);
-       void (*go_unlock) (struct gfs2_holder * gh);
-       void (*go_callback) (struct gfs2_glock * gl, unsigned int state);
-       void (*go_greedy) (struct gfs2_glock * gl);
+       void (*go_xmote_th) (struct gfs2_glock *gl, unsigned int state, int flags);
+       void (*go_xmote_bh) (struct gfs2_glock *gl);
+       void (*go_drop_th) (struct gfs2_glock *gl);
+       void (*go_drop_bh) (struct gfs2_glock *gl);
+       void (*go_sync) (struct gfs2_glock *gl);
+       void (*go_inval) (struct gfs2_glock *gl, int flags);
+       int (*go_demote_ok) (struct gfs2_glock *gl);
+       int (*go_lock) (struct gfs2_holder *gh);
+       void (*go_unlock) (struct gfs2_holder *gh);
+       void (*go_callback) (struct gfs2_glock *gl, unsigned int state);
+       void (*go_greedy) (struct gfs2_glock *gl);
        const int go_type;
 };
 
@@ -217,6 +214,7 @@ struct gfs2_alloc {
 };
 
 enum {
+       GIF_INVALID             = 0,
        GIF_QD_LOCKED           = 1,
        GIF_PAGED               = 2,
        GIF_SW_PAGED            = 3,
@@ -224,12 +222,11 @@ enum {
 
 struct gfs2_inode {
        struct inode i_inode;
-       struct gfs2_inum i_num;
+       struct gfs2_inum_host i_num;
 
        unsigned long i_flags;          /* GIF_... */
 
-       u64 i_vn;
-       struct gfs2_dinode i_di; /* To be replaced by ref to block */
+       struct gfs2_dinode_host i_di; /* To be replaced by ref to block */
 
        struct gfs2_glock *i_gl; /* Move into i_gh? */
        struct gfs2_holder i_iopen_gh;
@@ -450,7 +447,7 @@ struct gfs2_sbd {
        struct super_block *sd_vfs_meta;
        struct kobject sd_kobj;
        unsigned long sd_flags; /* SDF_... */
-       struct gfs2_sb sd_sb;
+       struct gfs2_sb_host sd_sb;
 
        /* Constants computed on mount */
 
@@ -503,8 +500,8 @@ struct gfs2_sbd {
 
        spinlock_t sd_statfs_spin;
        struct mutex sd_statfs_mutex;
-       struct gfs2_statfs_change sd_statfs_master;
-       struct gfs2_statfs_change sd_statfs_local;
+       struct gfs2_statfs_change_host sd_statfs_master;
+       struct gfs2_statfs_change_host sd_statfs_local;
        unsigned long sd_statfs_sync_time;
 
        /* Resource group stuff */
index d470e5286ecd7715e0804a7fc54a6e34015c7559..d122074c45e16d3163dd61d9e819b6c01ae652aa 100644 (file)
 #include "trans.h"
 #include "util.h"
 
-/**
- * gfs2_inode_attr_in - Copy attributes from the dinode into the VFS inode
- * @ip: The GFS2 inode (with embedded disk inode data)
- * @inode:  The Linux VFS inode
- *
- */
-
-void gfs2_inode_attr_in(struct gfs2_inode *ip)
-{
-       struct inode *inode = &ip->i_inode;
-       struct gfs2_dinode *di = &ip->i_di;
-
-       inode->i_ino = ip->i_num.no_addr;
-
-       switch (di->di_mode & S_IFMT) {
-       case S_IFBLK:
-       case S_IFCHR:
-               inode->i_rdev = MKDEV(di->di_major, di->di_minor);
-               break;
-       default:
-               inode->i_rdev = 0;
-               break;
-       };
-
-       inode->i_mode = di->di_mode;
-       inode->i_nlink = di->di_nlink;
-       inode->i_uid = di->di_uid;
-       inode->i_gid = di->di_gid;
-       i_size_write(inode, di->di_size);
-       inode->i_atime.tv_sec = di->di_atime;
-       inode->i_mtime.tv_sec = di->di_mtime;
-       inode->i_ctime.tv_sec = di->di_ctime;
-       inode->i_atime.tv_nsec = 0;
-       inode->i_mtime.tv_nsec = 0;
-       inode->i_ctime.tv_nsec = 0;
-       inode->i_blocks = di->di_blocks <<
-               (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT);
-
-       if (di->di_flags & GFS2_DIF_IMMUTABLE)
-               inode->i_flags |= S_IMMUTABLE;
-       else
-               inode->i_flags &= ~S_IMMUTABLE;
-
-       if (di->di_flags & GFS2_DIF_APPENDONLY)
-               inode->i_flags |= S_APPEND;
-       else
-               inode->i_flags &= ~S_APPEND;
-}
-
-/**
- * gfs2_inode_attr_out - Copy attributes from VFS inode into the dinode
- * @ip: The GFS2 inode
- *
- * Only copy out the attributes that we want the VFS layer
- * to be able to modify.
- */
-
-void gfs2_inode_attr_out(struct gfs2_inode *ip)
-{
-       struct inode *inode = &ip->i_inode;
-       struct gfs2_dinode *di = &ip->i_di;
-       gfs2_assert_withdraw(GFS2_SB(inode),
-               (di->di_mode & S_IFMT) == (inode->i_mode & S_IFMT));
-       di->di_mode = inode->i_mode;
-       di->di_uid = inode->i_uid;
-       di->di_gid = inode->i_gid;
-       di->di_atime = inode->i_atime.tv_sec;
-       di->di_mtime = inode->i_mtime.tv_sec;
-       di->di_ctime = inode->i_ctime.tv_sec;
-}
-
 static int iget_test(struct inode *inode, void *opaque)
 {
        struct gfs2_inode *ip = GFS2_I(inode);
-       struct gfs2_inum *inum = opaque;
+       struct gfs2_inum_host *inum = opaque;
 
-       if (ip && ip->i_num.no_addr == inum->no_addr)
+       if (ip->i_num.no_addr == inum->no_addr)
                return 1;
 
        return 0;
@@ -123,19 +52,20 @@ static int iget_test(struct inode *inode, void *opaque)
 static int iget_set(struct inode *inode, void *opaque)
 {
        struct gfs2_inode *ip = GFS2_I(inode);
-       struct gfs2_inum *inum = opaque;
+       struct gfs2_inum_host *inum = opaque;
 
        ip->i_num = *inum;
+       inode->i_ino = inum->no_addr;
        return 0;
 }
 
-struct inode *gfs2_ilookup(struct super_block *sb, struct gfs2_inum *inum)
+struct inode *gfs2_ilookup(struct super_block *sb, struct gfs2_inum_host *inum)
 {
        return ilookup5(sb, (unsigned long)inum->no_formal_ino,
                        iget_test, inum);
 }
 
-static struct inode *gfs2_iget(struct super_block *sb, struct gfs2_inum *inum)
+static struct inode *gfs2_iget(struct super_block *sb, struct gfs2_inum_host *inum)
 {
        return iget5_locked(sb, (unsigned long)inum->no_formal_ino,
                     iget_test, iget_set, inum);
@@ -150,7 +80,7 @@ static struct inode *gfs2_iget(struct super_block *sb, struct gfs2_inum *inum)
  * Returns: A VFS inode, or an error
  */
 
-struct inode *gfs2_inode_lookup(struct super_block *sb, struct gfs2_inum *inum, unsigned int type)
+struct inode *gfs2_inode_lookup(struct super_block *sb, struct gfs2_inum_host *inum, unsigned int type)
 {
        struct inode *inode = gfs2_iget(sb, inum);
        struct gfs2_inode *ip = GFS2_I(inode);
@@ -188,7 +118,7 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, struct gfs2_inum *inum,
                if (unlikely(error))
                        goto fail_put;
 
-               ip->i_vn = ip->i_gl->gl_vn - 1;
+               set_bit(GIF_INVALID, &ip->i_flags);
                error = gfs2_glock_nq_init(io_gl, LM_ST_SHARED, GL_EXACT, &ip->i_iopen_gh);
                if (unlikely(error))
                        goto fail_iopen;
@@ -208,6 +138,63 @@ fail:
        return ERR_PTR(error);
 }
 
+static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
+{
+       struct gfs2_dinode_host *di = &ip->i_di;
+       const struct gfs2_dinode *str = buf;
+
+       if (ip->i_num.no_addr != be64_to_cpu(str->di_num.no_addr)) {
+               if (gfs2_consist_inode(ip))
+                       gfs2_dinode_print(ip);
+               return -EIO;
+       }
+       if (ip->i_num.no_formal_ino != be64_to_cpu(str->di_num.no_formal_ino))
+               return -ESTALE;
+
+       ip->i_inode.i_mode = be32_to_cpu(str->di_mode);
+       ip->i_inode.i_rdev = 0;
+       switch (ip->i_inode.i_mode & S_IFMT) {
+       case S_IFBLK:
+       case S_IFCHR:
+               ip->i_inode.i_rdev = MKDEV(be32_to_cpu(str->di_major),
+                                          be32_to_cpu(str->di_minor));
+               break;
+       };
+
+       ip->i_inode.i_uid = be32_to_cpu(str->di_uid);
+       ip->i_inode.i_gid = be32_to_cpu(str->di_gid);
+       /*
+        * We will need to review setting the nlink count here in the
+        * light of the forthcoming ro bind mount work. This is a reminder
+        * to do that.
+        */
+       ip->i_inode.i_nlink = be32_to_cpu(str->di_nlink);
+       di->di_size = be64_to_cpu(str->di_size);
+       i_size_write(&ip->i_inode, di->di_size);
+       di->di_blocks = be64_to_cpu(str->di_blocks);
+       gfs2_set_inode_blocks(&ip->i_inode);
+       ip->i_inode.i_atime.tv_sec = be64_to_cpu(str->di_atime);
+       ip->i_inode.i_atime.tv_nsec = 0;
+       ip->i_inode.i_mtime.tv_sec = be64_to_cpu(str->di_mtime);
+       ip->i_inode.i_mtime.tv_nsec = 0;
+       ip->i_inode.i_ctime.tv_sec = be64_to_cpu(str->di_ctime);
+       ip->i_inode.i_ctime.tv_nsec = 0;
+
+       di->di_goal_meta = be64_to_cpu(str->di_goal_meta);
+       di->di_goal_data = be64_to_cpu(str->di_goal_data);
+       di->di_generation = be64_to_cpu(str->di_generation);
+
+       di->di_flags = be32_to_cpu(str->di_flags);
+       gfs2_set_inode_flags(&ip->i_inode);
+       di->di_height = be16_to_cpu(str->di_height);
+
+       di->di_depth = be16_to_cpu(str->di_depth);
+       di->di_entries = be32_to_cpu(str->di_entries);
+
+       di->di_eattr = be64_to_cpu(str->di_eattr);
+       return 0;
+}
+
 /**
  * gfs2_inode_refresh - Refresh the incore copy of the dinode
  * @ip: The GFS2 inode
@@ -229,21 +216,11 @@ int gfs2_inode_refresh(struct gfs2_inode *ip)
                return -EIO;
        }
 
-       gfs2_dinode_in(&ip->i_di, dibh->b_data);
-
+       error = gfs2_dinode_in(ip, dibh->b_data);
        brelse(dibh);
+       clear_bit(GIF_INVALID, &ip->i_flags);
 
-       if (ip->i_num.no_addr != ip->i_di.di_num.no_addr) {
-               if (gfs2_consist_inode(ip))
-                       gfs2_dinode_print(&ip->i_di);
-               return -EIO;
-       }
-       if (ip->i_num.no_formal_ino != ip->i_di.di_num.no_formal_ino)
-               return -ESTALE;
-
-       ip->i_vn = ip->i_gl->gl_vn;
-
-       return 0;
+       return error;
 }
 
 int gfs2_dinode_dealloc(struct gfs2_inode *ip)
@@ -255,7 +232,7 @@ int gfs2_dinode_dealloc(struct gfs2_inode *ip)
 
        if (ip->i_di.di_blocks != 1) {
                if (gfs2_consist_inode(ip))
-                       gfs2_dinode_print(&ip->i_di);
+                       gfs2_dinode_print(ip);
                return -EIO;
        }
 
@@ -318,14 +295,14 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff)
        u32 nlink;
        int error;
 
-       BUG_ON(ip->i_di.di_nlink != ip->i_inode.i_nlink);
-       nlink = ip->i_di.di_nlink + diff;
+       BUG_ON(diff != 1 && diff != -1);
+       nlink = ip->i_inode.i_nlink + diff;
 
        /* If we are reducing the nlink count, but the new value ends up being
           bigger than the old one, we must have underflowed. */
-       if (diff < 0 && nlink > ip->i_di.di_nlink) {
+       if (diff < 0 && nlink > ip->i_inode.i_nlink) {
                if (gfs2_consist_inode(ip))
-                       gfs2_dinode_print(&ip->i_di);
+                       gfs2_dinode_print(ip);
                return -EIO;
        }
 
@@ -333,16 +310,19 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff)
        if (error)
                return error;
 
-       ip->i_di.di_nlink = nlink;
-       ip->i_di.di_ctime = get_seconds();
-       ip->i_inode.i_nlink = nlink;
+       if (diff > 0)
+               inc_nlink(&ip->i_inode);
+       else
+               drop_nlink(&ip->i_inode);
+
+       ip->i_inode.i_ctime.tv_sec = get_seconds();
 
        gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-       gfs2_dinode_out(&ip->i_di, dibh->b_data);
+       gfs2_dinode_out(ip, dibh->b_data);
        brelse(dibh);
        mark_inode_dirty(&ip->i_inode);
 
-       if (ip->i_di.di_nlink == 0) {
+       if (ip->i_inode.i_nlink == 0) {
                struct gfs2_rgrpd *rgd;
                struct gfs2_holder ri_gh, rg_gh;
 
@@ -357,7 +337,6 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff)
                if (error)
                        goto out_norgrp;
 
-               clear_nlink(&ip->i_inode);
                gfs2_unlink_di(&ip->i_inode); /* mark inode unlinked */
                gfs2_glock_dq_uninit(&rg_gh);
 out_norgrp:
@@ -394,7 +373,7 @@ struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
        struct super_block *sb = dir->i_sb;
        struct gfs2_inode *dip = GFS2_I(dir);
        struct gfs2_holder d_gh;
-       struct gfs2_inum inum;
+       struct gfs2_inum_host inum;
        unsigned int type;
        int error = 0;
        struct inode *inode = NULL;
@@ -436,7 +415,7 @@ static int pick_formal_ino_1(struct gfs2_sbd *sdp, u64 *formal_ino)
 {
        struct gfs2_inode *ip = GFS2_I(sdp->sd_ir_inode);
        struct buffer_head *bh;
-       struct gfs2_inum_range ir;
+       struct gfs2_inum_range_host ir;
        int error;
 
        error = gfs2_trans_begin(sdp, RES_DINODE, 0);
@@ -479,7 +458,7 @@ static int pick_formal_ino_2(struct gfs2_sbd *sdp, u64 *formal_ino)
        struct gfs2_inode *m_ip = GFS2_I(sdp->sd_inum_inode);
        struct gfs2_holder gh;
        struct buffer_head *bh;
-       struct gfs2_inum_range ir;
+       struct gfs2_inum_range_host ir;
        int error;
 
        error = gfs2_glock_nq_init(m_ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
@@ -500,21 +479,22 @@ static int pick_formal_ino_2(struct gfs2_sbd *sdp, u64 *formal_ino)
        if (!ir.ir_length) {
                struct buffer_head *m_bh;
                u64 x, y;
+               __be64 z;
 
                error = gfs2_meta_inode_buffer(m_ip, &m_bh);
                if (error)
                        goto out_brelse;
 
-               x = *(u64 *)(m_bh->b_data + sizeof(struct gfs2_dinode));
-               x = y = be64_to_cpu(x);
+               z = *(__be64 *)(m_bh->b_data + sizeof(struct gfs2_dinode));
+               x = y = be64_to_cpu(z);
                ir.ir_start = x;
                ir.ir_length = GFS2_INUM_QUANTUM;
                x += GFS2_INUM_QUANTUM;
                if (x < y)
                        gfs2_consist_inode(m_ip);
-               x = cpu_to_be64(x);
+               z = cpu_to_be64(x);
                gfs2_trans_add_bh(m_ip->i_gl, m_bh, 1);
-               *(u64 *)(m_bh->b_data + sizeof(struct gfs2_dinode)) = x;
+               *(__be64 *)(m_bh->b_data + sizeof(struct gfs2_dinode)) = z;
 
                brelse(m_bh);
        }
@@ -567,7 +547,7 @@ static int create_ok(struct gfs2_inode *dip, const struct qstr *name,
                return error;
 
        /*  Don't create entries in an unlinked directory  */
-       if (!dip->i_di.di_nlink)
+       if (!dip->i_inode.i_nlink)
                return -EPERM;
 
        error = gfs2_dir_search(&dip->i_inode, name, NULL, NULL);
@@ -583,7 +563,7 @@ static int create_ok(struct gfs2_inode *dip, const struct qstr *name,
 
        if (dip->i_di.di_entries == (u32)-1)
                return -EFBIG;
-       if (S_ISDIR(mode) && dip->i_di.di_nlink == (u32)-1)
+       if (S_ISDIR(mode) && dip->i_inode.i_nlink == (u32)-1)
                return -EMLINK;
 
        return 0;
@@ -593,24 +573,24 @@ static void munge_mode_uid_gid(struct gfs2_inode *dip, unsigned int *mode,
                               unsigned int *uid, unsigned int *gid)
 {
        if (GFS2_SB(&dip->i_inode)->sd_args.ar_suiddir &&
-           (dip->i_di.di_mode & S_ISUID) && dip->i_di.di_uid) {
+           (dip->i_inode.i_mode & S_ISUID) && dip->i_inode.i_uid) {
                if (S_ISDIR(*mode))
                        *mode |= S_ISUID;
-               else if (dip->i_di.di_uid != current->fsuid)
+               else if (dip->i_inode.i_uid != current->fsuid)
                        *mode &= ~07111;
-               *uid = dip->i_di.di_uid;
+               *uid = dip->i_inode.i_uid;
        } else
                *uid = current->fsuid;
 
-       if (dip->i_di.di_mode & S_ISGID) {
+       if (dip->i_inode.i_mode & S_ISGID) {
                if (S_ISDIR(*mode))
                        *mode |= S_ISGID;
-               *gid = dip->i_di.di_gid;
+               *gid = dip->i_inode.i_gid;
        } else
                *gid = current->fsgid;
 }
 
-static int alloc_dinode(struct gfs2_inode *dip, struct gfs2_inum *inum,
+static int alloc_dinode(struct gfs2_inode *dip, struct gfs2_inum_host *inum,
                        u64 *generation)
 {
        struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
@@ -650,9 +630,9 @@ out:
  */
 
 static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
-                       const struct gfs2_inum *inum, unsigned int mode,
+                       const struct gfs2_inum_host *inum, unsigned int mode,
                        unsigned int uid, unsigned int gid,
-                       const u64 *generation)
+                       const u64 *generation, dev_t dev)
 {
        struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
        struct gfs2_dinode *di;
@@ -669,14 +649,15 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
        di->di_mode = cpu_to_be32(mode);
        di->di_uid = cpu_to_be32(uid);
        di->di_gid = cpu_to_be32(gid);
-       di->di_nlink = cpu_to_be32(0);
-       di->di_size = cpu_to_be64(0);
+       di->di_nlink = 0;
+       di->di_size = 0;
        di->di_blocks = cpu_to_be64(1);
        di->di_atime = di->di_mtime = di->di_ctime = cpu_to_be64(get_seconds());
-       di->di_major = di->di_minor = cpu_to_be32(0);
+       di->di_major = cpu_to_be32(MAJOR(dev));
+       di->di_minor = cpu_to_be32(MINOR(dev));
        di->di_goal_meta = di->di_goal_data = cpu_to_be64(inum->no_addr);
        di->di_generation = cpu_to_be64(*generation);
-       di->di_flags = cpu_to_be32(0);
+       di->di_flags = 0;
 
        if (S_ISREG(mode)) {
                if ((dip->i_di.di_flags & GFS2_DIF_INHERIT_JDATA) ||
@@ -693,22 +674,22 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
        }
 
        di->__pad1 = 0;
-       di->di_payload_format = cpu_to_be32(0);
-       di->di_height = cpu_to_be32(0);
+       di->di_payload_format = cpu_to_be32(S_ISDIR(mode) ? GFS2_FORMAT_DE : 0);
+       di->di_height = 0;
        di->__pad2 = 0;
        di->__pad3 = 0;
-       di->di_depth = cpu_to_be16(0);
-       di->di_entries = cpu_to_be32(0);
+       di->di_depth = 0;
+       di->di_entries = 0;
        memset(&di->__pad4, 0, sizeof(di->__pad4));
-       di->di_eattr = cpu_to_be64(0);
+       di->di_eattr = 0;
        memset(&di->di_reserved, 0, sizeof(di->di_reserved));
 
        brelse(dibh);
 }
 
 static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
-                      unsigned int mode, const struct gfs2_inum *inum,
-                      const u64 *generation)
+                      unsigned int mode, const struct gfs2_inum_host *inum,
+                      const u64 *generation, dev_t dev)
 {
        struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
        unsigned int uid, gid;
@@ -729,7 +710,7 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
        if (error)
                goto out_quota;
 
-       init_dinode(dip, gl, inum, mode, uid, gid, generation);
+       init_dinode(dip, gl, inum, mode, uid, gid, generation, dev);
        gfs2_quota_change(dip, +1, uid, gid);
        gfs2_trans_end(sdp);
 
@@ -759,8 +740,7 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
        if (alloc_required < 0)
                goto fail;
        if (alloc_required) {
-               error = gfs2_quota_check(dip, dip->i_di.di_uid,
-                                        dip->i_di.di_gid);
+               error = gfs2_quota_check(dip, dip->i_inode.i_uid, dip->i_inode.i_gid);
                if (error)
                        goto fail_quota_locks;
 
@@ -782,16 +762,16 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
                        goto fail_quota_locks;
        }
 
-       error = gfs2_dir_add(&dip->i_inode, name, &ip->i_num, IF2DT(ip->i_di.di_mode));
+       error = gfs2_dir_add(&dip->i_inode, name, &ip->i_num, IF2DT(ip->i_inode.i_mode));
        if (error)
                goto fail_end_trans;
 
        error = gfs2_meta_inode_buffer(ip, &dibh);
        if (error)
                goto fail_end_trans;
-       ip->i_di.di_nlink = 1;
+       ip->i_inode.i_nlink = 1;
        gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-       gfs2_dinode_out(&ip->i_di, dibh->b_data);
+       gfs2_dinode_out(ip, dibh->b_data);
        brelse(dibh);
        return 0;
 
@@ -860,13 +840,13 @@ static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip)
  */
 
 struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name,
-                          unsigned int mode)
+                          unsigned int mode, dev_t dev)
 {
        struct inode *inode;
        struct gfs2_inode *dip = ghs->gh_gl->gl_object;
        struct inode *dir = &dip->i_inode;
        struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
-       struct gfs2_inum inum;
+       struct gfs2_inum_host inum;
        int error;
        u64 generation;
 
@@ -890,35 +870,12 @@ struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name,
        if (error)
                goto fail_gunlock;
 
-       if (inum.no_addr < dip->i_num.no_addr) {
-               gfs2_glock_dq(ghs);
-
-               error = gfs2_glock_nq_num(sdp, inum.no_addr,
-                                         &gfs2_inode_glops, LM_ST_EXCLUSIVE,
-                                         GL_SKIP, ghs + 1);
-               if (error) {
-                       return ERR_PTR(error);
-               }
-
-               gfs2_holder_reinit(LM_ST_EXCLUSIVE, 0, ghs);
-               error = gfs2_glock_nq(ghs);
-               if (error) {
-                       gfs2_glock_dq_uninit(ghs + 1);
-                       return ERR_PTR(error);
-               }
-
-               error = create_ok(dip, name, mode);
-               if (error)
-                       goto fail_gunlock2;
-       } else {
-               error = gfs2_glock_nq_num(sdp, inum.no_addr,
-                                         &gfs2_inode_glops, LM_ST_EXCLUSIVE,
-                                         GL_SKIP, ghs + 1);
-               if (error)
-                       goto fail_gunlock;
-       }
+       error = gfs2_glock_nq_num(sdp, inum.no_addr, &gfs2_inode_glops,
+                                 LM_ST_EXCLUSIVE, GL_SKIP, ghs + 1);
+       if (error)
+               goto fail_gunlock;
 
-       error = make_dinode(dip, ghs[1].gh_gl, mode, &inum, &generation);
+       error = make_dinode(dip, ghs[1].gh_gl, mode, &inum, &generation, dev);
        if (error)
                goto fail_gunlock2;
 
@@ -975,7 +932,7 @@ int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,
 
        if (ip->i_di.di_entries != 2) {
                if (gfs2_consist_inode(ip))
-                       gfs2_dinode_print(&ip->i_di);
+                       gfs2_dinode_print(ip);
                return -EIO;
        }
 
@@ -997,7 +954,12 @@ int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,
        if (error)
                return error;
 
-       error = gfs2_change_nlink(ip, -2);
+       /* It looks odd, but it really should be done twice */
+       error = gfs2_change_nlink(ip, -1);
+       if (error)
+               return error;
+
+       error = gfs2_change_nlink(ip, -1);
        if (error)
                return error;
 
@@ -1018,16 +980,16 @@ int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,
 int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
                   struct gfs2_inode *ip)
 {
-       struct gfs2_inum inum;
+       struct gfs2_inum_host inum;
        unsigned int type;
        int error;
 
        if (IS_IMMUTABLE(&ip->i_inode) || IS_APPEND(&ip->i_inode))
                return -EPERM;
 
-       if ((dip->i_di.di_mode & S_ISVTX) &&
-           dip->i_di.di_uid != current->fsuid &&
-           ip->i_di.di_uid != current->fsuid && !capable(CAP_FOWNER))
+       if ((dip->i_inode.i_mode & S_ISVTX) &&
+           dip->i_inode.i_uid != current->fsuid &&
+           ip->i_inode.i_uid != current->fsuid && !capable(CAP_FOWNER))
                return -EPERM;
 
        if (IS_APPEND(&dip->i_inode))
@@ -1044,7 +1006,7 @@ int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
        if (!gfs2_inum_equal(&inum, &ip->i_num))
                return -ENOENT;
 
-       if (IF2DT(ip->i_di.di_mode) != type) {
+       if (IF2DT(ip->i_inode.i_mode) != type) {
                gfs2_consist_inode(dip);
                return -EIO;
        }
@@ -1194,7 +1156,7 @@ int gfs2_glock_nq_atime(struct gfs2_holder *gh)
                return 0;
 
        curtime = get_seconds();
-       if (curtime - ip->i_di.di_atime >= quantum) {
+       if (curtime - ip->i_inode.i_atime.tv_sec >= quantum) {
                gfs2_glock_dq(gh);
                gfs2_holder_reinit(LM_ST_EXCLUSIVE, gh->gh_flags & ~LM_FLAG_ANY,
                                   gh);
@@ -1206,7 +1168,7 @@ int gfs2_glock_nq_atime(struct gfs2_holder *gh)
                   trying to get exclusive lock. */
 
                curtime = get_seconds();
-               if (curtime - ip->i_di.di_atime >= quantum) {
+               if (curtime - ip->i_inode.i_atime.tv_sec >= quantum) {
                        struct buffer_head *dibh;
                        struct gfs2_dinode *di;
 
@@ -1220,11 +1182,11 @@ int gfs2_glock_nq_atime(struct gfs2_holder *gh)
                        if (error)
                                goto fail_end_trans;
 
-                       ip->i_di.di_atime = curtime;
+                       ip->i_inode.i_atime.tv_sec = curtime;
 
                        gfs2_trans_add_bh(ip->i_gl, dibh, 1);
                        di = (struct gfs2_dinode *)dibh->b_data;
-                       di->di_atime = cpu_to_be64(ip->i_di.di_atime);
+                       di->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec);
                        brelse(dibh);
 
                        gfs2_trans_end(sdp);
@@ -1249,92 +1211,6 @@ fail:
        return error;
 }
 
-/**
- * glock_compare_atime - Compare two struct gfs2_glock structures for sort
- * @arg_a: the first structure
- * @arg_b: the second structure
- *
- * Returns: 1 if A > B
- *         -1 if A < B
- *          0 if A == B
- */
-
-static int glock_compare_atime(const void *arg_a, const void *arg_b)
-{
-       const struct gfs2_holder *gh_a = *(const struct gfs2_holder **)arg_a;
-       const struct gfs2_holder *gh_b = *(const struct gfs2_holder **)arg_b;
-       const struct lm_lockname *a = &gh_a->gh_gl->gl_name;
-       const struct lm_lockname *b = &gh_b->gh_gl->gl_name;
-
-       if (a->ln_number > b->ln_number)
-               return 1;
-       if (a->ln_number < b->ln_number)
-               return -1;
-       if (gh_a->gh_state == LM_ST_SHARED && gh_b->gh_state == LM_ST_EXCLUSIVE)
-               return 1;
-       if (gh_a->gh_state == LM_ST_SHARED && (gh_b->gh_flags & GL_ATIME))
-               return 1;
-
-       return 0;
-}
-
-/**
- * gfs2_glock_nq_m_atime - acquire multiple glocks where one may need an
- *      atime update
- * @num_gh: the number of structures
- * @ghs: an array of struct gfs2_holder structures
- *
- * Returns: 0 on success (all glocks acquired),
- *          errno on failure (no glocks acquired)
- */
-
-int gfs2_glock_nq_m_atime(unsigned int num_gh, struct gfs2_holder *ghs)
-{
-       struct gfs2_holder **p;
-       unsigned int x;
-       int error = 0;
-
-       if (!num_gh)
-               return 0;
-
-       if (num_gh == 1) {
-               ghs->gh_flags &= ~(LM_FLAG_TRY | GL_ASYNC);
-               if (ghs->gh_flags & GL_ATIME)
-                       error = gfs2_glock_nq_atime(ghs);
-               else
-                       error = gfs2_glock_nq(ghs);
-               return error;
-       }
-
-       p = kcalloc(num_gh, sizeof(struct gfs2_holder *), GFP_KERNEL);
-       if (!p)
-               return -ENOMEM;
-
-       for (x = 0; x < num_gh; x++)
-               p[x] = &ghs[x];
-
-       sort(p, num_gh, sizeof(struct gfs2_holder *), glock_compare_atime,NULL);
-
-       for (x = 0; x < num_gh; x++) {
-               p[x]->gh_flags &= ~(LM_FLAG_TRY | GL_ASYNC);
-
-               if (p[x]->gh_flags & GL_ATIME)
-                       error = gfs2_glock_nq_atime(p[x]);
-               else
-                       error = gfs2_glock_nq(p[x]);
-
-               if (error) {
-                       while (x--)
-                               gfs2_glock_dq(p[x]);
-                       break;
-               }
-       }
-
-       kfree(p);
-       return error;
-}
-
-
 static int
 __gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr)
 {
@@ -1345,10 +1221,8 @@ __gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr)
        if (!error) {
                error = inode_setattr(&ip->i_inode, attr);
                gfs2_assert_warn(GFS2_SB(&ip->i_inode), !error);
-               gfs2_inode_attr_out(ip);
-
                gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-               gfs2_dinode_out(&ip->i_di, dibh->b_data);
+               gfs2_dinode_out(ip, dibh->b_data);
                brelse(dibh);
        }
        return error;
index f5d8617605795be28aabdc1cdf11fa002780ebb4..b57f448b15bc42e09c18c2889fe866bdc2efacc6 100644 (file)
@@ -22,13 +22,19 @@ static inline int gfs2_is_jdata(struct gfs2_inode *ip)
 
 static inline int gfs2_is_dir(struct gfs2_inode *ip)
 {
-       return S_ISDIR(ip->i_di.di_mode);
+       return S_ISDIR(ip->i_inode.i_mode);
+}
+
+static inline void gfs2_set_inode_blocks(struct inode *inode)
+{
+       struct gfs2_inode *ip = GFS2_I(inode);
+       inode->i_blocks = ip->i_di.di_blocks <<
+               (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT);
 }
 
 void gfs2_inode_attr_in(struct gfs2_inode *ip);
-void gfs2_inode_attr_out(struct gfs2_inode *ip);
-struct inode *gfs2_inode_lookup(struct super_block *sb, struct gfs2_inum *inum, unsigned type);
-struct inode *gfs2_ilookup(struct super_block *sb, struct gfs2_inum *inum);
+struct inode *gfs2_inode_lookup(struct super_block *sb, struct gfs2_inum_host *inum, unsigned type);
+struct inode *gfs2_ilookup(struct super_block *sb, struct gfs2_inum_host *inum);
 
 int gfs2_inode_refresh(struct gfs2_inode *ip);
 
@@ -37,19 +43,15 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff);
 struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
                           int is_root, struct nameidata *nd);
 struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name,
-                          unsigned int mode);
+                          unsigned int mode, dev_t dev);
 int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,
                struct gfs2_inode *ip);
 int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
                   struct gfs2_inode *ip);
 int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to);
 int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len);
-
 int gfs2_glock_nq_atime(struct gfs2_holder *gh);
-int gfs2_glock_nq_m_atime(unsigned int num_gh, struct gfs2_holder *ghs);
-
 int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr);
-
 struct inode *gfs2_lookup_simple(struct inode *dip, const char *name);
 
 #endif /* __INODE_DOT_H__ */
index 0cace3da9dbb41795b6cacdbe97de52786d3678e..291415ddfe51cb291ccd66b23703e63a58b089d7 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/gfs2_ondisk.h>
 #include <linux/crc32.h>
 #include <linux/lm_interface.h>
+#include <linux/delay.h>
 
 #include "gfs2.h"
 #include "incore.h"
@@ -142,7 +143,7 @@ static int gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai, int fl
        return list_empty(&ai->ai_ail1_list);
 }
 
-void gfs2_ail1_start(struct gfs2_sbd *sdp, int flags)
+static void gfs2_ail1_start(struct gfs2_sbd *sdp, int flags)
 {
        struct list_head *head = &sdp->sd_ail1_list;
        u64 sync_gen;
@@ -261,6 +262,12 @@ static void ail2_empty(struct gfs2_sbd *sdp, unsigned int new_tail)
  * @sdp: The GFS2 superblock
  * @blks: The number of blocks to reserve
  *
+ * Note that we never give out the last 6 blocks of the journal. Thats
+ * due to the fact that there is are a small number of header blocks
+ * associated with each log flush. The exact number can't be known until
+ * flush time, so we ensure that we have just enough free blocks at all
+ * times to avoid running out during a log flush.
+ *
  * Returns: errno
  */
 
@@ -274,7 +281,7 @@ int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks)
 
        mutex_lock(&sdp->sd_log_reserve_mutex);
        gfs2_log_lock(sdp);
-       while(sdp->sd_log_blks_free <= blks) {
+       while(sdp->sd_log_blks_free <= (blks + 6)) {
                gfs2_log_unlock(sdp);
                gfs2_ail1_empty(sdp, 0);
                gfs2_log_flush(sdp, NULL);
@@ -319,7 +326,8 @@ static u64 log_bmap(struct gfs2_sbd *sdp, unsigned int lbn)
        bh_map.b_size = 1 << inode->i_blkbits;
        error = gfs2_block_map(inode, lbn, 0, &bh_map);
        if (error || !bh_map.b_blocknr)
-               printk(KERN_INFO "error=%d, dbn=%llu lbn=%u", error, bh_map.b_blocknr, lbn);
+               printk(KERN_INFO "error=%d, dbn=%llu lbn=%u", error,
+                      (unsigned long long)bh_map.b_blocknr, lbn);
        gfs2_assert_withdraw(sdp, !error && bh_map.b_blocknr);
 
        return bh_map.b_blocknr;
@@ -643,12 +651,9 @@ void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
        up_read(&sdp->sd_log_flush_lock);
 
        gfs2_log_lock(sdp);
-       if (sdp->sd_log_num_buf > gfs2_tune_get(sdp, gt_incore_log_blocks)) {
-               gfs2_log_unlock(sdp);
-               gfs2_log_flush(sdp, NULL);
-       } else {
-               gfs2_log_unlock(sdp);
-       }
+       if (sdp->sd_log_num_buf > gfs2_tune_get(sdp, gt_incore_log_blocks))
+               wake_up_process(sdp->sd_logd_process);
+       gfs2_log_unlock(sdp);
 }
 
 /**
@@ -686,3 +691,21 @@ void gfs2_log_shutdown(struct gfs2_sbd *sdp)
        up_write(&sdp->sd_log_flush_lock);
 }
 
+
+/**
+ * gfs2_meta_syncfs - sync all the buffers in a filesystem
+ * @sdp: the filesystem
+ *
+ */
+
+void gfs2_meta_syncfs(struct gfs2_sbd *sdp)
+{
+       gfs2_log_flush(sdp, NULL);
+       for (;;) {
+               gfs2_ail1_start(sdp, DIO_ALL);
+               if (gfs2_ail1_empty(sdp, DIO_ALL))
+                       break;
+               msleep(10);
+       }
+}
+
index 7f5737d55612883e5de8bb922d34d9e9053245bc..8e7aa0f2910961fedd690f9641732bc9e7ed64a7 100644 (file)
@@ -48,7 +48,6 @@ static inline void gfs2_log_pointers_init(struct gfs2_sbd *sdp,
 unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct,
                            unsigned int ssize);
 
-void gfs2_ail1_start(struct gfs2_sbd *sdp, int flags);
 int gfs2_ail1_empty(struct gfs2_sbd *sdp, int flags);
 
 int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks);
@@ -61,5 +60,6 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl);
 void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *trans);
 
 void gfs2_log_shutdown(struct gfs2_sbd *sdp);
+void gfs2_meta_syncfs(struct gfs2_sbd *sdp);
 
 #endif /* __LOG_DOT_H__ */
index ab6d1115f95d5fd2cfdb407a7338e0535fc9c487..4d7f94d8c7bd2ca07162fed385efcc1ae65ea835 100644 (file)
@@ -182,7 +182,7 @@ static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
 }
 
 static void buf_lo_before_scan(struct gfs2_jdesc *jd,
-                              struct gfs2_log_header *head, int pass)
+                              struct gfs2_log_header_host *head, int pass)
 {
        struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
 
@@ -328,7 +328,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
 }
 
 static void revoke_lo_before_scan(struct gfs2_jdesc *jd,
-                                 struct gfs2_log_header *head, int pass)
+                                 struct gfs2_log_header_host *head, int pass)
 {
        struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
 
@@ -509,7 +509,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
 {
        LIST_HEAD(started);
        struct gfs2_bufdata *bd1 = NULL, *bd2, *bdt;
-       struct buffer_head *bh = NULL;
+       struct buffer_head *bh = NULL,*bh1 = NULL;
        unsigned int offset = sizeof(struct gfs2_log_descriptor);
        struct gfs2_log_descriptor *ld;
        unsigned int limit;
@@ -537,8 +537,13 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
                list_for_each_entry_safe_continue(bd1, bdt,
                                                  &sdp->sd_log_le_databuf,
                                                  bd_le.le_list) {
+                       /* store off the buffer head in a local ptr since
+                        * gfs2_bufdata might change when we drop the log lock
+                        */
+                       bh1 = bd1->bd_bh;
+
                        /* An ordered write buffer */
-                       if (bd1->bd_bh && !buffer_pinned(bd1->bd_bh)) {
+                       if (bh1 && !buffer_pinned(bh1)) {
                                list_move(&bd1->bd_le.le_list, &started);
                                if (bd1 == bd2) {
                                        bd2 = NULL;
@@ -547,20 +552,21 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
                                                        bd_le.le_list);
                                }
                                total_dbuf--;
-                               if (bd1->bd_bh) {
-                                       get_bh(bd1->bd_bh);
-                                       if (buffer_dirty(bd1->bd_bh)) {
+                               if (bh1) {
+                                       if (buffer_dirty(bh1)) {
+                                               get_bh(bh1);
+
                                                gfs2_log_unlock(sdp);
-                                               wait_on_buffer(bd1->bd_bh);
-                                               ll_rw_block(WRITE, 1,
-                                                           &bd1->bd_bh);
+
+                                               ll_rw_block(SWRITE, 1, &bh1);
+                                               brelse(bh1);
+
                                                gfs2_log_lock(sdp);
                                        }
-                                       brelse(bd1->bd_bh);
                                        continue;
                                }
                                continue;
-                       } else if (bd1->bd_bh) { /* A journaled buffer */
+                       } else if (bh1) { /* A journaled buffer */
                                int magic;
                                gfs2_log_unlock(sdp);
                                if (!bh) {
@@ -582,16 +588,16 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
                                        ld->ld_data2 = cpu_to_be32(0);
                                        memset(ld->ld_reserved, 0, sizeof(ld->ld_reserved));
                                }
-                               magic = gfs2_check_magic(bd1->bd_bh);
-                               *ptr++ = cpu_to_be64(bd1->bd_bh->b_blocknr);
+                               magic = gfs2_check_magic(bh1);
+                               *ptr++ = cpu_to_be64(bh1->b_blocknr);
                                *ptr++ = cpu_to_be64((__u64)magic);
-                               clear_buffer_escaped(bd1->bd_bh);
+                               clear_buffer_escaped(bh1);
                                if (unlikely(magic != 0))
-                                       set_buffer_escaped(bd1->bd_bh);
+                                       set_buffer_escaped(bh1);
                                gfs2_log_lock(sdp);
                                if (n++ > num)
                                        break;
-                       } else if (!bd1->bd_bh) {
+                       } else if (!bh1) {
                                total_dbuf--;
                                sdp->sd_log_num_databuf--;
                                list_del_init(&bd1->bd_le.le_list);
index 5839c05ae6be29cfc7fe692c2c8f1028aaead2dd..965bc65c7c6432b9f47f3937d4dbd27f5b4c9446 100644 (file)
@@ -60,7 +60,7 @@ static inline void lops_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
 }
 
 static inline void lops_before_scan(struct gfs2_jdesc *jd,
-                                   struct gfs2_log_header *head,
+                                   struct gfs2_log_header_host *head,
                                    unsigned int pass)
 {
        int x;
index 9889c1eacec186efe383f9c9801563123bb0511d..7c1a9e22a526e0c0203d8d1426c2125fe81fcf70 100644 (file)
@@ -25,7 +25,7 @@
 #include "util.h"
 #include "glock.h"
 
-static void gfs2_init_inode_once(void *foo, kmem_cache_t *cachep, unsigned long flags)
+static void gfs2_init_inode_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
 {
        struct gfs2_inode *ip = foo;
        if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
@@ -37,7 +37,7 @@ static void gfs2_init_inode_once(void *foo, kmem_cache_t *cachep, unsigned long
        }
 }
 
-static void gfs2_init_glock_once(void *foo, kmem_cache_t *cachep, unsigned long flags)
+static void gfs2_init_glock_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
 {
        struct gfs2_glock *gl = foo;
        if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
index 3912d6a4b1e65a7debb78120d0817db1106d1f33..0e34d9918973126c710c227bf35197bac57c30cc 100644 (file)
@@ -127,17 +127,17 @@ void gfs2_meta_sync(struct gfs2_glock *gl)
 
 /**
  * getbuf - Get a buffer with a given address space
- * @sdp: the filesystem
- * @aspace: the address space
+ * @gl: the glock
  * @blkno: the block number (filesystem scope)
  * @create: 1 if the buffer should be created
  *
  * Returns: the buffer
  */
 
-static struct buffer_head *getbuf(struct gfs2_sbd *sdp, struct inode *aspace,
-                                 u64 blkno, int create)
+static struct buffer_head *getbuf(struct gfs2_glock *gl, u64 blkno, int create)
 {
+       struct address_space *mapping = gl->gl_aspace->i_mapping;
+       struct gfs2_sbd *sdp = gl->gl_sbd;
        struct page *page;
        struct buffer_head *bh;
        unsigned int shift;
@@ -150,13 +150,13 @@ static struct buffer_head *getbuf(struct gfs2_sbd *sdp, struct inode *aspace,
 
        if (create) {
                for (;;) {
-                       page = grab_cache_page(aspace->i_mapping, index);
+                       page = grab_cache_page(mapping, index);
                        if (page)
                                break;
                        yield();
                }
        } else {
-               page = find_lock_page(aspace->i_mapping, index);
+               page = find_lock_page(mapping, index);
                if (!page)
                        return NULL;
        }
@@ -202,7 +202,7 @@ static void meta_prep_new(struct buffer_head *bh)
 struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno)
 {
        struct buffer_head *bh;
-       bh = getbuf(gl->gl_sbd, gl->gl_aspace, blkno, CREATE);
+       bh = getbuf(gl, blkno, CREATE);
        meta_prep_new(bh);
        return bh;
 }
@@ -220,7 +220,7 @@ struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno)
 int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags,
                   struct buffer_head **bhp)
 {
-       *bhp = getbuf(gl->gl_sbd, gl->gl_aspace, blkno, CREATE);
+       *bhp = getbuf(gl, blkno, CREATE);
        if (!buffer_uptodate(*bhp))
                ll_rw_block(READ_META, 1, bhp);
        if (flags & DIO_WAIT) {
@@ -379,11 +379,10 @@ void gfs2_unpin(struct gfs2_sbd *sdp, struct buffer_head *bh,
 void gfs2_meta_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen)
 {
        struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
-       struct inode *aspace = ip->i_gl->gl_aspace;
        struct buffer_head *bh;
 
        while (blen) {
-               bh = getbuf(sdp, aspace, bstart, NO_CREATE);
+               bh = getbuf(ip->i_gl, bstart, NO_CREATE);
                if (bh) {
                        struct gfs2_bufdata *bd = bh->b_private;
 
@@ -472,6 +471,9 @@ int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, u64 num,
        struct buffer_head *bh = NULL, **bh_slot = ip->i_cache + height;
        int in_cache = 0;
 
+       BUG_ON(!gl);
+       BUG_ON(!sdp);
+
        spin_lock(&ip->i_spin);
        if (*bh_slot && (*bh_slot)->b_blocknr == num) {
                bh = *bh_slot;
@@ -481,7 +483,7 @@ int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, u64 num,
        spin_unlock(&ip->i_spin);
 
        if (!bh)
-               bh = getbuf(gl->gl_sbd, gl->gl_aspace, num, CREATE);
+               bh = getbuf(gl, num, CREATE);
 
        if (!bh)
                return -ENOBUFS;
@@ -532,7 +534,6 @@ err:
 struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen)
 {
        struct gfs2_sbd *sdp = gl->gl_sbd;
-       struct inode *aspace = gl->gl_aspace;
        struct buffer_head *first_bh, *bh;
        u32 max_ra = gfs2_tune_get(sdp, gt_max_readahead) >>
                          sdp->sd_sb.sb_bsize_shift;
@@ -544,7 +545,7 @@ struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen)
        if (extlen > max_ra)
                extlen = max_ra;
 
-       first_bh = getbuf(sdp, aspace, dblock, CREATE);
+       first_bh = getbuf(gl, dblock, CREATE);
 
        if (buffer_uptodate(first_bh))
                goto out;
@@ -555,7 +556,7 @@ struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen)
        extlen--;
 
        while (extlen) {
-               bh = getbuf(sdp, aspace, dblock, CREATE);
+               bh = getbuf(gl, dblock, CREATE);
 
                if (!buffer_uptodate(bh) && !buffer_locked(bh))
                        ll_rw_block(READA, 1, &bh);
@@ -571,20 +572,3 @@ out:
        return first_bh;
 }
 
-/**
- * gfs2_meta_syncfs - sync all the buffers in a filesystem
- * @sdp: the filesystem
- *
- */
-
-void gfs2_meta_syncfs(struct gfs2_sbd *sdp)
-{
-       gfs2_log_flush(sdp, NULL);
-       for (;;) {
-               gfs2_ail1_start(sdp, DIO_ALL);
-               if (gfs2_ail1_empty(sdp, DIO_ALL))
-                       break;
-               msleep(10);
-       }
-}
-
index 3ec939e20dffeffcd66a207fdd58687a2a4947e5..e037425bc0427e6cff31c6bda1bae2daa16cf626 100644 (file)
@@ -67,7 +67,6 @@ static inline int gfs2_meta_inode_buffer(struct gfs2_inode *ip,
 }
 
 struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen);
-void gfs2_meta_syncfs(struct gfs2_sbd *sdp);
 
 #define buffer_busy(bh) \
 ((bh)->b_state & ((1ul << BH_Dirty) | (1ul << BH_Lock) | (1ul << BH_Pinned)))
index 1025960b0e6e8242d8f97bdd2f288576c0d2416f..f2495f1e21adc0fde6f4a51ff73ff1fa8376bb43 100644 (file)
@@ -15,6 +15,8 @@
 
 #include "gfs2.h"
 #include <linux/gfs2_ondisk.h>
+#include <linux/lm_interface.h>
+#include "incore.h"
 
 #define pv(struct, member, fmt) printk(KERN_INFO "  "#member" = "fmt"\n", \
                                       struct->member);
@@ -32,7 +34,7 @@
  * first arg: the cpu-order structure
  */
 
-void gfs2_inum_in(struct gfs2_inum *no, const void *buf)
+void gfs2_inum_in(struct gfs2_inum_host *no, const void *buf)
 {
        const struct gfs2_inum *str = buf;
 
@@ -40,7 +42,7 @@ void gfs2_inum_in(struct gfs2_inum *no, const void *buf)
        no->no_addr = be64_to_cpu(str->no_addr);
 }
 
-void gfs2_inum_out(const struct gfs2_inum *no, void *buf)
+void gfs2_inum_out(const struct gfs2_inum_host *no, void *buf)
 {
        struct gfs2_inum *str = buf;
 
@@ -48,13 +50,13 @@ void gfs2_inum_out(const struct gfs2_inum *no, void *buf)
        str->no_addr = cpu_to_be64(no->no_addr);
 }
 
-static void gfs2_inum_print(const struct gfs2_inum *no)
+static void gfs2_inum_print(const struct gfs2_inum_host *no)
 {
        printk(KERN_INFO "  no_formal_ino = %llu\n", (unsigned long long)no->no_formal_ino);
        printk(KERN_INFO "  no_addr = %llu\n", (unsigned long long)no->no_addr);
 }
 
-static void gfs2_meta_header_in(struct gfs2_meta_header *mh, const void *buf)
+static void gfs2_meta_header_in(struct gfs2_meta_header_host *mh, const void *buf)
 {
        const struct gfs2_meta_header *str = buf;
 
@@ -63,23 +65,7 @@ static void gfs2_meta_header_in(struct gfs2_meta_header *mh, const void *buf)
        mh->mh_format = be32_to_cpu(str->mh_format);
 }
 
-static void gfs2_meta_header_out(const struct gfs2_meta_header *mh, void *buf)
-{
-       struct gfs2_meta_header *str = buf;
-
-       str->mh_magic = cpu_to_be32(mh->mh_magic);
-       str->mh_type = cpu_to_be32(mh->mh_type);
-       str->mh_format = cpu_to_be32(mh->mh_format);
-}
-
-static void gfs2_meta_header_print(const struct gfs2_meta_header *mh)
-{
-       pv(mh, mh_magic, "0x%.8X");
-       pv(mh, mh_type, "%u");
-       pv(mh, mh_format, "%u");
-}
-
-void gfs2_sb_in(struct gfs2_sb *sb, const void *buf)
+void gfs2_sb_in(struct gfs2_sb_host *sb, const void *buf)
 {
        const struct gfs2_sb *str = buf;
 
@@ -97,7 +83,7 @@ void gfs2_sb_in(struct gfs2_sb *sb, const void *buf)
        memcpy(sb->sb_locktable, str->sb_locktable, GFS2_LOCKNAME_LEN);
 }
 
-void gfs2_rindex_in(struct gfs2_rindex *ri, const void *buf)
+void gfs2_rindex_in(struct gfs2_rindex_host *ri, const void *buf)
 {
        const struct gfs2_rindex *str = buf;
 
@@ -109,7 +95,7 @@ void gfs2_rindex_in(struct gfs2_rindex *ri, const void *buf)
 
 }
 
-void gfs2_rindex_print(const struct gfs2_rindex *ri)
+void gfs2_rindex_print(const struct gfs2_rindex_host *ri)
 {
        printk(KERN_INFO "  ri_addr = %llu\n", (unsigned long long)ri->ri_addr);
        pv(ri, ri_length, "%u");
@@ -120,22 +106,20 @@ void gfs2_rindex_print(const struct gfs2_rindex *ri)
        pv(ri, ri_bitbytes, "%u");
 }
 
-void gfs2_rgrp_in(struct gfs2_rgrp *rg, const void *buf)
+void gfs2_rgrp_in(struct gfs2_rgrp_host *rg, const void *buf)
 {
        const struct gfs2_rgrp *str = buf;
 
-       gfs2_meta_header_in(&rg->rg_header, buf);
        rg->rg_flags = be32_to_cpu(str->rg_flags);
        rg->rg_free = be32_to_cpu(str->rg_free);
        rg->rg_dinodes = be32_to_cpu(str->rg_dinodes);
        rg->rg_igeneration = be64_to_cpu(str->rg_igeneration);
 }
 
-void gfs2_rgrp_out(const struct gfs2_rgrp *rg, void *buf)
+void gfs2_rgrp_out(const struct gfs2_rgrp_host *rg, void *buf)
 {
        struct gfs2_rgrp *str = buf;
 
-       gfs2_meta_header_out(&rg->rg_header, buf);
        str->rg_flags = cpu_to_be32(rg->rg_flags);
        str->rg_free = cpu_to_be32(rg->rg_free);
        str->rg_dinodes = cpu_to_be32(rg->rg_dinodes);
@@ -144,7 +128,7 @@ void gfs2_rgrp_out(const struct gfs2_rgrp *rg, void *buf)
        memset(&str->rg_reserved, 0, sizeof(str->rg_reserved));
 }
 
-void gfs2_quota_in(struct gfs2_quota *qu, const void *buf)
+void gfs2_quota_in(struct gfs2_quota_host *qu, const void *buf)
 {
        const struct gfs2_quota *str = buf;
 
@@ -153,96 +137,56 @@ void gfs2_quota_in(struct gfs2_quota *qu, const void *buf)
        qu->qu_value = be64_to_cpu(str->qu_value);
 }
 
-void gfs2_dinode_in(struct gfs2_dinode *di, const void *buf)
-{
-       const struct gfs2_dinode *str = buf;
-
-       gfs2_meta_header_in(&di->di_header, buf);
-       gfs2_inum_in(&di->di_num, &str->di_num);
-
-       di->di_mode = be32_to_cpu(str->di_mode);
-       di->di_uid = be32_to_cpu(str->di_uid);
-       di->di_gid = be32_to_cpu(str->di_gid);
-       di->di_nlink = be32_to_cpu(str->di_nlink);
-       di->di_size = be64_to_cpu(str->di_size);
-       di->di_blocks = be64_to_cpu(str->di_blocks);
-       di->di_atime = be64_to_cpu(str->di_atime);
-       di->di_mtime = be64_to_cpu(str->di_mtime);
-       di->di_ctime = be64_to_cpu(str->di_ctime);
-       di->di_major = be32_to_cpu(str->di_major);
-       di->di_minor = be32_to_cpu(str->di_minor);
-
-       di->di_goal_meta = be64_to_cpu(str->di_goal_meta);
-       di->di_goal_data = be64_to_cpu(str->di_goal_data);
-       di->di_generation = be64_to_cpu(str->di_generation);
-
-       di->di_flags = be32_to_cpu(str->di_flags);
-       di->di_payload_format = be32_to_cpu(str->di_payload_format);
-       di->di_height = be16_to_cpu(str->di_height);
-
-       di->di_depth = be16_to_cpu(str->di_depth);
-       di->di_entries = be32_to_cpu(str->di_entries);
-
-       di->di_eattr = be64_to_cpu(str->di_eattr);
-
-}
-
-void gfs2_dinode_out(const struct gfs2_dinode *di, void *buf)
+void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
 {
+       const struct gfs2_dinode_host *di = &ip->i_di;
        struct gfs2_dinode *str = buf;
 
-       gfs2_meta_header_out(&di->di_header, buf);
-       gfs2_inum_out(&di->di_num, (char *)&str->di_num);
+       str->di_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
+       str->di_header.mh_type = cpu_to_be32(GFS2_METATYPE_DI);
+       str->di_header.__pad0 = 0;
+       str->di_header.mh_format = cpu_to_be32(GFS2_FORMAT_DI);
+       str->di_header.__pad1 = 0;
 
-       str->di_mode = cpu_to_be32(di->di_mode);
-       str->di_uid = cpu_to_be32(di->di_uid);
-       str->di_gid = cpu_to_be32(di->di_gid);
-       str->di_nlink = cpu_to_be32(di->di_nlink);
+       gfs2_inum_out(&ip->i_num, &str->di_num);
+
+       str->di_mode = cpu_to_be32(ip->i_inode.i_mode);
+       str->di_uid = cpu_to_be32(ip->i_inode.i_uid);
+       str->di_gid = cpu_to_be32(ip->i_inode.i_gid);
+       str->di_nlink = cpu_to_be32(ip->i_inode.i_nlink);
        str->di_size = cpu_to_be64(di->di_size);
        str->di_blocks = cpu_to_be64(di->di_blocks);
-       str->di_atime = cpu_to_be64(di->di_atime);
-       str->di_mtime = cpu_to_be64(di->di_mtime);
-       str->di_ctime = cpu_to_be64(di->di_ctime);
-       str->di_major = cpu_to_be32(di->di_major);
-       str->di_minor = cpu_to_be32(di->di_minor);
+       str->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec);
+       str->di_mtime = cpu_to_be64(ip->i_inode.i_mtime.tv_sec);
+       str->di_ctime = cpu_to_be64(ip->i_inode.i_ctime.tv_sec);
 
        str->di_goal_meta = cpu_to_be64(di->di_goal_meta);
        str->di_goal_data = cpu_to_be64(di->di_goal_data);
        str->di_generation = cpu_to_be64(di->di_generation);
 
        str->di_flags = cpu_to_be32(di->di_flags);
-       str->di_payload_format = cpu_to_be32(di->di_payload_format);
        str->di_height = cpu_to_be16(di->di_height);
-
+       str->di_payload_format = cpu_to_be32(S_ISDIR(ip->i_inode.i_mode) &&
+                                            !(ip->i_di.di_flags & GFS2_DIF_EXHASH) ?
+                                            GFS2_FORMAT_DE : 0);
        str->di_depth = cpu_to_be16(di->di_depth);
        str->di_entries = cpu_to_be32(di->di_entries);
 
        str->di_eattr = cpu_to_be64(di->di_eattr);
-
 }
 
-void gfs2_dinode_print(const struct gfs2_dinode *di)
+void gfs2_dinode_print(const struct gfs2_inode *ip)
 {
-       gfs2_meta_header_print(&di->di_header);
-       gfs2_inum_print(&di->di_num);
+       const struct gfs2_dinode_host *di = &ip->i_di;
+
+       gfs2_inum_print(&ip->i_num);
 
-       pv(di, di_mode, "0%o");
-       pv(di, di_uid, "%u");
-       pv(di, di_gid, "%u");
-       pv(di, di_nlink, "%u");
        printk(KERN_INFO "  di_size = %llu\n", (unsigned long long)di->di_size);
        printk(KERN_INFO "  di_blocks = %llu\n", (unsigned long long)di->di_blocks);
-       printk(KERN_INFO "  di_atime = %lld\n", (long long)di->di_atime);
-       printk(KERN_INFO "  di_mtime = %lld\n", (long long)di->di_mtime);
-       printk(KERN_INFO "  di_ctime = %lld\n", (long long)di->di_ctime);
-       pv(di, di_major, "%u");
-       pv(di, di_minor, "%u");
-
        printk(KERN_INFO "  di_goal_meta = %llu\n", (unsigned long long)di->di_goal_meta);
        printk(KERN_INFO "  di_goal_data = %llu\n", (unsigned long long)di->di_goal_data);
 
        pv(di, di_flags, "0x%.8X");
-       pv(di, di_payload_format, "%u");
        pv(di, di_height, "%u");
 
        pv(di, di_depth, "%u");
@@ -251,7 +195,7 @@ void gfs2_dinode_print(const struct gfs2_dinode *di)
        printk(KERN_INFO "  di_eattr = %llu\n", (unsigned long long)di->di_eattr);
 }
 
-void gfs2_log_header_in(struct gfs2_log_header *lh, const void *buf)
+void gfs2_log_header_in(struct gfs2_log_header_host *lh, const void *buf)
 {
        const struct gfs2_log_header *str = buf;
 
@@ -263,7 +207,7 @@ void gfs2_log_header_in(struct gfs2_log_header *lh, const void *buf)
        lh->lh_hash = be32_to_cpu(str->lh_hash);
 }
 
-void gfs2_inum_range_in(struct gfs2_inum_range *ir, const void *buf)
+void gfs2_inum_range_in(struct gfs2_inum_range_host *ir, const void *buf)
 {
        const struct gfs2_inum_range *str = buf;
 
@@ -271,7 +215,7 @@ void gfs2_inum_range_in(struct gfs2_inum_range *ir, const void *buf)
        ir->ir_length = be64_to_cpu(str->ir_length);
 }
 
-void gfs2_inum_range_out(const struct gfs2_inum_range *ir, void *buf)
+void gfs2_inum_range_out(const struct gfs2_inum_range_host *ir, void *buf)
 {
        struct gfs2_inum_range *str = buf;
 
@@ -279,7 +223,7 @@ void gfs2_inum_range_out(const struct gfs2_inum_range *ir, void *buf)
        str->ir_length = cpu_to_be64(ir->ir_length);
 }
 
-void gfs2_statfs_change_in(struct gfs2_statfs_change *sc, const void *buf)
+void gfs2_statfs_change_in(struct gfs2_statfs_change_host *sc, const void *buf)
 {
        const struct gfs2_statfs_change *str = buf;
 
@@ -288,7 +232,7 @@ void gfs2_statfs_change_in(struct gfs2_statfs_change *sc, const void *buf)
        sc->sc_dinodes = be64_to_cpu(str->sc_dinodes);
 }
 
-void gfs2_statfs_change_out(const struct gfs2_statfs_change *sc, void *buf)
+void gfs2_statfs_change_out(const struct gfs2_statfs_change_host *sc, void *buf)
 {
        struct gfs2_statfs_change *str = buf;
 
@@ -297,7 +241,7 @@ void gfs2_statfs_change_out(const struct gfs2_statfs_change *sc, void *buf)
        str->sc_dinodes = cpu_to_be64(sc->sc_dinodes);
 }
 
-void gfs2_quota_change_in(struct gfs2_quota_change *qc, const void *buf)
+void gfs2_quota_change_in(struct gfs2_quota_change_host *qc, const void *buf)
 {
        const struct gfs2_quota_change *str = buf;
 
index 015640b3f123fcde76a28195c1859577c38ef9b7..d8d69a72a10dd819bfcdbe6a736009bda5a92e27 100644 (file)
@@ -156,19 +156,6 @@ out_ignore:
        return 0;
 }
 
-static int zero_readpage(struct page *page)
-{
-       void *kaddr;
-
-       kaddr = kmap_atomic(page, KM_USER0);
-       memset(kaddr, 0, PAGE_CACHE_SIZE);
-       kunmap_atomic(kaddr, KM_USER0);
-
-       SetPageUptodate(page);
-
-       return 0;
-}
-
 /**
  * stuffed_readpage - Fill in a Linux page with stuffed file data
  * @ip: the inode
@@ -183,9 +170,7 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
        void *kaddr;
        int error;
 
-       /* Only the first page of a stuffed file might contain data */
-       if (unlikely(page->index))
-               return zero_readpage(page);
+       BUG_ON(page->index);
 
        error = gfs2_meta_inode_buffer(ip, &dibh);
        if (error)
@@ -230,9 +215,9 @@ static int gfs2_readpage(struct file *file, struct page *page)
                                /* gfs2_sharewrite_nopage has grabbed the ip->i_gl already */
                                goto skip_lock;
                }
-               gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME|GL_AOP, &gh);
+               gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME|LM_FLAG_TRY_1CB, &gh);
                do_unlock = 1;
-               error = gfs2_glock_nq_m_atime(1, &gh);
+               error = gfs2_glock_nq_atime(&gh);
                if (unlikely(error))
                        goto out_unlock;
        }
@@ -254,6 +239,8 @@ skip_lock:
 out:
        return error;
 out_unlock:
+       if (error == GLR_TRYFAILED)
+               error = AOP_TRUNCATED_PAGE;
        unlock_page(page);
        if (do_unlock)
                gfs2_holder_uninit(&gh);
@@ -293,9 +280,9 @@ static int gfs2_readpages(struct file *file, struct address_space *mapping,
                                goto skip_lock;
                }
                gfs2_holder_init(ip->i_gl, LM_ST_SHARED,
-                                LM_FLAG_TRY_1CB|GL_ATIME|GL_AOP, &gh);
+                                LM_FLAG_TRY_1CB|GL_ATIME, &gh);
                do_unlock = 1;
-               ret = gfs2_glock_nq_m_atime(1, &gh);
+               ret = gfs2_glock_nq_atime(&gh);
                if (ret == GLR_TRYFAILED)
                        goto out_noerror;
                if (unlikely(ret))
@@ -366,10 +353,13 @@ static int gfs2_prepare_write(struct file *file, struct page *page,
        unsigned int write_len = to - from;
 
 
-       gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_ATIME|GL_AOP, &ip->i_gh);
-       error = gfs2_glock_nq_m_atime(1, &ip->i_gh);
-       if (error)
+       gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_ATIME|LM_FLAG_TRY_1CB, &ip->i_gh);
+       error = gfs2_glock_nq_atime(&ip->i_gh);
+       if (unlikely(error)) {
+               if (error == GLR_TRYFAILED)
+                       error = AOP_TRUNCATED_PAGE;
                goto out_uninit;
+       }
 
        gfs2_write_calc_reserv(ip, write_len, &data_blocks, &ind_blocks);
 
@@ -386,7 +376,7 @@ static int gfs2_prepare_write(struct file *file, struct page *page,
                if (error)
                        goto out_alloc_put;
 
-               error = gfs2_quota_check(ip, ip->i_di.di_uid, ip->i_di.di_gid);
+               error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
                if (error)
                        goto out_qunlock;
 
@@ -482,8 +472,10 @@ static int gfs2_commit_write(struct file *file, struct page *page,
 
                SetPageUptodate(page);
 
-               if (inode->i_size < file_size)
+               if (inode->i_size < file_size) {
                        i_size_write(inode, file_size);
+                       mark_inode_dirty(inode);
+               }
        } else {
                if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED ||
                    gfs2_is_jdata(ip))
@@ -498,11 +490,6 @@ static int gfs2_commit_write(struct file *file, struct page *page,
                di->di_size = cpu_to_be64(inode->i_size);
        }
 
-       di->di_mode = cpu_to_be32(inode->i_mode);
-       di->di_atime = cpu_to_be64(inode->i_atime.tv_sec);
-       di->di_mtime = cpu_to_be64(inode->i_mtime.tv_sec);
-       di->di_ctime = cpu_to_be64(inode->i_ctime.tv_sec);
-
        brelse(dibh);
        gfs2_trans_end(sdp);
        if (al->al_requested) {
@@ -624,7 +611,7 @@ static ssize_t gfs2_direct_IO(int rw, struct kiocb *iocb,
         * on this path. All we need change is atime.
         */
        gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh);
-       rv = gfs2_glock_nq_m_atime(1, &gh);
+       rv = gfs2_glock_nq_atime(&gh);
        if (rv)
                goto out;
 
@@ -737,6 +724,9 @@ int gfs2_releasepage(struct page *page, gfp_t gfp_mask)
                        if (!atomic_read(&aspace->i_writecount))
                                return 0;
 
+                       if (!(gfp_mask & __GFP_WAIT))
+                               return 0;
+
                        if (time_after_eq(jiffies, t)) {
                                stuck_releasepage(bh);
                                /* should we withdraw here? */
index 00041b1b802522254a8cb8689f4a67d245101808..d355899585d822b800d15f2d8826734bc2d02a6f 100644 (file)
@@ -43,7 +43,7 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
        struct inode *inode = dentry->d_inode;
        struct gfs2_holder d_gh;
        struct gfs2_inode *ip;
-       struct gfs2_inum inum;
+       struct gfs2_inum_host inum;
        unsigned int type;
        int error;
 
@@ -76,7 +76,7 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
        if (!gfs2_inum_equal(&ip->i_num, &inum))
                goto invalid_gunlock;
 
-       if (IF2DT(ip->i_di.di_mode) != type) {
+       if (IF2DT(ip->i_inode.i_mode) != type) {
                gfs2_consist_inode(dip);
                goto fail_gunlock;
        }
index 86127d93bd35f6f846f7d5b46f53cfd4fa0ccb53..b4e7b8775315e34dd70ad60b935875d3ed274b1c 100644 (file)
 #include "util.h"
 
 static struct dentry *gfs2_decode_fh(struct super_block *sb,
-                                    __u32 *fh,
+                                    __u32 *p,
                                     int fh_len,
                                     int fh_type,
                                     int (*acceptable)(void *context,
                                                       struct dentry *dentry),
                                     void *context)
 {
+       __be32 *fh = (__force __be32 *)p;
        struct gfs2_fh_obj fh_obj;
-       struct gfs2_inum *this, parent;
+       struct gfs2_inum_host *this, parent;
 
        if (fh_type != fh_len)
                return NULL;
@@ -65,9 +66,10 @@ static struct dentry *gfs2_decode_fh(struct super_block *sb,
                                                    acceptable, context);
 }
 
-static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
+static int gfs2_encode_fh(struct dentry *dentry, __u32 *p, int *len,
                          int connectable)
 {
+       __be32 *fh = (__force __be32 *)p;
        struct inode *inode = dentry->d_inode;
        struct super_block *sb = inode->i_sb;
        struct gfs2_inode *ip = GFS2_I(inode);
@@ -76,14 +78,10 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
            (connectable && *len < GFS2_LARGE_FH_SIZE))
                return 255;
 
-       fh[0] = ip->i_num.no_formal_ino >> 32;
-       fh[0] = cpu_to_be32(fh[0]);
-       fh[1] = ip->i_num.no_formal_ino & 0xFFFFFFFF;
-       fh[1] = cpu_to_be32(fh[1]);
-       fh[2] = ip->i_num.no_addr >> 32;
-       fh[2] = cpu_to_be32(fh[2]);
-       fh[3] = ip->i_num.no_addr & 0xFFFFFFFF;
-       fh[3] = cpu_to_be32(fh[3]);
+       fh[0] = cpu_to_be32(ip->i_num.no_formal_ino >> 32);
+       fh[1] = cpu_to_be32(ip->i_num.no_formal_ino & 0xFFFFFFFF);
+       fh[2] = cpu_to_be32(ip->i_num.no_addr >> 32);
+       fh[3] = cpu_to_be32(ip->i_num.no_addr & 0xFFFFFFFF);
        *len = GFS2_SMALL_FH_SIZE;
 
        if (!connectable || inode == sb->s_root->d_inode)
@@ -95,14 +93,10 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
        igrab(inode);
        spin_unlock(&dentry->d_lock);
 
-       fh[4] = ip->i_num.no_formal_ino >> 32;
-       fh[4] = cpu_to_be32(fh[4]);
-       fh[5] = ip->i_num.no_formal_ino & 0xFFFFFFFF;
-       fh[5] = cpu_to_be32(fh[5]);
-       fh[6] = ip->i_num.no_addr >> 32;
-       fh[6] = cpu_to_be32(fh[6]);
-       fh[7] = ip->i_num.no_addr & 0xFFFFFFFF;
-       fh[7] = cpu_to_be32(fh[7]);
+       fh[4] = cpu_to_be32(ip->i_num.no_formal_ino >> 32);
+       fh[5] = cpu_to_be32(ip->i_num.no_formal_ino & 0xFFFFFFFF);
+       fh[6] = cpu_to_be32(ip->i_num.no_addr >> 32);
+       fh[7] = cpu_to_be32(ip->i_num.no_addr & 0xFFFFFFFF);
 
        fh[8]  = cpu_to_be32(inode->i_mode);
        fh[9]  = 0;     /* pad to double word */
@@ -114,12 +108,12 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
 }
 
 struct get_name_filldir {
-       struct gfs2_inum inum;
+       struct gfs2_inum_host inum;
        char *name;
 };
 
 static int get_name_filldir(void *opaque, const char *name, unsigned int length,
-                           u64 offset, struct gfs2_inum *inum,
+                           u64 offset, struct gfs2_inum_host *inum,
                            unsigned int type)
 {
        struct get_name_filldir *gnfd = (struct get_name_filldir *)opaque;
@@ -202,7 +196,7 @@ static struct dentry *gfs2_get_dentry(struct super_block *sb, void *inum_obj)
 {
        struct gfs2_sbd *sdp = sb->s_fs_info;
        struct gfs2_fh_obj *fh_obj = (struct gfs2_fh_obj *)inum_obj;
-       struct gfs2_inum *inum = &fh_obj->this;
+       struct gfs2_inum_host *inum = &fh_obj->this;
        struct gfs2_holder i_gh, ri_gh, rgd_gh;
        struct gfs2_rgrpd *rgd;
        struct inode *inode;
index 09aca5046fb177396ef020e01240b994bc76b9c0..f925a955b3b86124a1c43634a2659ed4fa0b1c11 100644 (file)
@@ -15,7 +15,7 @@
 
 extern struct export_operations gfs2_export_ops;
 struct gfs2_fh_obj {
-       struct gfs2_inum this;
+       struct gfs2_inum_host this;
        __u32            imode;
 };
 
index 3064f133bf3c23380bbb6ee2bc5e824fdfd6dfa9..faa07e4b97d025709cc246a22d51fd367e2c6d89 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/ext2_fs.h>
 #include <linux/crc32.h>
 #include <linux/lm_interface.h>
+#include <linux/writeback.h>
 #include <asm/uaccess.h>
 
 #include "gfs2.h"
@@ -71,7 +72,7 @@ static int gfs2_read_actor(read_descriptor_t *desc, struct page *page,
                size = count;
 
        kaddr = kmap(page);
-       memcpy(desc->arg.buf, kaddr + offset, size);
+       memcpy(desc->arg.data, kaddr + offset, size);
        kunmap(page);
 
        desc->count = count - size;
@@ -86,7 +87,7 @@ int gfs2_internal_read(struct gfs2_inode *ip, struct file_ra_state *ra_state,
        struct inode *inode = &ip->i_inode;
        read_descriptor_t desc;
        desc.written = 0;
-       desc.arg.buf = buf;
+       desc.arg.data = buf;
        desc.count = size;
        desc.error = 0;
        do_generic_mapping_read(inode->i_mapping, ra_state,
@@ -139,7 +140,7 @@ static loff_t gfs2_llseek(struct file *file, loff_t offset, int origin)
  */
 
 static int filldir_func(void *opaque, const char *name, unsigned int length,
-                       u64 offset, struct gfs2_inum *inum,
+                       u64 offset, struct gfs2_inum_host *inum,
                        unsigned int type)
 {
        struct filldir_reg *fdr = (struct filldir_reg *)opaque;
@@ -246,14 +247,14 @@ static const u32 gfs2_to_fsflags[32] = {
 
 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct gfs2_inode *ip = GFS2_I(inode);
        struct gfs2_holder gh;
        int error;
        u32 fsflags;
 
        gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh);
-       error = gfs2_glock_nq_m_atime(1, &gh);
+       error = gfs2_glock_nq_atime(&gh);
        if (error)
                return error;
 
@@ -266,6 +267,24 @@ static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
        return error;
 }
 
+void gfs2_set_inode_flags(struct inode *inode)
+{
+       struct gfs2_inode *ip = GFS2_I(inode);
+       struct gfs2_dinode_host *di = &ip->i_di;
+       unsigned int flags = inode->i_flags;
+
+       flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
+       if (di->di_flags & GFS2_DIF_IMMUTABLE)
+               flags |= S_IMMUTABLE;
+       if (di->di_flags & GFS2_DIF_APPENDONLY)
+               flags |= S_APPEND;
+       if (di->di_flags & GFS2_DIF_NOATIME)
+               flags |= S_NOATIME;
+       if (di->di_flags & GFS2_DIF_SYNC)
+               flags |= S_SYNC;
+       inode->i_flags = flags;
+}
+
 /* Flags that can be set by user space */
 #define GFS2_FLAGS_USER_SET (GFS2_DIF_JDATA|                   \
                             GFS2_DIF_DIRECTIO|                 \
@@ -286,7 +305,7 @@ static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
  */
 static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct gfs2_inode *ip = GFS2_I(inode);
        struct gfs2_sbd *sdp = GFS2_SB(inode);
        struct buffer_head *bh;
@@ -336,8 +355,9 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
                goto out_trans_end;
        gfs2_trans_add_bh(ip->i_gl, bh, 1);
        ip->i_di.di_flags = new_flags;
-       gfs2_dinode_out(&ip->i_di, bh->b_data);
+       gfs2_dinode_out(ip, bh->b_data);
        brelse(bh);
+       gfs2_set_inode_flags(inode);
 out_trans_end:
        gfs2_trans_end(sdp);
 out:
@@ -425,7 +445,7 @@ static int gfs2_open(struct inode *inode, struct file *file)
        gfs2_assert_warn(GFS2_SB(inode), !file->private_data);
        file->private_data = fp;
 
-       if (S_ISREG(ip->i_di.di_mode)) {
+       if (S_ISREG(ip->i_inode.i_mode)) {
                error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY,
                                           &i_gh);
                if (error)
@@ -484,16 +504,40 @@ static int gfs2_close(struct inode *inode, struct file *file)
  * @file: the file that points to the dentry (we ignore this)
  * @dentry: the dentry that points to the inode to sync
  *
+ * The VFS will flush "normal" data for us. We only need to worry
+ * about metadata here. For journaled data, we just do a log flush
+ * as we can't avoid it. Otherwise we can just bale out if datasync
+ * is set. For stuffed inodes we must flush the log in order to
+ * ensure that all data is on disk.
+ *
+ * The call to write_inode_now() is there to write back metadata and
+ * the inode itself. It does also try and write the data, but thats
+ * (hopefully) a no-op due to the VFS having already called filemap_fdatawrite()
+ * for us.
+ *
  * Returns: errno
  */
 
 static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync)
 {
-       struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
+       struct inode *inode = dentry->d_inode;
+       int sync_state = inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC);
+       int ret = 0;
 
-       gfs2_log_flush(ip->i_gl->gl_sbd, ip->i_gl);
+       if (gfs2_is_jdata(GFS2_I(inode))) {
+               gfs2_log_flush(GFS2_SB(inode), GFS2_I(inode)->i_gl);
+               return 0;
+       }
 
-       return 0;
+       if (sync_state != 0) {
+               if (!datasync)
+                       ret = write_inode_now(inode, 0);
+
+               if (gfs2_is_stuffed(GFS2_I(inode)))
+                       gfs2_log_flush(GFS2_SB(inode), GFS2_I(inode)->i_gl);
+       }
+
+       return ret;
 }
 
 /**
@@ -515,7 +559,7 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)
 
        if (!(fl->fl_flags & FL_POSIX))
                return -ENOLCK;
-       if ((ip->i_di.di_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
+       if ((ip->i_inode.i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
                return -ENOLCK;
 
        if (sdp->sd_args.ar_localflocks) {
@@ -544,7 +588,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl)
 {
        struct gfs2_file *fp = file->private_data;
        struct gfs2_holder *fl_gh = &fp->f_fl_gh;
-       struct gfs2_inode *ip = GFS2_I(file->f_dentry->d_inode);
+       struct gfs2_inode *ip = GFS2_I(file->f_path.dentry->d_inode);
        struct gfs2_glock *gl;
        unsigned int state;
        int flags;
@@ -617,7 +661,7 @@ static int gfs2_flock(struct file *file, int cmd, struct file_lock *fl)
 
        if (!(fl->fl_flags & FL_FLOCK))
                return -ENOLCK;
-       if ((ip->i_di.di_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
+       if ((ip->i_inode.i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
                return -ENOLCK;
 
        if (sdp->sd_args.ar_localflocks)
index ce319f89ec8e9ae95c64469a678a713465b28c76..7e5d8ec9c8463c1bbcc354d13379d57c8844324c 100644 (file)
@@ -17,7 +17,7 @@ extern struct file gfs2_internal_file_sentinel;
 extern int gfs2_internal_read(struct gfs2_inode *ip,
                              struct file_ra_state *ra_state,
                              char *buf, loff_t *pos, unsigned size);
-
+extern void gfs2_set_inode_flags(struct inode *inode);
 extern const struct file_operations gfs2_file_fops;
 extern const struct file_operations gfs2_dir_fops;
 
index 882873a6bd6909cf985c78ed859bbf54fb66c078..d14e139d267478395cf9b91ca31114c02fe4ba53 100644 (file)
@@ -237,7 +237,7 @@ fail:
 }
 
 static struct inode *gfs2_lookup_root(struct super_block *sb,
-                                     struct gfs2_inum *inum)
+                                     struct gfs2_inum_host *inum)
 {
        return gfs2_inode_lookup(sb, inum, DT_DIR);
 }
@@ -246,7 +246,7 @@ static int init_sb(struct gfs2_sbd *sdp, int silent, int undo)
 {
        struct super_block *sb = sdp->sd_vfs;
        struct gfs2_holder sb_gh;
-       struct gfs2_inum *inum;
+       struct gfs2_inum_host *inum;
        struct inode *inode;
        int error = 0;
 
index ef6e5ed70e94fea379c5dd5005d90ee71ae64331..636dda4c7d38d688c76923c6289e130e8d4754ac 100644 (file)
@@ -59,7 +59,7 @@ static int gfs2_create(struct inode *dir, struct dentry *dentry,
        gfs2_holder_init(dip->i_gl, 0, 0, ghs);
 
        for (;;) {
-               inode = gfs2_createi(ghs, &dentry->d_name, S_IFREG | mode);
+               inode = gfs2_createi(ghs, &dentry->d_name, S_IFREG | mode, 0);
                if (!IS_ERR(inode)) {
                        gfs2_trans_end(sdp);
                        if (dip->i_alloc.al_rgd)
@@ -144,7 +144,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
        int alloc_required;
        int error;
 
-       if (S_ISDIR(ip->i_di.di_mode))
+       if (S_ISDIR(inode->i_mode))
                return -EPERM;
 
        gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
@@ -169,7 +169,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
        }
 
        error = -EINVAL;
-       if (!dip->i_di.di_nlink)
+       if (!dip->i_inode.i_nlink)
                goto out_gunlock;
        error = -EFBIG;
        if (dip->i_di.di_entries == (u32)-1)
@@ -178,10 +178,10 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
        if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
                goto out_gunlock;
        error = -EINVAL;
-       if (!ip->i_di.di_nlink)
+       if (!ip->i_inode.i_nlink)
                goto out_gunlock;
        error = -EMLINK;
-       if (ip->i_di.di_nlink == (u32)-1)
+       if (ip->i_inode.i_nlink == (u32)-1)
                goto out_gunlock;
 
        alloc_required = error = gfs2_diradd_alloc_required(dir, &dentry->d_name);
@@ -196,8 +196,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
                if (error)
                        goto out_alloc;
 
-               error = gfs2_quota_check(dip, dip->i_di.di_uid,
-                                        dip->i_di.di_gid);
+               error = gfs2_quota_check(dip, dip->i_inode.i_uid, dip->i_inode.i_gid);
                if (error)
                        goto out_gunlock_q;
 
@@ -220,7 +219,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
        }
 
        error = gfs2_dir_add(dir, &dentry->d_name, &ip->i_num,
-                            IF2DT(ip->i_di.di_mode));
+                            IF2DT(inode->i_mode));
        if (error)
                goto out_end_trans;
 
@@ -326,7 +325,7 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry,
 
        gfs2_holder_init(dip->i_gl, 0, 0, ghs);
 
-       inode = gfs2_createi(ghs, &dentry->d_name, S_IFLNK | S_IRWXUGO);
+       inode = gfs2_createi(ghs, &dentry->d_name, S_IFLNK | S_IRWXUGO, 0);
        if (IS_ERR(inode)) {
                gfs2_holder_uninit(ghs);
                return PTR_ERR(inode);
@@ -339,7 +338,7 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry,
        error = gfs2_meta_inode_buffer(ip, &dibh);
 
        if (!gfs2_assert_withdraw(sdp, !error)) {
-               gfs2_dinode_out(&ip->i_di, dibh->b_data);
+               gfs2_dinode_out(ip, dibh->b_data);
                memcpy(dibh->b_data + sizeof(struct gfs2_dinode), symname,
                       size);
                brelse(dibh);
@@ -379,7 +378,7 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 
        gfs2_holder_init(dip->i_gl, 0, 0, ghs);
 
-       inode = gfs2_createi(ghs, &dentry->d_name, S_IFDIR | mode);
+       inode = gfs2_createi(ghs, &dentry->d_name, S_IFDIR | mode, 0);
        if (IS_ERR(inode)) {
                gfs2_holder_uninit(ghs);
                return PTR_ERR(inode);
@@ -387,10 +386,9 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 
        ip = ghs[1].gh_gl->gl_object;
 
-       ip->i_di.di_nlink = 2;
+       ip->i_inode.i_nlink = 2;
        ip->i_di.di_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode);
        ip->i_di.di_flags |= GFS2_DIF_JDATA;
-       ip->i_di.di_payload_format = GFS2_FORMAT_DE;
        ip->i_di.di_entries = 2;
 
        error = gfs2_meta_inode_buffer(ip, &dibh);
@@ -414,7 +412,7 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
                gfs2_inum_out(&dip->i_num, &dent->de_inum);
                dent->de_type = cpu_to_be16(DT_DIR);
 
-               gfs2_dinode_out(&ip->i_di, di);
+               gfs2_dinode_out(ip, di);
 
                brelse(dibh);
        }
@@ -467,7 +465,7 @@ static int gfs2_rmdir(struct inode *dir, struct dentry *dentry)
 
        if (ip->i_di.di_entries < 2) {
                if (gfs2_consist_inode(ip))
-                       gfs2_dinode_print(&ip->i_di);
+                       gfs2_dinode_print(ip);
                error = -EIO;
                goto out_gunlock;
        }
@@ -504,47 +502,19 @@ out:
 static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode,
                      dev_t dev)
 {
-       struct gfs2_inode *dip = GFS2_I(dir), *ip;
+       struct gfs2_inode *dip = GFS2_I(dir);
        struct gfs2_sbd *sdp = GFS2_SB(dir);
        struct gfs2_holder ghs[2];
        struct inode *inode;
-       struct buffer_head *dibh;
-       u32 major = 0, minor = 0;
-       int error;
-
-       switch (mode & S_IFMT) {
-       case S_IFBLK:
-       case S_IFCHR:
-               major = MAJOR(dev);
-               minor = MINOR(dev);
-               break;
-       case S_IFIFO:
-       case S_IFSOCK:
-               break;
-       default:
-               return -EOPNOTSUPP;
-       };
 
        gfs2_holder_init(dip->i_gl, 0, 0, ghs);
 
-       inode = gfs2_createi(ghs, &dentry->d_name, mode);
+       inode = gfs2_createi(ghs, &dentry->d_name, mode, dev);
        if (IS_ERR(inode)) {
                gfs2_holder_uninit(ghs);
                return PTR_ERR(inode);
        }
 
-       ip = ghs[1].gh_gl->gl_object;
-
-       ip->i_di.di_major = major;
-       ip->i_di.di_minor = minor;
-
-       error = gfs2_meta_inode_buffer(ip, &dibh);
-
-       if (!gfs2_assert_withdraw(sdp, !error)) {
-               gfs2_dinode_out(&ip->i_di, dibh->b_data);
-               brelse(dibh);
-       }
-
        gfs2_trans_end(sdp);
        if (dip->i_alloc.al_rgd)
                gfs2_inplace_release(dip);
@@ -592,11 +562,10 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
 
        /* Make sure we aren't trying to move a dirctory into it's subdir */
 
-       if (S_ISDIR(ip->i_di.di_mode) && odip != ndip) {
+       if (S_ISDIR(ip->i_inode.i_mode) && odip != ndip) {
                dir_rename = 1;
 
-               error = gfs2_glock_nq_init(sdp->sd_rename_gl,
-                                          LM_ST_EXCLUSIVE, 0,
+               error = gfs2_glock_nq_init(sdp->sd_rename_gl, LM_ST_EXCLUSIVE, 0,
                                           &r_gh);
                if (error)
                        goto out;
@@ -637,10 +606,10 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
                if (error)
                        goto out_gunlock;
 
-               if (S_ISDIR(nip->i_di.di_mode)) {
+               if (S_ISDIR(nip->i_inode.i_mode)) {
                        if (nip->i_di.di_entries < 2) {
                                if (gfs2_consist_inode(nip))
-                                       gfs2_dinode_print(&nip->i_di);
+                                       gfs2_dinode_print(nip);
                                error = -EIO;
                                goto out_gunlock;
                        }
@@ -666,7 +635,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
                };
 
                if (odip != ndip) {
-                       if (!ndip->i_di.di_nlink) {
+                       if (!ndip->i_inode.i_nlink) {
                                error = -EINVAL;
                                goto out_gunlock;
                        }
@@ -674,8 +643,8 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
                                error = -EFBIG;
                                goto out_gunlock;
                        }
-                       if (S_ISDIR(ip->i_di.di_mode) &&
-                           ndip->i_di.di_nlink == (u32)-1) {
+                       if (S_ISDIR(ip->i_inode.i_mode) &&
+                           ndip->i_inode.i_nlink == (u32)-1) {
                                error = -EMLINK;
                                goto out_gunlock;
                        }
@@ -702,8 +671,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
                if (error)
                        goto out_alloc;
 
-               error = gfs2_quota_check(ndip, ndip->i_di.di_uid,
-                                        ndip->i_di.di_gid);
+               error = gfs2_quota_check(ndip, ndip->i_inode.i_uid, ndip->i_inode.i_gid);
                if (error)
                        goto out_gunlock_q;
 
@@ -729,7 +697,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
        /* Remove the target file, if it exists */
 
        if (nip) {
-               if (S_ISDIR(nip->i_di.di_mode))
+               if (S_ISDIR(nip->i_inode.i_mode))
                        error = gfs2_rmdiri(ndip, &ndentry->d_name, nip);
                else {
                        error = gfs2_dir_del(ndip, &ndentry->d_name);
@@ -760,9 +728,9 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
                error = gfs2_meta_inode_buffer(ip, &dibh);
                if (error)
                        goto out_end_trans;
-               ip->i_di.di_ctime = get_seconds();
+               ip->i_inode.i_ctime.tv_sec = get_seconds();
                gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-               gfs2_dinode_out(&ip->i_di, dibh->b_data);
+               gfs2_dinode_out(ip, dibh->b_data);
                brelse(dibh);
        }
 
@@ -771,7 +739,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
                goto out_end_trans;
 
        error = gfs2_dir_add(ndir, &ndentry->d_name, &ip->i_num,
-                            IF2DT(ip->i_di.di_mode));
+                            IF2DT(ip->i_inode.i_mode));
        if (error)
                goto out_end_trans;
 
@@ -867,6 +835,10 @@ static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd)
  * @mask:
  * @nd: passed from Linux VFS, ignored by us
  *
+ * This may be called from the VFS directly, or from within GFS2 with the
+ * inode locked, so we look to see if the glock is already locked and only
+ * lock the glock if its not already been done.
+ *
  * Returns: errno
  */
 
@@ -875,15 +847,18 @@ static int gfs2_permission(struct inode *inode, int mask, struct nameidata *nd)
        struct gfs2_inode *ip = GFS2_I(inode);
        struct gfs2_holder i_gh;
        int error;
+       int unlock = 0;
 
-       if (ip->i_vn == ip->i_gl->gl_vn)
-               return generic_permission(inode, mask, gfs2_check_acl);
+       if (gfs2_glock_is_locked_by_me(ip->i_gl) == 0) {
+               error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
+               if (error)
+                       return error;
+               unlock = 1;
+       }
 
-       error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
-       if (!error) {
-               error = generic_permission(inode, mask, gfs2_check_acl_locked);
+       error = generic_permission(inode, mask, gfs2_check_acl);
+       if (unlock)
                gfs2_glock_dq_uninit(&i_gh);
-       }
 
        return error;
 }
@@ -914,8 +889,8 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
        u32 ouid, ogid, nuid, ngid;
        int error;
 
-       ouid = ip->i_di.di_uid;
-       ogid = ip->i_di.di_gid;
+       ouid = inode->i_uid;
+       ogid = inode->i_gid;
        nuid = attr->ia_uid;
        ngid = attr->ia_gid;
 
@@ -946,10 +921,9 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
 
        error = inode_setattr(inode, attr);
        gfs2_assert_warn(sdp, !error);
-       gfs2_inode_attr_out(ip);
 
        gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-       gfs2_dinode_out(&ip->i_di, dibh->b_data);
+       gfs2_dinode_out(ip, dibh->b_data);
        brelse(dibh);
 
        if (ouid != NO_QUOTA_CHANGE || ogid != NO_QUOTA_CHANGE) {
@@ -1018,6 +992,12 @@ out:
  * @dentry: The dentry to stat
  * @stat: The inode's stats
  *
+ * This may be called from the VFS directly, or from within GFS2 with the
+ * inode locked, so we look to see if the glock is already locked and only
+ * lock the glock if its not already been done. Note that its the NFS
+ * readdirplus operation which causes this to be called (from filldir)
+ * with the glock already held.
+ *
  * Returns: errno
  */
 
@@ -1028,14 +1008,20 @@ static int gfs2_getattr(struct vfsmount *mnt, struct dentry *dentry,
        struct gfs2_inode *ip = GFS2_I(inode);
        struct gfs2_holder gh;
        int error;
+       int unlock = 0;
 
-       error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh);
-       if (!error) {
-               generic_fillattr(inode, stat);
-               gfs2_glock_dq_uninit(&gh);
+       if (gfs2_glock_is_locked_by_me(ip->i_gl) == 0) {
+               error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh);
+               if (error)
+                       return error;
+               unlock = 1;
        }
 
-       return error;
+       generic_fillattr(inode, stat);
+       if (unlock);
+               gfs2_glock_dq_uninit(&gh);
+
+       return 0;
 }
 
 static int gfs2_setxattr(struct dentry *dentry, const char *name,
index b47d9598c047e23324c5860cc9798e41d6ad72cb..7685b46f934b4ad07c419a4b11b4eef60aa0c167 100644 (file)
@@ -157,7 +157,8 @@ static void gfs2_write_super(struct super_block *sb)
 static int gfs2_sync_fs(struct super_block *sb, int wait)
 {
        sb->s_dirt = 0;
-       gfs2_log_flush(sb->s_fs_info, NULL);
+       if (wait)
+               gfs2_log_flush(sb->s_fs_info, NULL);
        return 0;
 }
 
@@ -215,7 +216,7 @@ static int gfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
 {
        struct super_block *sb = dentry->d_inode->i_sb;
        struct gfs2_sbd *sdp = sb->s_fs_info;
-       struct gfs2_statfs_change sc;
+       struct gfs2_statfs_change_host sc;
        int error;
 
        if (gfs2_tune_get(sdp, gt_statfs_slow))
@@ -293,8 +294,6 @@ static void gfs2_clear_inode(struct inode *inode)
         */
        if (inode->i_private) {
                struct gfs2_inode *ip = GFS2_I(inode);
-               gfs2_glock_inode_squish(inode);
-               gfs2_assert(inode->i_sb->s_fs_info, ip->i_gl->gl_state == LM_ST_UNLOCKED);
                ip->i_gl->gl_object = NULL;
                gfs2_glock_schedule_for_reclaim(ip->i_gl);
                gfs2_glock_put(ip->i_gl);
@@ -395,7 +394,7 @@ static void gfs2_delete_inode(struct inode *inode)
        if (!inode->i_private)
                goto out;
 
-       error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, &gh);
+       error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB, &gh);
        if (unlikely(error)) {
                gfs2_glock_dq_uninit(&ip->i_iopen_gh);
                goto out;
@@ -407,7 +406,7 @@ static void gfs2_delete_inode(struct inode *inode)
        if (error)
                goto out_uninit;
 
-       if (S_ISDIR(ip->i_di.di_mode) &&
+       if (S_ISDIR(inode->i_mode) &&
            (ip->i_di.di_flags & GFS2_DIF_EXHASH)) {
                error = gfs2_dir_exhash_dealloc(ip);
                if (error)
index 5453d2947ab3a40d7743925834349575f733536a..45a5f11fc39a88b0a53953e590cae739c4ad920b 100644 (file)
@@ -76,7 +76,7 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page)
        if (error)
                goto out;
 
-       error = gfs2_quota_check(ip, ip->i_di.di_uid, ip->i_di.di_gid);
+       error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
        if (error)
                goto out_gunlock_q;
 
index a3deae7416c92d9ed8d78beae04dbea92165a73e..d0db881b55d2cf34231335d1c2848f1fd131af30 100644 (file)
@@ -452,19 +452,19 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid)
        if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
                return 0;
 
-       error = qdsb_get(sdp, QUOTA_USER, ip->i_di.di_uid, CREATE, qd);
+       error = qdsb_get(sdp, QUOTA_USER, ip->i_inode.i_uid, CREATE, qd);
        if (error)
                goto out;
        al->al_qd_num++;
        qd++;
 
-       error = qdsb_get(sdp, QUOTA_GROUP, ip->i_di.di_gid, CREATE, qd);
+       error = qdsb_get(sdp, QUOTA_GROUP, ip->i_inode.i_gid, CREATE, qd);
        if (error)
                goto out;
        al->al_qd_num++;
        qd++;
 
-       if (uid != NO_QUOTA_CHANGE && uid != ip->i_di.di_uid) {
+       if (uid != NO_QUOTA_CHANGE && uid != ip->i_inode.i_uid) {
                error = qdsb_get(sdp, QUOTA_USER, uid, CREATE, qd);
                if (error)
                        goto out;
@@ -472,7 +472,7 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid)
                qd++;
        }
 
-       if (gid != NO_QUOTA_CHANGE && gid != ip->i_di.di_gid) {
+       if (gid != NO_QUOTA_CHANGE && gid != ip->i_inode.i_gid) {
                error = qdsb_get(sdp, QUOTA_GROUP, gid, CREATE, qd);
                if (error)
                        goto out;
@@ -539,8 +539,7 @@ static void do_qc(struct gfs2_quota_data *qd, s64 change)
                qc->qc_id = cpu_to_be32(qd->qd_id);
        }
 
-       x = qc->qc_change;
-       x = be64_to_cpu(x) + change;
+       x = be64_to_cpu(qc->qc_change) + change;
        qc->qc_change = cpu_to_be64(x);
 
        spin_lock(&sdp->sd_quota_spin);
@@ -743,7 +742,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh,
        struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd;
        struct gfs2_inode *ip = GFS2_I(sdp->sd_quota_inode);
        struct gfs2_holder i_gh;
-       struct gfs2_quota q;
+       struct gfs2_quota_host q;
        char buf[sizeof(struct gfs2_quota)];
        struct file_ra_state ra_state;
        int error;
@@ -1103,7 +1102,7 @@ int gfs2_quota_init(struct gfs2_sbd *sdp)
 
                for (y = 0; y < sdp->sd_qc_per_block && slot < sdp->sd_quota_slots;
                     y++, slot++) {
-                       struct gfs2_quota_change qc;
+                       struct gfs2_quota_change_host qc;
                        struct gfs2_quota_data *qd;
 
                        gfs2_quota_change_in(&qc, bh->b_data +
index 62cd223819b7aa4536335ef460ed9382ac90eb12..d0c806b85c864387cffec4a7a82a9dd8d5deb329 100644 (file)
@@ -132,10 +132,11 @@ void gfs2_revoke_clean(struct gfs2_sbd *sdp)
  */
 
 static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk,
-                         struct gfs2_log_header *head)
+                         struct gfs2_log_header_host *head)
 {
        struct buffer_head *bh;
-       struct gfs2_log_header lh;
+       struct gfs2_log_header_host lh;
+       const u32 nothing = 0;
        u32 hash;
        int error;
 
@@ -143,11 +144,11 @@ static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk,
        if (error)
                return error;
 
-       memcpy(&lh, bh->b_data, sizeof(struct gfs2_log_header));
-       lh.lh_hash = 0;
-       hash = gfs2_disk_hash((char *)&lh, sizeof(struct gfs2_log_header));
+       hash = crc32_le((u32)~0, bh->b_data, sizeof(struct gfs2_log_header) -
+                                            sizeof(u32));
+       hash = crc32_le(hash, (unsigned char const *)&nothing, sizeof(nothing));
+       hash ^= (u32)~0;
        gfs2_log_header_in(&lh, bh->b_data);
-
        brelse(bh);
 
        if (lh.lh_header.mh_magic != GFS2_MAGIC ||
@@ -174,7 +175,7 @@ static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk,
  */
 
 static int find_good_lh(struct gfs2_jdesc *jd, unsigned int *blk,
-                       struct gfs2_log_header *head)
+                       struct gfs2_log_header_host *head)
 {
        unsigned int orig_blk = *blk;
        int error;
@@ -205,10 +206,10 @@ static int find_good_lh(struct gfs2_jdesc *jd, unsigned int *blk,
  * Returns: errno
  */
 
-static int jhead_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
+static int jhead_scan(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head)
 {
        unsigned int blk = head->lh_blkno;
-       struct gfs2_log_header lh;
+       struct gfs2_log_header_host lh;
        int error;
 
        for (;;) {
@@ -245,9 +246,9 @@ static int jhead_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
  * Returns: errno
  */
 
-int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
+int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head)
 {
-       struct gfs2_log_header lh_1, lh_m;
+       struct gfs2_log_header_host lh_1, lh_m;
        u32 blk_1, blk_2, blk_m;
        int error;
 
@@ -320,7 +321,7 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start,
                length = be32_to_cpu(ld->ld_length);
 
                if (be32_to_cpu(ld->ld_header.mh_type) == GFS2_METATYPE_LH) {
-                       struct gfs2_log_header lh;
+                       struct gfs2_log_header_host lh;
                        error = get_log_header(jd, start, &lh);
                        if (!error) {
                                gfs2_replay_incr_blk(sdp, &start);
@@ -363,7 +364,7 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start,
  * Returns: errno
  */
 
-static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
+static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head)
 {
        struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
        struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
@@ -425,7 +426,7 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd)
 {
        struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
        struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
-       struct gfs2_log_header head;
+       struct gfs2_log_header_host head;
        struct gfs2_holder j_gh, ji_gh, t_gh;
        unsigned long t;
        int ro = 0;
index 961feedf4d8bb026949d8bac19542c2c651281a2..f7235e61c723bfe7ac106df41242785ff42de4ee 100644 (file)
@@ -26,7 +26,7 @@ int gfs2_revoke_check(struct gfs2_sbd *sdp, u64 blkno, unsigned int where);
 void gfs2_revoke_clean(struct gfs2_sbd *sdp);
 
 int gfs2_find_jhead(struct gfs2_jdesc *jd,
-                   struct gfs2_log_header *head);
+                   struct gfs2_log_header_host *head);
 int gfs2_recover_journal(struct gfs2_jdesc *gfs2_jd);
 void gfs2_check_journals(struct gfs2_sbd *sdp);
 
index b261385c006556d7633ed24cb8a34773ca02cfac..ff0846528d5475cb9cc6ec5021c8aad42a96128c 100644 (file)
@@ -253,7 +253,7 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd)
 
 }
 
-static inline int rgrp_contains_block(struct gfs2_rindex *ri, u64 block)
+static inline int rgrp_contains_block(struct gfs2_rindex_host *ri, u64 block)
 {
        u64 first = ri->ri_data0;
        u64 last = first + ri->ri_data;
@@ -1217,7 +1217,7 @@ u64 gfs2_alloc_data(struct gfs2_inode *ip)
        al->al_alloced++;
 
        gfs2_statfs_change(sdp, 0, -1, 0);
-       gfs2_quota_change(ip, +1, ip->i_di.di_uid, ip->i_di.di_gid);
+       gfs2_quota_change(ip, +1, ip->i_inode.i_uid, ip->i_inode.i_gid);
 
        spin_lock(&sdp->sd_rindex_spin);
        rgd->rd_free_clone--;
@@ -1261,7 +1261,7 @@ u64 gfs2_alloc_meta(struct gfs2_inode *ip)
        al->al_alloced++;
 
        gfs2_statfs_change(sdp, 0, -1, 0);
-       gfs2_quota_change(ip, +1, ip->i_di.di_uid, ip->i_di.di_gid);
+       gfs2_quota_change(ip, +1, ip->i_inode.i_uid, ip->i_inode.i_gid);
        gfs2_trans_add_unrevoke(sdp, block);
 
        spin_lock(&sdp->sd_rindex_spin);
@@ -1337,8 +1337,7 @@ void gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen)
        gfs2_trans_add_rg(rgd);
 
        gfs2_statfs_change(sdp, 0, +blen, 0);
-       gfs2_quota_change(ip, -(s64)blen,
-                        ip->i_di.di_uid, ip->i_di.di_gid);
+       gfs2_quota_change(ip, -(s64)blen, ip->i_inode.i_uid, ip->i_inode.i_gid);
 }
 
 /**
@@ -1366,7 +1365,7 @@ void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen)
        gfs2_trans_add_rg(rgd);
 
        gfs2_statfs_change(sdp, 0, +blen, 0);
-       gfs2_quota_change(ip, -(s64)blen, ip->i_di.di_uid, ip->i_di.di_gid);
+       gfs2_quota_change(ip, -(s64)blen, ip->i_inode.i_uid, ip->i_inode.i_gid);
        gfs2_meta_wipe(ip, bstart, blen);
 }
 
@@ -1411,7 +1410,7 @@ static void gfs2_free_uninit_di(struct gfs2_rgrpd *rgd, u64 blkno)
 void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip)
 {
        gfs2_free_uninit_di(rgd, ip->i_num.no_addr);
-       gfs2_quota_change(ip, -1, ip->i_di.di_uid, ip->i_di.di_gid);
+       gfs2_quota_change(ip, -1, ip->i_inode.i_uid, ip->i_inode.i_gid);
        gfs2_meta_wipe(ip, ip->i_num.no_addr, 1);
 }
 
index 6a78b1b32e25597fac6a2ef0e0f13d7a2c3be78e..43a24f2e5905f9a26be19bcc032b4761a777baef 100644 (file)
@@ -97,7 +97,7 @@ void gfs2_tune_init(struct gfs2_tune *gt)
  * changed.
  */
 
-int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent)
+int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb_host *sb, int silent)
 {
        unsigned int x;
 
@@ -180,6 +180,24 @@ static int end_bio_io_page(struct bio *bio, unsigned int bytes_done, int error)
        return 0;
 }
 
+/**
+ * gfs2_read_super - Read the gfs2 super block from disk
+ * @sb: The VFS super block
+ * @sector: The location of the super block
+ *
+ * This uses the bio functions to read the super block from disk
+ * because we want to be 100% sure that we never read cached data.
+ * A super block is read twice only during each GFS2 mount and is
+ * never written to by the filesystem. The first time its read no
+ * locks are held, and the only details which are looked at are those
+ * relating to the locking protocol. Once locking is up and working,
+ * the sb is read again under the lock to establish the location of
+ * the master directory (contains pointers to journals etc) and the
+ * root directory.
+ *
+ * Returns: A page containing the sb or NULL
+ */
+
 struct page *gfs2_read_super(struct super_block *sb, sector_t sector)
 {
        struct page *page;
@@ -199,7 +217,7 @@ struct page *gfs2_read_super(struct super_block *sb, sector_t sector)
                return NULL;
        }
 
-       bio->bi_sector = sector;
+       bio->bi_sector = sector * (sb->s_blocksize >> 9);
        bio->bi_bdev = sb->s_bdev;
        bio_add_page(bio, page, PAGE_SIZE, 0);
 
@@ -508,7 +526,7 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
        struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode);
        struct gfs2_glock *j_gl = ip->i_gl;
        struct gfs2_holder t_gh;
-       struct gfs2_log_header head;
+       struct gfs2_log_header_host head;
        int error;
 
        error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED,
@@ -517,7 +535,7 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
                return error;
 
        gfs2_meta_cache_flush(ip);
-       j_gl->gl_ops->go_inval(j_gl, DIO_METADATA | DIO_DATA);
+       j_gl->gl_ops->go_inval(j_gl, DIO_METADATA);
 
        error = gfs2_find_jhead(sdp->sd_jdesc, &head);
        if (error)
@@ -587,9 +605,9 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp)
 int gfs2_statfs_init(struct gfs2_sbd *sdp)
 {
        struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
-       struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master;
+       struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
        struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
-       struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
+       struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
        struct buffer_head *m_bh, *l_bh;
        struct gfs2_holder gh;
        int error;
@@ -634,7 +652,7 @@ void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free,
                        s64 dinodes)
 {
        struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
-       struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
+       struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
        struct buffer_head *l_bh;
        int error;
 
@@ -660,8 +678,8 @@ int gfs2_statfs_sync(struct gfs2_sbd *sdp)
 {
        struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
        struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
-       struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master;
-       struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
+       struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
+       struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
        struct gfs2_holder gh;
        struct buffer_head *m_bh, *l_bh;
        int error;
@@ -727,10 +745,10 @@ out:
  * Returns: errno
  */
 
-int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc)
+int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
 {
-       struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master;
-       struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
+       struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
+       struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
 
        spin_lock(&sdp->sd_statfs_spin);
 
@@ -760,7 +778,7 @@ int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc)
  */
 
 static int statfs_slow_fill(struct gfs2_rgrpd *rgd,
-                           struct gfs2_statfs_change *sc)
+                           struct gfs2_statfs_change_host *sc)
 {
        gfs2_rgrp_verify(rgd);
        sc->sc_total += rgd->rd_ri.ri_data;
@@ -782,7 +800,7 @@ static int statfs_slow_fill(struct gfs2_rgrpd *rgd,
  * Returns: errno
  */
 
-int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc)
+int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
 {
        struct gfs2_holder ri_gh;
        struct gfs2_rgrpd *rgd_next;
@@ -792,7 +810,7 @@ int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc)
        int done;
        int error = 0, err;
 
-       memset(sc, 0, sizeof(struct gfs2_statfs_change));
+       memset(sc, 0, sizeof(struct gfs2_statfs_change_host));
        gha = kcalloc(slots, sizeof(struct gfs2_holder), GFP_KERNEL);
        if (!gha)
                return -ENOMEM;
@@ -873,7 +891,7 @@ static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp,
        struct gfs2_jdesc *jd;
        struct lfcc *lfcc;
        LIST_HEAD(list);
-       struct gfs2_log_header lh;
+       struct gfs2_log_header_host lh;
        int error;
 
        error = gfs2_jindex_hold(sdp, &ji_gh);
index 5bb443ae0f5902c5ab51437d6b04294aa3d2e1b1..e590b2df11dc1c88343743132a64ece6ae83ddd9 100644 (file)
@@ -14,7 +14,7 @@
 
 void gfs2_tune_init(struct gfs2_tune *gt);
 
-int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent);
+int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb_host *sb, int silent);
 int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent);
 struct page *gfs2_read_super(struct super_block *sb, sector_t sector);
 
@@ -45,8 +45,8 @@ int gfs2_statfs_init(struct gfs2_sbd *sdp);
 void gfs2_statfs_change(struct gfs2_sbd *sdp,
                        s64 total, s64 free, s64 dinodes);
 int gfs2_statfs_sync(struct gfs2_sbd *sdp);
-int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc);
-int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc);
+int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc);
+int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc);
 
 int gfs2_freeze_fs(struct gfs2_sbd *sdp);
 void gfs2_unfreeze_fs(struct gfs2_sbd *sdp);
index 0e0ec988f731c5ffd19306fcf34679c05ffa03d2..983eaf1e06becb3e0c6516bb04ffa397bc121ab9 100644 (file)
@@ -426,9 +426,6 @@ static ssize_t name##_store(struct gfs2_sbd *sdp, const char *buf, size_t len)\
 }                                                                             \
 TUNE_ATTR_2(name, name##_store)
 
-TUNE_ATTR(ilimit, 0);
-TUNE_ATTR(ilimit_tries, 0);
-TUNE_ATTR(ilimit_min, 0);
 TUNE_ATTR(demote_secs, 0);
 TUNE_ATTR(incore_log_blocks, 0);
 TUNE_ATTR(log_flush_secs, 0);
@@ -447,7 +444,6 @@ TUNE_ATTR(quota_simul_sync, 1);
 TUNE_ATTR(quota_cache_secs, 1);
 TUNE_ATTR(max_atomic_write, 1);
 TUNE_ATTR(stall_secs, 1);
-TUNE_ATTR(entries_per_readdir, 1);
 TUNE_ATTR(greedy_default, 1);
 TUNE_ATTR(greedy_quantum, 1);
 TUNE_ATTR(greedy_max, 1);
@@ -459,9 +455,6 @@ TUNE_ATTR_DAEMON(quotad_secs, quotad_process);
 TUNE_ATTR_3(quota_scale, quota_scale_show, quota_scale_store);
 
 static struct attribute *tune_attrs[] = {
-       &tune_attr_ilimit.attr,
-       &tune_attr_ilimit_tries.attr,
-       &tune_attr_ilimit_min.attr,
        &tune_attr_demote_secs.attr,
        &tune_attr_incore_log_blocks.attr,
        &tune_attr_log_flush_secs.attr,
@@ -478,7 +471,6 @@ static struct attribute *tune_attrs[] = {
        &tune_attr_quota_cache_secs.attr,
        &tune_attr_max_atomic_write.attr,
        &tune_attr_stall_secs.attr,
-       &tune_attr_entries_per_readdir.attr,
        &tune_attr_greedy_default.attr,
        &tune_attr_greedy_quantum.attr,
        &tune_attr_greedy_max.attr,
index 196c604faadcfe16132fba320f070bbd88138bc8..e5707a9f78c2091901813acee8d4db23a1e06029 100644 (file)
@@ -23,9 +23,9 @@
 #include "lm.h"
 #include "util.h"
 
-kmem_cache_t *gfs2_glock_cachep __read_mostly;
-kmem_cache_t *gfs2_inode_cachep __read_mostly;
-kmem_cache_t *gfs2_bufdata_cachep __read_mostly;
+struct kmem_cache *gfs2_glock_cachep __read_mostly;
+struct kmem_cache *gfs2_inode_cachep __read_mostly;
+struct kmem_cache *gfs2_bufdata_cachep __read_mostly;
 
 void gfs2_assert_i(struct gfs2_sbd *sdp)
 {
index 76a50899fe9e2252074a3aa844723d545802581c..28938a46cf4785c63544ff4bea34aa5ef6052b32 100644 (file)
@@ -83,8 +83,7 @@ static inline int gfs2_meta_check_i(struct gfs2_sbd *sdp,
                                    char *file, unsigned int line)
 {
        struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
-       u32 magic = mh->mh_magic;
-       magic = be32_to_cpu(magic);
+       u32 magic = be32_to_cpu(mh->mh_magic);
        if (unlikely(magic != GFS2_MAGIC))
                return gfs2_meta_check_ii(sdp, bh, "magic number", function,
                                          file, line);
@@ -107,9 +106,8 @@ static inline int gfs2_metatype_check_i(struct gfs2_sbd *sdp,
                                        char *file, unsigned int line)
 {
        struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
-       u32 magic = mh->mh_magic;
+       u32 magic = be32_to_cpu(mh->mh_magic);
        u16 t = be32_to_cpu(mh->mh_type);
-       magic = be32_to_cpu(magic);
        if (unlikely(magic != GFS2_MAGIC))
                return gfs2_meta_check_ii(sdp, bh, "magic number", function,
                                          file, line);
@@ -146,9 +144,9 @@ int gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh,
 gfs2_io_error_bh_i((sdp), (bh), __FUNCTION__, __FILE__, __LINE__);
 
 
-extern kmem_cache_t *gfs2_glock_cachep;
-extern kmem_cache_t *gfs2_inode_cachep;
-extern kmem_cache_t *gfs2_bufdata_cachep;
+extern struct kmem_cache *gfs2_glock_cachep;
+extern struct kmem_cache *gfs2_inode_cachep;
+extern struct kmem_cache *gfs2_bufdata_cachep;
 
 static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt,
                                           unsigned int *p)
index 37d681b4f2162da24cdaacd9b93e07108e041173..e2e0358da335f51503fb8527a32d115c2f56204a 100644 (file)
@@ -53,7 +53,7 @@ done:
  */
 static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct super_block *sb = inode->i_sb;
        int len, err;
        char strbuf[HFS_MAX_NAMELEN];
index 02f5573e03491b597a7d68b40fb45f72f87e4a07..5cb7f8fee8d6501d53e8a1931a07feafb502f8c6 100644 (file)
@@ -102,7 +102,7 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb,
                const struct iovec *iov, loff_t offset, unsigned long nr_segs)
 {
        struct file *file = iocb->ki_filp;
-       struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
+       struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host;
 
        return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
                                  offset, nr_segs, hfs_get_block, NULL);
index 85b17b3fa4a0f768e8f6155800b582243a74f965..a3698796600439413d4d0536cd9edf8f2184201a 100644 (file)
@@ -24,7 +24,7 @@
 #include "hfs_fs.h"
 #include "btree.h"
 
-static kmem_cache_t *hfs_inode_cachep;
+static struct kmem_cache *hfs_inode_cachep;
 
 MODULE_LICENSE("GPL");
 
@@ -145,7 +145,7 @@ static struct inode *hfs_alloc_inode(struct super_block *sb)
 {
        struct hfs_inode_info *i;
 
-       i = kmem_cache_alloc(hfs_inode_cachep, SLAB_KERNEL);
+       i = kmem_cache_alloc(hfs_inode_cachep, GFP_KERNEL);
        return i ? &i->vfs_inode : NULL;
 }
 
@@ -430,7 +430,7 @@ static struct file_system_type hfs_fs_type = {
        .fs_flags       = FS_REQUIRES_DEV,
 };
 
-static void hfs_init_once(void *p, kmem_cache_t *cachep, unsigned long flags)
+static void hfs_init_once(void *p, struct kmem_cache *cachep, unsigned long flags)
 {
        struct hfs_inode_info *i = p;
 
index 7e309751645f1618feec1547b502a5cbf5f03032..e886ac8460d375ccda11f4a005aefffe34b60bcd 100644 (file)
@@ -111,7 +111,7 @@ fail:
 
 static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct super_block *sb = inode->i_sb;
        int len, err;
        char strbuf[HFSPLUS_MAX_STRLEN + 1];
index 9e36752496336fa86ea19a7fbb3bdf6e73e8d2fd..75e8c4d8aac35d31ab65bbd01e5bb36d8a86c383 100644 (file)
@@ -97,7 +97,7 @@ static ssize_t hfsplus_direct_IO(int rw, struct kiocb *iocb,
                const struct iovec *iov, loff_t offset, unsigned long nr_segs)
 {
        struct file *file = iocb->ki_filp;
-       struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
+       struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host;
 
        return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
                                  offset, nr_segs, hfsplus_get_block, NULL);
index 194eede52fa46005949042c37d8e57e3ef8fe7db..0f513c6bf8434adfc311c57e6829e9b3c23663e6 100644 (file)
@@ -434,13 +434,13 @@ MODULE_AUTHOR("Brad Boyer");
 MODULE_DESCRIPTION("Extended Macintosh Filesystem");
 MODULE_LICENSE("GPL");
 
-static kmem_cache_t *hfsplus_inode_cachep;
+static struct kmem_cache *hfsplus_inode_cachep;
 
 static struct inode *hfsplus_alloc_inode(struct super_block *sb)
 {
        struct hfsplus_inode_info *i;
 
-       i = kmem_cache_alloc(hfsplus_inode_cachep, SLAB_KERNEL);
+       i = kmem_cache_alloc(hfsplus_inode_cachep, GFP_KERNEL);
        return i ? &i->vfs_inode : NULL;
 }
 
@@ -467,7 +467,7 @@ static struct file_system_type hfsplus_fs_type = {
        .fs_flags       = FS_REQUIRES_DEV,
 };
 
-static void hfsplus_init_once(void *p, kmem_cache_t *cachep, unsigned long flags)
+static void hfsplus_init_once(void *p, struct kmem_cache *cachep, unsigned long flags)
 {
        struct hfsplus_inode_info *i = p;
 
index b6bd33ca3731edafe9866ce0a7a725a2bc3287c3..1e6fc37998768faf3539d31fd8960e7d9404e3f4 100644 (file)
@@ -35,7 +35,7 @@ static inline struct hostfs_inode_info *HOSTFS_I(struct inode *inode)
        return(list_entry(inode, struct hostfs_inode_info, vfs_inode));
 }
 
-#define FILE_HOSTFS_I(file) HOSTFS_I((file)->f_dentry->d_inode)
+#define FILE_HOSTFS_I(file) HOSTFS_I((file)->f_path.dentry->d_inode)
 
 int hostfs_d_delete(struct dentry *dentry)
 {
@@ -325,7 +325,7 @@ int hostfs_readdir(struct file *file, void *ent, filldir_t filldir)
        unsigned long long next, ino;
        int error, len;
 
-       name = dentry_name(file->f_dentry, 0);
+       name = dentry_name(file->f_path.dentry, 0);
        if(name == NULL) return(-ENOMEM);
        dir = open_dir(name, &error);
        kfree(name);
@@ -366,7 +366,7 @@ int hostfs_file_open(struct inode *ino, struct file *file)
        if(w)
                r = 1;
 
-       name = dentry_name(file->f_dentry, 0);
+       name = dentry_name(file->f_path.dentry, 0);
        if(name == NULL)
                return(-ENOMEM);
 
index ecc9180645ae1a12b70beab00bc5561f602c4a65..6916c41d70176f97dd22326dd7d47d4a39abfdeb 100644 (file)
@@ -24,7 +24,7 @@ static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence)
        loff_t new_off = off + (whence == 1 ? filp->f_pos : 0);
        loff_t pos;
        struct quad_buffer_head qbh;
-       struct inode *i = filp->f_dentry->d_inode;
+       struct inode *i = filp->f_path.dentry->d_inode;
        struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
        struct super_block *s = i->i_sb;
 
@@ -52,7 +52,7 @@ fail:
 
 static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct hpfs_inode_info *hpfs_inode = hpfs_i(inode);
        struct quad_buffer_head qbh;
        struct hpfs_dirent *de;
@@ -84,7 +84,8 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
                }
                if (!fno->dirflag) {
                        e = 1;
-                       hpfs_error(inode->i_sb, "not a directory, fnode %08x",inode->i_ino);
+                       hpfs_error(inode->i_sb, "not a directory, fnode %08lx",
+                                       (unsigned long)inode->i_ino);
                }
                if (hpfs_inode->i_dno != fno->u.external[0].disk_secno) {
                        e = 1;
@@ -144,8 +145,11 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
                }
                if (de->first || de->last) {
                        if (hpfs_sb(inode->i_sb)->sb_chk) {
-                               if (de->first && !de->last && (de->namelen != 2 || de ->name[0] != 1 || de->name[1] != 1)) hpfs_error(inode->i_sb, "hpfs_readdir: bad ^A^A entry; pos = %08x", old_pos);
-                               if (de->last && (de->namelen != 1 || de ->name[0] != 255)) hpfs_error(inode->i_sb, "hpfs_readdir: bad \\377 entry; pos = %08x", old_pos);
+                               if (de->first && !de->last && (de->namelen != 2
+                                   || de ->name[0] != 1 || de->name[1] != 1))
+                                       hpfs_error(inode->i_sb, "hpfs_readdir: bad ^A^A entry; pos = %08lx", old_pos);
+                               if (de->last && (de->namelen != 1 || de ->name[0] != 255))
+                                       hpfs_error(inode->i_sb, "hpfs_readdir: bad \\377 entry; pos = %08lx", old_pos);
                        }
                        hpfs_brelse4(&qbh);
                        goto again;
index 229ff2fb1809f7b6276c66655b47679f013225c6..fe83c2b7d2d8bb8899ca47e0f90ce5741ff3bbc4 100644 (file)
@@ -533,10 +533,13 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
                        struct buffer_head *bh;
                        struct dnode *d1;
                        struct quad_buffer_head qbh1;
-                       if (hpfs_sb(i->i_sb)->sb_chk) if (up != i->i_ino) {
-                               hpfs_error(i->i_sb, "bad pointer to fnode, dnode %08x, pointing to %08x, should be %08x", dno, up, i->i_ino);
+                       if (hpfs_sb(i->i_sb)->sb_chk)
+                           if (up != i->i_ino) {
+                               hpfs_error(i->i_sb,
+                                       "bad pointer to fnode, dnode %08x, pointing to %08x, should be %08lx",
+                                       dno, up, (unsigned long)i->i_ino);
                                return;
-                       }
+                           }
                        if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) {
                                d1->up = up;
                                d1->root_dnode = 1;
@@ -851,7 +854,9 @@ struct hpfs_dirent *map_pos_dirent(struct inode *inode, loff_t *posp,
        /* Going to the next dirent */
        if ((d = de_next_de(de)) < dnode_end_de(dnode)) {
                if (!(++*posp & 077)) {
-                       hpfs_error(inode->i_sb, "map_pos_dirent: pos crossed dnode boundary; pos = %08x", *posp);
+                       hpfs_error(inode->i_sb,
+                               "map_pos_dirent: pos crossed dnode boundary; pos = %08llx",
+                               (unsigned long long)*posp);
                        goto bail;
                }
                /* We're going down the tree */
index 66339dc030e4003849facc162d9822fa0c90e9e0..547a8384571fcc9d1b95282933879125db098efa 100644 (file)
@@ -243,8 +243,9 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, char *key, char *data
                fnode->ea_offs = 0xc4;
        }
        if (fnode->ea_offs < 0xc4 || fnode->ea_offs + fnode->acl_size_s + fnode->ea_size_s > 0x200) {
-               hpfs_error(s, "fnode %08x: ea_offs == %03x, ea_size_s == %03x",
-                       inode->i_ino, fnode->ea_offs, fnode->ea_size_s);
+               hpfs_error(s, "fnode %08lx: ea_offs == %03x, ea_size_s == %03x",
+                       (unsigned long)inode->i_ino,
+                       fnode->ea_offs, fnode->ea_size_s);
                return;
        }
        if ((fnode->ea_size_s || !fnode->ea_size_l) &&
index 8b94d24855f00b7ece487dc2b1cd5b5a741af0db..fb4c8915010a4a99c9daf905f58522026b37895c 100644 (file)
@@ -115,7 +115,7 @@ static ssize_t hpfs_file_write(struct file *file, const char __user *buf,
 
        retval = do_sync_write(file, buf, count, ppos);
        if (retval > 0)
-               hpfs_i(file->f_dentry->d_inode)->i_dirty = 1;
+               hpfs_i(file->f_path.dentry->d_inode)->i_dirty = 1;
        return retval;
 }
 
index 32ab51e42b967e374726e9d5681c2970f55520e3..1c07aa82d32787ef3e7751c1f04c11ce0e8e8483 100644 (file)
@@ -317,7 +317,8 @@ static inline struct hpfs_sb_info *hpfs_sb(struct super_block *sb)
 
 /* super.c */
 
-void hpfs_error(struct super_block *, char *, ...);
+void hpfs_error(struct super_block *, const char *, ...)
+       __attribute__((format (printf, 2, 3)));
 int hpfs_stop_cycles(struct super_block *, int, int *, int *, char *);
 unsigned hpfs_count_one_bitmap(struct super_block *, secno);
 
index 7faef8544f320bd67933fe560992800235c36728..85d3e1d9ac000072df33c32b52da5e16394cc676 100644 (file)
@@ -251,7 +251,10 @@ void hpfs_write_inode_nolock(struct inode *i)
                        de->file_size = 0;
                        hpfs_mark_4buffers_dirty(&qbh);
                        hpfs_brelse4(&qbh);
-               } else hpfs_error(i->i_sb, "directory %08x doesn't have '.' entry", i->i_ino);
+               } else
+                       hpfs_error(i->i_sb,
+                               "directory %08lx doesn't have '.' entry",
+                               (unsigned long)i->i_ino);
        }
        mark_buffer_dirty(bh);
        brelse(bh);
index 0fecdac22e4e9602c5721d6d162105a9bdc7fee0..c4724589b2eba1854f9d5afc7a274c1a9beed066 100644 (file)
@@ -126,32 +126,40 @@ struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_hea
                        struct extended_attribute *ea;
                        struct extended_attribute *ea_end;
                        if (fnode->magic != FNODE_MAGIC) {
-                               hpfs_error(s, "bad magic on fnode %08x", ino);
+                               hpfs_error(s, "bad magic on fnode %08lx",
+                                       (unsigned long)ino);
                                goto bail;
                        }
                        if (!fnode->dirflag) {
                                if ((unsigned)fnode->btree.n_used_nodes + (unsigned)fnode->btree.n_free_nodes !=
                                    (fnode->btree.internal ? 12 : 8)) {
-                                       hpfs_error(s, "bad number of nodes in fnode %08x", ino);
+                                       hpfs_error(s,
+                                          "bad number of nodes in fnode %08lx",
+                                           (unsigned long)ino);
                                        goto bail;
                                }
                                if (fnode->btree.first_free !=
                                    8 + fnode->btree.n_used_nodes * (fnode->btree.internal ? 8 : 12)) {
-                                       hpfs_error(s, "bad first_free pointer in fnode %08x", ino);
+                                       hpfs_error(s,
+                                           "bad first_free pointer in fnode %08lx",
+                                           (unsigned long)ino);
                                        goto bail;
                                }
                        }
                        if (fnode->ea_size_s && ((signed int)fnode->ea_offs < 0xc4 ||
                           (signed int)fnode->ea_offs + fnode->acl_size_s + fnode->ea_size_s > 0x200)) {
-                               hpfs_error(s, "bad EA info in fnode %08x: ea_offs == %04x ea_size_s == %04x",
-                                       ino, fnode->ea_offs, fnode->ea_size_s);
+                               hpfs_error(s,
+                                       "bad EA info in fnode %08lx: ea_offs == %04x ea_size_s == %04x",
+                                       (unsigned long)ino,
+                                       fnode->ea_offs, fnode->ea_size_s);
                                goto bail;
                        }
                        ea = fnode_ea(fnode);
                        ea_end = fnode_end_ea(fnode);
                        while (ea != ea_end) {
                                if (ea > ea_end) {
-                                       hpfs_error(s, "bad EA in fnode %08x", ino);
+                                       hpfs_error(s, "bad EA in fnode %08lx",
+                                               (unsigned long)ino);
                                        goto bail;
                                }
                                ea = next_ea(ea);
index 450b5e0b4785c59431b002e5aa1db2b33aed70b8..d4abc1a1d56648b82ab3c8f8d8c8043ab03c95d9 100644 (file)
@@ -46,21 +46,17 @@ static void unmark_dirty(struct super_block *s)
 }
 
 /* Filesystem error... */
+static char err_buf[1024];
 
-#define ERR_BUF_SIZE 1024
-
-void hpfs_error(struct super_block *s, char *m,...)
+void hpfs_error(struct super_block *s, const char *fmt, ...)
 {
-       char *buf;
-       va_list l;
-       va_start(l, m);
-       if (!(buf = kmalloc(ERR_BUF_SIZE, GFP_KERNEL)))
-               printk("HPFS: No memory for error message '%s'\n",m);
-       else if (vsprintf(buf, m, l) >= ERR_BUF_SIZE)
-               printk("HPFS: Grrrr... Kernel memory corrupted ... going on, but it'll crash very soon :-(\n");
-       printk("HPFS: filesystem error: ");
-       if (buf) printk("%s", buf);
-       else printk("%s\n",m);
+       va_list args;
+
+       va_start(args, fmt);
+       vsnprintf(err_buf, sizeof(err_buf), fmt, args);
+       va_end(args);
+
+       printk("HPFS: filesystem error: %s", err_buf);
        if (!hpfs_sb(s)->sb_was_error) {
                if (hpfs_sb(s)->sb_err == 2) {
                        printk("; crashing the system because you wanted it\n");
@@ -76,7 +72,6 @@ void hpfs_error(struct super_block *s, char *m,...)
                } else if (s->s_flags & MS_RDONLY) printk("; going on - but anything won't be destroyed because it's read-only\n");
                else printk("; corrupted filesystem mounted read/write - your computer will explode within 20 seconds ... but you wanted it so!\n");
        } else printk("\n");
-       kfree(buf);
        hpfs_sb(s)->sb_was_error = 1;
 }
 
@@ -160,12 +155,12 @@ static int hpfs_statfs(struct dentry *dentry, struct kstatfs *buf)
        return 0;
 }
 
-static kmem_cache_t * hpfs_inode_cachep;
+static struct kmem_cache * hpfs_inode_cachep;
 
 static struct inode *hpfs_alloc_inode(struct super_block *sb)
 {
        struct hpfs_inode_info *ei;
-       ei = (struct hpfs_inode_info *)kmem_cache_alloc(hpfs_inode_cachep, SLAB_NOFS);
+       ei = (struct hpfs_inode_info *)kmem_cache_alloc(hpfs_inode_cachep, GFP_NOFS);
        if (!ei)
                return NULL;
        ei->vfs_inode.i_version = 1;
@@ -177,7 +172,7 @@ static void hpfs_destroy_inode(struct inode *inode)
        kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo;
 
index 642675fc394a9e0a2771d4a106c91c2097d4fb23..afd340a45da461ea47e7cc4ef4d8736417441511 100644 (file)
@@ -221,7 +221,7 @@ static ssize_t read_proc(struct file *file, char __user *buf, ssize_t count,
        ssize_t (*read)(struct file *, char __user *, size_t, loff_t *);
        ssize_t n;
 
-       read = file->f_dentry->d_inode->i_fop->read;
+       read = file->f_path.dentry->d_inode->i_fop->read;
 
        if(!is_user)
                set_fs(KERNEL_DS);
@@ -320,7 +320,7 @@ static ssize_t hppfs_write(struct file *file, const char __user *buf, size_t len
        ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *);
        int err;
 
-       write = proc_file->f_dentry->d_inode->i_fop->write;
+       write = proc_file->f_path.dentry->d_inode->i_fop->write;
 
        proc_file->f_pos = file->f_pos;
        err = (*write)(proc_file, buf, len, &proc_file->f_pos);
@@ -464,7 +464,7 @@ static int hppfs_open(struct inode *inode, struct file *file)
        if(data == NULL)
                goto out;
 
-       host_file = dentry_name(file->f_dentry, strlen("/rw"));
+       host_file = dentry_name(file->f_path.dentry, strlen("/rw"));
        if(host_file == NULL)
                goto out_free2;
 
@@ -547,7 +547,7 @@ static loff_t hppfs_llseek(struct file *file, loff_t off, int where)
        loff_t (*llseek)(struct file *, loff_t, int);
        loff_t ret;
 
-       llseek = proc_file->f_dentry->d_inode->i_fop->llseek;
+       llseek = proc_file->f_path.dentry->d_inode->i_fop->llseek;
        if(llseek != NULL){
                ret = (*llseek)(proc_file, off, where);
                if(ret < 0)
@@ -591,10 +591,10 @@ static int hppfs_readdir(struct file *file, void *ent, filldir_t filldir)
        struct hppfs_dirent dirent = ((struct hppfs_dirent)
                                      { .vfs_dirent     = ent,
                                        .filldir        = filldir,
-                                       .dentry         = file->f_dentry } );
+                                       .dentry         = file->f_path.dentry } );
        int err;
 
-       readdir = proc_file->f_dentry->d_inode->i_fop->readdir;
+       readdir = proc_file->f_path.dentry->d_inode->i_fop->readdir;
 
        proc_file->f_pos = file->f_pos;
        err = (*readdir)(proc_file, &dirent, hppfs_filldir);
index 7f4756963d05e067464dcb9570db9ebba54b1170..ed2c22340ad73c0a807bacb7c1baffbf27dfaafb 100644 (file)
@@ -58,7 +58,7 @@ static void huge_pagevec_release(struct pagevec *pvec)
 
 static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        loff_t len, vma_len;
        int ret;
 
@@ -513,7 +513,7 @@ static void hugetlbfs_inc_free_inodes(struct hugetlbfs_sb_info *sbinfo)
 }
 
 
-static kmem_cache_t *hugetlbfs_inode_cachep;
+static struct kmem_cache *hugetlbfs_inode_cachep;
 
 static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)
 {
@@ -522,7 +522,7 @@ static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)
 
        if (unlikely(!hugetlbfs_dec_free_inodes(sbinfo)))
                return NULL;
-       p = kmem_cache_alloc(hugetlbfs_inode_cachep, SLAB_KERNEL);
+       p = kmem_cache_alloc(hugetlbfs_inode_cachep, GFP_KERNEL);
        if (unlikely(!p)) {
                hugetlbfs_inc_free_inodes(sbinfo);
                return NULL;
@@ -545,7 +545,7 @@ static const struct address_space_operations hugetlbfs_aops = {
 };
 
 
-static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags)
+static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
 {
        struct hugetlbfs_inode_info *ei = (struct hugetlbfs_inode_info *)foo;
 
@@ -774,8 +774,8 @@ struct file *hugetlb_zero_setup(size_t size)
        d_instantiate(dentry, inode);
        inode->i_size = size;
        inode->i_nlink = 0;
-       file->f_vfsmnt = mntget(hugetlbfs_vfsmount);
-       file->f_dentry = dentry;
+       file->f_path.mnt = mntget(hugetlbfs_vfsmount);
+       file->f_path.dentry = dentry;
        file->f_mapping = inode->i_mapping;
        file->f_op = &hugetlbfs_file_operations;
        file->f_mode = FMODE_WRITE | FMODE_READ;
index 26cdb115ce67d5361222d39cf5e94039db654eec..d00de182ecb97fec47c74eb454b89918b6ab3802 100644 (file)
@@ -97,7 +97,7 @@ static DEFINE_MUTEX(iprune_mutex);
  */
 struct inodes_stat_t inodes_stat;
 
-static kmem_cache_t * inode_cachep __read_mostly;
+static struct kmem_cache * inode_cachep __read_mostly;
 
 static struct inode *alloc_inode(struct super_block *sb)
 {
@@ -109,7 +109,7 @@ static struct inode *alloc_inode(struct super_block *sb)
        if (sb->s_op->alloc_inode)
                inode = sb->s_op->alloc_inode(sb);
        else
-               inode = (struct inode *) kmem_cache_alloc(inode_cachep, SLAB_KERNEL);
+               inode = (struct inode *) kmem_cache_alloc(inode_cachep, GFP_KERNEL);
 
        if (inode) {
                struct address_space * const mapping = &inode->i_data;
@@ -209,7 +209,7 @@ void inode_init_once(struct inode *inode)
 
 EXPORT_SYMBOL(inode_init_once);
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct inode * inode = (struct inode *) foo;
 
@@ -1200,7 +1200,7 @@ EXPORT_SYMBOL(touch_atime);
 
 void file_update_time(struct file *file)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct timespec now;
        int sync_it = 0;
 
@@ -1242,9 +1242,6 @@ EXPORT_SYMBOL(inode_needs_sync);
  */
 #ifdef CONFIG_QUOTA
 
-/* Function back in dquot.c */
-int remove_inode_dquot_ref(struct inode *, int, struct list_head *);
-
 void remove_dquot_ref(struct super_block *sb, int type,
                        struct list_head *tofree_head)
 {
index 017cb0f134d6aa600f5c37296b6c786bacb6cf7c..55f6da55b7c0ec36f8e76307c512999570103e4e 100644 (file)
@@ -34,8 +34,8 @@
 
 #include <asm/ioctls.h>
 
-static kmem_cache_t *watch_cachep __read_mostly;
-static kmem_cache_t *event_cachep __read_mostly;
+static struct kmem_cache *watch_cachep __read_mostly;
+static struct kmem_cache *event_cachep __read_mostly;
 
 static struct vfsmount *inotify_mnt __read_mostly;
 
@@ -570,9 +570,9 @@ asmlinkage long sys_inotify_init(void)
        dev->ih = ih;
 
        filp->f_op = &inotify_fops;
-       filp->f_vfsmnt = mntget(inotify_mnt);
-       filp->f_dentry = dget(inotify_mnt->mnt_root);
-       filp->f_mapping = filp->f_dentry->d_inode->i_mapping;
+       filp->f_path.mnt = mntget(inotify_mnt);
+       filp->f_path.dentry = dget(inotify_mnt->mnt_root);
+       filp->f_mapping = filp->f_path.dentry->d_inode->i_mapping;
        filp->f_mode = FMODE_READ;
        filp->f_flags = O_RDONLY;
        filp->private_data = dev;
index 4b7660b09ac0679cd79481bc14727dbd4888eeb5..ff61772ceedd88362c35e9a9a550ca3cf1d8752a 100644 (file)
@@ -31,7 +31,7 @@ static long do_ioctl(struct file *filp, unsigned int cmd,
                goto out;
        } else if (filp->f_op->ioctl) {
                lock_kernel();
-               error = filp->f_op->ioctl(filp->f_dentry->d_inode,
+               error = filp->f_op->ioctl(filp->f_path.dentry->d_inode,
                                          filp, cmd, arg);
                unlock_kernel();
        }
@@ -45,7 +45,7 @@ static int file_ioctl(struct file *filp, unsigned int cmd,
 {
        int error;
        int block;
-       struct inode * inode = filp->f_dentry->d_inode;
+       struct inode * inode = filp->f_path.dentry->d_inode;
        int __user *p = (int __user *)arg;
 
        switch (cmd) {
@@ -137,17 +137,17 @@ int vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, unsigned lon
                        break;
 
                case FIOQSIZE:
-                       if (S_ISDIR(filp->f_dentry->d_inode->i_mode) ||
-                           S_ISREG(filp->f_dentry->d_inode->i_mode) ||
-                           S_ISLNK(filp->f_dentry->d_inode->i_mode)) {
-                               loff_t res = inode_get_bytes(filp->f_dentry->d_inode);
+                       if (S_ISDIR(filp->f_path.dentry->d_inode->i_mode) ||
+                           S_ISREG(filp->f_path.dentry->d_inode->i_mode) ||
+                           S_ISLNK(filp->f_path.dentry->d_inode->i_mode)) {
+                               loff_t res = inode_get_bytes(filp->f_path.dentry->d_inode);
                                error = copy_to_user((loff_t __user *)arg, &res, sizeof(res)) ? -EFAULT : 0;
                        }
                        else
                                error = -ENOTTY;
                        break;
                default:
-                       if (S_ISREG(filp->f_dentry->d_inode->i_mode))
+                       if (S_ISREG(filp->f_path.dentry->d_inode->i_mode))
                                error = file_ioctl(filp, cmd, arg);
                        else
                                error = do_ioctl(filp, cmd, arg);
index 731816332b12b5a310623fbc85134710714ddd41..6bbbdb53581d1bb42b1db87f88a4de9799b82808 100644 (file)
@@ -42,7 +42,7 @@ static struct semaphore zisofs_zlib_semaphore;
  */
 static int zisofs_readpage(struct file *file, struct page *page)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct address_space *mapping = inode->i_mapping;
        unsigned int maxpage, xpage, fpage, blockindex;
        unsigned long offset;
index 27e276987fd2705536e3ea2e00e530f12cbfbe48..4af2548f97a97d4b6149208148302886b55933a8 100644 (file)
@@ -183,7 +183,7 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp,
 
                /* Handle the case of the '..' directory */
                if (de->name_len[0] == 1 && de->name[0] == 1) {
-                       inode_number = parent_ino(filp->f_dentry);
+                       inode_number = parent_ino(filp->f_path.dentry);
                        if (filldir(dirent, "..", 2, filp->f_pos, inode_number, DT_DIR) < 0)
                                break;
                        filp->f_pos += de_len;
@@ -255,8 +255,7 @@ static int isofs_readdir(struct file *filp,
        int result;
        char * tmpname;
        struct iso_directory_record * tmpde;
-       struct inode *inode = filp->f_dentry->d_inode;
-
+       struct inode *inode = filp->f_path.dentry->d_inode;
 
        tmpname = (char *)__get_free_page(GFP_KERNEL);
        if (tmpname == NULL)
index c34b862cdbf204cf5e7124408659f89108289a82..ea55b6c469ecdc8f0cb97a050f5b1d9ad0d04038 100644 (file)
@@ -57,12 +57,12 @@ static void isofs_put_super(struct super_block *sb)
 static void isofs_read_inode(struct inode *);
 static int isofs_statfs (struct dentry *, struct kstatfs *);
 
-static kmem_cache_t *isofs_inode_cachep;
+static struct kmem_cache *isofs_inode_cachep;
 
 static struct inode *isofs_alloc_inode(struct super_block *sb)
 {
        struct iso_inode_info *ei;
-       ei = kmem_cache_alloc(isofs_inode_cachep, SLAB_KERNEL);
+       ei = kmem_cache_alloc(isofs_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        return &ei->vfs_inode;
@@ -73,7 +73,7 @@ static void isofs_destroy_inode(struct inode *inode)
        kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode));
 }
 
-static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void *foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct iso_inode_info *ei = foo;
 
index b85c686b60dbc7f58c32e04740dcb7052056544e..10fff94439387ab98b55dabb8d6f1af1e7a5384a 100644 (file)
@@ -31,7 +31,7 @@
 #include <linux/smp_lock.h>
 #include <linux/init.h>
 #include <linux/mm.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 #include <linux/pagemap.h>
 #include <linux/kthread.h>
 #include <linux/poison.h>
@@ -1630,7 +1630,7 @@ void * __jbd_kmalloc (const char *where, size_t size, gfp_t flags, int retry)
 #define JBD_MAX_SLABS 5
 #define JBD_SLAB_INDEX(size)  (size >> 11)
 
-static kmem_cache_t *jbd_slab[JBD_MAX_SLABS];
+static struct kmem_cache *jbd_slab[JBD_MAX_SLABS];
 static const char *jbd_slab_names[JBD_MAX_SLABS] = {
        "jbd_1k", "jbd_2k", "jbd_4k", NULL, "jbd_8k"
 };
@@ -1693,7 +1693,7 @@ void jbd_slab_free(void *ptr,  size_t size)
 /*
  * Journal_head storage management
  */
-static kmem_cache_t *journal_head_cache;
+static struct kmem_cache *journal_head_cache;
 #ifdef CONFIG_JBD_DEBUG
 static atomic_t nr_journal_heads = ATOMIC_INIT(0);
 #endif
@@ -1996,7 +1996,7 @@ static void __exit remove_jbd_proc_entry(void)
 
 #endif
 
-kmem_cache_t *jbd_handle_cache;
+struct kmem_cache *jbd_handle_cache;
 
 static int __init journal_init_handle_cache(void)
 {
index c532429d8d9b365e9b540255e4f684071a9e0894..d204ab394f36bb0001c36d22b88fa0a1217c21f1 100644 (file)
@@ -70,8 +70,8 @@
 #include <linux/init.h>
 #endif
 
-static kmem_cache_t *revoke_record_cache;
-static kmem_cache_t *revoke_table_cache;
+static struct kmem_cache *revoke_record_cache;
+static struct kmem_cache *revoke_table_cache;
 
 /* Each revoke record represents one single revoked block.  During
    journal replay, this involves recording the transaction ID of the
index 4f82bcd63e488a6a1b0ff1b8bb20bb7e2a968b3c..d38e0d575e48d3d0554384a52277be8f4469b1c0 100644 (file)
@@ -27,6 +27,8 @@
 #include <linux/mm.h>
 #include <linux/highmem.h>
 
+static void __journal_temp_unlink_buffer(struct journal_head *jh);
+
 /*
  * get_transaction: obtain a new transaction_t object.
  *
@@ -1499,7 +1501,7 @@ __blist_del_buffer(struct journal_head **list, struct journal_head *jh)
  *
  * Called under j_list_lock.  The journal may not be locked.
  */
-void __journal_temp_unlink_buffer(struct journal_head *jh)
+static void __journal_temp_unlink_buffer(struct journal_head *jh)
 {
        struct journal_head **list = NULL;
        transaction_t *transaction;
index 70b2ae1ef2810e1a8fea2a557bfa5f5e7a395190..6bd8005e3d34434d95fac5037d79d4042af34678 100644 (file)
@@ -248,8 +248,12 @@ write_out_data:
                                bufs = 0;
                                goto write_out_data;
                        }
-               }
-               else {
+               } else if (!locked && buffer_locked(bh)) {
+                       __jbd2_journal_file_buffer(jh, commit_transaction,
+                                               BJ_Locked);
+                       jbd_unlock_bh_state(bh);
+                       put_bh(bh);
+               } else {
                        BUFFER_TRACE(bh, "writeout complete: unfile");
                        __jbd2_journal_unfile_buffer(jh);
                        jbd_unlock_bh_state(bh);
index c60f378b0f7670dec45afd81cd576cb030a0a324..44fc32bfd7f1d2d847bb3b84c423b00a9d07f8b8 100644 (file)
@@ -31,7 +31,7 @@
 #include <linux/smp_lock.h>
 #include <linux/init.h>
 #include <linux/mm.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 #include <linux/pagemap.h>
 #include <linux/kthread.h>
 #include <linux/poison.h>
@@ -1641,7 +1641,7 @@ void * __jbd2_kmalloc (const char *where, size_t size, gfp_t flags, int retry)
 #define JBD_MAX_SLABS 5
 #define JBD_SLAB_INDEX(size)  (size >> 11)
 
-static kmem_cache_t *jbd_slab[JBD_MAX_SLABS];
+static struct kmem_cache *jbd_slab[JBD_MAX_SLABS];
 static const char *jbd_slab_names[JBD_MAX_SLABS] = {
        "jbd2_1k", "jbd2_2k", "jbd2_4k", NULL, "jbd2_8k"
 };
@@ -1704,7 +1704,7 @@ void jbd2_slab_free(void *ptr,  size_t size)
 /*
  * Journal_head storage management
  */
-static kmem_cache_t *jbd2_journal_head_cache;
+static struct kmem_cache *jbd2_journal_head_cache;
 #ifdef CONFIG_JBD_DEBUG
 static atomic_t nr_journal_heads = ATOMIC_INIT(0);
 #endif
@@ -2007,7 +2007,7 @@ static void __exit jbd2_remove_jbd_proc_entry(void)
 
 #endif
 
-kmem_cache_t *jbd2_handle_cache;
+struct kmem_cache *jbd2_handle_cache;
 
 static int __init journal_init_handle_cache(void)
 {
index 380d19917f3732ad198edd47947f6fcfad662d5f..f506646ad0ffaa17369e68c4120e18b1aff7003f 100644 (file)
@@ -70,8 +70,8 @@
 #include <linux/init.h>
 #endif
 
-static kmem_cache_t *jbd2_revoke_record_cache;
-static kmem_cache_t *jbd2_revoke_table_cache;
+static struct kmem_cache *jbd2_revoke_record_cache;
+static struct kmem_cache *jbd2_revoke_table_cache;
 
 /* Each revoke record represents one single revoked block.  During
    journal replay, this involves recording the transaction ID of the
index c051a94c8a979106a326cd3e3fb931095dc8305f..3a8700153cb087bdade5965990201eeddee9da5c 100644 (file)
@@ -27,6 +27,8 @@
 #include <linux/mm.h>
 #include <linux/highmem.h>
 
+static void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh);
+
 /*
  * jbd2_get_transaction: obtain a new transaction_t object.
  *
index 3f7899ea4cba9389742e6cb85d441ce9ff8c2535..7b40c69f44ebb07bd60edd7a44ece0b29c4e9e76 100644 (file)
@@ -61,8 +61,8 @@ static const struct file_operations jffs_dir_operations;
 static struct inode_operations jffs_dir_inode_operations;
 static const struct address_space_operations jffs_address_operations;
 
-kmem_cache_t     *node_cache = NULL;
-kmem_cache_t     *fm_cache = NULL;
+struct kmem_cache     *node_cache = NULL;
+struct kmem_cache     *fm_cache = NULL;
 
 /* Called by the VFS at mount time to initialize the whole file system.  */
 static int jffs_fill_super(struct super_block *sb, void *data, int silent)
@@ -566,7 +566,7 @@ static int
 jffs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
        struct jffs_file *f;
-       struct dentry *dentry = filp->f_dentry;
+       struct dentry *dentry = filp->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        struct jffs_control *c = (struct jffs_control *)inode->i_sb->s_fs_info;
        int j;
@@ -1372,7 +1372,7 @@ jffs_file_write(struct file *filp, const char *buf, size_t count,
        struct jffs_control *c;
        struct jffs_file *f;
        struct jffs_node *node;
-       struct dentry *dentry = filp->f_dentry;
+       struct dentry *dentry = filp->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        int recoverable = 0;
        size_t written = 0;
@@ -1380,7 +1380,7 @@ jffs_file_write(struct file *filp, const char *buf, size_t count,
        loff_t pos = *ppos;
        int err;
 
-       inode = filp->f_dentry->d_inode;
+       inode = filp->f_path.dentry->d_inode;
 
        D2(printk("***jffs_file_write(): inode: 0x%p (ino: %lu), "
                  "filp: 0x%p, buf: 0x%p, count: %d\n",
index 4a543e1149700b08141d6769814848ea9295e2c9..d0e783f199eafd0a76e42b6f97cc01385d89cbea 100644 (file)
@@ -66,6 +66,7 @@
 #include <linux/smp_lock.h>
 #include <linux/time.h>
 #include <linux/ctype.h>
+#include <linux/freezer.h>
 
 #include "intrep.h"
 #include "jffs_fm.h"
@@ -591,7 +592,7 @@ jffs_add_virtual_root(struct jffs_control *c)
        D2(printk("jffs_add_virtual_root(): "
                  "Creating a virtual root directory.\n"));
 
-       if (!(root = kmalloc(sizeof(struct jffs_file), GFP_KERNEL))) {
+       if (!(root = kzalloc(sizeof(struct jffs_file), GFP_KERNEL))) {
                return -ENOMEM;
        }
        no_jffs_file++;
@@ -603,7 +604,6 @@ jffs_add_virtual_root(struct jffs_control *c)
        DJM(no_jffs_node++);
        memset(node, 0, sizeof(struct jffs_node));
        node->ino = JFFS_MIN_INO;
-       memset(root, 0, sizeof(struct jffs_file));
        root->ino = JFFS_MIN_INO;
        root->mode = S_IFDIR | S_IRWXU | S_IRGRP
                     | S_IXGRP | S_IROTH | S_IXOTH;
index 29b68d939bd9e9f6f9c8bd0572d1b157f2476dcd..077258b2103e5bac0d386a46102f4741292e5b2d 100644 (file)
@@ -29,8 +29,8 @@ static int jffs_mark_obsolete(struct jffs_fmcontrol *fmc, __u32 fm_offset);
 static struct jffs_fm *jffs_alloc_fm(void);
 static void jffs_free_fm(struct jffs_fm *n);
 
-extern kmem_cache_t     *fm_cache;
-extern kmem_cache_t     *node_cache;
+extern struct kmem_cache     *fm_cache;
+extern struct kmem_cache     *node_cache;
 
 #if CONFIG_JFFS_FS_VERBOSE > 0
 void
index ff2a872e80e78677de43baaf8acc758299106ec0..6eb3daebd56354ca4973093c9d5966c7e148ae0a 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/mtd/mtd.h>
 #include <linux/completion.h>
 #include <linux/sched.h>
+#include <linux/freezer.h>
 #include "nodelist.h"
 
 
index 9def6adf4a5dee6a0a0162e31ebdf475842d9305..da6034d50718dad0f06bac3c5004f60d0124479d 100644 (file)
@@ -123,11 +123,11 @@ static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
        struct jffs2_inode_info *f;
        struct jffs2_sb_info *c;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct jffs2_full_dirent *fd;
        unsigned long offset, curofs;
 
-       D1(printk(KERN_DEBUG "jffs2_readdir() for dir_i #%lu\n", filp->f_dentry->d_inode->i_ino));
+       D1(printk(KERN_DEBUG "jffs2_readdir() for dir_i #%lu\n", filp->f_path.dentry->d_inode->i_ino));
 
        f = JFFS2_INODE_INFO(inode);
        c = JFFS2_SB_INFO(inode->i_sb);
@@ -141,7 +141,7 @@ static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir)
                offset++;
        }
        if (offset == 1) {
-               unsigned long pino = parent_ino(filp->f_dentry);
+               unsigned long pino = parent_ino(filp->f_path.dentry);
                D1(printk(KERN_DEBUG "Dirent 1: \"..\", ino #%lu\n", pino));
                if (filldir(dirent, "..", 2, 1, pino, DT_DIR) < 0)
                        goto out;
index 33f291005012bedf622daaaaa4ebf5f77655d2a1..83f9881ec4cc970a2cd61e267b5fd46a78dd9deb 100644 (file)
 
 /* These are initialised to NULL in the kernel startup code.
    If you're porting to other operating systems, beware */
-static kmem_cache_t *full_dnode_slab;
-static kmem_cache_t *raw_dirent_slab;
-static kmem_cache_t *raw_inode_slab;
-static kmem_cache_t *tmp_dnode_info_slab;
-static kmem_cache_t *raw_node_ref_slab;
-static kmem_cache_t *node_frag_slab;
-static kmem_cache_t *inode_cache_slab;
+static struct kmem_cache *full_dnode_slab;
+static struct kmem_cache *raw_dirent_slab;
+static struct kmem_cache *raw_inode_slab;
+static struct kmem_cache *tmp_dnode_info_slab;
+static struct kmem_cache *raw_node_ref_slab;
+static struct kmem_cache *node_frag_slab;
+static struct kmem_cache *inode_cache_slab;
 #ifdef CONFIG_JFFS2_FS_XATTR
-static kmem_cache_t *xattr_datum_cache;
-static kmem_cache_t *xattr_ref_cache;
+static struct kmem_cache *xattr_datum_cache;
+static struct kmem_cache *xattr_ref_cache;
 #endif
 
 int __init jffs2_create_slab_caches(void)
index bc4b8106a49010bf8144bfbe3a0e6532860eacb4..7deb7825402156fcd5f04d47b518452df2945a7f 100644 (file)
 
 static void jffs2_put_super(struct super_block *);
 
-static kmem_cache_t *jffs2_inode_cachep;
+static struct kmem_cache *jffs2_inode_cachep;
 
 static struct inode *jffs2_alloc_inode(struct super_block *sb)
 {
        struct jffs2_inode_info *ei;
-       ei = (struct jffs2_inode_info *)kmem_cache_alloc(jffs2_inode_cachep, SLAB_KERNEL);
+       ei = (struct jffs2_inode_info *)kmem_cache_alloc(jffs2_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        return &ei->vfs_inode;
@@ -44,7 +44,7 @@ static void jffs2_destroy_inode(struct inode *inode)
        kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode));
 }
 
-static void jffs2_i_init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void jffs2_i_init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct jffs2_inode_info *ei = (struct jffs2_inode_info *) foo;
 
index ecb2216d881ccf5fb76bbd46151cc14763866018..47bc0b5d13242c69e8ceb344d837769bb623a929 100644 (file)
@@ -3009,7 +3009,7 @@ static inline struct jfs_dirent *next_jfs_dirent(struct jfs_dirent *dirent)
  */
 int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct inode *ip = filp->f_dentry->d_inode;
+       struct inode *ip = filp->f_path.dentry->d_inode;
        struct nls_table *codepage = JFS_SBI(ip->i_sb)->nls_tab;
        int rc = 0;
        loff_t dtpos;   /* legacy OS/2 style position */
index b89c9aba046635b90ec977a9415ddb8ef79a2f8f..5065baa530b601d2d4ee28a5247ff7bc23e09b60 100644 (file)
@@ -67,7 +67,7 @@
 #include <linux/kthread.h>
 #include <linux/buffer_head.h>         /* for sync_blockdev() */
 #include <linux/bio.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 #include <linux/delay.h>
 #include <linux/mutex.h>
 #include "jfs_incore.h"
index 0cccd1c39d750e199185c4b1d7f7004f52246142..b1a1c7296014de6dc0da37af7b4cfade89639eec 100644 (file)
@@ -74,7 +74,7 @@ static inline void lock_metapage(struct metapage *mp)
 }
 
 #define METAPOOL_MIN_PAGES 32
-static kmem_cache_t *metapage_cache;
+static struct kmem_cache *metapage_cache;
 static mempool_t *metapage_mempool;
 
 #define MPS_PER_PAGE (PAGE_CACHE_SIZE >> L2PSIZE)
@@ -180,7 +180,7 @@ static inline void remove_metapage(struct page *page, struct metapage *mp)
 
 #endif
 
-static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags)
+static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
 {
        struct metapage *mp = (struct metapage *)foo;
 
index 81f6f04af192ae45c64d3022591522b527342a38..d558e51b0df8ffe4217b091f68a26bc7389dfcc2 100644 (file)
@@ -46,7 +46,7 @@
 #include <linux/vmalloc.h>
 #include <linux/smp_lock.h>
 #include <linux/completion.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kthread.h>
index 9c1c6e0e633d365dca62a9726037c5cfefcbaa2c..846ac8f34513e64f49eefc11d446b8b8bfbad37a 100644 (file)
@@ -44,7 +44,7 @@ MODULE_DESCRIPTION("The Journaled Filesystem (JFS)");
 MODULE_AUTHOR("Steve Best/Dave Kleikamp/Barry Arndt, IBM");
 MODULE_LICENSE("GPL");
 
-static kmem_cache_t * jfs_inode_cachep;
+static struct kmem_cache * jfs_inode_cachep;
 
 static struct super_operations jfs_super_operations;
 static struct export_operations jfs_export_operations;
@@ -93,7 +93,7 @@ void jfs_error(struct super_block *sb, const char * function, ...)
        va_list args;
 
        va_start(args, function);
-       vsprintf(error_buf, function, args);
+       vsnprintf(error_buf, sizeof(error_buf), function, args);
        va_end(args);
 
        printk(KERN_ERR "ERROR: (device %s): %s\n", sb->s_id, error_buf);
@@ -748,7 +748,7 @@ static struct file_system_type jfs_fs_type = {
        .fs_flags       = FS_REQUIRES_DEV,
 };
 
-static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void *foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct jfs_inode_info *jfs_ip = (struct jfs_inode_info *) foo;
 
index bd08e0e64a8caa8731c9ee5ccbd37962eb658298..503898d5c4a748226e2f17e2cd9c8ab4ee081b87 100644 (file)
@@ -63,7 +63,7 @@ int dcache_dir_open(struct inode *inode, struct file *file)
 {
        static struct qstr cursor_name = {.len = 1, .name = "."};
 
-       file->private_data = d_alloc(file->f_dentry, &cursor_name);
+       file->private_data = d_alloc(file->f_path.dentry, &cursor_name);
 
        return file->private_data ? 0 : -ENOMEM;
 }
@@ -76,7 +76,7 @@ int dcache_dir_close(struct inode *inode, struct file *file)
 
 loff_t dcache_dir_lseek(struct file *file, loff_t offset, int origin)
 {
-       mutex_lock(&file->f_dentry->d_inode->i_mutex);
+       mutex_lock(&file->f_path.dentry->d_inode->i_mutex);
        switch (origin) {
                case 1:
                        offset += file->f_pos;
@@ -84,7 +84,7 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int origin)
                        if (offset >= 0)
                                break;
                default:
-                       mutex_unlock(&file->f_dentry->d_inode->i_mutex);
+                       mutex_unlock(&file->f_path.dentry->d_inode->i_mutex);
                        return -EINVAL;
        }
        if (offset != file->f_pos) {
@@ -96,8 +96,8 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int origin)
 
                        spin_lock(&dcache_lock);
                        list_del(&cursor->d_u.d_child);
-                       p = file->f_dentry->d_subdirs.next;
-                       while (n && p != &file->f_dentry->d_subdirs) {
+                       p = file->f_path.dentry->d_subdirs.next;
+                       while (n && p != &file->f_path.dentry->d_subdirs) {
                                struct dentry *next;
                                next = list_entry(p, struct dentry, d_u.d_child);
                                if (!d_unhashed(next) && next->d_inode)
@@ -108,7 +108,7 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int origin)
                        spin_unlock(&dcache_lock);
                }
        }
-       mutex_unlock(&file->f_dentry->d_inode->i_mutex);
+       mutex_unlock(&file->f_path.dentry->d_inode->i_mutex);
        return offset;
 }
 
@@ -126,7 +126,7 @@ static inline unsigned char dt_type(struct inode *inode)
 
 int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
 {
-       struct dentry *dentry = filp->f_dentry;
+       struct dentry *dentry = filp->f_path.dentry;
        struct dentry *cursor = filp->private_data;
        struct list_head *p, *q = &cursor->d_u.d_child;
        ino_t ino;
index b85a0ad2cfb622fee0986450f530b44d3f987b16..92681c9e9b2009247ce091641cd89311a4025dbb 100644 (file)
@@ -126,7 +126,7 @@ __be32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *lock
                        continue;
                if (!nlm_cmp_addr(&block->b_host->h_addr, addr))
                        continue;
-               if (nfs_compare_fh(NFS_FH(fl_blocked->fl_file->f_dentry->d_inode) ,fh) != 0)
+               if (nfs_compare_fh(NFS_FH(fl_blocked->fl_file->f_path.dentry->d_inode) ,fh) != 0)
                        continue;
                /* Alright, we found a lock. Set the return status
                 * and wake up the caller
index 3d84f600b633693f37078a28ee9fb5e31290b378..80a1a6dccc8f293d3d3feda1bad9f293d9876108 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/nfs_fs.h>
 #include <linux/utsname.h>
 #include <linux/smp_lock.h>
+#include <linux/freezer.h>
 #include <linux/sunrpc/clnt.h>
 #include <linux/sunrpc/svc.h>
 #include <linux/lockd/lockd.h>
@@ -128,7 +129,7 @@ static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl)
 
        nlmclnt_next_cookie(&argp->cookie);
        argp->state   = nsm_local_state;
-       memcpy(&lock->fh, NFS_FH(fl->fl_file->f_dentry->d_inode), sizeof(struct nfs_fh));
+       memcpy(&lock->fh, NFS_FH(fl->fl_file->f_path.dentry->d_inode), sizeof(struct nfs_fh));
        lock->caller  = utsname()->nodename;
        lock->oh.data = req->a_owner;
        lock->oh.len  = snprintf(req->a_owner, sizeof(req->a_owner), "%u@%s",
@@ -729,7 +730,7 @@ static void nlmclnt_cancel_callback(struct rpc_task *task, void *data)
                goto retry_cancel;
        }
 
-       dprintk("lockd: cancel status %d (task %d)\n",
+       dprintk("lockd: cancel status %u (task %u)\n",
                        req->a_res.status, task->tk_pid);
 
        switch (req->a_res.status) {
index fb24a97303458f1b282f81111895c105e2c0399f..3d4610c2a2665f9ce7236988f6bd40c52d3623bd 100644 (file)
@@ -36,34 +36,14 @@ static DEFINE_MUTEX(nlm_host_mutex);
 static void                    nlm_gc_hosts(void);
 static struct nsm_handle *     __nsm_find(const struct sockaddr_in *,
                                        const char *, int, int);
-
-/*
- * Find an NLM server handle in the cache. If there is none, create it.
- */
-struct nlm_host *
-nlmclnt_lookup_host(const struct sockaddr_in *sin, int proto, int version,
-                       const char *hostname, int hostname_len)
-{
-       return nlm_lookup_host(0, sin, proto, version,
-                              hostname, hostname_len);
-}
-
-/*
- * Find an NLM client handle in the cache. If there is none, create it.
- */
-struct nlm_host *
-nlmsvc_lookup_host(struct svc_rqst *rqstp,
-                       const char *hostname, int hostname_len)
-{
-       return nlm_lookup_host(1, &rqstp->rq_addr,
-                              rqstp->rq_prot, rqstp->rq_vers,
-                              hostname, hostname_len);
-}
+static struct nsm_handle *     nsm_find(const struct sockaddr_in *sin,
+                                        const char *hostname,
+                                        int hostname_len);
 
 /*
  * Common host lookup routine for server & client
  */
-struct nlm_host *
+static struct nlm_host *
 nlm_lookup_host(int server, const struct sockaddr_in *sin,
                                        int proto, int version,
                                        const char *hostname,
@@ -194,6 +174,29 @@ nlm_destroy_host(struct nlm_host *host)
        kfree(host);
 }
 
+/*
+ * Find an NLM server handle in the cache. If there is none, create it.
+ */
+struct nlm_host *
+nlmclnt_lookup_host(const struct sockaddr_in *sin, int proto, int version,
+                       const char *hostname, int hostname_len)
+{
+       return nlm_lookup_host(0, sin, proto, version,
+                              hostname, hostname_len);
+}
+
+/*
+ * Find an NLM client handle in the cache. If there is none, create it.
+ */
+struct nlm_host *
+nlmsvc_lookup_host(struct svc_rqst *rqstp,
+                       const char *hostname, int hostname_len)
+{
+       return nlm_lookup_host(1, &rqstp->rq_addr,
+                              rqstp->rq_prot, rqstp->rq_vers,
+                              hostname, hostname_len);
+}
+
 /*
  * Create the NLM RPC client for an NLM peer
  */
@@ -495,7 +498,7 @@ out:
        return nsm;
 }
 
-struct nsm_handle *
+static struct nsm_handle *
 nsm_find(const struct sockaddr_in *sin, const char *hostname, int hostname_len)
 {
        return __nsm_find(sin, hostname, hostname_len, 1);
index 0ce5c81ff5078076e3fd43f659fa0de561370917..f67146a8199a0a98149407080dd83582357dc52f 100644 (file)
@@ -234,7 +234,7 @@ nlm4svc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp,
  */
 static void nlm4svc_callback_exit(struct rpc_task *task, void *data)
 {
-       dprintk("lockd: %4d callback returned %d\n", task->tk_pid,
+       dprintk("lockd: %5u callback returned %d\n", task->tk_pid,
                        -task->tk_status);
 }
 
index 7e219b93855274dd053551b6c2c09b6f747b464d..5c054b20fd5e8ced08856105c1a7409364aebfe8 100644 (file)
@@ -343,8 +343,8 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
        __be32                  ret;
 
        dprintk("lockd: nlmsvc_lock(%s/%ld, ty=%d, pi=%d, %Ld-%Ld, bl=%d)\n",
-                               file->f_file->f_dentry->d_inode->i_sb->s_id,
-                               file->f_file->f_dentry->d_inode->i_ino,
+                               file->f_file->f_path.dentry->d_inode->i_sb->s_id,
+                               file->f_file->f_path.dentry->d_inode->i_ino,
                                lock->fl.fl_type, lock->fl.fl_pid,
                                (long long)lock->fl.fl_start,
                                (long long)lock->fl.fl_end,
@@ -420,8 +420,8 @@ nlmsvc_testlock(struct nlm_file *file, struct nlm_lock *lock,
                                       struct nlm_lock *conflock)
 {
        dprintk("lockd: nlmsvc_testlock(%s/%ld, ty=%d, %Ld-%Ld)\n",
-                               file->f_file->f_dentry->d_inode->i_sb->s_id,
-                               file->f_file->f_dentry->d_inode->i_ino,
+                               file->f_file->f_path.dentry->d_inode->i_sb->s_id,
+                               file->f_file->f_path.dentry->d_inode->i_ino,
                                lock->fl.fl_type,
                                (long long)lock->fl.fl_start,
                                (long long)lock->fl.fl_end);
@@ -454,8 +454,8 @@ nlmsvc_unlock(struct nlm_file *file, struct nlm_lock *lock)
        int     error;
 
        dprintk("lockd: nlmsvc_unlock(%s/%ld, pi=%d, %Ld-%Ld)\n",
-                               file->f_file->f_dentry->d_inode->i_sb->s_id,
-                               file->f_file->f_dentry->d_inode->i_ino,
+                               file->f_file->f_path.dentry->d_inode->i_sb->s_id,
+                               file->f_file->f_path.dentry->d_inode->i_ino,
                                lock->fl.fl_pid,
                                (long long)lock->fl.fl_start,
                                (long long)lock->fl.fl_end);
@@ -483,8 +483,8 @@ nlmsvc_cancel_blocked(struct nlm_file *file, struct nlm_lock *lock)
        int status = 0;
 
        dprintk("lockd: nlmsvc_cancel(%s/%ld, pi=%d, %Ld-%Ld)\n",
-                               file->f_file->f_dentry->d_inode->i_sb->s_id,
-                               file->f_file->f_dentry->d_inode->i_ino,
+                               file->f_file->f_path.dentry->d_inode->i_sb->s_id,
+                               file->f_file->f_path.dentry->d_inode->i_ino,
                                lock->fl.fl_pid,
                                (long long)lock->fl.fl_start,
                                (long long)lock->fl.fl_end);
index 32e99a6e8dcad6c20964d63d3dcb5d460423b495..3707c3a23e9330173b1d50fdbb1548691064f688 100644 (file)
@@ -263,7 +263,7 @@ nlmsvc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp,
  */
 static void nlmsvc_callback_exit(struct rpc_task *task, void *data)
 {
-       dprintk("lockd: %4d callback returned %d\n", task->tk_pid,
+       dprintk("lockd: %5u callback returned %d\n", task->tk_pid,
                        -task->tk_status);
 }
 
index e83024e16042b57c9c13fc8d64f15573b7168416..c0df00c74ce38b9ac77f7c9e85bfc6d119f367c1 100644 (file)
@@ -43,7 +43,7 @@ static inline void nlm_debug_print_fh(char *msg, struct nfs_fh *f)
 
 static inline void nlm_debug_print_file(char *msg, struct nlm_file *file)
 {
-       struct inode *inode = file->f_file->f_dentry->d_inode;
+       struct inode *inode = file->f_file->f_path.dentry->d_inode;
 
        dprintk("lockd: %s %s/%ld\n",
                msg, inode->i_sb->s_id, inode->i_ino);
index e0b6a80649a01ff79c26206c039ece3d4faebd0c..52a81005dab4b8878bba2a3f1586bc346890cc5b 100644 (file)
@@ -142,12 +142,12 @@ int lease_break_time = 45;
 static LIST_HEAD(file_lock_list);
 static LIST_HEAD(blocked_list);
 
-static kmem_cache_t *filelock_cache __read_mostly;
+static struct kmem_cache *filelock_cache __read_mostly;
 
 /* Allocate an empty lock structure. */
 static struct file_lock *locks_alloc_lock(void)
 {
-       return kmem_cache_alloc(filelock_cache, SLAB_KERNEL);
+       return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
 }
 
 static void locks_release_private(struct file_lock *fl)
@@ -199,7 +199,7 @@ EXPORT_SYMBOL(locks_init_lock);
  * Initialises the fields of the file lock which are invariant for
  * free file_locks.
  */
-static void init_once(void *foo, kmem_cache_t *cache, unsigned long flags)
+static void init_once(void *foo, struct kmem_cache *cache, unsigned long flags)
 {
        struct file_lock *lock = (struct file_lock *) foo;
 
@@ -321,7 +321,7 @@ static int flock_to_posix_lock(struct file *filp, struct file_lock *fl,
                start = filp->f_pos;
                break;
        case SEEK_END:
-               start = i_size_read(filp->f_dentry->d_inode);
+               start = i_size_read(filp->f_path.dentry->d_inode);
                break;
        default:
                return -EINVAL;
@@ -371,7 +371,7 @@ static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl,
                start = filp->f_pos;
                break;
        case SEEK_END:
-               start = i_size_read(filp->f_dentry->d_inode);
+               start = i_size_read(filp->f_path.dentry->d_inode);
                break;
        default:
                return -EINVAL;
@@ -672,7 +672,7 @@ posix_test_lock(struct file *filp, struct file_lock *fl,
        struct file_lock *cfl;
 
        lock_kernel();
-       for (cfl = filp->f_dentry->d_inode->i_flock; cfl; cfl = cfl->fl_next) {
+       for (cfl = filp->f_path.dentry->d_inode->i_flock; cfl; cfl = cfl->fl_next) {
                if (!IS_POSIX(cfl))
                        continue;
                if (posix_locks_conflict(cfl, fl))
@@ -734,7 +734,7 @@ static int flock_lock_file(struct file *filp, struct file_lock *request)
 {
        struct file_lock *new_fl = NULL;
        struct file_lock **before;
-       struct inode * inode = filp->f_dentry->d_inode;
+       struct inode * inode = filp->f_path.dentry->d_inode;
        int error = 0;
        int found = 0;
 
@@ -1018,7 +1018,7 @@ static int __posix_lock_file_conf(struct inode *inode, struct file_lock *request
  */
 int posix_lock_file(struct file *filp, struct file_lock *fl)
 {
-       return __posix_lock_file_conf(filp->f_dentry->d_inode, fl, NULL);
+       return __posix_lock_file_conf(filp->f_path.dentry->d_inode, fl, NULL);
 }
 EXPORT_SYMBOL(posix_lock_file);
 
@@ -1033,7 +1033,7 @@ EXPORT_SYMBOL(posix_lock_file);
 int posix_lock_file_conf(struct file *filp, struct file_lock *fl,
                        struct file_lock *conflock)
 {
-       return __posix_lock_file_conf(filp->f_dentry->d_inode, fl, conflock);
+       return __posix_lock_file_conf(filp->f_path.dentry->d_inode, fl, conflock);
 }
 EXPORT_SYMBOL(posix_lock_file_conf);
 
@@ -1333,8 +1333,8 @@ int fcntl_getlease(struct file *filp)
        int type = F_UNLCK;
 
        lock_kernel();
-       time_out_leases(filp->f_dentry->d_inode);
-       for (fl = filp->f_dentry->d_inode->i_flock; fl && IS_LEASE(fl);
+       time_out_leases(filp->f_path.dentry->d_inode);
+       for (fl = filp->f_path.dentry->d_inode->i_flock; fl && IS_LEASE(fl);
                        fl = fl->fl_next) {
                if (fl->fl_file == filp) {
                        type = fl->fl_type & ~F_INPROGRESS;
@@ -1359,7 +1359,7 @@ int fcntl_getlease(struct file *filp)
 static int __setlease(struct file *filp, long arg, struct file_lock **flp)
 {
        struct file_lock *fl, **before, **my_before = NULL, *lease;
-       struct dentry *dentry = filp->f_dentry;
+       struct dentry *dentry = filp->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        int error, rdlease_count = 0, wrlease_count = 0;
 
@@ -1448,7 +1448,7 @@ out:
 
 int setlease(struct file *filp, long arg, struct file_lock **lease)
 {
-       struct dentry *dentry = filp->f_dentry;
+       struct dentry *dentry = filp->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        int error;
 
@@ -1482,7 +1482,7 @@ EXPORT_SYMBOL(setlease);
 int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
 {
        struct file_lock fl, *flp = &fl;
-       struct dentry *dentry = filp->f_dentry;
+       struct dentry *dentry = filp->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        int error;
 
@@ -1692,7 +1692,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
        if (copy_from_user(&flock, l, sizeof(flock)))
                goto out;
 
-       inode = filp->f_dentry->d_inode;
+       inode = filp->f_path.dentry->d_inode;
 
        /* Don't allow mandatory locks on files that may be memory mapped
         * and shared.
@@ -1835,7 +1835,7 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
        if (copy_from_user(&flock, l, sizeof(flock)))
                goto out;
 
-       inode = filp->f_dentry->d_inode;
+       inode = filp->f_path.dentry->d_inode;
 
        /* Don't allow mandatory locks on files that may be memory mapped
         * and shared.
@@ -1922,7 +1922,7 @@ void locks_remove_posix(struct file *filp, fl_owner_t owner)
         * posix_lock_file().  Another process could be setting a lock on this
         * file at the same time, but we wouldn't remove that lock anyway.
         */
-       if (!filp->f_dentry->d_inode->i_flock)
+       if (!filp->f_path.dentry->d_inode->i_flock)
                return;
 
        lock.fl_type = F_UNLCK;
@@ -1951,7 +1951,7 @@ EXPORT_SYMBOL(locks_remove_posix);
  */
 void locks_remove_flock(struct file *filp)
 {
-       struct inode * inode = filp->f_dentry->d_inode; 
+       struct inode * inode = filp->f_path.dentry->d_inode;
        struct file_lock *fl;
        struct file_lock **before;
 
@@ -2020,7 +2020,7 @@ static void lock_get_status(char* out, struct file_lock *fl, int id, char *pfx)
        struct inode *inode = NULL;
 
        if (fl->fl_file != NULL)
-               inode = fl->fl_file->f_dentry->d_inode;
+               inode = fl->fl_file->f_path.dentry->d_inode;
 
        out += sprintf(out, "%d:%s ", id, pfx);
        if (IS_POSIX(fl)) {
index 0ff71256e65b4fb0d3a9fc4352c0a8c9b4b5e365..deeb9dc062d9dfdc74676734163e8c273f6aa274 100644 (file)
@@ -85,7 +85,7 @@ struct mb_cache {
 #ifndef MB_CACHE_INDEXES_COUNT
        int                             c_indexes_count;
 #endif
-       kmem_cache_t                    *c_entry_cache;
+       struct kmem_cache                       *c_entry_cache;
        struct list_head                *c_block_hash;
        struct list_head                *c_indexes_hash[0];
 };
index 2b0a389d19874765585f3565102005f6facdc470..ab782c4086f5b0c5833780f186634ace32f8439f 100644 (file)
@@ -82,7 +82,7 @@ static inline void *minix_next_entry(void *de, struct minix_sb_info *sbi)
 static int minix_readdir(struct file * filp, void * dirent, filldir_t filldir)
 {
        unsigned long pos = filp->f_pos;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct super_block *sb = inode->i_sb;
        unsigned offset = pos & ~PAGE_CACHE_MASK;
        unsigned long n = pos >> PAGE_CACHE_SHIFT;
index 1e36bae4d0eb1a4d8a8b17140c3216fad2d5c81b..629e09b38c5cf67b23a4fe1eee0190616f44ccb6 100644 (file)
@@ -51,12 +51,12 @@ static void minix_put_super(struct super_block *sb)
        return;
 }
 
-static kmem_cache_t * minix_inode_cachep;
+static struct kmem_cache * minix_inode_cachep;
 
 static struct inode *minix_alloc_inode(struct super_block *sb)
 {
        struct minix_inode_info *ei;
-       ei = (struct minix_inode_info *)kmem_cache_alloc(minix_inode_cachep, SLAB_KERNEL);
+       ei = (struct minix_inode_info *)kmem_cache_alloc(minix_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        return &ei->vfs_inode;
@@ -67,7 +67,7 @@ static void minix_destroy_inode(struct inode *inode)
        kmem_cache_free(minix_inode_cachep, minix_i(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct minix_inode_info *ei = (struct minix_inode_info *) foo;
 
index 28d49b301d5516bbdfb5bf7651f3c51b8f370f31..e4f108f082303c99023c3b950e8f8f3202551a4c 100644 (file)
@@ -249,9 +249,11 @@ int permission(struct inode *inode, int mask, struct nameidata *nd)
 
        /*
         * MAY_EXEC on regular files requires special handling: We override
-        * filesystem execute permissions if the mode bits aren't set.
+        * filesystem execute permissions if the mode bits aren't set or
+        * the fs is mounted with the "noexec" flag.
         */
-       if ((mask & MAY_EXEC) && S_ISREG(mode) && !(mode & S_IXUGO))
+       if ((mask & MAY_EXEC) && S_ISREG(mode) && (!(mode & S_IXUGO) ||
+                       (nd && nd->mnt && (nd->mnt->mnt_flags & MNT_NOEXEC))))
                return -EACCES;
 
        /* Ordinary permission routines do not understand MAY_APPEND. */
@@ -295,7 +297,7 @@ int vfs_permission(struct nameidata *nd, int mask)
  */
 int file_permission(struct file *file, int mask)
 {
-       return permission(file->f_dentry->d_inode, mask, NULL);
+       return permission(file->f_path.dentry->d_inode, mask, NULL);
 }
 
 /*
@@ -331,7 +333,7 @@ int get_write_access(struct inode * inode)
 
 int deny_write_access(struct file * file)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
 
        spin_lock(&inode->i_lock);
        if (atomic_read(&inode->i_writecount) > 0) {
@@ -366,7 +368,7 @@ void path_release_on_umount(struct nameidata *nd)
  */
 void release_open_intent(struct nameidata *nd)
 {
-       if (nd->intent.open.file->f_dentry == NULL)
+       if (nd->intent.open.file->f_path.dentry == NULL)
                put_filp(nd->intent.open.file);
        else
                fput(nd->intent.open.file);
@@ -570,11 +572,6 @@ fail:
        return PTR_ERR(link);
 }
 
-struct path {
-       struct vfsmount *mnt;
-       struct dentry *dentry;
-};
-
 static inline void dput_path(struct path *path, struct nameidata *nd)
 {
        dput(path->dentry);
@@ -1141,7 +1138,7 @@ static int fastcall do_path_lookup(int dfd, const char *name,
                if (!file)
                        goto out_fail;
 
-               dentry = file->f_dentry;
+               dentry = file->f_path.dentry;
 
                retval = -ENOTDIR;
                if (!S_ISDIR(dentry->d_inode->i_mode))
@@ -1151,7 +1148,7 @@ static int fastcall do_path_lookup(int dfd, const char *name,
                if (retval)
                        goto fput_fail;
 
-               nd->mnt = mntget(file->f_vfsmnt);
+               nd->mnt = mntget(file->f_path.mnt);
                nd->dentry = dget(dentry);
 
                fput_light(file, fput_needed);
@@ -1996,8 +1993,7 @@ asmlinkage long sys_mkdir(const char __user *pathname, int mode)
 void dentry_unhash(struct dentry *dentry)
 {
        dget(dentry);
-       if (atomic_read(&dentry->d_count))
-               shrink_dcache_parent(dentry);
+       shrink_dcache_parent(dentry);
        spin_lock(&dcache_lock);
        spin_lock(&dentry->d_lock);
        if (atomic_read(&dentry->d_count) == 2)
index 55442a6cf22133d2c9687636b3e3ca788eacac53..fde8553faa7661677e2210d65620b753eceddaf8 100644 (file)
@@ -20,7 +20,7 @@
 #include <linux/module.h>
 #include <linux/sysfs.h>
 #include <linux/seq_file.h>
-#include <linux/namespace.h>
+#include <linux/mnt_namespace.h>
 #include <linux/namei.h>
 #include <linux/security.h>
 #include <linux/mount.h>
@@ -36,7 +36,7 @@ static int event;
 
 static struct list_head *mount_hashtable __read_mostly;
 static int hash_mask __read_mostly, hash_bits __read_mostly;
-static kmem_cache_t *mnt_cache __read_mostly;
+static struct kmem_cache *mnt_cache __read_mostly;
 static struct rw_semaphore namespace_sem;
 
 /* /sys/fs */
@@ -133,10 +133,10 @@ struct vfsmount *lookup_mnt(struct vfsmount *mnt, struct dentry *dentry)
 
 static inline int check_mnt(struct vfsmount *mnt)
 {
-       return mnt->mnt_namespace == current->nsproxy->namespace;
+       return mnt->mnt_ns == current->nsproxy->mnt_ns;
 }
 
-static void touch_namespace(struct namespace *ns)
+static void touch_mnt_namespace(struct mnt_namespace *ns)
 {
        if (ns) {
                ns->event = ++event;
@@ -144,7 +144,7 @@ static void touch_namespace(struct namespace *ns)
        }
 }
 
-static void __touch_namespace(struct namespace *ns)
+static void __touch_mnt_namespace(struct mnt_namespace *ns)
 {
        if (ns && ns->event != event) {
                ns->event = event;
@@ -187,19 +187,19 @@ static void commit_tree(struct vfsmount *mnt)
        struct vfsmount *parent = mnt->mnt_parent;
        struct vfsmount *m;
        LIST_HEAD(head);
-       struct namespace *n = parent->mnt_namespace;
+       struct mnt_namespace *n = parent->mnt_ns;
 
        BUG_ON(parent == mnt);
 
        list_add_tail(&head, &mnt->mnt_list);
        list_for_each_entry(m, &head, mnt_list)
-               m->mnt_namespace = n;
+               m->mnt_ns = n;
        list_splice(&head, n->list.prev);
 
        list_add_tail(&mnt->mnt_hash, mount_hashtable +
                                hash(parent, mnt->mnt_mountpoint));
        list_add_tail(&mnt->mnt_child, &parent->mnt_mounts);
-       touch_namespace(n);
+       touch_mnt_namespace(n);
 }
 
 static struct vfsmount *next_mnt(struct vfsmount *p, struct vfsmount *root)
@@ -320,7 +320,7 @@ EXPORT_SYMBOL(mnt_unpin);
 /* iterator */
 static void *m_start(struct seq_file *m, loff_t *pos)
 {
-       struct namespace *n = m->private;
+       struct mnt_namespace *n = m->private;
        struct list_head *p;
        loff_t l = *pos;
 
@@ -333,7 +333,7 @@ static void *m_start(struct seq_file *m, loff_t *pos)
 
 static void *m_next(struct seq_file *m, void *v, loff_t *pos)
 {
-       struct namespace *n = m->private;
+       struct mnt_namespace *n = m->private;
        struct list_head *p = ((struct vfsmount *)v)->mnt_list.next;
        (*pos)++;
        return p == &n->list ? NULL : list_entry(p, struct vfsmount, mnt_list);
@@ -526,8 +526,8 @@ void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill)
        list_for_each_entry(p, kill, mnt_hash) {
                list_del_init(&p->mnt_expire);
                list_del_init(&p->mnt_list);
-               __touch_namespace(p->mnt_namespace);
-               p->mnt_namespace = NULL;
+               __touch_mnt_namespace(p->mnt_ns);
+               p->mnt_ns = NULL;
                list_del_init(&p->mnt_child);
                if (p->mnt_parent != p)
                        p->mnt_mountpoint->d_mounted--;
@@ -830,7 +830,7 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt,
        if (parent_nd) {
                detach_mnt(source_mnt, parent_nd);
                attach_mnt(source_mnt, nd);
-               touch_namespace(current->nsproxy->namespace);
+               touch_mnt_namespace(current->nsproxy->mnt_ns);
        } else {
                mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt);
                commit_tree(source_mnt);
@@ -1145,9 +1145,9 @@ static void expire_mount(struct vfsmount *mnt, struct list_head *mounts,
         */
        if (!propagate_mount_busy(mnt, 2)) {
                /* delete from the namespace */
-               touch_namespace(mnt->mnt_namespace);
+               touch_mnt_namespace(mnt->mnt_ns);
                list_del_init(&mnt->mnt_list);
-               mnt->mnt_namespace = NULL;
+               mnt->mnt_ns = NULL;
                umount_tree(mnt, 1, umounts);
                spin_unlock(&vfsmount_lock);
        } else {
@@ -1168,7 +1168,7 @@ static void expire_mount(struct vfsmount *mnt, struct list_head *mounts,
  */
 static void expire_mount_list(struct list_head *graveyard, struct list_head *mounts)
 {
-       struct namespace *namespace;
+       struct mnt_namespace *ns;
        struct vfsmount *mnt;
 
        while (!list_empty(graveyard)) {
@@ -1178,10 +1178,10 @@ static void expire_mount_list(struct list_head *graveyard, struct list_head *mou
 
                /* don't do anything if the namespace is dead - all the
                 * vfsmounts from it are going away anyway */
-               namespace = mnt->mnt_namespace;
-               if (!namespace || !namespace->root)
+               ns = mnt->mnt_ns;
+               if (!ns || !ns->root)
                        continue;
-               get_namespace(namespace);
+               get_mnt_ns(ns);
 
                spin_unlock(&vfsmount_lock);
                down_write(&namespace_sem);
@@ -1189,7 +1189,7 @@ static void expire_mount_list(struct list_head *graveyard, struct list_head *mou
                up_write(&namespace_sem);
                release_mounts(&umounts);
                mntput(mnt);
-               put_namespace(namespace);
+               put_mnt_ns(ns);
                spin_lock(&vfsmount_lock);
        }
 }
@@ -1439,14 +1439,15 @@ dput_out:
  * Allocate a new namespace structure and populate it with contents
  * copied from the namespace of the passed in task structure.
  */
-struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs)
+struct mnt_namespace *dup_mnt_ns(struct task_struct *tsk,
+               struct fs_struct *fs)
 {
-       struct namespace *namespace = tsk->nsproxy->namespace;
-       struct namespace *new_ns;
+       struct mnt_namespace *mnt_ns = tsk->nsproxy->mnt_ns;
+       struct mnt_namespace *new_ns;
        struct vfsmount *rootmnt = NULL, *pwdmnt = NULL, *altrootmnt = NULL;
        struct vfsmount *p, *q;
 
-       new_ns = kmalloc(sizeof(struct namespace), GFP_KERNEL);
+       new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL);
        if (!new_ns)
                return NULL;
 
@@ -1457,7 +1458,7 @@ struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs)
 
        down_write(&namespace_sem);
        /* First pass: copy the tree topology */
-       new_ns->root = copy_tree(namespace->root, namespace->root->mnt_root,
+       new_ns->root = copy_tree(mnt_ns->root, mnt_ns->root->mnt_root,
                                        CL_COPY_ALL | CL_EXPIRE);
        if (!new_ns->root) {
                up_write(&namespace_sem);
@@ -1473,10 +1474,10 @@ struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs)
         * as belonging to new namespace.  We have already acquired a private
         * fs_struct, so tsk->fs->lock is not needed.
         */
-       p = namespace->root;
+       p = mnt_ns->root;
        q = new_ns->root;
        while (p) {
-               q->mnt_namespace = new_ns;
+               q->mnt_ns = new_ns;
                if (fs) {
                        if (p == fs->rootmnt) {
                                rootmnt = p;
@@ -1491,7 +1492,7 @@ struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs)
                                fs->altrootmnt = mntget(q);
                        }
                }
-               p = next_mnt(p, namespace->root);
+               p = next_mnt(p, mnt_ns->root);
                q = next_mnt(q, new_ns->root);
        }
        up_write(&namespace_sem);
@@ -1506,16 +1507,16 @@ struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs)
        return new_ns;
 }
 
-int copy_namespace(int flags, struct task_struct *tsk)
+int copy_mnt_ns(int flags, struct task_struct *tsk)
 {
-       struct namespace *namespace = tsk->nsproxy->namespace;
-       struct namespace *new_ns;
+       struct mnt_namespace *ns = tsk->nsproxy->mnt_ns;
+       struct mnt_namespace *new_ns;
        int err = 0;
 
-       if (!namespace)
+       if (!ns)
                return 0;
 
-       get_namespace(namespace);
+       get_mnt_ns(ns);
 
        if (!(flags & CLONE_NEWNS))
                return 0;
@@ -1525,16 +1526,16 @@ int copy_namespace(int flags, struct task_struct *tsk)
                goto out;
        }
 
-       new_ns = dup_namespace(tsk, tsk->fs);
+       new_ns = dup_mnt_ns(tsk, tsk->fs);
        if (!new_ns) {
                err = -ENOMEM;
                goto out;
        }
 
-       tsk->nsproxy->namespace = new_ns;
+       tsk->nsproxy->mnt_ns = new_ns;
 
 out:
-       put_namespace(namespace);
+       put_mnt_ns(ns);
        return err;
 }
 
@@ -1754,7 +1755,7 @@ asmlinkage long sys_pivot_root(const char __user * new_root,
        detach_mnt(user_nd.mnt, &root_parent);
        attach_mnt(user_nd.mnt, &old_nd);     /* mount old root on put_old */
        attach_mnt(new_nd.mnt, &root_parent); /* mount new_root on / */
-       touch_namespace(current->nsproxy->namespace);
+       touch_mnt_namespace(current->nsproxy->mnt_ns);
        spin_unlock(&vfsmount_lock);
        chroot_fs_refs(&user_nd, &new_nd);
        security_sb_post_pivotroot(&user_nd, &new_nd);
@@ -1779,27 +1780,27 @@ out3:
 static void __init init_mount_tree(void)
 {
        struct vfsmount *mnt;
-       struct namespace *namespace;
+       struct mnt_namespace *ns;
 
        mnt = do_kern_mount("rootfs", 0, "rootfs", NULL);
        if (IS_ERR(mnt))
                panic("Can't create rootfs");
-       namespace = kmalloc(sizeof(*namespace), GFP_KERNEL);
-       if (!namespace)
+       ns = kmalloc(sizeof(*ns), GFP_KERNEL);
+       if (!ns)
                panic("Can't allocate initial namespace");
-       atomic_set(&namespace->count, 1);
-       INIT_LIST_HEAD(&namespace->list);
-       init_waitqueue_head(&namespace->poll);
-       namespace->event = 0;
-       list_add(&mnt->mnt_list, &namespace->list);
-       namespace->root = mnt;
-       mnt->mnt_namespace = namespace;
-
-       init_task.nsproxy->namespace = namespace;
-       get_namespace(namespace);
-
-       set_fs_pwd(current->fs, namespace->root, namespace->root->mnt_root);
-       set_fs_root(current->fs, namespace->root, namespace->root->mnt_root);
+       atomic_set(&ns->count, 1);
+       INIT_LIST_HEAD(&ns->list);
+       init_waitqueue_head(&ns->poll);
+       ns->event = 0;
+       list_add(&mnt->mnt_list, &ns->list);
+       ns->root = mnt;
+       mnt->mnt_ns = ns;
+
+       init_task.nsproxy->mnt_ns = ns;
+       get_mnt_ns(ns);
+
+       set_fs_pwd(current->fs, ns->root, ns->root->mnt_root);
+       set_fs_root(current->fs, ns->root, ns->root->mnt_root);
 }
 
 void __init mnt_init(unsigned long mempages)
@@ -1860,11 +1861,11 @@ void __init mnt_init(unsigned long mempages)
        init_mount_tree();
 }
 
-void __put_namespace(struct namespace *namespace)
+void __put_mnt_ns(struct mnt_namespace *ns)
 {
-       struct vfsmount *root = namespace->root;
+       struct vfsmount *root = ns->root;
        LIST_HEAD(umount_list);
-       namespace->root = NULL;
+       ns->root = NULL;
        spin_unlock(&vfsmount_lock);
        down_write(&namespace_sem);
        spin_lock(&vfsmount_lock);
@@ -1872,5 +1873,5 @@ void __put_namespace(struct namespace *namespace)
        spin_unlock(&vfsmount_lock);
        up_write(&namespace_sem);
        release_mounts(&umount_list);
-       kfree(namespace);
+       kfree(ns);
 }
index 458b3b785194e815a0081ed3dcd3cf2e116a6172..73747772c3bb23434ea8bdc2cb4a9630fffea3f2 100644 (file)
@@ -402,7 +402,7 @@ static time_t ncp_obtain_mtime(struct dentry *dentry)
 
 static int ncp_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct dentry *dentry = filp->f_dentry;
+       struct dentry *dentry = filp->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        struct page *page = NULL;
        struct ncp_server *server = NCP_SERVER(inode);
@@ -554,7 +554,7 @@ static int
 ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
                struct ncp_cache_control *ctrl, struct ncp_entry_info *entry)
 {
-       struct dentry *newdent, *dentry = filp->f_dentry;
+       struct dentry *newdent, *dentry = filp->f_path.dentry;
        struct inode *newino, *inode = dentry->d_inode;
        struct ncp_cache_control ctl = *ctrl;
        struct qstr qname;
@@ -649,7 +649,7 @@ static void
 ncp_read_volume_list(struct file *filp, void *dirent, filldir_t filldir,
                        struct ncp_cache_control *ctl)
 {
-       struct dentry *dentry = filp->f_dentry;
+       struct dentry *dentry = filp->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        struct ncp_server *server = NCP_SERVER(inode);
        struct ncp_volume_info info;
@@ -685,7 +685,7 @@ static void
 ncp_do_readdir(struct file *filp, void *dirent, filldir_t filldir,
                                                struct ncp_cache_control *ctl)
 {
-       struct dentry *dentry = filp->f_dentry;
+       struct dentry *dentry = filp->f_path.dentry;
        struct inode *dir = dentry->d_inode;
        struct ncp_server *server = NCP_SERVER(dir);
        struct nw_search_sequence seq;
index df37524b85db0a69f823935bdf666cda214f48e8..b91fea03b1c3e9d0cd50c9eee699c543b0ff6095 100644 (file)
@@ -101,7 +101,7 @@ out:
 static ssize_t
 ncp_file_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 {
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        size_t already_read = 0;
        off_t pos;
@@ -182,7 +182,7 @@ outrel:
 static ssize_t
 ncp_file_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 {
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        size_t already_written = 0;
        off_t pos;
index 72dad552aa001897d5d3d6ab03ed236a9cad0e59..47462ac94474984a2f05b7aa1517e06c6d68b266 100644 (file)
@@ -40,12 +40,12 @@ static void ncp_delete_inode(struct inode *);
 static void ncp_put_super(struct super_block *);
 static int  ncp_statfs(struct dentry *, struct kstatfs *);
 
-static kmem_cache_t * ncp_inode_cachep;
+static struct kmem_cache * ncp_inode_cachep;
 
 static struct inode *ncp_alloc_inode(struct super_block *sb)
 {
        struct ncp_inode_info *ei;
-       ei = (struct ncp_inode_info *)kmem_cache_alloc(ncp_inode_cachep, SLAB_KERNEL);
+       ei = (struct ncp_inode_info *)kmem_cache_alloc(ncp_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        return &ei->vfs_inode;
@@ -56,7 +56,7 @@ static void ncp_destroy_inode(struct inode *inode)
        kmem_cache_free(ncp_inode_cachep, NCP_FINFO(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct ncp_inode_info *ei = (struct ncp_inode_info *) foo;
 
@@ -471,7 +471,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
        if (!ncp_filp)
                goto out;
        error = -ENOTSOCK;
-       sock_inode = ncp_filp->f_dentry->d_inode;
+       sock_inode = ncp_filp->f_path.dentry->d_inode;
        if (!S_ISSOCK(sock_inode->i_mode))
                goto out_fput;
        sock = SOCKET_I(sock_inode);
@@ -504,7 +504,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
                if (!server->info_filp)
                        goto out_fput;
                error = -ENOTSOCK;
-               sock_inode = server->info_filp->f_dentry->d_inode;
+               sock_inode = server->info_filp->f_path.dentry->d_inode;
                if (!S_ISSOCK(sock_inode->i_mode))
                        goto out_fput2;
                info_sock = SOCKET_I(sock_inode);
index 589d1eac55c1c97499d8b1a13626dde1b869f3f5..8843a83d4ef03dc4242dd11646c78480736375cb 100644 (file)
@@ -35,7 +35,7 @@ static int
 ncp_get_fs_info(struct ncp_server * server, struct file *file,
                struct ncp_fs_info __user *arg)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct ncp_fs_info info;
 
        if ((file_permission(file, MAY_WRITE) != 0)
@@ -65,7 +65,7 @@ static int
 ncp_get_fs_info_v2(struct ncp_server * server, struct file *file,
                   struct ncp_fs_info_v2 __user * arg)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct ncp_fs_info_v2 info2;
 
        if ((file_permission(file, MAY_WRITE) != 0)
@@ -136,7 +136,7 @@ static int
 ncp_get_compat_fs_info_v2(struct ncp_server * server, struct file *file,
                   struct compat_ncp_fs_info_v2 __user * arg)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct compat_ncp_fs_info_v2 info2;
 
        if ((file_permission(file, MAY_WRITE) != 0)
@@ -824,7 +824,7 @@ outrel:
 #ifdef CONFIG_COMPAT
 long ncp_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int ret;
 
        lock_kernel();
index e7d5a3097fe60d2ff05dc4d0a1fc28ba9683d867..70a69115500f1603b589fb3d65e72acc5eb771db 100644 (file)
@@ -29,7 +29,7 @@ static struct page* ncp_file_mmap_nopage(struct vm_area_struct *area,
                                     unsigned long address, int *type)
 {
        struct file *file = area->vm_file;
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        struct page* page;
        char *pg_addr;
@@ -106,7 +106,7 @@ static struct vm_operations_struct ncp_file_mmap =
 /* This is used for a general mmap of a ncp file */
 int ncp_mmap(struct file *file, struct vm_area_struct *vma)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        
        DPRINTK("ncp_mmap: called\n");
 
index b34cd16f472fef71c798c0470f98cbb33f6ea10c..dee3d6c0f194178c6a1c060ff2eb1121a1d7d5aa 100644 (file)
@@ -172,7 +172,7 @@ static
 int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
 {
        struct file     *file = desc->file;
-       struct inode    *inode = file->f_dentry->d_inode;
+       struct inode    *inode = file->f_path.dentry->d_inode;
        struct rpc_cred *cred = nfs_file_cred(file);
        unsigned long   timestamp;
        int             error;
@@ -183,7 +183,7 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
 
  again:
        timestamp = jiffies;
-       error = NFS_PROTO(inode)->readdir(file->f_dentry, cred, desc->entry->cookie, page,
+       error = NFS_PROTO(inode)->readdir(file->f_path.dentry, cred, desc->entry->cookie, page,
                                          NFS_SERVER(inode)->dtsize, desc->plus);
        if (error < 0) {
                /* We requested READDIRPLUS, but the server doesn't grok it */
@@ -308,7 +308,7 @@ int find_dirent_index(nfs_readdir_descriptor_t *desc)
 static inline
 int find_dirent_page(nfs_readdir_descriptor_t *desc)
 {
-       struct inode    *inode = desc->file->f_dentry->d_inode;
+       struct inode    *inode = desc->file->f_path.dentry->d_inode;
        struct page     *page;
        int             status;
 
@@ -464,7 +464,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
                     filldir_t filldir)
 {
        struct file     *file = desc->file;
-       struct inode    *inode = file->f_dentry->d_inode;
+       struct inode    *inode = file->f_path.dentry->d_inode;
        struct rpc_cred *cred = nfs_file_cred(file);
        struct page     *page = NULL;
        int             status;
@@ -477,7 +477,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
                status = -ENOMEM;
                goto out;
        }
-       desc->error = NFS_PROTO(inode)->readdir(file->f_dentry, cred, *desc->dir_cookie,
+       desc->error = NFS_PROTO(inode)->readdir(file->f_path.dentry, cred, *desc->dir_cookie,
                                                page,
                                                NFS_SERVER(inode)->dtsize,
                                                desc->plus);
@@ -516,7 +516,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
  */
 static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct dentry   *dentry = filp->f_dentry;
+       struct dentry   *dentry = filp->f_path.dentry;
        struct inode    *inode = dentry->d_inode;
        nfs_readdir_descriptor_t my_desc,
                        *desc = &my_desc;
@@ -599,7 +599,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 
 loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin)
 {
-       mutex_lock(&filp->f_dentry->d_inode->i_mutex);
+       mutex_lock(&filp->f_path.dentry->d_inode->i_mutex);
        switch (origin) {
                case 1:
                        offset += filp->f_pos;
@@ -615,7 +615,7 @@ loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin)
                ((struct nfs_open_context *)filp->private_data)->dir_cookie = 0;
        }
 out:
-       mutex_unlock(&filp->f_dentry->d_inode->i_mutex);
+       mutex_unlock(&filp->f_path.dentry->d_inode->i_mutex);
        return offset;
 }
 
@@ -1102,7 +1102,7 @@ no_open:
 
 static struct dentry *nfs_readdir_lookup(nfs_readdir_descriptor_t *desc)
 {
-       struct dentry *parent = desc->file->f_dentry;
+       struct dentry *parent = desc->file->f_path.dentry;
        struct inode *dir = parent->d_inode;
        struct nfs_entry *entry = desc->entry;
        struct dentry *dentry, *alias;
index bdfabf854a519af44ae5f07e83ee64e3e0089c6a..bd21d7fde650a57722e8afbda83402d352b8e07a 100644 (file)
@@ -58,7 +58,7 @@
 
 #define NFSDBG_FACILITY                NFSDBG_VFS
 
-static kmem_cache_t *nfs_direct_cachep;
+static struct kmem_cache *nfs_direct_cachep;
 
 /*
  * This represents a set of asynchronous requests that we're waiting on
@@ -116,7 +116,7 @@ static inline int put_dreq(struct nfs_direct_req *dreq)
 ssize_t nfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, loff_t pos, unsigned long nr_segs)
 {
        dprintk("NFS: nfs_direct_IO (%s) off/no(%Ld/%lu) EINVAL\n",
-                       iocb->ki_filp->f_dentry->d_name.name,
+                       iocb->ki_filp->f_path.dentry->d_name.name,
                        (long long) pos, nr_segs);
 
        return -EINVAL;
@@ -143,7 +143,7 @@ static inline struct nfs_direct_req *nfs_direct_req_alloc(void)
 {
        struct nfs_direct_req *dreq;
 
-       dreq = kmem_cache_alloc(nfs_direct_cachep, SLAB_KERNEL);
+       dreq = kmem_cache_alloc(nfs_direct_cachep, GFP_KERNEL);
        if (!dreq)
                return NULL;
 
@@ -307,9 +307,7 @@ static ssize_t nfs_direct_read_schedule(struct nfs_direct_req *dreq, unsigned lo
 
                data->task.tk_cookie = (unsigned long) inode;
 
-               lock_kernel();
                rpc_execute(&data->task);
-               unlock_kernel();
 
                dfprintk(VFS, "NFS: %5u initiated direct read call (req %s/%Ld, %zu bytes @ offset %Lu)\n",
                                data->task.tk_pid,
@@ -475,9 +473,7 @@ static void nfs_direct_commit_schedule(struct nfs_direct_req *dreq)
 
        dprintk("NFS: %5u initiated commit call\n", data->task.tk_pid);
 
-       lock_kernel();
        rpc_execute(&data->task);
-       unlock_kernel();
 }
 
 static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode *inode)
@@ -641,9 +637,7 @@ static ssize_t nfs_direct_write_schedule(struct nfs_direct_req *dreq, unsigned l
                data->task.tk_priority = RPC_PRIORITY_NORMAL;
                data->task.tk_cookie = (unsigned long) inode;
 
-               lock_kernel();
                rpc_execute(&data->task);
-               unlock_kernel();
 
                dfprintk(VFS, "NFS: %5u initiated direct write call (req %s/%Ld, %zu bytes @ offset %Lu)\n",
                                data->task.tk_pid,
@@ -740,8 +734,8 @@ ssize_t nfs_file_direct_read(struct kiocb *iocb, const struct iovec *iov,
        size_t count = iov[0].iov_len;
 
        dprintk("nfs: direct read(%s/%s, %lu@%Ld)\n",
-               file->f_dentry->d_parent->d_name.name,
-               file->f_dentry->d_name.name,
+               file->f_path.dentry->d_parent->d_name.name,
+               file->f_path.dentry->d_name.name,
                (unsigned long) count, (long long) pos);
 
        if (nr_segs != 1)
@@ -804,8 +798,8 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, const struct iovec *iov,
        size_t count = iov[0].iov_len;
 
        dfprintk(VFS, "nfs: direct write(%s/%s, %lu@%Ld)\n",
-               file->f_dentry->d_parent->d_name.name,
-               file->f_dentry->d_name.name,
+               file->f_path.dentry->d_parent->d_name.name,
+               file->f_path.dentry->d_name.name,
                (unsigned long) count, (long long) pos);
 
        if (nr_segs != 1)
index cc93865cea932a4e9c78ea95e1c0165e575630d1..0dd6be346aa740051f9730785053c5f6d41b229b 100644 (file)
@@ -176,7 +176,7 @@ static int
 nfs_file_flush(struct file *file, fl_owner_t id)
 {
        struct nfs_open_context *ctx = (struct nfs_open_context *)file->private_data;
-       struct inode    *inode = file->f_dentry->d_inode;
+       struct inode    *inode = file->f_path.dentry->d_inode;
        int             status;
 
        dfprintk(VFS, "nfs: flush(%s/%ld)\n", inode->i_sb->s_id, inode->i_ino);
@@ -201,7 +201,7 @@ static ssize_t
 nfs_file_read(struct kiocb *iocb, const struct iovec *iov,
                unsigned long nr_segs, loff_t pos)
 {
-       struct dentry * dentry = iocb->ki_filp->f_dentry;
+       struct dentry * dentry = iocb->ki_filp->f_path.dentry;
        struct inode * inode = dentry->d_inode;
        ssize_t result;
        size_t count = iov_length(iov, nr_segs);
@@ -226,7 +226,7 @@ static ssize_t
 nfs_file_sendfile(struct file *filp, loff_t *ppos, size_t count,
                read_actor_t actor, void *target)
 {
-       struct dentry *dentry = filp->f_dentry;
+       struct dentry *dentry = filp->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        ssize_t res;
 
@@ -243,7 +243,7 @@ nfs_file_sendfile(struct file *filp, loff_t *ppos, size_t count,
 static int
 nfs_file_mmap(struct file * file, struct vm_area_struct * vma)
 {
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        int     status;
 
@@ -307,28 +307,28 @@ static int nfs_commit_write(struct file *file, struct page *page, unsigned offse
 
 static void nfs_invalidate_page(struct page *page, unsigned long offset)
 {
-       struct inode *inode = page->mapping->host;
-
+       if (offset != 0)
+               return;
        /* Cancel any unstarted writes on this page */
-       if (offset == 0)
-               nfs_sync_inode_wait(inode, page->index, 1, FLUSH_INVALIDATE);
+       nfs_wb_page_priority(page->mapping->host, page, FLUSH_INVALIDATE);
 }
 
 static int nfs_release_page(struct page *page, gfp_t gfp)
 {
-       if (gfp & __GFP_FS)
-               return !nfs_wb_page(page->mapping->host, page);
-       else
-               /*
-                * Avoid deadlock on nfs_wait_on_request().
-                */
+       /*
+        * Avoid deadlock on nfs_wait_on_request().
+        */
+       if (!(gfp & __GFP_FS))
                return 0;
+       /* Hack... Force nfs_wb_page() to write out the page */
+       SetPageDirty(page);
+       return !nfs_wb_page(page->mapping->host, page);
 }
 
 const struct address_space_operations nfs_file_aops = {
        .readpage = nfs_readpage,
        .readpages = nfs_readpages,
-       .set_page_dirty = __set_page_dirty_nobuffers,
+       .set_page_dirty = nfs_set_page_dirty,
        .writepage = nfs_writepage,
        .writepages = nfs_writepages,
        .prepare_write = nfs_prepare_write,
@@ -343,7 +343,7 @@ const struct address_space_operations nfs_file_aops = {
 static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
                                unsigned long nr_segs, loff_t pos)
 {
-       struct dentry * dentry = iocb->ki_filp->f_dentry;
+       struct dentry * dentry = iocb->ki_filp->f_path.dentry;
        struct inode * inode = dentry->d_inode;
        ssize_t result;
        size_t count = iov_length(iov, nr_segs);
@@ -375,6 +375,12 @@ static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
 
        nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, count);
        result = generic_file_aio_write(iocb, iov, nr_segs, pos);
+       /* Return error values for O_SYNC and IS_SYNC() */
+       if (result >= 0 && (IS_SYNC(inode) || (iocb->ki_filp->f_flags & O_SYNC))) {
+               int err = nfs_fsync(iocb->ki_filp, dentry, 1);
+               if (err < 0)
+                       result = err;
+       }
 out:
        return result;
 
@@ -529,8 +535,8 @@ static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl)
 static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl)
 {
        dprintk("NFS: nfs_flock(f=%s/%ld, t=%x, fl=%x)\n",
-                       filp->f_dentry->d_inode->i_sb->s_id,
-                       filp->f_dentry->d_inode->i_ino,
+                       filp->f_path.dentry->d_inode->i_sb->s_id,
+                       filp->f_path.dentry->d_inode->i_ino,
                        fl->fl_type, fl->fl_flags);
 
        /*
index 20c6f39ea38a20c44cdbead39d4edeb0d65316c5..8391bd7a83ce46b81b9480f6710e7cbe37512ae3 100644 (file)
@@ -31,7 +31,7 @@
 #include <linux/nfs_idmap.h>
 #include <linux/vfs.h>
 #include <linux/namei.h>
-#include <linux/namespace.h>
+#include <linux/mnt_namespace.h>
 #include <linux/security.h>
 
 #include <asm/system.h>
index 82ad7110a1c0b75458ff84aeffdeb2c4423251ad..9d4a6b2d199672c67388262b808a67adef72e433 100644 (file)
@@ -377,7 +377,7 @@ idmap_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg,
 static ssize_t
 idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
 {
-        struct rpc_inode *rpci = RPC_I(filp->f_dentry->d_inode);
+        struct rpc_inode *rpci = RPC_I(filp->f_path.dentry->d_inode);
        struct idmap *idmap = (struct idmap *)rpci->private;
        struct idmap_msg im_in, *im = &idmap->idmap_im;
        struct idmap_hashtable *h;
index 08cc4c5919abee92f1f28b411e1154c627ff15d3..63e4702793090b6d0109b31dcfff4306a0742e24 100644 (file)
@@ -55,7 +55,7 @@ static int nfs_update_inode(struct inode *, struct nfs_fattr *);
 
 static void nfs_zap_acl_cache(struct inode *);
 
-static kmem_cache_t * nfs_inode_cachep;
+static struct kmem_cache * nfs_inode_cachep;
 
 static inline unsigned long
 nfs_fattr_to_ino_t(struct nfs_fattr *fattr)
@@ -422,7 +422,7 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
        int err;
 
        /* Flush out writes to the server in order to update c/mtime */
-       nfs_sync_inode_wait(inode, 0, 0, FLUSH_NOCOMMIT);
+       nfs_sync_mapping_range(inode->i_mapping, 0, 0, FLUSH_NOCOMMIT);
 
        /*
         * We may force a getattr if the user cares about atime.
@@ -496,7 +496,7 @@ void put_nfs_open_context(struct nfs_open_context *ctx)
  */
 static void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct nfs_inode *nfsi = NFS_I(inode);
 
        filp->private_data = get_nfs_open_context(ctx);
@@ -528,7 +528,7 @@ struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_c
 
 static void nfs_file_clear_open_context(struct file *filp)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct nfs_open_context *ctx = (struct nfs_open_context *)filp->private_data;
 
        if (ctx) {
@@ -551,7 +551,7 @@ int nfs_open(struct inode *inode, struct file *filp)
        cred = rpcauth_lookupcred(NFS_CLIENT(inode)->cl_auth, 0);
        if (IS_ERR(cred))
                return PTR_ERR(cred);
-       ctx = alloc_nfs_open_context(filp->f_vfsmnt, filp->f_dentry, cred);
+       ctx = alloc_nfs_open_context(filp->f_path.mnt, filp->f_path.dentry, cred);
        put_rpccred(cred);
        if (ctx == NULL)
                return -ENOMEM;
@@ -1080,7 +1080,7 @@ void nfs4_clear_inode(struct inode *inode)
 struct inode *nfs_alloc_inode(struct super_block *sb)
 {
        struct nfs_inode *nfsi;
-       nfsi = (struct nfs_inode *)kmem_cache_alloc(nfs_inode_cachep, SLAB_KERNEL);
+       nfsi = (struct nfs_inode *)kmem_cache_alloc(nfs_inode_cachep, GFP_KERNEL);
        if (!nfsi)
                return NULL;
        nfsi->flags = 0UL;
@@ -1111,7 +1111,7 @@ static inline void nfs4_init_once(struct nfs_inode *nfsi)
 #endif
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct nfs_inode *nfsi = (struct nfs_inode *) foo;
 
index d205466233f67f932460d51f124cade1bec0a516..a28f6ce2e131e4df24e40223ebdc36d7d986da6f 100644 (file)
@@ -217,3 +217,21 @@ void nfs_super_set_maxbytes(struct super_block *sb, __u64 maxfilesize)
        if (sb->s_maxbytes > MAX_LFS_FILESIZE || sb->s_maxbytes <= 0)
                sb->s_maxbytes = MAX_LFS_FILESIZE;
 }
+
+/*
+ * Determine the number of bytes of data the page contains
+ */
+static inline
+unsigned int nfs_page_length(struct page *page)
+{
+       loff_t i_size = i_size_read(page->mapping->host);
+
+       if (i_size > 0) {
+               pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT;
+               if (page->index < end_index)
+                       return PAGE_CACHE_SIZE;
+               if (page->index == end_index)
+                       return ((i_size - 1) & ~PAGE_CACHE_MASK) + 1;
+       }
+       return 0;
+}
index e5f128ffc32dd7ee368946768f9ce762a44c4fe7..acd8fe9762d3fc7abd6c626439dc6cb50105a0b7 100644 (file)
@@ -276,51 +276,6 @@ static int nfs3_proc_read(struct nfs_read_data *rdata)
        return status;
 }
 
-static int nfs3_proc_write(struct nfs_write_data *wdata)
-{
-       int                     rpcflags = wdata->flags;
-       struct inode *          inode = wdata->inode;
-       struct nfs_fattr *      fattr = wdata->res.fattr;
-       struct rpc_message      msg = {
-               .rpc_proc       = &nfs3_procedures[NFS3PROC_WRITE],
-               .rpc_argp       = &wdata->args,
-               .rpc_resp       = &wdata->res,
-               .rpc_cred       = wdata->cred,
-       };
-       int                     status;
-
-       dprintk("NFS call  write %d @ %Ld\n", wdata->args.count,
-                       (long long) wdata->args.offset);
-       nfs_fattr_init(fattr);
-       status = rpc_call_sync(NFS_CLIENT(inode), &msg, rpcflags);
-       if (status >= 0)
-               nfs_post_op_update_inode(inode, fattr);
-       dprintk("NFS reply write: %d\n", status);
-       return status < 0? status : wdata->res.count;
-}
-
-static int nfs3_proc_commit(struct nfs_write_data *cdata)
-{
-       struct inode *          inode = cdata->inode;
-       struct nfs_fattr *      fattr = cdata->res.fattr;
-       struct rpc_message      msg = {
-               .rpc_proc       = &nfs3_procedures[NFS3PROC_COMMIT],
-               .rpc_argp       = &cdata->args,
-               .rpc_resp       = &cdata->res,
-               .rpc_cred       = cdata->cred,
-       };
-       int                     status;
-
-       dprintk("NFS call  commit %d @ %Ld\n", cdata->args.count,
-                       (long long) cdata->args.offset);
-       nfs_fattr_init(fattr);
-       status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
-       if (status >= 0)
-               nfs_post_op_update_inode(inode, fattr);
-       dprintk("NFS reply commit: %d\n", status);
-       return status;
-}
-
 /*
  * Create a regular file.
  * For now, we don't implement O_EXCL.
@@ -369,7 +324,7 @@ again:
 
        /* If the server doesn't support the exclusive creation semantics,
         * try again with simple 'guarded' mode. */
-       if (status == NFSERR_NOTSUPP) {
+       if (status == -ENOTSUPP) {
                switch (arg.createmode) {
                        case NFS3_CREATE_EXCLUSIVE:
                                arg.createmode = NFS3_CREATE_GUARDED;
@@ -690,8 +645,6 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
        };
        int                     status;
 
-       lock_kernel();
-
        if (plus)
                msg.rpc_proc = &nfs3_procedures[NFS3PROC_READDIRPLUS];
 
@@ -702,7 +655,6 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
        status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
        nfs_refresh_inode(dir, &dir_attr);
        dprintk("NFS reply readdir: %d\n", status);
-       unlock_kernel();
        return status;
 }
 
@@ -889,7 +841,7 @@ static void nfs3_proc_commit_setup(struct nfs_write_data *data, int how)
 static int
 nfs3_proc_lock(struct file *filp, int cmd, struct file_lock *fl)
 {
-       return nlmclnt_proc(filp->f_dentry->d_inode, cmd, fl);
+       return nlmclnt_proc(filp->f_path.dentry->d_inode, cmd, fl);
 }
 
 const struct nfs_rpc_ops nfs_v3_clientops = {
@@ -904,8 +856,6 @@ const struct nfs_rpc_ops nfs_v3_clientops = {
        .access         = nfs3_proc_access,
        .readlink       = nfs3_proc_readlink,
        .read           = nfs3_proc_read,
-       .write          = nfs3_proc_write,
-       .commit         = nfs3_proc_commit,
        .create         = nfs3_proc_create,
        .remove         = nfs3_proc_remove,
        .unlink_setup   = nfs3_proc_unlink_setup,
index 8118036cc4494c3a420869820cdebdb66c2c6262..ee458aeab24a5ef1ebc1ad8aad1410cd2d64abd9 100644 (file)
@@ -636,7 +636,7 @@ static int _nfs4_proc_open_confirm(struct nfs4_opendata *data)
                smp_wmb();
        } else
                status = data->rpc_status;
-       rpc_release_task(task);
+       rpc_put_task(task);
        return status;
 }
 
@@ -742,7 +742,7 @@ static int _nfs4_proc_open(struct nfs4_opendata *data)
                smp_wmb();
        } else
                status = data->rpc_status;
-       rpc_release_task(task);
+       rpc_put_task(task);
        if (status != 0)
                return status;
 
@@ -1775,89 +1775,6 @@ static int nfs4_proc_read(struct nfs_read_data *rdata)
        return err;
 }
 
-static int _nfs4_proc_write(struct nfs_write_data *wdata)
-{
-       int rpcflags = wdata->flags;
-       struct inode *inode = wdata->inode;
-       struct nfs_fattr *fattr = wdata->res.fattr;
-       struct nfs_server *server = NFS_SERVER(inode);
-       struct rpc_message msg = {
-               .rpc_proc       = &nfs4_procedures[NFSPROC4_CLNT_WRITE],
-               .rpc_argp       = &wdata->args,
-               .rpc_resp       = &wdata->res,
-               .rpc_cred       = wdata->cred,
-       };
-       int status;
-
-       dprintk("NFS call  write %d @ %Ld\n", wdata->args.count,
-                       (long long) wdata->args.offset);
-
-       wdata->args.bitmask = server->attr_bitmask;
-       wdata->res.server = server;
-       wdata->timestamp = jiffies;
-       nfs_fattr_init(fattr);
-       status = rpc_call_sync(server->client, &msg, rpcflags);
-       dprintk("NFS reply write: %d\n", status);
-       if (status < 0)
-               return status;
-       renew_lease(server, wdata->timestamp);
-       nfs_post_op_update_inode(inode, fattr);
-       return wdata->res.count;
-}
-
-static int nfs4_proc_write(struct nfs_write_data *wdata)
-{
-       struct nfs4_exception exception = { };
-       int err;
-       do {
-               err = nfs4_handle_exception(NFS_SERVER(wdata->inode),
-                               _nfs4_proc_write(wdata),
-                               &exception);
-       } while (exception.retry);
-       return err;
-}
-
-static int _nfs4_proc_commit(struct nfs_write_data *cdata)
-{
-       struct inode *inode = cdata->inode;
-       struct nfs_fattr *fattr = cdata->res.fattr;
-       struct nfs_server *server = NFS_SERVER(inode);
-       struct rpc_message msg = {
-               .rpc_proc       = &nfs4_procedures[NFSPROC4_CLNT_COMMIT],
-               .rpc_argp       = &cdata->args,
-               .rpc_resp       = &cdata->res,
-               .rpc_cred       = cdata->cred,
-       };
-       int status;
-
-       dprintk("NFS call  commit %d @ %Ld\n", cdata->args.count,
-                       (long long) cdata->args.offset);
-
-       cdata->args.bitmask = server->attr_bitmask;
-       cdata->res.server = server;
-       cdata->timestamp = jiffies;
-       nfs_fattr_init(fattr);
-       status = rpc_call_sync(server->client, &msg, 0);
-       if (status >= 0)
-               renew_lease(server, cdata->timestamp);
-       dprintk("NFS reply commit: %d\n", status);
-       if (status >= 0)
-               nfs_post_op_update_inode(inode, fattr);
-       return status;
-}
-
-static int nfs4_proc_commit(struct nfs_write_data *cdata)
-{
-       struct nfs4_exception exception = { };
-       int err;
-       do {
-               err = nfs4_handle_exception(NFS_SERVER(cdata->inode),
-                               _nfs4_proc_commit(cdata),
-                               &exception);
-       } while (exception.retry);
-       return err;
-}
-
 /*
  * Got race?
  * We will need to arrange for the VFS layer to provide an atomic open.
@@ -2223,13 +2140,11 @@ static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
                        dentry->d_parent->d_name.name,
                        dentry->d_name.name,
                        (unsigned long long)cookie);
-       lock_kernel();
        nfs4_setup_readdir(cookie, NFS_COOKIEVERF(dir), dentry, &args);
        res.pgbase = args.pgbase;
        status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
        if (status == 0)
                memcpy(NFS_COOKIEVERF(dir), res.verifier.data, NFS4_VERIFIER_SIZE);
-       unlock_kernel();
        dprintk("%s: returns %d\n", __FUNCTION__, status);
        return status;
 }
@@ -3067,7 +2982,7 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co
                if (status == 0)
                        nfs_post_op_update_inode(inode, &data->fattr);
        }
-       rpc_release_task(task);
+       rpc_put_task(task);
        return status;
 }
 
@@ -3314,7 +3229,7 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *
        if (IS_ERR(task))
                goto out;
        status = nfs4_wait_for_completion_rpc_task(task);
-       rpc_release_task(task);
+       rpc_put_task(task);
 out:
        return status;
 }
@@ -3430,7 +3345,7 @@ static void nfs4_lock_release(void *calldata)
                task = nfs4_do_unlck(&data->fl, data->ctx, data->lsp,
                                data->arg.lock_seqid);
                if (!IS_ERR(task))
-                       rpc_release_task(task);
+                       rpc_put_task(task);
                dprintk("%s: cancelling lock!\n", __FUNCTION__);
        } else
                nfs_free_seqid(data->arg.lock_seqid);
@@ -3472,7 +3387,7 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
                        ret = -EAGAIN;
        } else
                data->cancelled = 1;
-       rpc_release_task(task);
+       rpc_put_task(task);
        dprintk("%s: done, ret = %d!\n", __FUNCTION__, ret);
        return ret;
 }
@@ -3732,8 +3647,6 @@ const struct nfs_rpc_ops nfs_v4_clientops = {
        .access         = nfs4_proc_access,
        .readlink       = nfs4_proc_readlink,
        .read           = nfs4_proc_read,
-       .write          = nfs4_proc_write,
-       .commit         = nfs4_proc_commit,
        .create         = nfs4_proc_create,
        .remove         = nfs4_proc_remove,
        .unlink_setup   = nfs4_proc_unlink_setup,
index 829af323f28862f2218ab1d3f5163b5953f6b623..ca4b1d4ff42b0f7d337ad01fa7c1675f959c4134 100644 (file)
 #include <linux/nfs_page.h>
 #include <linux/nfs_fs.h>
 #include <linux/nfs_mount.h>
+#include <linux/writeback.h>
 
 #define NFS_PARANOIA 1
 
-static kmem_cache_t *nfs_page_cachep;
+static struct kmem_cache *nfs_page_cachep;
 
 static inline struct nfs_page *
 nfs_page_alloc(void)
 {
        struct nfs_page *p;
-       p = kmem_cache_alloc(nfs_page_cachep, SLAB_KERNEL);
+       p = kmem_cache_alloc(nfs_page_cachep, GFP_KERNEL);
        if (p) {
                memset(p, 0, sizeof(*p));
                INIT_LIST_HEAD(&p->wb_list);
@@ -268,11 +269,10 @@ nfs_coalesce_requests(struct list_head *head, struct list_head *dst,
 
 #define NFS_SCAN_MAXENTRIES 16
 /**
- * nfs_scan_lock_dirty - Scan the radix tree for dirty requests
- * @nfsi: NFS inode
+ * nfs_scan_dirty - Scan the radix tree for dirty requests
+ * @mapping: pointer to address space
+ * @wbc: writeback_control structure
  * @dst: Destination list
- * @idx_start: lower bound of page->index to scan
- * @npages: idx_start + npages sets the upper bound to scan.
  *
  * Moves elements from one of the inode request lists.
  * If the number of requests is set to 0, the entire address_space
@@ -280,46 +280,63 @@ nfs_coalesce_requests(struct list_head *head, struct list_head *dst,
  * The requests are *not* checked to ensure that they form a contiguous set.
  * You must be holding the inode's req_lock when calling this function
  */
-int
-nfs_scan_lock_dirty(struct nfs_inode *nfsi, struct list_head *dst,
-             unsigned long idx_start, unsigned int npages)
+long nfs_scan_dirty(struct address_space *mapping,
+                       struct writeback_control *wbc,
+                       struct list_head *dst)
 {
+       struct nfs_inode *nfsi = NFS_I(mapping->host);
        struct nfs_page *pgvec[NFS_SCAN_MAXENTRIES];
        struct nfs_page *req;
-       unsigned long idx_end;
+       pgoff_t idx_start, idx_end;
+       long res = 0;
        int found, i;
-       int res;
 
-       res = 0;
-       if (npages == 0)
-               idx_end = ~0;
-       else
-               idx_end = idx_start + npages - 1;
+       if (nfsi->ndirty == 0)
+               return 0;
+       if (wbc->range_cyclic) {
+               idx_start = 0;
+               idx_end = ULONG_MAX;
+       } else if (wbc->range_end == 0) {
+               idx_start = wbc->range_start >> PAGE_CACHE_SHIFT;
+               idx_end = ULONG_MAX;
+       } else {
+               idx_start = wbc->range_start >> PAGE_CACHE_SHIFT;
+               idx_end = wbc->range_end >> PAGE_CACHE_SHIFT;
+       }
 
        for (;;) {
+               unsigned int toscan = NFS_SCAN_MAXENTRIES;
+
                found = radix_tree_gang_lookup_tag(&nfsi->nfs_page_tree,
-                               (void **)&pgvec[0], idx_start, NFS_SCAN_MAXENTRIES,
+                               (void **)&pgvec[0], idx_start, toscan,
                                NFS_PAGE_TAG_DIRTY);
+
+               /* Did we make progress? */
                if (found <= 0)
                        break;
+
                for (i = 0; i < found; i++) {
                        req = pgvec[i];
-                       if (req->wb_index > idx_end)
+                       if (!wbc->range_cyclic && req->wb_index > idx_end)
                                goto out;
 
+                       /* Try to lock request and mark it for writeback */
+                       if (!nfs_set_page_writeback_locked(req))
+                               goto next;
+                       radix_tree_tag_clear(&nfsi->nfs_page_tree,
+                                       req->wb_index, NFS_PAGE_TAG_DIRTY);
+                       nfsi->ndirty--;
+                       nfs_list_remove_request(req);
+                       nfs_list_add_request(req, dst);
+                       res++;
+                       if (res == LONG_MAX)
+                               goto out;
+next:
                        idx_start = req->wb_index + 1;
-
-                       if (nfs_set_page_writeback_locked(req)) {
-                               radix_tree_tag_clear(&nfsi->nfs_page_tree,
-                                               req->wb_index, NFS_PAGE_TAG_DIRTY);
-                               nfs_list_remove_request(req);
-                               nfs_list_add_request(req, dst);
-                               dec_zone_page_state(req->wb_page, NR_FILE_DIRTY);
-                               res++;
-                       }
                }
        }
 out:
+       WARN_ON ((nfsi->ndirty == 0) != list_empty(&nfsi->dirty));
        return res;
 }
 
index 4529cc4f3f8fe427bb6b262718213f933b7ac6a1..560536ad74a49fd500077882b211655c26424b85 100644 (file)
@@ -215,32 +215,6 @@ static int nfs_proc_read(struct nfs_read_data *rdata)
        return status;
 }
 
-static int nfs_proc_write(struct nfs_write_data *wdata)
-{
-       int                     flags = wdata->flags;
-       struct inode *          inode = wdata->inode;
-       struct nfs_fattr *      fattr = wdata->res.fattr;
-       struct rpc_message      msg = {
-               .rpc_proc       = &nfs_procedures[NFSPROC_WRITE],
-               .rpc_argp       = &wdata->args,
-               .rpc_resp       = &wdata->res,
-               .rpc_cred       = wdata->cred,
-       };
-       int                     status;
-
-       dprintk("NFS call  write %d @ %Ld\n", wdata->args.count,
-                       (long long) wdata->args.offset);
-       nfs_fattr_init(fattr);
-       status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);
-       if (status >= 0) {
-               nfs_post_op_update_inode(inode, fattr);
-               wdata->res.count = wdata->args.count;
-               wdata->verf.committed = NFS_FILE_SYNC;
-       }
-       dprintk("NFS reply write: %d\n", status);
-       return status < 0? status : wdata->res.count;
-}
-
 static int
 nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
                int flags, struct nameidata *nd)
@@ -545,13 +519,10 @@ nfs_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
        };
        int                     status;
 
-       lock_kernel();
-
        dprintk("NFS call  readdir %d\n", (unsigned int)cookie);
        status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
 
        dprintk("NFS reply readdir: %d\n", status);
-       unlock_kernel();
        return status;
 }
 
@@ -680,7 +651,7 @@ nfs_proc_commit_setup(struct nfs_write_data *data, int how)
 static int
 nfs_proc_lock(struct file *filp, int cmd, struct file_lock *fl)
 {
-       return nlmclnt_proc(filp->f_dentry->d_inode, cmd, fl);
+       return nlmclnt_proc(filp->f_path.dentry->d_inode, cmd, fl);
 }
 
 
@@ -696,8 +667,6 @@ const struct nfs_rpc_ops nfs_v2_clientops = {
        .access         = NULL,                /* access */
        .readlink       = nfs_proc_readlink,
        .read           = nfs_proc_read,
-       .write          = nfs_proc_write,
-       .commit         = NULL,                /* commit */
        .create         = nfs_proc_create,
        .remove         = nfs_proc_remove,
        .unlink_setup   = nfs_proc_unlink_setup,
index c2e49c397a27186ac9ba09ebd49710bb091935e8..a9c26521a9e2d8a13965e364dae9ac8392cecdb1 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <asm/system.h>
 
+#include "internal.h"
 #include "iostat.h"
 
 #define NFSDBG_FACILITY                NFSDBG_PAGECACHE
@@ -38,7 +39,7 @@ static int nfs_pagein_one(struct list_head *, struct inode *);
 static const struct rpc_call_ops nfs_read_partial_ops;
 static const struct rpc_call_ops nfs_read_full_ops;
 
-static kmem_cache_t *nfs_rdata_cachep;
+static struct kmem_cache *nfs_rdata_cachep;
 static mempool_t *nfs_rdata_mempool;
 
 #define MIN_POOL_READ  (32)
@@ -46,7 +47,7 @@ static mempool_t *nfs_rdata_mempool;
 struct nfs_read_data *nfs_readdata_alloc(size_t len)
 {
        unsigned int pagecount = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
-       struct nfs_read_data *p = mempool_alloc(nfs_rdata_mempool, SLAB_NOFS);
+       struct nfs_read_data *p = mempool_alloc(nfs_rdata_mempool, GFP_NOFS);
 
        if (p) {
                memset(p, 0, sizeof(*p));
@@ -65,32 +66,22 @@ struct nfs_read_data *nfs_readdata_alloc(size_t len)
        return p;
 }
 
-static void nfs_readdata_free(struct nfs_read_data *p)
+static void nfs_readdata_rcu_free(struct rcu_head *head)
 {
+       struct nfs_read_data *p = container_of(head, struct nfs_read_data, task.u.tk_rcu);
        if (p && (p->pagevec != &p->page_array[0]))
                kfree(p->pagevec);
        mempool_free(p, nfs_rdata_mempool);
 }
 
-void nfs_readdata_release(void *data)
+static void nfs_readdata_free(struct nfs_read_data *rdata)
 {
-        nfs_readdata_free(data);
+       call_rcu_bh(&rdata->task.u.tk_rcu, nfs_readdata_rcu_free);
 }
 
-static
-unsigned int nfs_page_length(struct inode *inode, struct page *page)
+void nfs_readdata_release(void *data)
 {
-       loff_t i_size = i_size_read(inode);
-       unsigned long idx;
-
-       if (i_size <= 0)
-               return 0;
-       idx = (i_size - 1) >> PAGE_CACHE_SHIFT;
-       if (page->index > idx)
-               return 0;
-       if (page->index != idx)
-               return PAGE_CACHE_SIZE;
-       return 1 + ((i_size - 1) & (PAGE_CACHE_SIZE - 1));
+        nfs_readdata_free(data);
 }
 
 static
@@ -139,12 +130,12 @@ static int nfs_readpage_sync(struct nfs_open_context *ctx, struct inode *inode,
 {
        unsigned int    rsize = NFS_SERVER(inode)->rsize;
        unsigned int    count = PAGE_CACHE_SIZE;
-       int             result;
+       int result = -ENOMEM;
        struct nfs_read_data *rdata;
 
        rdata = nfs_readdata_alloc(count);
        if (!rdata)
-               return -ENOMEM;
+               goto out_unlock;
 
        memset(rdata, 0, sizeof(*rdata));
        rdata->flags = (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0);
@@ -212,8 +203,9 @@ static int nfs_readpage_sync(struct nfs_open_context *ctx, struct inode *inode,
        result = 0;
 
 io_error:
-       unlock_page(page);
        nfs_readdata_free(rdata);
+out_unlock:
+       unlock_page(page);
        return result;
 }
 
@@ -224,7 +216,7 @@ static int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
        struct nfs_page *new;
        unsigned int len;
 
-       len = nfs_page_length(inode, page);
+       len = nfs_page_length(page);
        if (len == 0)
                return nfs_return_empty_page(page);
        new = nfs_create_request(ctx, inode, page, 0, len);
@@ -316,9 +308,7 @@ static void nfs_execute_read(struct nfs_read_data *data)
        sigset_t oldset;
 
        rpc_clnt_sigmask(clnt, &oldset);
-       lock_kernel();
        rpc_execute(&data->task);
-       unlock_kernel();
        rpc_clnt_sigunmask(clnt, &oldset);
 }
 
@@ -454,6 +444,55 @@ nfs_pagein_list(struct list_head *head, int rpages)
        return error;
 }
 
+/*
+ * This is the callback from RPC telling us whether a reply was
+ * received or some error occurred (timeout or socket shutdown).
+ */
+int nfs_readpage_result(struct rpc_task *task, struct nfs_read_data *data)
+{
+       int status;
+
+       dprintk("%s: %4d, (status %d)\n", __FUNCTION__, task->tk_pid,
+                       task->tk_status);
+
+       status = NFS_PROTO(data->inode)->read_done(task, data);
+       if (status != 0)
+               return status;
+
+       nfs_add_stats(data->inode, NFSIOS_SERVERREADBYTES, data->res.count);
+
+       if (task->tk_status == -ESTALE) {
+               set_bit(NFS_INO_STALE, &NFS_FLAGS(data->inode));
+               nfs_mark_for_revalidate(data->inode);
+       }
+       spin_lock(&data->inode->i_lock);
+       NFS_I(data->inode)->cache_validity |= NFS_INO_INVALID_ATIME;
+       spin_unlock(&data->inode->i_lock);
+       return 0;
+}
+
+static int nfs_readpage_retry(struct rpc_task *task, struct nfs_read_data *data)
+{
+       struct nfs_readargs *argp = &data->args;
+       struct nfs_readres *resp = &data->res;
+
+       if (resp->eof || resp->count == argp->count)
+               return 0;
+
+       /* This is a short read! */
+       nfs_inc_stats(data->inode, NFSIOS_SHORTREAD);
+       /* Has the server at least made some progress? */
+       if (resp->count == 0)
+               return 0;
+
+       /* Yes, so retry the read at the end of the data */
+       argp->offset += resp->count;
+       argp->pgbase += resp->count;
+       argp->count -= resp->count;
+       rpc_restart_call(task);
+       return -EAGAIN;
+}
+
 /*
  * Handle a read reply that fills part of a page.
  */
@@ -463,12 +502,16 @@ static void nfs_readpage_result_partial(struct rpc_task *task, void *calldata)
        struct nfs_page *req = data->req;
        struct page *page = req->wb_page;
  
-       if (likely(task->tk_status >= 0))
-               nfs_readpage_truncate_uninitialised_page(data);
-       else
-               SetPageError(page);
        if (nfs_readpage_result(task, data) != 0)
                return;
+
+       if (likely(task->tk_status >= 0)) {
+               nfs_readpage_truncate_uninitialised_page(data);
+               if (nfs_readpage_retry(task, data) != 0)
+                       return;
+       }
+       if (unlikely(task->tk_status < 0))
+               SetPageError(page);
        if (atomic_dec_and_test(&req->wb_complete)) {
                if (!PageError(page))
                        SetPageUptodate(page);
@@ -496,25 +539,13 @@ static void nfs_readpage_set_pages_uptodate(struct nfs_read_data *data)
        count += base;
        for (;count >= PAGE_CACHE_SIZE; count -= PAGE_CACHE_SIZE, pages++)
                SetPageUptodate(*pages);
-       if (count != 0)
+       if (count == 0)
+               return;
+       /* Was this a short read? */
+       if (data->res.eof || data->res.count == data->args.count)
                SetPageUptodate(*pages);
 }
 
-static void nfs_readpage_set_pages_error(struct nfs_read_data *data)
-{
-       unsigned int count = data->args.count;
-       unsigned int base = data->args.pgbase;
-       struct page **pages;
-
-       pages = &data->args.pages[base >> PAGE_CACHE_SHIFT];
-       base &= ~PAGE_CACHE_MASK;
-       count += base;
-       for (;count >= PAGE_CACHE_SIZE; count -= PAGE_CACHE_SIZE, pages++)
-               SetPageError(*pages);
-       if (count != 0)
-               SetPageError(*pages);
-}
-
 /*
  * This is the callback from RPC telling us whether a reply was
  * received or some error occurred (timeout or socket shutdown).
@@ -523,19 +554,20 @@ static void nfs_readpage_result_full(struct rpc_task *task, void *calldata)
 {
        struct nfs_read_data *data = calldata;
 
+       if (nfs_readpage_result(task, data) != 0)
+               return;
        /*
-        * Note: nfs_readpage_result may change the values of
+        * Note: nfs_readpage_retry may change the values of
         * data->args. In the multi-page case, we therefore need
-        * to ensure that we call the next nfs_readpage_set_page_uptodate()
-        * first in the multi-page case.
+        * to ensure that we call nfs_readpage_set_pages_uptodate()
+        * first.
         */
        if (likely(task->tk_status >= 0)) {
                nfs_readpage_truncate_uninitialised_page(data);
                nfs_readpage_set_pages_uptodate(data);
-       } else
-               nfs_readpage_set_pages_error(data);
-       if (nfs_readpage_result(task, data) != 0)
-               return;
+               if (nfs_readpage_retry(task, data) != 0)
+                       return;
+       }
        while (!list_empty(&data->pages)) {
                struct nfs_page *req = nfs_list_entry(data->pages.next);
 
@@ -549,50 +581,6 @@ static const struct rpc_call_ops nfs_read_full_ops = {
        .rpc_release = nfs_readdata_release,
 };
 
-/*
- * This is the callback from RPC telling us whether a reply was
- * received or some error occurred (timeout or socket shutdown).
- */
-int nfs_readpage_result(struct rpc_task *task, struct nfs_read_data *data)
-{
-       struct nfs_readargs *argp = &data->args;
-       struct nfs_readres *resp = &data->res;
-       int status;
-
-       dprintk("NFS: %4d nfs_readpage_result, (status %d)\n",
-               task->tk_pid, task->tk_status);
-
-       status = NFS_PROTO(data->inode)->read_done(task, data);
-       if (status != 0)
-               return status;
-
-       nfs_add_stats(data->inode, NFSIOS_SERVERREADBYTES, resp->count);
-
-       if (task->tk_status < 0) {
-               if (task->tk_status == -ESTALE) {
-                       set_bit(NFS_INO_STALE, &NFS_FLAGS(data->inode));
-                       nfs_mark_for_revalidate(data->inode);
-               }
-       } else if (resp->count < argp->count && !resp->eof) {
-               /* This is a short read! */
-               nfs_inc_stats(data->inode, NFSIOS_SHORTREAD);
-               /* Has the server at least made some progress? */
-               if (resp->count != 0) {
-                       /* Yes, so retry the read at the end of the data */
-                       argp->offset += resp->count;
-                       argp->pgbase += resp->count;
-                       argp->count -= resp->count;
-                       rpc_restart_call(task);
-                       return -EAGAIN;
-               }
-               task->tk_status = -EIO;
-       }
-       spin_lock(&data->inode->i_lock);
-       NFS_I(data->inode)->cache_validity |= NFS_INO_INVALID_ATIME;
-       spin_unlock(&data->inode->i_lock);
-       return 0;
-}
-
 /*
  * Read a page over NFS.
  * We read the page synchronously in the following case:
@@ -626,9 +614,10 @@ int nfs_readpage(struct file *file, struct page *page)
                goto out_error;
 
        if (file == NULL) {
+               error = -EBADF;
                ctx = nfs_find_open_context(inode, NULL, FMODE_READ);
                if (ctx == NULL)
-                       return -EBADF;
+                       goto out_error;
        } else
                ctx = get_nfs_open_context((struct nfs_open_context *)
                                file->private_data);
@@ -663,7 +652,7 @@ readpage_async_filler(void *data, struct page *page)
        unsigned int len;
 
        nfs_wb_page(inode, page);
-       len = nfs_page_length(inode, page);
+       len = nfs_page_length(page);
        if (len == 0)
                return nfs_return_empty_page(page);
        new = nfs_create_request(desc->ctx, inode, page, 0, len);
index 600bbe630abd99cdc6e8f9074984495630c9adc1..6c686112cc03fa3c3dcea70180653640d95aaeb9 100644 (file)
@@ -33,9 +33,7 @@ static int nfs_symlink_filler(struct inode *inode, struct page *page)
 {
        int error;
 
-       lock_kernel();
        error = NFS_PROTO(inode)->readlink(inode, page, 0, PAGE_SIZE);
-       unlock_kernel();
        if (error < 0)
                goto error;
        SetPageUptodate(page);
index 883dd4a1c157599284f3bae5127fa69418ec06e1..345492e78643846a6a5f356ad4ab3e7c91c6a94d 100644 (file)
@@ -63,6 +63,7 @@
 #include <linux/smp_lock.h>
 
 #include "delegation.h"
+#include "internal.h"
 #include "iostat.h"
 
 #define NFSDBG_FACILITY                NFSDBG_PAGECACHE
  * Local function declarations
  */
 static struct nfs_page * nfs_update_request(struct nfs_open_context*,
-                                           struct inode *,
                                            struct page *,
                                            unsigned int, unsigned int);
+static void nfs_mark_request_dirty(struct nfs_page *req);
 static int nfs_wait_on_write_congestion(struct address_space *, int);
 static int nfs_wait_on_requests(struct inode *, unsigned long, unsigned int);
-static int nfs_flush_inode(struct inode *inode, unsigned long idx_start,
-                          unsigned int npages, int how);
+static long nfs_flush_mapping(struct address_space *mapping, struct writeback_control *wbc, int how);
 static const struct rpc_call_ops nfs_write_partial_ops;
 static const struct rpc_call_ops nfs_write_full_ops;
 static const struct rpc_call_ops nfs_commit_ops;
 
-static kmem_cache_t *nfs_wdata_cachep;
+static struct kmem_cache *nfs_wdata_cachep;
 static mempool_t *nfs_wdata_mempool;
 static mempool_t *nfs_commit_mempool;
 
@@ -93,7 +93,7 @@ static DECLARE_WAIT_QUEUE_HEAD(nfs_write_congestion);
 
 struct nfs_write_data *nfs_commit_alloc(void)
 {
-       struct nfs_write_data *p = mempool_alloc(nfs_commit_mempool, SLAB_NOFS);
+       struct nfs_write_data *p = mempool_alloc(nfs_commit_mempool, GFP_NOFS);
 
        if (p) {
                memset(p, 0, sizeof(*p));
@@ -102,17 +102,23 @@ struct nfs_write_data *nfs_commit_alloc(void)
        return p;
 }
 
-void nfs_commit_free(struct nfs_write_data *p)
+void nfs_commit_rcu_free(struct rcu_head *head)
 {
+       struct nfs_write_data *p = container_of(head, struct nfs_write_data, task.u.tk_rcu);
        if (p && (p->pagevec != &p->page_array[0]))
                kfree(p->pagevec);
        mempool_free(p, nfs_commit_mempool);
 }
 
+void nfs_commit_free(struct nfs_write_data *wdata)
+{
+       call_rcu_bh(&wdata->task.u.tk_rcu, nfs_commit_rcu_free);
+}
+
 struct nfs_write_data *nfs_writedata_alloc(size_t len)
 {
        unsigned int pagecount = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
-       struct nfs_write_data *p = mempool_alloc(nfs_wdata_mempool, SLAB_NOFS);
+       struct nfs_write_data *p = mempool_alloc(nfs_wdata_mempool, GFP_NOFS);
 
        if (p) {
                memset(p, 0, sizeof(*p));
@@ -131,18 +137,47 @@ struct nfs_write_data *nfs_writedata_alloc(size_t len)
        return p;
 }
 
-static void nfs_writedata_free(struct nfs_write_data *p)
+static void nfs_writedata_rcu_free(struct rcu_head *head)
 {
+       struct nfs_write_data *p = container_of(head, struct nfs_write_data, task.u.tk_rcu);
        if (p && (p->pagevec != &p->page_array[0]))
                kfree(p->pagevec);
        mempool_free(p, nfs_wdata_mempool);
 }
 
+static void nfs_writedata_free(struct nfs_write_data *wdata)
+{
+       call_rcu_bh(&wdata->task.u.tk_rcu, nfs_writedata_rcu_free);
+}
+
 void nfs_writedata_release(void *wdata)
 {
        nfs_writedata_free(wdata);
 }
 
+static struct nfs_page *nfs_page_find_request_locked(struct page *page)
+{
+       struct nfs_page *req = NULL;
+
+       if (PagePrivate(page)) {
+               req = (struct nfs_page *)page_private(page);
+               if (req != NULL)
+                       atomic_inc(&req->wb_count);
+       }
+       return req;
+}
+
+static struct nfs_page *nfs_page_find_request(struct page *page)
+{
+       struct nfs_page *req = NULL;
+       spinlock_t *req_lock = &NFS_I(page->mapping->host)->req_lock;
+
+       spin_lock(req_lock);
+       req = nfs_page_find_request_locked(page);
+       spin_unlock(req_lock);
+       return req;
+}
+
 /* Adjust the file length if we're writing beyond the end */
 static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int count)
 {
@@ -164,113 +199,34 @@ static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int c
  */
 static void nfs_mark_uptodate(struct page *page, unsigned int base, unsigned int count)
 {
-       loff_t end_offs;
-
        if (PageUptodate(page))
                return;
        if (base != 0)
                return;
-       if (count == PAGE_CACHE_SIZE) {
-               SetPageUptodate(page);
-               return;
-       }
-
-       end_offs = i_size_read(page->mapping->host) - 1;
-       if (end_offs < 0)
+       if (count != nfs_page_length(page))
                return;
-       /* Is this the last page? */
-       if (page->index != (unsigned long)(end_offs >> PAGE_CACHE_SHIFT))
-               return;
-       /* This is the last page: set PG_uptodate if we cover the entire
-        * extent of the data, then zero the rest of the page.
-        */
-       if (count == (unsigned int)(end_offs & (PAGE_CACHE_SIZE - 1)) + 1) {
+       if (count != PAGE_CACHE_SIZE)
                memclear_highpage_flush(page, count, PAGE_CACHE_SIZE - count);
-               SetPageUptodate(page);
-       }
+       SetPageUptodate(page);
 }
 
-/*
- * Write a page synchronously.
- * Offset is the data offset within the page.
- */
-static int nfs_writepage_sync(struct nfs_open_context *ctx, struct inode *inode,
-               struct page *page, unsigned int offset, unsigned int count,
-               int how)
-{
-       unsigned int    wsize = NFS_SERVER(inode)->wsize;
-       int             result, written = 0;
-       struct nfs_write_data *wdata;
-
-       wdata = nfs_writedata_alloc(wsize);
-       if (!wdata)
-               return -ENOMEM;
-
-       wdata->flags = how;
-       wdata->cred = ctx->cred;
-       wdata->inode = inode;
-       wdata->args.fh = NFS_FH(inode);
-       wdata->args.context = ctx;
-       wdata->args.pages = &page;
-       wdata->args.stable = NFS_FILE_SYNC;
-       wdata->args.pgbase = offset;
-       wdata->args.count = wsize;
-       wdata->res.fattr = &wdata->fattr;
-       wdata->res.verf = &wdata->verf;
-
-       dprintk("NFS:      nfs_writepage_sync(%s/%Ld %d@%Ld)\n",
-               inode->i_sb->s_id,
-               (long long)NFS_FILEID(inode),
-               count, (long long)(page_offset(page) + offset));
-
-       set_page_writeback(page);
-       nfs_begin_data_update(inode);
-       do {
-               if (count < wsize)
-                       wdata->args.count = count;
-               wdata->args.offset = page_offset(page) + wdata->args.pgbase;
-
-               result = NFS_PROTO(inode)->write(wdata);
-
-               if (result < 0) {
-                       /* Must mark the page invalid after I/O error */
-                       ClearPageUptodate(page);
-                       goto io_error;
-               }
-               if (result < wdata->args.count)
-                       printk(KERN_WARNING "NFS: short write, count=%u, result=%d\n",
-                                       wdata->args.count, result);
-
-               wdata->args.offset += result;
-               wdata->args.pgbase += result;
-               written += result;
-               count -= result;
-               nfs_add_stats(inode, NFSIOS_SERVERWRITTENBYTES, result);
-       } while (count);
-       /* Update file length */
-       nfs_grow_file(page, offset, written);
-       /* Set the PG_uptodate flag? */
-       nfs_mark_uptodate(page, offset, written);
-
-       if (PageError(page))
-               ClearPageError(page);
-
-io_error:
-       nfs_end_data_update(inode);
-       end_page_writeback(page);
-       nfs_writedata_free(wdata);
-       return written ? written : result;
-}
-
-static int nfs_writepage_async(struct nfs_open_context *ctx,
-               struct inode *inode, struct page *page,
+static int nfs_writepage_setup(struct nfs_open_context *ctx, struct page *page,
                unsigned int offset, unsigned int count)
 {
        struct nfs_page *req;
+       int ret;
 
-       req = nfs_update_request(ctx, inode, page, offset, count);
-       if (IS_ERR(req))
-               return PTR_ERR(req);
+       for (;;) {
+               req = nfs_update_request(ctx, page, offset, count);
+               if (!IS_ERR(req))
+                       break;
+               ret = PTR_ERR(req);
+               if (ret != -EBUSY)
+                       return ret;
+               ret = nfs_wb_page(page->mapping->host, page);
+               if (ret != 0)
+                       return ret;
+       }
        /* Update file length */
        nfs_grow_file(page, offset, count);
        /* Set the PG_uptodate flag? */
@@ -288,74 +244,95 @@ static int wb_priority(struct writeback_control *wbc)
        return 0;
 }
 
+/*
+ * Find an associated nfs write request, and prepare to flush it out
+ * Returns 1 if there was no write request, or if the request was
+ * already tagged by nfs_set_page_dirty.Returns 0 if the request
+ * was not tagged.
+ * May also return an error if the user signalled nfs_wait_on_request().
+ */
+static int nfs_page_mark_flush(struct page *page)
+{
+       struct nfs_page *req;
+       spinlock_t *req_lock = &NFS_I(page->mapping->host)->req_lock;
+       int ret;
+
+       spin_lock(req_lock);
+       for(;;) {
+               req = nfs_page_find_request_locked(page);
+               if (req == NULL) {
+                       spin_unlock(req_lock);
+                       return 1;
+               }
+               if (nfs_lock_request_dontget(req))
+                       break;
+               /* Note: If we hold the page lock, as is the case in nfs_writepage,
+                *       then the call to nfs_lock_request_dontget() will always
+                *       succeed provided that someone hasn't already marked the
+                *       request as dirty (in which case we don't care).
+                */
+               spin_unlock(req_lock);
+               ret = nfs_wait_on_request(req);
+               nfs_release_request(req);
+               if (ret != 0)
+                       return ret;
+               spin_lock(req_lock);
+       }
+       spin_unlock(req_lock);
+       if (test_and_set_bit(PG_FLUSHING, &req->wb_flags) == 0) {
+               nfs_mark_request_dirty(req);
+               set_page_writeback(page);
+       }
+       ret = test_bit(PG_NEED_FLUSH, &req->wb_flags);
+       nfs_unlock_request(req);
+       return ret;
+}
+
 /*
  * Write an mmapped page to the server.
  */
-int nfs_writepage(struct page *page, struct writeback_control *wbc)
+static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc)
 {
        struct nfs_open_context *ctx;
        struct inode *inode = page->mapping->host;
-       unsigned long end_index;
-       unsigned offset = PAGE_CACHE_SIZE;
-       loff_t i_size = i_size_read(inode);
-       int inode_referenced = 0;
-       int priority = wb_priority(wbc);
+       unsigned offset;
        int err;
 
        nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE);
        nfs_add_stats(inode, NFSIOS_WRITEPAGES, 1);
 
-       /*
-        * Note: We need to ensure that we have a reference to the inode
-        *       if we are to do asynchronous writes. If not, waiting
-        *       in nfs_wait_on_request() may deadlock with clear_inode().
-        *
-        *       If igrab() fails here, then it is in any case safe to
-        *       call nfs_wb_page(), since there will be no pending writes.
-        */
-       if (igrab(inode) != 0)
-               inode_referenced = 1;
-       end_index = i_size >> PAGE_CACHE_SHIFT;
-
-       /* Ensure we've flushed out any previous writes */
-       nfs_wb_page_priority(inode, page, priority);
-
-       /* easy case */
-       if (page->index < end_index)
-               goto do_it;
-       /* things got complicated... */
-       offset = i_size & (PAGE_CACHE_SIZE-1);
-
-       /* OK, are we completely out? */
-       err = 0; /* potential race with truncate - ignore */
-       if (page->index >= end_index+1 || !offset)
+       err = nfs_page_mark_flush(page);
+       if (err <= 0)
+               goto out;
+       err = 0;
+       offset = nfs_page_length(page);
+       if (!offset)
                goto out;
-do_it:
+
        ctx = nfs_find_open_context(inode, NULL, FMODE_WRITE);
        if (ctx == NULL) {
                err = -EBADF;
                goto out;
        }
-       lock_kernel();
-       if (!IS_SYNC(inode) && inode_referenced) {
-               err = nfs_writepage_async(ctx, inode, page, 0, offset);
-               if (!wbc->for_writepages)
-                       nfs_flush_inode(inode, 0, 0, wb_priority(wbc));
-       } else {
-               err = nfs_writepage_sync(ctx, inode, page, 0,
-                                               offset, priority);
-               if (err >= 0) {
-                       if (err != offset)
-                               redirty_page_for_writepage(wbc, page);
-                       err = 0;
-               }
-       }
-       unlock_kernel();
+       err = nfs_writepage_setup(ctx, page, 0, offset);
        put_nfs_open_context(ctx);
+       if (err != 0)
+               goto out;
+       err = nfs_page_mark_flush(page);
+       if (err > 0)
+               err = 0;
 out:
+       if (!wbc->for_writepages)
+               nfs_flush_mapping(page->mapping, wbc, wb_priority(wbc));
+       return err;
+}
+
+int nfs_writepage(struct page *page, struct writeback_control *wbc)
+{
+       int err;
+
+       err = nfs_writepage_locked(page, wbc);
        unlock_page(page);
-       if (inode_referenced)
-               iput(inode);
        return err; 
 }
 
@@ -379,21 +356,18 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc)
                        return 0;
                nfs_wait_on_write_congestion(mapping, 0);
        }
-       err = nfs_flush_inode(inode, 0, 0, wb_priority(wbc));
+       err = nfs_flush_mapping(mapping, wbc, wb_priority(wbc));
        if (err < 0)
                goto out;
        nfs_add_stats(inode, NFSIOS_WRITEPAGES, err);
-       wbc->nr_to_write -= err;
        if (!wbc->nonblocking && wbc->sync_mode == WB_SYNC_ALL) {
                err = nfs_wait_on_requests(inode, 0, 0);
                if (err < 0)
                        goto out;
        }
        err = nfs_commit_inode(inode, wb_priority(wbc));
-       if (err > 0) {
-               wbc->nr_to_write -= err;
+       if (err > 0)
                err = 0;
-       }
 out:
        clear_bit(BDI_write_congested, &bdi->state);
        wake_up_all(&nfs_write_congestion);
@@ -420,6 +394,7 @@ static int nfs_inode_add_request(struct inode *inode, struct nfs_page *req)
                        nfsi->change_attr++;
        }
        SetPagePrivate(req->wb_page);
+       set_page_private(req->wb_page, (unsigned long)req);
        nfsi->npages++;
        atomic_inc(&req->wb_count);
        return 0;
@@ -436,6 +411,7 @@ static void nfs_inode_remove_request(struct nfs_page *req)
        BUG_ON (!NFS_WBACK_BUSY(req));
 
        spin_lock(&nfsi->req_lock);
+       set_page_private(req->wb_page, 0);
        ClearPagePrivate(req->wb_page);
        radix_tree_delete(&nfsi->nfs_page_tree, req->wb_index);
        nfsi->npages--;
@@ -449,33 +425,6 @@ static void nfs_inode_remove_request(struct nfs_page *req)
        nfs_release_request(req);
 }
 
-/*
- * Find a request
- */
-static inline struct nfs_page *
-_nfs_find_request(struct inode *inode, unsigned long index)
-{
-       struct nfs_inode *nfsi = NFS_I(inode);
-       struct nfs_page *req;
-
-       req = (struct nfs_page*)radix_tree_lookup(&nfsi->nfs_page_tree, index);
-       if (req)
-               atomic_inc(&req->wb_count);
-       return req;
-}
-
-static struct nfs_page *
-nfs_find_request(struct inode *inode, unsigned long index)
-{
-       struct nfs_page         *req;
-       struct nfs_inode        *nfsi = NFS_I(inode);
-
-       spin_lock(&nfsi->req_lock);
-       req = _nfs_find_request(inode, index);
-       spin_unlock(&nfsi->req_lock);
-       return req;
-}
-
 /*
  * Add a request to the inode's dirty list.
  */
@@ -491,8 +440,14 @@ nfs_mark_request_dirty(struct nfs_page *req)
        nfs_list_add_request(req, &nfsi->dirty);
        nfsi->ndirty++;
        spin_unlock(&nfsi->req_lock);
-       inc_zone_page_state(req->wb_page, NR_FILE_DIRTY);
-       mark_inode_dirty(inode);
+       __mark_inode_dirty(inode, I_DIRTY_PAGES);
+}
+
+static void
+nfs_redirty_request(struct nfs_page *req)
+{
+       clear_bit(PG_FLUSHING, &req->wb_flags);
+       __set_page_dirty_nobuffers(req->wb_page);
 }
 
 /*
@@ -501,8 +456,7 @@ nfs_mark_request_dirty(struct nfs_page *req)
 static inline int
 nfs_dirty_request(struct nfs_page *req)
 {
-       struct nfs_inode *nfsi = NFS_I(req->wb_context->dentry->d_inode);
-       return !list_empty(&req->wb_list) && req->wb_list_head == &nfsi->dirty;
+       return test_bit(PG_FLUSHING, &req->wb_flags) == 0;
 }
 
 #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
@@ -520,7 +474,7 @@ nfs_mark_request_commit(struct nfs_page *req)
        nfsi->ncommit++;
        spin_unlock(&nfsi->req_lock);
        inc_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
-       mark_inode_dirty(inode);
+       __mark_inode_dirty(inode, I_DIRTY_DATASYNC);
 }
 #endif
 
@@ -597,31 +551,6 @@ static void nfs_cancel_commit_list(struct list_head *head)
        }
 }
 
-/*
- * nfs_scan_dirty - Scan an inode for dirty requests
- * @inode: NFS inode to scan
- * @dst: destination list
- * @idx_start: lower bound of page->index to scan.
- * @npages: idx_start + npages sets the upper bound to scan.
- *
- * Moves requests from the inode's dirty page list.
- * The requests are *not* checked to ensure that they form a contiguous set.
- */
-static int
-nfs_scan_dirty(struct inode *inode, struct list_head *dst, unsigned long idx_start, unsigned int npages)
-{
-       struct nfs_inode *nfsi = NFS_I(inode);
-       int res = 0;
-
-       if (nfsi->ndirty != 0) {
-               res = nfs_scan_lock_dirty(nfsi, dst, idx_start, npages);
-               nfsi->ndirty -= res;
-               if ((nfsi->ndirty == 0) != list_empty(&nfsi->dirty))
-                       printk(KERN_ERR "NFS: desynchronized value of nfs_i.ndirty.\n");
-       }
-       return res;
-}
-
 #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
 /*
  * nfs_scan_commit - Scan an inode for commit requests
@@ -698,27 +627,27 @@ static int nfs_wait_on_write_congestion(struct address_space *mapping, int intr)
  * Note: Should always be called with the Page Lock held!
  */
 static struct nfs_page * nfs_update_request(struct nfs_open_context* ctx,
-               struct inode *inode, struct page *page,
-               unsigned int offset, unsigned int bytes)
+               struct page *page, unsigned int offset, unsigned int bytes)
 {
-       struct nfs_server *server = NFS_SERVER(inode);
+       struct inode *inode = page->mapping->host;
        struct nfs_inode *nfsi = NFS_I(inode);
        struct nfs_page         *req, *new = NULL;
        unsigned long           rqend, end;
 
        end = offset + bytes;
 
-       if (nfs_wait_on_write_congestion(page->mapping, server->flags & NFS_MOUNT_INTR))
+       if (nfs_wait_on_write_congestion(page->mapping, NFS_SERVER(inode)->flags & NFS_MOUNT_INTR))
                return ERR_PTR(-ERESTARTSYS);
        for (;;) {
                /* Loop over all inode entries and see if we find
                 * A request for the page we wish to update
                 */
                spin_lock(&nfsi->req_lock);
-               req = _nfs_find_request(inode, page->index);
+               req = nfs_page_find_request_locked(page);
                if (req) {
                        if (!nfs_lock_request_dontget(req)) {
                                int error;
+
                                spin_unlock(&nfsi->req_lock);
                                error = nfs_wait_on_request(req);
                                nfs_release_request(req);
@@ -745,7 +674,6 @@ static struct nfs_page * nfs_update_request(struct nfs_open_context* ctx,
                                return ERR_PTR(error);
                        }
                        spin_unlock(&nfsi->req_lock);
-                       nfs_mark_request_dirty(new);
                        return new;
                }
                spin_unlock(&nfsi->req_lock);
@@ -786,9 +714,8 @@ static struct nfs_page * nfs_update_request(struct nfs_open_context* ctx,
 int nfs_flush_incompatible(struct file *file, struct page *page)
 {
        struct nfs_open_context *ctx = (struct nfs_open_context *)file->private_data;
-       struct inode    *inode = page->mapping->host;
        struct nfs_page *req;
-       int             status = 0;
+       int do_flush, status;
        /*
         * Look for a request corresponding to this page. If there
         * is one, and it belongs to another file, we flush it out
@@ -797,13 +724,18 @@ int nfs_flush_incompatible(struct file *file, struct page *page)
         * Also do the same if we find a request from an existing
         * dropped page.
         */
-       req = nfs_find_request(inode, page->index);
-       if (req) {
-               if (req->wb_page != page || ctx != req->wb_context)
-                       status = nfs_wb_page(inode, page);
+       do {
+               req = nfs_page_find_request(page);
+               if (req == NULL)
+                       return 0;
+               do_flush = req->wb_page != page || req->wb_context != ctx
+                       || !nfs_dirty_request(req);
                nfs_release_request(req);
-       }
-       return (status < 0) ? status : 0;
+               if (!do_flush)
+                       return 0;
+               status = nfs_wb_page(page->mapping->host, page);
+       } while (status == 0);
+       return status;
 }
 
 /*
@@ -817,72 +749,27 @@ int nfs_updatepage(struct file *file, struct page *page,
 {
        struct nfs_open_context *ctx = (struct nfs_open_context *)file->private_data;
        struct inode    *inode = page->mapping->host;
-       struct nfs_page *req;
        int             status = 0;
 
        nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE);
 
        dprintk("NFS:      nfs_updatepage(%s/%s %d@%Ld)\n",
-               file->f_dentry->d_parent->d_name.name,
-               file->f_dentry->d_name.name, count,
+               file->f_path.dentry->d_parent->d_name.name,
+               file->f_path.dentry->d_name.name, count,
                (long long)(page_offset(page) +offset));
 
-       if (IS_SYNC(inode)) {
-               status = nfs_writepage_sync(ctx, inode, page, offset, count, 0);
-               if (status > 0) {
-                       if (offset == 0 && status == PAGE_CACHE_SIZE)
-                               SetPageUptodate(page);
-                       return 0;
-               }
-               return status;
-       }
-
        /* If we're not using byte range locks, and we know the page
         * is entirely in cache, it may be more efficient to avoid
         * fragmenting write requests.
         */
        if (PageUptodate(page) && inode->i_flock == NULL && !(file->f_mode & O_SYNC)) {
-               loff_t end_offs = i_size_read(inode) - 1;
-               unsigned long end_index = end_offs >> PAGE_CACHE_SHIFT;
-
-               count += offset;
+               count = max(count + offset, nfs_page_length(page));
                offset = 0;
-               if (unlikely(end_offs < 0)) {
-                       /* Do nothing */
-               } else if (page->index == end_index) {
-                       unsigned int pglen;
-                       pglen = (unsigned int)(end_offs & (PAGE_CACHE_SIZE-1)) + 1;
-                       if (count < pglen)
-                               count = pglen;
-               } else if (page->index < end_index)
-                       count = PAGE_CACHE_SIZE;
        }
 
-       /*
-        * Try to find an NFS request corresponding to this page
-        * and update it.
-        * If the existing request cannot be updated, we must flush
-        * it out now.
-        */
-       do {
-               req = nfs_update_request(ctx, inode, page, offset, count);
-               status = (IS_ERR(req)) ? PTR_ERR(req) : 0;
-               if (status != -EBUSY)
-                       break;
-               /* Request could not be updated. Flush it out and try again */
-               status = nfs_wb_page(inode, page);
-       } while (status >= 0);
-       if (status < 0)
-               goto done;
-
-       status = 0;
+       status = nfs_writepage_setup(ctx, page, offset, count);
+       __set_page_dirty_nobuffers(page);
 
-       /* Update file length */
-       nfs_grow_file(page, offset, count);
-       /* Set the PG_uptodate flag? */
-       nfs_mark_uptodate(page, req->wb_pgbase, req->wb_bytes);
-       nfs_unlock_request(req);
-done:
         dprintk("NFS:      nfs_updatepage returns %d (isize %Ld)\n",
                        status, (long long)i_size_read(inode));
        if (status < 0)
@@ -897,7 +784,7 @@ static void nfs_writepage_release(struct nfs_page *req)
 #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
        if (!PageError(req->wb_page)) {
                if (NFS_NEED_RESCHED(req)) {
-                       nfs_mark_request_dirty(req);
+                       nfs_redirty_request(req);
                        goto out;
                } else if (NFS_NEED_COMMIT(req)) {
                        nfs_mark_request_commit(req);
@@ -979,9 +866,7 @@ static void nfs_execute_write(struct nfs_write_data *data)
        sigset_t oldset;
 
        rpc_clnt_sigmask(clnt, &oldset);
-       lock_kernel();
        rpc_execute(&data->task);
-       unlock_kernel();
        rpc_clnt_sigunmask(clnt, &oldset);
 }
 
@@ -1015,7 +900,6 @@ static int nfs_flush_multi(struct inode *inode, struct list_head *head, int how)
        atomic_set(&req->wb_complete, requests);
 
        ClearPageError(page);
-       set_page_writeback(page);
        offset = 0;
        nbytes = req->wb_bytes;
        do {
@@ -1043,9 +927,9 @@ out_bad:
        while (!list_empty(&list)) {
                data = list_entry(list.next, struct nfs_write_data, pages);
                list_del(&data->pages);
-               nfs_writedata_free(data);
+               nfs_writedata_release(data);
        }
-       nfs_mark_request_dirty(req);
+       nfs_redirty_request(req);
        nfs_clear_page_writeback(req);
        return -ENOMEM;
 }
@@ -1076,7 +960,6 @@ static int nfs_flush_one(struct inode *inode, struct list_head *head, int how)
                nfs_list_remove_request(req);
                nfs_list_add_request(req, &data->pages);
                ClearPageError(req->wb_page);
-               set_page_writeback(req->wb_page);
                *pages++ = req->wb_page;
                count += req->wb_bytes;
        }
@@ -1091,7 +974,7 @@ static int nfs_flush_one(struct inode *inode, struct list_head *head, int how)
        while (!list_empty(head)) {
                struct nfs_page *req = nfs_list_entry(head->next);
                nfs_list_remove_request(req);
-               nfs_mark_request_dirty(req);
+               nfs_redirty_request(req);
                nfs_clear_page_writeback(req);
        }
        return -ENOMEM;
@@ -1126,7 +1009,7 @@ out_err:
        while (!list_empty(head)) {
                req = nfs_list_entry(head->next);
                nfs_list_remove_request(req);
-               nfs_mark_request_dirty(req);
+               nfs_redirty_request(req);
                nfs_clear_page_writeback(req);
        }
        return error;
@@ -1442,7 +1325,7 @@ static void nfs_commit_done(struct rpc_task *task, void *calldata)
                }
                /* We have a mismatch. Write the page again */
                dprintk(" mismatch\n");
-               nfs_mark_request_dirty(req);
+               nfs_redirty_request(req);
        next:
                nfs_clear_page_writeback(req);
        }
@@ -1459,18 +1342,17 @@ static inline int nfs_commit_list(struct inode *inode, struct list_head *head, i
 }
 #endif
 
-static int nfs_flush_inode(struct inode *inode, unsigned long idx_start,
-                          unsigned int npages, int how)
+static long nfs_flush_mapping(struct address_space *mapping, struct writeback_control *wbc, int how)
 {
-       struct nfs_inode *nfsi = NFS_I(inode);
+       struct nfs_inode *nfsi = NFS_I(mapping->host);
        LIST_HEAD(head);
-       int res;
+       long res;
 
        spin_lock(&nfsi->req_lock);
-       res = nfs_scan_dirty(inode, &head, idx_start, npages);
+       res = nfs_scan_dirty(mapping, wbc, &head);
        spin_unlock(&nfsi->req_lock);
        if (res) {
-               int error = nfs_flush_list(inode, &head, res, how);
+               int error = nfs_flush_list(mapping->host, &head, res, how);
                if (error < 0)
                        return error;
        }
@@ -1496,38 +1378,62 @@ int nfs_commit_inode(struct inode *inode, int how)
 }
 #endif
 
-int nfs_sync_inode_wait(struct inode *inode, unsigned long idx_start,
-               unsigned int npages, int how)
+long nfs_sync_mapping_wait(struct address_space *mapping, struct writeback_control *wbc, int how)
 {
+       struct inode *inode = mapping->host;
        struct nfs_inode *nfsi = NFS_I(inode);
+       unsigned long idx_start, idx_end;
+       unsigned int npages = 0;
        LIST_HEAD(head);
        int nocommit = how & FLUSH_NOCOMMIT;
-       int pages, ret;
-
+       long pages, ret;
+
+       /* FIXME */
+       if (wbc->range_cyclic)
+               idx_start = 0;
+       else {
+               idx_start = wbc->range_start >> PAGE_CACHE_SHIFT;
+               idx_end = wbc->range_end >> PAGE_CACHE_SHIFT;
+               if (idx_end > idx_start) {
+                       unsigned long l_npages = 1 + idx_end - idx_start;
+                       npages = l_npages;
+                       if (sizeof(npages) != sizeof(l_npages) &&
+                                       (unsigned long)npages != l_npages)
+                               npages = 0;
+               }
+       }
        how &= ~FLUSH_NOCOMMIT;
        spin_lock(&nfsi->req_lock);
        do {
+               wbc->pages_skipped = 0;
                ret = nfs_wait_on_requests_locked(inode, idx_start, npages);
                if (ret != 0)
                        continue;
-               pages = nfs_scan_dirty(inode, &head, idx_start, npages);
+               pages = nfs_scan_dirty(mapping, wbc, &head);
                if (pages != 0) {
                        spin_unlock(&nfsi->req_lock);
-                       if (how & FLUSH_INVALIDATE)
+                       if (how & FLUSH_INVALIDATE) {
                                nfs_cancel_dirty_list(&head);
-                       else
+                               ret = pages;
+                       } else
                                ret = nfs_flush_list(inode, &head, pages, how);
                        spin_lock(&nfsi->req_lock);
                        continue;
                }
+               if (wbc->pages_skipped != 0)
+                       continue;
                if (nocommit)
                        break;
                pages = nfs_scan_commit(inode, &head, idx_start, npages);
-               if (pages == 0)
+               if (pages == 0) {
+                       if (wbc->pages_skipped != 0)
+                               continue;
                        break;
+               }
                if (how & FLUSH_INVALIDATE) {
                        spin_unlock(&nfsi->req_lock);
                        nfs_cancel_commit_list(&head);
+                       ret = pages;
                        spin_lock(&nfsi->req_lock);
                        continue;
                }
@@ -1540,6 +1446,106 @@ int nfs_sync_inode_wait(struct inode *inode, unsigned long idx_start,
        return ret;
 }
 
+/*
+ * flush the inode to disk.
+ */
+int nfs_wb_all(struct inode *inode)
+{
+       struct address_space *mapping = inode->i_mapping;
+       struct writeback_control wbc = {
+               .bdi = mapping->backing_dev_info,
+               .sync_mode = WB_SYNC_ALL,
+               .nr_to_write = LONG_MAX,
+               .for_writepages = 1,
+               .range_cyclic = 1,
+       };
+       int ret;
+
+       ret = generic_writepages(mapping, &wbc);
+       if (ret < 0)
+               goto out;
+       ret = nfs_sync_mapping_wait(mapping, &wbc, 0);
+       if (ret >= 0)
+               return 0;
+out:
+       __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
+       return ret;
+}
+
+int nfs_sync_mapping_range(struct address_space *mapping, loff_t range_start, loff_t range_end, int how)
+{
+       struct writeback_control wbc = {
+               .bdi = mapping->backing_dev_info,
+               .sync_mode = WB_SYNC_ALL,
+               .nr_to_write = LONG_MAX,
+               .range_start = range_start,
+               .range_end = range_end,
+               .for_writepages = 1,
+       };
+       int ret;
+
+       if (!(how & FLUSH_NOWRITEPAGE)) {
+               ret = generic_writepages(mapping, &wbc);
+               if (ret < 0)
+                       goto out;
+       }
+       ret = nfs_sync_mapping_wait(mapping, &wbc, how);
+       if (ret >= 0)
+               return 0;
+out:
+       __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
+       return ret;
+}
+
+int nfs_wb_page_priority(struct inode *inode, struct page *page, int how)
+{
+       loff_t range_start = page_offset(page);
+       loff_t range_end = range_start + (loff_t)(PAGE_CACHE_SIZE - 1);
+       struct writeback_control wbc = {
+               .bdi = page->mapping->backing_dev_info,
+               .sync_mode = WB_SYNC_ALL,
+               .nr_to_write = LONG_MAX,
+               .range_start = range_start,
+               .range_end = range_end,
+       };
+       int ret;
+
+       BUG_ON(!PageLocked(page));
+       if (!(how & FLUSH_NOWRITEPAGE) && clear_page_dirty_for_io(page)) {
+               ret = nfs_writepage_locked(page, &wbc);
+               if (ret < 0)
+                       goto out;
+       }
+       ret = nfs_sync_mapping_wait(page->mapping, &wbc, how);
+       if (ret >= 0)
+               return 0;
+out:
+       __mark_inode_dirty(inode, I_DIRTY_PAGES);
+       return ret;
+}
+
+/*
+ * Write back all requests on one page - we do this before reading it.
+ */
+int nfs_wb_page(struct inode *inode, struct page* page)
+{
+       return nfs_wb_page_priority(inode, page, FLUSH_STABLE);
+}
+
+int nfs_set_page_dirty(struct page *page)
+{
+       struct nfs_page *req;
+
+       req = nfs_page_find_request(page);
+       if (req != NULL) {
+               /* Mark any existing write requests for flushing */
+               set_bit(PG_NEED_FLUSH, &req->wb_flags);
+               nfs_release_request(req);
+       }
+       return __set_page_dirty_nobuffers(page);
+}
+
+
 int __init nfs_init_writepagecache(void)
 {
        nfs_wdata_cachep = kmem_cache_create("nfs_write_data",
index e3eca0816986fd2b6410f020ad9919c2b5f9e5e4..edde5dc5f796687c84d7ae2dec0140e3e9a453ad 100644 (file)
@@ -222,12 +222,10 @@ static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p,
 {
        struct dentry *dentry = resp->fh.fh_dentry;
        struct inode *inode = dentry->d_inode;
-       int w = nfsacl_size(
-               (resp->mask & NFS_ACL)   ? resp->acl_access  : NULL,
-               (resp->mask & NFS_DFACL) ? resp->acl_default : NULL);
        struct kvec *head = rqstp->rq_res.head;
        unsigned int base;
        int n;
+       int w;
 
        if (dentry == NULL || dentry->d_inode == NULL)
                return 0;
@@ -239,7 +237,9 @@ static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p,
                return 0;
        base = (char *)p - (char *)head->iov_base;
 
-       rqstp->rq_res.page_len = w;
+       rqstp->rq_res.page_len = w = nfsacl_size(
+               (resp->mask & NFS_ACL)   ? resp->acl_access  : NULL,
+               (resp->mask & NFS_DFACL) ? resp->acl_default : NULL);
        while (w > 0) {
                if (!rqstp->rq_respages[rqstp->rq_resused++])
                        return 0;
index fcad2895ddb00dd288fb07618c1047d919b75076..3e3f2de82c36bc4586789c79ca1a30aeb5272626 100644 (file)
@@ -171,19 +171,19 @@ static int nfs3svc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p,
        p = nfs3svc_encode_post_op_attr(rqstp, p, &resp->fh);
        if (resp->status == 0 && dentry && dentry->d_inode) {
                struct inode *inode = dentry->d_inode;
-               int w = nfsacl_size(
-                       (resp->mask & NFS_ACL)   ? resp->acl_access  : NULL,
-                       (resp->mask & NFS_DFACL) ? resp->acl_default : NULL);
                struct kvec *head = rqstp->rq_res.head;
                unsigned int base;
                int n;
+               int w;
 
                *p++ = htonl(resp->mask);
                if (!xdr_ressize_check(rqstp, p))
                        return 0;
                base = (char *)p - (char *)head->iov_base;
 
-               rqstp->rq_res.page_len = w;
+               rqstp->rq_res.page_len = w = nfsacl_size(
+                       (resp->mask & NFS_ACL)   ? resp->acl_access  : NULL,
+                       (resp->mask & NFS_DFACL) ? resp->acl_default : NULL);
                while (w > 0) {
                        if (!rqstp->rq_respages[rqstp->rq_resused++])
                                return 0;
index b4baca3053c35a96b526107096f1864e349848f6..277df40f098de5038b7a62cb7cca1ca138a7e12c 100644 (file)
 
 #define NFSDDBG_FACILITY               NFSDDBG_XDR
 
-#ifdef NFSD_OPTIMIZE_SPACE
-# define inline
-#endif
-
 
 /*
  * Mapping of S_IF* types to NFS file types
@@ -42,14 +38,14 @@ static u32  nfs3_ftypes[] = {
 /*
  * XDR functions for basic NFS types
  */
-static inline __be32 *
+static __be32 *
 encode_time3(__be32 *p, struct timespec *time)
 {
        *p++ = htonl((u32) time->tv_sec); *p++ = htonl(time->tv_nsec);
        return p;
 }
 
-static inline __be32 *
+static __be32 *
 decode_time3(__be32 *p, struct timespec *time)
 {
        time->tv_sec = ntohl(*p++);
@@ -57,7 +53,7 @@ decode_time3(__be32 *p, struct timespec *time)
        return p;
 }
 
-static inline __be32 *
+static __be32 *
 decode_fh(__be32 *p, struct svc_fh *fhp)
 {
        unsigned int size;
@@ -77,7 +73,7 @@ __be32 *nfs3svc_decode_fh(__be32 *p, struct svc_fh *fhp)
        return decode_fh(p, fhp);
 }
 
-static inline __be32 *
+static __be32 *
 encode_fh(__be32 *p, struct svc_fh *fhp)
 {
        unsigned int size = fhp->fh_handle.fh_size;
@@ -91,7 +87,7 @@ encode_fh(__be32 *p, struct svc_fh *fhp)
  * Decode a file name and make sure that the path contains
  * no slashes or null bytes.
  */
-static inline __be32 *
+static __be32 *
 decode_filename(__be32 *p, char **namp, int *lenp)
 {
        char            *name;
@@ -107,7 +103,7 @@ decode_filename(__be32 *p, char **namp, int *lenp)
        return p;
 }
 
-static inline __be32 *
+static __be32 *
 decode_sattr3(__be32 *p, struct iattr *iap)
 {
        u32     tmp;
@@ -153,7 +149,7 @@ decode_sattr3(__be32 *p, struct iattr *iap)
        return p;
 }
 
-static inline __be32 *
+static __be32 *
 encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
              struct kstat *stat)
 {
@@ -186,7 +182,7 @@ encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
        return p;
 }
 
-static inline __be32 *
+static __be32 *
 encode_saved_post_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
 {
        struct inode    *inode = fhp->fh_dentry->d_inode;
@@ -776,7 +772,7 @@ nfs3svc_encode_readdirres(struct svc_rqst *rqstp, __be32 *p,
                return xdr_ressize_check(rqstp, p);
 }
 
-static inline __be32 *
+static __be32 *
 encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name,
             int namlen, ino_t ino)
 {
@@ -790,7 +786,7 @@ encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name,
        return p;
 }
 
-static inline __be32 *
+static __be32 *
 encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p,
                struct svc_fh *fhp)
 {
index 81b8565d3837a58137c1c589905e294f0bbb2ccd..c7774e3a9469fc9c3bfbc5ee7a011ec957ac2160 100644 (file)
@@ -259,7 +259,7 @@ nfsd4_remove_clid_file(struct dentry *dir, struct dentry *dentry)
                printk("nfsd4: non-file found in client recovery directory\n");
                return -EINVAL;
        }
-       mutex_lock(&dir->d_inode->i_mutex);
+       mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
        status = vfs_unlink(dir->d_inode, dentry);
        mutex_unlock(&dir->d_inode->i_mutex);
        return status;
index e431e93ab503ad7dbc2ab7ca398a1627476a78c4..b7179bd45a1e959280b24f9199367050478a9ada 100644 (file)
@@ -84,10 +84,10 @@ static void nfs4_set_recdir(char *recdir);
  */
 static DEFINE_MUTEX(client_mutex);
 
-static kmem_cache_t *stateowner_slab = NULL;
-static kmem_cache_t *file_slab = NULL;
-static kmem_cache_t *stateid_slab = NULL;
-static kmem_cache_t *deleg_slab = NULL;
+static struct kmem_cache *stateowner_slab = NULL;
+static struct kmem_cache *file_slab = NULL;
+static struct kmem_cache *stateid_slab = NULL;
+static struct kmem_cache *deleg_slab = NULL;
 
 void
 nfs4_lock_state(void)
@@ -1003,7 +1003,7 @@ alloc_init_file(struct inode *ino)
 }
 
 static void
-nfsd4_free_slab(kmem_cache_t **slab)
+nfsd4_free_slab(struct kmem_cache **slab)
 {
        if (*slab == NULL)
                return;
@@ -1310,7 +1310,7 @@ static inline void
 nfs4_file_downgrade(struct file *filp, unsigned int share_access)
 {
        if (share_access & NFS4_SHARE_ACCESS_WRITE) {
-               put_write_access(filp->f_dentry->d_inode);
+               put_write_access(filp->f_path.dentry->d_inode);
                filp->f_mode = (filp->f_mode | FMODE_READ) & ~FMODE_WRITE;
        }
 }
@@ -1623,7 +1623,7 @@ static __be32
 nfs4_upgrade_open(struct svc_rqst *rqstp, struct svc_fh *cur_fh, struct nfs4_stateid *stp, struct nfsd4_open *open)
 {
        struct file *filp = stp->st_vfs_file;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        unsigned int share_access, new_writer;
        __be32 status;
 
@@ -1965,7 +1965,7 @@ search_close_lru(u32 st_id, int flags)
 static inline int
 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stateid *stp)
 {
-       return fhp->fh_dentry->d_inode != stp->st_vfs_file->f_dentry->d_inode;
+       return fhp->fh_dentry->d_inode != stp->st_vfs_file->f_path.dentry->d_inode;
 }
 
 static int
@@ -2862,7 +2862,7 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
         * only the dentry:inode set.
         */
        memset(&file, 0, sizeof (struct file));
-       file.f_dentry = current_fh->fh_dentry;
+       file.f_path.dentry = current_fh->fh_dentry;
 
        status = nfs_ok;
        if (posix_test_lock(&file, &file_lock, &conflock)) {
@@ -2952,7 +2952,7 @@ static int
 check_for_locks(struct file *filp, struct nfs4_stateowner *lowner)
 {
        struct file_lock **flpp;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        int status = 0;
 
        lock_kernel();
index 6100bbe27432d6b6f826733a47b3a87dfdbc3041..f90d70475854f5b85f2f20a5bc61a1821a6cae37 100644 (file)
@@ -66,14 +66,13 @@ nfsd_cache_init(void)
                printk (KERN_ERR "nfsd: cannot allocate all %d cache entries, only got %d\n",
                        CACHESIZE, CACHESIZE-i);
 
-       hash_list = kmalloc (HASHSIZE * sizeof(struct hlist_head), GFP_KERNEL);
+       hash_list = kcalloc (HASHSIZE, sizeof(struct hlist_head), GFP_KERNEL);
        if (!hash_list) {
                nfsd_cache_shutdown();
                printk (KERN_ERR "nfsd: cannot allocate %Zd bytes for hash list\n",
                        HASHSIZE * sizeof(struct hlist_head));
                return;
        }
-       memset(hash_list, 0, HASHSIZE * sizeof(struct hlist_head));
 
        cache_disabled = 0;
 }
index 39aed901514b0c34d30cb468b1a8aabadc33b2e8..eedf2e3990a9a8f3d0bdad85faa119f4eef4ef97 100644 (file)
@@ -111,7 +111,7 @@ static ssize_t (*write_op[])(struct file *, char *, size_t) = {
 
 static ssize_t nfsctl_transaction_write(struct file *file, const char __user *buf, size_t size, loff_t *pos)
 {
-       ino_t ino =  file->f_dentry->d_inode->i_ino;
+       ino_t ino =  file->f_path.dentry->d_inode->i_ino;
        char *data;
        ssize_t rv;
 
index 56ebb1443e0eb7bf067a773690dee36a1d60f2ee..f5243f943996030896b9dc4280b7b5f550252fec 100644 (file)
 
 #define NFSDDBG_FACILITY               NFSDDBG_XDR
 
-
-#ifdef NFSD_OPTIMIZE_SPACE
-# define inline
-#endif
-
 /*
  * Mapping of S_IF* types to NFS file types
  */
@@ -55,7 +50,7 @@ __be32 *nfs2svc_decode_fh(__be32 *p, struct svc_fh *fhp)
        return decode_fh(p, fhp);
 }
 
-static inline __be32 *
+static __be32 *
 encode_fh(__be32 *p, struct svc_fh *fhp)
 {
        memcpy(p, &fhp->fh_handle.fh_base, NFS_FHSIZE);
@@ -66,7 +61,7 @@ encode_fh(__be32 *p, struct svc_fh *fhp)
  * Decode a file name and make sure that the path contains
  * no slashes or null bytes.
  */
-static inline __be32 *
+static __be32 *
 decode_filename(__be32 *p, char **namp, int *lenp)
 {
        char            *name;
@@ -82,7 +77,7 @@ decode_filename(__be32 *p, char **namp, int *lenp)
        return p;
 }
 
-static inline __be32 *
+static __be32 *
 decode_pathname(__be32 *p, char **namp, int *lenp)
 {
        char            *name;
@@ -98,7 +93,7 @@ decode_pathname(__be32 *p, char **namp, int *lenp)
        return p;
 }
 
-static inline __be32 *
+static __be32 *
 decode_sattr(__be32 *p, struct iattr *iap)
 {
        u32     tmp, tmp1;
index bb4d926e4487dd60f1f9a72b3b06c9bb2d496848..4883d758622983cab8fc870d4bddf7ba67491971 100644 (file)
@@ -736,10 +736,10 @@ static int
 nfsd_sync(struct file *filp)
 {
         int err;
-       struct inode *inode = filp->f_dentry->d_inode;
-       dprintk("nfsd: sync file %s\n", filp->f_dentry->d_name.name);
+       struct inode *inode = filp->f_path.dentry->d_inode;
+       dprintk("nfsd: sync file %s\n", filp->f_path.dentry->d_name.name);
        mutex_lock(&inode->i_mutex);
-       err=nfsd_dosync(filp, filp->f_dentry, filp->f_op);
+       err=nfsd_dosync(filp, filp->f_path.dentry, filp->f_op);
        mutex_unlock(&inode->i_mutex);
 
        return err;
@@ -845,7 +845,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
        int             host_err;
 
        err = nfserr_perm;
-       inode = file->f_dentry->d_inode;
+       inode = file->f_path.dentry->d_inode;
 #ifdef MSNFS
        if ((fhp->fh_export->ex_flags & NFSEXP_MSNFS) &&
                (!lock_may_read(inode, offset, *count)))
@@ -883,7 +883,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
                nfsdstats.io_read += host_err;
                *count = host_err;
                err = 0;
-               fsnotify_access(file->f_dentry);
+               fsnotify_access(file->f_path.dentry);
        } else 
                err = nfserrno(host_err);
 out:
@@ -917,11 +917,11 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
        err = nfserr_perm;
 
        if ((fhp->fh_export->ex_flags & NFSEXP_MSNFS) &&
-               (!lock_may_write(file->f_dentry->d_inode, offset, cnt)))
+               (!lock_may_write(file->f_path.dentry->d_inode, offset, cnt)))
                goto out;
 #endif
 
-       dentry = file->f_dentry;
+       dentry = file->f_path.dentry;
        inode = dentry->d_inode;
        exp   = fhp->fh_export;
 
@@ -950,7 +950,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
        set_fs(oldfs);
        if (host_err >= 0) {
                nfsdstats.io_write += cnt;
-               fsnotify_modify(file->f_dentry);
+               fsnotify_modify(file->f_path.dentry);
        }
 
        /* clear setuid/setgid flag after write */
@@ -1885,28 +1885,27 @@ nfsd_racache_init(int cache_size)
                return 0;
        if (cache_size < 2*RAPARM_HASH_SIZE)
                cache_size = 2*RAPARM_HASH_SIZE;
-       raparml = kmalloc(sizeof(struct raparms) * cache_size, GFP_KERNEL);
-
-       if (raparml != NULL) {
-               dprintk("nfsd: allocating %d readahead buffers.\n",
-                       cache_size);
-               for (i = 0 ; i < RAPARM_HASH_SIZE ; i++) {
-                       raparm_hash[i].pb_head = NULL;
-                       spin_lock_init(&raparm_hash[i].pb_lock);
-               }
-               nperbucket = cache_size >> RAPARM_HASH_BITS;
-               memset(raparml, 0, sizeof(struct raparms) * cache_size);
-               for (i = 0; i < cache_size - 1; i++) {
-                       if (i % nperbucket == 0)
-                               raparm_hash[j++].pb_head = raparml + i;
-                       if (i % nperbucket < nperbucket-1)
-                               raparml[i].p_next = raparml + i + 1;
-               }
-       } else {
+       raparml = kcalloc(cache_size, sizeof(struct raparms), GFP_KERNEL);
+
+       if (!raparml) {
                printk(KERN_WARNING
-                      "nfsd: Could not allocate memory read-ahead cache.\n");
+                       "nfsd: Could not allocate memory read-ahead cache.\n");
                return -ENOMEM;
        }
+
+       dprintk("nfsd: allocating %d readahead buffers.\n", cache_size);
+       for (i = 0 ; i < RAPARM_HASH_SIZE ; i++) {
+               raparm_hash[i].pb_head = NULL;
+               spin_lock_init(&raparm_hash[i].pb_lock);
+       }
+       nperbucket = cache_size >> RAPARM_HASH_BITS;
+       for (i = 0; i < cache_size - 1; i++) {
+               if (i % nperbucket == 0)
+                       raparm_hash[j++].pb_head = raparml + i;
+               if (i % nperbucket < nperbucket-1)
+                       raparml[i].p_next = raparml + i + 1;
+       }
+
        nfsdstats.ra_size = cache_size;
        return 0;
 }
index 046fde8170eaf50038d907602106409b3dd104b0..65e640c61c8bb29f1b879d4d3898b3939462cfdc 100644 (file)
@@ -4421,6 +4421,73 @@ static wchar_t *page_charset2uni[256] = {
        c2u_F8, c2u_F9, c2u_FA, c2u_FB, c2u_FC, c2u_FD, c2u_FE, NULL,   
 };
 
+static unsigned char u2c_00[512] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0B */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0C-0x0F */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x13 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x14-0x17 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1B */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1C-0x1F */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x23 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x24-0x27 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2B */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2C-0x2F */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x33 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x34-0x37 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3B */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3C-0x3F */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x43 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x44-0x47 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4B */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x4C-0x4F */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x53 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x54-0x57 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5B */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x5C-0x5F */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x63 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x64-0x67 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6B */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x6C-0x6F */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x73 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x74-0x77 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7B */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x7C-0x7F */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x83 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x84-0x87 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8B */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x8C-0x8F */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x93 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x94-0x97 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9B */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x9C-0x9F */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA0-0xA3 */
+       0xA1, 0xE8, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xEC, /* 0xA4-0xA7 */
+       0xA1, 0xA7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA8-0xAB */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xAC-0xAF */
+       0xA1, 0xE3, 0xA1, 0xC0, 0x00, 0x00, 0x00, 0x00, /* 0xB0-0xB3 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xA4, /* 0xB4-0xB7 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB8-0xBB */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xBC-0xBF */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC0-0xC3 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC4-0xC7 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC8-0xCB */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xCC-0xCF */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xD0-0xD3 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xC1, /* 0xD4-0xD7 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xD8-0xDB */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xDC-0xDF */
+       0xA8, 0xA4, 0xA8, 0xA2, 0x00, 0x00, 0x00, 0x00, /* 0xE0-0xE3 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xE4-0xE7 */
+       0xA8, 0xA8, 0xA8, 0xA6, 0xA8, 0xBA, 0x00, 0x00, /* 0xE8-0xEB */
+       0xA8, 0xAC, 0xA8, 0xAA, 0x00, 0x00, 0x00, 0x00, /* 0xEC-0xEF */
+       0x00, 0x00, 0x00, 0x00, 0xA8, 0xB0, 0xA8, 0xAE, /* 0xF0-0xF3 */
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xC2, /* 0xF4-0xF7 */
+       0x00, 0x00, 0xA8, 0xB4, 0xA8, 0xB2, 0x00, 0x00, /* 0xF8-0xFB */
+       0xA8, 0xB9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xFC-0xFF */
+};
+
 static unsigned char u2c_01[512] = {
        0xA8, 0xA1, 0xA8, 0xA1, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */
@@ -10825,7 +10892,7 @@ static unsigned char u2c_FF[512] = {
 };
 
 static unsigned char *page_uni2charset[256] = {
-       NULL,   u2c_01, u2c_02, u2c_03, u2c_04, NULL,   NULL,   NULL,   
+       u2c_00, u2c_01, u2c_02, u2c_03, u2c_04, NULL,   NULL,   NULL,
        NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
        NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
        NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
@@ -10936,11 +11003,34 @@ static int uni2char(const wchar_t uni,
        unsigned char *uni2charset;
        unsigned char cl = uni&0xFF;
        unsigned char ch = (uni>>8)&0xFF;
-       int n;
+       unsigned char out0,out1;
 
        if (boundlen <= 0)
                return -ENAMETOOLONG;
 
+       if (uni == 0x20ac) {/* Euro symbol.The only exception with a non-ascii unicode */
+               out[0] = 0x80;
+               return 1;
+       }
+
+       if (ch == 0) { /* handle the U00 plane*/
+               /* if (cl == 0) return -EINVAL;*/ /*U0000 is legal in cp936*/
+               out0 = u2c_00[cl*2];
+               out1 = u2c_00[cl*2+1];
+               if (out0 == 0x00 && out1 == 0x00) {
+                       if (cl<0x80) {
+                               out[0] = cl;
+                               return 1;
+                       }
+                       return -EINVAL;
+               } else {
+                       if (boundlen <= 1)
+                               return -ENAMETOOLONG;
+                       out[0] = out0;
+                       out[1] = out1;
+                       return 2;
+               }
+       }
 
        uni2charset = page_uni2charset[ch];
        if (uni2charset) {
@@ -10950,15 +11040,10 @@ static int uni2char(const wchar_t uni,
                out[1] = uni2charset[cl*2+1];
                if (out[0] == 0x00 && out[1] == 0x00)
                        return -EINVAL;
-               n = 2;
-       } else if (ch==0 && cl) {
-               out[0] = cl;
-               n = 1;
+               return 2;
        }
        else
                return -EINVAL;
-
-       return n;
 }
 
 static int char2uni(const unsigned char *rawstring, int boundlen,
@@ -10972,7 +11057,11 @@ static int char2uni(const unsigned char *rawstring, int boundlen,
                return -ENAMETOOLONG;
 
        if (boundlen == 1) {
-               *uni = rawstring[0];
+               if (rawstring[0]==0x80) { /* Euro symbol.The only exception with a non-ascii unicode */
+                       *uni = 0x20ac;
+               } else {
+                       *uni = rawstring[0];
+               }
                return 1;
        }
 
@@ -10986,7 +11075,11 @@ static int char2uni(const unsigned char *rawstring, int boundlen,
                        return -EINVAL;
                n = 2;
        } else{
-               *uni = ch;
+               if (ch==0x80) {/* Euro symbol.The only exception with a non-ascii unicode */
+                       *uni = 0x20ac;
+               } else {
+                       *uni = ch;
+               }
                n = 1;
        }
        return n;
index 9f08e851cfb69ed9373344b7865b42b747451d0f..c577d8e1bd95d530604386e293f4ec5dd3884ce9 100644 (file)
@@ -1272,7 +1272,7 @@ ntfs_attr_search_ctx *ntfs_attr_get_search_ctx(ntfs_inode *ni, MFT_RECORD *mrec)
 {
        ntfs_attr_search_ctx *ctx;
 
-       ctx = kmem_cache_alloc(ntfs_attr_ctx_cache, SLAB_NOFS);
+       ctx = kmem_cache_alloc(ntfs_attr_ctx_cache, GFP_NOFS);
        if (ctx)
                ntfs_attr_init_search_ctx(ctx, ni, mrec);
        return ctx;
index 85c36b8ca452e828493fac9a2170f474e1b7e552..8296c29ae3b8394719bff4ceead2fa81dfd6001b 100644 (file)
@@ -1101,7 +1101,7 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
        s64 ia_pos, ia_start, prev_ia_pos, bmp_pos;
        loff_t fpos, i_size;
-       struct inode *bmp_vi, *vdir = filp->f_dentry->d_inode;
+       struct inode *bmp_vi, *vdir = filp->f_path.dentry->d_inode;
        struct super_block *sb = vdir->i_sb;
        ntfs_inode *ndir = NTFS_I(vdir);
        ntfs_volume *vol = NTFS_SB(sb);
@@ -1136,9 +1136,9 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
        if (fpos == 1) {
                ntfs_debug("Calling filldir for .. with len 2, fpos 0x1, "
                                "inode 0x%lx, DT_DIR.",
-                               (unsigned long)parent_ino(filp->f_dentry));
+                               (unsigned long)parent_ino(filp->f_path.dentry));
                rc = filldir(dirent, "..", 2, fpos,
-                               parent_ino(filp->f_dentry), DT_DIR);
+                               parent_ino(filp->f_path.dentry), DT_DIR);
                if (rc)
                        goto done;
                fpos++;
index ae2fe0016d2c7be63adf1029f878b798fa1af7b6..076c9420c257dc6d0e8842135d7a87f6dcc74a61 100644 (file)
@@ -2162,7 +2162,7 @@ static ssize_t ntfs_file_aio_write_nolock(struct kiocb *iocb,
                goto out;
        if (!count)
                goto out;
-       err = remove_suid(file->f_dentry);
+       err = remove_suid(file->f_path.dentry);
        if (err)
                goto out;
        file_update_time(file);
index e32cde486362bb21976d271fb02892effbeb2460..2194eff4974379062c1d19578228766555da2519 100644 (file)
@@ -38,7 +38,7 @@ ntfs_index_context *ntfs_index_ctx_get(ntfs_inode *idx_ni)
 {
        ntfs_index_context *ictx;
 
-       ictx = kmem_cache_alloc(ntfs_index_ctx_cache, SLAB_NOFS);
+       ictx = kmem_cache_alloc(ntfs_index_ctx_cache, GFP_NOFS);
        if (ictx)
                *ictx = (ntfs_index_context){ .idx_ni = idx_ni };
        return ictx;
index 2d3de9c89818033a0c96f1a9f43afeb84132a285..247989891b4b6e45cd9f20548a91d202c1cea82e 100644 (file)
@@ -324,7 +324,7 @@ struct inode *ntfs_alloc_big_inode(struct super_block *sb)
        ntfs_inode *ni;
 
        ntfs_debug("Entering.");
-       ni = kmem_cache_alloc(ntfs_big_inode_cache, SLAB_NOFS);
+       ni = kmem_cache_alloc(ntfs_big_inode_cache, GFP_NOFS);
        if (likely(ni != NULL)) {
                ni->state = 0;
                return VFS_I(ni);
@@ -349,7 +349,7 @@ static inline ntfs_inode *ntfs_alloc_extent_inode(void)
        ntfs_inode *ni;
 
        ntfs_debug("Entering.");
-       ni = kmem_cache_alloc(ntfs_inode_cache, SLAB_NOFS);
+       ni = kmem_cache_alloc(ntfs_inode_cache, GFP_NOFS);
        if (likely(ni != NULL)) {
                ni->state = 0;
                return ni;
index 6a495f7369f9e7fbd170d0802014f4d750d6c6ae..005ca4b0f132fc1e4515a5f5b9e5e7d1acd26726 100644 (file)
@@ -266,7 +266,7 @@ int ntfs_nlstoucs(const ntfs_volume *vol, const char *ins,
 
        /* We do not trust outside sources. */
        if (likely(ins)) {
-               ucs = kmem_cache_alloc(ntfs_name_cache, SLAB_NOFS);
+               ucs = kmem_cache_alloc(ntfs_name_cache, GFP_NOFS);
                if (likely(ucs)) {
                        for (i = o = 0; i < ins_len; i += wc_len) {
                                wc_len = nls->char2uni(ins + i, ins_len - i,
index 2f7268e81520dbc0fdabc3155189459a0db67356..ef6cd30108a9fb153a244c97050420f93a9efb0e 100644 (file)
@@ -595,7 +595,7 @@ static void ocfs2_dio_end_io(struct kiocb *iocb,
                             ssize_t bytes,
                             void *private)
 {
-       struct inode *inode = iocb->ki_filp->f_dentry->d_inode;
+       struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode;
 
        /* this io's submitter should not have unlocked this before we could */
        BUG_ON(!ocfs2_iocb_is_rw_locked(iocb));
@@ -611,7 +611,7 @@ static ssize_t ocfs2_direct_IO(int rw,
                               unsigned long nr_segs)
 {
        struct file *file = iocb->ki_filp;
-       struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
+       struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host;
        int ret;
 
        mlog_entry_void();
index baad2aa27c144935ec13df8a2d05324d1096eed0..66821e178167d385866ce28c9d079425cf41b850 100644 (file)
@@ -79,7 +79,7 @@ int ocfs2_readdir(struct file * filp, void * dirent, filldir_t filldir)
        struct buffer_head * bh, * tmp;
        struct ocfs2_dir_entry * de;
        int err;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct super_block * sb = inode->i_sb;
        unsigned int ra_sectors = 16;
        int lock_level = 0;
index 16b8d1ba706662c15ee99db4fc20f07f20b10e1f..b7f0ba97a1a2ff6acc8d7a76659704838073b0d6 100644 (file)
@@ -66,7 +66,7 @@ static struct file_operations dlmfs_file_operations;
 static struct inode_operations dlmfs_dir_inode_operations;
 static struct inode_operations dlmfs_root_inode_operations;
 static struct inode_operations dlmfs_file_inode_operations;
-static kmem_cache_t *dlmfs_inode_cache;
+static struct kmem_cache *dlmfs_inode_cache;
 
 struct workqueue_struct *user_dlm_worker;
 
@@ -176,7 +176,7 @@ static ssize_t dlmfs_file_read(struct file *filp,
        int bytes_left;
        ssize_t readlen;
        char *lvb_buf;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
 
        mlog(0, "inode %lu, count = %zu, *ppos = %llu\n",
                inode->i_ino, count, *ppos);
@@ -220,7 +220,7 @@ static ssize_t dlmfs_file_write(struct file *filp,
        int bytes_left;
        ssize_t writelen;
        char *lvb_buf;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
 
        mlog(0, "inode %lu, count = %zu, *ppos = %llu\n",
                inode->i_ino, count, *ppos);
@@ -257,7 +257,7 @@ static ssize_t dlmfs_file_write(struct file *filp,
 }
 
 static void dlmfs_init_once(void *foo,
-                           kmem_cache_t *cachep,
+                           struct kmem_cache *cachep,
                            unsigned long flags)
 {
        struct dlmfs_inode_private *ip =
@@ -276,7 +276,7 @@ static struct inode *dlmfs_alloc_inode(struct super_block *sb)
 {
        struct dlmfs_inode_private *ip;
 
-       ip = kmem_cache_alloc(dlmfs_inode_cache, SLAB_NOFS);
+       ip = kmem_cache_alloc(dlmfs_inode_cache, GFP_NOFS);
        if (!ip)
                return NULL;
 
index f784177b62417bea10e474d568f45e07ddbb5781..856012b4fa4954534ac6d4471d2ebee25b9bdae9 100644 (file)
@@ -221,7 +221,7 @@ EXPORT_SYMBOL_GPL(dlm_dump_all_mles);
 #endif  /*  0  */
 
 
-static kmem_cache_t *dlm_mle_cache = NULL;
+static struct kmem_cache *dlm_mle_cache = NULL;
 
 
 static void dlm_mle_release(struct kref *kref);
index fcd4475d1f899754bb5ed61fa069b149a5e48c20..80ac69f11d9f4d2354fa5dab987e4a1904a5547e 100644 (file)
@@ -61,7 +61,7 @@ struct ocfs2_em_insert_context {
        struct ocfs2_extent_map_entry *right_ent;
 };
 
-static kmem_cache_t *ocfs2_em_ent_cachep = NULL;
+static struct kmem_cache *ocfs2_em_ent_cachep = NULL;
 
 
 static struct ocfs2_extent_map_entry *
index 8786b3c490aa5ff32da1277196204173c1ca1440..e9a82ad95c1e234fb4cc439f482d79d346ccd4f1 100644 (file)
@@ -68,7 +68,7 @@ static int ocfs2_file_open(struct inode *inode, struct file *file)
        struct ocfs2_inode_info *oi = OCFS2_I(inode);
 
        mlog_entry("(0x%p, 0x%p, '%.*s')\n", inode, file,
-                  file->f_dentry->d_name.len, file->f_dentry->d_name.name);
+                  file->f_path.dentry->d_name.len, file->f_path.dentry->d_name.name);
 
        spin_lock(&oi->ip_lock);
 
@@ -98,8 +98,8 @@ static int ocfs2_file_release(struct inode *inode, struct file *file)
        struct ocfs2_inode_info *oi = OCFS2_I(inode);
 
        mlog_entry("(0x%p, 0x%p, '%.*s')\n", inode, file,
-                      file->f_dentry->d_name.len,
-                      file->f_dentry->d_name.name);
+                      file->f_path.dentry->d_name.len,
+                      file->f_path.dentry->d_name.name);
 
        spin_lock(&oi->ip_lock);
        if (!--oi->ip_open_count)
@@ -1131,13 +1131,13 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
 {
        int ret, rw_level, have_alloc_sem = 0;
        struct file *filp = iocb->ki_filp;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        int appending = filp->f_flags & O_APPEND ? 1 : 0;
 
        mlog_entry("(0x%p, %u, '%.*s')\n", filp,
                   (unsigned int)nr_segs,
-                  filp->f_dentry->d_name.len,
-                  filp->f_dentry->d_name.name);
+                  filp->f_path.dentry->d_name.len,
+                  filp->f_path.dentry->d_name.name);
 
        /* happy write of zero bytes */
        if (iocb->ki_left == 0)
@@ -1159,7 +1159,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
                goto out;
        }
 
-       ret = ocfs2_prepare_inode_for_write(filp->f_dentry, &iocb->ki_pos,
+       ret = ocfs2_prepare_inode_for_write(filp->f_path.dentry, &iocb->ki_pos,
                                            iocb->ki_left, appending);
        if (ret < 0) {
                mlog_errno(ret);
@@ -1207,12 +1207,12 @@ static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe,
                                       unsigned int flags)
 {
        int ret;
-       struct inode *inode = out->f_dentry->d_inode;
+       struct inode *inode = out->f_path.dentry->d_inode;
 
        mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", out, pipe,
                   (unsigned int)len,
-                  out->f_dentry->d_name.len,
-                  out->f_dentry->d_name.name);
+                  out->f_path.dentry->d_name.len,
+                  out->f_path.dentry->d_name.name);
 
        inode_double_lock(inode, pipe->inode);
 
@@ -1222,7 +1222,7 @@ static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe,
                goto out;
        }
 
-       ret = ocfs2_prepare_inode_for_write(out->f_dentry, ppos, len, 0);
+       ret = ocfs2_prepare_inode_for_write(out->f_path.dentry, ppos, len, 0);
        if (ret < 0) {
                mlog_errno(ret);
                goto out_unlock;
@@ -1247,12 +1247,12 @@ static ssize_t ocfs2_file_splice_read(struct file *in,
                                      unsigned int flags)
 {
        int ret = 0;
-       struct inode *inode = in->f_dentry->d_inode;
+       struct inode *inode = in->f_path.dentry->d_inode;
 
        mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", in, pipe,
                   (unsigned int)len,
-                  in->f_dentry->d_name.len,
-                  in->f_dentry->d_name.name);
+                  in->f_path.dentry->d_name.len,
+                  in->f_path.dentry->d_name.name);
 
        /*
         * See the comment in ocfs2_file_aio_read()
@@ -1278,12 +1278,12 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb,
 {
        int ret = 0, rw_level = -1, have_alloc_sem = 0, lock_level = 0;
        struct file *filp = iocb->ki_filp;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
 
        mlog_entry("(0x%p, %u, '%.*s')\n", filp,
                   (unsigned int)nr_segs,
-                  filp->f_dentry->d_name.len,
-                  filp->f_dentry->d_name.name);
+                  filp->f_path.dentry->d_name.len,
+                  filp->f_path.dentry->d_name.name);
 
        if (!inode) {
                ret = -EINVAL;
index 46a378fbc40b56a9652f39aacb996cb8bc8151ea..1a7dd2945b34a7bd5f608dddea23b17f4e2d4b9a 100644 (file)
@@ -106,7 +106,7 @@ static inline struct ocfs2_inode_info *OCFS2_I(struct inode *inode)
 #define INODE_JOURNAL(i) (OCFS2_I(i)->ip_flags & OCFS2_INODE_JOURNAL)
 #define SET_INODE_JOURNAL(i) (OCFS2_I(i)->ip_flags |= OCFS2_INODE_JOURNAL)
 
-extern kmem_cache_t *ocfs2_inode_cache;
+extern struct kmem_cache *ocfs2_inode_cache;
 
 extern const struct address_space_operations ocfs2_aops;
 
index d9b4214a12da4051e4c1461a7e1fd359c8b520e6..4bf39540e652fb85b99e62045bf3e84646e5f72d 100644 (file)
@@ -68,7 +68,7 @@
 
 #include "buffer_head_io.h"
 
-static kmem_cache_t *ocfs2_inode_cachep = NULL;
+static struct kmem_cache *ocfs2_inode_cachep = NULL;
 
 /* OCFS2 needs to schedule several differnt types of work which
  * require cluster locking, disk I/O, recovery waits, etc. Since these
@@ -303,7 +303,7 @@ static struct inode *ocfs2_alloc_inode(struct super_block *sb)
 {
        struct ocfs2_inode_info *oi;
 
-       oi = kmem_cache_alloc(ocfs2_inode_cachep, SLAB_NOFS);
+       oi = kmem_cache_alloc(ocfs2_inode_cachep, GFP_NOFS);
        if (!oi)
                return NULL;
 
@@ -914,7 +914,7 @@ bail:
 }
 
 static void ocfs2_inode_init_once(void *data,
-                                 kmem_cache_t *cachep,
+                                 struct kmem_cache *cachep,
                                  unsigned long flags)
 {
        struct ocfs2_inode_info *oi = data;
@@ -1674,7 +1674,7 @@ void __ocfs2_error(struct super_block *sb,
        va_list args;
 
        va_start(args, fmt);
-       vsprintf(error_buf, fmt, args);
+       vsnprintf(error_buf, sizeof(error_buf), fmt, args);
        va_end(args);
 
        /* Not using mlog here because we want to show the actual
@@ -1695,7 +1695,7 @@ void __ocfs2_abort(struct super_block* sb,
        va_list args;
 
        va_start(args, fmt);
-       vsprintf(error_buf, fmt, args);
+       vsnprintf(error_buf, sizeof(error_buf), fmt, args);
        va_end(args);
 
        printk(KERN_CRIT "OCFS2: abort (device %s): %s: %s\n",
index 9707ed7a3206d5055587e5cea8555b17b8e61d8b..39814b900fc0dda863895768dda78e1ab64afa45 100644 (file)
@@ -69,7 +69,7 @@ struct ocfs2_meta_cache_item {
        sector_t        c_block;
 };
 
-static kmem_cache_t *ocfs2_uptodate_cachep = NULL;
+static struct kmem_cache *ocfs2_uptodate_cachep = NULL;
 
 void ocfs2_metadata_cache_init(struct inode *inode)
 {
index 89e0c237a636987d5b131e5816e8d9d9f238f210..0d94319e8681b010cb8aaf0bf9c5df77504ddcde 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -165,7 +165,7 @@ asmlinkage long sys_fstatfs(unsigned int fd, struct statfs __user * buf)
        file = fget(fd);
        if (!file)
                goto out;
-       error = vfs_statfs_native(file->f_dentry, &tmp);
+       error = vfs_statfs_native(file->f_path.dentry, &tmp);
        if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
                error = -EFAULT;
        fput(file);
@@ -186,7 +186,7 @@ asmlinkage long sys_fstatfs64(unsigned int fd, size_t sz, struct statfs64 __user
        file = fget(fd);
        if (!file)
                goto out;
-       error = vfs_statfs64(file->f_dentry, &tmp);
+       error = vfs_statfs64(file->f_path.dentry, &tmp);
        if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
                error = -EFAULT;
        fput(file);
@@ -302,7 +302,7 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
        if (file->f_flags & O_LARGEFILE)
                small = 0;
 
-       dentry = file->f_dentry;
+       dentry = file->f_path.dentry;
        inode = dentry->d_inode;
        error = -EINVAL;
        if (!S_ISREG(inode->i_mode) || !(file->f_mode & FMODE_WRITE))
@@ -448,8 +448,8 @@ asmlinkage long sys_fchdir(unsigned int fd)
        if (!file)
                goto out;
 
-       dentry = file->f_dentry;
-       mnt = file->f_vfsmnt;
+       dentry = file->f_path.dentry;
+       mnt = file->f_path.mnt;
        inode = dentry->d_inode;
 
        error = -ENOTDIR;
@@ -503,7 +503,7 @@ asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
        if (!file)
                goto out;
 
-       dentry = file->f_dentry;
+       dentry = file->f_path.dentry;
        inode = dentry->d_inode;
 
        audit_inode(NULL, inode);
@@ -662,7 +662,7 @@ asmlinkage long sys_fchown(unsigned int fd, uid_t user, gid_t group)
        if (!file)
                goto out;
 
-       dentry = file->f_dentry;
+       dentry = file->f_path.dentry;
        audit_inode(NULL, dentry->d_inode);
        error = chown_common(dentry, user, group);
        fput(file);
@@ -688,8 +688,8 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
        }
 
        f->f_mapping = inode->i_mapping;
-       f->f_dentry = dentry;
-       f->f_vfsmnt = mnt;
+       f->f_path.dentry = dentry;
+       f->f_path.mnt = mnt;
        f->f_pos = 0;
        f->f_op = fops_get(inode->i_fop);
        file_move(f, &inode->i_sb->s_files);
@@ -723,8 +723,8 @@ cleanup_all:
        if (f->f_mode & FMODE_WRITE)
                put_write_access(inode);
        file_kill(f);
-       f->f_dentry = NULL;
-       f->f_vfsmnt = NULL;
+       f->f_path.dentry = NULL;
+       f->f_path.mnt = NULL;
 cleanup_file:
        put_filp(f);
        dput(dentry);
@@ -822,7 +822,7 @@ struct file *nameidata_to_filp(struct nameidata *nd, int flags)
        /* Pick up the filp from the open intent */
        filp = nd->intent.open.file;
        /* Has the filesystem initialised the file for us? */
-       if (filp->f_dentry == NULL)
+       if (filp->f_path.dentry == NULL)
                filp = __dentry_open(nd->dentry, nd->mnt, flags, filp, NULL);
        else
                path_release(nd);
@@ -965,7 +965,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, int mode)
                                put_unused_fd(fd);
                                fd = PTR_ERR(f);
                        } else {
-                               fsnotify_open(f->f_dentry);
+                               fsnotify_open(f->f_path.dentry);
                                fd_install(fd, f);
                        }
                }
@@ -1087,6 +1087,7 @@ EXPORT_SYMBOL(sys_close);
 asmlinkage long sys_vhangup(void)
 {
        if (capable(CAP_SYS_TTY_CONFIG)) {
+               /* XXX: this needs locking */
                tty_vhangup(current->signal->tty);
                return 0;
        }
index 592a6402e8511e945c316aa6637a39e1f0698d44..99c0bc37ba09b91dd2cf99e819261e621634342f 100644 (file)
@@ -262,7 +262,7 @@ found:
 
 static int openpromfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct op_inode_info *oi = OP_I(inode);
        struct device_node *dp = oi->u.node;
        struct device_node *child;
@@ -330,13 +330,13 @@ out:
        return 0;
 }
 
-static kmem_cache_t *op_inode_cachep;
+static struct kmem_cache *op_inode_cachep;
 
 static struct inode *openprom_alloc_inode(struct super_block *sb)
 {
        struct op_inode_info *oi;
 
-       oi = kmem_cache_alloc(op_inode_cachep, SLAB_KERNEL);
+       oi = kmem_cache_alloc(op_inode_cachep, GFP_KERNEL);
        if (!oi)
                return NULL;
 
@@ -415,7 +415,7 @@ static struct file_system_type openprom_fs_type = {
        .kill_sb        = kill_anon_super,
 };
 
-static void op_inode_init_once(void *data, kmem_cache_t * cachep, unsigned long flags)
+static void op_inode_init_once(void *data, struct kmem_cache * cachep, unsigned long flags)
 {
        struct op_inode_info *oi = (struct op_inode_info *) data;
 
index e478f194183147b21169aa91a7b8d81b9415f823..74552c60b671fa1f7b0525723d1d5ddae77a0f29 100644 (file)
@@ -194,7 +194,7 @@ config LDM_DEBUG
 
 config SGI_PARTITION
        bool "SGI partition support" if PARTITION_ADVANCED
-       default y if (SGI_IP22 || SGI_IP27 || ((MACH_JAZZ || SNI_RM200_PCI) && !CPU_LITTLE_ENDIAN))
+       default y if (SGI_IP22 || SGI_IP27 || ((MACH_JAZZ || SNI_RM) && !CPU_LITTLE_ENDIAN))
        help
          Say Y here if you would like to be able to read the hard disk
          partition table format used by SGI machines.
index 3068528890a6255191d813195fb636363584f2e5..9917a8c360f2da0537baea01559b468825476521 100644 (file)
@@ -43,6 +43,7 @@ amiga_partition(struct parsed_partitions *state, struct block_device *bdev)
                        if (warn_no_part)
                                printk("Dev %s: unable to read RDB block %d\n",
                                       bdevname(bdev, b), blk);
+                       res = -1;
                        goto rdb_done;
                }
                if (*(__be32 *)data != cpu_to_be32(IDNAME_RIGIDDISK))
@@ -79,6 +80,7 @@ amiga_partition(struct parsed_partitions *state, struct block_device *bdev)
                        if (warn_no_part)
                                printk("Dev %s: unable to read partition block %d\n",
                                       bdevname(bdev, b), blk);
+                       res = -1;
                        goto rdb_done;
                }
                pb  = (struct PartitionBlock *)data;
index 192a6adfdefddb504616436969d24732203ff1f8..1f3572d5b755127ed2043a7329815687dff06f8e 100644 (file)
@@ -88,7 +88,7 @@ int atari_partition(struct parsed_partitions *state, struct block_device *bdev)
                        if (!xrs) {
                                printk (" block %ld read failed\n", partsect);
                                put_dev_sector(sect);
-                               return 0;
+                               return -1;
                        }
 
                        /* ++roman: sanity check: bit 0 of flg field must be set */
index 6fb4b6150d7701cd57085f80a0f9222f31be53ed..3d73d94d93a7dd9321cdfe5d9750fcf25a836df5 100644 (file)
@@ -153,7 +153,7 @@ static struct parsed_partitions *
 check_partition(struct gendisk *hd, struct block_device *bdev)
 {
        struct parsed_partitions *state;
-       int i, res;
+       int i, res, err;
 
        state = kmalloc(sizeof(struct parsed_partitions), GFP_KERNEL);
        if (!state)
@@ -165,19 +165,30 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
                sprintf(state->name, "p");
 
        state->limit = hd->minors;
-       i = res = 0;
+       i = res = err = 0;
        while (!res && check_part[i]) {
                memset(&state->parts, 0, sizeof(state->parts));
                res = check_part[i++](state, bdev);
+               if (res < 0) {
+                       /* We have hit an I/O error which we don't report now.
+                       * But record it, and let the others do their job.
+                       */
+                       err = res;
+                       res = 0;
+               }
+
        }
        if (res > 0)
                return state;
+       if (!err)
+       /* The partition is unrecognized. So report I/O errors if there were any */
+               res = err;
        if (!res)
                printk(" unknown partition table\n");
        else if (warn_no_part)
                printk(" unable to read partition table\n");
        kfree(state);
-       return NULL;
+       return ERR_PTR(res);
 }
 
 /*
@@ -265,12 +276,39 @@ static struct part_attribute part_attr_stat = {
        .show   = part_stat_read
 };
 
+#ifdef CONFIG_FAIL_MAKE_REQUEST
+
+static ssize_t part_fail_store(struct hd_struct * p,
+                              const char *buf, size_t count)
+{
+       int i;
+
+       if (count > 0 && sscanf(buf, "%d", &i) > 0)
+               p->make_it_fail = (i == 0) ? 0 : 1;
+
+       return count;
+}
+static ssize_t part_fail_read(struct hd_struct * p, char *page)
+{
+       return sprintf(page, "%d\n", p->make_it_fail);
+}
+static struct part_attribute part_attr_fail = {
+       .attr = {.name = "make-it-fail", .mode = S_IRUGO | S_IWUSR },
+       .store  = part_fail_store,
+       .show   = part_fail_read
+};
+
+#endif
+
 static struct attribute * default_attrs[] = {
        &part_attr_uevent.attr,
        &part_attr_dev.attr,
        &part_attr_start.attr,
        &part_attr_size.attr,
        &part_attr_stat.attr,
+#ifdef CONFIG_FAIL_MAKE_REQUEST
+       &part_attr_fail.attr,
+#endif
        NULL,
 };
 
@@ -494,6 +532,8 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
                disk->fops->revalidate_disk(disk);
        if (!get_capacity(disk) || !(state = check_partition(disk, bdev)))
                return 0;
+       if (IS_ERR(state))      /* I/O error reading the partition table */
+               return PTR_ERR(state);
        for (p = 1; p < state->limit; p++) {
                sector_t size = state->parts[p].size;
                sector_t from = state->parts[p].from;
index d352a7381fed88ff20f5f1c7b9b6365a2264e436..9f7ad4244f63d64ed723939c568fc88de53ae7c3 100644 (file)
@@ -43,7 +43,7 @@ cchhb2blk (struct vtoc_cchhb *ptr, struct hd_geometry *geo) {
 int
 ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
 {
-       int blocksize, offset, size;
+       int blocksize, offset, size,res;
        loff_t i_size;
        dasd_information_t *info;
        struct hd_geometry *geo;
@@ -56,15 +56,16 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
        unsigned char *data;
        Sector sect;
 
+       res = 0;
        blocksize = bdev_hardsect_size(bdev);
        if (blocksize <= 0)
-               return 0;
+               goto out_exit;
        i_size = i_size_read(bdev->bd_inode);
        if (i_size == 0)
-               return 0;
+               goto out_exit;
 
        if ((info = kmalloc(sizeof(dasd_information_t), GFP_KERNEL)) == NULL)
-               goto out_noinfo;
+               goto out_exit;
        if ((geo = kmalloc(sizeof(struct hd_geometry), GFP_KERNEL)) == NULL)
                goto out_nogeo;
        if ((label = kmalloc(sizeof(union label_t), GFP_KERNEL)) == NULL)
@@ -72,7 +73,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
 
        if (ioctl_by_bdev(bdev, BIODASDINFO, (unsigned long)info) != 0 ||
            ioctl_by_bdev(bdev, HDIO_GETGEO, (unsigned long)geo) != 0)
-               goto out_noioctl;
+               goto out_freeall;
 
        /*
         * Get volume label, extract name and type.
@@ -92,6 +93,8 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
        EBCASC(type, 4);
        EBCASC(name, 6);
 
+       res = 1;
+
        /*
         * Three different types: CMS1, VOL1 and LNX1/unlabeled
         */
@@ -156,6 +159,9 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
                        counter++;
                        blk++;
                }
+               if (!data)
+               /* Are we not supposed to report this ? */
+                       goto out_readerr;
        } else {
                /*
                 * Old style LNX1 or unlabeled disk
@@ -171,18 +177,17 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
        }
 
        printk("\n");
-       kfree(label);
-       kfree(geo);
-       kfree(info);
-       return 1;
+       goto out_freeall;
+
 
 out_readerr:
-out_noioctl:
+       res = -1;
+out_freeall:
        kfree(label);
 out_nolab:
        kfree(geo);
 out_nogeo:
        kfree(info);
-out_noinfo:
-       return 0;
+out_exit:
+       return res;
 }
index b1626f269a3445e38f34c1bc338734e0893bbd32..f8b6bdcb879aa8f4ba9ccfa7340edb087d7e2d57 100644 (file)
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -222,7 +222,7 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
           unsigned long nr_segs, loff_t pos)
 {
        struct file *filp = iocb->ki_filp;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct pipe_inode_info *pipe;
        int do_wakeup;
        ssize_t ret;
@@ -335,7 +335,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
            unsigned long nr_segs, loff_t ppos)
 {
        struct file *filp = iocb->ki_filp;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct pipe_inode_info *pipe;
        ssize_t ret;
        int do_wakeup;
@@ -520,7 +520,7 @@ static int
 pipe_ioctl(struct inode *pino, struct file *filp,
           unsigned int cmd, unsigned long arg)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct pipe_inode_info *pipe;
        int count, buf, nrbufs;
 
@@ -548,7 +548,7 @@ static unsigned int
 pipe_poll(struct file *filp, poll_table *wait)
 {
        unsigned int mask;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct pipe_inode_info *pipe = inode->i_pipe;
        int nrbufs;
 
@@ -601,7 +601,7 @@ pipe_release(struct inode *inode, int decr, int decw)
 static int
 pipe_read_fasync(int fd, struct file *filp, int on)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        int retval;
 
        mutex_lock(&inode->i_mutex);
@@ -618,7 +618,7 @@ pipe_read_fasync(int fd, struct file *filp, int on)
 static int
 pipe_write_fasync(int fd, struct file *filp, int on)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        int retval;
 
        mutex_lock(&inode->i_mutex);
@@ -635,7 +635,7 @@ pipe_write_fasync(int fd, struct file *filp, int on)
 static int
 pipe_rdwr_fasync(int fd, struct file *filp, int on)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct pipe_inode_info *pipe = inode->i_pipe;
        int retval;
 
@@ -830,7 +830,14 @@ void free_pipe_info(struct inode *inode)
 static struct vfsmount *pipe_mnt __read_mostly;
 static int pipefs_delete_dentry(struct dentry *dentry)
 {
-       return 1;
+       /*
+        * At creation time, we pretended this dentry was hashed
+        * (by clearing DCACHE_UNHASHED bit in d_flags)
+        * At delete time, we restore the truth : not hashed.
+        * (so that dput() can proceed correctly)
+        */
+       dentry->d_flags |= DCACHE_UNHASHED;
+       return 0;
 }
 
 static struct dentry_operations pipefs_dentry_operations = {
@@ -891,19 +898,24 @@ struct file *create_write_pipe(void)
        if (!inode)
                goto err_file;
 
-       sprintf(name, "[%lu]", inode->i_ino);
+       this.len = sprintf(name, "[%lu]", inode->i_ino);
        this.name = name;
-       this.len = strlen(name);
-       this.hash = inode->i_ino; /* will go */
+       this.hash = 0;
        err = -ENOMEM;
        dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &this);
        if (!dentry)
                goto err_inode;
 
        dentry->d_op = &pipefs_dentry_operations;
-       d_add(dentry, inode);
-       f->f_vfsmnt = mntget(pipe_mnt);
-       f->f_dentry = dentry;
+       /*
+        * We dont want to publish this dentry into global dentry hash table.
+        * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED
+        * This permits a working /proc/$pid/fd/XXX on pipes
+        */
+       dentry->d_flags &= ~DCACHE_UNHASHED;
+       d_instantiate(dentry, inode);
+       f->f_path.mnt = mntget(pipe_mnt);
+       f->f_path.dentry = dentry;
        f->f_mapping = inode->i_mapping;
 
        f->f_flags = O_WRONLY;
@@ -923,8 +935,8 @@ struct file *create_write_pipe(void)
 
 void free_write_pipe(struct file *f)
 {
-       mntput(f->f_vfsmnt);
-       dput(f->f_dentry);
+       mntput(f->f_path.mnt);
+       dput(f->f_path.dentry);
        put_filp(f);
 }
 
@@ -935,9 +947,9 @@ struct file *create_read_pipe(struct file *wrf)
                return ERR_PTR(-ENFILE);
 
        /* Grab pipe from the writer */
-       f->f_vfsmnt = mntget(wrf->f_vfsmnt);
-       f->f_dentry = dget(wrf->f_dentry);
-       f->f_mapping = wrf->f_dentry->d_inode->i_mapping;
+       f->f_path.mnt = mntget(wrf->f_path.mnt);
+       f->f_path.dentry = dget(wrf->f_path.dentry);
+       f->f_mapping = wrf->f_path.dentry->d_inode->i_mapping;
 
        f->f_pos = 0;
        f->f_flags = O_RDONLY;
index da42ee61c1dfd9dee68251b3ba3bdad78a86185d..56aacead836284b7577ad9146aed46582c592a5f 100644 (file)
@@ -6,7 +6,7 @@
  *     Author : Ram Pai (linuxram@us.ibm.com)
  *
  */
-#include <linux/namespace.h>
+#include <linux/mnt_namespace.h>
 #include <linux/mount.h>
 #include <linux/fs.h>
 #include "pnode.h"
index 020e1bb60fdb6b3e4601727a273bad4e2d322331..d45bd8ec36bf1443bd76c906be04cb67b15236a3 100644 (file)
@@ -13,7 +13,7 @@
 
 #define IS_MNT_SHARED(mnt) (mnt->mnt_flags & MNT_SHARED)
 #define IS_MNT_SLAVE(mnt) (mnt->mnt_master)
-#define IS_MNT_NEW(mnt)  (!mnt->mnt_namespace)
+#define IS_MNT_NEW(mnt)  (!mnt->mnt_ns)
 #define CLEAR_MNT_SHARED(mnt) (mnt->mnt_flags &= ~MNT_SHARED)
 #define IS_MNT_UNBINDABLE(mnt) (mnt->mnt_flags & MNT_UNBINDABLE)
 
index 7431d7ba2d097981e1e87a191dc0ab81a2684537..f6c7762725727b49af2e7b4afbdff56a2440f822 100644 (file)
@@ -8,8 +8,9 @@ proc-y                  := nommu.o task_nommu.o
 proc-$(CONFIG_MMU)     := mmu.o task_mmu.o
 
 proc-y       += inode.o root.o base.o generic.o array.o \
-               kmsg.o proc_tty.o proc_misc.o
+               proc_tty.o proc_misc.o
 
 proc-$(CONFIG_PROC_KCORE)      += kcore.o
 proc-$(CONFIG_PROC_VMCORE)     += vmcore.o
 proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o
+proc-$(CONFIG_PRINTK)  += kmsg.o
index 25e917fb47399bf22761fb8ed47b190776ee6cff..70e4fab117b154ec0379aea1f924e5f021195e7e 100644 (file)
@@ -346,20 +346,13 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
        sigemptyset(&sigcatch);
        cutime = cstime = utime = stime = cputime_zero;
 
-       mutex_lock(&tty_mutex);
        rcu_read_lock();
        if (lock_task_sighand(task, &flags)) {
                struct signal_struct *sig = task->signal;
-               struct tty_struct *tty = sig->tty;
-
-               if (tty) {
-                       /*
-                        * sig->tty is not stable, but tty_mutex
-                        * protects us from release_dev(tty)
-                        */
-                       barrier();
-                       tty_pgrp = tty->pgrp;
-                       tty_nr = new_encode_dev(tty_devnum(tty));
+
+               if (sig->tty) {
+                       tty_pgrp = sig->tty->pgrp;
+                       tty_nr = new_encode_dev(tty_devnum(sig->tty));
                }
 
                num_threads = atomic_read(&sig->count);
@@ -388,14 +381,13 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
                        stime = cputime_add(stime, sig->stime);
                }
 
-               sid = sig->session;
+               sid = signal_session(sig);
                pgid = process_group(task);
                ppid = rcu_dereference(task->real_parent)->tgid;
 
                unlock_task_sighand(task, &flags);
        }
        rcu_read_unlock();
-       mutex_unlock(&tty_mutex);
 
        if (!whole || num_threads<2)
                wchan = get_wchan(task);
index 795319c54f7283430f2ec28ed346d39af6291e34..fd959d5b5a802c0897d586114a0c1fb2878ceec0 100644 (file)
@@ -59,7 +59,7 @@
 #include <linux/string.h>
 #include <linux/seq_file.h>
 #include <linux/namei.h>
-#include <linux/namespace.h>
+#include <linux/mnt_namespace.h>
 #include <linux/mm.h>
 #include <linux/smp_lock.h>
 #include <linux/rcupdate.h>
@@ -365,33 +365,33 @@ struct proc_mounts {
 static int mounts_open(struct inode *inode, struct file *file)
 {
        struct task_struct *task = get_proc_task(inode);
-       struct namespace *namespace = NULL;
+       struct mnt_namespace *ns = NULL;
        struct proc_mounts *p;
        int ret = -EINVAL;
 
        if (task) {
                task_lock(task);
-               namespace = task->nsproxy->namespace;
-               if (namespace)
-                       get_namespace(namespace);
+               ns = task->nsproxy->mnt_ns;
+               if (ns)
+                       get_mnt_ns(ns);
                task_unlock(task);
                put_task_struct(task);
        }
 
-       if (namespace) {
+       if (ns) {
                ret = -ENOMEM;
                p = kmalloc(sizeof(struct proc_mounts), GFP_KERNEL);
                if (p) {
                        file->private_data = &p->m;
                        ret = seq_open(file, &mounts_op);
                        if (!ret) {
-                               p->m.private = namespace;
-                               p->event = namespace->event;
+                               p->m.private = ns;
+                               p->event = ns->event;
                                return 0;
                        }
                        kfree(p);
                }
-               put_namespace(namespace);
+               put_mnt_ns(ns);
        }
        return ret;
 }
@@ -399,15 +399,15 @@ static int mounts_open(struct inode *inode, struct file *file)
 static int mounts_release(struct inode *inode, struct file *file)
 {
        struct seq_file *m = file->private_data;
-       struct namespace *namespace = m->private;
-       put_namespace(namespace);
+       struct mnt_namespace *ns = m->private;
+       put_mnt_ns(ns);
        return seq_release(inode, file);
 }
 
 static unsigned mounts_poll(struct file *file, poll_table *wait)
 {
        struct proc_mounts *p = file->private_data;
-       struct namespace *ns = p->m.private;
+       struct mnt_namespace *ns = p->m.private;
        unsigned res = 0;
 
        poll_wait(file, &ns->poll, wait);
@@ -437,21 +437,21 @@ static int mountstats_open(struct inode *inode, struct file *file)
 
        if (!ret) {
                struct seq_file *m = file->private_data;
-               struct namespace *namespace = NULL;
+               struct mnt_namespace *mnt_ns = NULL;
                struct task_struct *task = get_proc_task(inode);
 
                if (task) {
                        task_lock(task);
                        if (task->nsproxy)
-                               namespace = task->nsproxy->namespace;
-                       if (namespace)
-                               get_namespace(namespace);
+                               mnt_ns = task->nsproxy->mnt_ns;
+                       if (mnt_ns)
+                               get_mnt_ns(mnt_ns);
                        task_unlock(task);
                        put_task_struct(task);
                }
 
-               if (namespace)
-                       m->private = namespace;
+               if (mnt_ns)
+                       m->private = mnt_ns;
                else {
                        seq_release(inode, file);
                        ret = -EINVAL;
@@ -472,7 +472,7 @@ static struct file_operations proc_mountstats_operations = {
 static ssize_t proc_info_read(struct file * file, char __user * buf,
                          size_t count, loff_t *ppos)
 {
-       struct inode * inode = file->f_dentry->d_inode;
+       struct inode * inode = file->f_path.dentry->d_inode;
        unsigned long page;
        ssize_t length;
        struct task_struct *task = get_proc_task(inode);
@@ -512,7 +512,7 @@ static int mem_open(struct inode* inode, struct file* file)
 static ssize_t mem_read(struct file * file, char __user * buf,
                        size_t count, loff_t *ppos)
 {
-       struct task_struct *task = get_proc_task(file->f_dentry->d_inode);
+       struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
        char *page;
        unsigned long src = *ppos;
        int ret = -ESRCH;
@@ -584,7 +584,7 @@ static ssize_t mem_write(struct file * file, const char * buf,
 {
        int copied;
        char *page;
-       struct task_struct *task = get_proc_task(file->f_dentry->d_inode);
+       struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
        unsigned long dst = *ppos;
 
        copied = -ESRCH;
@@ -654,7 +654,7 @@ static struct file_operations proc_mem_operations = {
 static ssize_t oom_adjust_read(struct file *file, char __user *buf,
                                size_t count, loff_t *ppos)
 {
-       struct task_struct *task = get_proc_task(file->f_dentry->d_inode);
+       struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
        char buffer[PROC_NUMBUF];
        size_t len;
        int oom_adjust;
@@ -683,8 +683,6 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
        char buffer[PROC_NUMBUF], *end;
        int oom_adjust;
 
-       if (!capable(CAP_SYS_RESOURCE))
-               return -EPERM;
        memset(buffer, 0, sizeof(buffer));
        if (count > sizeof(buffer) - 1)
                count = sizeof(buffer) - 1;
@@ -696,9 +694,13 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
                return -EINVAL;
        if (*end == '\n')
                end++;
-       task = get_proc_task(file->f_dentry->d_inode);
+       task = get_proc_task(file->f_path.dentry->d_inode);
        if (!task)
                return -ESRCH;
+       if (oom_adjust < task->oomkilladj && !capable(CAP_SYS_RESOURCE)) {
+               put_task_struct(task);
+               return -EACCES;
+       }
        task->oomkilladj = oom_adjust;
        put_task_struct(task);
        if (end - buffer == 0)
@@ -716,7 +718,7 @@ static struct file_operations proc_oom_adjust_operations = {
 static ssize_t proc_loginuid_read(struct file * file, char __user * buf,
                                  size_t count, loff_t *ppos)
 {
-       struct inode * inode = file->f_dentry->d_inode;
+       struct inode * inode = file->f_path.dentry->d_inode;
        struct task_struct *task = get_proc_task(inode);
        ssize_t length;
        char tmpbuf[TMPBUFLEN];
@@ -732,7 +734,7 @@ static ssize_t proc_loginuid_read(struct file * file, char __user * buf,
 static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
                                   size_t count, loff_t *ppos)
 {
-       struct inode * inode = file->f_dentry->d_inode;
+       struct inode * inode = file->f_path.dentry->d_inode;
        char *page, *tmp;
        ssize_t length;
        uid_t loginuid;
@@ -851,6 +853,65 @@ static struct file_operations proc_seccomp_operations = {
 };
 #endif /* CONFIG_SECCOMP */
 
+#ifdef CONFIG_FAULT_INJECTION
+static ssize_t proc_fault_inject_read(struct file * file, char __user * buf,
+                                     size_t count, loff_t *ppos)
+{
+       struct task_struct *task = get_proc_task(file->f_dentry->d_inode);
+       char buffer[PROC_NUMBUF];
+       size_t len;
+       int make_it_fail;
+       loff_t __ppos = *ppos;
+
+       if (!task)
+               return -ESRCH;
+       make_it_fail = task->make_it_fail;
+       put_task_struct(task);
+
+       len = snprintf(buffer, sizeof(buffer), "%i\n", make_it_fail);
+       if (__ppos >= len)
+               return 0;
+       if (count > len-__ppos)
+               count = len-__ppos;
+       if (copy_to_user(buf, buffer + __ppos, count))
+               return -EFAULT;
+       *ppos = __ppos + count;
+       return count;
+}
+
+static ssize_t proc_fault_inject_write(struct file * file,
+                       const char __user * buf, size_t count, loff_t *ppos)
+{
+       struct task_struct *task;
+       char buffer[PROC_NUMBUF], *end;
+       int make_it_fail;
+
+       if (!capable(CAP_SYS_RESOURCE))
+               return -EPERM;
+       memset(buffer, 0, sizeof(buffer));
+       if (count > sizeof(buffer) - 1)
+               count = sizeof(buffer) - 1;
+       if (copy_from_user(buffer, buf, count))
+               return -EFAULT;
+       make_it_fail = simple_strtol(buffer, &end, 0);
+       if (*end == '\n')
+               end++;
+       task = get_proc_task(file->f_dentry->d_inode);
+       if (!task)
+               return -ESRCH;
+       task->make_it_fail = make_it_fail;
+       put_task_struct(task);
+       if (end - buffer == 0)
+               return -EIO;
+       return end - buffer;
+}
+
+static struct file_operations proc_fault_inject_operations = {
+       .read           = proc_fault_inject_read,
+       .write          = proc_fault_inject_write,
+};
+#endif
+
 static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
        struct inode *inode = dentry->d_inode;
@@ -1076,7 +1137,7 @@ static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
        char *name, int len,
        instantiate_t instantiate, struct task_struct *task, void *ptr)
 {
-       struct dentry *child, *dir = filp->f_dentry;
+       struct dentry *child, *dir = filp->f_path.dentry;
        struct inode *inode;
        struct qstr qname;
        ino_t ino = 0;
@@ -1155,8 +1216,8 @@ static int proc_fd_link(struct inode *inode, struct dentry **dentry, struct vfsm
                spin_lock(&files->file_lock);
                file = fcheck_files(files, fd);
                if (file) {
-                       *mnt = mntget(file->f_vfsmnt);
-                       *dentry = dget(file->f_dentry);
+                       *mnt = mntget(file->f_path.mnt);
+                       *dentry = dget(file->f_path.dentry);
                        spin_unlock(&files->file_lock);
                        put_files_struct(files);
                        return 0;
@@ -1291,7 +1352,7 @@ static int proc_fd_fill_cache(struct file *filp, void *dirent, filldir_t filldir
 
 static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir)
 {
-       struct dentry *dentry = filp->f_dentry;
+       struct dentry *dentry = filp->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        struct task_struct *p = get_proc_task(inode);
        unsigned int fd, tid, ino;
@@ -1438,7 +1499,7 @@ static int proc_pident_readdir(struct file *filp,
 {
        int i;
        int pid;
-       struct dentry *dentry = filp->f_dentry;
+       struct dentry *dentry = filp->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        struct task_struct *task = get_proc_task(inode);
        struct pid_entry *p, *last;
@@ -1494,7 +1555,7 @@ out_no_task:
 static ssize_t proc_pid_attr_read(struct file * file, char __user * buf,
                                  size_t count, loff_t *ppos)
 {
-       struct inode * inode = file->f_dentry->d_inode;
+       struct inode * inode = file->f_path.dentry->d_inode;
        unsigned long page;
        ssize_t length;
        struct task_struct *task = get_proc_task(inode);
@@ -1510,7 +1571,7 @@ static ssize_t proc_pid_attr_read(struct file * file, char __user * buf,
                goto out;
 
        length = security_getprocattr(task,
-                                     (char*)file->f_dentry->d_name.name,
+                                     (char*)file->f_path.dentry->d_name.name,
                                      (void*)page, count);
        if (length >= 0)
                length = simple_read_from_buffer(buf, count, ppos, (char *)page, length);
@@ -1524,7 +1585,7 @@ out_no_task:
 static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
                                   size_t count, loff_t *ppos)
 {
-       struct inode * inode = file->f_dentry->d_inode;
+       struct inode * inode = file->f_path.dentry->d_inode;
        char *page;
        ssize_t length;
        struct task_struct *task = get_proc_task(inode);
@@ -1550,7 +1611,7 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
                goto out_free;
 
        length = security_setprocattr(task,
-                                     (char*)file->f_dentry->d_name.name,
+                                     (char*)file->f_path.dentry->d_name.name,
                                      (void*)page, count);
 out_free:
        free_page((unsigned long) page);
@@ -1791,6 +1852,9 @@ static struct pid_entry tgid_base_stuff[] = {
 #ifdef CONFIG_AUDITSYSCALL
        REG("loginuid",   S_IWUSR|S_IRUGO, loginuid),
 #endif
+#ifdef CONFIG_FAULT_INJECTION
+       REG("make-it-fail", S_IRUGO|S_IWUSR, fault_inject),
+#endif
 };
 
 static int proc_tgid_base_readdir(struct file * filp,
@@ -1883,8 +1947,9 @@ out:
        return;
 }
 
-struct dentry *proc_pid_instantiate(struct inode *dir,
-       struct dentry * dentry, struct task_struct *task, void *ptr)
+static struct dentry *proc_pid_instantiate(struct inode *dir,
+                                          struct dentry * dentry,
+                                          struct task_struct *task, void *ptr)
 {
        struct dentry *error = ERR_PTR(-ENOENT);
        struct inode *inode;
@@ -1991,7 +2056,7 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
 {
        unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
-       struct task_struct *reaper = get_proc_task(filp->f_dentry->d_inode);
+       struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
        struct task_struct *task;
        int tgid;
 
@@ -2065,6 +2130,9 @@ static struct pid_entry tid_base_stuff[] = {
 #ifdef CONFIG_AUDITSYSCALL
        REG("loginuid",  S_IWUSR|S_IRUGO, loginuid),
 #endif
+#ifdef CONFIG_FAULT_INJECTION
+       REG("make-it-fail", S_IRUGO|S_IWUSR, fault_inject),
+#endif
 };
 
 static int proc_tid_base_readdir(struct file * filp,
@@ -2232,7 +2300,7 @@ static int proc_task_fill_cache(struct file *filp, void *dirent, filldir_t filld
 /* for the /proc/TGID/task/ directories */
 static int proc_task_readdir(struct file * filp, void * dirent, filldir_t filldir)
 {
-       struct dentry *dentry = filp->f_dentry;
+       struct dentry *dentry = filp->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        struct task_struct *leader = get_proc_task(inode);
        struct task_struct *task;
index 4ba03009cf72328770df1a9e1b33787dc7ef7429..853cb877d5f3e42b2c617f972a6292bc03912ee8 100644 (file)
@@ -52,7 +52,7 @@ static ssize_t
 proc_file_read(struct file *file, char __user *buf, size_t nbytes,
               loff_t *ppos)
 {
-       struct inode * inode = file->f_dentry->d_inode;
+       struct inode * inode = file->f_path.dentry->d_inode;
        char    *page;
        ssize_t retval=0;
        int     eof=0;
@@ -203,7 +203,7 @@ static ssize_t
 proc_file_write(struct file *file, const char __user *buffer,
                size_t count, loff_t *ppos)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct proc_dir_entry * dp;
        
        dp = PDE(inode);
@@ -432,7 +432,7 @@ int proc_readdir(struct file * filp,
        struct proc_dir_entry * de;
        unsigned int ino;
        int i;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        int ret = 0;
 
        lock_kernel();
@@ -453,7 +453,7 @@ int proc_readdir(struct file * filp,
                        /* fall through */
                case 1:
                        if (filldir(dirent, "..", 2, i,
-                                   parent_ino(filp->f_dentry),
+                                   parent_ino(filp->f_path.dentry),
                                    DT_DIR) < 0)
                                goto out;
                        i++;
@@ -558,7 +558,7 @@ static void proc_kill_inodes(struct proc_dir_entry *de)
        file_list_lock();
        list_for_each(p, &sb->s_files) {
                struct file * filp = list_entry(p, struct file, f_u.fu_list);
-               struct dentry * dentry = filp->f_dentry;
+               struct dentry * dentry = filp->f_path.dentry;
                struct inode * inode;
                const struct file_operations *fops;
 
index 49dfb2ab783e6f921fdd344f1b6c39ee29cd1935..e26945ba685b5c80f0abdca78f4631db7d64f992 100644 (file)
@@ -81,14 +81,14 @@ static void proc_read_inode(struct inode * inode)
        inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
 }
 
-static kmem_cache_t * proc_inode_cachep;
+static struct kmem_cache * proc_inode_cachep;
 
 static struct inode *proc_alloc_inode(struct super_block *sb)
 {
        struct proc_inode *ei;
        struct inode *inode;
 
-       ei = (struct proc_inode *)kmem_cache_alloc(proc_inode_cachep, SLAB_KERNEL);
+       ei = (struct proc_inode *)kmem_cache_alloc(proc_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        ei->pid = NULL;
@@ -105,7 +105,7 @@ static void proc_destroy_inode(struct inode *inode)
        kmem_cache_free(proc_inode_cachep, PROC_I(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct proc_inode *ei = (struct proc_inode *) foo;
 
index 1294eda4acaeefc5739bd4ad267a7fca2dd679dd..1be73082edd388bd443f0be5c559cdf756eccbbb 100644 (file)
@@ -22,6 +22,7 @@
 #include <asm/uaccess.h>
 #include <asm/io.h>
 
+#define CORE_STR "CORE"
 
 static int open_kcore(struct inode * inode, struct file * filp)
 {
@@ -82,10 +83,11 @@ static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
        }
        *elf_buflen =   sizeof(struct elfhdr) + 
                        (*nphdr + 2)*sizeof(struct elf_phdr) + 
-                       3 * (sizeof(struct elf_note) + 4) +
-                       sizeof(struct elf_prstatus) +
-                       sizeof(struct elf_prpsinfo) +
-                       sizeof(struct task_struct);
+                       3 * ((sizeof(struct elf_note)) +
+                            roundup(sizeof(CORE_STR), 4)) +
+                       roundup(sizeof(struct elf_prstatus), 4) +
+                       roundup(sizeof(struct elf_prpsinfo), 4) +
+                       roundup(sizeof(struct task_struct), 4);
        *elf_buflen = PAGE_ALIGN(*elf_buflen);
        return size + *elf_buflen;
 }
@@ -210,7 +212,7 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
        nhdr->p_offset  = offset;
 
        /* set up the process status */
-       notes[0].name = "CORE";
+       notes[0].name = CORE_STR;
        notes[0].type = NT_PRSTATUS;
        notes[0].datasz = sizeof(struct elf_prstatus);
        notes[0].data = &prstatus;
@@ -221,7 +223,7 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
        bufp = storenote(&notes[0], bufp);
 
        /* set up the process info */
-       notes[1].name   = "CORE";
+       notes[1].name   = CORE_STR;
        notes[1].type   = NT_PRPSINFO;
        notes[1].datasz = sizeof(struct elf_prpsinfo);
        notes[1].data   = &prpsinfo;
@@ -238,7 +240,7 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
        bufp = storenote(&notes[1], bufp);
 
        /* set up the task structure */
-       notes[2].name   = "CORE";
+       notes[2].name   = CORE_STR;
        notes[2].type   = NT_TASKSTRUCT;
        notes[2].datasz = sizeof(struct task_struct);
        notes[2].data   = current;
index d7dbdf9e0f496adfa70facf0612ca382e41a3462..5ec67257e5f92426e94f41c40f1d42a36692583a 100644 (file)
@@ -46,7 +46,7 @@ int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma)
        file = vma->vm_file;
 
        if (file) {
-               struct inode *inode = vma->vm_file->f_dentry->d_inode;
+               struct inode *inode = vma->vm_file->f_path.dentry->d_inode;
                dev = inode->i_sb->s_dev;
                ino = inode->i_ino;
        }
@@ -67,7 +67,7 @@ int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma)
                if (len < 1)
                        len = 1;
                seq_printf(m, "%*c", len, ' ');
-               seq_path(m, file->f_vfsmnt, file->f_dentry, "");
+               seq_path(m, file->f_path.mnt, file->f_path.dentry, "");
        }
 
        seq_putc(m, '\n');
index 93c43b676e59f374813e9ae7095470ce9c23b87c..dc3e580d1dcaa817b59dd1c1955db1ded46bb0e2 100644 (file)
 #include <linux/seq_file.h>
 #include <linux/times.h>
 #include <linux/profile.h>
+#include <linux/utsname.h>
 #include <linux/blkdev.h>
 #include <linux/hugetlb.h>
 #include <linux/jiffies.h>
 #include <linux/sysrq.h>
 #include <linux/vmalloc.h>
 #include <linux/crash_dump.h>
-#include <linux/pspace.h>
+#include <linux/pid_namespace.h>
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
 #include <asm/io.h>
@@ -92,7 +93,7 @@ static int loadavg_read_proc(char *page, char **start, off_t off,
                LOAD_INT(a), LOAD_FRAC(a),
                LOAD_INT(b), LOAD_FRAC(b),
                LOAD_INT(c), LOAD_FRAC(c),
-               nr_running(), nr_threads, init_pspace.last_pid);
+               nr_running(), nr_threads, current->nsproxy->pid_ns->last_pid);
        return proc_calc_metrics(page, start, off, count, eof, len);
 }
 
@@ -252,8 +253,8 @@ static int version_read_proc(char *page, char **start, off_t off,
 {
        int len;
 
-       strcpy(page, linux_banner);
-       len = strlen(page);
+       len = sprintf(page, linux_banner,
+               utsname()->release, utsname()->version);
        return proc_calc_metrics(page, start, off, count, eof, len);
 }
 
@@ -696,9 +697,11 @@ void __init proc_misc_init(void)
        proc_symlink("mounts", NULL, "self/mounts");
 
        /* And now for trickier ones */
+#ifdef CONFIG_PRINTK
        entry = create_proc_entry("kmsg", S_IRUSR, &proc_root);
        if (entry)
                entry->proc_fops = &proc_kmsg_operations;
+#endif
        create_seq_entry("devices", 0, &proc_devinfo_operations);
        create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations);
 #ifdef CONFIG_BLOCK
index 6b769afac55a18ff274ef8ed90b2d0510a86804b..55ade0d1562160000060c0b35b860b6ff018229a 100644 (file)
@@ -94,8 +94,8 @@ int proc_exe_link(struct inode *inode, struct dentry **dentry, struct vfsmount *
        }
 
        if (vma) {
-               *mnt = mntget(vma->vm_file->f_vfsmnt);
-               *dentry = dget(vma->vm_file->f_dentry);
+               *mnt = mntget(vma->vm_file->f_path.mnt);
+               *dentry = dget(vma->vm_file->f_path.dentry);
                result = 0;
        }
 
@@ -135,7 +135,7 @@ static int show_map_internal(struct seq_file *m, void *v, struct mem_size_stats
        int len;
 
        if (file) {
-               struct inode *inode = vma->vm_file->f_dentry->d_inode;
+               struct inode *inode = vma->vm_file->f_path.dentry->d_inode;
                dev = inode->i_sb->s_dev;
                ino = inode->i_ino;
        }
@@ -156,7 +156,7 @@ static int show_map_internal(struct seq_file *m, void *v, struct mem_size_stats
         */
        if (file) {
                pad_len_spaces(m, len);
-               seq_path(m, file->f_vfsmnt, file->f_dentry, "\n");
+               seq_path(m, file->f_path.mnt, file->f_path.dentry, "\n");
        } else {
                const char *name = arch_vma_name(vma);
                if (!name) {
index 091aa8e48e0285f825f513a3ca9daa760edc56d6..fcc5caf93f554594aa3a9873abef5c22b67abfa6 100644 (file)
@@ -126,8 +126,8 @@ int proc_exe_link(struct inode *inode, struct dentry **dentry, struct vfsmount *
        }
 
        if (vma) {
-               *mnt = mntget(vma->vm_file->f_vfsmnt);
-               *dentry = dget(vma->vm_file->f_dentry);
+               *mnt = mntget(vma->vm_file->f_path.mnt);
+               *dentry = dget(vma->vm_file->f_path.dentry);
                result = 0;
        }
 
index 0d7103fa0df5c253217f313f0d5b9599867216ab..c94db1db7a71cdcdb70de74d64fc0edae029e0de 100644 (file)
@@ -22,7 +22,7 @@
 
 static int qnx4_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        unsigned int offset;
        struct buffer_head *bh;
        struct qnx4_inode_entry *de;
index 5a41db2a218dedccfad415885fd54727d0c2fade..c047dc654d5c4999ead8383f190b2013d6f14d11 100644 (file)
@@ -515,12 +515,12 @@ static void qnx4_read_inode(struct inode *inode)
        brelse(bh);
 }
 
-static kmem_cache_t *qnx4_inode_cachep;
+static struct kmem_cache *qnx4_inode_cachep;
 
 static struct inode *qnx4_alloc_inode(struct super_block *sb)
 {
        struct qnx4_inode_info *ei;
-       ei = kmem_cache_alloc(qnx4_inode_cachep, SLAB_KERNEL);
+       ei = kmem_cache_alloc(qnx4_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        return &ei->vfs_inode;
@@ -531,7 +531,7 @@ static void qnx4_destroy_inode(struct inode *inode)
        kmem_cache_free(qnx4_inode_cachep, qnx4_i(inode));
 }
 
-static void init_once(void *foo, kmem_cache_t * cachep,
+static void init_once(void *foo, struct kmem_cache * cachep,
                      unsigned long flags)
 {
        struct qnx4_inode_info *ei = (struct qnx4_inode_info *) foo;
index bfe5dbf1002e597a5b0b5ca25cfb9ea411b1c36e..61cbe1ef06b99c9d423f2be0aad2c8f979e759fa 100644 (file)
@@ -232,7 +232,7 @@ unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
                                            unsigned long pgoff, unsigned long flags)
 {
        unsigned long maxpages, lpages, nr, loop, ret;
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct page **pages = NULL, **ptr, *page;
        loff_t isize;
 
index f792000a28e63179ce88fea9bbeba93f48b9dc94..1d3dda4fa70cdac79cffcccb16cb03a279f3268b 100644 (file)
@@ -64,13 +64,13 @@ loff_t remote_llseek(struct file *file, loff_t offset, int origin)
        lock_kernel();
        switch (origin) {
                case 2:
-                       offset += i_size_read(file->f_dentry->d_inode);
+                       offset += i_size_read(file->f_path.dentry->d_inode);
                        break;
                case 1:
                        offset += file->f_pos;
        }
        retval = -EINVAL;
-       if (offset>=0 && offset<=file->f_dentry->d_inode->i_sb->s_maxbytes) {
+       if (offset>=0 && offset<=file->f_path.dentry->d_inode->i_sb->s_maxbytes) {
                if (offset != file->f_pos) {
                        file->f_pos = offset;
                        file->f_version = 0;
@@ -95,7 +95,7 @@ loff_t default_llseek(struct file *file, loff_t offset, int origin)
        lock_kernel();
        switch (origin) {
                case 2:
-                       offset += i_size_read(file->f_dentry->d_inode);
+                       offset += i_size_read(file->f_path.dentry->d_inode);
                        break;
                case 1:
                        offset += file->f_pos;
@@ -203,7 +203,7 @@ int rw_verify_area(int read_write, struct file *file, loff_t *ppos, size_t count
        if (unlikely((pos < 0) || (loff_t) (pos + count) < 0))
                goto Einval;
 
-       inode = file->f_dentry->d_inode;
+       inode = file->f_path.dentry->d_inode;
        if (unlikely(inode->i_flock && MANDATORY_LOCK(inode))) {
                int retval = locks_mandatory_area(
                        read_write == READ ? FLOCK_VERIFY_READ : FLOCK_VERIFY_WRITE,
@@ -273,7 +273,7 @@ ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
                        else
                                ret = do_sync_read(file, buf, count, pos);
                        if (ret > 0) {
-                               fsnotify_access(file->f_dentry);
+                               fsnotify_access(file->f_path.dentry);
                                current->rchar += ret;
                        }
                        current->syscr++;
@@ -331,7 +331,7 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
                        else
                                ret = do_sync_write(file, buf, count, pos);
                        if (ret > 0) {
-                               fsnotify_modify(file->f_dentry);
+                               fsnotify_modify(file->f_path.dentry);
                                current->wchar += ret;
                        }
                        current->syscw++;
@@ -628,9 +628,9 @@ out:
                kfree(iov);
        if ((ret + (type == READ)) > 0) {
                if (type == READ)
-                       fsnotify_access(file->f_dentry);
+                       fsnotify_access(file->f_path.dentry);
                else
-                       fsnotify_modify(file->f_dentry);
+                       fsnotify_modify(file->f_path.dentry);
        }
        return ret;
 }
@@ -722,7 +722,7 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
        if (!(in_file->f_mode & FMODE_READ))
                goto fput_in;
        retval = -EINVAL;
-       in_inode = in_file->f_dentry->d_inode;
+       in_inode = in_file->f_path.dentry->d_inode;
        if (!in_inode)
                goto fput_in;
        if (!in_file->f_op || !in_file->f_op->sendfile)
@@ -754,7 +754,7 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
        retval = -EINVAL;
        if (!out_file->f_op || !out_file->f_op->sendpage)
                goto fput_out;
-       out_inode = out_file->f_dentry->d_inode;
+       out_inode = out_file->f_path.dentry->d_inode;
        retval = rw_verify_area(WRITE, out_file, &out_file->f_pos, count);
        if (retval < 0)
                goto fput_out;
index bff3ee58e2f86ecd8e599e104b46e7faa04752f5..f39f5b3132527243a5eb08979d7bf5aebaaa9f15 100644 (file)
@@ -21,7 +21,7 @@
 
 int vfs_readdir(struct file *file, filldir_t filler, void *buf)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int res = -ENOTDIR;
        if (!file->f_op || !file->f_op->readdir)
                goto out;
index e3d466a228d40bd9756bafe76a4f5a419b43a8cf..b286ccb085879172a6bac6f5055c14b4c3cd363a 100644 (file)
@@ -708,7 +708,7 @@ static void oid_groups(reiserfs_blocknr_hint_t * hint)
  */
 static int get_left_neighbor(reiserfs_blocknr_hint_t * hint)
 {
-       struct path *path;
+       struct treepath *path;
        struct buffer_head *bh;
        struct item_head *ih;
        int pos_in_item;
index 657050ad7430e68777a326c18fad5a4d8a04cefb..96a2f8889da3a52073805b013cccb6223f706df5 100644 (file)
@@ -45,7 +45,7 @@ static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry,
 //
 static int reiserfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct cpu_key pos_key; /* key of current position in the directory (key of directory entry) */
        INITIALIZE_PATH(path_to_entry);
        struct buffer_head *bh;
@@ -135,7 +135,7 @@ static int reiserfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
                                /* Ignore the .reiserfs_priv entry */
                                if (reiserfs_xattrs(inode->i_sb) &&
                                    !old_format_only(inode->i_sb) &&
-                                   filp->f_dentry == inode->i_sb->s_root &&
+                                   filp->f_path.dentry == inode->i_sb->s_root &&
                                    REISERFS_SB(inode->i_sb)->priv_root &&
                                    REISERFS_SB(inode->i_sb)->priv_root->d_inode
                                    && deh_objectid(deh) ==
index ac14318c81ba71eaf944e120c26f4b9630d16b0e..99b6f329ba23edc7b513e9b7dd606028497bb275 100644 (file)
@@ -317,12 +317,11 @@ static int reiserfs_allocate_blocks_for_region(struct reiserfs_transaction_handl
                        /* area filled with zeroes, to supply as list of zero blocknumbers
                           We allocate it outside of loop just in case loop would spin for
                           several iterations. */
-                       char *zeros = kmalloc(to_paste * UNFM_P_SIZE, GFP_ATOMIC);      // We cannot insert more than MAX_ITEM_LEN bytes anyway.
+                       char *zeros = kzalloc(to_paste * UNFM_P_SIZE, GFP_ATOMIC);      // We cannot insert more than MAX_ITEM_LEN bytes anyway.
                        if (!zeros) {
                                res = -ENOMEM;
                                goto error_exit_free_blocks;
                        }
-                       memset(zeros, 0, to_paste * UNFM_P_SIZE);
                        do {
                                to_paste =
                                    min_t(__u64, hole_size,
@@ -407,6 +406,8 @@ static int reiserfs_allocate_blocks_for_region(struct reiserfs_transaction_handl
                                   we restart it. This will also free the path. */
                                if (journal_transaction_should_end
                                    (th, th->t_blocks_allocated)) {
+                                       inode->i_size = cpu_key_k_offset(&key) +
+                                               (to_paste << inode->i_blkbits);
                                        res =
                                            restart_transaction(th, inode,
                                                                &path);
@@ -1045,6 +1046,7 @@ static int reiserfs_prepare_file_region_for_write(struct inode *inode
                        char *kaddr = kmap_atomic(prepared_pages[0], KM_USER0);
                        memset(kaddr, 0, from);
                        kunmap_atomic(kaddr, KM_USER0);
+                       flush_dcache_page(prepared_pages[0]);
                }
                if (to != PAGE_CACHE_SIZE) {    /* Last page needs to be partially zeroed */
                        char *kaddr =
@@ -1052,6 +1054,7 @@ static int reiserfs_prepare_file_region_for_write(struct inode *inode
                                        KM_USER0);
                        memset(kaddr + to, 0, PAGE_CACHE_SIZE - to);
                        kunmap_atomic(kaddr, KM_USER0);
+                       flush_dcache_page(prepared_pages[num_pages - 1]);
                }
 
                /* Since all blocks are new - use already calculated value */
@@ -1185,6 +1188,7 @@ static int reiserfs_prepare_file_region_for_write(struct inode *inode
                                        memset(kaddr + block_start, 0,
                                               from - block_start);
                                        kunmap_atomic(kaddr, KM_USER0);
+                                       flush_dcache_page(prepared_pages[0]);
                                        set_buffer_uptodate(bh);
                                }
                        }
@@ -1222,6 +1226,7 @@ static int reiserfs_prepare_file_region_for_write(struct inode *inode
                                                        KM_USER0);
                                        memset(kaddr + to, 0, block_end - to);
                                        kunmap_atomic(kaddr, KM_USER0);
+                                       flush_dcache_page(prepared_pages[num_pages - 1]);
                                        set_buffer_uptodate(bh);
                                }
                        }
@@ -1283,7 +1288,7 @@ static ssize_t reiserfs_file_write(struct file *file,     /* the file we are going t
        loff_t pos;             // Current position in the file.
        ssize_t res;            // return value of various functions that we call.
        int err = 0;
-       struct inode *inode = file->f_dentry->d_inode;  // Inode of the file that we are writing to.
+       struct inode *inode = file->f_path.dentry->d_inode;     // Inode of the file that we are writing to.
        /* To simplify coding at this time, we store
           locked pages in array for now */
        struct page *prepared_pages[REISERFS_WRITE_PAGES_AT_A_TIME];
@@ -1307,56 +1312,8 @@ static ssize_t reiserfs_file_write(struct file *file,    /* the file we are going t
                        count = MAX_NON_LFS - (unsigned long)*ppos;
        }
 
-       if (file->f_flags & O_DIRECT) { // Direct IO needs treatment
-               ssize_t result, after_file_end = 0;
-               if ((*ppos + count >= inode->i_size)
-                   || (file->f_flags & O_APPEND)) {
-                       /* If we are appending a file, we need to put this savelink in here.
-                          If we will crash while doing direct io, finish_unfinished will
-                          cut the garbage from the file end. */
-                       reiserfs_write_lock(inode->i_sb);
-                       err =
-                           journal_begin(&th, inode->i_sb,
-                                         JOURNAL_PER_BALANCE_CNT);
-                       if (err) {
-                               reiserfs_write_unlock(inode->i_sb);
-                               return err;
-                       }
-                       reiserfs_update_inode_transaction(inode);
-                       add_save_link(&th, inode, 1 /* Truncate */ );
-                       after_file_end = 1;
-                       err =
-                           journal_end(&th, inode->i_sb,
-                                       JOURNAL_PER_BALANCE_CNT);
-                       reiserfs_write_unlock(inode->i_sb);
-                       if (err)
-                               return err;
-               }
-               result = do_sync_write(file, buf, count, ppos);
-
-               if (after_file_end) {   /* Now update i_size and remove the savelink */
-                       struct reiserfs_transaction_handle th;
-                       reiserfs_write_lock(inode->i_sb);
-                       err = journal_begin(&th, inode->i_sb, 1);
-                       if (err) {
-                               reiserfs_write_unlock(inode->i_sb);
-                               return err;
-                       }
-                       reiserfs_update_inode_transaction(inode);
-                       mark_inode_dirty(inode);
-                       err = journal_end(&th, inode->i_sb, 1);
-                       if (err) {
-                               reiserfs_write_unlock(inode->i_sb);
-                               return err;
-                       }
-                       err = remove_save_link(inode, 1 /* truncate */ );
-                       reiserfs_write_unlock(inode->i_sb);
-                       if (err)
-                               return err;
-               }
-
-               return result;
-       }
+       if (file->f_flags & O_DIRECT)
+               return do_sync_write(file, buf, count, ppos);
 
        if (unlikely((ssize_t) count < 0))
                return -EINVAL;
@@ -1378,7 +1335,7 @@ static ssize_t reiserfs_file_write(struct file *file,     /* the file we are going t
        if (count == 0)
                goto out;
 
-       res = remove_suid(file->f_dentry);
+       res = remove_suid(file->f_path.dentry);
        if (res)
                goto out;
 
index 6d0e554daa9d845fd9a608826654f84cc6834f59..0ee35c6c9b722ef225e666f63713e4d92cf29be6 100644 (file)
@@ -957,7 +957,7 @@ static int get_far_parent(struct tree_balance *p_s_tb,
 {
        struct buffer_head *p_s_parent;
        INITIALIZE_PATH(s_path_to_neighbor_father);
-       struct path *p_s_path = p_s_tb->tb_path;
+       struct treepath *p_s_path = p_s_tb->tb_path;
        struct cpu_key s_lr_father_key;
        int n_counter,
            n_position = INT_MAX,
@@ -1074,7 +1074,7 @@ static int get_far_parent(struct tree_balance *p_s_tb,
  */
 static int get_parents(struct tree_balance *p_s_tb, int n_h)
 {
-       struct path *p_s_path = p_s_tb->tb_path;
+       struct treepath *p_s_path = p_s_tb->tb_path;
        int n_position,
            n_ret_value,
            n_path_offset = PATH_H_PATH_OFFSET(p_s_tb->tb_path, n_h);
@@ -1885,7 +1885,7 @@ static int check_balance(int mode,
 static int get_direct_parent(struct tree_balance *p_s_tb, int n_h)
 {
        struct buffer_head *p_s_bh;
-       struct path *p_s_path = p_s_tb->tb_path;
+       struct treepath *p_s_path = p_s_tb->tb_path;
        int n_position,
            n_path_offset = PATH_H_PATH_OFFSET(p_s_tb->tb_path, n_h);
 
index 9c69bcacad2286c1e7a926bf2a5000ae9d84da64..f3d1c4a77979d1506903c88df9c8cdc76c388a09 100644 (file)
@@ -207,7 +207,7 @@ static int file_capable(struct inode *inode, long block)
 }
 
 /*static*/ int restart_transaction(struct reiserfs_transaction_handle *th,
-                                  struct inode *inode, struct path *path)
+                                  struct inode *inode, struct treepath *path)
 {
        struct super_block *s = th->t_super;
        int len = th->t_blocks_allocated;
@@ -216,11 +216,12 @@ static int file_capable(struct inode *inode, long block)
        BUG_ON(!th->t_trans_id);
        BUG_ON(!th->t_refcount);
 
+       pathrelse(path);
+
        /* we cannot restart while nested */
        if (th->t_refcount > 1) {
                return 0;
        }
-       pathrelse(path);
        reiserfs_update_sd(th, inode);
        err = journal_end(th, s, len);
        if (!err) {
@@ -569,7 +570,7 @@ static inline int _allocate_block(struct reiserfs_transaction_handle *th,
                                  long block,
                                  struct inode *inode,
                                  b_blocknr_t * allocated_block_nr,
-                                 struct path *path, int flags)
+                                 struct treepath *path, int flags)
 {
        BUG_ON(!th->t_trans_id);
 
@@ -928,15 +929,12 @@ int reiserfs_get_block(struct inode *inode, sector_t block,
                        if (blocks_needed == 1) {
                                un = &unf_single;
                        } else {
-                               un = kmalloc(min(blocks_needed, max_to_insert) * UNFM_P_SIZE, GFP_ATOMIC);      // We need to avoid scheduling.
+                               un = kzalloc(min(blocks_needed, max_to_insert) * UNFM_P_SIZE, GFP_ATOMIC);      // We need to avoid scheduling.
                                if (!un) {
                                        un = &unf_single;
                                        blocks_needed = 1;
                                        max_to_insert = 0;
-                               } else
-                                       memset(un, 0,
-                                              UNFM_P_SIZE * min(blocks_needed,
-                                                                max_to_insert));
+                               }
                        }
                        if (blocks_needed <= max_to_insert) {
                                /* we are going to add target block to the file. Use allocated
@@ -1109,7 +1107,7 @@ static inline ulong to_fake_used_blocks(struct inode *inode, int sd_size)
 //
 
 // called by read_locked_inode
-static void init_inode(struct inode *inode, struct path *path)
+static void init_inode(struct inode *inode, struct treepath *path)
 {
        struct buffer_head *bh;
        struct item_head *ih;
@@ -1286,7 +1284,7 @@ static void inode2sd_v1(void *sd, struct inode *inode, loff_t size)
 /* NOTE, you must prepare the buffer head before sending it here,
 ** and then log it after the call
 */
-static void update_stat_data(struct path *path, struct inode *inode,
+static void update_stat_data(struct treepath *path, struct inode *inode,
                             loff_t size)
 {
        struct buffer_head *bh;
@@ -1655,7 +1653,7 @@ int reiserfs_write_inode(struct inode *inode, int do_sync)
    containing "." and ".." entries */
 static int reiserfs_new_directory(struct reiserfs_transaction_handle *th,
                                  struct inode *inode,
-                                 struct item_head *ih, struct path *path,
+                                 struct item_head *ih, struct treepath *path,
                                  struct inode *dir)
 {
        struct super_block *sb = th->t_super;
@@ -1714,7 +1712,7 @@ static int reiserfs_new_directory(struct reiserfs_transaction_handle *th,
    containing the body of symlink */
 static int reiserfs_new_symlink(struct reiserfs_transaction_handle *th, struct inode *inode,   /* Inode of symlink */
                                struct item_head *ih,
-                               struct path *path, const char *symname,
+                               struct treepath *path, const char *symname,
                                int item_len)
 {
        struct super_block *sb = th->t_super;
index 9c57578cb831a2f869c7e277896b04b06a369c80..b484d2913c0dc18389fe242fd9c1568d578dd82f 100644 (file)
@@ -99,7 +99,7 @@ int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
 long reiserfs_compat_ioctl(struct file *file, unsigned int cmd,
                                unsigned long arg)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int ret;
 
        /* These are just misnamed, they actually get/put from/to user an int */
index abde1edc2235605c9a4a9680cfdcafbf830f6a12..23f5cd5bbf564253d4012c82b60490facc56e40f 100644 (file)
@@ -54,7 +54,7 @@ static int bin_search_in_dir_item(struct reiserfs_dir_entry *de, loff_t off)
 
 // comment?  maybe something like set de to point to what the path points to?
 static inline void set_de_item_location(struct reiserfs_dir_entry *de,
-                                       struct path *path)
+                                       struct treepath *path)
 {
        de->de_bh = get_last_bh(path);
        de->de_ih = get_ih(path);
@@ -113,7 +113,7 @@ entry position in the item
 
 /* The function is NOT SCHEDULE-SAFE! */
 int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
-                       struct path *path, struct reiserfs_dir_entry *de)
+                       struct treepath *path, struct reiserfs_dir_entry *de)
 {
        int retval;
 
@@ -282,7 +282,7 @@ static int linear_search_in_dir_item(struct cpu_key *key,
 // may return NAME_FOUND, NAME_FOUND_INVISIBLE, NAME_NOT_FOUND
 // FIXME: should add something like IOERROR
 static int reiserfs_find_entry(struct inode *dir, const char *name, int namelen,
-                              struct path *path_to_entry,
+                              struct treepath *path_to_entry,
                               struct reiserfs_dir_entry *de)
 {
        struct cpu_key key_to_search;
index c533ec1bcaec3461a8c7e7cee9d3451a12258d93..ecc9943202fc571a45d43a511434db39e7f24e5b 100644 (file)
@@ -295,7 +295,7 @@ static int show_oidmap(struct seq_file *m, struct super_block *sb)
        }
 #if defined( REISERFS_USE_OIDMAPF )
        if (sb_info->oidmap.use_file && (sb_info->oidmap.mapf != NULL)) {
-               loff_t size = sb_info->oidmap.mapf->f_dentry->d_inode->i_size;
+               loff_t size = sb_info->oidmap.mapf->f_path.dentry->d_inode->i_size;
                total_used += size / sizeof(reiserfs_oidinterval_d_t);
        }
 #endif
index 5240abe1a709df1411785d61a66cc64d28d8abf4..47e7027ea39f5183f0aadeb8148b41179fe3ee27 100644 (file)
@@ -244,7 +244,7 @@ static const struct reiserfs_key MAX_KEY = {
    of the path, and going upwards.  We must check the path's validity at each step.  If the key is not in
    the path, there is no delimiting key in the tree (buffer is first or last buffer in tree), and in this
    case we return a special key, either MIN_KEY or MAX_KEY. */
-static inline const struct reiserfs_key *get_lkey(const struct path
+static inline const struct reiserfs_key *get_lkey(const struct treepath
                                                  *p_s_chk_path,
                                                  const struct super_block
                                                  *p_s_sb)
@@ -290,7 +290,7 @@ static inline const struct reiserfs_key *get_lkey(const struct path
 }
 
 /* Get delimiting key of the buffer at the path and its right neighbor. */
-inline const struct reiserfs_key *get_rkey(const struct path *p_s_chk_path,
+inline const struct reiserfs_key *get_rkey(const struct treepath *p_s_chk_path,
                                           const struct super_block *p_s_sb)
 {
        int n_position, n_path_offset = p_s_chk_path->path_length;
@@ -337,7 +337,7 @@ inline const struct reiserfs_key *get_rkey(const struct path *p_s_chk_path,
    the path.  These delimiting keys are stored at least one level above that buffer in the tree. If the
    buffer is the first or last node in the tree order then one of the delimiting keys may be absent, and in
    this case get_lkey and get_rkey return a special key which is MIN_KEY or MAX_KEY. */
-static inline int key_in_buffer(struct path *p_s_chk_path,     /* Path which should be checked.  */
+static inline int key_in_buffer(struct treepath *p_s_chk_path, /* Path which should be checked.  */
                                const struct cpu_key *p_s_key,  /* Key which should be checked.   */
                                struct super_block *p_s_sb      /* Super block pointer.           */
     )
@@ -374,7 +374,7 @@ inline void decrement_bcount(struct buffer_head *p_s_bh)
 }
 
 /* Decrement b_count field of the all buffers in the path. */
-void decrement_counters_in_path(struct path *p_s_search_path)
+void decrement_counters_in_path(struct treepath *p_s_search_path)
 {
        int n_path_offset = p_s_search_path->path_length;
 
@@ -391,7 +391,7 @@ void decrement_counters_in_path(struct path *p_s_search_path)
        p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
 }
 
-int reiserfs_check_path(struct path *p)
+int reiserfs_check_path(struct treepath *p)
 {
        RFALSE(p->path_length != ILLEGAL_PATH_ELEMENT_OFFSET,
               "path not properly relsed");
@@ -403,7 +403,7 @@ int reiserfs_check_path(struct path *p)
 **
 ** only called from fix_nodes()
 */
-void pathrelse_and_restore(struct super_block *s, struct path *p_s_search_path)
+void pathrelse_and_restore(struct super_block *s, struct treepath *p_s_search_path)
 {
        int n_path_offset = p_s_search_path->path_length;
 
@@ -421,7 +421,7 @@ void pathrelse_and_restore(struct super_block *s, struct path *p_s_search_path)
 }
 
 /* Release all buffers in the path. */
-void pathrelse(struct path *p_s_search_path)
+void pathrelse(struct treepath *p_s_search_path)
 {
        int n_path_offset = p_s_search_path->path_length;
 
@@ -602,7 +602,7 @@ static void search_by_key_reada(struct super_block *s,
    correctness of the bottom of the path */
 /* The function is NOT SCHEDULE-SAFE! */
 int search_by_key(struct super_block *p_s_sb, const struct cpu_key *p_s_key,   /* Key to search. */
-                 struct path *p_s_search_path, /* This structure was
+                 struct treepath *p_s_search_path,/* This structure was
                                                   allocated and initialized
                                                   by the calling
                                                   function. It is filled up
@@ -813,7 +813,7 @@ int search_by_key(struct super_block *p_s_sb, const struct cpu_key *p_s_key,        /*
 /* The function is NOT SCHEDULE-SAFE! */
 int search_for_position_by_key(struct super_block *p_s_sb,     /* Pointer to the super block.          */
                               const struct cpu_key *p_cpu_key, /* Key to search (cpu variable)         */
-                              struct path *p_s_search_path     /* Filled up by this function.          */
+                              struct treepath *p_s_search_path /* Filled up by this function.          */
     )
 {
        struct item_head *p_le_ih;      /* pointer to on-disk structure */
@@ -884,7 +884,7 @@ int search_for_position_by_key(struct super_block *p_s_sb,  /* Pointer to the sup
 }
 
 /* Compare given item and item pointed to by the path. */
-int comp_items(const struct item_head *stored_ih, const struct path *p_s_path)
+int comp_items(const struct item_head *stored_ih, const struct treepath *p_s_path)
 {
        struct buffer_head *p_s_bh;
        struct item_head *ih;
@@ -911,7 +911,7 @@ int comp_items(const struct item_head *stored_ih, const struct path *p_s_path)
 #define block_in_use(bh) (buffer_locked(bh) || (held_by_others(bh)))
 
 // prepare for delete or cut of direct item
-static inline int prepare_for_direct_item(struct path *path,
+static inline int prepare_for_direct_item(struct treepath *path,
                                          struct item_head *le_ih,
                                          struct inode *inode,
                                          loff_t new_file_length, int *cut_size)
@@ -952,7 +952,7 @@ static inline int prepare_for_direct_item(struct path *path,
        return M_CUT;           /* Cut from this item. */
 }
 
-static inline int prepare_for_direntry_item(struct path *path,
+static inline int prepare_for_direntry_item(struct treepath *path,
                                            struct item_head *le_ih,
                                            struct inode *inode,
                                            loff_t new_file_length,
@@ -987,7 +987,7 @@ static inline int prepare_for_direntry_item(struct path *path,
     In case of file truncate calculate whether this item must be deleted/truncated or last
     unformatted node of this item will be converted to a direct item.
     This function returns a determination of what balance mode the calling function should employ. */
-static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, struct inode *inode, struct path *p_s_path, const struct cpu_key *p_s_item_key, int *p_n_removed,        /* Number of unformatted nodes which were removed
+static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, struct inode *inode, struct treepath *p_s_path, const struct cpu_key *p_s_item_key, int *p_n_removed,    /* Number of unformatted nodes which were removed
                                                                                                                                                                                   from end of the file. */
                                      int *p_n_cut_size, unsigned long long n_new_file_length   /* MAX_KEY_OFFSET in case of delete. */
     )
@@ -1125,7 +1125,7 @@ static int calc_deleted_bytes_number(struct tree_balance *p_s_tb, char c_mode)
 static void init_tb_struct(struct reiserfs_transaction_handle *th,
                           struct tree_balance *p_s_tb,
                           struct super_block *p_s_sb,
-                          struct path *p_s_path, int n_size)
+                          struct treepath *p_s_path, int n_size)
 {
 
        BUG_ON(!th->t_trans_id);
@@ -1176,7 +1176,7 @@ char head2type(struct item_head *ih)
 #endif
 
 /* Delete object item. */
-int reiserfs_delete_item(struct reiserfs_transaction_handle *th, struct path *p_s_path,        /* Path to the deleted item. */
+int reiserfs_delete_item(struct reiserfs_transaction_handle *th, struct treepath *p_s_path,    /* Path to the deleted item. */
                         const struct cpu_key *p_s_item_key,    /* Key to search for the deleted item.  */
                         struct inode *p_s_inode,       /* inode is here just to update i_blocks and quotas */
                         struct buffer_head *p_s_un_bh)
@@ -1468,7 +1468,7 @@ static void unmap_buffers(struct page *page, loff_t pos)
 static int maybe_indirect_to_direct(struct reiserfs_transaction_handle *th,
                                    struct inode *p_s_inode,
                                    struct page *page,
-                                   struct path *p_s_path,
+                                   struct treepath *p_s_path,
                                    const struct cpu_key *p_s_item_key,
                                    loff_t n_new_file_size, char *p_c_mode)
 {
@@ -1503,7 +1503,7 @@ static int maybe_indirect_to_direct(struct reiserfs_transaction_handle *th,
    pointer being converted. Therefore we have to delete inserted
    direct item(s) */
 static void indirect_to_direct_roll_back(struct reiserfs_transaction_handle *th,
-                                        struct inode *inode, struct path *path)
+                                        struct inode *inode, struct treepath *path)
 {
        struct cpu_key tail_key;
        int tail_len;
@@ -1545,7 +1545,7 @@ static void indirect_to_direct_roll_back(struct reiserfs_transaction_handle *th,
 
 /* (Truncate or cut entry) or delete object item. Returns < 0 on failure */
 int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th,
-                          struct path *p_s_path,
+                          struct treepath *p_s_path,
                           struct cpu_key *p_s_item_key,
                           struct inode *p_s_inode,
                           struct page *page, loff_t n_new_file_size)
@@ -1920,7 +1920,7 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th, struct inode *p
 
 #ifdef CONFIG_REISERFS_CHECK
 // this makes sure, that we __append__, not overwrite or add holes
-static void check_research_for_paste(struct path *path,
+static void check_research_for_paste(struct treepath *path,
                                     const struct cpu_key *p_s_key)
 {
        struct item_head *found_ih = get_ih(path);
@@ -1954,7 +1954,7 @@ static void check_research_for_paste(struct path *path,
 #endif                         /* config reiserfs check */
 
 /* Paste bytes to the existing item. Returns bytes number pasted into the item. */
-int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct path *p_s_search_path,     /* Path to the pasted item.          */
+int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct treepath *p_s_search_path, /* Path to the pasted item.          */
                             const struct cpu_key *p_s_key,     /* Key to search for the needed item. */
                             struct inode *inode,       /* Inode item belongs to */
                             const char *p_c_body,      /* Pointer to the bytes to paste.    */
@@ -2036,7 +2036,7 @@ int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct path
 }
 
 /* Insert new item into the buffer at the path. */
-int reiserfs_insert_item(struct reiserfs_transaction_handle *th, struct path *p_s_path,        /* Path to the inserteded item.         */
+int reiserfs_insert_item(struct reiserfs_transaction_handle *th, struct treepath *p_s_path,    /* Path to the inserteded item.         */
                         const struct cpu_key *key, struct item_head *p_s_ih,   /* Pointer to the item header to insert. */
                         struct inode *inode, const char *p_c_body)
 {                              /* Pointer to the bytes to insert.      */
index 17249994110f5fcf1f8a9f07c18bfb3a35710ca2..58ad4551a7c144d07a42d74843a5f568bb4f9366 100644 (file)
@@ -23,7 +23,7 @@
 #include <linux/blkdev.h>
 #include <linux/buffer_head.h>
 #include <linux/vfs.h>
-#include <linux/namespace.h>
+#include <linux/mnt_namespace.h>
 #include <linux/mount.h>
 #include <linux/namei.h>
 #include <linux/quotaops.h>
@@ -490,13 +490,13 @@ static void reiserfs_put_super(struct super_block *s)
        return;
 }
 
-static kmem_cache_t *reiserfs_inode_cachep;
+static struct kmem_cache *reiserfs_inode_cachep;
 
 static struct inode *reiserfs_alloc_inode(struct super_block *sb)
 {
        struct reiserfs_inode_info *ei;
        ei = (struct reiserfs_inode_info *)
-           kmem_cache_alloc(reiserfs_inode_cachep, SLAB_KERNEL);
+           kmem_cache_alloc(reiserfs_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        return &ei->vfs_inode;
@@ -507,7 +507,7 @@ static void reiserfs_destroy_inode(struct inode *inode)
        kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode));
 }
 
-static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void *foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo;
 
@@ -1549,13 +1549,12 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
        struct reiserfs_sb_info *sbi;
        int errval = -EINVAL;
 
-       sbi = kmalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL);
+       sbi = kzalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL);
        if (!sbi) {
                errval = -ENOMEM;
                goto error;
        }
        s->s_fs_info = sbi;
-       memset(sbi, 0, sizeof(struct reiserfs_sb_info));
        /* Set default values for options: non-aggressive tails, RO on errors */
        REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_SMALLTAIL);
        REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_ERROR_RO);
index 36f108fc1cf5fde849204bdc14a146e72fb7e600..f8121a1147e863e80039ba676939b9c5abd7bd7f 100644 (file)
@@ -15,7 +15,7 @@
 /* path points to first direct item of the file regarless of how many of
    them are there */
 int direct2indirect(struct reiserfs_transaction_handle *th, struct inode *inode,
-                   struct path *path, struct buffer_head *unbh,
+                   struct treepath *path, struct buffer_head *unbh,
                    loff_t tail_offset)
 {
        struct super_block *sb = inode->i_sb;
@@ -171,7 +171,7 @@ void reiserfs_unmap_buffer(struct buffer_head *bh)
    what we expect from it (number of cut bytes). But when tail remains
    in the unformatted node, we set mode to SKIP_BALANCING and unlock
    inode */
-int indirect2direct(struct reiserfs_transaction_handle *th, struct inode *p_s_inode, struct page *page, struct path *p_s_path, /* path to the indirect item. */
+int indirect2direct(struct reiserfs_transaction_handle *th, struct inode *p_s_inode, struct page *page, struct treepath *p_s_path,     /* path to the indirect item. */
                    const struct cpu_key *p_s_item_key, /* Key to look for unformatted node pointer to be cut. */
                    loff_t n_new_file_size,     /* New file size. */
                    char *p_c_mode)
index 1e4d685901785284f45e3473f1da8d78b4929ee4..f01389fd162e0a3d7befea369945546ea1355528 100644 (file)
@@ -274,7 +274,7 @@ static struct file *open_xa_file(const struct inode *inode, const char *name,
  */
 static int __xattr_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct cpu_key pos_key; /* key of current position in the directory (key of directory entry) */
        INITIALIZE_PATH(path_to_entry);
        struct buffer_head *bh;
@@ -420,7 +420,7 @@ static int __xattr_readdir(struct file *filp, void *dirent, filldir_t filldir)
 static
 int xattr_readdir(struct file *file, filldir_t filler, void *buf)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int res = -ENOTDIR;
        if (!file->f_op || !file->f_op->readdir)
                goto out;
@@ -508,7 +508,7 @@ reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer,
                goto out;
        }
 
-       xinode = fp->f_dentry->d_inode;
+       xinode = fp->f_path.dentry->d_inode;
        REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
 
        /* we need to copy it off.. */
@@ -527,7 +527,7 @@ reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer,
        newattrs.ia_size = buffer_size;
        newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
        mutex_lock(&xinode->i_mutex);
-       err = notify_change(fp->f_dentry, &newattrs);
+       err = notify_change(fp->f_path.dentry, &newattrs);
        if (err)
                goto out_filp;
 
@@ -626,7 +626,7 @@ reiserfs_xattr_get(const struct inode *inode, const char *name, void *buffer,
                goto out;
        }
 
-       xinode = fp->f_dentry->d_inode;
+       xinode = fp->f_path.dentry->d_inode;
        isize = xinode->i_size;
        REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
 
index ddcd9e1ef2828a52e91e1d5a71754509dc5f8dbb..d3e243a6f609eb5a9536a2851e5e0713590fe077 100644 (file)
@@ -276,7 +276,7 @@ static unsigned char romfs_dtype_table[] = {
 static int
 romfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct inode *i = filp->f_dentry->d_inode;
+       struct inode *i = filp->f_path.dentry->d_inode;
        struct romfs_inode ri;
        unsigned long offset, maxoff;
        int j, ino, nextfh;
@@ -550,12 +550,12 @@ romfs_read_inode(struct inode *i)
        }
 }
 
-static kmem_cache_t * romfs_inode_cachep;
+static struct kmem_cache * romfs_inode_cachep;
 
 static struct inode *romfs_alloc_inode(struct super_block *sb)
 {
        struct romfs_inode_info *ei;
-       ei = (struct romfs_inode_info *)kmem_cache_alloc(romfs_inode_cachep, SLAB_KERNEL);
+       ei = (struct romfs_inode_info *)kmem_cache_alloc(romfs_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        return &ei->vfs_inode;
@@ -566,7 +566,7 @@ static void romfs_destroy_inode(struct inode *inode)
        kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct romfs_inode_info *ei = (struct romfs_inode_info *) foo;
 
index 555b9ac04c25be9ac5354bea2810ef79290ab92e..0ac22af7afe5f2b31ea2d289f68b5ee13e1b9040 100644 (file)
@@ -26,7 +26,7 @@
  *     ERR_PTR(error).  In the end of sequence they return %NULL. ->show()
  *     returns 0 in case of success and negative number in case of error.
  */
-int seq_open(struct file *file, struct seq_operations *op)
+int seq_open(struct file *file, const struct seq_operations *op)
 {
        struct seq_file *p = file->private_data;
 
@@ -269,7 +269,7 @@ EXPORT_SYMBOL(seq_lseek);
 /**
  *     seq_release -   free the structures associated with sequential file.
  *     @file: file in question
- *     @inode: file->f_dentry->d_inode
+ *     @inode: file->f_path.dentry->d_inode
  *
  *     Frees the structures associated with sequential file; can be used
  *     as ->f_op->release() if you don't have private data to destroy.
@@ -408,7 +408,7 @@ EXPORT_SYMBOL(single_open);
 
 int single_release(struct inode *inode, struct file *file)
 {
-       struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
+       const struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
        int res = seq_release(inode, file);
        kfree(op);
        return res;
index 74b86d9725a63cce6a65ad53514cecc3d9437a82..8182f0542a2176aadc221c40d65dfec7e4bb382e 100644 (file)
@@ -125,7 +125,7 @@ smb_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
               struct smb_cache_control *ctrl, struct qstr *qname,
               struct smb_fattr *entry)
 {
-       struct dentry *newdent, *dentry = filp->f_dentry;
+       struct dentry *newdent, *dentry = filp->f_path.dentry;
        struct inode *newino, *inode = dentry->d_inode;
        struct smb_cache_control ctl = *ctrl;
        int valid = 0;
index 70d9c5a37f5a3c6f7d5cad12e7bad8e1d2e21136..b1e58d1ac9ca84090a4519e56a3d2692660f04b3 100644 (file)
@@ -78,7 +78,7 @@ struct inode_operations smb_dir_inode_operations_unix =
 static int 
 smb_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct dentry *dentry = filp->f_dentry;
+       struct dentry *dentry = filp->f_path.dentry;
        struct inode *dir = dentry->d_inode;
        struct smb_sb_info *server = server_from_dentry(dentry);
        union  smb_dir_cache *cache = NULL;
@@ -238,12 +238,12 @@ out:
 static int
 smb_dir_open(struct inode *dir, struct file *file)
 {
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
        struct smb_sb_info *server;
        int error = 0;
 
        VERBOSE("(%s/%s)\n", dentry->d_parent->d_name.name,
-               file->f_dentry->d_name.name);
+               file->f_path.dentry->d_name.name);
 
        /*
         * Directory timestamps in the core protocol aren't updated
index 50784d13c87b55a542d9db3dce156ede054b5a1a..e50533a7951754e2c55ab5176f23f1f3fe582004 100644 (file)
@@ -102,7 +102,7 @@ static int
 smb_readpage(struct file *file, struct page *page)
 {
        int             error;
-       struct dentry  *dentry = file->f_dentry;
+       struct dentry  *dentry = file->f_path.dentry;
 
        page_cache_get(page);
        error = smb_readpage_sync(dentry, page);
@@ -205,7 +205,7 @@ static int
 smb_updatepage(struct file *file, struct page *page, unsigned long offset,
               unsigned int count)
 {
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
 
        DEBUG1("(%s/%s %d@%lld)\n", DENTRY_PATH(dentry), count,
                ((unsigned long long)page->index << PAGE_CACHE_SHIFT) + offset);
@@ -218,7 +218,7 @@ smb_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
                        unsigned long nr_segs, loff_t pos)
 {
        struct file * file = iocb->ki_filp;
-       struct dentry * dentry = file->f_dentry;
+       struct dentry * dentry = file->f_path.dentry;
        ssize_t status;
 
        VERBOSE("file %s/%s, count=%lu@%lu\n", DENTRY_PATH(dentry),
@@ -243,7 +243,7 @@ out:
 static int
 smb_file_mmap(struct file * file, struct vm_area_struct * vma)
 {
-       struct dentry * dentry = file->f_dentry;
+       struct dentry * dentry = file->f_path.dentry;
        int     status;
 
        VERBOSE("file %s/%s, address %lu - %lu\n",
@@ -264,7 +264,7 @@ static ssize_t
 smb_file_sendfile(struct file *file, loff_t *ppos,
                  size_t count, read_actor_t actor, void *target)
 {
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
        ssize_t status;
 
        VERBOSE("file %s/%s, pos=%Ld, count=%d\n",
@@ -323,7 +323,7 @@ smb_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
                               unsigned long nr_segs, loff_t pos)
 {
        struct file * file = iocb->ki_filp;
-       struct dentry * dentry = file->f_dentry;
+       struct dentry * dentry = file->f_path.dentry;
        ssize_t result;
 
        VERBOSE("file %s/%s, count=%lu@%lu\n",
@@ -355,7 +355,7 @@ static int
 smb_file_open(struct inode *inode, struct file * file)
 {
        int result;
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
        int smb_mode = (file->f_mode & O_ACCMODE) - 1;
 
        lock_kernel();
index 2c122ee83adbdd3d693c2c8a4fb671aeca4b85f3..4af4cd729a5a8589706e536d3860175c69b90d2d 100644 (file)
@@ -50,12 +50,12 @@ static void smb_put_super(struct super_block *);
 static int  smb_statfs(struct dentry *, struct kstatfs *);
 static int  smb_show_options(struct seq_file *, struct vfsmount *);
 
-static kmem_cache_t *smb_inode_cachep;
+static struct kmem_cache *smb_inode_cachep;
 
 static struct inode *smb_alloc_inode(struct super_block *sb)
 {
        struct smb_inode_info *ei;
-       ei = (struct smb_inode_info *)kmem_cache_alloc(smb_inode_cachep, SLAB_KERNEL);
+       ei = (struct smb_inode_info *)kmem_cache_alloc(smb_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        return &ei->vfs_inode;
@@ -66,7 +66,7 @@ static void smb_destroy_inode(struct inode *inode)
        kmem_cache_free(smb_inode_cachep, SMB_I(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct smb_inode_info *ei = (struct smb_inode_info *) foo;
        unsigned long flagmask = SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR;
index 40e174db9872fb0a915e83ba77d0b08975a708ff..a5ced9e0c6c482ed0256a6420a8f47f9d88a23cc 100644 (file)
@@ -873,7 +873,7 @@ smb_newconn(struct smb_sb_info *server, struct smb_conn_opt *opt)
        filp = fget(opt->fd);
        if (!filp)
                goto out;
-       if (!smb_valid_socket(filp->f_dentry->d_inode))
+       if (!smb_valid_socket(filp->f_path.dentry->d_inode))
                goto out_putf;
 
        server->sock_file = filp;
@@ -898,7 +898,7 @@ smb_newconn(struct smb_sb_info *server, struct smb_conn_opt *opt)
        /*
         * Store the server in sock user_data (Only used by sunrpc)
         */
-       sk = SOCKET_I(filp->f_dentry->d_inode)->sk;
+       sk = SOCKET_I(filp->f_path.dentry->d_inode)->sk;
        sk->sk_user_data = server;
 
        /* chain into the data_ready callback */
@@ -1939,7 +1939,7 @@ static int
 smb_proc_readdir_short(struct file *filp, void *dirent, filldir_t filldir,
                       struct smb_cache_control *ctl)
 {
-       struct dentry *dir = filp->f_dentry;
+       struct dentry *dir = filp->f_path.dentry;
        struct smb_sb_info *server = server_from_dentry(dir);
        struct qstr qname;
        struct smb_fattr fattr;
@@ -2291,7 +2291,7 @@ static int
 smb_proc_readdir_long(struct file *filp, void *dirent, filldir_t filldir,
                      struct smb_cache_control *ctl)
 {
-       struct dentry *dir = filp->f_dentry;
+       struct dentry *dir = filp->f_path.dentry;
        struct smb_sb_info *server = server_from_dentry(dir);
        struct qstr qname;
        struct smb_fattr fattr;
@@ -2859,7 +2859,7 @@ static int
 smb_proc_readdir_null(struct file *filp, void *dirent, filldir_t filldir,
                      struct smb_cache_control *ctl)
 {
-       struct smb_sb_info *server = server_from_dentry(filp->f_dentry);
+       struct smb_sb_info *server = server_from_dentry(filp->f_path.dentry);
 
        if (smb_proc_ops_wait(server) < 0)
                return -EIO;
index 0fb74697abc401694ea0a0e9aed4f8352a5213c5..a4bcae8a9aff23f0835e996427d38036afb73c47 100644 (file)
@@ -25,7 +25,7 @@
 #define ROUND_UP(x) (((x)+3) & ~3)
 
 /* cache for request structures */
-static kmem_cache_t *req_cachep;
+static struct kmem_cache *req_cachep;
 
 static int smb_request_send_req(struct smb_request *req);
 
@@ -61,7 +61,7 @@ static struct smb_request *smb_do_alloc_request(struct smb_sb_info *server,
        struct smb_request *req;
        unsigned char *buf = NULL;
 
-       req = kmem_cache_alloc(req_cachep, SLAB_KERNEL);
+       req = kmem_cache_alloc(req_cachep, GFP_KERNEL);
        VERBOSE("allocating request: %p\n", req);
        if (!req)
                goto out;
index 6815b1b12b68853351a9af047031de63cfae7782..92ea6b2367d7f69224462396b021d0f23937d4dc 100644 (file)
@@ -82,10 +82,10 @@ server_sock(struct smb_sb_info *server)
        if (server && (file = server->sock_file))
        {
 #ifdef SMBFS_PARANOIA
-               if (!smb_valid_socket(file->f_dentry->d_inode))
+               if (!smb_valid_socket(file->f_path.dentry->d_inode))
                        PARANOIA("bad socket!\n");
 #endif
-               return SOCKET_I(file->f_dentry->d_inode);
+               return SOCKET_I(file->f_path.dentry->d_inode);
        }
        return NULL;
 }
index da74583a00eecd0144159597b0ba3d329683aa0b..bbd0aeb3f68e1723cc11c4be939137ebabb61dfd 100644 (file)
@@ -844,7 +844,7 @@ generic_file_splice_write_nolock(struct pipe_inode_info *pipe, struct file *out,
        ssize_t ret;
        int err;
 
-       err = remove_suid(out->f_dentry);
+       err = remove_suid(out->f_path.dentry);
        if (unlikely(err))
                return err;
 
@@ -890,10 +890,10 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
        ssize_t ret;
        int err;
 
-       err = should_remove_suid(out->f_dentry);
+       err = should_remove_suid(out->f_path.dentry);
        if (unlikely(err)) {
                mutex_lock(&inode->i_mutex);
-               err = __remove_suid(out->f_dentry, err);
+               err = __remove_suid(out->f_path.dentry, err);
                mutex_unlock(&inode->i_mutex);
                if (err)
                        return err;
@@ -1008,7 +1008,7 @@ long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
         * randomly drop data for eg socket -> socket splicing. Use the
         * piped splicing for that!
         */
-       i_mode = in->f_dentry->d_inode->i_mode;
+       i_mode = in->f_path.dentry->d_inode->i_mode;
        if (unlikely(!S_ISREG(i_mode) && !S_ISBLK(i_mode)))
                return -EINVAL;
 
@@ -1132,7 +1132,7 @@ static long do_splice(struct file *in, loff_t __user *off_in,
        loff_t offset, *off;
        long ret;
 
-       pipe = pipe_info(in->f_dentry->d_inode);
+       pipe = pipe_info(in->f_path.dentry->d_inode);
        if (pipe) {
                if (off_in)
                        return -ESPIPE;
@@ -1153,7 +1153,7 @@ static long do_splice(struct file *in, loff_t __user *off_in,
                return ret;
        }
 
-       pipe = pipe_info(out->f_dentry->d_inode);
+       pipe = pipe_info(out->f_path.dentry->d_inode);
        if (pipe) {
                if (off_out)
                        return -ESPIPE;
@@ -1321,7 +1321,7 @@ static long do_vmsplice(struct file *file, const struct iovec __user *iov,
                .ops = &user_page_pipe_buf_ops,
        };
 
-       pipe = pipe_info(file->f_dentry->d_inode);
+       pipe = pipe_info(file->f_path.dentry->d_inode);
        if (!pipe)
                return -EBADF;
        if (unlikely(nr_segs > UIO_MAXIOV))
@@ -1549,8 +1549,8 @@ static int link_pipe(struct pipe_inode_info *ipipe,
 static long do_tee(struct file *in, struct file *out, size_t len,
                   unsigned int flags)
 {
-       struct pipe_inode_info *ipipe = pipe_info(in->f_dentry->d_inode);
-       struct pipe_inode_info *opipe = pipe_info(out->f_dentry->d_inode);
+       struct pipe_inode_info *ipipe = pipe_info(in->f_path.dentry->d_inode);
+       struct pipe_inode_info *opipe = pipe_info(out->f_path.dentry->d_inode);
        int ret = -EINVAL;
 
        /*
diff --git a/fs/stack.c b/fs/stack.c
new file mode 100644 (file)
index 0000000..5ddbc34
--- /dev/null
@@ -0,0 +1,40 @@
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/fs_stack.h>
+
+/* does _NOT_ require i_mutex to be held.
+ *
+ * This function cannot be inlined since i_size_{read,write} is rather
+ * heavy-weight on 32-bit systems
+ */
+void fsstack_copy_inode_size(struct inode *dst, const struct inode *src)
+{
+       i_size_write(dst, i_size_read((struct inode *)src));
+       dst->i_blocks = src->i_blocks;
+}
+EXPORT_SYMBOL_GPL(fsstack_copy_inode_size);
+
+/* copy all attributes; get_nlinks is optional way to override the i_nlink
+ * copying
+ */
+void fsstack_copy_attr_all(struct inode *dest, const struct inode *src,
+                               int (*get_nlinks)(struct inode *))
+{
+       if (!get_nlinks)
+               dest->i_nlink = src->i_nlink;
+       else
+               dest->i_nlink = (*get_nlinks)(dest);
+
+       dest->i_mode = src->i_mode;
+       dest->i_uid = src->i_uid;
+       dest->i_gid = src->i_gid;
+       dest->i_rdev = src->i_rdev;
+       dest->i_atime = src->i_atime;
+       dest->i_mtime = src->i_mtime;
+       dest->i_ctime = src->i_ctime;
+       dest->i_blkbits = src->i_blkbits;
+       dest->i_flags = src->i_flags;
+
+       fsstack_copy_inode_size(dest, src);
+}
+EXPORT_SYMBOL_GPL(fsstack_copy_attr_all);
index bca07eb2003c395b8e40d33cfe3ce548065d9ff7..38a8cb2a28de4292047f93fa6fae59bf1490eb7d 100644 (file)
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -51,13 +51,6 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
                return inode->i_op->getattr(mnt, dentry, stat);
 
        generic_fillattr(inode, stat);
-       if (!stat->blksize) {
-               struct super_block *s = inode->i_sb;
-               unsigned blocks;
-               blocks = (stat->size+s->s_blocksize-1) >> s->s_blocksize_bits;
-               stat->blocks = (s->s_blocksize / 512) * blocks;
-               stat->blksize = s->s_blocksize;
-       }
        return 0;
 }
 
@@ -109,7 +102,7 @@ int vfs_fstat(unsigned int fd, struct kstat *stat)
        int error = -EBADF;
 
        if (f) {
-               error = vfs_getattr(f->f_vfsmnt, f->f_dentry, stat);
+               error = vfs_getattr(f->f_path.mnt, f->f_path.dentry, stat);
                fput(f);
        }
        return error;
index 84c320f6ad7e39471277c581476860caded889e9..f961e03079974a374cdf7476107924e0c2a5ebc0 100644 (file)
@@ -570,7 +570,7 @@ static void mark_files_ro(struct super_block *sb)
 
        file_list_lock();
        list_for_each_entry(f, &sb->s_files, f_u.fu_list) {
-               if (S_ISREG(f->f_dentry->d_inode->i_mode) && file_count(f))
+               if (S_ISREG(f->f_path.dentry->d_inode->i_mode) && file_count(f))
                        f->f_mode &= ~FMODE_WRITE;
        }
        file_list_unlock();
index 865f32be386eadfb4348bb5c048663b2488acd05..d0feff61e6aad6cce80df1d7cad635320b8b25eb 100644 (file)
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -94,7 +94,7 @@ long do_fsync(struct file *file, int datasync)
         * livelocks in fsync_buffers_list().
         */
        mutex_lock(&mapping->host->i_mutex);
-       err = file->f_op->fsync(file, file->f_dentry, datasync);
+       err = file->f_op->fsync(file, file->f_path.dentry, datasync);
        if (!ret)
                ret = err;
        mutex_unlock(&mapping->host->i_mutex);
@@ -223,7 +223,7 @@ asmlinkage long sys_sync_file_range(int fd, loff_t offset, loff_t nbytes,
        if (!file)
                goto out;
 
-       i_mode = file->f_dentry->d_inode->i_mode;
+       i_mode = file->f_path.dentry->d_inode->i_mode;
        ret = -ESPIPE;
        if (!S_ISREG(i_mode) && !S_ISBLK(i_mode) && !S_ISDIR(i_mode) &&
                        !S_ISLNK(i_mode))
index 98022e41cda121aa6f511538691531351e4499e1..e8f540d38d486df31f5ce6482950bcd552b2ebc3 100644 (file)
@@ -35,7 +35,7 @@ static ssize_t
 read(struct file * file, char __user * userbuf, size_t count, loff_t * off)
 {
        char *buffer = file->private_data;
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
        int size = dentry->d_inode->i_size;
        loff_t offs = *off;
        int ret;
@@ -81,7 +81,7 @@ static ssize_t write(struct file * file, const char __user * userbuf,
                     size_t count, loff_t * off)
 {
        char *buffer = file->private_data;
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
        int size = dentry->d_inode->i_size;
        loff_t offs = *off;
 
@@ -105,7 +105,7 @@ static ssize_t write(struct file * file, const char __user * userbuf,
 
 static int mmap(struct file *file, struct vm_area_struct *vma)
 {
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
        struct bin_attribute *attr = to_bin_attr(dentry);
        struct kobject *kobj = to_kobj(dentry->d_parent);
 
@@ -117,8 +117,8 @@ static int mmap(struct file *file, struct vm_area_struct *vma)
 
 static int open(struct inode * inode, struct file * file)
 {
-       struct kobject *kobj = sysfs_get_kobject(file->f_dentry->d_parent);
-       struct bin_attribute * attr = to_bin_attr(file->f_dentry);
+       struct kobject *kobj = sysfs_get_kobject(file->f_path.dentry->d_parent);
+       struct bin_attribute * attr = to_bin_attr(file->f_path.dentry);
        int error = -EINVAL;
 
        if (!kobj || !attr)
@@ -153,8 +153,8 @@ static int open(struct inode * inode, struct file * file)
 
 static int release(struct inode * inode, struct file * file)
 {
-       struct kobject * kobj = to_kobj(file->f_dentry->d_parent);
-       struct bin_attribute * attr = to_bin_attr(file->f_dentry);
+       struct kobject * kobj = to_kobj(file->f_path.dentry->d_parent);
+       struct bin_attribute * attr = to_bin_attr(file->f_path.dentry);
        u8 * buffer = file->private_data;
 
        if (kobj) 
index a5782e8c7f07143262085dda013f62cbbd9c8ecb..511edef8b321a99c8ba4a45ee8e70515d6d3d61b 100644 (file)
@@ -419,7 +419,7 @@ out:
 
 static int sysfs_dir_open(struct inode *inode, struct file *file)
 {
-       struct dentry * dentry = file->f_dentry;
+       struct dentry * dentry = file->f_path.dentry;
        struct sysfs_dirent * parent_sd = dentry->d_fsdata;
 
        mutex_lock(&dentry->d_inode->i_mutex);
@@ -432,7 +432,7 @@ static int sysfs_dir_open(struct inode *inode, struct file *file)
 
 static int sysfs_dir_close(struct inode *inode, struct file *file)
 {
-       struct dentry * dentry = file->f_dentry;
+       struct dentry * dentry = file->f_path.dentry;
        struct sysfs_dirent * cursor = file->private_data;
 
        mutex_lock(&dentry->d_inode->i_mutex);
@@ -452,7 +452,7 @@ static inline unsigned char dt_type(struct sysfs_dirent *sd)
 
 static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
 {
-       struct dentry *dentry = filp->f_dentry;
+       struct dentry *dentry = filp->f_path.dentry;
        struct sysfs_dirent * parent_sd = dentry->d_fsdata;
        struct sysfs_dirent *cursor = filp->private_data;
        struct list_head *p, *q = &cursor->s_sibling;
@@ -509,7 +509,7 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
 
 static loff_t sysfs_dir_lseek(struct file * file, loff_t offset, int origin)
 {
-       struct dentry * dentry = file->f_dentry;
+       struct dentry * dentry = file->f_path.dentry;
 
        mutex_lock(&dentry->d_inode->i_mutex);
        switch (origin) {
@@ -519,7 +519,7 @@ static loff_t sysfs_dir_lseek(struct file * file, loff_t offset, int origin)
                        if (offset >= 0)
                                break;
                default:
-                       mutex_unlock(&file->f_dentry->d_inode->i_mutex);
+                       mutex_unlock(&file->f_path.dentry->d_inode->i_mutex);
                        return -EINVAL;
        }
        if (offset != file->f_pos) {
index 95c165101c98d16e7a6e537ff6b54a2a95b6ccc2..9cfe53e1e00d0c7128a2532644ad79f9f5c2560d 100644 (file)
@@ -154,7 +154,7 @@ sysfs_read_file(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 
        down(&buffer->sem);
        if (buffer->needs_read_fill) {
-               if ((retval = fill_read_buffer(file->f_dentry,buffer)))
+               if ((retval = fill_read_buffer(file->f_path.dentry,buffer)))
                        goto out;
        }
        pr_debug("%s: count = %zd, ppos = %lld, buf = %s\n",
@@ -245,7 +245,7 @@ sysfs_write_file(struct file *file, const char __user *buf, size_t count, loff_t
        down(&buffer->sem);
        len = fill_write_buffer(buffer, buf, count);
        if (len > 0)
-               len = flush_write_buffer(file->f_dentry, buffer, len);
+               len = flush_write_buffer(file->f_path.dentry, buffer, len);
        if (len > 0)
                *ppos += len;
        up(&buffer->sem);
@@ -254,8 +254,8 @@ sysfs_write_file(struct file *file, const char __user *buf, size_t count, loff_t
 
 static int check_perm(struct inode * inode, struct file * file)
 {
-       struct kobject *kobj = sysfs_get_kobject(file->f_dentry->d_parent);
-       struct attribute * attr = to_attr(file->f_dentry);
+       struct kobject *kobj = sysfs_get_kobject(file->f_path.dentry->d_parent);
+       struct attribute * attr = to_attr(file->f_path.dentry);
        struct sysfs_buffer * buffer;
        struct sysfs_ops * ops = NULL;
        int error = 0;
@@ -337,8 +337,8 @@ static int sysfs_open_file(struct inode * inode, struct file * filp)
 
 static int sysfs_release(struct inode * inode, struct file * filp)
 {
-       struct kobject * kobj = to_kobj(filp->f_dentry->d_parent);
-       struct attribute * attr = to_attr(filp->f_dentry);
+       struct kobject * kobj = to_kobj(filp->f_path.dentry->d_parent);
+       struct attribute * attr = to_attr(filp->f_path.dentry);
        struct module * owner = attr->owner;
        struct sysfs_buffer * buffer = filp->private_data;
 
@@ -372,8 +372,8 @@ static int sysfs_release(struct inode * inode, struct file * filp)
 static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
 {
        struct sysfs_buffer * buffer = filp->private_data;
-       struct kobject * kobj = to_kobj(filp->f_dentry->d_parent);
-       struct sysfs_dirent * sd = filp->f_dentry->d_fsdata;
+       struct kobject * kobj = to_kobj(filp->f_path.dentry->d_parent);
+       struct sysfs_dirent * sd = filp->f_path.dentry->d_fsdata;
        int res = 0;
 
        poll_wait(filp, &kobj->poll, wait);
index 20551a1b8a56494ffb7ea2b0a10c01f8f7f99a78..e503f858fba84ffa6462ae042c95077721e41f96 100644 (file)
@@ -16,7 +16,7 @@
 
 struct vfsmount *sysfs_mount;
 struct super_block * sysfs_sb = NULL;
-kmem_cache_t *sysfs_dir_cachep;
+struct kmem_cache *sysfs_dir_cachep;
 
 static struct super_operations sysfs_ops = {
        .statfs         = simple_statfs,
index 6f3d6bd52887bcd541aa917ede96338d47300bfe..bd7cec295dab25dd3451ebf2154bd6784f483695 100644 (file)
@@ -1,6 +1,6 @@
 
 extern struct vfsmount * sysfs_mount;
-extern kmem_cache_t *sysfs_dir_cachep;
+extern struct kmem_cache *sysfs_dir_cachep;
 
 extern struct inode * sysfs_new_inode(mode_t mode, struct sysfs_dirent *);
 extern int sysfs_create(struct dentry *, int mode, int (*init)(struct inode *));
diff --git a/fs/sysv/CHANGES b/fs/sysv/CHANGES
deleted file mode 100644 (file)
index 66ea6e9..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-Mon, 15 Dec 1997         Krzysztof G. Baranowski <kgb@manjak.knm.org.pl>
-       *    namei.c: struct sysv_dir_inode_operations updated to use dentries.
-
-Fri, 23 Jan 1998   Krzysztof G. Baranowski <kgb@manjak.knm.org.pl>
-       *    inode.c: corrected 1 track offset setting (in sb->sv_block_base).
-                     Originally it was overridden (by setting to zero)
-                     in detected_[xenix,sysv4,sysv2,coherent]. Thanks
-                     to Andrzej Krzysztofowicz <ankry@mif.pg.gda.pl>
-                     for identifying the problem.
-
-Tue, 27 Jan 1998   Krzysztof G. Baranowski <kgb@manjak.knm.org.pl>
-        *    inode.c: added 2048-byte block support to SystemV FS.
-                     Merged detected_bs[512,1024,2048]() into one function:
-                     void detected_bs (u_char type, struct super_block *sb).
-                     Thanks to Andrzej Krzysztofowicz <ankry@mif.pg.gda.pl>
-                     for the patch.
-
-Wed, 4 Feb 1998   Krzysztof G. Baranowski <kgb@manjak.knm.org.pl>
-       *    namei.c: removed static subdir(); is_subdir() from dcache.c
-                     is used instead. Cosmetic changes.
-
-Thu, 3 Dec 1998   Al Viro (viro@parcelfarce.linux.theplanet.co.uk)
-       *    namei.c (sysv_rmdir):
-                     Bugectomy: old check for victim being busy
-                     (inode->i_count) wasn't replaced (with checking
-                     dentry->d_count) and escaped Linus in the last round
-                     of changes. Shot and buried.
-
-Wed, 9 Dec 1998   AV
-       *    namei.c (do_sysv_rename):
-                      Fixed incorrect check for other owners + race.
-                      Removed checks that went to VFS.
-       *    namei.c (sysv_unlink):
-                      Removed checks that went to VFS.
-
-Thu, 10 Dec 1998   AV
-       *    namei.c (do_mknod):
-                       Removed dead code - mknod is never asked to
-                       create a symlink or directory. Incidentially,
-                       it wouldn't do it right if it would be called.
-
-Sat, 26 Dec 1998   KGB
-       *    inode.c (detect_sysv4):
-                       Added detection of expanded s_type field (0x10,
-                       0x20 and 0x30).  Forced read-only access in this case.
-
-Sun, 21 Mar 1999   AV
-       *    namei.c (sysv_link):
-                       Fixed i_count usage that resulted in dcache corruption.
-       *    inode.c:
-                       Filled ->delete_inode() method with sysv_delete_inode().
-                       sysv_put_inode() is gone, as it tried to do ->delete_
-                       _inode()'s job.
-       *    ialloc.c: (sysv_free_inode):
-                       Fixed race.
-
-Sun, 30 Apr 1999   AV
-       *    namei.c (sysv_mknod):
-                       Removed dead code (S_IFREG case is now passed to
-                       ->create() by VFS).
diff --git a/fs/sysv/ChangeLog b/fs/sysv/ChangeLog
deleted file mode 100644 (file)
index f403f8b..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-Thu Feb 14 2002  Andrew Morton  <akpm@zip.com.au>
-
-       * dir_commit_chunk(): call writeout_one_page() as well as
-         waitfor_one_page() for IS_SYNC directories, so that we
-         actually do sync the directory. (forward-port from 2.4).
-
-Thu Feb  7 2002  Alexander Viro  <viro@parcelfarce.linux.theplanet.co.uk>
-
-       * super.c: switched to ->get_sb()
-       * ChangeLog: fixed dates ;-)
-
-2002-01-24  David S. Miller  <davem@redhat.com>
-
-       * inode.c: Include linux/init.h
-
-Mon Jan 21 2002  Alexander Viro  <viro@parcelfarce.linux.theplanet.co.uk>
-       * ialloc.c (sysv_new_inode): zero SYSV_I(inode)->i_data out.
-       * i_vnode renamed to vfs_inode.  Sorry, but let's keep that
-         consistent.
-
-Sat Jan 19 2002  Christoph Hellwig  <hch@infradead.org>
-
-       * include/linux/sysv_fs.h (SYSV_I): Get fs-private inode data using
-               list_entry() instead of inode->u.
-       * include/linux/sysv_fs_i.h: Add 'struct inode  i_vnode' field to
-               sysv_inode_info structure.
-       * inode.c: Include <linux/slab.h>, implement alloc_inode/destroy_inode
-               sop methods, add infrastructure for per-fs inode slab cache.
-       * super.c (init_sysv_fs): Initialize inode cache, recover properly
-               in the case of failed register_filesystem for V7.
-       (exit_sysv_fs): Destroy inode cache.
-
-Sat Jan 19 2002  Christoph Hellwig  <hch@infradead.org>
-
-       * include/linux/sysv_fs.h: Include <linux/sysv_fs_i.h>, declare SYSV_I().
-       * dir.c (sysv_find_entry): Use SYSV_I() instead of ->u.sysv_i to
-               access fs-private inode data.
-       * ialloc.c (sysv_new_inode): Likewise.
-       * inode.c (sysv_read_inode): Likewise.
-       (sysv_update_inode): Likewise.
-       * itree.c (get_branch): Likewise.
-       (sysv_truncate): Likewise.
-       * symlink.c (sysv_readlink): Likewise.
-       (sysv_follow_link): Likewise.
-
-Fri Jan  4 2002  Alexander Viro  <viro@parcelfarce.linux.theplanet.co.uk>
-
-       * ialloc.c (sysv_free_inode): Use sb->s_id instead of bdevname().
-       * inode.c (sysv_read_inode): Likewise.
-         (sysv_update_inode): Likewise.
-         (sysv_sync_inode): Likewise.
-       * super.c (detect_sysv): Likewise.
-         (complete_read_super): Likewise.
-         (sysv_read_super): Likewise.
-         (v7_read_super): Likewise.
-
-Sun Dec 30 2001  Manfred Spraul  <manfred@colorfullife.com>
-
-       * dir.c (dir_commit_chunk): Do not set dir->i_version.
-       (sysv_readdir): Likewise.
-
-Thu Dec 27 2001  Alexander Viro  <viro@parcelfarce.linux.theplanet.co.uk>
-
-       * itree.c (get_block): Use map_bh() to fill out bh_result.
-
-Tue Dec 25 2001  Alexander Viro  <viro@parcelfarce.linux.theplanet.co.uk>
-
-       * super.c (sysv_read_super): Use sb_set_blocksize() to set blocksize.
-         (v7_read_super): Likewise.
-
-Tue Nov 27 2001  Alexander Viro  <viro@parcelfarce.linux.theplanet.co.uk>
-
-       * itree.c (get_block): Change type for iblock argument to sector_t.
-       * super.c (sysv_read_super): Set s_blocksize early.
-         (v7_read_super): Likewise.
-       * balloc.c (sysv_new_block): Use sb_bread(). instead of bread().
-         (sysv_count_free_blocks): Likewise.
-       * ialloc.c (sysv_raw_inode): Likewise.
-       * itree.c (get_branch): Likewise.
-         (free_branches): Likewise.
-       * super.c (sysv_read_super): Likewise.
-         (v7_read_super): Likewise.
-
-Sat Dec 15 2001  Christoph Hellwig  <hch@infradead.org>
-
-       * inode.c (sysv_read_inode): Mark inode as bad in case of failure.
-       * super.c (complete_read_super): Check for bad root inode.
-
-Wed Nov 21 2001  Andrew Morton  <andrewm@uow.edu.au>
-
-       * file.c (sysv_sync_file): Call fsync_inode_data_buffers.
-
-Fri Oct 26 2001  Christoph Hellwig  <hch@infradead.org>
-
-       * dir.c, ialloc.c, namei.c, include/linux/sysv_fs_i.h:
-       Implement per-Inode lookup offset cache.
-       Modelled after Ted's ext2 patch.
-
-Fri Oct 26 2001  Christoph Hellwig  <hch@infradead.org>
-
-       * inode.c, super.c, include/linux/sysv_fs.h,
-         include/linux/sysv_fs_sb.h:
-       Remove symlink faking.  Noone really wants to use these as
-       linux filesystems and native OSes don't support it anyway.
-
-
diff --git a/fs/sysv/INTRO b/fs/sysv/INTRO
deleted file mode 100644 (file)
index de4e4d1..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-This is the implementation of the SystemV/Coherent filesystem for Linux.
-It grew out of separate filesystem implementations
-
-    Xenix FS      Doug Evans <dje@cygnus.com>  June 1992
-    SystemV FS    Paul B. Monday <pmonday@eecs.wsu.edu> March-June 1993
-    Coherent FS   B. Haible <haible@ma2s2.mathematik.uni-karlsruhe.de> June 1993
-
-and was merged together in July 1993.
-
-These filesystems are rather similar. Here is a comparison with Minix FS:
-
-* Linux fdisk reports on partitions
-  - Minix FS     0x81 Linux/Minix
-  - Xenix FS     ??
-  - SystemV FS   ??
-  - Coherent FS  0x08 AIX bootable
-
-* Size of a block or zone (data allocation unit on disk)
-  - Minix FS     1024
-  - Xenix FS     1024 (also 512 ??)
-  - SystemV FS   1024 (also 512 and 2048)
-  - Coherent FS   512
-
-* General layout: all have one boot block, one super block and
-  separate areas for inodes and for directories/data.
-  On SystemV Release 2 FS (e.g. Microport) the first track is reserved and
-  all the block numbers (including the super block) are offset by one track.
-
-* Byte ordering of "short" (16 bit entities) on disk:
-  - Minix FS     little endian  0 1
-  - Xenix FS     little endian  0 1
-  - SystemV FS   little endian  0 1
-  - Coherent FS  little endian  0 1
-  Of course, this affects only the file system, not the data of files on it!
-
-* Byte ordering of "long" (32 bit entities) on disk:
-  - Minix FS     little endian  0 1 2 3
-  - Xenix FS     little endian  0 1 2 3
-  - SystemV FS   little endian  0 1 2 3
-  - Coherent FS  PDP-11         2 3 0 1
-  Of course, this affects only the file system, not the data of files on it!
-
-* Inode on disk: "short", 0 means non-existent, the root dir ino is:
-  - Minix FS                            1
-  - Xenix FS, SystemV FS, Coherent FS   2
-
-* Maximum number of hard links to a file:
-  - Minix FS     250
-  - Xenix FS     ??
-  - SystemV FS   ??
-  - Coherent FS  >=10000
-
-* Free inode management:
-  - Minix FS                             a bitmap
-  - Xenix FS, SystemV FS, Coherent FS
-      There is a cache of a certain number of free inodes in the super-block.
-      When it is exhausted, new free inodes are found using a linear search.
-
-* Free block management:
-  - Minix FS                             a bitmap
-  - Xenix FS, SystemV FS, Coherent FS
-      Free blocks are organized in a "free list". Maybe a misleading term,
-      since it is not true that every free block contains a pointer to
-      the next free block. Rather, the free blocks are organized in chunks
-      of limited size, and every now and then a free block contains pointers
-      to the free blocks pertaining to the next chunk; the first of these
-      contains pointers and so on. The list terminates with a "block number"
-      0 on Xenix FS and SystemV FS, with a block zeroed out on Coherent FS.
-
-* Super-block location:
-  - Minix FS     block 1 = bytes 1024..2047
-  - Xenix FS     block 1 = bytes 1024..2047
-  - SystemV FS   bytes 512..1023
-  - Coherent FS  block 1 = bytes 512..1023
-
-* Super-block layout:
-  - Minix FS
-                    unsigned short s_ninodes;
-                    unsigned short s_nzones;
-                    unsigned short s_imap_blocks;
-                    unsigned short s_zmap_blocks;
-                    unsigned short s_firstdatazone;
-                    unsigned short s_log_zone_size;
-                    unsigned long s_max_size;
-                    unsigned short s_magic;
-  - Xenix FS, SystemV FS, Coherent FS
-                    unsigned short s_firstdatazone;
-                    unsigned long  s_nzones;
-                    unsigned short s_fzone_count;
-                    unsigned long  s_fzones[NICFREE];
-                    unsigned short s_finode_count;
-                    unsigned short s_finodes[NICINOD];
-                    char           s_flock;
-                    char           s_ilock;
-                    char           s_modified;
-                    char           s_rdonly;
-                    unsigned long  s_time;
-                    short          s_dinfo[4]; -- SystemV FS only
-                    unsigned long  s_free_zones;
-                    unsigned short s_free_inodes;
-                    short          s_dinfo[4]; -- Xenix FS only
-                    unsigned short s_interleave_m,s_interleave_n; -- Coherent FS only
-                    char           s_fname[6];
-                    char           s_fpack[6];
-    then they differ considerably:
-        Xenix FS
-                    char           s_clean;
-                    char           s_fill[371];
-                    long           s_magic;
-                    long           s_type;
-        SystemV FS
-                    long           s_fill[12 or 14];
-                    long           s_state;
-                    long           s_magic;
-                    long           s_type;
-        Coherent FS
-                    unsigned long  s_unique;
-    Note that Coherent FS has no magic.
-
-* Inode layout:
-  - Minix FS
-                    unsigned short i_mode;
-                    unsigned short i_uid;
-                    unsigned long  i_size;
-                    unsigned long  i_time;
-                    unsigned char  i_gid;
-                    unsigned char  i_nlinks;
-                    unsigned short i_zone[7+1+1];
-  - Xenix FS, SystemV FS, Coherent FS
-                    unsigned short i_mode;
-                    unsigned short i_nlink;
-                    unsigned short i_uid;
-                    unsigned short i_gid;
-                    unsigned long  i_size;
-                    unsigned char  i_zone[3*(10+1+1+1)];
-                    unsigned long  i_atime;
-                    unsigned long  i_mtime;
-                    unsigned long  i_ctime;
-
-* Regular file data blocks are organized as
-  - Minix FS
-               7 direct blocks
-               1 indirect block (pointers to blocks)
-               1 double-indirect block (pointer to pointers to blocks)
-  - Xenix FS, SystemV FS, Coherent FS
-              10 direct blocks
-               1 indirect block (pointers to blocks)
-               1 double-indirect block (pointer to pointers to blocks)
-               1 triple-indirect block (pointer to pointers to pointers to blocks)
-
-* Inode size, inodes per block
-  - Minix FS        32   32
-  - Xenix FS        64   16
-  - SystemV FS      64   16
-  - Coherent FS     64    8
-
-* Directory entry on disk
-  - Minix FS
-                    unsigned short inode;
-                    char name[14/30];
-  - Xenix FS, SystemV FS, Coherent FS
-                    unsigned short inode;
-                    char name[14];
-
-* Dir entry size, dir entries per block
-  - Minix FS     16/32    64/32
-  - Xenix FS     16       64
-  - SystemV FS   16       64
-  - Coherent FS  16       32
-
-* How to implement symbolic links such that the host fsck doesn't scream:
-  - Minix FS     normal
-  - Xenix FS     kludge: as regular files with  chmod 1000
-  - SystemV FS   ??
-  - Coherent FS  kludge: as regular files with  chmod 1000
-
-
-Notation: We often speak of a "block" but mean a zone (the allocation unit)
-and not the disk driver's notion of "block".
-
-
-Bruno Haible  <haible@ma2s2.mathematik.uni-karlsruhe.de>
index f2bef962d30983cc1f43d2d965db2faa3fd1af17..ebf7007fa1612ef41a16317594eeb006264aa7c5 100644 (file)
@@ -70,7 +70,7 @@ fail:
 static int sysv_readdir(struct file * filp, void * dirent, filldir_t filldir)
 {
        unsigned long pos = filp->f_pos;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct super_block *sb = inode->i_sb;
        unsigned offset = pos & ~PAGE_CACHE_MASK;
        unsigned long n = pos >> PAGE_CACHE_SHIFT;
index d63c5e48b050e0865c19d086e9e6346fc59a8f47..ead9864567e39d237364868ee710632adcd4175a 100644 (file)
@@ -301,13 +301,13 @@ static void sysv_delete_inode(struct inode *inode)
        unlock_kernel();
 }
 
-static kmem_cache_t *sysv_inode_cachep;
+static struct kmem_cache *sysv_inode_cachep;
 
 static struct inode *sysv_alloc_inode(struct super_block *sb)
 {
        struct sysv_inode_info *si;
 
-       si = kmem_cache_alloc(sysv_inode_cachep, SLAB_KERNEL);
+       si = kmem_cache_alloc(sysv_inode_cachep, GFP_KERNEL);
        if (!si)
                return NULL;
        return &si->vfs_inode;
@@ -318,7 +318,7 @@ static void sysv_destroy_inode(struct inode *inode)
        kmem_cache_free(sysv_inode_cachep, SYSV_I(inode));
 }
 
-static void init_once(void *p, kmem_cache_t *cachep, unsigned long flags)
+static void init_once(void *p, struct kmem_cache *cachep, unsigned long flags)
 {
        struct sysv_inode_info *si = (struct sysv_inode_info *)p;
 
index 8c28efa3b8ff2e4a40e981dd9bc7a4cbe193d44a..2391c9150c497dbd27f3b6bf0bf25808a1672889 100644 (file)
@@ -77,7 +77,7 @@ const struct file_operations udf_dir_operations = {
 
 int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct inode *dir = filp->f_dentry->d_inode;
+       struct inode *dir = filp->f_path.dentry->d_inode;
        int result;
 
        lock_kernel();
@@ -225,7 +225,7 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
 
                if ( cfi.fileCharacteristics & FID_FILE_CHAR_PARENT )
                {
-                       iblock = parent_ino(filp->f_dentry);
+                       iblock = parent_ino(filp->f_path.dentry);
                        flen = 2;
                        memcpy(fname, "..", flen);
                        dt_type = DT_DIR;
index 7aedd552cba12c205706fb921dd0bde45ec68e11..d81f2db7b0e3cc47fe445e1ce8486493250619d9 100644 (file)
@@ -108,7 +108,7 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
 {
        ssize_t retval;
        struct file *file = iocb->ki_filp;
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int err, pos;
        size_t count = iocb->ki_left;
 
index 1aea6a4f9a4ab1ce76c3d452be99313f76f7dd1d..1dbc2955f02e5493879cdfda7f9b154910941504 100644 (file)
@@ -107,12 +107,12 @@ static struct file_system_type udf_fstype = {
        .fs_flags       = FS_REQUIRES_DEV,
 };
 
-static kmem_cache_t * udf_inode_cachep;
+static struct kmem_cache * udf_inode_cachep;
 
 static struct inode *udf_alloc_inode(struct super_block *sb)
 {
        struct udf_inode_info *ei;
-       ei = (struct udf_inode_info *)kmem_cache_alloc(udf_inode_cachep, SLAB_KERNEL);
+       ei = (struct udf_inode_info *)kmem_cache_alloc(udf_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
 
@@ -130,7 +130,7 @@ static void udf_destroy_inode(struct inode *inode)
        kmem_cache_free(udf_inode_cachep, UDF_I(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct udf_inode_info *ei = (struct udf_inode_info *) foo;
 
@@ -1709,7 +1709,7 @@ void udf_error(struct super_block *sb, const char *function,
                sb->s_dirt = 1;
        }
        va_start(args, fmt);
-       vsprintf(error_buf, fmt, args);
+       vsnprintf(error_buf, sizeof(error_buf), fmt, args);
        va_end(args);
        printk (KERN_CRIT "UDF-fs error (device %s): %s: %s\n",
                sb->s_id, function, error_buf);
@@ -1721,7 +1721,7 @@ void udf_warning(struct super_block *sb, const char *function,
        va_list args;
 
        va_start (args, fmt);
-       vsprintf(error_buf, fmt, args);
+       vsnprintf(error_buf, sizeof(error_buf), fmt, args);
        va_end(args);
        printk(KERN_WARNING "UDF-fs warning (device %s): %s: %s\n",
                sb->s_id, function, error_buf);
index 7f0a0aa63584e729d53d01177ed74a0372ea830a..433b6f68403a73bf73c43667e52eb3d97f96c4a0 100644 (file)
@@ -426,7 +426,7 @@ static int
 ufs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
        loff_t pos = filp->f_pos;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct super_block *sb = inode->i_sb;
        unsigned int offset = pos & ~PAGE_CACHE_MASK;
        unsigned long n = pos >> PAGE_CACHE_SHIFT;
index ec79e3091d1bc7f647905edc7c410c94dcb10a3a..8a8e9382ec099a2b41d176c6dc391a316af7b80d 100644 (file)
@@ -224,7 +224,7 @@ void ufs_error (struct super_block * sb, const char * function,
                sb->s_flags |= MS_RDONLY;
        }
        va_start (args, fmt);
-       vsprintf (error_buf, fmt, args);
+       vsnprintf (error_buf, sizeof(error_buf), fmt, args);
        va_end (args);
        switch (UFS_SB(sb)->s_mount_opt & UFS_MOUNT_ONERROR) {
        case UFS_MOUNT_ONERROR_PANIC:
@@ -255,7 +255,7 @@ void ufs_panic (struct super_block * sb, const char * function,
                sb->s_dirt = 1;
        }
        va_start (args, fmt);
-       vsprintf (error_buf, fmt, args);
+       vsnprintf (error_buf, sizeof(error_buf), fmt, args);
        va_end (args);
        sb->s_flags |= MS_RDONLY;
        printk (KERN_CRIT "UFS-fs panic (device %s): %s: %s\n",
@@ -268,7 +268,7 @@ void ufs_warning (struct super_block * sb, const char * function,
        va_list args;
 
        va_start (args, fmt);
-       vsprintf (error_buf, fmt, args);
+       vsnprintf (error_buf, sizeof(error_buf), fmt, args);
        va_end (args);
        printk (KERN_WARNING "UFS-fs warning (device %s): %s: %s\n",
                sb->s_id, function, error_buf);
@@ -1204,12 +1204,12 @@ static int ufs_statfs(struct dentry *dentry, struct kstatfs *buf)
        return 0;
 }
 
-static kmem_cache_t * ufs_inode_cachep;
+static struct kmem_cache * ufs_inode_cachep;
 
 static struct inode *ufs_alloc_inode(struct super_block *sb)
 {
        struct ufs_inode_info *ei;
-       ei = (struct ufs_inode_info *)kmem_cache_alloc(ufs_inode_cachep, SLAB_KERNEL);
+       ei = (struct ufs_inode_info *)kmem_cache_alloc(ufs_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        ei->vfs_inode.i_version = 1;
@@ -1221,7 +1221,7 @@ static void ufs_destroy_inode(struct inode *inode)
        kmem_cache_free(ufs_inode_cachep, UFS_I(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct ufs_inode_info *ei = (struct ufs_inode_info *) foo;
 
index 28fce6c239b56f8d960a7bf7a820c12ad1b2b3e4..7dd12bb1d62bdf9a9f2223e0d5840097831d4960 100644 (file)
@@ -299,7 +299,7 @@ static inline void *get_usb_offset(struct ufs_sb_private_info *uspi,
 
 #define ubh_get_addr16(ubh,begin) \
        (((__fs16*)((ubh)->bh[(begin) >> (uspi->s_fshift-1)]->b_data)) + \
-       ((begin) & (uspi->fsize>>1) - 1)))
+       ((begin) & ((uspi->fsize>>1) - 1)))
 
 #define ubh_get_addr32(ubh,begin) \
        (((__fs32*)((ubh)->bh[(begin) >> (uspi->s_fshift-2)]->b_data)) + \
index 0901bdc2ce24f43d8ca1a62f3cee4c8519e0b21f..38646132ab0e29ec4c8ab8a4d3c7bbb491eaeaeb 100644 (file)
@@ -268,7 +268,7 @@ sys_fsetxattr(int fd, char __user *name, void __user *value,
        f = fget(fd);
        if (!f)
                return error;
-       dentry = f->f_dentry;
+       dentry = f->f_path.dentry;
        audit_inode(NULL, dentry->d_inode);
        error = setxattr(dentry, name, value, size, flags);
        fput(f);
@@ -351,7 +351,7 @@ sys_fgetxattr(int fd, char __user *name, void __user *value, size_t size)
        f = fget(fd);
        if (!f)
                return error;
-       error = getxattr(f->f_dentry, name, value, size);
+       error = getxattr(f->f_path.dentry, name, value, size);
        fput(f);
        return error;
 }
@@ -423,7 +423,7 @@ sys_flistxattr(int fd, char __user *list, size_t size)
        f = fget(fd);
        if (!f)
                return error;
-       error = listxattr(f->f_dentry, list, size);
+       error = listxattr(f->f_path.dentry, list, size);
        fput(f);
        return error;
 }
@@ -484,7 +484,7 @@ sys_fremovexattr(int fd, char __user *name)
        f = fget(fd);
        if (!f)
                return error;
-       dentry = f->f_dentry;
+       dentry = f->f_path.dentry;
        audit_inode(NULL, dentry->d_inode);
        error = removexattr(dentry, name);
        fput(f);
index eef4a0ba11e9867a0991b2435a08fc1603dd80d1..4fb01ffdfd1a06163263186b967a2e04f7f90743 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/kthread.h>
 #include <linux/migrate.h>
 #include <linux/backing-dev.h>
+#include <linux/freezer.h>
 
 STATIC kmem_zone_t *xfs_buf_zone;
 STATIC kmem_shaker_t xfs_buf_shake;
@@ -1826,11 +1827,11 @@ xfs_buf_init(void)
        if (!xfs_buf_zone)
                goto out_free_trace_buf;
 
-       xfslogd_workqueue = create_workqueue("xfslogd");
+       xfslogd_workqueue = create_freezeable_workqueue("xfslogd");
        if (!xfslogd_workqueue)
                goto out_free_buf_zone;
 
-       xfsdatad_workqueue = create_workqueue("xfsdatad");
+       xfsdatad_workqueue = create_freezeable_workqueue("xfsdatad");
        if (!xfsdatad_workqueue)
                goto out_destroy_xfslogd_workqueue;
 
index d93d8dd1958d3fcb5cc597d44fdda345ac522fac..d26f5cd2ba70ec0cd9c73471a0eb1d23b544c529 100644 (file)
@@ -55,7 +55,7 @@ __xfs_file_read(
        loff_t                  pos)
 {
        struct file             *file = iocb->ki_filp;
-       bhv_vnode_t             *vp = vn_from_inode(file->f_dentry->d_inode);
+       bhv_vnode_t             *vp = vn_from_inode(file->f_path.dentry->d_inode);
 
        BUG_ON(iocb->ki_pos != pos);
        if (unlikely(file->f_flags & O_DIRECT))
@@ -131,7 +131,7 @@ xfs_file_sendfile(
        read_actor_t            actor,
        void                    *target)
 {
-       return bhv_vop_sendfile(vn_from_inode(filp->f_dentry->d_inode),
+       return bhv_vop_sendfile(vn_from_inode(filp->f_path.dentry->d_inode),
                                filp, pos, 0, count, actor, target, NULL);
 }
 
@@ -143,7 +143,7 @@ xfs_file_sendfile_invis(
        read_actor_t            actor,
        void                    *target)
 {
-       return bhv_vop_sendfile(vn_from_inode(filp->f_dentry->d_inode),
+       return bhv_vop_sendfile(vn_from_inode(filp->f_path.dentry->d_inode),
                                filp, pos, IO_INVIS, count, actor, target, NULL);
 }
 
@@ -155,7 +155,7 @@ xfs_file_splice_read(
        size_t                  len,
        unsigned int            flags)
 {
-       return bhv_vop_splice_read(vn_from_inode(infilp->f_dentry->d_inode),
+       return bhv_vop_splice_read(vn_from_inode(infilp->f_path.dentry->d_inode),
                                   infilp, ppos, pipe, len, flags, 0, NULL);
 }
 
@@ -167,7 +167,7 @@ xfs_file_splice_read_invis(
        size_t                  len,
        unsigned int            flags)
 {
-       return bhv_vop_splice_read(vn_from_inode(infilp->f_dentry->d_inode),
+       return bhv_vop_splice_read(vn_from_inode(infilp->f_path.dentry->d_inode),
                                   infilp, ppos, pipe, len, flags, IO_INVIS,
                                   NULL);
 }
@@ -180,7 +180,7 @@ xfs_file_splice_write(
        size_t                  len,
        unsigned int            flags)
 {
-       return bhv_vop_splice_write(vn_from_inode(outfilp->f_dentry->d_inode),
+       return bhv_vop_splice_write(vn_from_inode(outfilp->f_path.dentry->d_inode),
                                    pipe, outfilp, ppos, len, flags, 0, NULL);
 }
 
@@ -192,7 +192,7 @@ xfs_file_splice_write_invis(
        size_t                  len,
        unsigned int            flags)
 {
-       return bhv_vop_splice_write(vn_from_inode(outfilp->f_dentry->d_inode),
+       return bhv_vop_splice_write(vn_from_inode(outfilp->f_path.dentry->d_inode),
                                    pipe, outfilp, ppos, len, flags, IO_INVIS,
                                    NULL);
 }
@@ -212,7 +212,7 @@ xfs_file_close(
        struct file     *filp,
        fl_owner_t      id)
 {
-       return -bhv_vop_close(vn_from_inode(filp->f_dentry->d_inode), 0,
+       return -bhv_vop_close(vn_from_inode(filp->f_path.dentry->d_inode), 0,
                                file_count(filp) > 1 ? L_FALSE : L_TRUE, NULL);
 }
 
@@ -251,7 +251,7 @@ xfs_vm_nopage(
        unsigned long           address,
        int                     *type)
 {
-       struct inode    *inode = area->vm_file->f_dentry->d_inode;
+       struct inode    *inode = area->vm_file->f_path.dentry->d_inode;
        bhv_vnode_t     *vp = vn_from_inode(inode);
 
        ASSERT_ALWAYS(vp->v_vfsp->vfs_flag & VFS_DMI);
@@ -268,7 +268,7 @@ xfs_file_readdir(
        filldir_t       filldir)
 {
        int             error = 0;
-       bhv_vnode_t     *vp = vn_from_inode(filp->f_dentry->d_inode);
+       bhv_vnode_t     *vp = vn_from_inode(filp->f_path.dentry->d_inode);
        uio_t           uio;
        iovec_t         iov;
        int             eof = 0;
@@ -345,7 +345,7 @@ xfs_file_mmap(
        vma->vm_ops = &xfs_file_vm_ops;
 
 #ifdef CONFIG_XFS_DMAPI
-       if (vn_from_inode(filp->f_dentry->d_inode)->v_vfsp->vfs_flag & VFS_DMI)
+       if (vn_from_inode(filp->f_path.dentry->d_inode)->v_vfsp->vfs_flag & VFS_DMI)
                vma->vm_ops = &xfs_dmapi_file_vm_ops;
 #endif /* CONFIG_XFS_DMAPI */
 
@@ -360,7 +360,7 @@ xfs_file_ioctl(
        unsigned long   p)
 {
        int             error;
-       struct inode    *inode = filp->f_dentry->d_inode;
+       struct inode    *inode = filp->f_path.dentry->d_inode;
        bhv_vnode_t     *vp = vn_from_inode(inode);
 
        error = bhv_vop_ioctl(vp, inode, filp, 0, cmd, (void __user *)p);
@@ -382,7 +382,7 @@ xfs_file_ioctl_invis(
        unsigned long   p)
 {
        int             error;
-       struct inode    *inode = filp->f_dentry->d_inode;
+       struct inode    *inode = filp->f_path.dentry->d_inode;
        bhv_vnode_t     *vp = vn_from_inode(inode);
 
        error = bhv_vop_ioctl(vp, inode, filp, IO_INVIS, cmd, (void __user *)p);
@@ -404,7 +404,7 @@ xfs_vm_mprotect(
        struct vm_area_struct *vma,
        unsigned int    newflags)
 {
-       bhv_vnode_t     *vp = vn_from_inode(vma->vm_file->f_dentry->d_inode);
+       bhv_vnode_t     *vp = vn_from_inode(vma->vm_file->f_path.dentry->d_inode);
        int             error = 0;
 
        if (vp->v_vfsp->vfs_flag & VFS_DMI) {
index 74d094829a4d5aaec02469ad6b1e4bfb643a1275..f011c9cd0d6211b3635661d3f76a6125c70b53e7 100644 (file)
@@ -107,9 +107,9 @@ xfs_find_handle(
                if (!file)
                    return -EBADF;
 
-               ASSERT(file->f_dentry);
-               ASSERT(file->f_dentry->d_inode);
-               inode = igrab(file->f_dentry->d_inode);
+               ASSERT(file->f_path.dentry);
+               ASSERT(file->f_path.dentry->d_inode);
+               inode = igrab(file->f_path.dentry->d_inode);
                fput(file);
                break;
        }
@@ -333,10 +333,10 @@ xfs_open_by_handle(
        }
 
        /* Ensure umount returns EBUSY on umounts while this file is open. */
-       mntget(parfilp->f_vfsmnt);
+       mntget(parfilp->f_path.mnt);
 
        /* Create file pointer. */
-       filp = dentry_open(dentry, parfilp->f_vfsmnt, hreq.oflags);
+       filp = dentry_open(dentry, parfilp->f_path.mnt, hreq.oflags);
        if (IS_ERR(filp)) {
                put_unused_fd(new_fd);
                return -XFS_ERROR(-PTR_ERR(filp));
index 270db0f3861d1597c6401a2e25872b005e97fe26..b83cebc165f13ea53fa6be44f9c009f3d87c9eb5 100644 (file)
@@ -112,7 +112,7 @@ xfs_compat_ioctl(
        unsigned        cmd,
        unsigned long   arg)
 {
-       struct inode    *inode = file->f_dentry->d_inode;
+       struct inode    *inode = file->f_path.dentry->d_inode;
        bhv_vnode_t     *vp = vn_from_inode(inode);
        int             error;
 
index fa842f1c9fa27b3511c86725a1cad2f3334f4b9c..65e79b471d49570f825033d31843327e2d7c50f2 100644 (file)
@@ -805,7 +805,7 @@ start:
             !capable(CAP_FSETID)) {
                error = xfs_write_clear_setuid(xip);
                if (likely(!error))
-                       error = -remove_suid(file->f_dentry);
+                       error = -remove_suid(file->f_path.dentry);
                if (unlikely(error)) {
                        xfs_iunlock(xip, iolock);
                        goto out_unlock_mutex;
index de05abbbe7fd5b4d220b3baee7230006631cdd33..b93265b7c79ccd8f4238f4fd1a6c651d370ee067 100644 (file)
@@ -56,6 +56,7 @@
 #include <linux/mempool.h>
 #include <linux/writeback.h>
 #include <linux/kthread.h>
+#include <linux/freezer.h>
 
 STATIC struct quotactl_ops xfs_quotactl_operations;
 STATIC struct super_operations xfs_super_operations;
index 80562b60fb95f5c041ee202701f011d1bb9a648c..50d0faea371d26502de68c8aa86c4fe86f0b5a70 100644 (file)
@@ -71,7 +71,7 @@ xfs_swapext(
 
        /* Pull information for the target fd */
        if (((fp = fget((int)sxp->sx_fdtarget)) == NULL) ||
-           ((vp = vn_from_inode(fp->f_dentry->d_inode)) == NULL))  {
+           ((vp = vn_from_inode(fp->f_path.dentry->d_inode)) == NULL))  {
                error = XFS_ERROR(EINVAL);
                goto error0;
        }
@@ -83,7 +83,7 @@ xfs_swapext(
        }
 
        if (((tfp = fget((int)sxp->sx_fdtmp)) == NULL) ||
-           ((tvp = vn_from_inode(tfp->f_dentry->d_inode)) == NULL)) {
+           ((tvp = vn_from_inode(tfp->f_path.dentry->d_inode)) == NULL)) {
                error = XFS_ERROR(EINVAL);
                goto error0;
        }
index 47faf27913a576ccf930d8cbcad1f8a3fc8f2215..7f1e92930b6258b75e931daac2e25f657441dd27 100644 (file)
@@ -64,7 +64,7 @@
 /* Host-dependent types and defines */
 
 #define ACPI_MACHINE_WIDTH          BITS_PER_LONG
-#define acpi_cache_t                        kmem_cache_t
+#define acpi_cache_t                        struct kmem_cache
 #define acpi_spinlock                   spinlock_t *
 #define ACPI_EXPORT_SYMBOL(symbol)  EXPORT_SYMBOL(symbol);
 #define strtoul                     simple_strtoul
index b9ff4d8cb33a95dd5c50db2d77c88a110c415d70..57e09f5e342490488e0a86e424fc499df326794b 100644 (file)
@@ -51,7 +51,7 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
 
 #define dma_alloc_noncoherent(d, s, h, f)      dma_alloc_coherent(d, s, h, f)
 #define dma_free_noncoherent(d, s, v, h)       dma_free_coherent(d, s, v, h)
-#define dma_is_consistent(dev)                 (1)
+#define dma_is_consistent(d, h)                        (1)
 
 int dma_set_mask(struct device *dev, u64 mask);
 
@@ -60,7 +60,7 @@ int dma_set_mask(struct device *dev, u64 mask);
 #define dma_sync_single_range(dev, addr, off, size, dir)  do { } while (0)
 #define dma_sync_sg_for_cpu(dev, sg, nents, dir)         do { } while (0)
 #define dma_sync_sg_for_device(dev, sg, nents, dir)      do { } while (0)
-#define dma_cache_sync(va, size, dir)                    do { } while (0)
+#define dma_cache_sync(dev, va, size, dir)               do { } while (0)
 
 #define dma_get_cache_alignment()                        L1_CACHE_BYTES
 
index 5541101b58aef8c962ebc416539daefe12cc3fd8..ad854a4a3af63061290bd0fa02a0a58dc8f16bac 100644 (file)
@@ -25,6 +25,19 @@ struct termios {
        speed_t c_ospeed;               /* output speed */
 };
 
+/* Alpha has matching termios and ktermios */
+
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_cc[NCCS];                /* control characters */
+       cc_t c_line;                    /* line discipline (== c_cc[19]) */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
 /* c_cc characters */
 #define VEOF 0
 #define VEOL 1
index 2cabbd465c0c4d1b3437dafea1bf7030b080c217..84313d14e78065284ea619bb9b20a90f0377bf76 100644 (file)
 
 #define NR_SYSCALLS                    447
 
-#if defined(__GNUC__)
-
-#define _syscall_return(type)                                          \
-       return (_sc_err ? errno = _sc_ret, _sc_ret = -1L : 0), (type) _sc_ret
-
-#define _syscall_clobbers                                              \
-       "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8",                 \
-       "$22", "$23", "$24", "$25", "$27", "$28"                        \
-
-#define _syscall0(type, name)                                          \
-type name(void)                                                                \
-{                                                                      \
-       long _sc_ret, _sc_err;                                          \
-       {                                                               \
-               register long _sc_0 __asm__("$0");                      \
-               register long _sc_19 __asm__("$19");                    \
-                                                                       \
-               _sc_0 = __NR_##name;                                    \
-               __asm__("callsys # %0 %1 %2"                            \
-                       : "=r"(_sc_0), "=r"(_sc_19)                     \
-                       : "0"(_sc_0)                                    \
-                       : _syscall_clobbers);                           \
-               _sc_ret = _sc_0, _sc_err = _sc_19;                      \
-       }                                                               \
-       _syscall_return(type);                                          \
-}
-
-#define _syscall1(type,name,type1,arg1)                                        \
-type name(type1 arg1)                                                  \
-{                                                                      \
-       long _sc_ret, _sc_err;                                          \
-       {                                                               \
-               register long _sc_0 __asm__("$0");                      \
-               register long _sc_16 __asm__("$16");                    \
-               register long _sc_19 __asm__("$19");                    \
-                                                                       \
-               _sc_0 = __NR_##name;                                    \
-               _sc_16 = (long) (arg1);                                 \
-               __asm__("callsys # %0 %1 %2 %3"                         \
-                       : "=r"(_sc_0), "=r"(_sc_19)                     \
-                       : "0"(_sc_0), "r"(_sc_16)                       \
-                       : _syscall_clobbers);                           \
-               _sc_ret = _sc_0, _sc_err = _sc_19;                      \
-       }                                                               \
-       _syscall_return(type);                                          \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2)                     \
-type name(type1 arg1,type2 arg2)                                       \
-{                                                                      \
-       long _sc_ret, _sc_err;                                          \
-       {                                                               \
-               register long _sc_0 __asm__("$0");                      \
-               register long _sc_16 __asm__("$16");                    \
-               register long _sc_17 __asm__("$17");                    \
-               register long _sc_19 __asm__("$19");                    \
-                                                                       \
-               _sc_0 = __NR_##name;                                    \
-               _sc_16 = (long) (arg1);                                 \
-               _sc_17 = (long) (arg2);                                 \
-               __asm__("callsys # %0 %1 %2 %3 %4"                      \
-                       : "=r"(_sc_0), "=r"(_sc_19)                     \
-                       : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17)          \
-                       : _syscall_clobbers);                           \
-               _sc_ret = _sc_0, _sc_err = _sc_19;                      \
-       }                                                               \
-       _syscall_return(type);                                          \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3)          \
-type name(type1 arg1,type2 arg2,type3 arg3)                            \
-{                                                                      \
-       long _sc_ret, _sc_err;                                          \
-       {                                                               \
-               register long _sc_0 __asm__("$0");                      \
-               register long _sc_16 __asm__("$16");                    \
-               register long _sc_17 __asm__("$17");                    \
-               register long _sc_18 __asm__("$18");                    \
-               register long _sc_19 __asm__("$19");                    \
-                                                                       \
-               _sc_0 = __NR_##name;                                    \
-               _sc_16 = (long) (arg1);                                 \
-               _sc_17 = (long) (arg2);                                 \
-               _sc_18 = (long) (arg3);                                 \
-               __asm__("callsys # %0 %1 %2 %3 %4 %5"                   \
-                       : "=r"(_sc_0), "=r"(_sc_19)                     \
-                       : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17),         \
-                         "r"(_sc_18)                                   \
-                       : _syscall_clobbers);                           \
-               _sc_ret = _sc_0, _sc_err = _sc_19;                      \
-       }                                                               \
-       _syscall_return(type);                                          \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4)              \
-{                                                                       \
-       long _sc_ret, _sc_err;                                          \
-       {                                                               \
-               register long _sc_0 __asm__("$0");                      \
-               register long _sc_16 __asm__("$16");                    \
-               register long _sc_17 __asm__("$17");                    \
-               register long _sc_18 __asm__("$18");                    \
-               register long _sc_19 __asm__("$19");                    \
-                                                                       \
-               _sc_0 = __NR_##name;                                    \
-               _sc_16 = (long) (arg1);                                 \
-               _sc_17 = (long) (arg2);                                 \
-               _sc_18 = (long) (arg3);                                 \
-               _sc_19 = (long) (arg4);                                 \
-               __asm__("callsys # %0 %1 %2 %3 %4 %5 %6"                \
-                       : "=r"(_sc_0), "=r"(_sc_19)                     \
-                       : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17),         \
-                         "r"(_sc_18), "1"(_sc_19)                      \
-                       : _syscall_clobbers);                           \
-               _sc_ret = _sc_0, _sc_err = _sc_19;                      \
-       }                                                               \
-       _syscall_return(type);                                          \
-} 
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-         type5,arg5)                                                    \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5)     \
-{                                                                      \
-       long _sc_ret, _sc_err;                                          \
-       {                                                               \
-               register long _sc_0 __asm__("$0");                      \
-               register long _sc_16 __asm__("$16");                    \
-               register long _sc_17 __asm__("$17");                    \
-               register long _sc_18 __asm__("$18");                    \
-               register long _sc_19 __asm__("$19");                    \
-               register long _sc_20 __asm__("$20");                    \
-                                                                       \
-               _sc_0 = __NR_##name;                                    \
-               _sc_16 = (long) (arg1);                                 \
-               _sc_17 = (long) (arg2);                                 \
-               _sc_18 = (long) (arg3);                                 \
-               _sc_19 = (long) (arg4);                                 \
-               _sc_20 = (long) (arg5);                                 \
-               __asm__("callsys # %0 %1 %2 %3 %4 %5 %6 %7"             \
-                       : "=r"(_sc_0), "=r"(_sc_19)                     \
-                       : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17),         \
-                         "r"(_sc_18), "1"(_sc_19), "r"(_sc_20)         \
-                       : _syscall_clobbers);                           \
-               _sc_ret = _sc_0, _sc_err = _sc_19;                      \
-       }                                                               \
-       _syscall_return(type);                                          \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-         type5,arg5,type6,arg6)                                         \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6)\
-{                                                                      \
-       long _sc_ret, _sc_err;                                          \
-       {                                                               \
-               register long _sc_0 __asm__("$0");                      \
-               register long _sc_16 __asm__("$16");                    \
-               register long _sc_17 __asm__("$17");                    \
-               register long _sc_18 __asm__("$18");                    \
-               register long _sc_19 __asm__("$19");                    \
-               register long _sc_20 __asm__("$20");                    \
-               register long _sc_21 __asm__("$21");                    \
-                                                                       \
-               _sc_0 = __NR_##name;                                    \
-               _sc_16 = (long) (arg1);                                 \
-               _sc_17 = (long) (arg2);                                 \
-               _sc_18 = (long) (arg3);                                 \
-               _sc_19 = (long) (arg4);                                 \
-               _sc_20 = (long) (arg5);                                 \
-               _sc_21 = (long) (arg6);                                 \
-               __asm__("callsys # %0 %1 %2 %3 %4 %5 %6 %7 %8"          \
-                       : "=r"(_sc_0), "=r"(_sc_19)                     \
-                       : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17),         \
-                         "r"(_sc_18), "1"(_sc_19), "r"(_sc_20), "r"(_sc_21) \
-                       : _syscall_clobbers);                           \
-               _sc_ret = _sc_0, _sc_err = _sc_19;                      \
-       }                                                               \
-       _syscall_return(type);                                          \
-}
-
-#endif /* __GNUC__ */
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_STAT64
index 24b51cccde8f270ce7efe2a70d7481706e6996ed..9eceb4148922e7e1a9bff39f1ca263ae73b2c134 100644 (file)
@@ -17,8 +17,6 @@
 #define __virt_to_bus(x)       __virt_to_phys(x)
 #define __bus_to_virt(x)       __phys_to_virt(x)
 
-#ifdef CONFIG_DISCONTIGMEM
-
 /*
  * The nodes are the followings:
  *
  *   node 2: 0xf800.0000 - 0xfbff.ffff
  *   node 3: 0xfc00.0000 - 0xffff.ffff
  */
-
-/*
- * Given a kernel address, find the home node of the underlying memory.
- */
-#define KVADDR_TO_NID(addr) \
-       (((unsigned long)(addr) - PAGE_OFFSET) >> NODE_MAX_MEM_SHIFT)
-
-/*
- * Given a page frame number, convert it to a node id.
- */
-#define PFN_TO_NID(pfn) \
-       (((pfn) - PHYS_PFN_OFFSET) >> (NODE_MAX_MEM_SHIFT - PAGE_SHIFT))
-
-/*
- * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
- * and return the mem_map of that node.
- */
-#define ADDR_TO_MAPBASE(kaddr)  NODE_MEM_MAP(KVADDR_TO_NID(kaddr))
-
-/*
- * Given a page frame number, find the owning node of the memory
- * and return the mem_map of that node.
- */
-#define PFN_TO_MAPBASE(pfn)     NODE_MEM_MAP(PFN_TO_NID(pfn))
-
-/*
- *  Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
- *  and returns the index corresponding to the appropriate page in the
- *  node's mem_map.
- */
-#define LOCAL_MAP_NR(addr) \
-        (((unsigned long)(addr) & (NODE_MAX_MEM_SIZE - 1)) >> PAGE_SHIFT)
-
-#define NODE_MAX_MEM_SHIFT     26
-#define NODE_MAX_MEM_SIZE      (1 << NODE_MAX_MEM_SHIFT)
-
-#endif /* CONFIG_DISCONTIGMEM */
+#define NODE_MEM_SIZE_BITS     26
 
 #endif /* __ASM_ARCH_MEMORY_H */
diff --git a/include/asm-arm/arch-at91rm9200/at91_aic.h b/include/asm-arm/arch-at91rm9200/at91_aic.h
new file mode 100644 (file)
index 0000000..267e698
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91_aic.h
+ *
+ * Copyright (C) 2005 Ivan Kokshaysky
+ * Copyright (C) SAN People
+ *
+ * Advanced Interrupt Controller (AIC) - System peripherals registers.
+ * Based on AT91RM9200 datasheet revision E.
+ *
+ * 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.
+ */
+
+#ifndef AT91_AIC_H
+#define AT91_AIC_H
+
+#define AT91_AIC_SMR(n)                (AT91_AIC + ((n) * 4))  /* Source Mode Registers 0-31 */
+#define                AT91_AIC_PRIOR          (7 << 0)                /* Priority Level */
+#define                AT91_AIC_SRCTYPE        (3 << 5)                /* Interrupt Source Type */
+#define                        AT91_AIC_SRCTYPE_LOW            (0 << 5)
+#define                        AT91_AIC_SRCTYPE_FALLING        (1 << 5)
+#define                        AT91_AIC_SRCTYPE_HIGH           (2 << 5)
+#define                        AT91_AIC_SRCTYPE_RISING         (3 << 5)
+
+#define AT91_AIC_SVR(n)                (AT91_AIC + 0x80 + ((n) * 4))   /* Source Vector Registers 0-31 */
+#define AT91_AIC_IVR           (AT91_AIC + 0x100)      /* Interrupt Vector Register */
+#define AT91_AIC_FVR           (AT91_AIC + 0x104)      /* Fast Interrupt Vector Register */
+#define AT91_AIC_ISR           (AT91_AIC + 0x108)      /* Interrupt Status Register */
+#define                AT91_AIC_IRQID          (0x1f << 0)             /* Current Interrupt Identifier */
+
+#define AT91_AIC_IPR           (AT91_AIC + 0x10c)      /* Interrupt Pending Register */
+#define AT91_AIC_IMR           (AT91_AIC + 0x110)      /* Interrupt Mask Register */
+#define AT91_AIC_CISR          (AT91_AIC + 0x114)      /* Core Interrupt Status Register */
+#define                AT91_AIC_NFIQ           (1 << 0)                /* nFIQ Status */
+#define                AT91_AIC_NIRQ           (1 << 1)                /* nIRQ Status */
+
+#define AT91_AIC_IECR          (AT91_AIC + 0x120)      /* Interrupt Enable Command Register */
+#define AT91_AIC_IDCR          (AT91_AIC + 0x124)      /* Interrupt Disable Command Register */
+#define AT91_AIC_ICCR          (AT91_AIC + 0x128)      /* Interrupt Clear Command Register */
+#define AT91_AIC_ISCR          (AT91_AIC + 0x12c)      /* Interrupt Set Command Register */
+#define AT91_AIC_EOICR         (AT91_AIC + 0x130)      /* End of Interrupt Command Register */
+#define AT91_AIC_SPU           (AT91_AIC + 0x134)      /* Spurious Interrupt Vector Register */
+#define AT91_AIC_DCR           (AT91_AIC + 0x138)      /* Debug Control Register */
+#define                AT91_AIC_DCR_PROT       (1 << 0)                /* Protection Mode */
+#define                AT91_AIC_DCR_GMSK       (1 << 1)                /* General Mask */
+
+#define AT91_AIC_FFER          (AT91_AIC + 0x140)      /* Fast Forcing Enable Register [SAM9 only] */
+#define AT91_AIC_FFDR          (AT91_AIC + 0x144)      /* Fast Forcing Disable Register [SAM9 only] */
+#define AT91_AIC_FFSR          (AT91_AIC + 0x148)      /* Fast Forcing Status Register [SAM9 only] */
+
+#endif
diff --git a/include/asm-arm/arch-at91rm9200/at91_dbgu.h b/include/asm-arm/arch-at91rm9200/at91_dbgu.h
new file mode 100644 (file)
index 0000000..e4b8b27
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91_dbgu.h
+ *
+ * Copyright (C) 2005 Ivan Kokshaysky
+ * Copyright (C) SAN People
+ *
+ * Debug Unit (DBGU) - System peripherals registers.
+ * Based on AT91RM9200 datasheet revision E.
+ *
+ * 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.
+ */
+
+#ifndef AT91_DBGU_H
+#define AT91_DBGU_H
+
+#define AT91_DBGU_CR           (AT91_DBGU + 0x00)      /* Control Register */
+#define AT91_DBGU_MR           (AT91_DBGU + 0x04)      /* Mode Register */
+#define AT91_DBGU_IER          (AT91_DBGU + 0x08)      /* Interrupt Enable Register */
+#define                AT91_DBGU_TXRDY         (1 << 1)                /* Transmitter Ready */
+#define                AT91_DBGU_TXEMPTY       (1 << 9)                /* Transmitter Empty */
+#define AT91_DBGU_IDR          (AT91_DBGU + 0x0c)      /* Interrupt Disable Register */
+#define AT91_DBGU_IMR          (AT91_DBGU + 0x10)      /* Interrupt Mask Register */
+#define AT91_DBGU_SR           (AT91_DBGU + 0x14)      /* Status Register */
+#define AT91_DBGU_RHR          (AT91_DBGU + 0x18)      /* Receiver Holding Register */
+#define AT91_DBGU_THR          (AT91_DBGU + 0x1c)      /* Transmitter Holding Register */
+#define AT91_DBGU_BRGR         (AT91_DBGU + 0x20)      /* Baud Rate Generator Register */
+
+#define AT91_DBGU_CIDR         (AT91_DBGU + 0x40)      /* Chip ID Register */
+#define AT91_DBGU_EXID         (AT91_DBGU + 0x44)      /* Chip ID Extension Register */
+#define                AT91_CIDR_VERSION       (0x1f << 0)             /* Version of the Device */
+#define                AT91_CIDR_EPROC         (7    << 5)             /* Embedded Processor */
+#define                AT91_CIDR_NVPSIZ        (0xf  << 8)             /* Nonvolatile Program Memory Size */
+#define                AT91_CIDR_NVPSIZ2       (0xf  << 12)            /* Second Nonvolatile Program Memory Size */
+#define                AT91_CIDR_SRAMSIZ       (0xf  << 16)            /* Internal SRAM Size */
+#define                AT91_CIDR_ARCH          (0xff << 20)            /* Architecture Identifier */
+#define                AT91_CIDR_NVPTYP        (7    << 28)            /* Nonvolatile Program Memory Type */
+#define                AT91_CIDR_EXT           (1    << 31)            /* Extension Flag */
+
+#define AT91_DBGU_FNR          (AT91_DBGU + 0x48)      /* Force NTRST Register [SAM9 only] */
+#define                AT91_DBGU_FNTRST        (1 << 0)                /* Force NTRST */
+
+#endif
diff --git a/include/asm-arm/arch-at91rm9200/at91_ecc.h b/include/asm-arm/arch-at91rm9200/at91_ecc.h
new file mode 100644 (file)
index 0000000..fddf256
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91_ecc.h
+ *
+ * Error Corrected Code Controller (ECC) - System peripherals regsters.
+ * Based on AT91SAM9260 datasheet revision B.
+ *
+ * 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.
+ */
+
+#ifndef AT91_ECC_H
+#define AT91_ECC_H
+
+#define AT91_ECC_CR            (AT91_ECC + 0x00)       /* Control register */
+#define                AT91_ECC_RST            (1 << 0)                /* Reset parity */
+
+#define AT91_ECC_MR            (AT91_ECC + 0x04)       /* Mode register */
+#define                AT91_ECC_PAGESIZE       (3 << 0)                /* Page Size */
+#define                        AT91_ECC_PAGESIZE_528           (0)
+#define                        AT91_ECC_PAGESIZE_1056          (1)
+#define                        AT91_ECC_PAGESIZE_2112          (2)
+#define                        AT91_ECC_PAGESIZE_4224          (3)
+
+#define AT91_ECC_SR            (AT91_ECC + 0x08)       /* Status register */
+#define                AT91_ECC_RECERR         (1 << 0)                /* Recoverable Error */
+#define                AT91_ECC_ECCERR         (1 << 1)                /* ECC Single Bit Error */
+#define                AT91_ECC_MULERR         (1 << 2)                /* Multiple Errors */
+
+#define AT91_ECC_PR            (AT91_ECC + 0x0c)       /* Parity register */
+#define                AT91_ECC_BITADDR        (0xf << 0)              /* Bit Error Address */
+#define                AT91_ECC_WORDADDR       (0xfff << 4)            /* Word Error Address */
+
+#define AT91_ECC_NPR           (AT91_ECC + 0x10)       /* NParity register */
+#define                AT91_ECC_NPARITY        (0xffff << 0)           /* NParity */
+
+#endif
diff --git a/include/asm-arm/arch-at91rm9200/at91_lcdc.h b/include/asm-arm/arch-at91rm9200/at91_lcdc.h
new file mode 100644 (file)
index 0000000..9cbfcdd
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91_lcdc.h
+ *
+ * LCD Controller (LCDC).
+ * Based on AT91SAM9261 datasheet revision E.
+ *
+ * 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.
+ */
+
+#ifndef AT91_LCDC_H
+#define AT91_LCDC_H
+
+#define AT91_LCDC_DMABADDR1    0x00            /* DMA Base Address Register 1 */
+#define AT91_LCDC_DMABADDR2    0x04            /* DMA Base Address Register 2 */
+#define AT91_LCDC_DMAFRMPT1    0x08            /* DMA Frame Pointer Register 1 */
+#define AT91_LCDC_DMAFRMPT2    0x0c            /* DMA Frame Pointer Register 2 */
+#define AT91_LCDC_DMAFRMADD1   0x10            /* DMA Frame Address Register 1 */
+#define AT91_LCDC_DMAFRMADD2   0x14            /* DMA Frame Address Register 2 */
+
+#define AT91_LCDC_DMAFRMCFG    0x18            /* DMA Frame Configuration Register */
+#define                AT91_LCDC_FRSIZE        (0x7fffff <<  0)        /* Frame Size */
+#define                AT91_LCDC_BLENGTH       (0x7f     << 24)        /* Burst Length */
+
+#define AT91_LCDC_DMACON       0x1c            /* DMA Control Register */
+#define                AT91_LCDC_DMAEN         (0x1 << 0)      /* DMA Enable */
+#define                AT91_LCDC_DMARST        (0x1 << 1)      /* DMA Reset */
+#define                AT91_LCDC_DMABUSY       (0x1 << 2)      /* DMA Busy */
+
+#define AT91_LCDC_LCDCON1      0x0800          /* LCD Control Register 1 */
+#define                AT91_LCDC_BYPASS        (1     <<  0)   /* Bypass lcd_dotck divider */
+#define                AT91_LCDC_CLKVAL        (0x1ff << 12)   /* Clock Divider */
+#define                AT91_LCDC_LINCNT        (0x7ff << 21)   /* Line Counter */
+
+#define AT91_LCDC_LCDCON2      0x0804          /* LCD Control Register 2 */
+#define                AT91_LCDC_DISTYPE       (3 << 0)        /* Display Type */
+#define                        AT91_LCDC_DISTYPE_STNMONO       (0 << 0)
+#define                        AT91_LCDC_DISTYPE_STNCOLOR      (1 << 0)
+#define                        AT91_LCDC_DISTYPE_TFT           (2 << 0)
+#define                AT91_LCDC_SCANMOD       (1 << 2)        /* Scan Mode */
+#define                        AT91_LCDC_SCANMOD_SINGLE        (0 << 2)
+#define                        AT91_LCDC_SCANMOD_DUAL          (1 << 2)
+#define                AT91_LCDC_IFWIDTH       (3 << 3)        /*Interface Width */
+#define                        AT91_LCDC_IFWIDTH_4             (0 << 3)
+#define                        AT91_LCDC_IFWIDTH_8             (1 << 3)
+#define                        AT91_LCDC_IFWIDTH_16            (2 << 3)
+#define                AT91_LCDC_PIXELSIZE     (7 << 5)        /* Bits per pixel */
+#define                        AT91_LCDC_PIXELSIZE_1           (0 << 5)
+#define                        AT91_LCDC_PIXELSIZE_2           (1 << 5)
+#define                        AT91_LCDC_PIXELSIZE_4           (2 << 5)
+#define                        AT91_LCDC_PIXELSIZE_8           (3 << 5)
+#define                        AT91_LCDC_PIXELSIZE_16          (4 << 5)
+#define                        AT91_LCDC_PIXELSIZE_24          (5 << 5)
+#define                AT91_LCDC_INVVD         (1 << 8)        /* LCD Data polarity */
+#define                        AT91_LCDC_INVVD_NORMAL          (0 << 8)
+#define                        AT91_LCDC_INVVD_INVERTED        (1 << 8)
+#define                AT91_LCDC_INVFRAME      (1 << 9 )       /* LCD VSync polarity */
+#define                        AT91_LCDC_INVFRAME_NORMAL       (0 << 9)
+#define                        AT91_LCDC_INVFRAME_INVERTED     (1 << 9)
+#define                AT91_LCDC_INVLINE       (1 << 10)       /* LCD HSync polarity */
+#define                        AT91_LCDC_INVLINE_NORMAL        (0 << 10)
+#define                        AT91_LCDC_INVLINE_INVERTED      (1 << 10)
+#define                AT91_LCDC_INVCLK        (1 << 11)       /* LCD dotclk polarity */
+#define                        AT91_LCDC_INVCLK_NORMAL         (0 << 11)
+#define                        AT91_LCDC_INVCLK_INVERTED       (1 << 11)
+#define                AT91_LCDC_INVDVAL       (1 << 12)       /* LCD dval polarity */
+#define                        AT91_LCDC_INVDVAL_NORMAL        (0 << 12)
+#define                        AT91_LCDC_INVDVAL_INVERTED      (1 << 12)
+#define                AT91_LCDC_CLKMOD        (1 << 15)       /* LCD dotclk mode */
+#define                        AT91_LCDC_CLKMOD_ACTIVEDISPLAY  (0 << 15)
+#define                        AT91_LCDC_CLKMOD_ALWAYSACTIVE   (1 << 15)
+#define                AT91_LCDC_MEMOR         (1 << 31)       /* Memory Ordering Format */
+#define                        AT91_LCDC_MEMOR_BIG             (0 << 31)
+#define                        AT91_LCDC_MEMOR_LITTLE          (1 << 31)
+
+#define AT91_LCDC_TIM1         0x0808          /* LCD Timing Register 1 */
+#define                AT91_LCDC_VFP           (0xff <<  0)    /* Vertical Front Porch */
+#define                AT91_LCDC_VBP           (0xff <<  8)    /* Vertical Back Porch */
+#define                AT91_LCDC_VPW           (0x3f << 16)    /* Vertical Synchronization Pulse Width */
+#define                AT91_LCDC_VHDLY         (0xf  << 24)    /* Vertical to Horizontal Delay */
+
+#define AT91_LCDC_TIM2         0x080c          /* LCD Timing Register 2 */
+#define                AT91_LCDC_HBP           (0xff  <<  0)   /* Horizontal Back Porch */
+#define                AT91_LCDC_HPW           (0x3f  <<  8)   /* Horizontal Synchronization Pulse Width */
+#define                AT91_LCDC_HFP           (0x7ff << 21)   /* Horizontal Front Porch */
+
+#define AT91_LCDC_LCDFRMCFG    0x0810          /* LCD Frame Configuration Register */
+#define                AT91_LCDC_LINEVAL       (0x7ff <<  0)   /* Vertical Size of LCD Module */
+#define                AT91_LCDC_HOZVAL        (0x7ff << 21)   /* Horizontal Size of LCD Module */
+
+#define AT91_LCDC_FIFO         0x0814          /* LCD FIFO Register */
+#define                AT91_LCDC_FIFOTH        (0xffff)        /* FIFO Threshold */
+
+#define AT91_LCDC_DP1_2                0x081c          /* Dithering Pattern DP1_2 Register */
+#define AT91_LCDC_DP4_7                0x0820          /* Dithering Pattern DP4_7 Register */
+#define AT91_LCDC_DP3_5                0x0824          /* Dithering Pattern DP3_5 Register */
+#define AT91_LCDC_DP2_3                0x0828          /* Dithering Pattern DP2_3 Register */
+#define AT91_LCDC_DP5_7                0x082c          /* Dithering Pattern DP5_7 Register */
+#define AT91_LCDC_DP3_4                0x0830          /* Dithering Pattern DP3_4 Register */
+#define AT91_LCDC_DP4_5                0x0834          /* Dithering Pattern DP4_5 Register */
+#define AT91_LCDC_DP6_7                0x0838          /* Dithering Pattern DP6_7 Register */
+#define                AT91_LCDC_DP1_2_VAL     (0xff)
+#define                AT91_LCDC_DP4_7_VAL     (0xfffffff)
+#define                AT91_LCDC_DP3_5_VAL     (0xfffff)
+#define                AT91_LCDC_DP2_3_VAL     (0xfff)
+#define                AT91_LCDC_DP5_7_VAL     (0xfffffff)
+#define                AT91_LCDC_DP3_4_VAL     (0xffff)
+#define                AT91_LCDC_DP4_5_VAL     (0xfffff)
+#define                AT91_LCDC_DP6_7_VAL     (0xfffffff)
+
+#define AT91_LCDC_PWRCON       0x083c          /* Power Control Register */
+#define                AT91_LCDC_PWR           (1    <<  0)    /* LCD Module Power Control */
+#define                AT91_LCDC_GUARDT        (0x7f <<  1)    /* Delay in Frame Period */
+#define                AT91_LCDC_BUSY          (1    << 31)    /* LCD Busy */
+
+#define AT91_LCDC_CONTRAST_CTR 0x0840          /* Contrast Control Register */
+#define                AT91_LCDC_PS            (3 << 0)        /* Contrast Counter Prescaler */
+#define                        AT91_LCDC_PS_DIV1               (0 << 0)
+#define                        AT91_LCDC_PS_DIV2               (1 << 0)
+#define                        AT91_LCDC_PS_DIV4               (2 << 0)
+#define                        AT91_LCDC_PS_DIV8               (3 << 0)
+#define                AT91_LCDC_POL           (1 << 2)        /* Polarity of output Pulse */
+#define                        AT91_LCDC_POL_NEGATIVE          (0 << 2)
+#define                        AT91_LCDC_POL_POSITIVE          (1 << 2)
+#define                AT91_LCDC_ENA           (1 << 3)        /* PWM generator Control */
+#define                        AT91_LCDC_ENA_PWMDISABLE        (0 << 3)
+#define                        AT91_LCDC_ENA_PWMENABLE         (1 << 3)
+
+#define AT91_LCDC_CONTRAST_VAL 0x0844          /* Contrast Value Register */
+#define                AT91_LCDC_CVAL          (0xff)          /* PWM compare value */
+
+#define AT91_LCDC_IER          0x0848          /* Interrupt Enable Register */
+#define AT91_LCDC_IDR          0x084c          /* Interrupt Disable Register */
+#define AT91_LCDC_IMR          0x0850          /* Interrupt Mask Register */
+#define AT91_LCDC_ISR          0x0854          /* Interrupt Enable Register */
+#define AT91_LCDC_ICR          0x0858          /* Interrupt Clear Register */
+#define                AT91_LCDC_LNI           (1 << 0)        /* Line Interrupt */
+#define                AT91_LCDC_LSTLNI        (1 << 1)        /* Last Line Interrupt */
+#define                AT91_LCDC_EOFI          (1 << 2)        /* DMA End Of Frame Interrupt */
+#define                AT91_LCDC_UFLWI         (1 << 4)        /* FIFO Underflow Interrupt */
+#define                AT91_LCDC_OWRI          (1 << 5)        /* FIFO Overwrite Interrupt */
+#define                AT91_LCDC_MERI          (1 << 6)        /* DMA Memory Error Interrupt */
+
+#define AT91_LCDC_LUT_(n)      (0x0c00 + ((n)*4))      /* Palette Entry 0..255 */
+
+#endif
similarity index 85%
rename from include/asm-arm/arch-at91rm9200/at91rm9200_mci.h
rename to include/asm-arm/arch-at91rm9200/at91_mci.h
index f28636d61e39b1ffd4404de1f298526784187018..9a552cb743c0c763faec0050c49dc3b2088ced71 100644 (file)
@@ -1,11 +1,11 @@
 /*
- * include/asm-arm/arch-at91rm9200/at91rm9200_mci.h
+ * include/asm-arm/arch-at91rm9200/at91_mci.h
  *
  * Copyright (C) 2005 Ivan Kokshaysky
  * Copyright (C) SAN People
  *
  * MultiMedia Card Interface (MCI) registers.
- * Based on AT91RM9200 datasheet revision E.
+ * Based on AT91RM9200 datasheet revision F.
  *
  * 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
@@ -13,8 +13,8 @@
  * (at your option) any later version.
  */
 
-#ifndef AT91RM9200_MCI_H
-#define AT91RM9200_MCI_H
+#ifndef AT91_MCI_H
+#define AT91_MCI_H
 
 #define AT91_MCI_CR            0x00            /* Control Register */
 #define                AT91_MCI_MCIEN          (1 <<  0)       /* Multi-Media Interface Enable */
 
 #define AT91_MCI_MR            0x04            /* Mode Register */
 #define                AT91_MCI_CLKDIV         (0xff  <<  0)   /* Clock Divider */
-#define                AT91_MCI_PWSDIV         (3     <<  8)   /* Power Saving Divider */
+#define                AT91_MCI_PWSDIV         (7     <<  8)   /* Power Saving Divider */
 #define                AT91_MCI_PDCPADV        (1     << 14)   /* PDC Padding Value */
 #define                AT91_MCI_PDCMODE        (1     << 15)   /* PDC-orientated Mode */
-#define                AT91_MCI_BLKLEN         (0xfff << 18)   /* Data Block Length */
+#define                AT91_MCI_BLKLEN         (0xfff << 18)   /* Data Block Length */
 
 #define AT91_MCI_DTOR          0x08            /* Data Timeout Register */
 #define                AT91_MCI_DTOCYC         (0xf << 0)      /* Data Timeout Cycle Number */
@@ -43,8 +43,8 @@
 #define                AT91_MCI_DTOMUL_1M              (7 <<  4)
 
 #define AT91_MCI_SDCR          0x0c            /* SD Card Register */
-#define                AT91_MCI_SDCSEL         (0xf << 0)      /* SD Card Selector */
-#define                AT91_MCI_SDCBUS         (1   << 7)      /* 1-bit or 4-bit bus */
+#define                AT91_MCI_SDCSEL         (3 << 0)        /* SD Card Selector */
+#define                AT91_MCI_SDCBUS         (1 << 7)        /* 1-bit or 4-bit bus */
 
 #define AT91_MCI_ARGR          0x10            /* Argument Register */
 
 
 #define AT91_MCI_SR            0x40            /* Status Register */
 #define                AT91_MCI_CMDRDY         (1 <<  0)       /* Command Ready */
-#define                AT91_MCI_RXRDY          (1 <<  1)       /* Receiver Ready */
+#define                AT91_MCI_RXRDY          (1 <<  1)       /* Receiver Ready */
 #define                AT91_MCI_TXRDY          (1 <<  2)       /* Transmit Ready */
 #define                AT91_MCI_BLKE           (1 <<  3)       /* Data Block Ended */
 #define                AT91_MCI_DTIP           (1 <<  4)       /* Data Transfer in Progress */
 #define                AT91_MCI_NOTBUSY        (1 <<  5)       /* Data Not Busy */
 #define                AT91_MCI_ENDRX          (1 <<  6)       /* End of RX Buffer */
 #define                AT91_MCI_ENDTX          (1 <<  7)       /* End fo TX Buffer */
+#define                AT91_MCI_SDIOIRQA       (1 <<  8)       /* SDIO Interrupt for Slot A */
+#define                At91_MCI_SDIOIRQB       (1 <<  9)       /* SDIO Interrupt for Slot B [AT91RM9200 only] */
 #define                AT91_MCI_RXBUFF         (1 << 14)       /* RX Buffer Full */
 #define                AT91_MCI_TXBUFE         (1 << 15)       /* TX Buffer Empty */
-#define                AT91_MCI_RINDE          (1 << 16)       /* Response Index Error */
+#define                AT91_MCI_RINDE          (1 << 16)       /* Response Index Error */
 #define                AT91_MCI_RDIRE          (1 << 17)       /* Response Direction Error */
-#define                AT91_MCI_RCRCE          (1 << 18)       /* Response CRC Error */
+#define                AT91_MCI_RCRCE          (1 << 18)       /* Response CRC Error */
 #define                AT91_MCI_RENDE          (1 << 19)       /* Response End Bit Error */
 #define                AT91_MCI_RTOE           (1 << 20)       /* Reponse Time-out Error */
 #define                AT91_MCI_DCRCE          (1 << 21)       /* Data CRC Error */
similarity index 92%
rename from include/asm-avr32/arch-at32ap/at91rm9200_pdc.h
rename to include/asm-arm/arch-at91rm9200/at91_pdc.h
index ce1150d4438d46de7fa3f9d3f7c0c08b80daeccb..79d6e02fa45e161958b64d7c51af5d3dd97d7819 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * include/asm-arm/arch-at91rm9200/at91rm9200_pdc.h
+ * include/asm-arm/arch-at91rm9200/at91_pdc.h
  *
  * Copyright (C) 2005 Ivan Kokshaysky
  * Copyright (C) SAN People
@@ -13,8 +13,8 @@
  * (at your option) any later version.
  */
 
-#ifndef AT91RM9200_PDC_H
-#define AT91RM9200_PDC_H
+#ifndef AT91_PDC_H
+#define AT91_PDC_H
 
 #define AT91_PDC_RPR           0x100   /* Receive Pointer Register */
 #define AT91_PDC_RCR           0x104   /* Receive Counter Register */
diff --git a/include/asm-arm/arch-at91rm9200/at91_pio.h b/include/asm-arm/arch-at91rm9200/at91_pio.h
new file mode 100644 (file)
index 0000000..680eaa1
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91_pio.h
+ *
+ * Copyright (C) 2005 Ivan Kokshaysky
+ * Copyright (C) SAN People
+ *
+ * Parallel I/O Controller (PIO) - System peripherals registers.
+ * Based on AT91RM9200 datasheet revision E.
+ *
+ * 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.
+ */
+
+#ifndef AT91_PIO_H
+#define AT91_PIO_H
+
+#define PIO_PER                0x00    /* Enable Register */
+#define PIO_PDR                0x04    /* Disable Register */
+#define PIO_PSR                0x08    /* Status Register */
+#define PIO_OER                0x10    /* Output Enable Register */
+#define PIO_ODR                0x14    /* Output Disable Register */
+#define PIO_OSR                0x18    /* Output Status Register */
+#define PIO_IFER       0x20    /* Glitch Input Filter Enable */
+#define PIO_IFDR       0x24    /* Glitch Input Filter Disable */
+#define PIO_IFSR       0x28    /* Glitch Input Filter Status */
+#define PIO_SODR       0x30    /* Set Output Data Register */
+#define PIO_CODR       0x34    /* Clear Output Data Register */
+#define PIO_ODSR       0x38    /* Output Data Status Register */
+#define PIO_PDSR       0x3c    /* Pin Data Status Register */
+#define PIO_IER                0x40    /* Interrupt Enable Register */
+#define PIO_IDR                0x44    /* Interrupt Disable Register */
+#define PIO_IMR                0x48    /* Interrupt Mask Register */
+#define PIO_ISR                0x4c    /* Interrupt Status Register */
+#define PIO_MDER       0x50    /* Multi-driver Enable Register */
+#define PIO_MDDR       0x54    /* Multi-driver Disable Register */
+#define PIO_MDSR       0x58    /* Multi-driver Status Register */
+#define PIO_PUDR       0x60    /* Pull-up Disable Register */
+#define PIO_PUER       0x64    /* Pull-up Enable Register */
+#define PIO_PUSR       0x68    /* Pull-up Status Register */
+#define PIO_ASR                0x70    /* Peripheral A Select Register */
+#define PIO_BSR                0x74    /* Peripheral B Select Register */
+#define PIO_ABSR       0x78    /* AB Status Register */
+#define PIO_OWER       0xa0    /* Output Write Enable Register */
+#define PIO_OWDR       0xa4    /* Output Write Disable Register */
+#define PIO_OWSR       0xa8    /* Output Write Status Register */
+
+#endif
diff --git a/include/asm-arm/arch-at91rm9200/at91_pit.h b/include/asm-arm/arch-at91rm9200/at91_pit.h
new file mode 100644 (file)
index 0000000..4a30d00
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91_pit.h
+ *
+ * Periodic Interval Timer (PIT) - System peripherals regsters.
+ * Based on AT91SAM9261 datasheet revision D.
+ *
+ * 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.
+ */
+
+#ifndef AT91_PIT_H
+#define AT91_PIT_H
+
+#define AT91_PIT_MR            (AT91_PIT + 0x00)       /* Mode Register */
+#define                AT91_PIT_PITIEN         (1 << 25)               /* Timer Interrupt Enable */
+#define                AT91_PIT_PITEN          (1 << 24)               /* Timer Enabled */
+#define                AT91_PIT_PIV            (0xfffff)               /* Periodic Interval Value */
+
+#define AT91_PIT_SR            (AT91_PIT + 0x04)       /* Status Register */
+#define                AT91_PIT_PITS           (1 << 0)                /* Timer Status */
+
+#define AT91_PIT_PIVR          (AT91_PIT + 0x08)       /* Periodic Interval Value Register */
+#define AT91_PIT_PIIR          (AT91_PIT + 0x0c)       /* Periodic Interval Image Register */
+#define                AT91_PIT_PICNT          (0xfff << 20)           /* Interval Counter */
+#define                AT91_PIT_CPIV           (0xfffff)               /* Inverval Value */
+
+#endif
diff --git a/include/asm-arm/arch-at91rm9200/at91_pmc.h b/include/asm-arm/arch-at91rm9200/at91_pmc.h
new file mode 100644 (file)
index 0000000..de8c3da
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91_pmc.h
+ *
+ * Copyright (C) 2005 Ivan Kokshaysky
+ * Copyright (C) SAN People
+ *
+ * Power Management Controller (PMC) - System peripherals registers.
+ * Based on AT91RM9200 datasheet revision E.
+ *
+ * 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.
+ */
+
+#ifndef AT91_PMC_H
+#define AT91_PMC_H
+
+#define        AT91_PMC_SCER           (AT91_PMC + 0x00)       /* System Clock Enable Register */
+#define        AT91_PMC_SCDR           (AT91_PMC + 0x04)       /* System Clock Disable Register */
+
+#define        AT91_PMC_SCSR           (AT91_PMC + 0x08)       /* System Clock Status Register */
+#define                AT91_PMC_PCK            (1 <<  0)               /* Processor Clock */
+#define                AT91RM9200_PMC_UDP      (1 <<  1)               /* USB Devcice Port Clock [AT91RM9200 only] */
+#define                AT91RM9200_PMC_MCKUDP   (1 <<  2)               /* USB Device Port Master Clock Automatic Disable on Suspend [AT91RM9200 only] */
+#define                AT91RM9200_PMC_UHP      (1 <<  4)               /* USB Host Port Clock [AT91RM9200 only] */
+#define                AT91SAM926x_PMC_UHP     (1 <<  6)               /* USB Host Port Clock [AT91SAM926x only] */
+#define                AT91SAM926x_PMC_UDP     (1 <<  7)               /* USB Devcice Port Clock [AT91SAM926x only] */
+#define                AT91_PMC_PCK0           (1 <<  8)               /* Programmable Clock 0 */
+#define                AT91_PMC_PCK1           (1 <<  9)               /* Programmable Clock 1 */
+#define                AT91_PMC_PCK2           (1 << 10)               /* Programmable Clock 2 */
+#define                AT91_PMC_PCK3           (1 << 11)               /* Programmable Clock 3 */
+#define                AT91_PMC_HCK0           (1 << 16)               /* AHB Clock (USB host) [AT91SAM9261 only] */
+#define                AT91_PMC_HCK1           (1 << 17)               /* AHB Clock (LCD) [AT91SAM9261 only] */
+
+#define        AT91_PMC_PCER           (AT91_PMC + 0x10)       /* Peripheral Clock Enable Register */
+#define        AT91_PMC_PCDR           (AT91_PMC + 0x14)       /* Peripheral Clock Disable Register */
+#define        AT91_PMC_PCSR           (AT91_PMC + 0x18)       /* Peripheral Clock Status Register */
+
+#define        AT91_CKGR_MOR           (AT91_PMC + 0x20)       /* Main Oscillator Register */
+#define                AT91_PMC_MOSCEN         (1    << 0)             /* Main Oscillator Enable */
+#define                AT91_PMC_OSCBYPASS      (1    << 1)             /* Oscillator Bypass [AT91SAM926x only] */
+#define                AT91_PMC_OSCOUNT        (0xff << 8)             /* Main Oscillator Start-up Time */
+
+#define        AT91_CKGR_MCFR          (AT91_PMC + 0x24)       /* Main Clock Frequency Register */
+#define                AT91_PMC_MAINF          (0xffff <<  0)          /* Main Clock Frequency */
+#define                AT91_PMC_MAINRDY        (1      << 16)          /* Main Clock Ready */
+
+#define        AT91_CKGR_PLLAR         (AT91_PMC + 0x28)       /* PLL A Register */
+#define        AT91_CKGR_PLLBR         (AT91_PMC + 0x2c)       /* PLL B Register */
+#define                AT91_PMC_DIV            (0xff  <<  0)           /* Divider */
+#define                AT91_PMC_PLLCOUNT       (0x3f  <<  8)           /* PLL Counter */
+#define                AT91_PMC_OUT            (3     << 14)           /* PLL Clock Frequency Range */
+#define                AT91_PMC_MUL            (0x7ff << 16)           /* PLL Multiplier */
+#define                AT91_PMC_USB96M         (1     << 28)           /* Divider by 2 Enable (PLLB only) */
+
+#define        AT91_PMC_MCKR           (AT91_PMC + 0x30)       /* Master Clock Register */
+#define                AT91_PMC_CSS            (3 <<  0)               /* Master Clock Selection */
+#define                        AT91_PMC_CSS_SLOW               (0 << 0)
+#define                        AT91_PMC_CSS_MAIN               (1 << 0)
+#define                        AT91_PMC_CSS_PLLA               (2 << 0)
+#define                        AT91_PMC_CSS_PLLB               (3 << 0)
+#define                AT91_PMC_PRES           (7 <<  2)               /* Master Clock Prescaler */
+#define                AT91_PMC_PRES_1                 (0 << 2)
+#define                        AT91_PMC_PRES_2                 (1 << 2)
+#define                        AT91_PMC_PRES_4                 (2 << 2)
+#define                        AT91_PMC_PRES_8                 (3 << 2)
+#define                        AT91_PMC_PRES_16                (4 << 2)
+#define                        AT91_PMC_PRES_32                (5 << 2)
+#define                        AT91_PMC_PRES_64                (6 << 2)
+#define                AT91_PMC_MDIV           (3 <<  8)               /* Master Clock Division */
+#define                        AT91_PMC_MDIV_1                 (0 << 8)
+#define                        AT91_PMC_MDIV_2                 (1 << 8)
+#define                        AT91_PMC_MDIV_3                 (2 << 8)
+#define                        AT91_PMC_MDIV_4                 (3 << 8)
+
+#define        AT91_PMC_PCKR(n)        (AT91_PMC + 0x40 + ((n) * 4))   /* Programmable Clock 0-3 Registers */
+
+#define        AT91_PMC_IER            (AT91_PMC + 0x60)       /* Interrupt Enable Register */
+#define        AT91_PMC_IDR            (AT91_PMC + 0x64)       /* Interrupt Disable Register */
+#define        AT91_PMC_SR             (AT91_PMC + 0x68)       /* Status Register */
+#define                AT91_PMC_MOSCS          (1 <<  0)               /* MOSCS Flag */
+#define                AT91_PMC_LOCKA          (1 <<  1)               /* PLLA Lock */
+#define                AT91_PMC_LOCKB          (1 <<  2)               /* PLLB Lock */
+#define                AT91_PMC_MCKRDY         (1 <<  3)               /* Master Clock */
+#define                AT91_PMC_PCK0RDY        (1 <<  8)               /* Programmable Clock 0 */
+#define                AT91_PMC_PCK1RDY        (1 <<  9)               /* Programmable Clock 1 */
+#define                AT91_PMC_PCK2RDY        (1 << 10)               /* Programmable Clock 2 */
+#define                AT91_PMC_PCK3RDY        (1 << 11)               /* Programmable Clock 3 */
+#define        AT91_PMC_IMR            (AT91_PMC + 0x6c)       /* Interrupt Mask Register */
+
+#endif
diff --git a/include/asm-arm/arch-at91rm9200/at91_rstc.h b/include/asm-arm/arch-at91rm9200/at91_rstc.h
new file mode 100644 (file)
index 0000000..ccdc52d
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91_rstc.h
+ *
+ * Reset Controller (RSTC) - System peripherals regsters.
+ * Based on AT91SAM9261 datasheet revision D.
+ *
+ * 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.
+ */
+
+#ifndef AT91_RSTC_H
+#define AT91_RSTC_H
+
+#define AT91_RSTC_CR           (AT91_RSTC + 0x00)      /* Reset Controller Control Register */
+#define                AT91_RSTC_PROCRST       (1 << 0)                /* Processor Reset */
+#define                AT91_RSTC_PERRST        (1 << 2)                /* Peripheral Reset */
+#define                AT91_RSTC_EXTRST        (1 << 3)                /* External Reset */
+#define                AT01_RSTC_KEY           (0xff << 24)            /* KEY Password */
+
+#define AT91_RSTC_SR           (AT91_RSTC + 0x04)      /* Reset Controller Status Register */
+#define                AT91_RSTC_URSTS         (1 << 0)                /* User Reset Status */
+#define                AT91_RSTC_RSTTYP        (7 << 8)                /* Reset Type */
+#define                        AT91_RSTC_RSTTYP_GENERAL        (0 << 8)
+#define                        AT91_RSTC_RSTTYP_WAKEUP         (1 << 8)
+#define                        AT91_RSTC_RSTTYP_WATCHDOG       (2 << 8)
+#define                        AT91_RSTC_RSTTYP_SOFTWARE       (3 << 8)
+#define                        AT91_RSTC_RSTTYP_USER   (4 << 8)
+#define                AT91_RSTC_NRSTL         (1 << 16)               /* NRST Pin Level */
+#define                AT91_RSTC_SRCMP         (1 << 17)               /* Software Reset Command in Progress */
+
+#define AT91_RSTC_MR           (AT91_RSTC + 0x08)      /* Reset Controller Mode Register */
+#define                AT91_RSTC_URSTEN        (1 << 0)                /* User Reset Enable */
+#define                AT91_RSTC_URSTIEN       (1 << 4)                /* User Reset Interrupt Enable */
+#define                AT91_RSTC_ERSTL         (0xf << 8)              /* External Reset Length */
+#define                AT91_RSTC_KEY           (0xff << 24)            /* KEY Password */
+
+#endif
diff --git a/include/asm-arm/arch-at91rm9200/at91_rtc.h b/include/asm-arm/arch-at91rm9200/at91_rtc.h
new file mode 100644 (file)
index 0000000..6e5065d
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91_rtc.h
+ *
+ * Copyright (C) 2005 Ivan Kokshaysky
+ * Copyright (C) SAN People
+ *
+ * Real Time Clock (RTC) - System peripheral registers.
+ * Based on AT91RM9200 datasheet revision E.
+ *
+ * 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.
+ */
+
+#ifndef AT91_RTC_H
+#define AT91_RTC_H
+
+#define        AT91_RTC_CR             (AT91_RTC + 0x00)       /* Control Register */
+#define                AT91_RTC_UPDTIM         (1 <<  0)               /* Update Request Time Register */
+#define                AT91_RTC_UPDCAL         (1 <<  1)               /* Update Request Calendar Register */
+#define                AT91_RTC_TIMEVSEL       (3 <<  8)               /* Time Event Selection */
+#define                        AT91_RTC_TIMEVSEL_MINUTE        (0 << 8)
+#define                AT91_RTC_TIMEVSEL_HOUR          (1 << 8)
+#define                AT91_RTC_TIMEVSEL_DAY24         (2 << 8)
+#define                AT91_RTC_TIMEVSEL_DAY12         (3 << 8)
+#define                AT91_RTC_CALEVSEL       (3 << 16)               /* Calendar Event Selection */
+#define                AT91_RTC_CALEVSEL_WEEK          (0 << 16)
+#define                AT91_RTC_CALEVSEL_MONTH         (1 << 16)
+#define                AT91_RTC_CALEVSEL_YEAR          (2 << 16)
+
+#define        AT91_RTC_MR             (AT91_RTC + 0x04)       /* Mode Register */
+#define        AT91_RTC_HRMOD          (1 <<  0)               /* 12/24 Hour Mode */
+
+#define        AT91_RTC_TIMR           (AT91_RTC + 0x08)       /* Time Register */
+#define                AT91_RTC_SEC            (0x7f <<  0)            /* Current Second */
+#define                AT91_RTC_MIN            (0x7f <<  8)            /* Current Minute */
+#define                AT91_RTC_HOUR           (0x3f << 16)            /* Current Hour */
+#define                AT91_RTC_AMPM           (1    << 22)            /* Ante Meridiem Post Meridiem Indicator */
+
+#define        AT91_RTC_CALR           (AT91_RTC + 0x0c)       /* Calendar Register */
+#define                AT91_RTC_CENT           (0x7f <<  0)            /* Current Century */
+#define                AT91_RTC_YEAR           (0xff <<  8)            /* Current Year */
+#define                AT91_RTC_MONTH          (0x1f << 16)            /* Current Month */
+#define                AT91_RTC_DAY            (7    << 21)            /* Current Day */
+#define                AT91_RTC_DATE           (0x3f << 24)            /* Current Date */
+
+#define        AT91_RTC_TIMALR         (AT91_RTC + 0x10)       /* Time Alarm Register */
+#define                AT91_RTC_SECEN          (1 <<  7)               /* Second Alarm Enable */
+#define                AT91_RTC_MINEN          (1 << 15)               /* Minute Alarm Enable */
+#define                AT91_RTC_HOUREN         (1 << 23)               /* Hour Alarm Enable */
+
+#define        AT91_RTC_CALALR         (AT91_RTC + 0x14)       /* Calendar Alarm Register */
+#define                AT91_RTC_MTHEN          (1 << 23)               /* Month Alarm Enable */
+#define                AT91_RTC_DATEEN         (1 << 31)               /* Date Alarm Enable */
+
+#define        AT91_RTC_SR             (AT91_RTC + 0x18)       /* Status Register */
+#define                AT91_RTC_ACKUPD         (1 <<  0)               /* Acknowledge for Update */
+#define                AT91_RTC_ALARM          (1 <<  1)               /* Alarm Flag */
+#define                AT91_RTC_SECEV          (1 <<  2)               /* Second Event */
+#define                AT91_RTC_TIMEV          (1 <<  3)               /* Time Event */
+#define                AT91_RTC_CALEV          (1 <<  4)               /* Calendar Event */
+
+#define        AT91_RTC_SCCR           (AT91_RTC + 0x1c)       /* Status Clear Command Register */
+#define        AT91_RTC_IER            (AT91_RTC + 0x20)       /* Interrupt Enable Register */
+#define        AT91_RTC_IDR            (AT91_RTC + 0x24)       /* Interrupt Disable Register */
+#define        AT91_RTC_IMR            (AT91_RTC + 0x28)       /* Interrupt Mask Register */
+
+#define        AT91_RTC_VER            (AT91_RTC + 0x2c)       /* Valid Entry Register */
+#define                AT91_RTC_NVTIM          (1 <<  0)               /* Non valid Time */
+#define                AT91_RTC_NVCAL          (1 <<  1)               /* Non valid Calendar */
+#define                AT91_RTC_NVTIMALR       (1 <<  2)               /* Non valid Time Alarm */
+#define                AT91_RTC_NVCALALR       (1 <<  3)               /* Non valid Calendar Alarm */
+
+#endif
diff --git a/include/asm-arm/arch-at91rm9200/at91_rtt.h b/include/asm-arm/arch-at91rm9200/at91_rtt.h
new file mode 100644 (file)
index 0000000..c6751ba
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91_rtt.h
+ *
+ * Real-time Timer (RTT) - System peripherals regsters.
+ * Based on AT91SAM9261 datasheet revision D.
+ *
+ * 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.
+ */
+
+#ifndef AT91_RTT_H
+#define AT91_RTT_H
+
+#define AT91_RTT_MR            (AT91_RTT + 0x00)       /* Real-time Mode Register */
+#define                AT91_RTT_RTPRES         (0xffff << 0)           /* Real-time Timer Prescaler Value */
+#define                AT91_RTT_ALMIEN         (1 << 16)               /* Alarm Interrupt Enable */
+#define                AT91_RTT_RTTINCIEN      (1 << 17)               /* Real Time Timer Increment Interrupt Enable */
+#define                AT91_RTT_RTTRST         (1 << 18)               /* Real Time Timer Restart */
+
+#define AT91_RTT_AR            (AT91_RTT + 0x04)       /* Real-time Alarm Register */
+#define                AT91_RTT_ALMV           (0xffffffff)            /* Alarm Value */
+
+#define AT91_RTT_VR            (AT91_RTT + 0x08)       /* Real-time Value Register */
+#define                AT91_RTT_CRTV           (0xffffffff)            /* Current Real-time Value */
+
+#define AT91_RTT_SR            (AT91_RTT + 0x0c)       /* Real-time Status Register */
+#define                AT91_RTT_ALMS           (1 << 0)                /* Real-time Alarm Status */
+#define                AT91_RTT_RTTINC         (1 << 1)                /* Real-time Timer Increment */
+
+#endif
diff --git a/include/asm-arm/arch-at91rm9200/at91_shdwc.h b/include/asm-arm/arch-at91rm9200/at91_shdwc.h
new file mode 100644 (file)
index 0000000..0439250
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91_shdwc.h
+ *
+ * Shutdown Controller (SHDWC) - System peripherals regsters.
+ * Based on AT91SAM9261 datasheet revision D.
+ *
+ * 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.
+ */
+
+#ifndef AT91_SHDWC_H
+#define AT91_SHDWC_H
+
+#define AT91_SHDW_CR           (AT91_SHDWC + 0x00)     /* Shut Down Control Register */
+#define                AT91_SHDW_SHDW          (1    << 0)             /* Processor Reset */
+#define                AT91_SHDW_KEY           (0xff << 24)            /* KEY Password */
+
+#define AT91_SHDW_MR           (AT91_SHDWC + 0x04)     /* Shut Down Mode Register */
+#define                AT91_SHDW_WKMODE0       (3 << 0)                /* Wake-up 0 Mode Selection */
+#define                        AT91_SHDW_WKMODE0_NONE          0
+#define                        AT91_SHDW_WKMODE0_HIGH          1
+#define                        AT91_SHDW_WKMODE0_LOW           2
+#define                        AT91_SHDW_WKMODE0_ANYLEVEL      3
+#define                AT91_SHDW_CPTWK0        (0xf << 4)              /* Counter On Wake Up 0 */
+#define                AT91_SHDW_RTTWKEN       (1   << 16)             /* Real Time Timer Wake-up Enable */
+
+#define AT91_SHDW_SR           (AT91_SHDWC + 0x08)     /* Shut Down Status Register */
+#define                AT91_SHDW_WAKEUP0       (1 <<  0)               /* Wake-up 0 Status */
+#define                AT91_SHDW_RTTWK         (1 << 16)               /* Real-time Timer Wake-up */
+
+#endif
similarity index 95%
rename from include/asm-arm/arch-at91rm9200/at91rm9200_spi.h
rename to include/asm-arm/arch-at91rm9200/at91_spi.h
index bff5ea45f604a0f4429bf39387093eddee973218..bec48ca89bbadd80500cfcfbceaa8547bcd1d30f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * include/asm-arm/arch-at91rm9200/at91rm9200_spi.h
+ * include/asm-arm/arch-at91rm9200/at91_spi.h
  *
  * Copyright (C) 2005 Ivan Kokshaysky
  * Copyright (C) SAN People
@@ -13,8 +13,8 @@
  * (at your option) any later version.
  */
 
-#ifndef AT91RM9200_SPI_H
-#define AT91RM9200_SPI_H
+#ifndef AT91_SPI_H
+#define AT91_SPI_H
 
 #define AT91_SPI_CR                    0x00            /* Control Register */
 #define                AT91_SPI_SPIEN          (1 <<  0)               /* SPI Enable */
@@ -28,7 +28,7 @@
 #define                        AT91_SPI_PS_FIXED       (0 << 1)
 #define                        AT91_SPI_PS_VARIABLE    (1 << 1)
 #define                AT91_SPI_PCSDEC         (1    <<  2)            /* Chip Select Decode */
-#define                AT91_SPI_DIV32          (1    <<  3)            /* Clock Selection */
+#define                AT91_SPI_DIV32          (1    <<  3)            /* Clock Selection [AT91RM9200 only] */
 #define                AT91_SPI_MODFDIS        (1    <<  4)            /* Mode Fault Detection */
 #define                AT91_SPI_LLB            (1    <<  7)            /* Local Loopback Enable */
 #define                AT91_SPI_PCS            (0xf  << 16)            /* Peripheral Chip Select */
similarity index 86%
rename from include/asm-arm/arch-at91rm9200/at91rm9200_ssc.h
rename to include/asm-arm/arch-at91rm9200/at91_ssc.h
index ac880227147f7ea447dae0f7ed1e56b13bc0d49a..694bcaa8f7c2016ef2e2b1429bd4f8453d1d974c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * include/asm-arm/arch-at91rm9200/at91rm9200_ssc.h
+ * include/asm-arm/arch-at91rm9200/at91_ssc.h
  *
  * Copyright (C) SAN People
  *
@@ -12,8 +12,8 @@
  * (at your option) any later version.
  */
 
-#ifndef AT91RM9200_SSC_H
-#define AT91RM9200_SSC_H
+#ifndef AT91_SSC_H
+#define AT91_SSC_H
 
 #define AT91_SSC_CR            0x00    /* Control Register */
 #define                AT91_SSC_RXEN           (1 <<  0)       /* Receive Enable */
 #define                AT91_SSC_CKI            (1    <<  5)    /* Clock Inversion */
 #define                        AT91_SSC_CKI_FALLING            (0 << 5)
 #define                        AT91_SSC_CK_RISING              (1 << 5)
+#define                AT91_SSC_CKG            (1    <<  6)    /* Receive Clock Gating Selection [AT91SAM9261 only] */
+#define                        AT91_SSC_CKG_NONE               (0 << 6)
+#define                        AT91_SSC_CKG_RFLOW              (1 << 6)
+#define                        AT91_SSC_CKG_RFHIGH             (2 << 6)
 #define                AT91_SSC_START          (0xf  <<  8)    /* Start Selection */
 #define                        AT91_SSC_START_CONTINUOUS       (0 << 8)
 #define                        AT91_SSC_START_TX_RX            (1 << 8)
@@ -45,6 +49,7 @@
 #define                        AT91_SSC_START_RISING_RF        (5 << 8)
 #define                        AT91_SSC_START_LEVEL_RF         (6 << 8)
 #define                        AT91_SSC_START_EDGE_RF          (7 << 8)
+#define                AT91_SSC_STOP           (1    << 12)    /* Receive Stop Selection [AT91SAM9261 only] */
 #define                AT91_SSC_STTDLY         (0xff << 16)    /* Start Delay */
 #define                AT91_SSC_PERIOD         (0xff << 24)    /* Period Divider Selection */
 
@@ -75,6 +80,9 @@
 #define AT91_SSC_RSHR          0x30    /* Receive Sync Holding Register */
 #define AT91_SSC_TSHR          0x34    /* Transmit Sync Holding Register */
 
+#define AT91_SSC_RC0R          0x38    /* Receive Compare 0 Register [AT91SAM9261 only] */
+#define AT91_SSC_RC1R          0x3c    /* Receive Compare 1 Register [AT91SAM9261 only] */
+
 #define AT91_SSC_SR            0x40    /* Status Register */
 #define                AT91_SSC_TXRDY          (1 <<  0)       /* Transmit Ready */
 #define                AT91_SSC_TXEMPTY        (1 <<  1)       /* Transmit Empty */
@@ -84,6 +92,8 @@
 #define                AT91_SSC_OVRUN          (1 <<  5)       /* Receive Overrun */
 #define                AT91_SSC_ENDRX          (1 <<  6)       /* End of Reception */
 #define                AT91_SSC_RXBUFF         (1 <<  7)       /* Receive Buffer Full */
+#define                AT91_SSC_CP0            (1 <<  8)       /* Compare 0 [AT91SAM9261 only] */
+#define                AT91_SSC_CP1            (1 <<  9)       /* Compare 1 [AT91SAM9261 only] */
 #define                AT91_SSC_TXSYN          (1 << 10)       /* Transmit Sync */
 #define                AT91_SSC_RXSYN          (1 << 11)       /* Receive Sync */
 #define                AT91_SSC_TXENA          (1 << 16)       /* Transmit Enable */
diff --git a/include/asm-arm/arch-at91rm9200/at91_st.h b/include/asm-arm/arch-at91rm9200/at91_st.h
new file mode 100644 (file)
index 0000000..2432ddf
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91_st.h
+ *
+ * Copyright (C) 2005 Ivan Kokshaysky
+ * Copyright (C) SAN People
+ *
+ * System Timer (ST) - System peripherals registers.
+ * Based on AT91RM9200 datasheet revision E.
+ *
+ * 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.
+ */
+
+#ifndef AT91_ST_H
+#define AT91_ST_H
+
+#define        AT91_ST_CR              (AT91_ST + 0x00)        /* Control Register */
+#define        AT91_ST_WDRST           (1 << 0)                /* Watchdog Timer Restart */
+
+#define        AT91_ST_PIMR            (AT91_ST + 0x04)        /* Period Interval Mode Register */
+#define                AT91_ST_PIV             (0xffff <<  0)          /* Period Interval Value */
+
+#define        AT91_ST_WDMR            (AT91_ST + 0x08)        /* Watchdog Mode Register */
+#define                AT91_ST_WDV             (0xffff <<  0)          /* Watchdog Counter Value */
+#define                AT91_ST_RSTEN           (1      << 16)          /* Reset Enable */
+#define                AT91_ST_EXTEN           (1      << 17)          /* External Signal Assertion Enable */
+
+#define        AT91_ST_RTMR            (AT91_ST + 0x0c)        /* Real-time Mode Register */
+#define                AT91_ST_RTPRES          (0xffff <<  0)          /* Real-time Prescalar Value */
+
+#define        AT91_ST_SR              (AT91_ST + 0x10)        /* Status Register */
+#define                AT91_ST_PITS            (1 << 0)                /* Period Interval Timer Status */
+#define                AT91_ST_WDOVF           (1 << 1)                /* Watchdog Overflow */
+#define                AT91_ST_RTTINC          (1 << 2)                /* Real-time Timer Increment */
+#define                AT91_ST_ALMS            (1 << 3)                /* Alarm Status */
+
+#define        AT91_ST_IER             (AT91_ST + 0x14)        /* Interrupt Enable Register */
+#define        AT91_ST_IDR             (AT91_ST + 0x18)        /* Interrupt Disable Register */
+#define        AT91_ST_IMR             (AT91_ST + 0x1c)        /* Interrupt Mask Register */
+
+#define        AT91_ST_RTAR            (AT91_ST + 0x20)        /* Real-time Alarm Register */
+#define                AT91_ST_ALMV            (0xfffff << 0)          /* Alarm Value */
+
+#define        AT91_ST_CRTR            (AT91_ST + 0x24)        /* Current Real-time Register */
+#define                AT91_ST_CRTV            (0xfffff << 0)          /* Current Real-Time Value */
+
+#endif
similarity index 98%
rename from include/asm-arm/arch-at91rm9200/at91rm9200_tc.h
rename to include/asm-arm/arch-at91rm9200/at91_tc.h
index f4da752bb0c8004b88e5474a8f4b77480c255511..8d06eb078e1d1624e5faf737622530ea8de3ba70 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * include/asm-arm/arch-at91rm9200/at91rm9200_tc.h
+ * include/asm-arm/arch-at91rm9200/at91_tc.h
  *
  * Copyright (C) SAN People
  *
@@ -12,8 +12,8 @@
  * (at your option) any later version.
  */
 
-#ifndef AT91RM9200_TC_H
-#define AT91RM9200_TC_H
+#ifndef AT91_TC_H
+#define AT91_TC_H
 
 #define AT91_TC_BCR            0xc0            /* TC Block Control Register */
 #define                AT91_TC_SYNC            (1 << 0)        /* Synchro Command */
similarity index 90%
rename from include/asm-arm/arch-at91rm9200/at91rm9200_twi.h
rename to include/asm-arm/arch-at91rm9200/at91_twi.h
index 93547d7482bd3200b8832dee86210fbcec9c07ff..cda914f1e7402501482a090a1d88e29a01e3ceb0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * include/asm-arm/arch-at91rm9200/at91rm9200_twi.h
+ * include/asm-arm/arch-at91rm9200/at91_twi.h
  *
  * Copyright (C) 2005 Ivan Kokshaysky
  * Copyright (C) SAN People
@@ -13,8 +13,8 @@
  * (at your option) any later version.
  */
 
-#ifndef AT91RM9200_TWI_H
-#define AT91RM9200_TWI_H
+#ifndef AT91_TWI_H
+#define AT91_TWI_H
 
 #define        AT91_TWI_CR             0x00            /* Control Register */
 #define                AT91_TWI_START          (1 <<  0)       /* Send a Start Condition */
@@ -43,8 +43,8 @@
 #define                AT91_TWI_TXCOMP         (1 <<  0)       /* Transmission Complete */
 #define                AT91_TWI_RXRDY          (1 <<  1)       /* Receive Holding Register Ready */
 #define                AT91_TWI_TXRDY          (1 <<  2)       /* Transmit Holding Register Ready */
-#define                AT91_TWI_OVRE           (1 <<  6)       /* Overrun Error */
-#define                AT91_TWI_UNRE           (1 <<  7)       /* Underrun Error */
+#define                AT91_TWI_OVRE           (1 <<  6)       /* Overrun Error [AT91RM9200 only] */
+#define                AT91_TWI_UNRE           (1 <<  7)       /* Underrun Error [AT91RM9200 only] */
 #define                AT91_TWI_NACK           (1 <<  8)       /* Not Acknowledged */
 
 #define        AT91_TWI_IER            0x24            /* Interrupt Enable Register */
diff --git a/include/asm-arm/arch-at91rm9200/at91_wdt.h b/include/asm-arm/arch-at91rm9200/at91_wdt.h
new file mode 100644 (file)
index 0000000..ac63e77
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91_wdt.h
+ *
+ * Watchdog Timer (WDT) - System peripherals regsters.
+ * Based on AT91SAM9261 datasheet revision D.
+ *
+ * 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.
+ */
+
+#ifndef AT91_WDT_H
+#define AT91_WDT_H
+
+#define AT91_WDT_CR            (AT91_WDT + 0x00)       /* Watchdog Control Register */
+#define                AT91_WDT_WDRSTT         (1    << 0)             /* Restart */
+#define                AT91_WDT_KEY            (0xff << 24)            /* KEY Password */
+
+#define AT91_WDT_MR            (AT91_WDT + 0x04)       /* Watchdog Mode Register */
+#define                AT91_WDT_WDV            (0xfff << 0)            /* Counter Value */
+#define                AT91_WDT_WDFIEN         (1     << 12)           /* Fault Interrupt Enable */
+#define                AT91_WDT_WDRSTEN        (1     << 13)           /* Reset Processor */
+#define                AT91_WDT_WDRPROC        (1     << 14)           /* Timer Restart */
+#define                AT91_WDT_WDDIS          (1     << 15)           /* Watchdog Disable */
+#define                AT91_WDT_WDD            (0xfff << 16)           /* Delta Value */
+#define                AT91_WDT_WDDBGHLT       (1     << 28)           /* Debug Halt */
+#define                AT91_WDT_WDIDLEHLT      (1     << 29)           /* Idle Halt */
+
+#define AT91_WDT_SR            (AT91_WDT + 0x08)       /* Watchdog Status Register */
+#define                AT91_WDT_WDUNF          (1 << 0)                /* Watchdog Underflow */
+#define                AT91_WDT_WDERR          (1 << 1)                /* Watchdog Error */
+
+#endif
index a5a86b1ff886d73aac3bbccb0a3a9e849cbba52e..4d51177efddde3cd1c372b39009b07f6d8f5db1f 100644 (file)
 #define AT91_BASE_SYS          0xfffff000
 
 
+/*
+ * System Peripherals (offset from AT91_BASE_SYS)
+ */
+#define AT91_AIC       (0xfffff000 - AT91_BASE_SYS)    /* Advanced Interrupt Controller */
+#define AT91_DBGU      (0xfffff200 - AT91_BASE_SYS)    /* Debug Unit */
+#define AT91_PIOA      (0xfffff400 - AT91_BASE_SYS)    /* PIO Controller A */
+#define AT91_PIOB      (0xfffff600 - AT91_BASE_SYS)    /* PIO Controller B */
+#define AT91_PIOC      (0xfffff800 - AT91_BASE_SYS)    /* PIO Controller C */
+#define AT91_PIOD      (0xfffffa00 - AT91_BASE_SYS)    /* PIO Controller D */
+#define AT91_PMC       (0xfffffc00 - AT91_BASE_SYS)    /* Power Management Controller */
+#define AT91_ST                (0xfffffd00 - AT91_BASE_SYS)    /* System Timer */
+#define AT91_RTC       (0xfffffe00 - AT91_BASE_SYS)    /* Real-Time Clock */
+#define AT91_MC                (0xffffff00 - AT91_BASE_SYS)    /* Memory Controllers */
+
+#define AT91_MATRIX    0       /* not supported */
+
 /*
  * Internal Memory.
  */
diff --git a/include/asm-arm/arch-at91rm9200/at91rm9200_mc.h b/include/asm-arm/arch-at91rm9200/at91rm9200_mc.h
new file mode 100644 (file)
index 0000000..0c0d814
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91rm9200_mc.h
+ *
+ * Copyright (C) 2005 Ivan Kokshaysky
+ * Copyright (C) SAN People
+ *
+ * Memory Controllers (MC, EBI, SMC, SDRAMC, BFC) - System peripherals registers.
+ * Based on AT91RM9200 datasheet revision E.
+ *
+ * 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.
+ */
+
+#ifndef AT91RM9200_MC_H
+#define AT91RM9200_MC_H
+
+/* Memory Controller */
+#define AT91_MC_RCR            (AT91_MC + 0x00)        /* MC Remap Control Register */
+#define                AT91_MC_RCB             (1 <<  0)               /* Remap Command Bit */
+
+#define AT91_MC_ASR            (AT91_MC + 0x04)        /* MC Abort Status Register */
+#define                AT91_MC_UNADD           (1 <<  0)               /* Undefined Address Abort Status */
+#define                AT91_MC_MISADD          (1 <<  1)               /* Misaligned Address Abort Status */
+#define                AT91_MC_ABTSZ           (3 <<  8)               /* Abort Size Status */
+#define                        AT91_MC_ABTSZ_BYTE              (0 << 8)
+#define                        AT91_MC_ABTSZ_HALFWORD          (1 << 8)
+#define                        AT91_MC_ABTSZ_WORD              (2 << 8)
+#define                AT91_MC_ABTTYP          (3 << 10)               /* Abort Type Status */
+#define                        AT91_MC_ABTTYP_DATAREAD         (0 << 10)
+#define                        AT91_MC_ABTTYP_DATAWRITE        (1 << 10)
+#define                        AT91_MC_ABTTYP_FETCH            (2 << 10)
+#define                AT91_MC_MST0            (1 << 16)               /* ARM920T Abort Source */
+#define                AT91_MC_MST1            (1 << 17)               /* PDC Abort Source */
+#define                AT91_MC_MST2            (1 << 18)               /* UHP Abort Source */
+#define                AT91_MC_MST3            (1 << 19)               /* EMAC Abort Source */
+#define                AT91_MC_SVMST0          (1 << 24)               /* Saved ARM920T Abort Source */
+#define                AT91_MC_SVMST1          (1 << 25)               /* Saved PDC Abort Source */
+#define                AT91_MC_SVMST2          (1 << 26)               /* Saved UHP Abort Source */
+#define                AT91_MC_SVMST3          (1 << 27)               /* Saved EMAC Abort Source */
+
+#define AT91_MC_AASR           (AT91_MC + 0x08)        /* MC Abort Address Status Register */
+
+#define AT91_MC_MPR            (AT91_MC + 0x0c)        /* MC Master Priority Register */
+#define                AT91_MPR_MSTP0          (7 <<  0)               /* ARM920T Priority */
+#define                AT91_MPR_MSTP1          (7 <<  4)               /* PDC Priority */
+#define                AT91_MPR_MSTP2          (7 <<  8)               /* UHP Priority */
+#define                AT91_MPR_MSTP3          (7 << 12)               /* EMAC Priority */
+
+/* External Bus Interface (EBI) registers */
+#define AT91_EBI_CSA           (AT91_MC + 0x60)        /* Chip Select Assignment Register */
+#define                AT91_EBI_CS0A           (1 << 0)                /* Chip Select 0 Assignment */
+#define                        AT91_EBI_CS0A_SMC               (0 << 0)
+#define                        AT91_EBI_CS0A_BFC               (1 << 0)
+#define                AT91_EBI_CS1A           (1 << 1)                /* Chip Select 1 Assignment */
+#define                        AT91_EBI_CS1A_SMC               (0 << 1)
+#define                        AT91_EBI_CS1A_SDRAMC            (1 << 1)
+#define                AT91_EBI_CS3A           (1 << 3)                /* Chip Select 2 Assignment */
+#define                        AT91_EBI_CS3A_SMC               (0 << 3)
+#define                        AT91_EBI_CS3A_SMC_SMARTMEDIA    (1 << 3)
+#define                AT91_EBI_CS4A           (1 << 4)                /* Chip Select 3 Assignment */
+#define                        AT91_EBI_CS4A_SMC               (0 << 4)
+#define                        AT91_EBI_CS4A_SMC_COMPACTFLASH  (1 << 4)
+#define AT91_EBI_CFGR          (AT91_MC + 0x64)        /* Configuration Register */
+#define                AT91_EBI_DBPUC          (1 << 0)                /* Data Bus Pull-Up Configuration */
+
+/* Static Memory Controller (SMC) registers */
+#define        AT91_SMC_CSR(n)         (AT91_MC + 0x70 + ((n) * 4))/* SMC Chip Select Register */
+#define                AT91_SMC_NWS            (0x7f <<  0)            /* Number of Wait States */
+#define                        AT91_SMC_NWS_(x)        ((x) << 0)
+#define                AT91_SMC_WSEN           (1    <<  7)            /* Wait State Enable */
+#define                AT91_SMC_TDF            (0xf  <<  8)            /* Data Float Time */
+#define                        AT91_SMC_TDF_(x)        ((x) << 8)
+#define                AT91_SMC_BAT            (1    << 12)            /* Byte Access Type */
+#define                AT91_SMC_DBW            (3    << 13)            /* Data Bus Width */
+#define                        AT91_SMC_DBW_16         (1 << 13)
+#define                        AT91_SMC_DBW_8          (2 << 13)
+#define                AT91_SMC_DPR            (1 << 15)               /* Data Read Protocol */
+#define                AT91_SMC_ACSS           (3 << 16)               /* Address to Chip Select Setup */
+#define                        AT91_SMC_ACSS_STD       (0 << 16)
+#define                        AT91_SMC_ACSS_1         (1 << 16)
+#define                        AT91_SMC_ACSS_2         (2 << 16)
+#define                        AT91_SMC_ACSS_3         (3 << 16)
+#define                AT91_SMC_RWSETUP        (7 << 24)               /* Read & Write Signal Time Setup */
+#define                        AT91_SMC_RWSETUP_(x)    ((x) << 24)
+#define                AT91_SMC_RWHOLD         (7 << 28)               /* Read & Write Signal Hold Time */
+#define                        AT91_SMC_RWHOLD_(x)     ((x) << 28)
+
+/* SDRAM Controller registers */
+#define AT91_SDRAMC_MR         (AT91_MC + 0x90)        /* Mode Register */
+#define                AT91_SDRAMC_MODE        (0xf << 0)              /* Command Mode */
+#define                        AT91_SDRAMC_MODE_NORMAL         (0 << 0)
+#define                        AT91_SDRAMC_MODE_NOP            (1 << 0)
+#define                        AT91_SDRAMC_MODE_PRECHARGE      (2 << 0)
+#define                        AT91_SDRAMC_MODE_LMR            (3 << 0)
+#define                        AT91_SDRAMC_MODE_REFRESH        (4 << 0)
+#define                AT91_SDRAMC_DBW         (1   << 4)              /* Data Bus Width */
+#define                        AT91_SDRAMC_DBW_32      (0 << 4)
+#define                        AT91_SDRAMC_DBW_16      (1 << 4)
+
+#define AT91_SDRAMC_TR         (AT91_MC + 0x94)        /* Refresh Timer Register */
+#define                AT91_SDRAMC_COUNT       (0xfff << 0)            /* Refresh Timer Count */
+
+#define AT91_SDRAMC_CR         (AT91_MC + 0x98)        /* Configuration Register */
+#define                AT91_SDRAMC_NC          (3   <<  0)             /* Number of Column Bits */
+#define                        AT91_SDRAMC_NC_8        (0 << 0)
+#define                        AT91_SDRAMC_NC_9        (1 << 0)
+#define                        AT91_SDRAMC_NC_10       (2 << 0)
+#define                        AT91_SDRAMC_NC_11       (3 << 0)
+#define                AT91_SDRAMC_NR          (3   <<  2)             /* Number of Row Bits */
+#define                        AT91_SDRAMC_NR_11       (0 << 2)
+#define                        AT91_SDRAMC_NR_12       (1 << 2)
+#define                        AT91_SDRAMC_NR_13       (2 << 2)
+#define                AT91_SDRAMC_NB          (1   <<  4)             /* Number of Banks */
+#define                        AT91_SDRAMC_NB_2        (0 << 4)
+#define                        AT91_SDRAMC_NB_4        (1 << 4)
+#define                AT91_SDRAMC_CAS         (3   <<  5)             /* CAS Latency */
+#define                        AT91_SDRAMC_CAS_2       (2 << 5)
+#define                AT91_SDRAMC_TWR         (0xf <<  7)             /* Write Recovery Delay */
+#define                AT91_SDRAMC_TRC         (0xf << 11)             /* Row Cycle Delay */
+#define                AT91_SDRAMC_TRP         (0xf << 15)             /* Row Precharge Delay */
+#define                AT91_SDRAMC_TRCD        (0xf << 19)             /* Row to Column Delay */
+#define                AT91_SDRAMC_TRAS        (0xf << 23)             /* Active to Precharge Delay */
+#define                AT91_SDRAMC_TXSR        (0xf << 27)             /* Exit Self Refresh to Active Delay */
+
+#define AT91_SDRAMC_SRR                (AT91_MC + 0x9c)        /* Self Refresh Register */
+#define AT91_SDRAMC_LPR                (AT91_MC + 0xa0)        /* Low Power Register */
+#define AT91_SDRAMC_IER                (AT91_MC + 0xa4)        /* Interrupt Enable Register */
+#define AT91_SDRAMC_IDR                (AT91_MC + 0xa8)        /* Interrupt Disable Register */
+#define AT91_SDRAMC_IMR                (AT91_MC + 0xac)        /* Interrupt Mask Register */
+#define AT91_SDRAMC_ISR                (AT91_MC + 0xb0)        /* Interrupt Status Register */
+
+/* Burst Flash Controller register */
+#define AT91_BFC_MR            (AT91_MC + 0xc0)        /* Mode Register */
+#define                AT91_BFC_BFCOM          (3   <<  0)             /* Burst Flash Controller Operating Mode */
+#define                        AT91_BFC_BFCOM_DISABLED (0 << 0)
+#define                        AT91_BFC_BFCOM_ASYNC    (1 << 0)
+#define                        AT91_BFC_BFCOM_BURST    (2 << 0)
+#define                AT91_BFC_BFCC           (3   <<  2)             /* Burst Flash Controller Clock */
+#define                        AT91_BFC_BFCC_MCK       (1 << 2)
+#define                        AT91_BFC_BFCC_DIV2      (2 << 2)
+#define                        AT91_BFC_BFCC_DIV4      (3 << 2)
+#define                AT91_BFC_AVL            (0xf <<  4)             /* Address Valid Latency */
+#define                AT91_BFC_PAGES          (7   <<  8)             /* Page Size */
+#define                        AT91_BFC_PAGES_NO_PAGE  (0 << 8)
+#define                        AT91_BFC_PAGES_16       (1 << 8)
+#define                        AT91_BFC_PAGES_32       (2 << 8)
+#define                        AT91_BFC_PAGES_64       (3 << 8)
+#define                        AT91_BFC_PAGES_128      (4 << 8)
+#define                        AT91_BFC_PAGES_256      (5 << 8)
+#define                        AT91_BFC_PAGES_512      (6 << 8)
+#define                        AT91_BFC_PAGES_1024     (7 << 8)
+#define                AT91_BFC_OEL            (3   << 12)             /* Output Enable Latency */
+#define                AT91_BFC_BAAEN          (1   << 16)             /* Burst Address Advance Enable */
+#define                AT91_BFC_BFOEH          (1   << 17)             /* Burst Flash Output Enable Handling */
+#define                AT91_BFC_MUXEN          (1   << 18)             /* Multiplexed Bus Enable */
+#define                AT91_BFC_RDYEN          (1   << 19)             /* Ready Enable Mode */
+
+#endif
diff --git a/include/asm-arm/arch-at91rm9200/at91rm9200_sys.h b/include/asm-arm/arch-at91rm9200/at91rm9200_sys.h
deleted file mode 100644 (file)
index 73693fe..0000000
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
- * include/asm-arm/arch-at91rm9200/at91rm9200_sys.h
- *
- * Copyright (C) 2005 Ivan Kokshaysky
- * Copyright (C) SAN People
- *
- * System peripherals registers.
- * Based on AT91RM9200 datasheet revision E.
- *
- * 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.
- */
-
-#ifndef AT91RM9200_SYS_H
-#define AT91RM9200_SYS_H
-
-/*
- * Advanced Interrupt Controller.
- */
-#define AT91_AIC       0x000
-
-#define AT91_AIC_SMR(n)                (AT91_AIC + ((n) * 4))  /* Source Mode Registers 0-31 */
-#define                AT91_AIC_PRIOR          (7 << 0)                /* Priority Level */
-#define                AT91_AIC_SRCTYPE        (3 << 5)                /* Interrupt Source Type */
-#define                        AT91_AIC_SRCTYPE_LOW            (0 << 5)
-#define                        AT91_AIC_SRCTYPE_FALLING        (1 << 5)
-#define                        AT91_AIC_SRCTYPE_HIGH           (2 << 5)
-#define                        AT91_AIC_SRCTYPE_RISING         (3 << 5)
-
-#define AT91_AIC_SVR(n)                (AT91_AIC + 0x80 + ((n) * 4))   /* Source Vector Registers 0-31 */
-#define AT91_AIC_IVR           (AT91_AIC + 0x100)      /* Interrupt Vector Register */
-#define AT91_AIC_FVR           (AT91_AIC + 0x104)      /* Fast Interrupt Vector Register */
-#define AT91_AIC_ISR           (AT91_AIC + 0x108)      /* Interrupt Status Register */
-#define                AT91_AIC_IRQID          (0x1f << 0)             /* Current Interrupt Identifier */
-
-#define AT91_AIC_IPR           (AT91_AIC + 0x10c)      /* Interrupt Pending Register */
-#define AT91_AIC_IMR           (AT91_AIC + 0x110)      /* Interrupt Mask Register */
-#define AT91_AIC_CISR          (AT91_AIC + 0x114)      /* Core Interrupt Status Register */
-#define                AT91_AIC_NFIQ           (1 << 0)                /* nFIQ Status */
-#define                AT91_AIC_NIRQ           (1 << 1)                /* nIRQ Status */
-
-#define AT91_AIC_IECR          (AT91_AIC + 0x120)      /* Interrupt Enable Command Register */
-#define AT91_AIC_IDCR          (AT91_AIC + 0x124)      /* Interrupt Disable Command Register */
-#define AT91_AIC_ICCR          (AT91_AIC + 0x128)      /* Interrupt Clear Command Register */
-#define AT91_AIC_ISCR          (AT91_AIC + 0x12c)      /* Interrupt Set Command Register */
-#define AT91_AIC_EOICR         (AT91_AIC + 0x130)      /* End of Interrupt Command Register */
-#define AT91_AIC_SPU           (AT91_AIC + 0x134)      /* Spurious Interrupt Vector Register */
-#define AT91_AIC_DCR           (AT91_AIC + 0x138)      /* Debug Control Register */
-#define                AT91_AIC_DCR_PROT       (1 << 0)                /* Protection Mode */
-#define                AT91_AIC_DCR_GMSK       (1 << 1)                /* General Mask */
-
-
-/*
- * Debug Unit.
- */
-#define AT91_DBGU      0x200
-
-#define AT91_DBGU_CR           (AT91_DBGU + 0x00)      /* Control Register */
-#define AT91_DBGU_MR           (AT91_DBGU + 0x04)      /* Mode Register */
-#define AT91_DBGU_IER          (AT91_DBGU + 0x08)      /* Interrupt Enable Register */
-#define                AT91_DBGU_TXRDY         (1 << 1)                /* Transmitter Ready */
-#define                AT91_DBGU_TXEMPTY       (1 << 9)                /* Transmitter Empty */
-#define AT91_DBGU_IDR          (AT91_DBGU + 0x0c)      /* Interrupt Disable Register */
-#define AT91_DBGU_IMR          (AT91_DBGU + 0x10)      /* Interrupt Mask Register */
-#define AT91_DBGU_SR           (AT91_DBGU + 0x14)      /* Status Register */
-#define AT91_DBGU_RHR          (AT91_DBGU + 0x18)      /* Receiver Holding Register */
-#define AT91_DBGU_THR          (AT91_DBGU + 0x1c)      /* Transmitter Holding Register */
-#define AT91_DBGU_BRGR         (AT91_DBGU + 0x20)      /* Baud Rate Generator Register */
-
-#define AT91_DBGU_CIDR         (AT91_DBGU + 0x40)      /* Chip ID Register */
-#define AT91_DBGU_EXID         (AT91_DBGU + 0x44)      /* Chip ID Extension Register */
-#define                AT91_CIDR_VERSION       (0x1f << 0)             /* Version of the Device */
-#define                AT91_CIDR_EPROC         (7    << 5)             /* Embedded Processor */
-#define                AT91_CIDR_NVPSIZ        (0xf  << 8)             /* Nonvolatile Program Memory Size */
-#define                AT91_CIDR_NVPSIZ2       (0xf  << 12)            /* Second Nonvolatile Program Memory Size */
-#define                AT91_CIDR_SRAMSIZ       (0xf  << 16)            /* Internal SRAM Size */
-#define                AT91_CIDR_ARCH          (0xff << 20)            /* Architecture Identifier */
-#define                AT91_CIDR_NVPTYP        (7    << 28)            /* Nonvolatile Program Memory Type */
-#define                AT91_CIDR_EXT           (1    << 31)            /* Extension Flag */
-
-#define AT91_AIC_FFER          (AT91_AIC + 0x140)      /* Fast Forcing Enable Register [SAM9 only] */
-#define AT91_AIC_FFDR          (AT91_AIC + 0x144)      /* Fast Forcing Disable Register [SAM9 only] */
-#define AT91_AIC_FFSR          (AT91_AIC + 0x148)      /* Fast Forcing Status Register [SAM9 only] */
-
-/*
- * PIO Controllers.
- */
-#define AT91_PIOA      0x400
-#define AT91_PIOB      0x600
-#define AT91_PIOC      0x800
-#define AT91_PIOD      0xa00
-
-#define PIO_PER                0x00    /* Enable Register */
-#define PIO_PDR                0x04    /* Disable Register */
-#define PIO_PSR                0x08    /* Status Register */
-#define PIO_OER                0x10    /* Output Enable Register */
-#define PIO_ODR                0x14    /* Output Disable Register */
-#define PIO_OSR                0x18    /* Output Status Register */
-#define PIO_IFER       0x20    /* Glitch Input Filter Enable */
-#define PIO_IFDR       0x24    /* Glitch Input Filter Disable */
-#define PIO_IFSR       0x28    /* Glitch Input Filter Status */
-#define PIO_SODR       0x30    /* Set Output Data Register */
-#define PIO_CODR       0x34    /* Clear Output Data Register */
-#define PIO_ODSR       0x38    /* Output Data Status Register */
-#define PIO_PDSR       0x3c    /* Pin Data Status Register */
-#define PIO_IER                0x40    /* Interrupt Enable Register */
-#define PIO_IDR                0x44    /* Interrupt Disable Register */
-#define PIO_IMR                0x48    /* Interrupt Mask Register */
-#define PIO_ISR                0x4c    /* Interrupt Status Register */
-#define PIO_MDER       0x50    /* Multi-driver Enable Register */
-#define PIO_MDDR       0x54    /* Multi-driver Disable Register */
-#define PIO_MDSR       0x58    /* Multi-driver Status Register */
-#define PIO_PUDR       0x60    /* Pull-up Disable Register */
-#define PIO_PUER       0x64    /* Pull-up Enable Register */
-#define PIO_PUSR       0x68    /* Pull-up Status Register */
-#define PIO_ASR                0x70    /* Peripheral A Select Register */
-#define PIO_BSR                0x74    /* Peripheral B Select Register */
-#define PIO_ABSR       0x78    /* AB Status Register */
-#define PIO_OWER       0xa0    /* Output Write Enable Register */
-#define PIO_OWDR       0xa4    /* Output Write Disable Register */
-#define PIO_OWSR       0xa8    /* Output Write Status Register */
-
-#define AT91_PIO_P(n)  (1 << (n))
-
-
-/*
- * Power Management Controller.
- */
-#define        AT91_PMC        0xc00
-
-#define        AT91_PMC_SCER           (AT91_PMC + 0x00)       /* System Clock Enable Register */
-#define        AT91_PMC_SCDR           (AT91_PMC + 0x04)       /* System Clock Disable Register */
-
-#define        AT91_PMC_SCSR           (AT91_PMC + 0x08)       /* System Clock Status Register */
-#define                AT91_PMC_PCK            (1 <<  0)               /* Processor Clock */
-#define                AT91_PMC_UDP            (1 <<  1)               /* USB Devcice Port Clock */
-#define                AT91_PMC_MCKUDP         (1 <<  2)               /* USB Device Port Master Clock Automatic Disable on Suspend */
-#define                AT91_PMC_UHP            (1 <<  4)               /* USB Host Port Clock */
-#define                AT91_PMC_PCK0           (1 <<  8)               /* Programmable Clock 0 */
-#define                AT91_PMC_PCK1           (1 <<  9)               /* Programmable Clock 1 */
-#define                AT91_PMC_PCK2           (1 << 10)               /* Programmable Clock 2 */
-#define                AT91_PMC_PCK3           (1 << 11)               /* Programmable Clock 3 */
-
-#define        AT91_PMC_PCER           (AT91_PMC + 0x10)       /* Peripheral Clock Enable Register */
-#define        AT91_PMC_PCDR           (AT91_PMC + 0x14)       /* Peripheral Clock Disable Register */
-#define        AT91_PMC_PCSR           (AT91_PMC + 0x18)       /* Peripheral Clock Status Register */
-
-#define        AT91_CKGR_MOR           (AT91_PMC + 0x20)       /* Main Oscillator Register */
-#define                AT91_PMC_MOSCEN         (1    << 0)             /* Main Oscillator Enable */
-#define                AT91_PMC_OSCOUNT        (0xff << 8)             /* Main Oscillator Start-up Time */
-
-#define        AT91_CKGR_MCFR          (AT91_PMC + 0x24)       /* Main Clock Frequency Register */
-#define                AT91_PMC_MAINF          (0xffff <<  0)          /* Main Clock Frequency */
-#define                AT91_PMC_MAINRDY        (1      << 16)          /* Main Clock Ready */
-
-#define        AT91_CKGR_PLLAR         (AT91_PMC + 0x28)       /* PLL A Register */
-#define        AT91_CKGR_PLLBR         (AT91_PMC + 0x2c)       /* PLL B Register */
-#define                AT91_PMC_DIV            (0xff  <<  0)           /* Divider */
-#define                AT91_PMC_PLLCOUNT       (0x3f  <<  8)           /* PLL Counter */
-#define                AT91_PMC_OUT            (3     << 14)           /* PLL Clock Frequency Range */
-#define                AT91_PMC_MUL            (0x7ff << 16)           /* PLL Multiplier */
-#define                AT91_PMC_USB96M         (1     << 28)           /* Divider by 2 Enable (PLLB only) */
-
-#define        AT91_PMC_MCKR           (AT91_PMC + 0x30)       /* Master Clock Register */
-#define                AT91_PMC_CSS            (3 <<  0)               /* Master Clock Selection */
-#define                        AT91_PMC_CSS_SLOW               (0 << 0)
-#define                        AT91_PMC_CSS_MAIN               (1 << 0)
-#define                        AT91_PMC_CSS_PLLA               (2 << 0)
-#define                        AT91_PMC_CSS_PLLB               (3 << 0)
-#define                AT91_PMC_PRES           (7 <<  2)               /* Master Clock Prescaler */
-#define                AT91_PMC_PRES_1                 (0 << 2)
-#define                        AT91_PMC_PRES_2                 (1 << 2)
-#define                        AT91_PMC_PRES_4                 (2 << 2)
-#define                        AT91_PMC_PRES_8                 (3 << 2)
-#define                        AT91_PMC_PRES_16                (4 << 2)
-#define                        AT91_PMC_PRES_32                (5 << 2)
-#define                        AT91_PMC_PRES_64                (6 << 2)
-#define                AT91_PMC_MDIV           (3 <<  8)               /* Master Clock Division */
-#define                        AT91_PMC_MDIV_1                 (0 << 8)
-#define                        AT91_PMC_MDIV_2                 (1 << 8)
-#define                        AT91_PMC_MDIV_3                 (2 << 8)
-#define                        AT91_PMC_MDIV_4                 (3 << 8)
-
-#define        AT91_PMC_PCKR(n)        (AT91_PMC + 0x40 + ((n) * 4))   /* Programmable Clock 0-3 Registers */
-
-#define        AT91_PMC_IER            (AT91_PMC + 0x60)       /* Interrupt Enable Register */
-#define        AT91_PMC_IDR            (AT91_PMC + 0x64)       /* Interrupt Disable Register */
-#define        AT91_PMC_SR             (AT91_PMC + 0x68)       /* Status Register */
-#define                AT91_PMC_MOSCS          (1 <<  0)               /* MOSCS Flag */
-#define                AT91_PMC_LOCKA          (1 <<  1)               /* PLLA Lock */
-#define                AT91_PMC_LOCKB          (1 <<  2)               /* PLLB Lock */
-#define                AT91_PMC_MCKRDY         (1 <<  3)               /* Master Clock */
-#define                AT91_PMC_PCK0RDY        (1 <<  8)               /* Programmable Clock 0 */
-#define                AT91_PMC_PCK1RDY        (1 <<  9)               /* Programmable Clock 1 */
-#define                AT91_PMC_PCK2RDY        (1 << 10)               /* Programmable Clock 2 */
-#define                AT91_PMC_PCK3RDY        (1 << 11)               /* Programmable Clock 3 */
-#define        AT91_PMC_IMR            (AT91_PMC + 0x6c)       /* Interrupt Mask Register */
-
-
-/*
- * System Timer.
- */
-#define        AT91_ST         0xd00
-
-#define        AT91_ST_CR              (AT91_ST + 0x00)        /* Control Register */
-#define        AT91_ST_WDRST           (1 << 0)                /* Watchdog Timer Restart */
-#define        AT91_ST_PIMR            (AT91_ST + 0x04)        /* Period Interval Mode Register */
-#define                AT91_ST_PIV             (0xffff <<  0)          /* Period Interval Value */
-#define        AT91_ST_WDMR            (AT91_ST + 0x08)        /* Watchdog Mode Register */
-#define                AT91_ST_WDV             (0xffff <<  0)          /* Watchdog Counter Value */
-#define                AT91_ST_RSTEN           (1      << 16)          /* Reset Enable */
-#define                AT91_ST_EXTEN           (1      << 17)          /* External Signal Assertion Enable */
-#define        AT91_ST_RTMR            (AT91_ST + 0x0c)        /* Real-time Mode Register */
-#define                AT91_ST_RTPRES          (0xffff <<  0)          /* Real-time Prescalar Value */
-#define        AT91_ST_SR              (AT91_ST + 0x10)        /* Status Register */
-#define                AT91_ST_PITS            (1 << 0)                /* Period Interval Timer Status */
-#define                AT91_ST_WDOVF           (1 << 1)                /* Watchdog Overflow */
-#define                AT91_ST_RTTINC          (1 << 2)                /* Real-time Timer Increment */
-#define                AT91_ST_ALMS            (1 << 3)                /* Alarm Status */
-#define        AT91_ST_IER             (AT91_ST + 0x14)        /* Interrupt Enable Register */
-#define        AT91_ST_IDR             (AT91_ST + 0x18)        /* Interrupt Disable Register */
-#define        AT91_ST_IMR             (AT91_ST + 0x1c)        /* Interrupt Mask Register */
-#define        AT91_ST_RTAR            (AT91_ST + 0x20)        /* Real-time Alarm Register */
-#define                AT91_ST_ALMV            (0xfffff << 0)          /* Alarm Value */
-#define        AT91_ST_CRTR            (AT91_ST + 0x24)        /* Current Real-time Register */
-#define                AT91_ST_CRTV            (0xfffff << 0)          /* Current Real-Time Value */
-
-
-/*
- * Real-time Clock.
- */
-#define        AT91_RTC        0xe00
-
-#define        AT91_RTC_CR             (AT91_RTC + 0x00)       /* Control Register */
-#define                AT91_RTC_UPDTIM         (1 <<  0)               /* Update Request Time Register */
-#define                AT91_RTC_UPDCAL         (1 <<  1)               /* Update Request Calendar Register */
-#define                AT91_RTC_TIMEVSEL       (3 <<  8)               /* Time Event Selection */
-#define                        AT91_RTC_TIMEVSEL_MINUTE        (0 << 8)
-#define                AT91_RTC_TIMEVSEL_HOUR          (1 << 8)
-#define                AT91_RTC_TIMEVSEL_DAY24         (2 << 8)
-#define                AT91_RTC_TIMEVSEL_DAY12         (3 << 8)
-#define                AT91_RTC_CALEVSEL       (3 << 16)               /* Calendar Event Selection */
-#define                AT91_RTC_CALEVSEL_WEEK          (0 << 16)
-#define                AT91_RTC_CALEVSEL_MONTH         (1 << 16)
-#define                AT91_RTC_CALEVSEL_YEAR          (2 << 16)
-
-#define        AT91_RTC_MR             (AT91_RTC + 0x04)       /* Mode Register */
-#define        AT91_RTC_HRMOD          (1 <<  0)               /* 12/24 Hour Mode */
-
-#define        AT91_RTC_TIMR           (AT91_RTC + 0x08)       /* Time Register */
-#define                AT91_RTC_SEC            (0x7f <<  0)            /* Current Second */
-#define                AT91_RTC_MIN            (0x7f <<  8)            /* Current Minute */
-#define                AT91_RTC_HOUR           (0x3f << 16)            /* Current Hour */
-#define                AT91_RTC_AMPM           (1    << 22)            /* Ante Meridiem Post Meridiem Indicator */
-
-#define        AT91_RTC_CALR           (AT91_RTC + 0x0c)       /* Calendar Register */
-#define                AT91_RTC_CENT           (0x7f <<  0)            /* Current Century */
-#define                AT91_RTC_YEAR           (0xff <<  8)            /* Current Year */
-#define                AT91_RTC_MONTH          (0x1f << 16)            /* Current Month */
-#define                AT91_RTC_DAY            (7    << 21)            /* Current Day */
-#define                AT91_RTC_DATE           (0x3f << 24)            /* Current Date */
-
-#define        AT91_RTC_TIMALR         (AT91_RTC + 0x10)       /* Time Alarm Register */
-#define                AT91_RTC_SECEN          (1 <<  7)               /* Second Alarm Enable */
-#define                AT91_RTC_MINEN          (1 << 15)               /* Minute Alarm Enable */
-#define                AT91_RTC_HOUREN         (1 << 23)               /* Hour Alarm Enable */
-
-#define        AT91_RTC_CALALR         (AT91_RTC + 0x14)       /* Calendar Alarm Register */
-#define                AT91_RTC_MTHEN          (1 << 23)               /* Month Alarm Enable */
-#define                AT91_RTC_DATEEN         (1 << 31)               /* Date Alarm Enable */
-
-#define        AT91_RTC_SR             (AT91_RTC + 0x18)       /* Status Register */
-#define                AT91_RTC_ACKUPD         (1 <<  0)               /* Acknowledge for Update */
-#define                AT91_RTC_ALARM          (1 <<  1)               /* Alarm Flag */
-#define                AT91_RTC_SECEV          (1 <<  2)               /* Second Event */
-#define                AT91_RTC_TIMEV          (1 <<  3)               /* Time Event */
-#define                AT91_RTC_CALEV          (1 <<  4)               /* Calendar Event */
-
-#define        AT91_RTC_SCCR           (AT91_RTC + 0x1c)       /* Status Clear Command Register */
-#define        AT91_RTC_IER            (AT91_RTC + 0x20)       /* Interrupt Enable Register */
-#define        AT91_RTC_IDR            (AT91_RTC + 0x24)       /* Interrupt Disable Register */
-#define        AT91_RTC_IMR            (AT91_RTC + 0x28)       /* Interrupt Mask Register */
-
-#define        AT91_RTC_VER            (AT91_RTC + 0x2c)       /* Valid Entry Register */
-#define                AT91_RTC_NVTIM          (1 <<  0)               /* Non valid Time */
-#define                AT91_RTC_NVCAL          (1 <<  1)               /* Non valid Calendar */
-#define                AT91_RTC_NVTIMALR       (1 <<  2)               /* Non valid Time Alarm */
-#define                AT91_RTC_NVCALALR       (1 <<  3)               /* Non valid Calendar Alarm */
-
-
-/*
- * Memory Controller.
- */
-#define AT91_MC                0xf00
-
-#define AT91_MC_RCR            (AT91_MC + 0x00)        /* MC Remap Control Register */
-#define                AT91_MC_RCB             (1 <<  0)               /* Remap Command Bit */
-
-#define AT91_MC_ASR            (AT91_MC + 0x04)        /* MC Abort Status Register */
-#define                AT91_MC_UNADD           (1 <<  0)               /* Undefined Address Abort Status */
-#define                AT91_MC_MISADD          (1 <<  1)               /* Misaligned Address Abort Status */
-#define                AT91_MC_ABTSZ           (3 <<  8)               /* Abort Size Status */
-#define                        AT91_MC_ABTSZ_BYTE              (0 << 8)
-#define                        AT91_MC_ABTSZ_HALFWORD          (1 << 8)
-#define                        AT91_MC_ABTSZ_WORD              (2 << 8)
-#define                AT91_MC_ABTTYP          (3 << 10)               /* Abort Type Status */
-#define                        AT91_MC_ABTTYP_DATAREAD         (0 << 10)
-#define                        AT91_MC_ABTTYP_DATAWRITE        (1 << 10)
-#define                        AT91_MC_ABTTYP_FETCH            (2 << 10)
-#define                AT91_MC_MST0            (1 << 16)               /* ARM920T Abort Source */
-#define                AT91_MC_MST1            (1 << 17)               /* PDC Abort Source */
-#define                AT91_MC_MST2            (1 << 18)               /* UHP Abort Source */
-#define                AT91_MC_MST3            (1 << 19)               /* EMAC Abort Source */
-#define                AT91_MC_SVMST0          (1 << 24)               /* Saved ARM920T Abort Source */
-#define                AT91_MC_SVMST1          (1 << 25)               /* Saved PDC Abort Source */
-#define                AT91_MC_SVMST2          (1 << 26)               /* Saved UHP Abort Source */
-#define                AT91_MC_SVMST3          (1 << 27)               /* Saved EMAC Abort Source */
-
-#define AT91_MC_AASR           (AT91_MC + 0x08)        /* MC Abort Address Status Register */
-
-#define AT91_MC_MPR            (AT91_MC + 0x0c)        /* MC Master Priority Register */
-#define                AT91_MPR_MSTP0          (7 <<  0)               /* ARM920T Priority */
-#define                AT91_MPR_MSTP1          (7 <<  4)               /* PDC Priority */
-#define                AT91_MPR_MSTP2          (7 <<  8)               /* UHP Priority */
-#define                AT91_MPR_MSTP3          (7 << 12)               /* EMAC Priority */
-
-/* External Bus Interface (EBI) registers */
-#define AT91_EBI_CSA           (AT91_MC + 0x60)        /* Chip Select Assignment Register */
-#define                AT91_EBI_CS0A           (1 << 0)                /* Chip Select 0 Assignment */
-#define                        AT91_EBI_CS0A_SMC               (0 << 0)
-#define                        AT91_EBI_CS0A_BFC               (1 << 0)
-#define                AT91_EBI_CS1A           (1 << 1)                /* Chip Select 1 Assignment */
-#define                        AT91_EBI_CS1A_SMC               (0 << 1)
-#define                        AT91_EBI_CS1A_SDRAMC            (1 << 1)
-#define                AT91_EBI_CS3A           (1 << 3)                /* Chip Select 2 Assignment */
-#define                        AT91_EBI_CS3A_SMC               (0 << 3)
-#define                        AT91_EBI_CS3A_SMC_SMARTMEDIA    (1 << 3)
-#define                AT91_EBI_CS4A           (1 << 4)                /* Chip Select 3 Assignment */
-#define                        AT91_EBI_CS4A_SMC               (0 << 4)
-#define                        AT91_EBI_CS4A_SMC_COMPACTFLASH  (1 << 4)
-#define AT91_EBI_CFGR          (AT91_MC + 0x64)        /* Configuration Register */
-#define                AT91_EBI_DBPUC          (1 << 0)                /* Data Bus Pull-Up Configuration */
-
-/* Static Memory Controller (SMC) registers */
-#define        AT91_SMC_CSR(n)         (AT91_MC + 0x70 + ((n) * 4))/* SMC Chip Select Register */
-#define                AT91_SMC_NWS            (0x7f <<  0)            /* Number of Wait States */
-#define                        AT91_SMC_NWS_(x)        ((x) << 0)
-#define                AT91_SMC_WSEN           (1    <<  7)            /* Wait State Enable */
-#define                AT91_SMC_TDF            (0xf  <<  8)            /* Data Float Time */
-#define                        AT91_SMC_TDF_(x)        ((x) << 8)
-#define                AT91_SMC_BAT            (1    << 12)            /* Byte Access Type */
-#define                AT91_SMC_DBW            (3    << 13)            /* Data Bus Width */
-#define                        AT91_SMC_DBW_16         (1 << 13)
-#define                        AT91_SMC_DBW_8          (2 << 13)
-#define                AT91_SMC_DPR            (1 << 15)               /* Data Read Protocol */
-#define                AT91_SMC_ACSS           (3 << 16)               /* Address to Chip Select Setup */
-#define                        AT91_SMC_ACSS_STD       (0 << 16)
-#define                        AT91_SMC_ACSS_1         (1 << 16)
-#define                        AT91_SMC_ACSS_2         (2 << 16)
-#define                        AT91_SMC_ACSS_3         (3 << 16)
-#define                AT91_SMC_RWSETUP        (7 << 24)               /* Read & Write Signal Time Setup */
-#define                        AT91_SMC_RWSETUP_(x)    ((x) << 24)
-#define                AT91_SMC_RWHOLD         (7 << 28)               /* Read & Write Signal Hold Time */
-#define                        AT91_SMC_RWHOLD_(x)     ((x) << 28)
-
-/* SDRAM Controller registers */
-#define AT91_SDRAMC_MR         (AT91_MC + 0x90)        /* Mode Register */
-#define                AT91_SDRAMC_MODE        (0xf << 0)              /* Command Mode */
-#define                        AT91_SDRAMC_MODE_NORMAL         (0 << 0)
-#define                        AT91_SDRAMC_MODE_NOP            (1 << 0)
-#define                        AT91_SDRAMC_MODE_PRECHARGE      (2 << 0)
-#define                        AT91_SDRAMC_MODE_LMR            (3 << 0)
-#define                        AT91_SDRAMC_MODE_REFRESH        (4 << 0)
-#define                AT91_SDRAMC_DBW         (1   << 4)              /* Data Bus Width */
-#define                        AT91_SDRAMC_DBW_32      (0 << 4)
-#define                        AT91_SDRAMC_DBW_16      (1 << 4)
-
-#define AT91_SDRAMC_TR         (AT91_MC + 0x94)        /* Refresh Timer Register */
-#define                AT91_SDRAMC_COUNT       (0xfff << 0)            /* Refresh Timer Count */
-
-#define AT91_SDRAMC_CR         (AT91_MC + 0x98)        /* Configuration Register */
-#define                AT91_SDRAMC_NC          (3   <<  0)             /* Number of Column Bits */
-#define                        AT91_SDRAMC_NC_8        (0 << 0)
-#define                        AT91_SDRAMC_NC_9        (1 << 0)
-#define                        AT91_SDRAMC_NC_10       (2 << 0)
-#define                        AT91_SDRAMC_NC_11       (3 << 0)
-#define                AT91_SDRAMC_NR          (3   <<  2)             /* Number of Row Bits */
-#define                        AT91_SDRAMC_NR_11       (0 << 2)
-#define                        AT91_SDRAMC_NR_12       (1 << 2)
-#define                        AT91_SDRAMC_NR_13       (2 << 2)
-#define                AT91_SDRAMC_NB          (1   <<  4)             /* Number of Banks */
-#define                        AT91_SDRAMC_NB_2        (0 << 4)
-#define                        AT91_SDRAMC_NB_4        (1 << 4)
-#define                AT91_SDRAMC_CAS         (3   <<  5)             /* CAS Latency */
-#define                        AT91_SDRAMC_CAS_2       (2 << 5)
-#define                AT91_SDRAMC_TWR         (0xf <<  7)             /* Write Recovery Delay */
-#define                AT91_SDRAMC_TRC         (0xf << 11)             /* Row Cycle Delay */
-#define                AT91_SDRAMC_TRP         (0xf << 15)             /* Row Precharge Delay */
-#define                AT91_SDRAMC_TRCD        (0xf << 19)             /* Row to Column Delay */
-#define                AT91_SDRAMC_TRAS        (0xf << 23)             /* Active to Precharge Delay */
-#define                AT91_SDRAMC_TXSR        (0xf << 27)             /* Exit Self Refresh to Active Delay */
-
-#define AT91_SDRAMC_SRR                (AT91_MC + 0x9c)        /* Self Refresh Register */
-#define AT91_SDRAMC_LPR                (AT91_MC + 0xa0)        /* Low Power Register */
-#define AT91_SDRAMC_IER                (AT91_MC + 0xa4)        /* Interrupt Enable Register */
-#define AT91_SDRAMC_IDR                (AT91_MC + 0xa8)        /* Interrupt Disable Register */
-#define AT91_SDRAMC_IMR                (AT91_MC + 0xac)        /* Interrupt Mask Register */
-#define AT91_SDRAMC_ISR                (AT91_MC + 0xb0)        /* Interrupt Status Register */
-
-/* Burst Flash Controller register */
-#define AT91_BFC_MR            (AT91_MC + 0xc0)        /* Mode Register */
-#define                AT91_BFC_BFCOM          (3   <<  0)             /* Burst Flash Controller Operating Mode */
-#define                        AT91_BFC_BFCOM_DISABLED (0 << 0)
-#define                        AT91_BFC_BFCOM_ASYNC    (1 << 0)
-#define                        AT91_BFC_BFCOM_BURST    (2 << 0)
-#define                AT91_BFC_BFCC           (3   <<  2)             /* Burst Flash Controller Clock */
-#define                        AT91_BFC_BFCC_MCK       (1 << 2)
-#define                        AT91_BFC_BFCC_DIV2      (2 << 2)
-#define                        AT91_BFC_BFCC_DIV4      (3 << 2)
-#define                AT91_BFC_AVL            (0xf <<  4)             /* Address Valid Latency */
-#define                AT91_BFC_PAGES          (7   <<  8)             /* Page Size */
-#define                        AT91_BFC_PAGES_NO_PAGE  (0 << 8)
-#define                        AT91_BFC_PAGES_16       (1 << 8)
-#define                        AT91_BFC_PAGES_32       (2 << 8)
-#define                        AT91_BFC_PAGES_64       (3 << 8)
-#define                        AT91_BFC_PAGES_128      (4 << 8)
-#define                        AT91_BFC_PAGES_256      (5 << 8)
-#define                        AT91_BFC_PAGES_512      (6 << 8)
-#define                        AT91_BFC_PAGES_1024     (7 << 8)
-#define                AT91_BFC_OEL            (3   << 12)             /* Output Enable Latency */
-#define                AT91_BFC_BAAEN          (1   << 16)             /* Burst Address Advance Enable */
-#define                AT91_BFC_BFOEH          (1   << 17)             /* Burst Flash Output Enable Handling */
-#define                AT91_BFC_MUXEN          (1   << 18)             /* Multiplexed Bus Enable */
-#define                AT91_BFC_RDYEN          (1   << 19)             /* Ready Enable Mode */
-
-#endif
diff --git a/include/asm-arm/arch-at91rm9200/at91rm9200_udp.h b/include/asm-arm/arch-at91rm9200/at91rm9200_udp.h
deleted file mode 100644 (file)
index 951e3f6..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * include/asm-arm/arch-at91rm9200/at91rm9200_udp.h
- *
- * Copyright (C) 2005 Ivan Kokshaysky
- * Copyright (C) SAN People
- *
- * USB Device Port (UDP) registers.
- * Based on AT91RM9200 datasheet revision E.
- *
- * 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.
- */
-
-#ifndef AT91RM9200_UDP_H
-#define AT91RM9200_UDP_H
-
-#define AT91_UDP_FRM_NUM       0x00            /* Frame Number Register */
-#define                AT91_UDP_NUM            (0x7ff <<  0)           /* Frame Number */
-#define                AT91_UDP_FRM_ERR        (1     << 16)           /* Frame Error */
-#define                AT91_UDP_FRM_OK         (1     << 17)           /* Frame OK */
-
-#define AT91_UDP_GLB_STAT      0x04            /* Global State Register */
-#define                AT91_UDP_FADDEN         (1 <<  0)               /* Function Address Enable */
-#define                AT91_UDP_CONFG          (1 <<  1)               /* Configured */
-#define                AT91_UDP_ESR            (1 <<  2)               /* Enable Send Resume */
-#define                AT91_UDP_RSMINPR        (1 <<  3)               /* Resume has been sent */
-#define                AT91_UDP_RMWUPE         (1 <<  4)               /* Remote Wake Up Enable */
-
-#define AT91_UDP_FADDR         0x08            /* Function Address Register */
-#define                AT91_UDP_FADD           (0x7f << 0)             /* Function Address Value */
-#define                AT91_UDP_FEN            (1    << 8)             /* Function Enable */
-
-#define AT91_UDP_IER           0x10            /* Interrupt Enable Register */
-#define AT91_UDP_IDR           0x14            /* Interrupt Disable Register */
-#define AT91_UDP_IMR           0x18            /* Interrupt Mask Register */
-
-#define AT91_UDP_ISR           0x1c            /* Interrupt Status Register */
-#define                AT91_UDP_EP(n)          (1 << (n))              /* Endpoint Interrupt Status */
-#define                AT91_UDP_RXSUSP         (1 <<  8)               /* USB Suspend Interrupt Status */
-#define                AT91_UDP_RXRSM          (1 <<  9)               /* USB Resume Interrupt Status */
-#define                AT91_UDP_EXTRSM         (1 << 10)               /* External Resume Interrupt Status */
-#define                AT91_UDP_SOFINT         (1 << 11)               /* Start of Frame Interrupt Status */
-#define                AT91_UDP_ENDBUSRES      (1 << 12)               /* End of Bus Reset Interrpt Status */
-#define                AT91_UDP_WAKEUP         (1 << 13)               /* USB Wakeup Interrupt Status */
-
-#define AT91_UDP_ICR           0x20            /* Interrupt Clear Register */
-#define AT91_UDP_RST_EP                0x28            /* Reset Endpoint Register */
-
-#define AT91_UDP_CSR(n)                (0x30 + ((n) * 4))      /* Endpoint Control/Status Registers 0-7 */
-#define                AT91_UDP_TXCOMP         (1 <<  0)               /* Generates IN packet with data previously written in DPR */
-#define                AT91_UDP_RX_DATA_BK0    (1 <<  1)               /* Receive Data Bank 0 */
-#define                AT91_UDP_RXSETUP        (1 <<  2)               /* Send STALL to the host */
-#define                AT91_UDP_STALLSENT      (1 <<  3)               /* Stall Sent / Isochronous error (Isochronous endpoints) */
-#define                AT91_UDP_TXPKTRDY       (1 <<  4)               /* Transmit Packet Ready */
-#define                AT91_UDP_FORCESTALL     (1 <<  5)               /* Force Stall */
-#define                AT91_UDP_RX_DATA_BK1    (1 <<  6)               /* Receive Data Bank 1 */
-#define                AT91_UDP_DIR            (1 <<  7)               /* Transfer Direction */
-#define                AT91_UDP_EPTYPE         (7 <<  8)               /* Endpoint Type */
-#define                        AT91_UDP_EPTYPE_CTRL            (0 <<  8)
-#define                        AT91_UDP_EPTYPE_ISO_OUT         (1 <<  8)
-#define                        AT91_UDP_EPTYPE_BULK_OUT        (2 <<  8)
-#define                        AT91_UDP_EPTYPE_INT_OUT         (3 <<  8)
-#define                        AT91_UDP_EPTYPE_ISO_IN          (5 <<  8)
-#define                        AT91_UDP_EPTYPE_BULK_IN         (6 <<  8)
-#define                        AT91_UDP_EPTYPE_INT_IN          (7 <<  8)
-#define                AT91_UDP_DTGLE          (1 << 11)               /* Data Toggle */
-#define                AT91_UDP_EPEDS          (1 << 15)               /* Endpoint Enable/Disable */
-#define                AT91_UDP_RXBYTECNT      (0x7ff << 16)           /* Number of bytes in FIFO */
-
-#define AT91_UDP_FDR(n)                (0x50 + ((n) * 4))      /* Endpoint FIFO Data Registers 0-7 */
-
-#define AT91_UDP_TXVC          0x74            /* Transceiver Control Register */
-#define                AT91_UDP_TXVC_TXVDIS    (1 << 8)                /* Transceiver Disable */
-
-#endif
diff --git a/include/asm-arm/arch-at91rm9200/at91sam9260.h b/include/asm-arm/arch-at91rm9200/at91sam9260.h
new file mode 100644 (file)
index 0000000..46f4dd6
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91sam9260.h
+ *
+ * (C) 2006 Andrew Victor
+ *
+ * Common definitions.
+ * Based on AT91SAM9260 datasheet revision A (Preliminary).
+ *
+ * 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.
+ */
+
+#ifndef AT91SAM9260_H
+#define AT91SAM9260_H
+
+/*
+ * Peripheral identifiers/interrupts.
+ */
+#define AT91_ID_FIQ            0       /* Advanced Interrupt Controller (FIQ) */
+#define AT91_ID_SYS            1       /* System Peripherals */
+#define AT91SAM9260_ID_PIOA    2       /* Parallel IO Controller A */
+#define AT91SAM9260_ID_PIOB    3       /* Parallel IO Controller B */
+#define AT91SAM9260_ID_PIOC    4       /* Parallel IO Controller C */
+#define AT91SAM9260_ID_ADC     5       /* Analog-to-Digital Converter */
+#define AT91SAM9260_ID_US0     6       /* USART 0 */
+#define AT91SAM9260_ID_US1     7       /* USART 1 */
+#define AT91SAM9260_ID_US2     8       /* USART 2 */
+#define AT91SAM9260_ID_MCI     9       /* Multimedia Card Interface */
+#define AT91SAM9260_ID_UDP     10      /* USB Device Port */
+#define AT91SAM9260_ID_TWI     11      /* Two-Wire Interface */
+#define AT91SAM9260_ID_SPI0    12      /* Serial Peripheral Interface 0 */
+#define AT91SAM9260_ID_SPI1    13      /* Serial Peripheral Interface 1 */
+#define AT91SAM9260_ID_SSC     14      /* Serial Synchronous Controller */
+#define AT91SAM9260_ID_TC0     17      /* Timer Counter 0 */
+#define AT91SAM9260_ID_TC1     18      /* Timer Counter 1 */
+#define AT91SAM9260_ID_TC2     19      /* Timer Counter 2 */
+#define AT91SAM9260_ID_UHP     20      /* USB Host port */
+#define AT91SAM9260_ID_EMAC    21      /* Ethernet */
+#define AT91SAM9260_ID_ISI     22      /* Image Sensor Interface */
+#define AT91SAM9260_ID_US3     23      /* USART 3 */
+#define AT91SAM9260_ID_US4     24      /* USART 4 */
+#define AT91SAM9260_ID_US5     25      /* USART 5 */
+#define AT91SAM9260_ID_TC3     26      /* Timer Counter 3 */
+#define AT91SAM9260_ID_TC4     27      /* Timer Counter 4 */
+#define AT91SAM9260_ID_TC5     28      /* Timer Counter 5 */
+#define AT91SAM9260_ID_IRQ0    29      /* Advanced Interrupt Controller (IRQ0) */
+#define AT91SAM9260_ID_IRQ1    30      /* Advanced Interrupt Controller (IRQ1) */
+#define AT91SAM9260_ID_IRQ2    31      /* Advanced Interrupt Controller (IRQ2) */
+
+
+/*
+ * User Peripheral physical base addresses.
+ */
+#define AT91SAM9260_BASE_TCB0          0xfffa0000
+#define AT91SAM9260_BASE_TC0           0xfffa0000
+#define AT91SAM9260_BASE_TC1           0xfffa0040
+#define AT91SAM9260_BASE_TC2           0xfffa0080
+#define AT91SAM9260_BASE_UDP           0xfffa4000
+#define AT91SAM9260_BASE_MCI           0xfffa8000
+#define AT91SAM9260_BASE_TWI           0xfffac000
+#define AT91SAM9260_BASE_US0           0xfffb0000
+#define AT91SAM9260_BASE_US1           0xfffb4000
+#define AT91SAM9260_BASE_US2           0xfffb8000
+#define AT91SAM9260_BASE_SSC           0xfffbc000
+#define AT91SAM9260_BASE_ISI           0xfffc0000
+#define AT91SAM9260_BASE_EMAC          0xfffc4000
+#define AT91SAM9260_BASE_SPI0          0xfffc8000
+#define AT91SAM9260_BASE_SPI1          0xfffcc000
+#define AT91SAM9260_BASE_US3           0xfffd0000
+#define AT91SAM9260_BASE_US4           0xfffd4000
+#define AT91SAM9260_BASE_US5           0xfffd8000
+#define AT91SAM9260_BASE_TCB1          0xfffdc000
+#define AT91SAM9260_BASE_TC3           0xfffdc000
+#define AT91SAM9260_BASE_TC4           0xfffdc040
+#define AT91SAM9260_BASE_TC5           0xfffdc080
+#define AT91SAM9260_BASE_ADC           0xfffe0000
+#define AT91_BASE_SYS                  0xffffe800
+
+/*
+ * System Peripherals (offset from AT91_BASE_SYS)
+ */
+#define AT91_ECC       (0xffffe800 - AT91_BASE_SYS)
+#define AT91_SDRAMC    (0xffffea00 - AT91_BASE_SYS)
+#define AT91_SMC       (0xffffec00 - AT91_BASE_SYS)
+#define AT91_MATRIX    (0xffffee00 - AT91_BASE_SYS)
+#define AT91_CCFG      (0xffffef10 - AT91_BASE_SYS)
+#define AT91_AIC       (0xfffff000 - AT91_BASE_SYS)
+#define AT91_DBGU      (0xfffff200 - AT91_BASE_SYS)
+#define AT91_PIOA      (0xfffff400 - AT91_BASE_SYS)
+#define AT91_PIOB      (0xfffff600 - AT91_BASE_SYS)
+#define AT91_PIOC      (0xfffff800 - AT91_BASE_SYS)
+#define AT91_PMC       (0xfffffc00 - AT91_BASE_SYS)
+#define AT91_RSTC      (0xfffffd00 - AT91_BASE_SYS)
+#define AT91_SHDWC     (0xfffffd10 - AT91_BASE_SYS)
+#define AT91_RTT       (0xfffffd20 - AT91_BASE_SYS)
+#define AT91_PIT       (0xfffffd30 - AT91_BASE_SYS)
+#define AT91_WDT       (0xfffffd40 - AT91_BASE_SYS)
+#define AT91_GPBR      (0xfffffd50 - AT91_BASE_SYS)
+
+
+/*
+ * Internal Memory.
+ */
+#define AT91SAM9260_ROM_BASE   0x00100000      /* Internal ROM base address */
+#define AT91SAM9260_ROM_SIZE   SZ_32K          /* Internal ROM size (32Kb) */
+
+#define AT91SAM9260_SRAM0_BASE 0x00200000      /* Internal SRAM 0 base address */
+#define AT91SAM9260_SRAM0_SIZE SZ_4K           /* Internal SRAM 0 size (4Kb) */
+#define AT91SAM9260_SRAM1_BASE 0x00300000      /* Internal SRAM 1 base address */
+#define AT91SAM9260_SRAM1_SIZE SZ_4K           /* Internal SRAM 1 size (4Kb) */
+
+#define AT91SAM9260_UHP_BASE   0x00500000      /* USB Host controller */
+
+#if 0
+/*
+ * PIO pin definitions (peripheral A/B multiplexing).
+ */
+
+// TODO: Add
+
+#endif
+
+#endif
diff --git a/include/asm-arm/arch-at91rm9200/at91sam9260_matrix.h b/include/asm-arm/arch-at91rm9200/at91sam9260_matrix.h
new file mode 100644 (file)
index 0000000..746d973
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91sam9260_matrix.h
+ *
+ * Memory Controllers (MATRIX, EBI) - System peripherals registers.
+ * Based on AT91SAM9260 datasheet revision B.
+ *
+ * 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.
+ */
+
+#ifndef AT91SAM9260_MATRIX_H
+#define AT91SAM9260_MATRIX_H
+
+#define AT91_MATRIX_MCFG0      (AT91_MATRIX + 0x00)    /* Master Configuration Register 0 */
+#define AT91_MATRIX_MCFG1      (AT91_MATRIX + 0x04)    /* Master Configuration Register 1 */
+#define AT91_MATRIX_MCFG2      (AT91_MATRIX + 0x08)    /* Master Configuration Register 2 */
+#define AT91_MATRIX_MCFG3      (AT91_MATRIX + 0x0C)    /* Master Configuration Register 3 */
+#define AT91_MATRIX_MCFG4      (AT91_MATRIX + 0x10)    /* Master Configuration Register 4 */
+#define AT91_MATRIX_MCFG5      (AT91_MATRIX + 0x04)    /* Master Configuration Register 5 */
+#define                AT91_MATRIX_ULBT                (7 << 0)        /* Undefined Length Burst Type */
+#define                        AT91_MATRIX_ULBT_INFINITE       (0 << 0)
+#define                        AT91_MATRIX_ULBT_SINGLE         (1 << 0)
+#define                        AT91_MATRIX_ULBT_FOUR           (2 << 0)
+#define                        AT91_MATRIX_ULBT_EIGHT          (3 << 0)
+#define                        AT91_MATRIX_ULBT_SIXTEEN        (4 << 0)
+
+#define AT91_MATRIX_SCFG0      (AT91_MATRIX + 0x40)    /* Slave Configuration Register 0 */
+#define AT91_MATRIX_SCFG1      (AT91_MATRIX + 0x44)    /* Slave Configuration Register 1 */
+#define AT91_MATRIX_SCFG2      (AT91_MATRIX + 0x48)    /* Slave Configuration Register 2 */
+#define AT91_MATRIX_SCFG3      (AT91_MATRIX + 0x4C)    /* Slave Configuration Register 3 */
+#define AT91_MATRIX_SCFG4      (AT91_MATRIX + 0x50)    /* Slave Configuration Register 4 */
+#define                AT91_MATRIX_SLOT_CYCLE          (0xff <<  0)    /* Maximum Number of Allowed Cycles for a Burst */
+#define                AT91_MATRIX_DEFMSTR_TYPE        (3    << 16)    /* Default Master Type */
+#define                        AT91_MATRIX_DEFMSTR_TYPE_NONE   (0 << 16)
+#define                        AT91_MATRIX_DEFMSTR_TYPE_LAST   (1 << 16)
+#define                        AT91_MATRIX_DEFMSTR_TYPE_FIXED  (2 << 16)
+#define                AT91_MATRIX_FIXED_DEFMSTR       (7    << 18)    /* Fixed Index of Default Master */
+#define                AT91_MATRIX_ARBT                (3    << 24)    /* Arbitration Type */
+#define                        AT91_MATRIX_ARBT_ROUND_ROBIN    (0 << 24)
+#define                        AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24)
+
+#define AT91_MATRIX_PRAS0      (AT91_MATRIX + 0x80)    /* Priority Register A for Slave 0 */
+#define AT91_MATRIX_PRAS1      (AT91_MATRIX + 0x88)    /* Priority Register A for Slave 1 */
+#define AT91_MATRIX_PRAS2      (AT91_MATRIX + 0x90)    /* Priority Register A for Slave 2 */
+#define AT91_MATRIX_PRAS3      (AT91_MATRIX + 0x98)    /* Priority Register A for Slave 3 */
+#define AT91_MATRIX_PRAS4      (AT91_MATRIX + 0xA0)    /* Priority Register A for Slave 4 */
+#define                AT91_MATRIX_M0PR                (3 << 0)        /* Master 0 Priority */
+#define                AT91_MATRIX_M1PR                (3 << 4)        /* Master 1 Priority */
+#define                AT91_MATRIX_M2PR                (3 << 8)        /* Master 2 Priority */
+#define                AT91_MATRIX_M3PR                (3 << 12)       /* Master 3 Priority */
+#define                AT91_MATRIX_M4PR                (3 << 16)       /* Master 4 Priority */
+#define                AT91_MATRIX_M5PR                (3 << 20)       /* Master 5 Priority */
+
+#define AT91_MATRIX_MRCR       (AT91_MATRIX + 0x100)   /* Master Remap Control Register */
+#define                AT91_MATRIX_RCB0                (1 << 0)        /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */
+#define                AT91_MATRIX_RCB1                (1 << 1)        /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */
+
+#define AT91_MATRIX_EBICSA     (AT91_MATRIX + 0x11C)   /* EBI Chip Select Assignment Register */
+#define                AT91_MATRIX_CS1A                (1 << 1)         /* Chip Select 1 Assignment */
+#define                        AT91_MATRIX_CS1A_SMC            (0 << 1)
+#define                        AT91_MATRIX_CS1A_SDRAMC         (1 << 1)
+#define                AT91_MATRIX_CS3A                (1 << 3)        /* Chip Select 3 Assignment */
+#define                        AT91_MATRIX_CS3A_SMC            (0 << 3)
+#define                        AT91_MATRIX_CS3A_SMC_SMARTMEDIA (1 << 3)
+#define                AT91_MATRIX_CS4A                (1 << 4)        /* Chip Select 4 Assignment */
+#define                        AT91_MATRIX_CS4A_SMC            (0 << 4)
+#define                        AT91_MATRIX_CS4A_SMC_CF1        (1 << 4)
+#define                AT91_MATRIX_CS5A                (1 << 5 )       /* Chip Select 5 Assignment */
+#define                        AT91_MATRIX_CS5A_SMC            (0 << 5)
+#define                        AT91_MATRIX_CS5A_SMC_CF2        (1 << 5)
+#define                AT91_MATRIX_DBPUC               (1 << 8)        /* Data Bus Pull-up Configuration */
+#define                AT91_MATRIX_VDDIOMSEL           (1 << 16)       /* Memory voltage selection */
+#define                        AT91_MATRIX_VDDIOMSEL_1_8V      (0 << 16)
+#define                        AT91_MATRIX_VDDIOMSEL_3_3V      (1 << 16)
+
+#endif
diff --git a/include/asm-arm/arch-at91rm9200/at91sam9261.h b/include/asm-arm/arch-at91rm9200/at91sam9261.h
new file mode 100644 (file)
index 0000000..8d39672
--- /dev/null
@@ -0,0 +1,292 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91sam9261.h
+ *
+ * Copyright (C) SAN People
+ *
+ * Common definitions.
+ * Based on AT91SAM9261 datasheet revision E. (Preliminary)
+ *
+ * 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.
+ */
+
+#ifndef AT91SAM9261_H
+#define AT91SAM9261_H
+
+/*
+ * Peripheral identifiers/interrupts.
+ */
+#define AT91_ID_FIQ            0       /* Advanced Interrupt Controller (FIQ) */
+#define AT91_ID_SYS            1       /* System Peripherals */
+#define AT91SAM9261_ID_PIOA    2       /* Parallel IO Controller A */
+#define AT91SAM9261_ID_PIOB    3       /* Parallel IO Controller B */
+#define AT91SAM9261_ID_PIOC    4       /* Parallel IO Controller C */
+#define AT91SAM9261_ID_US0     6       /* USART 0 */
+#define AT91SAM9261_ID_US1     7       /* USART 1 */
+#define AT91SAM9261_ID_US2     8       /* USART 2 */
+#define AT91SAM9261_ID_MCI     9       /* Multimedia Card Interface */
+#define AT91SAM9261_ID_UDP     10      /* USB Device Port */
+#define AT91SAM9261_ID_TWI     11      /* Two-Wire Interface */
+#define AT91SAM9261_ID_SPI0    12      /* Serial Peripheral Interface 0 */
+#define AT91SAM9261_ID_SPI1    13      /* Serial Peripheral Interface 1 */
+#define AT91SAM9261_ID_SSC0    14      /* Serial Synchronous Controller 0 */
+#define AT91SAM9261_ID_SSC1    15      /* Serial Synchronous Controller 1 */
+#define AT91SAM9261_ID_SSC2    16      /* Serial Synchronous Controller 2 */
+#define AT91SAM9261_ID_TC0     17      /* Timer Counter 0 */
+#define AT91SAM9261_ID_TC1     18      /* Timer Counter 1 */
+#define AT91SAM9261_ID_TC2     19      /* Timer Counter 2 */
+#define AT91SAM9261_ID_UHP     20      /* USB Host port */
+#define AT91SAM9261_ID_LCDC    21      /* LDC Controller */
+#define AT91SAM9261_ID_IRQ0    29      /* Advanced Interrupt Controller (IRQ0) */
+#define AT91SAM9261_ID_IRQ1    30      /* Advanced Interrupt Controller (IRQ1) */
+#define AT91SAM9261_ID_IRQ2    31      /* Advanced Interrupt Controller (IRQ2) */
+
+
+/*
+ * User Peripheral physical base addresses.
+ */
+#define AT91SAM9261_BASE_TCB0          0xfffa0000
+#define AT91SAM9261_BASE_TC0           0xfffa0000
+#define AT91SAM9261_BASE_TC1           0xfffa0040
+#define AT91SAM9261_BASE_TC2           0xfffa0080
+#define AT91SAM9261_BASE_UDP           0xfffa4000
+#define AT91SAM9261_BASE_MCI           0xfffa8000
+#define AT91SAM9261_BASE_TWI           0xfffac000
+#define AT91SAM9261_BASE_US0           0xfffb0000
+#define AT91SAM9261_BASE_US1           0xfffb4000
+#define AT91SAM9261_BASE_US2           0xfffb8000
+#define AT91SAM9261_BASE_SSC0          0xfffbc000
+#define AT91SAM9261_BASE_SSC1          0xfffc0000
+#define AT91SAM9261_BASE_SSC2          0xfffc4000
+#define AT91SAM9261_BASE_SPI0          0xfffc8000
+#define AT91SAM9261_BASE_SPI1          0xfffcc000
+#define AT91_BASE_SYS                  0xffffea00
+
+
+/*
+ * System Peripherals (offset from AT91_BASE_SYS)
+ */
+#define AT91_SDRAMC    (0xffffea00 - AT91_BASE_SYS)
+#define AT91_SMC       (0xffffec00 - AT91_BASE_SYS)
+#define AT91_MATRIX    (0xffffee00 - AT91_BASE_SYS)
+#define AT91_AIC       (0xfffff000 - AT91_BASE_SYS)
+#define AT91_DBGU      (0xfffff200 - AT91_BASE_SYS)
+#define AT91_PIOA      (0xfffff400 - AT91_BASE_SYS)
+#define AT91_PIOB      (0xfffff600 - AT91_BASE_SYS)
+#define AT91_PIOC      (0xfffff800 - AT91_BASE_SYS)
+#define AT91_PMC       (0xfffffc00 - AT91_BASE_SYS)
+#define AT91_RSTC      (0xfffffd00 - AT91_BASE_SYS)
+#define AT91_SHDWC     (0xfffffd10 - AT91_BASE_SYS)
+#define AT91_RTT       (0xfffffd20 - AT91_BASE_SYS)
+#define AT91_PIT       (0xfffffd30 - AT91_BASE_SYS)
+#define AT91_WDT       (0xfffffd40 - AT91_BASE_SYS)
+#define AT91_GPBR      (0xfffffd50 - AT91_BASE_SYS)
+
+
+/*
+ * Internal Memory.
+ */
+#define AT91SAM9261_SRAM_BASE  0x00300000      /* Internal SRAM base address */
+#define AT91SAM9261_SRAM_SIZE  0x00028000      /* Internal SRAM size (160Kb) */
+
+#define AT91SAM9261_ROM_BASE   0x00400000      /* Internal ROM base address */
+#define AT91SAM9261_ROM_SIZE   SZ_32K          /* Internal ROM size (32Kb) */
+
+#define AT91SAM9261_UHP_BASE   0x00500000      /* USB Host controller */
+#define AT91SAM9261_LCDC_BASE  0x00600000      /* LDC controller */
+
+
+#if 0
+/*
+ * PIO pin definitions (peripheral A/B multiplexing).
+ */
+#define AT91_PA0_SPI0_MISO     (1 <<  0)       /* A: SPI0 Master In Slave */
+#define AT91_PA0_MCDA0         (1 <<  0)       /* B: Multimedia Card A Data 0 */
+#define AT91_PA1_SPI0_MOSI     (1 <<  1)       /* A: SPI0 Master Out Slave */
+#define AT91_PA1_MCCDA         (1 <<  1)       /* B: Multimedia Card A Command */
+#define AT91_PA2_SPI0_SPCK     (1 <<  2)       /* A: SPI0 Serial Clock */
+#define AT91_PA2_MCCK          (1 <<  2)       /* B: Multimedia Card Clock */
+#define AT91_PA3_SPI0_NPCS0    (1 <<  3)       /* A: SPI0 Peripheral Chip Select 0 */
+#define AT91_PA4_SPI0_NPCS1    (1 <<  4)       /* A: SPI0 Peripheral Chip Select 1 */
+#define AT91_PA4_MCDA1         (1 <<  4)       /* B: Multimedia Card A Data 1 */
+#define AT91_PA5_SPI0_NPCS2    (1 <<  5)       /* A: SPI0 Peripheral Chip Select 2 */
+#define AT91_PA5_MCDA2         (1 <<  5)       /* B: Multimedia Card A Data 2 */
+#define AT91_PA6_SPI0_NPCS3    (1 <<  6)       /* A: SPI0 Peripheral Chip Select 3 */
+#define AT91_PA6_MCDA3         (1 <<  6)       /* B: Multimedia Card A Data 3 */
+#define AT91_PA7_TWD           (1 <<  7)       /* A: TWI Two-wire Serial Data */
+#define AT91_PA7_PCK0          (1 <<  7)       /* B: PMC Programmable clock Output 0 */
+#define AT91_PA8_TWCK          (1 <<  8)       /* A: TWI Two-wire Serial Clock */
+#define AT91_PA8_PCK1          (1 <<  8)       /* B: PMC Programmable clock Output 1 */
+#define AT91_PA9_DRXD          (1 <<  9)       /* A: DBGU Debug Receive Data */
+#define AT91_PA9_PCK2          (1 <<  9)       /* B: PMC Programmable clock Output 2 */
+#define AT91_PA10_DTXD         (1 << 10)       /* A: DBGU Debug Transmit Data */
+#define AT91_PA10_PCK3         (1 << 10)       /* B: PMC Programmable clock Output 3 */
+#define AT91_PA11_TSYNC                (1 << 11)       /* A: Trace Synchronization Signal */
+#define AT91_PA11_SCK1         (1 << 11)       /* B: USART1 Serial Clock */
+#define AT91_PA12_TCLK         (1 << 12)       /* A: Trace Clock */
+#define AT91_PA12_RTS1         (1 << 12)       /* B: USART1 Ready To Send */
+#define AT91_PA13_TPS0         (1 << 13)       /* A: Trace ARM Pipeline Status 0 */
+#define AT91_PA13_CTS1         (1 << 13)       /* B: USART1 Clear To Send */
+#define AT91_PA14_TPS1         (1 << 14)       /* A: Trace ARM Pipeline Status 1 */
+#define AT91_PA14_SCK2         (1 << 14)       /* B: USART2 Serial Clock */
+#define AT91_PA15_TPS2         (1 << 15)       /* A: Trace ARM Pipeline Status 2 */
+#define AT91_PA15_RTS2         (1 << 15)       /* B: USART2 Ready To Send */
+#define AT91_PA16_TPK0         (1 << 16)       /* A: Trace Packet Port 0 */
+#define AT91_PA16_CTS2         (1 << 16)       /* B: USART2 Clear To Send */
+#define AT91_PA17_TPK1         (1 << 17)       /* A: Trace Packet Port 1 */
+#define AT91_PA17_TF1          (1 << 17)       /* B: SSC1 Transmit Frame Sync */
+#define AT91_PA18_TPK2         (1 << 18)       /* A: Trace Packet Port 2 */
+#define AT91_PA18_TK1          (1 << 18)       /* B: SSC1 Transmit Clock */
+#define AT91_PA19_TPK3         (1 << 19)       /* A: Trace Packet Port 3 */
+#define AT91_PA19_TD1          (1 << 19)       /* B: SSC1 Transmit Data */
+#define AT91_PA20_TPK4         (1 << 20)       /* A: Trace Packet Port 4 */
+#define AT91_PA20_RD1          (1 << 20)       /* B: SSC1 Receive Data */
+#define AT91_PA21_TPK5         (1 << 21)       /* A: Trace Packet Port 5 */
+#define AT91_PA21_RK1          (1 << 21)       /* B: SSC1 Receive Clock */
+#define AT91_PA22_TPK6         (1 << 22)       /* A: Trace Packet Port 6 */
+#define AT91_PA22_RF1          (1 << 22)       /* B: SSC1 Receive Frame Sync */
+#define AT91_PA23_TPK7         (1 << 23)       /* A: Trace Packet Port 7 */
+#define AT91_PA23_RTS0         (1 << 23)       /* B: USART0 Ready To Send */
+#define AT91_PA24_TPK8         (1 << 24)       /* A: Trace Packet Port 8 */
+#define AT91_PA24_SPI1_NPCS1   (1 << 24)       /* B: SPI1 Peripheral Chip Select 1 */
+#define AT91_PA25_TPK9         (1 << 25)       /* A: Trace Packet Port 9 */
+#define AT91_PA25_SPI1_NPCS2   (1 << 25)       /* B: SPI1 Peripheral Chip Select 2 */
+#define AT91_PA26_TPK10                (1 << 26)       /* A: Trace Packet Port 10 */
+#define AT91_PA26_SPI1_NPCS3   (1 << 26)       /* B: SPI1 Peripheral Chip Select 3 */
+#define AT91_PA27_TPK11                (1 << 27)       /* A: Trace Packet Port 11 */
+#define AT91_PA27_SPI0_NPCS1   (1 << 27)       /* B: SPI0 Peripheral Chip Select 1 */
+#define AT91_PA28_TPK12                (1 << 28)       /* A: Trace Packet Port 12 */
+#define AT91_PA28_SPI0_NPCS2   (1 << 28)       /* B: SPI0 Peripheral Chip Select 2 */
+#define AT91_PA29_TPK13                (1 << 29)       /* A: Trace Packet Port 13 */
+#define AT91_PA29_SPI0_NPCS3   (1 << 29)       /* B: SPI0 Peripheral Chip Select 3 */
+#define AT91_PA30_TPK14                (1 << 30)       /* A: Trace Packet Port 14 */
+#define AT91_PA30_A23          (1 << 30)       /* B: Address Bus bit 23 */
+#define AT91_PA31_TPK15                (1 << 31)       /* A: Trace Packet Port 15 */
+#define AT91_PA31_A24          (1 << 31)       /* B: Address Bus bit 24 */
+
+#define AT91_PB0_LCDVSYNC      (1 <<  0)       /* A: LCD Vertical Synchronization */
+#define AT91_PB1_LCDHSYNC      (1 <<  1)       /* A: LCD Horizontal Synchronization */
+#define AT91_PB2_LCDDOTCK      (1 <<  2)       /* A: LCD Dot Clock */
+#define AT91_PB2_PCK0          (1 <<  2)       /* B: PMC Programmable clock Output 0 */
+#define AT91_PB3_LCDDEN                (1 <<  3)       /* A: LCD Data Enable */
+#define AT91_PB4_LCDCC         (1 <<  4)       /* A: LCD Contrast Control */
+#define AT91_PB4_LCDD2         (1 <<  4)       /* B: LCD Data Bus Bit 2 */
+#define AT91_PB5_LCDD0         (1 <<  5)       /* A: LCD Data Bus Bit 0 */
+#define AT91_PB5_LCDD3         (1 <<  5)       /* B: LCD Data Bus Bit 3 */
+#define AT91_PB6_LCDD1         (1 <<  6)       /* A: LCD Data Bus Bit 1 */
+#define AT91_PB6_LCDD4         (1 <<  6)       /* B: LCD Data Bus Bit 4 */
+#define AT91_PB7_LCDD2         (1 <<  7)       /* A: LCD Data Bus Bit 2 */
+#define AT91_PB7_LCDD5         (1 <<  7)       /* B: LCD Data Bus Bit 5 */
+#define AT91_PB8_LCDD3         (1 <<  8)       /* A: LCD Data Bus Bit 3 */
+#define AT91_PB8_LCDD6         (1 <<  8)       /* B: LCD Data Bus Bit 6 */
+#define AT91_PB9_LCDD4         (1 <<  9)       /* A: LCD Data Bus Bit 4 */
+#define AT91_PB9_LCDD7         (1 <<  9)       /* B: LCD Data Bus Bit 7 */
+#define AT91_PB10_LCDD5                (1 << 10)       /* A: LCD Data Bus Bit 5 */
+#define AT91_PB10_LCDD10       (1 << 10)       /* B: LCD Data Bus Bit 10 */
+#define AT91_PB11_LCDD6                (1 << 11)       /* A: LCD Data Bus Bit 6 */
+#define AT91_PB11_LCDD11       (1 << 11)       /* B: LCD Data Bus Bit 11 */
+#define AT91_PB12_LCDD7                (1 << 12)       /* A: LCD Data Bus Bit 7 */
+#define AT91_PB12_LCDD12       (1 << 12)       /* B: LCD Data Bus Bit 12 */
+#define AT91_PB13_LCDD8                (1 << 13)       /* A: LCD Data Bus Bit 8 */
+#define AT91_PB13_LCDD13       (1 << 13)       /* B: LCD Data Bus Bit 13 */
+#define AT91_PB14_LCDD9                (1 << 14)       /* A: LCD Data Bus Bit 9 */
+#define AT91_PB14_LCDD14       (1 << 14)       /* B: LCD Data Bus Bit 14 */
+#define AT91_PB15_LCDD10       (1 << 15)       /* A: LCD Data Bus Bit 10 */
+#define AT91_PB15_LCDD15       (1 << 15)       /* B: LCD Data Bus Bit 15 */
+#define AT91_PB16_LCDD11       (1 << 16)       /* A: LCD Data Bus Bit 11 */
+#define AT91_PB16_LCDD19       (1 << 16)       /* B: LCD Data Bus Bit 19 */
+#define AT91_PB17_LCDD12       (1 << 17)       /* A: LCD Data Bus Bit 12 */
+#define AT91_PB17_LCDD20       (1 << 17)       /* B: LCD Data Bus Bit 20 */
+#define AT91_PB18_LCDD13       (1 << 18)       /* A: LCD Data Bus Bit 13 */
+#define AT91_PB18_LCDD21       (1 << 18)       /* B: LCD Data Bus Bit 21 */
+#define AT91_PB19_LCDD14       (1 << 19)       /* A: LCD Data Bus Bit 14 */
+#define AT91_PB19_LCDD22       (1 << 19)       /* B: LCD Data Bus Bit 22 */
+#define AT91_PB20_LCDD15       (1 << 20)       /* A: LCD Data Bus Bit 15 */
+#define AT91_PB20_LCDD23       (1 << 20)       /* B: LCD Data Bus Bit 23 */
+#define AT91_PB21_TF0          (1 << 21)       /* A: SSC0 Transmit Frame Sync */
+#define AT91_PB21_LCDD16       (1 << 21)       /* B: LCD Data Bus Bit 16 */
+#define AT91_PB22_TK0          (1 << 22)       /* A: SSC0 Transmit Clock */
+#define AT91_PB22_LCDD17       (1 << 22)       /* B: LCD Data Bus Bit 17 */
+#define AT91_PB23_TD0          (1 << 23)       /* A: SSC0 Transmit Data */
+#define AT91_PB23_LCDD18       (1 << 23)       /* B: LCD Data Bus Bit 18 */
+#define AT91_PB24_RD0          (1 << 24)       /* A: SSC0 Receive Data */
+#define AT91_PB24_LCDD19       (1 << 24)       /* B: LCD Data Bus Bit 19 */
+#define AT91_PB25_RK0          (1 << 25)       /* A: SSC0 Receive Clock */
+#define AT91_PB25_LCDD20       (1 << 25)       /* B: LCD Data Bus Bit 20 */
+#define AT91_PB26_RF0          (1 << 26)       /* A: SSC0 Receive Frame Sync */
+#define AT91_PB26_LCDD21       (1 << 26)       /* B: LCD Data Bus Bit 21 */
+#define AT91_PB27_SPI1_NPCS1   (1 << 27)       /* A: SPI1 Peripheral Chip Select 1 */
+#define AT91_PB27_LCDD22       (1 << 27)       /* B: LCD Data Bus Bit 22 */
+#define AT91_PB28_SPI1_NPCS0   (1 << 28)       /* A: SPI1 Peripheral Chip Select 0 */
+#define AT91_PB28_LCDD23       (1 << 28)       /* B: LCD Data Bus Bit 23 */
+#define AT91_PB29_SPI1_SPCK    (1 << 29)       /* A: SPI1 Serial Clock */
+#define AT91_PB29_IRQ2         (1 << 29)       /* B: Interrupt input 2 */
+#define AT91_PB30_SPI1_MISO    (1 << 30)       /* A: SPI1 Master In Slave */
+#define AT91_PB30_IRQ1         (1 << 30)       /* B: Interrupt input 1 */
+#define AT91_PB31_SPI1_MOSI    (1 << 31)       /* A: SPI1 Master Out Slave */
+#define AT91_PB31_PCK2         (1 << 31)       /* B: PMC Programmable clock Output 2 */
+
+#define AT91_PC0_SMOE          (1 << 0)        /* A: SmartMedia Output Enable */
+#define AT91_PC0_NCS6          (1 << 0)        /* B: Chip Select 6 */
+#define AT91_PC1_SMWE          (1 << 1)        /* A: SmartMedia Write Enable */
+#define AT91_PC1_NCS7          (1 << 1)        /* B: Chip Select 7 */
+#define AT91_PC2_NWAIT         (1 << 2)        /* A: NWAIT */
+#define AT91_PC2_IRQ0          (1 << 2)        /* B: Interrupt input 0 */
+#define AT91_PC3_A25_CFRNW     (1 << 3)        /* A: Address Bus[25] / Compact Flash Read Not Write */
+#define AT91_PC4_NCS4_CFCS0    (1 << 4)        /* A: Chip Select 4 / CompactFlash Chip Select 0 */
+#define AT91_PC5_NCS5_CFCS1    (1 << 5)        /* A: Chip Select 5 / CompactFlash Chip Select 1 */
+#define AT91_PC6_CFCE1         (1 << 6)        /* A: CompactFlash Chip Enable 1 */
+#define AT91_PC7_CFCE2         (1 << 7)        /* A: CompactFlash Chip Enable 2 */
+#define AT91_PC8_TXD0          (1 << 8)        /* A: USART0 Transmit Data */
+#define AT91_PC8_PCK2          (1 << 8)        /* B: PMC Programmable clock Output 2 */
+#define AT91_PC9_RXD0          (1 << 9)        /* A: USART0 Receive Data */
+#define AT91_PC9_PCK3          (1 << 9)        /* B: PMC Programmable clock Output 3 */
+#define AT91_PC10_RTS0         (1 << 10)       /* A: USART0 Ready To Send */
+#define AT91_PC10_SCK0         (1 << 10)       /* B: USART0 Serial Clock */
+#define AT91_PC11_CTS0         (1 << 11)       /* A: USART0 Clear To Send */
+#define AT91_PC11_FIQ          (1 << 11)       /* B: AIC Fast Interrupt Input */
+#define AT91_PC12_TXD1         (1 << 12)       /* A: USART1 Transmit Data */
+#define AT91_PC12_NCS6         (1 << 12)       /* B: Chip Select 6 */
+#define AT91_PC13_RXD1         (1 << 13)       /* A: USART1 Receive Data */
+#define AT91_PC13_NCS7         (1 << 13)       /* B: Chip Select 7 */
+#define AT91_PC14_TXD2         (1 << 14)       /* A: USART2 Transmit Data */
+#define AT91_PC14_SPI1_NPCS2   (1 << 14)       /* B: SPI1 Peripheral Chip Select 2 */
+#define AT91_PC15_RXD2         (1 << 15)       /* A: USART2 Receive Data */
+#define AT91_PC15_SPI1_NPCS3   (1 << 15)       /* B: SPI1 Peripheral Chip Select 3 */
+#define AT91_PC16_D16          (1 << 16)       /* A: Data Bus [16] */
+#define AT91_PC16_TCLK0                (1 << 16)       /* B: Timer Counter 0 external clock input */
+#define AT91_PC17_D17          (1 << 17)       /* A: Data Bus [17] */
+#define AT91_PC17_TCLK1                (1 << 17)       /* B: Timer Counter 1 external clock input */
+#define AT91_PC18_D18          (1 << 18)       /* A: Data Bus [18] */
+#define AT91_PC18_TCLK2                (1 << 18)       /* B: Timer Counter 2 external clock input */
+#define AT91_PC19_D19          (1 << 19)       /* A: Data Bus [19] */
+#define AT91_PC19_TIOA0                (1 << 19)       /* B: Timer Counter 0 Multipurpose Timer I/O Pin A */
+#define AT91_PC20_D20          (1 << 20)       /* A: Data Bus [20] */
+#define AT91_PC20_TIOB0                (1 << 20)       /* B: Timer Counter 0 Multipurpose Timer I/O Pin B */
+#define AT91_PC21_D21          (1 << 21)       /* A: Data Bus [21] */
+#define AT91_PC21_TIOA1                (1 << 21)       /* B: Timer Counter 1 Multipurpose Timer I/O Pin A */
+#define AT91_PC22_D22          (1 << 22)       /* A: Data Bus [22] */
+#define AT91_PC22_TIOB1                (1 << 22)       /* B: Timer Counter 1 Multipurpose Timer I/O Pin B */
+#define AT91_PC23_D23          (1 << 23)       /* A: Data Bus [23] */
+#define AT91_PC23_TIOA2                (1 << 23)       /* B: Timer Counter 2 Multipurpose Timer I/O Pin A */
+#define AT91_PC24_D24          (1 << 24)       /* A: Data Bus [24] */
+#define AT91_PC24_TIOB2                (1 << 24)       /* B: Timer Counter 2 Multipurpose Timer I/O Pin B */
+#define AT91_PC25_D25          (1 << 25)       /* A: Data Bus [25] */
+#define AT91_PC25_TF2          (1 << 25)       /* B: SSC2 Transmit Frame Sync */
+#define AT91_PC26_D26          (1 << 26)       /* A: Data Bus [26] */
+#define AT91_PC26_TK2          (1 << 26)       /* B: SSC2 Transmit Clock */
+#define AT91_PC27_D27          (1 << 27)       /* A: Data Bus [27] */
+#define AT91_PC27_TD2          (1 << 27)       /* B: SSC2 Transmit Data */
+#define AT91_PC28_D28          (1 << 28)       /* A: Data Bus [28] */
+#define AT91_PC28_RD2          (1 << 28)       /* B: SSC2 Receive Data */
+#define AT91_PC29_D29          (1 << 29)       /* A: Data Bus [29] */
+#define AT91_PC29_RK2          (1 << 29)       /* B: SSC2 Receive Clock */
+#define AT91_PC30_D30          (1 << 30)       /* A: Data Bus [30] */
+#define AT91_PC30_RF2          (1 << 30)       /* B: SSC2 Receive Frame Sync */
+#define AT91_PC31_D31          (1 << 31)       /* A: Data Bus [31] */
+#define AT91_PC31_PCK1         (1 << 31)       /* B: PMC Programmable clock Output 1 */
+#endif
+
+#endif
diff --git a/include/asm-arm/arch-at91rm9200/at91sam9261_matrix.h b/include/asm-arm/arch-at91rm9200/at91sam9261_matrix.h
new file mode 100644 (file)
index 0000000..270a5dc
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91sam9261_matrix.h
+ *
+ * Memory Controllers (MATRIX, EBI) - System peripherals registers.
+ * Based on AT91SAM9261 datasheet revision D.
+ *
+ * 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.
+ */
+
+#ifndef AT91SAM9261_MATRIX_H
+#define AT91SAM9261_MATRIX_H
+
+#define AT91_MATRIX_MCFG       (AT91_MATRIX + 0x00)    /* Master Configuration Register */
+#define                AT91_MATRIX_RCB0        (1 << 0)                /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */
+#define                AT01_MATRIX_RCB1        (1 << 1)                /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */
+
+#define AT91_MATRIX_SCFG0      (AT91_MATRIX + 0x04)    /* Slave Configuration Register 0 */
+#define AT91_MATRIX_SCFG1      (AT91_MATRIX + 0x08)    /* Slave Configuration Register 1 */
+#define AT91_MATRIX_SCFG2      (AT91_MATRIX + 0x0C)    /* Slave Configuration Register 2 */
+#define AT91_MATRIX_SCFG3      (AT91_MATRIX + 0x10)    /* Slave Configuration Register 3 */
+#define AT91_MATRIX_SCFG4      (AT91_MATRIX + 0x14)    /* Slave Configuration Register 4 */
+#define                AT91_MATRIX_SLOT_CYCLE          (0xff << 0)     /* Maximum Number of Allowed Cycles for a Burst */
+#define                AT91_MATRIX_DEFMSTR_TYPE        (3    << 16)    /* Default Master Type */
+#define                        AT91_MATRIX_DEFMSTR_TYPE_NONE   (0 << 16)
+#define                        AT91_MATRIX_DEFMSTR_TYPE_LAST   (1 << 16)
+#define                        AT91_MATRIX_DEFMSTR_TYPE_FIXED  (2 << 16)
+#define                AT91_MATRIX_FIXED_DEFMSTR       (7    << 18)    /* Fixed Index of Default Master */
+
+#define AT91_MATRIX_TCR                (AT91_MATRIX + 0x24)    /* TCM Configuration Register */
+#define                AT91_MATRIX_ITCM_SIZE           (0xf << 0)      /* Size of ITCM enabled memory block */
+#define                        AT91_MATRIX_ITCM_0              (0 << 0)
+#define                        AT91_MATRIX_ITCM_16             (5 << 0)
+#define                        AT91_MATRIX_ITCM_32             (6 << 0)
+#define                        AT91_MATRIX_ITCM_64             (7 << 0)
+#define                AT91_MATRIX_DTCM_SIZE           (0xf << 4)      /* Size of DTCM enabled memory block */
+#define                        AT91_MATRIX_DTCM_0              (0 << 4)
+#define                        AT91_MATRIX_DTCM_16             (5 << 4)
+#define                        AT91_MATRIX_DTCM_32             (6 << 4)
+#define                        AT91_MATRIX_DTCM_64             (7 << 4)
+
+#define AT91_MATRIX_EBICSA     (AT91_MATRIX + 0x30)    /* EBI Chip Select Assignment Register */
+#define                AT91_MATRIX_CS1A                (1 << 1)        /* Chip Select 1 Assignment */
+#define                AT91_MATRIX_CS1A_SMC            (0 << 1)
+#define                AT91_MATRIX_CS1A_SDRAMC         (1 << 1)
+#define                AT91_MATRIX_CS3A                (1 << 3)        /* Chip Select 3 Assignment */
+#define                        AT91_MATRIX_CS3A_SMC            (0 << 3)
+#define                        AT91_MATRIX_CS3A_SMC_SMARTMEDIA (1 << 3)
+#define                AT91_MATRIX_CS4A                (1 << 4)        /* Chip Select 4 Assignment */
+#define                        AT91_MATRIX_CS4A_SMC            (0 << 4)
+#define                        AT91_MATRIX_CS4A_SMC_CF1        (1 << 4)
+#define                AT91_MATRIX_CS5A                (1 << 5)        /* Chip Select 5 Assignment */
+#define                        AT91_MATRIX_CS5A_SMC            (0 << 5)
+#define                        AT91_MATRIX_CS5A_SMC_CF2        (1 << 5)
+#define                AT91_MATRIX_DBPUC               (1 << 8)        /* Data Bus Pull-up Configuration */
+
+#define AT91_MATRIX_USBPUCR    (AT91_MATRIX + 0x34)    /* USB Pad Pull-Up Control Register */
+#define                AT91_MATRIX_USBPUCR_PUON        (1 << 30)       /* USB Device PAD Pull-up Enable */
+
+#endif
diff --git a/include/asm-arm/arch-at91rm9200/at91sam926x_mc.h b/include/asm-arm/arch-at91rm9200/at91sam926x_mc.h
new file mode 100644 (file)
index 0000000..7d94968
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91sam926x_mc.h
+ *
+ * Memory Controllers (SMC, SDRAMC) - System peripherals registers.
+ * Based on AT91SAM9261 datasheet revision D.
+ *
+ * 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.
+ */
+
+#ifndef AT91SAM926x_MC_H
+#define AT91SAM926x_MC_H
+
+/* SDRAM Controller (SDRAMC) registers */
+#define AT91_SDRAMC_MR         (AT91_SDRAMC + 0x00)    /* SDRAM Controller Mode Register */
+#define                AT91_SDRAMC_MODE        (0xf << 0)              /* Command Mode */
+#define                        AT91_SDRAMC_MODE_NORMAL         0
+#define                        AT91_SDRAMC_MODE_NOP            1
+#define                        AT91_SDRAMC_MODE_PRECHARGE      2
+#define                        AT91_SDRAMC_MODE_LMR            3
+#define                        AT91_SDRAMC_MODE_REFRESH        4
+#define                        AT91_SDRAMC_MODE_EXT_LMR        5
+#define                        AT91_SDRAMC_MODE_DEEP           6
+
+#define AT91_SDRAMC_TR         (AT91_SDRAMC + 0x04)    /* SDRAM Controller Refresh Timer Register */
+#define                AT91_SDRAMC_COUNT       (0xfff << 0)            /* Refresh Timer Counter */
+
+#define AT91_SDRAMC_CR         (AT91_SDRAMC + 0x08)    /* SDRAM Controller Configuration Register */
+#define                AT91_SDRAMC_NC          (3 << 0)                /* Number of Column Bits */
+#define                        AT91_SDRAMC_NC_8        (0 << 0)
+#define                        AT91_SDRAMC_NC_9        (1 << 0)
+#define                        AT91_SDRAMC_NC_10       (2 << 0)
+#define                        AT91_SDRAMC_NC_11       (3 << 0)
+#define        AT91_SDRAMC_NR          (3 << 2)                /* Number of Row Bits */
+#define                        AT91_SDRAMC_NR_11       (0 << 2)
+#define                        AT91_SDRAMC_NR_12       (1 << 2)
+#define                        AT91_SDRAMC_NR_13       (2 << 2)
+#define        AT91_SDRAMC_NB          (1 << 4)                /* Number of Banks */
+#define                        AT91_SDRAMC_NB_2        (0 << 4)
+#define                AT91_SDRAMC_NB_4        (1 << 4)
+#define        AT91_SDRAMC_CAS         (3 << 5)                /* CAS Latency */
+#define                        AT91_SDRAMC_CAS_1       (1 << 5)
+#define                        AT91_SDRAMC_CAS_2       (2 << 5)
+#define                        AT91_SDRAMC_CAS_3       (3 << 5)
+#define                AT91_SDRAMC_DBW         (1 << 7)                /* Data Bus Width */
+#define                        AT91_SDRAMC_DBW_32      (0 << 7)
+#define                        AT91_SDRAMC_DBW_16      (1 << 7)
+#define                AT91_SDRAMC_TWR         (0xf <<  8)             /* Write Recovery Delay */
+#define                AT91_SDRAMC_TRC         (0xf << 12)             /* Row Cycle Delay */
+#define                AT91_SDRAMC_TRP         (0xf << 16)             /* Row Precharge Delay */
+#define                AT91_SDRAMC_TRCD        (0xf << 20)             /* Row to Column Delay */
+#define                AT91_SDRAMC_TRAS        (0xf << 24)             /* Active to Precharge Delay */
+#define                AT91_SDRAMC_TXSR        (0xf << 28)             /* Exit Self Refresh to Active Delay */
+
+#define AT91_SDRAMC_LPR                (AT91_SDRAMC + 0x10)    /* SDRAM Controller Low Power Register */
+#define                AT91_SDRAMC_LPCB                (3 << 0)        /* Low-power Configurations */
+#define                        AT91_SDRAMC_LPCB_DISABLE                0
+#define                        AT91_SDRAMC_LPCB_SELF_REFRESH           1
+#define                        AT91_SDRAMC_LPCB_POWER_DOWN             2
+#define                        AT91_SDRAMC_LPCB_DEEP_POWER_DOWN        3
+#define                AT91_SDRAMC_PASR                (7 << 4)        /* Partial Array Self Refresh */
+#define                AT91_SDRAMC_TCSR                (3 << 8)        /* Temperature Compensated Self Refresh */
+#define                AT91_SDRAMC_DS                  (3 << 10)       /* Drive Strenght */
+#define                AT91_SDRAMC_TIMEOUT             (3 << 12)       /* Time to define when Low Power Mode is enabled */
+#define                        AT91_SDRAMC_TIMEOUT_0_CLK_CYCLES        (0 << 12)
+#define                        AT91_SDRAMC_TIMEOUT_64_CLK_CYCLES       (1 << 12)
+#define                        AT91_SDRAMC_TIMEOUT_128_CLK_CYCLES      (2 << 12)
+
+#define AT91_SDRAMC_IER                (AT91_SDRAMC + 0x14)    /* SDRAM Controller Interrupt Enable Register */
+#define AT91_SDRAMC_IDR                (AT91_SDRAMC + 0x18)    /* SDRAM Controller Interrupt Disable Register */
+#define AT91_SDRAMC_IMR                (AT91_SDRAMC + 0x1C)    /* SDRAM Controller Interrupt Mask Register */
+#define AT91_SDRAMC_ISR                (AT91_SDRAMC + 0x20)    /* SDRAM Controller Interrupt Status Register */
+#define                AT91_SDRAMC_RES         (1 << 0)                /* Refresh Error Status */
+
+#define AT91_SDRAMC_MDR                (AT91_SDRAMC + 0x24)    /* SDRAM Memory Device Register */
+#define                AT91_SDRAMC_MD          (3 << 0)                /* Memory Device Type */
+#define                        AT91_SDRAMC_MD_SDRAM            0
+#define                        AT91_SDRAMC_MD_LOW_POWER_SDRAM  1
+
+
+/* Static Memory Controller (SMC) registers */
+#define AT91_SMC_SETUP(n)      (AT91_SMC + 0x00 + ((n)*0x10))  /* Setup Register for CS n */
+#define                AT91_SMC_NWESETUP       (0x3f << 0)                     /* NWE Setup Length */
+#define                        AT91_SMC_NWESETUP_(x)   ((x) << 0)
+#define                AT91_SMC_NCS_WRSETUP    (0x3f << 8)                     /* NCS Setup Length in Write Access */
+#define                        AT91_SMC_NCS_WRSETUP_(x)        ((x) << 8)
+#define                AT91_SMC_NRDSETUP       (0x3f << 16)                    /* NRD Setup Length */
+#define                        AT91_SMC_NRDSETUP_(x)   ((x) << 16)
+#define                AT91_SMC_NCS_RDSETUP    (0x3f << 24)                    /* NCS Setup Length in Read Access */
+#define                        AT91_SMC_NCS_RDSETUP_(x)        ((x) << 24)
+
+#define AT91_SMC_PULSE(n)      (AT91_SMC + 0x04 + ((n)*0x10))  /* Pulse Register for CS n */
+#define                AT91_SMC_NWEPULSE       (0x7f <<  0)                    /* NWE Pulse Length */
+#define                        AT91_SMC_NWEPULSE_(x)   ((x) << 0)
+#define                AT91_SMC_NCS_WRPULSE    (0x7f <<  8)                    /* NCS Pulse Length in Write Access */
+#define                        AT91_SMC_NCS_WRPULSE_(x)((x) << 8)
+#define                AT91_SMC_NRDPULSE       (0x7f << 16)                    /* NRD Pulse Length */
+#define                        AT91_SMC_NRDPULSE_(x)   ((x) << 16)
+#define                AT91_SMC_NCS_RDPULSE    (0x7f << 24)                    /* NCS Pulse Length in Read Access */
+#define                        AT91_SMC_NCS_RDPULSE_(x)((x) << 24)
+
+#define AT91_SMC_CYCLE(n)      (AT91_SMC + 0x08 + ((n)*0x10))  /* Cycle Register for CS n */
+#define                AT91_SMC_NWECYCLE       (0x1ff << 0 )                   /* Total Write Cycle Length */
+#define                        AT91_SMC_NWECYCLE_(x)   ((x) << 0)
+#define                AT91_SMC_NRDCYCLE       (0x1ff << 16)                   /* Total Read Cycle Length */
+#define                        AT91_SMC_NRDCYCLE_(x)   ((x) << 16)
+
+#define AT91_SMC_MODE(n)       (AT91_SMC + 0x0c + ((n)*0x10))  /* Mode Register for CS n */
+#define                AT91_SMC_READMODE       (1 <<  0)                       /* Read Mode */
+#define                AT91_SMC_WRITEMODE      (1 <<  1)                       /* Write Mode */
+#define                AT91_SMC_EXNWMODE       (3 <<  5)                       /* NWAIT Mode */
+#define                        AT91_SMC_EXNWMODE_DISABLE       (0 << 5)
+#define                        AT91_SMC_EXNWMODE_FROZEN        (2 << 5)
+#define                        AT91_SMC_EXNWMODE_READY         (3 << 5)
+#define                AT91_SMC_BAT            (1 <<  8)                       /* Byte Access Type */
+#define                        AT91_SMC_BAT_SELECT             (0 << 8)
+#define                        AT91_SMC_BAT_WRITE              (1 << 8)
+#define                AT91_SMC_DBW            (3 << 12)                       /* Data Bus Width */
+#define                        AT91_SMC_DBW_8                  (0 << 12)
+#define                        AT91_SMC_DBW_16                 (1 << 12)
+#define                        AT91_SMC_DBW_32                 (2 << 12)
+#define                AT91_SMC_TDF            (0xf << 16)                     /* Data Float Time. */
+#define                        AT91_SMC_TDF_(x)                ((x) << 16)
+#define                AT91_SMC_TDFMODE        (1 << 20)                       /* TDF Optimization - Enabled */
+#define                AT91_SMC_PMEN           (1 << 24)                       /* Page Mode Enabled */
+#define                AT91_SMC_PS             (3 << 28)                       /* Page Size */
+#define                        AT91_SMC_PS_4                   (0 << 28)
+#define                        AT91_SMC_PS_8                   (1 << 28)
+#define                        AT91_SMC_PS_16                  (2 << 28)
+#define                        AT91_SMC_PS_32                  (3 << 28)
+
+#endif
index 3cc9aec80f9d50320dc2231f314d243a4040287f..768e0fc6aa2f2d6b08250ec67f3346f5b5d5a4d6 100644 (file)
@@ -48,13 +48,14 @@ struct at91_cf_data {
        u8      det_pin;                /* Card detect */
        u8      vcc_pin;                /* power switching */
        u8      rst_pin;                /* card reset */
+       u8      chipselect;             /* EBI Chip Select number */
 };
 extern void __init at91_add_device_cf(struct at91_cf_data *data);
 
  /* MMC / SD */
 struct at91_mmc_data {
        u8              det_pin;        /* card detect IRQ */
-       unsigned        is_b:1;         /* uses B side (vs A) */
+       unsigned        slot_b:1;       /* uses Slot B */
        unsigned        wire4:1;        /* (SD) supports DAT0..DAT3 */
        u8              wp_pin;         /* (SD) writeprotect detect */
        u8              vcc_pin;        /* power switching (high == on) */
@@ -81,7 +82,8 @@ struct at91_nand_data {
        u8              rdy_pin;        /* ready/busy */
        u8              ale;            /* address line number connected to ALE */
        u8              cle;            /* address line number connected to CLE */
-        struct mtd_partition* (*partition_info)(int, int*);
+       u8              bus_width_16;   /* buswidth is 16 bit */
+       struct mtd_partition* (*partition_info)(int, int*);
 };
 extern void __init at91_add_device_nand(struct at91_nand_data *data);
 
diff --git a/include/asm-arm/arch-at91rm9200/cpu.h b/include/asm-arm/arch-at91rm9200/cpu.h
new file mode 100644 (file)
index 0000000..6f8d09b
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * include/asm-arm/arch-at91rm9200/cpu.h
+ *
+ *  Copyright (C) 2006 SAN People
+ *
+ * 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.
+ *
+ */
+
+#ifndef __ASM_ARCH_CPU_H
+#define __ASM_ARCH_CPU_H
+
+#include <asm/hardware.h>
+#include <asm/arch/at91_dbgu.h>
+
+
+#define ARCH_ID_AT91RM9200     0x09290780
+#define ARCH_ID_AT91SAM9260    0x019803a0
+#define ARCH_ID_AT91SAM9261    0x019703a0
+
+
+static inline unsigned long at91_cpu_identify(void)
+{
+       return (at91_sys_read(AT91_DBGU_CIDR) & ~AT91_CIDR_VERSION);
+}
+
+
+#ifdef CONFIG_ARCH_AT91RM9200
+#define cpu_is_at91rm9200()    (at91_cpu_identify() == ARCH_ID_AT91RM9200)
+#else
+#define cpu_is_at91rm9200()    (0)
+#endif
+
+#ifdef CONFIG_ARCH_AT91SAM9260
+#define cpu_is_at91sam9260()   (at91_cpu_identify() == ARCH_ID_AT91SAM9260)
+#else
+#define cpu_is_at91sam9260()   (0)
+#endif
+
+#ifdef CONFIG_ARCH_AT91SAM9261
+#define cpu_is_at91sam9261()   (at91_cpu_identify() == ARCH_ID_AT91SAM9261)
+#else
+#define cpu_is_at91sam9261()   (0)
+#endif
+
+#endif
index f496b54c4c3e6bc57c0cfa8734f6f7f6bb126307..85cdadf26634af030e88334cfe2e88e9c776d843 100644 (file)
@@ -12,6 +12,7 @@
 */
 
 #include <asm/hardware.h>
+#include <asm/arch/at91_dbgu.h>
 
        .macro  addruart,rx
        mrc     p15, 0, \rx, c1, c0
index 61a326e9490903881e95974e347547c1719c0039..57248a796472215ba376cdf59763c19b92ec0fd8 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <asm/hardware.h>
+#include <asm/arch/at91_aic.h>
 
        .macro  disable_fiq
        .endm
index 9ca4cc9c0b2e707b4f155c9053bde7571ac981f8..9ea5bfe06320ad908cc6b4e46023ddcbe1263146 100644 (file)
 
 #include <asm/sizes.h>
 
+#if defined(CONFIG_ARCH_AT91RM9200)
 #include <asm/arch/at91rm9200.h>
-#include <asm/arch/at91rm9200_sys.h>
+#elif defined(CONFIG_ARCH_AT91SAM9260)
+#include <asm/arch/at91sam9260.h>
+#elif defined(CONFIG_ARCH_AT91SAM9261)
+#include <asm/arch/at91sam9261.h>
+#else
+#error "Unsupported AT91 processor"
+#endif
+
 
 /*
  * Remap the peripherals from address 0xFFFA0000 .. 0xFFFFFFFF
  * Virtual to Physical Address mapping for IO devices.
  */
 #define AT91_VA_BASE_SYS       AT91_IO_P2V(AT91_BASE_SYS)
-#define AT91_VA_BASE_SPI       AT91_IO_P2V(AT91RM9200_BASE_SPI)
 #define AT91_VA_BASE_EMAC      AT91_IO_P2V(AT91RM9200_BASE_EMAC)
-#define AT91_VA_BASE_TWI       AT91_IO_P2V(AT91RM9200_BASE_TWI)
-#define AT91_VA_BASE_MCI       AT91_IO_P2V(AT91RM9200_BASE_MCI)
-#define AT91_VA_BASE_UDP       AT91_IO_P2V(AT91RM9200_BASE_UDP)
 
  /* Internal SRAM is mapped below the IO devices */
-#define AT91_SRAM_VIRT_BASE    (AT91_IO_VIRT_BASE - AT91RM9200_SRAM_SIZE)
+#define AT91_SRAM_MAX          SZ_1M
+#define AT91_VIRT_BASE         (AT91_IO_VIRT_BASE - AT91_SRAM_MAX)
 
 /* Serial ports */
-#define ATMEL_MAX_UART         5               /* 4 USART3's and one DBGU port */
-
-/* FLASH */
-#define AT91_FLASH_BASE                0x10000000      /* NCS0: Flash physical base address */
+#define ATMEL_MAX_UART         7               /* 6 USART3's and one DBGU port (SAM9260) */
+
+/* External Memory Map */
+#define AT91_CHIPSELECT_0      0x10000000
+#define AT91_CHIPSELECT_1      0x20000000
+#define AT91_CHIPSELECT_2      0x30000000
+#define AT91_CHIPSELECT_3      0x40000000
+#define AT91_CHIPSELECT_4      0x50000000
+#define AT91_CHIPSELECT_5      0x60000000
+#define AT91_CHIPSELECT_6      0x70000000
+#define AT91_CHIPSELECT_7      0x80000000
 
 /* SDRAM */
-#define AT91_SDRAM_BASE                0x20000000      /* NCS1: SDRAM physical base address */
-
-/* SmartMedia */
-#define AT91_SMARTMEDIA_BASE   0x40000000      /* NCS3: Smartmedia physical base address */
-
-/* Compact Flash */
-#define AT91_CF_BASE           0x50000000      /* NCS4-NCS6: Compact Flash physical base address */
+#define AT91_SDRAM_BASE                AT91_CHIPSELECT_1
 
 /* Clocks */
 #define AT91_SLOW_CLOCK                32768           /* slow clock */
index 763cb96c418bac0f6bebc32dbb40c55f2cc1f8e9..c0679eaefaf2587013d2a280565dcce13754d7ae 100644 (file)
@@ -21,6 +21,8 @@
 #ifndef __ASM_ARCH_IRQS_H
 #define __ASM_ARCH_IRQS_H
 
+#include <asm/arch/at91_aic.h>
+
 #define NR_AIC_IRQS 32
 
 
index 8a2ff472e4cff3e067dbaeb59f5695232c2109a0..9c67130603b2896195649648f4869a749d5c5b0b 100644 (file)
@@ -22,6 +22,8 @@
 #define __ASM_ARCH_SYSTEM_H
 
 #include <asm/hardware.h>
+#include <asm/arch/at91_st.h>
+#include <asm/arch/at91_dbgu.h>
 
 static inline void arch_idle(void)
 {
@@ -39,21 +41,13 @@ static inline void arch_idle(void)
        cpu_do_idle();
 }
 
-static inline void arch_reset(char mode)
-{
-       /*
-        * Perform a hardware reset with the use of the Watchdog timer.
-        */
-       at91_sys_write(AT91_ST_WDMR, AT91_ST_RSTEN | AT91_ST_EXTEN | 1);
-       at91_sys_write(AT91_ST_CR, AT91_ST_WDRST);
-}
-
-#define ARCH_ID_AT91RM9200     0x09200080
-#define ARCH_ID_AT91SAM9261    0x019000a0
+void (*at91_arch_reset)(void);
 
-static inline unsigned long arch_identify(void)
+static inline void arch_reset(char mode)
 {
-       return at91_sys_read(AT91_DBGU_CIDR) & (AT91_CIDR_EPROC | AT91_CIDR_ARCH);
+       /* call the CPU-specific reset function */
+       if (at91_arch_reset)
+               (at91_arch_reset)();
 }
 
 #endif
index 88687cefe6ebdeae179adc38d03800d7ced22fcc..faeca45a8d446f999badcb3a9fac7c95e4b9dfb4 100644 (file)
 
 #include <asm/hardware.h>
 
+#if defined(CONFIG_ARCH_AT91RM9200)
+
 #define CLOCK_TICK_RATE                (AT91_SLOW_CLOCK)
 
+#elif defined(CONFIG_ARCH_AT91SAM9260) || defined(CONFIG_ARCH_AT91SAM9261)
+
+#define AT91SAM9_MASTER_CLOCK  99300000
+#define CLOCK_TICK_RATE                (AT91SAM9_MASTER_CLOCK/16)
+
+#endif
+
 #endif
index ec7811ab0a52805f97840aa50fe796ea81e6d4a1..34b4b93fa01523ad088fa9fbf699b80b7117cce0 100644 (file)
 #define __ASM_ARCH_UNCOMPRESS_H
 
 #include <asm/hardware.h>
+#include <asm/arch/at91_dbgu.h>
 
 /*
  * The following code assumes the serial port has already been
- * initialized by the bootloader.  We search for the first enabled
- * port in the most probable order.  If you didn't setup a port in
+ * initialized by the bootloader.  If you didn't setup a port in
  * your bootloader then nothing will appear (which might be desired).
  *
  * This does not append a newline
index 4c367eb57f47c9dccc242612a71702951def3bfb..0a23b8c562b94f6033bef6c864bce85154e9b21b 100644 (file)
@@ -21,6 +21,6 @@
 #ifndef __ASM_ARCH_VMALLOC_H
 #define __ASM_ARCH_VMALLOC_H
 
-#define VMALLOC_END            (AT91_SRAM_VIRT_BASE & PGDIR_MASK)
+#define VMALLOC_END            (AT91_VIRT_BASE & PGDIR_MASK)
 
 #endif
index c6e8dcf674def5111a990215b9a11b1ea3f94faf..42768cc8bfb41aecf34eda2a5130b72a3fcdd94b 100644 (file)
  * memory bank.  For those systems, simply undefine CONFIG_DISCONTIGMEM.
  */
 
-#ifdef CONFIG_DISCONTIGMEM
+/*
+ * The PS7211 allows up to 256MB max per DRAM bank, but the EDB7211
+ * uses only one of the two banks (bank #1).  However, even within
+ * bank #1, memory is discontiguous.
+ *
+ * The EDB7211 has two 8MB DRAM areas with 8MB of empty space between
+ * them, so we use 24 for the node max shift to get 16MB node sizes.
+ */
+
 /*
  * 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
  *     node 2:  0xd0000000 - 0xd7ffffff
  *     node 3:  0xd8000000 - 0xdfffffff
  */
-
-/*
- * Given a kernel address, find the home node of the underlying memory.
- */
-#define KVADDR_TO_NID(addr) \
-               (((unsigned long)(addr) - PAGE_OFFSET) >> NODE_MAX_MEM_SHIFT)
-
-/*
- * Given a page frame number, convert it to a node id.
- */
-#define PFN_TO_NID(pfn) \
-       (((pfn) - PHYS_PFN_OFFSET) >> (NODE_MAX_MEM_SHIFT - PAGE_SHIFT))
-
-/*
- * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
- * and returns the mem_map of that node.
- */
-#define ADDR_TO_MAPBASE(kaddr) \
-                       NODE_MEM_MAP(KVADDR_TO_NID((unsigned long)(kaddr)))
-
-#define PFN_TO_MAPBASE(pfn)    NODE_MEM_MAP(PFN_TO_NID(pfn))
-
-/*
- * Given a kaddr, LOCAL_MAR_NR finds the owning node of the memory
- * and returns the index corresponding to the appropriate page in the
- * node's mem_map.
- */
-#define LOCAL_MAP_NR(addr) \
-       (((unsigned long)(addr) & (NODE_MAX_MEM_SIZE - 1)) >> PAGE_SHIFT)
-
-/*
- * The PS7211 allows up to 256MB max per DRAM bank, but the EDB7211
- * uses only one of the two banks (bank #1).  However, even within
- * bank #1, memory is discontiguous.
- *
- * The EDB7211 has two 8MB DRAM areas with 8MB of empty space between
- * them, so we use 24 for the node max shift to get 16MB node sizes.
- */
-#define NODE_MAX_MEM_SHIFT     24
-#define NODE_MAX_MEM_SIZE      (1<<NODE_MAX_MEM_SHIFT)
-
-#endif /* CONFIG_DISCONTIGMEM */
+#define NODE_MEM_SIZE_BITS     24
 
 #endif
 
index 8c91674706b1f276e4a08e0f3ba0b73a1a8ef24b..e22ba789546cd8a317e2eb3ae310a8a22dc4931f 100644 (file)
@@ -21,7 +21,6 @@
 #ifndef __ASM_ARCH_TIMEX_H
 #define __ASM_ARCH_TIMEX_H
 
-#include <asm/hardware.h>
-#define CLOCK_TICK_RATE                (CLK32)
+#define CLOCK_TICK_RATE                (16000000)
 
 #endif
diff --git a/include/asm-arm/arch-iop13xx/debug-macro.S b/include/asm-arm/arch-iop13xx/debug-macro.S
new file mode 100644 (file)
index 0000000..788b4e3
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * include/asm-arm/arch-iop13xx/debug-macro.S
+ *
+ * Debugging macro include header
+ *
+ * Copyright (C) 1994-1999 Russell King
+ * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
+ *
+ * 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.
+ */
+
+       .macro  addruart, rx
+       mrc     p15, 0, \rx, c1, c0
+       tst     \rx, #1                 @ mmu enabled?
+       moveq   \rx, #0xff000000        @ physical
+       orreq   \rx, \rx, #0x00d80000
+       movne   \rx, #0xfe000000        @ virtual
+       orrne   \rx, \rx, #0x00e80000
+       orr     \rx, \rx, #0x00002300
+       orr     \rx, \rx, #0x00000040
+       .endm
+
+#define UART_SHIFT     2
+#include <asm/hardware/debug-8250.S>
diff --git a/include/asm-arm/arch-iop13xx/dma.h b/include/asm-arm/arch-iop13xx/dma.h
new file mode 100644 (file)
index 0000000..2e15da5
--- /dev/null
@@ -0,0 +1,3 @@
+#ifndef _IOP13XX_DMA_H
+#define _IOP13XX_DMA_H_
+#endif
diff --git a/include/asm-arm/arch-iop13xx/entry-macro.S b/include/asm-arm/arch-iop13xx/entry-macro.S
new file mode 100644 (file)
index 0000000..94c5028
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * iop13xx low level irq macros
+ * Copyright (c) 2005-2006, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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.
+ *
+ */
+       .macro  disable_fiq
+       .endm
+
+       /*
+        * Note: a 1-cycle window exists where iintvec will return the value
+        * of iintbase, so we explicitly check for "bad zeros"
+        */
+       .macro  get_irqnr_and_base, irqnr, irqstat, base, tmp
+       mrc     p15, 0, \tmp, c15, c1, 0
+       orr     \tmp, \tmp, #(1 << 6)
+       mcr     p15, 0, \tmp, c15, c1, 0        @ Enable cp6 access
+
+       mrc     p6, 0, \irqnr, c3, c2, 0        @ Read IINTVEC
+       cmp     \irqnr, #0
+       mrceq   p6, 0, \irqnr, c3, c2, 0        @ Re-read on potentially bad zero
+       adds    \irqstat, \irqnr, #1            @ Check for 0xffffffff
+       movne   \irqnr, \irqnr, lsr #2          @ Convert to irqnr
+
+       biceq   \tmp, \tmp, #(1 << 6)
+       mcreq   p15, 0, \tmp, c15, c1, 0        @ Disable cp6 access if no more interrupts
+       .endm
diff --git a/include/asm-arm/arch-iop13xx/hardware.h b/include/asm-arm/arch-iop13xx/hardware.h
new file mode 100644 (file)
index 0000000..8e1d562
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef __ASM_ARCH_HARDWARE_H
+#define __ASM_ARCH_HARDWARE_H
+#include <asm/types.h>
+
+#define pcibios_assign_all_busses() 1
+
+#ifndef __ASSEMBLY__
+extern unsigned long iop13xx_pcibios_min_io;
+extern unsigned long iop13xx_pcibios_min_mem;
+extern u16 iop13xx_dev_id(void);
+extern void iop13xx_set_atu_mmr_bases(void);
+#endif
+
+#define PCIBIOS_MIN_IO      (iop13xx_pcibios_min_io)
+#define PCIBIOS_MIN_MEM     (iop13xx_pcibios_min_mem)
+
+/*
+ * Generic chipset bits
+ *
+ */
+#include "iop13xx.h"
+
+/*
+ * Board specific bits
+ */
+#include "iq81340.h"
+
+#endif  /* _ASM_ARCH_HARDWARE_H */
diff --git a/include/asm-arm/arch-iop13xx/io.h b/include/asm-arm/arch-iop13xx/io.h
new file mode 100644 (file)
index 0000000..db6de24
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * iop13xx custom ioremap implementation
+ * Copyright (c) 2005-2006, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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.
+ *
+ */
+#ifndef __ASM_ARM_ARCH_IO_H
+#define __ASM_ARM_ARCH_IO_H
+
+#define IO_SPACE_LIMIT 0xffffffff
+
+#define __io(a)      (a)
+#define __mem_pci(a) (a)
+#define __mem_isa(a) (a)
+
+extern void __iomem * __ioremap(unsigned long, size_t, unsigned long);
+extern void __iomem *__iop13xx_ioremap(unsigned long cookie, size_t size,
+       unsigned long flags);
+extern void __iop13xx_iounmap(void __iomem *addr);
+
+extern u32 iop13xx_atue_mem_base;
+extern u32 iop13xx_atux_mem_base;
+extern size_t iop13xx_atue_mem_size;
+extern size_t iop13xx_atux_mem_size;
+
+#define __arch_ioremap(a, s, f) __iop13xx_ioremap(a, s, f)
+#define __arch_iounmap(a)       __iop13xx_iounmap(a)
+
+#endif
diff --git a/include/asm-arm/arch-iop13xx/iop13xx.h b/include/asm-arm/arch-iop13xx/iop13xx.h
new file mode 100644 (file)
index 0000000..a88522a
--- /dev/null
@@ -0,0 +1,492 @@
+#ifndef _IOP13XX_HW_H_
+#define _IOP13XX_HW_H_
+
+#ifndef __ASSEMBLY__
+/* The ATU offsets can change based on the strapping */
+extern u32 iop13xx_atux_pmmr_offset;
+extern u32 iop13xx_atue_pmmr_offset;
+void iop13xx_init_irq(void);
+void iop13xx_map_io(void);
+void iop13xx_platform_init(void);
+void iop13xx_init_irq(void);
+void iop13xx_init_time(unsigned long tickrate);
+unsigned long iop13xx_gettimeoffset(void);
+
+/* handle cp6 access
+ * to do: handle access in entry-armv5.S and unify with
+ * the iop3xx implementation
+ * note: use iop13xx_cp6_enable_irq_save and iop13xx_cp6_irq_restore (irq.h)
+ * when interrupts are enabled
+ */
+static inline unsigned long iop13xx_cp6_save(void)
+{
+       u32 temp, cp_flags;
+
+       asm volatile (
+               "mrc    p15, 0, %1, c15, c1, 0\n\t"
+               "orr    %0, %1, #(1 << 6)\n\t"
+               "mcr    p15, 0, %0, c15, c1, 0\n\t"
+               : "=r" (temp), "=r"(cp_flags));
+
+       return cp_flags;
+}
+
+static inline void iop13xx_cp6_restore(unsigned long cp_flags)
+{
+       asm volatile (
+               "mcr    p15, 0, %0, c15, c1, 0\n\t"
+               : : "r" (cp_flags) );
+}
+
+/* CPUID CP6 R0 Page 0 */
+static inline int iop13xx_cpu_id(void)
+{
+       int id;
+       asm volatile("mrc p6, 0, %0, c0, c0, 0":"=r" (id));
+       return id;
+}
+
+#endif
+
+/*
+ * IOP13XX I/O and Mem space regions for PCI autoconfiguration
+ */
+#define IOP13XX_MAX_RAM_SIZE    0x80000000UL  /* 2GB */
+#define IOP13XX_PCI_OFFSET      IOP13XX_MAX_RAM_SIZE
+
+/* PCI MAP
+ * 0x0000.0000 - 0x8000.0000           1:1 mapping with Physical RAM
+ * 0x8000.0000 - 0x8800.0000           PCIX/PCIE memory window (128MB)
+*/
+#define IOP13XX_PCIX_IO_WINDOW_SIZE   0x10000UL
+#define IOP13XX_PCIX_LOWER_IO_PA      0xfffb0000UL
+#define IOP13XX_PCIX_LOWER_IO_VA      0xfec60000UL
+#define IOP13XX_PCIX_LOWER_IO_BA      0x0fff0000UL
+#define IOP13XX_PCIX_UPPER_IO_PA      (IOP13XX_PCIX_LOWER_IO_PA +\
+                                      IOP13XX_PCIX_IO_WINDOW_SIZE - 1)
+#define IOP13XX_PCIX_UPPER_IO_VA      (IOP13XX_PCIX_LOWER_IO_VA +\
+                                      IOP13XX_PCIX_IO_WINDOW_SIZE - 1)
+#define IOP13XX_PCIX_IO_OFFSET        (IOP13XX_PCIX_LOWER_IO_VA -\
+                                      IOP13XX_PCIX_LOWER_IO_BA)
+#define IOP13XX_PCIX_IO_PHYS_TO_VIRT(addr) (u32) ((u32) addr -\
+                                          (IOP13XX_PCIX_LOWER_IO_PA\
+                                          - IOP13XX_PCIX_LOWER_IO_VA))
+
+#define IOP13XX_PCIX_MEM_PHYS_OFFSET  0x100000000ULL
+#define IOP13XX_PCIX_MEM_WINDOW_SIZE  0x3a000000UL
+#define IOP13XX_PCIX_LOWER_MEM_BA     (PHYS_OFFSET + IOP13XX_PCI_OFFSET)
+#define IOP13XX_PCIX_LOWER_MEM_PA     (IOP13XX_PCIX_MEM_PHYS_OFFSET +\
+                                      IOP13XX_PCIX_LOWER_MEM_BA)
+#define IOP13XX_PCIX_UPPER_MEM_PA     (IOP13XX_PCIX_LOWER_MEM_PA +\
+                                      IOP13XX_PCIX_MEM_WINDOW_SIZE - 1)
+#define IOP13XX_PCIX_UPPER_MEM_BA     (IOP13XX_PCIX_LOWER_MEM_BA +\
+                                      IOP13XX_PCIX_MEM_WINDOW_SIZE - 1)
+
+#define IOP13XX_PCIX_MEM_COOKIE        0x80000000UL
+#define IOP13XX_PCIX_LOWER_MEM_RA      IOP13XX_PCIX_MEM_COOKIE
+#define IOP13XX_PCIX_UPPER_MEM_RA      (IOP13XX_PCIX_LOWER_MEM_RA +\
+                                       IOP13XX_PCIX_MEM_WINDOW_SIZE - 1)
+#define IOP13XX_PCIX_MEM_OFFSET        (IOP13XX_PCIX_MEM_COOKIE -\
+                                       IOP13XX_PCIX_LOWER_MEM_BA)
+
+/* PCI-E ranges */
+#define IOP13XX_PCIE_IO_WINDOW_SIZE     0x10000UL
+#define IOP13XX_PCIE_LOWER_IO_PA        0xfffd0000UL
+#define IOP13XX_PCIE_LOWER_IO_VA        0xfed70000UL
+#define IOP13XX_PCIE_LOWER_IO_BA        0x0fff0000UL
+#define IOP13XX_PCIE_UPPER_IO_PA        (IOP13XX_PCIE_LOWER_IO_PA +\
+                                        IOP13XX_PCIE_IO_WINDOW_SIZE - 1)
+#define IOP13XX_PCIE_UPPER_IO_VA        (IOP13XX_PCIE_LOWER_IO_VA +\
+                                        IOP13XX_PCIE_IO_WINDOW_SIZE - 1)
+#define IOP13XX_PCIE_UPPER_IO_BA        (IOP13XX_PCIE_LOWER_IO_BA +\
+                                        IOP13XX_PCIE_IO_WINDOW_SIZE - 1)
+#define IOP13XX_PCIE_IO_OFFSET          (IOP13XX_PCIE_LOWER_IO_VA -\
+                                        IOP13XX_PCIE_LOWER_IO_BA)
+#define IOP13XX_PCIE_IO_PHYS_TO_VIRT(addr) (u32) ((u32) addr -\
+                                          (IOP13XX_PCIE_LOWER_IO_PA\
+                                          - IOP13XX_PCIE_LOWER_IO_VA))
+
+#define IOP13XX_PCIE_MEM_PHYS_OFFSET    0x200000000ULL
+#define IOP13XX_PCIE_MEM_WINDOW_SIZE    0x3a000000UL
+#define IOP13XX_PCIE_LOWER_MEM_BA       (PHYS_OFFSET + IOP13XX_PCI_OFFSET)
+#define IOP13XX_PCIE_LOWER_MEM_PA       (IOP13XX_PCIE_MEM_PHYS_OFFSET +\
+                                        IOP13XX_PCIE_LOWER_MEM_BA)
+#define IOP13XX_PCIE_UPPER_MEM_PA       (IOP13XX_PCIE_LOWER_MEM_PA +\
+                                        IOP13XX_PCIE_MEM_WINDOW_SIZE - 1)
+#define IOP13XX_PCIE_UPPER_MEM_BA       (IOP13XX_PCIE_LOWER_MEM_BA +\
+                                        IOP13XX_PCIE_MEM_WINDOW_SIZE - 1)
+
+/* All 0xc000.0000 - 0xfdff.ffff addresses belong to PCIe */
+#define IOP13XX_PCIE_MEM_COOKIE         0xc0000000UL
+#define IOP13XX_PCIE_LOWER_MEM_RA       IOP13XX_PCIE_MEM_COOKIE
+#define IOP13XX_PCIE_UPPER_MEM_RA       (IOP13XX_PCIE_LOWER_MEM_RA +\
+                                        IOP13XX_PCIE_MEM_WINDOW_SIZE - 1)
+#define IOP13XX_PCIE_MEM_OFFSET         (IOP13XX_PCIE_MEM_COOKIE -\
+                                        IOP13XX_PCIE_LOWER_MEM_BA)
+
+/* PBI Ranges */
+#define IOP13XX_PBI_LOWER_MEM_PA         0xf0000000UL
+#define IOP13XX_PBI_MEM_WINDOW_SIZE      0x04000000UL
+#define IOP13XX_PBI_MEM_COOKIE           0xfa000000UL
+#define IOP13XX_PBI_LOWER_MEM_RA         IOP13XX_PBI_MEM_COOKIE
+#define IOP13XX_PBI_UPPER_MEM_RA         (IOP13XX_PBI_LOWER_MEM_RA +\
+                                         IOP13XX_PBI_MEM_WINDOW_SIZE - 1)
+
+/*
+ * IOP13XX chipset registers
+ */
+#define IOP13XX_PMMR_PHYS_MEM_BASE        0xffd80000UL  /* PMMR phys. address */
+#define IOP13XX_PMMR_VIRT_MEM_BASE        0xfee80000UL  /* PMMR phys. address */
+#define IOP13XX_PMMR_MEM_WINDOW_SIZE      0x80000
+#define IOP13XX_PMMR_UPPER_MEM_VA         (IOP13XX_PMMR_VIRT_MEM_BASE +\
+                                          IOP13XX_PMMR_MEM_WINDOW_SIZE - 1)
+#define IOP13XX_PMMR_UPPER_MEM_PA         (IOP13XX_PMMR_PHYS_MEM_BASE +\
+                                          IOP13XX_PMMR_MEM_WINDOW_SIZE - 1)
+#define IOP13XX_PMMR_VIRT_TO_PHYS(addr)   (u32) ((u32) addr +\
+                                          (IOP13XX_PMMR_PHYS_MEM_BASE\
+                                          - IOP13XX_PMMR_VIRT_MEM_BASE))
+#define IOP13XX_PMMR_PHYS_TO_VIRT(addr)   (u32) ((u32) addr -\
+                                          (IOP13XX_PMMR_PHYS_MEM_BASE\
+                                          - IOP13XX_PMMR_VIRT_MEM_BASE))
+#define IOP13XX_REG_ADDR32(reg)           (IOP13XX_PMMR_VIRT_MEM_BASE + (reg))
+#define IOP13XX_REG_ADDR16(reg)           (IOP13XX_PMMR_VIRT_MEM_BASE + (reg))
+#define IOP13XX_REG_ADDR8(reg)            (IOP13XX_PMMR_VIRT_MEM_BASE + (reg))
+#define IOP13XX_REG_ADDR32_PHYS(reg)      (IOP13XX_PMMR_PHYS_MEM_BASE + (reg))
+#define IOP13XX_REG_ADDR16_PHYS(reg)      (IOP13XX_PMMR_PHYS_MEM_BASE + (reg))
+#define IOP13XX_REG_ADDR8_PHYS(reg)       (IOP13XX_PMMR_PHYS_MEM_BASE + (reg))
+#define IOP13XX_PMMR_SIZE                 0x00080000
+
+/*=================== Defines for Platform Devices =====================*/
+#define IOP13XX_UART0_PHYS  (IOP13XX_PMMR_PHYS_MEM_BASE | 0x00002300)
+#define IOP13XX_UART1_PHYS  (IOP13XX_PMMR_PHYS_MEM_BASE | 0x00002340)
+#define IOP13XX_UART0_VIRT  (IOP13XX_PMMR_VIRT_MEM_BASE | 0x00002300)
+#define IOP13XX_UART1_VIRT  (IOP13XX_PMMR_VIRT_MEM_BASE | 0x00002340)
+
+#define IOP13XX_I2C0_PHYS   (IOP13XX_PMMR_PHYS_MEM_BASE | 0x00002500)
+#define IOP13XX_I2C1_PHYS   (IOP13XX_PMMR_PHYS_MEM_BASE | 0x00002520)
+#define IOP13XX_I2C2_PHYS   (IOP13XX_PMMR_PHYS_MEM_BASE | 0x00002540)
+#define IOP13XX_I2C0_VIRT   (IOP13XX_PMMR_VIRT_MEM_BASE | 0x00002500)
+#define IOP13XX_I2C1_VIRT   (IOP13XX_PMMR_VIRT_MEM_BASE | 0x00002520)
+#define IOP13XX_I2C2_VIRT   (IOP13XX_PMMR_VIRT_MEM_BASE | 0x00002540)
+
+/* ATU selection flags */
+/* IOP13XX_INIT_ATU_DEFAULT = Rely on CONFIG_IOP13XX_ATU* */
+#define IOP13XX_INIT_ATU_DEFAULT     (0)
+#define IOP13XX_INIT_ATU_ATUX        (1 << 0)
+#define IOP13XX_INIT_ATU_ATUE        (1 << 1)
+#define IOP13XX_INIT_ATU_NONE        (1 << 2)
+
+/* UART selection flags */
+/* IOP13XX_INIT_UART_DEFAULT = Rely on CONFIG_IOP13XX_UART* */
+#define IOP13XX_INIT_UART_DEFAULT    (0)
+#define IOP13XX_INIT_UART_0          (1 << 0)
+#define IOP13XX_INIT_UART_1          (1 << 1)
+
+/* I2C selection flags */
+/* IOP13XX_INIT_I2C_DEFAULT = Rely on CONFIG_IOP13XX_I2C* */
+#define IOP13XX_INIT_I2C_DEFAULT     (0)
+#define IOP13XX_INIT_I2C_0           (1 << 0)
+#define IOP13XX_INIT_I2C_1           (1 << 1)
+#define IOP13XX_INIT_I2C_2           (1 << 2)
+
+#define IQ81340_NUM_UART     2
+#define IQ81340_NUM_I2C      3
+#define IQ81340_NUM_PHYS_MAP_FLASH 1
+#define IQ81340_MAX_PLAT_DEVICES (IQ81340_NUM_UART +\
+                               IQ81340_NUM_I2C +\
+                               IQ81340_NUM_PHYS_MAP_FLASH)
+
+/*========================== PMMR offsets for key registers ============*/
+#define IOP13XX_ATU0_PMMR_OFFSET       0x00048000
+#define IOP13XX_ATU1_PMMR_OFFSET       0x0004c000
+#define IOP13XX_ATU2_PMMR_OFFSET       0x0004d000
+#define IOP13XX_ADMA0_PMMR_OFFSET      0x00000000
+#define IOP13XX_ADMA1_PMMR_OFFSET      0x00000200
+#define IOP13XX_ADMA2_PMMR_OFFSET      0x00000400
+#define IOP13XX_PBI_PMMR_OFFSET        0x00001580
+#define IOP13XX_ESSR0_PMMR_OFFSET      0x00002188
+#define IOP13XX_ESSR0                  IOP13XX_REG_ADDR32(0x00002188)
+
+#define IOP13XX_ESSR0_IFACE_MASK       0x00004000  /* Interface PCI-X / PCI-E */
+#define IOP13XX_CONTROLLER_ONLY        (1 << 14)
+#define IOP13XX_INTERFACE_SEL_PCIX     (1 << 15)
+
+#define IOP13XX_PMON_PMMR_OFFSET       0x0001A000
+#define IOP13XX_PMON_BASE              (IOP13XX_PMMR_VIRT_MEM_BASE +\
+                                       IOP13XX_PMON_PMMR_OFFSET)
+#define IOP13XX_PMON_PHYSBASE          (IOP13XX_PMMR_PHYS_MEM_BASE +\
+                                       IOP13XX_PMON_PMMR_OFFSET)
+
+#define IOP13XX_PMON_CMD0              (IOP13XX_PMON_BASE + 0x0)
+#define IOP13XX_PMON_EVR0              (IOP13XX_PMON_BASE + 0x4)
+#define IOP13XX_PMON_STS0              (IOP13XX_PMON_BASE + 0x8)
+#define IOP13XX_PMON_DATA0             (IOP13XX_PMON_BASE + 0xC)
+
+#define IOP13XX_PMON_CMD3              (IOP13XX_PMON_BASE + 0x30)
+#define IOP13XX_PMON_EVR3              (IOP13XX_PMON_BASE + 0x34)
+#define IOP13XX_PMON_STS3              (IOP13XX_PMON_BASE + 0x38)
+#define IOP13XX_PMON_DATA3             (IOP13XX_PMON_BASE + 0x3C)
+
+#define IOP13XX_PMON_CMD7              (IOP13XX_PMON_BASE + 0x70)
+#define IOP13XX_PMON_EVR7              (IOP13XX_PMON_BASE + 0x74)
+#define IOP13XX_PMON_STS7              (IOP13XX_PMON_BASE + 0x78)
+#define IOP13XX_PMON_DATA7             (IOP13XX_PMON_BASE + 0x7C)
+
+#define IOP13XX_PMONEN                 (IOP13XX_PMMR_VIRT_MEM_BASE + 0x4E040)
+#define IOP13XX_PMONSTAT               (IOP13XX_PMMR_VIRT_MEM_BASE + 0x4E044)
+
+/*================================ATU===================================*/
+#define IOP13XX_ATUX_OFFSET(ofs)       IOP13XX_REG_ADDR32(\
+                                       iop13xx_atux_pmmr_offset + (ofs))
+
+#define IOP13XX_ATUX_DID               IOP13XX_REG_ADDR16(\
+                                       iop13xx_atux_pmmr_offset + 0x2)
+
+#define IOP13XX_ATUX_ATUCMD            IOP13XX_REG_ADDR16(\
+                                       iop13xx_atux_pmmr_offset + 0x4)
+#define IOP13XX_ATUX_ATUSR             IOP13XX_REG_ADDR16(\
+                                       iop13xx_atux_pmmr_offset + 0x6)
+
+#define IOP13XX_ATUX_IABAR0            IOP13XX_ATUX_OFFSET(0x10)
+#define IOP13XX_ATUX_IAUBAR0           IOP13XX_ATUX_OFFSET(0x14)
+#define IOP13XX_ATUX_IABAR1            IOP13XX_ATUX_OFFSET(0x18)
+#define IOP13XX_ATUX_IAUBAR1           IOP13XX_ATUX_OFFSET(0x1c)
+#define IOP13XX_ATUX_IABAR2            IOP13XX_ATUX_OFFSET(0x20)
+#define IOP13XX_ATUX_IAUBAR2           IOP13XX_ATUX_OFFSET(0x24)
+#define IOP13XX_ATUX_IALR0             IOP13XX_ATUX_OFFSET(0x40)
+#define IOP13XX_ATUX_IATVR0            IOP13XX_ATUX_OFFSET(0x44)
+#define IOP13XX_ATUX_IAUTVR0           IOP13XX_ATUX_OFFSET(0x48)
+#define IOP13XX_ATUX_IALR1             IOP13XX_ATUX_OFFSET(0x4c)
+#define IOP13XX_ATUX_IATVR1            IOP13XX_ATUX_OFFSET(0x50)
+#define IOP13XX_ATUX_IAUTVR1           IOP13XX_ATUX_OFFSET(0x54)
+#define IOP13XX_ATUX_IALR2             IOP13XX_ATUX_OFFSET(0x58)
+#define IOP13XX_ATUX_IATVR2            IOP13XX_ATUX_OFFSET(0x5c)
+#define IOP13XX_ATUX_IAUTVR2           IOP13XX_ATUX_OFFSET(0x60)
+#define IOP13XX_ATUX_ATUCR             IOP13XX_ATUX_OFFSET(0x70)
+#define IOP13XX_ATUX_PCSR              IOP13XX_ATUX_OFFSET(0x74)
+#define IOP13XX_ATUX_ATUISR            IOP13XX_ATUX_OFFSET(0x78)
+#define IOP13XX_ATUX_PCIXSR            IOP13XX_ATUX_OFFSET(0xD4)
+#define IOP13XX_ATUX_IABAR3            IOP13XX_ATUX_OFFSET(0x200)
+#define IOP13XX_ATUX_IAUBAR3           IOP13XX_ATUX_OFFSET(0x204)
+#define IOP13XX_ATUX_IALR3             IOP13XX_ATUX_OFFSET(0x208)
+#define IOP13XX_ATUX_IATVR3            IOP13XX_ATUX_OFFSET(0x20c)
+#define IOP13XX_ATUX_IAUTVR3           IOP13XX_ATUX_OFFSET(0x210)
+
+#define IOP13XX_ATUX_OIOBAR            IOP13XX_ATUX_OFFSET(0x300)
+#define IOP13XX_ATUX_OIOWTVR           IOP13XX_ATUX_OFFSET(0x304)
+#define IOP13XX_ATUX_OUMBAR0           IOP13XX_ATUX_OFFSET(0x308)
+#define IOP13XX_ATUX_OUMWTVR0          IOP13XX_ATUX_OFFSET(0x30c)
+#define IOP13XX_ATUX_OUMBAR1           IOP13XX_ATUX_OFFSET(0x310)
+#define IOP13XX_ATUX_OUMWTVR1          IOP13XX_ATUX_OFFSET(0x314)
+#define IOP13XX_ATUX_OUMBAR2           IOP13XX_ATUX_OFFSET(0x318)
+#define IOP13XX_ATUX_OUMWTVR2          IOP13XX_ATUX_OFFSET(0x31c)
+#define IOP13XX_ATUX_OUMBAR3           IOP13XX_ATUX_OFFSET(0x320)
+#define IOP13XX_ATUX_OUMWTVR3          IOP13XX_ATUX_OFFSET(0x324)
+#define IOP13XX_ATUX_OUDMABAR          IOP13XX_ATUX_OFFSET(0x328)
+#define IOP13XX_ATUX_OUMSIBAR          IOP13XX_ATUX_OFFSET(0x32c)
+#define IOP13XX_ATUX_OCCAR             IOP13XX_ATUX_OFFSET(0x330)
+#define IOP13XX_ATUX_OCCDR             IOP13XX_ATUX_OFFSET(0x334)
+
+#define IOP13XX_ATUX_ATUCR_OUT_EN              (1 << 1)
+#define IOP13XX_ATUX_PCSR_CENTRAL_RES          (1 << 25)
+#define IOP13XX_ATUX_PCSR_P_RSTOUT             (1 << 21)
+#define IOP13XX_ATUX_PCSR_OUT_Q_BUSY           (1 << 15)
+#define IOP13XX_ATUX_PCSR_IN_Q_BUSY            (1 << 14)
+#define IOP13XX_ATUX_PCSR_FREQ_OFFSET          (16)
+
+#define IOP13XX_ATUX_STAT_PCI_IFACE_ERR        (1 << 18)
+#define IOP13XX_ATUX_STAT_VPD_ADDR             (1 << 17)
+#define IOP13XX_ATUX_STAT_INT_PAR_ERR          (1 << 16)
+#define IOP13XX_ATUX_STAT_CFG_WRITE            (1 << 15)
+#define IOP13XX_ATUX_STAT_ERR_COR              (1 << 14)
+#define IOP13XX_ATUX_STAT_TX_SCEM              (1 << 13)
+#define IOP13XX_ATUX_STAT_REC_SCEM             (1 << 12)
+#define IOP13XX_ATUX_STAT_POWER_TRAN           (1 << 11)
+#define IOP13XX_ATUX_STAT_TX_SERR              (1 << 10)
+#define IOP13XX_ATUX_STAT_DET_PAR_ERR          (1 << 9 )
+#define IOP13XX_ATUX_STAT_BIST                 (1 << 8 )
+#define IOP13XX_ATUX_STAT_INT_REC_MABORT       (1 << 7 )
+#define IOP13XX_ATUX_STAT_REC_SERR             (1 << 4 )
+#define IOP13XX_ATUX_STAT_EXT_REC_MABORT       (1 << 3 )
+#define IOP13XX_ATUX_STAT_EXT_REC_TABORT       (1 << 2 )
+#define IOP13XX_ATUX_STAT_EXT_SIG_TABORT       (1 << 1 )
+#define IOP13XX_ATUX_STAT_MASTER_DATA_PAR      (1 << 0 )
+
+#define IOP13XX_ATUX_PCIXSR_BUS_NUM    (8)
+#define IOP13XX_ATUX_PCIXSR_DEV_NUM    (3)
+#define IOP13XX_ATUX_PCIXSR_FUNC_NUM   (0)
+
+#define IOP13XX_ATUX_IALR_DISABLE      0x00000001
+#define IOP13XX_ATUX_OUMBAR_ENABLE     0x80000000
+
+#define IOP13XX_ATUE_OFFSET(ofs)       IOP13XX_REG_ADDR32(\
+                                       iop13xx_atue_pmmr_offset + (ofs))
+
+#define IOP13XX_ATUE_DID               IOP13XX_REG_ADDR16(\
+                                       iop13xx_atue_pmmr_offset + 0x2)
+#define IOP13XX_ATUE_ATUCMD            IOP13XX_REG_ADDR16(\
+                                       iop13xx_atue_pmmr_offset + 0x4)
+#define IOP13XX_ATUE_ATUSR             IOP13XX_REG_ADDR16(\
+                                       iop13xx_atue_pmmr_offset + 0x6)
+
+#define IOP13XX_ATUE_IABAR0            IOP13XX_ATUE_OFFSET(0x10)
+#define IOP13XX_ATUE_IAUBAR0           IOP13XX_ATUE_OFFSET(0x14)
+#define IOP13XX_ATUE_IABAR1            IOP13XX_ATUE_OFFSET(0x18)
+#define IOP13XX_ATUE_IAUBAR1           IOP13XX_ATUE_OFFSET(0x1c)
+#define IOP13XX_ATUE_IABAR2            IOP13XX_ATUE_OFFSET(0x20)
+#define IOP13XX_ATUE_IAUBAR2           IOP13XX_ATUE_OFFSET(0x24)
+#define IOP13XX_ATUE_IALR0             IOP13XX_ATUE_OFFSET(0x40)
+#define IOP13XX_ATUE_IATVR0            IOP13XX_ATUE_OFFSET(0x44)
+#define IOP13XX_ATUE_IAUTVR0           IOP13XX_ATUE_OFFSET(0x48)
+#define IOP13XX_ATUE_IALR1             IOP13XX_ATUE_OFFSET(0x4c)
+#define IOP13XX_ATUE_IATVR1            IOP13XX_ATUE_OFFSET(0x50)
+#define IOP13XX_ATUE_IAUTVR1           IOP13XX_ATUE_OFFSET(0x54)
+#define IOP13XX_ATUE_IALR2             IOP13XX_ATUE_OFFSET(0x58)
+#define IOP13XX_ATUE_IATVR2            IOP13XX_ATUE_OFFSET(0x5c)
+#define IOP13XX_ATUE_IAUTVR2           IOP13XX_ATUE_OFFSET(0x60)
+#define IOP13XX_ATUE_PE_LSTS           IOP13XX_REG_ADDR16(\
+                                       iop13xx_atue_pmmr_offset + 0xe2)
+#define IOP13XX_ATUE_OIOWTVR           IOP13XX_ATUE_OFFSET(0x304)
+#define IOP13XX_ATUE_OUMBAR0           IOP13XX_ATUE_OFFSET(0x308)
+#define IOP13XX_ATUE_OUMWTVR0          IOP13XX_ATUE_OFFSET(0x30c)
+#define IOP13XX_ATUE_OUMBAR1           IOP13XX_ATUE_OFFSET(0x310)
+#define IOP13XX_ATUE_OUMWTVR1          IOP13XX_ATUE_OFFSET(0x314)
+#define IOP13XX_ATUE_OUMBAR2           IOP13XX_ATUE_OFFSET(0x318)
+#define IOP13XX_ATUE_OUMWTVR2          IOP13XX_ATUE_OFFSET(0x31c)
+#define IOP13XX_ATUE_OUMBAR3           IOP13XX_ATUE_OFFSET(0x320)
+#define IOP13XX_ATUE_OUMWTVR3          IOP13XX_ATUE_OFFSET(0x324)
+
+#define IOP13XX_ATUE_ATUCR             IOP13XX_ATUE_OFFSET(0x70)
+#define IOP13XX_ATUE_PCSR              IOP13XX_ATUE_OFFSET(0x74)
+#define IOP13XX_ATUE_ATUISR            IOP13XX_ATUE_OFFSET(0x78)
+#define IOP13XX_ATUE_OIOBAR            IOP13XX_ATUE_OFFSET(0x300)
+#define IOP13XX_ATUE_OCCAR             IOP13XX_ATUE_OFFSET(0x32c)
+#define IOP13XX_ATUE_OCCDR             IOP13XX_ATUE_OFFSET(0x330)
+
+#define IOP13XX_ATUE_PIE_STS           IOP13XX_ATUE_OFFSET(0x384)
+#define IOP13XX_ATUE_PIE_MSK           IOP13XX_ATUE_OFFSET(0x388)
+
+#define IOP13XX_ATUE_ATUCR_IVM         (1 << 6)
+#define IOP13XX_ATUE_ATUCR_OUT_EN      (1 << 1)
+#define IOP13XX_ATUE_OCCAR_BUS_NUM     (24)
+#define IOP13XX_ATUE_OCCAR_DEV_NUM     (19)
+#define IOP13XX_ATUE_OCCAR_FUNC_NUM    (16)
+#define IOP13XX_ATUE_OCCAR_EXT_REG     (8)
+#define IOP13XX_ATUE_OCCAR_REG         (2)
+
+#define IOP13XX_ATUE_PCSR_BUS_NUM      (24)
+#define IOP13XX_ATUE_PCSR_DEV_NUM      (19)
+#define IOP13XX_ATUE_PCSR_FUNC_NUM     (16)
+#define IOP13XX_ATUE_PCSR_OUT_Q_BUSY   (1 << 15)
+#define IOP13XX_ATUE_PCSR_IN_Q_BUSY    (1 << 14)
+#define IOP13XX_ATUE_PCSR_END_POINT    (1 << 13)
+#define IOP13XX_ATUE_PCSR_LLRB_BUSY    (1 << 12)
+
+#define IOP13XX_ATUE_PCSR_BUS_NUM_MASK         (0xff)
+#define IOP13XX_ATUE_PCSR_DEV_NUM_MASK         (0x1f)
+#define IOP13XX_ATUE_PCSR_FUNC_NUM_MASK        (0x7)
+
+#define IOP13XX_ATUE_PCSR_CORE_RESET           (8)
+#define IOP13XX_ATUE_PCSR_FUNC_NUM             (16)
+
+#define IOP13XX_ATUE_LSTS_TRAINING             (1 << 11)
+#define IOP13XX_ATUE_STAT_SLOT_PWR_MSG         (1 << 28)
+#define IOP13XX_ATUE_STAT_PME                  (1 << 27)
+#define IOP13XX_ATUE_STAT_HOT_PLUG_MSG         (1 << 26)
+#define IOP13XX_ATUE_STAT_IVM                  (1 << 25)
+#define IOP13XX_ATUE_STAT_BIST                 (1 << 24)
+#define IOP13XX_ATUE_STAT_CFG_WRITE            (1 << 18)
+#define IOP13XX_ATUE_STAT_VPD_ADDR             (1 << 17)
+#define IOP13XX_ATUE_STAT_POWER_TRAN           (1 << 16)
+#define IOP13XX_ATUE_STAT_HALT_ON_ERROR        (1 << 13)
+#define IOP13XX_ATUE_STAT_ROOT_SYS_ERR         (1 << 12)
+#define IOP13XX_ATUE_STAT_ROOT_ERR_MSG         (1 << 11)
+#define IOP13XX_ATUE_STAT_PCI_IFACE_ERR        (1 << 10)
+#define IOP13XX_ATUE_STAT_ERR_COR              (1 << 9 )
+#define IOP13XX_ATUE_STAT_ERR_UNCOR            (1 << 8 )
+#define IOP13XX_ATUE_STAT_CRS                  (1 << 7 )
+#define IOP13XX_ATUE_STAT_LNK_DWN              (1 << 6 )
+#define IOP13XX_ATUE_STAT_INT_REC_MABORT       (1 << 5 )
+#define IOP13XX_ATUE_STAT_DET_PAR_ERR          (1 << 4 )
+#define IOP13XX_ATUE_STAT_EXT_REC_MABORT       (1 << 3 )
+#define IOP13XX_ATUE_STAT_SIG_TABORT           (1 << 2 )
+#define IOP13XX_ATUE_STAT_EXT_REC_TABORT       (1 << 1 )
+#define IOP13XX_ATUE_STAT_MASTER_DATA_PAR      (1 << 0 )
+
+#define IOP13XX_ATUE_ESTAT_REC_UNSUPPORTED_COMP_REQ    (1 << 31)
+#define IOP13XX_ATUE_ESTAT_REC_COMPLETER_ABORT         (1 << 30)
+#define IOP13XX_ATUE_ESTAT_TX_POISONED_TLP             (1 << 29)
+#define IOP13XX_ATUE_ESTAT_TX_PAR_ERR                  (1 << 28)
+#define IOP13XX_ATUE_ESTAT_REC_UNSUPPORTED_REQ         (1 << 20)
+#define IOP13XX_ATUE_ESTAT_REC_ECRC_ERR                (1 << 19)
+#define IOP13XX_ATUE_ESTAT_REC_MALFORMED_TLP           (1 << 18)
+#define IOP13XX_ATUE_ESTAT_TX_RECEIVER_OVERFLOW        (1 << 17)
+#define IOP13XX_ATUE_ESTAT_REC_UNEXPECTED_COMP         (1 << 16)
+#define IOP13XX_ATUE_ESTAT_INT_COMP_ABORT              (1 << 15)
+#define IOP13XX_ATUE_ESTAT_COMP_TIMEOUT                (1 << 14)
+#define IOP13XX_ATUE_ESTAT_FLOW_CONTROL_ERR            (1 << 13)
+#define IOP13XX_ATUE_ESTAT_REC_POISONED_TLP            (1 << 12)
+#define IOP13XX_ATUE_ESTAT_DATA_LNK_ERR                (1 << 4 )
+#define IOP13XX_ATUE_ESTAT_TRAINING_ERR                (1 << 0 )
+
+#define IOP13XX_ATUE_IALR_DISABLE              (0x00000001)
+#define IOP13XX_ATUE_OUMBAR_ENABLE             (0x80000000)
+#define IOP13XX_ATU_OUMBAR_FUNC_NUM            (28)
+#define IOP13XX_ATU_OUMBAR_FUNC_NUM_MASK       (0x7)
+/*=======================================================================*/
+
+/*==============================ADMA UNITS===============================*/
+#define IOP13XX_ADMA_PHYS_BASE(chan)   IOP13XX_REG_ADDR32_PHYS((chan << 9))
+#define IOP13XX_ADMA_UPPER_PA(chan)    (IOP13XX_ADMA_PHYS_BASE(chan) + 0xc0)
+#define IOP13XX_ADMA_OFFSET(chan, ofs) IOP13XX_REG_ADDR32((chan << 9) + (ofs))
+
+#define IOP13XX_ADMA_ACCR(chan)      IOP13XX_ADMA_OFFSET(chan, 0x0)
+#define IOP13XX_ADMA_ACSR(chan)      IOP13XX_ADMA_OFFSET(chan, 0x4)
+#define IOP13XX_ADMA_ADAR(chan)      IOP13XX_ADMA_OFFSET(chan, 0x8)
+#define IOP13XX_ADMA_IIPCR(chan)     IOP13XX_ADMA_OFFSET(chan, 0x18)
+#define IOP13XX_ADMA_IIPAR(chan)     IOP13XX_ADMA_OFFSET(chan, 0x1c)
+#define IOP13XX_ADMA_IIPUAR(chan)    IOP13XX_ADMA_OFFSET(chan, 0x20)
+#define IOP13XX_ADMA_ANDAR(chan)     IOP13XX_ADMA_OFFSET(chan, 0x24)
+#define IOP13XX_ADMA_ADCR(chan)      IOP13XX_ADMA_OFFSET(chan, 0x28)
+#define IOP13XX_ADMA_CARMD(chan)     IOP13XX_ADMA_OFFSET(chan, 0x2c)
+#define IOP13XX_ADMA_ABCR(chan)      IOP13XX_ADMA_OFFSET(chan, 0x30)
+#define IOP13XX_ADMA_DLADR(chan)     IOP13XX_ADMA_OFFSET(chan, 0x34)
+#define IOP13XX_ADMA_DUADR(chan)     IOP13XX_ADMA_OFFSET(chan, 0x38)
+#define IOP13XX_ADMA_SLAR(src, chan) IOP13XX_ADMA_OFFSET(chan, 0x3c + (src <<3))
+#define IOP13XX_ADMA_SUAR(src, chan) IOP13XX_ADMA_OFFSET(chan, 0x40 + (src <<3))
+
+/*==============================XSI BRIDGE===============================*/
+#define IOP13XX_XBG_BECSR              IOP13XX_REG_ADDR32(0x178c)
+#define IOP13XX_XBG_BERAR              IOP13XX_REG_ADDR32(0x1790)
+#define IOP13XX_XBG_BERUAR             IOP13XX_REG_ADDR32(0x1794)
+#define is_atue_occdr_error(x)         ((__raw_readl(IOP13XX_XBG_BERAR) == \
+                                       IOP13XX_PMMR_VIRT_TO_PHYS(\
+                                       IOP13XX_ATUE_OCCDR))\
+                                       && (__raw_readl(IOP13XX_XBG_BECSR) & 1))
+#define is_atux_occdr_error(x)         ((__raw_readl(IOP13XX_XBG_BERAR) == \
+                                       IOP13XX_PMMR_VIRT_TO_PHYS(\
+                                       IOP13XX_ATUX_OCCDR))\
+                                       && (__raw_readl(IOP13XX_XBG_BECSR) & 1))
+/*=======================================================================*/
+
+#define IOP13XX_PBI_OFFSET(ofs) IOP13XX_REG_ADDR32(IOP13XX_PBI_PMMR_OFFSET +\
+                                                       (ofs))
+
+#define IOP13XX_PBI_CR                 IOP13XX_PBI_OFFSET(0x0)
+#define IOP13XX_PBI_SR                 IOP13XX_PBI_OFFSET(0x4)
+#define IOP13XX_PBI_BAR0               IOP13XX_PBI_OFFSET(0x8)
+#define IOP13XX_PBI_LR0                IOP13XX_PBI_OFFSET(0xc)
+#define IOP13XX_PBI_BAR1               IOP13XX_PBI_OFFSET(0x10)
+#define IOP13XX_PBI_LR1                IOP13XX_PBI_OFFSET(0x14)
+
+#define IOP13XX_TMR_TC                 0x01
+#define IOP13XX_TMR_EN                 0x02
+#define IOP13XX_TMR_RELOAD             0x04
+#define IOP13XX_TMR_PRIVILEGED         0x08
+
+#define IOP13XX_TMR_RATIO_1_1          0x00
+#define IOP13XX_TMR_RATIO_4_1          0x10
+#define IOP13XX_TMR_RATIO_8_1          0x20
+#define IOP13XX_TMR_RATIO_16_1         0x30
+
+#endif /* _IOP13XX_HW_H_ */
diff --git a/include/asm-arm/arch-iop13xx/iq81340.h b/include/asm-arm/arch-iop13xx/iq81340.h
new file mode 100644 (file)
index 0000000..b98f8f1
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef _IQ81340_H_
+#define _IQ81340_H_
+
+#define IQ81340_PCE_BAR0    IOP13XX_PBI_LOWER_MEM_RA
+#define IQ81340_PCE_BAR1    (IQ81340_PCE_BAR0 + 0x02000000)
+
+#define IQ81340_FLASHBASE   IQ81340_PCE_BAR0   /* Flash */
+
+#define IQ81340_PCE_BAR1_OFFSET(a) (IQ81340_PCE_BAR1 + (a))
+
+#define IQ81340_PRD_CODE    IQ81340_PCE_BAR1_OFFSET(0)
+#define IQ81340_BRD_STEP    IQ81340_PCE_BAR1_OFFSET(0x10000)
+#define IQ81340_CPLD_REV    IQ81340_PCE_BAR1_OFFSET(0x20000)
+#define IQ81340_LED         IQ81340_PCE_BAR1_OFFSET(0x30000)
+#define IQ81340_LHEX        IQ81340_PCE_BAR1_OFFSET(0x40000)
+#define IQ81340_RHEX        IQ81340_PCE_BAR1_OFFSET(0x50000)
+#define IQ81340_BUZZER      IQ81340_PCE_BAR1_OFFSET(0x60000)
+#define IQ81340_32K_NVRAM   IQ81340_PCE_BAR1_OFFSET(0x70000)
+#define IQ81340_256K_NVRAM  IQ81340_PCE_BAR1_OFFSET(0x80000)
+#define IQ81340_ROTARY_SW   IQ81340_PCE_BAR1_OFFSET(0xd0000)
+#define IQ81340_BATT_STAT   IQ81340_PCE_BAR1_OFFSET(0xf0000)
+#define IQ81340_CMP_FLSH    IQ81340_PCE_BAR1_OFFSET(0x1000000) /* 16MB */
+
+#define PBI_CF_IDE_BASE     (IQ81340_CMP_FLSH)
+#define PBI_CF_BAR_ADDR     (IOP13XX_PBI_BAR1)
+
+/* These are the values used in the Machine description */
+#define PHYS_IO         0xfeffff00
+#define IO_PG_OFFSET    0xffffff00
+#define BOOT_PARAM_OFFSET  0x00000100
+#endif /* _IQ81340_H_ */
diff --git a/include/asm-arm/arch-iop13xx/irqs.h b/include/asm-arm/arch-iop13xx/irqs.h
new file mode 100644 (file)
index 0000000..442e35a
--- /dev/null
@@ -0,0 +1,207 @@
+#ifndef _IOP13XX_IRQS_H_
+#define _IOP13XX_IRQS_H_
+
+#ifndef __ASSEMBLER__
+#include <linux/types.h>
+#include <asm/system.h> /* local_irq_save */
+#include <asm/arch/iop13xx.h> /* iop13xx_cp6_* */
+
+/* INTPND0 CP6 R0 Page 3
+ */
+static inline u32 read_intpnd_0(void)
+{
+       u32 val;
+       asm volatile("mrc p6, 0, %0, c0, c3, 0":"=r" (val));
+       return val;
+}
+
+/* INTPND1 CP6 R1 Page 3
+ */
+static inline u32 read_intpnd_1(void)
+{
+       u32 val;
+       asm volatile("mrc p6, 0, %0, c1, c3, 0":"=r" (val));
+       return val;
+}
+
+/* INTPND2 CP6 R2 Page 3
+ */
+static inline u32 read_intpnd_2(void)
+{
+       u32 val;
+       asm volatile("mrc p6, 0, %0, c2, c3, 0":"=r" (val));
+       return val;
+}
+
+/* INTPND3 CP6 R3 Page 3
+ */
+static inline u32 read_intpnd_3(void)
+{
+       u32 val;
+       asm volatile("mrc p6, 0, %0, c3, c3, 0":"=r" (val));
+       return val;
+}
+
+static inline void
+iop13xx_cp6_enable_irq_save(unsigned long *cp_flags, unsigned long *irq_flags)
+{
+       local_irq_save(*irq_flags);
+       *cp_flags = iop13xx_cp6_save();
+}
+
+static inline void
+iop13xx_cp6_irq_restore(unsigned long *cp_flags,
+       unsigned long *irq_flags)
+{
+       iop13xx_cp6_restore(*cp_flags);
+       local_irq_restore(*irq_flags);
+}
+#endif
+
+#define INTBASE 0
+#define INTSIZE_4 1
+
+/*
+ * iop34x chipset interrupts
+ */
+#define IOP13XX_IRQ(x)         (IOP13XX_IRQ_OFS + (x))
+
+/*
+ * On IRQ or FIQ register
+ */
+#define IRQ_IOP13XX_ADMA0_EOT  (0)
+#define IRQ_IOP13XX_ADMA0_EOC  (1)
+#define IRQ_IOP13XX_ADMA1_EOT  (2)
+#define IRQ_IOP13XX_ADMA1_EOC  (3)
+#define IRQ_IOP13XX_ADMA2_EOT  (4)
+#define IRQ_IOP13XX_ADMA2_EOC  (5)
+#define IRQ_IOP134_WATCHDOG    (6)
+#define IRQ_IOP13XX_RSVD_7     (7)
+#define IRQ_IOP13XX_TIMER0     (8)
+#define IRQ_IOP13XX_TIMER1     (9)
+#define IRQ_IOP13XX_I2C_0      (10)
+#define IRQ_IOP13XX_I2C_1      (11)
+#define IRQ_IOP13XX_MSG        (12)
+#define IRQ_IOP13XX_MSGIBQ     (13)
+#define IRQ_IOP13XX_ATU_IM     (14)
+#define IRQ_IOP13XX_ATU_BIST   (15)
+#define IRQ_IOP13XX_PPMU       (16)
+#define IRQ_IOP13XX_COREPMU    (17)
+#define IRQ_IOP13XX_CORECACHE  (18)
+#define IRQ_IOP13XX_RSVD_19    (19)
+#define IRQ_IOP13XX_RSVD_20    (20)
+#define IRQ_IOP13XX_RSVD_21    (21)
+#define IRQ_IOP13XX_RSVD_22    (22)
+#define IRQ_IOP13XX_RSVD_23    (23)
+#define IRQ_IOP13XX_XINT0      (24)
+#define IRQ_IOP13XX_XINT1      (25)
+#define IRQ_IOP13XX_XINT2      (26)
+#define IRQ_IOP13XX_XINT3      (27)
+#define IRQ_IOP13XX_XINT4      (28)
+#define IRQ_IOP13XX_XINT5      (29)
+#define IRQ_IOP13XX_XINT6      (30)
+#define IRQ_IOP13XX_XINT7      (31)
+                                     /* IINTSRC1 bit */
+#define IRQ_IOP13XX_XINT8      (32)  /* 0  */
+#define IRQ_IOP13XX_XINT9      (33)  /* 1  */
+#define IRQ_IOP13XX_XINT10     (34)  /* 2  */
+#define IRQ_IOP13XX_XINT11     (35)  /* 3  */
+#define IRQ_IOP13XX_XINT12     (36)  /* 4  */
+#define IRQ_IOP13XX_XINT13     (37)  /* 5  */
+#define IRQ_IOP13XX_XINT14     (38)  /* 6  */
+#define IRQ_IOP13XX_XINT15     (39)  /* 7  */
+#define IRQ_IOP13XX_RSVD_40    (40)  /* 8  */
+#define IRQ_IOP13XX_RSVD_41    (41)  /* 9  */
+#define IRQ_IOP13XX_RSVD_42    (42)  /* 10 */
+#define IRQ_IOP13XX_RSVD_43    (43)  /* 11 */
+#define IRQ_IOP13XX_RSVD_44    (44)  /* 12 */
+#define IRQ_IOP13XX_RSVD_45    (45)  /* 13 */
+#define IRQ_IOP13XX_RSVD_46    (46)  /* 14 */
+#define IRQ_IOP13XX_RSVD_47    (47)  /* 15 */
+#define IRQ_IOP13XX_RSVD_48    (48)  /* 16 */
+#define IRQ_IOP13XX_RSVD_49    (49)  /* 17 */
+#define IRQ_IOP13XX_RSVD_50    (50)  /* 18 */
+#define IRQ_IOP13XX_UART0      (51)  /* 19 */
+#define IRQ_IOP13XX_UART1      (52)  /* 20 */
+#define IRQ_IOP13XX_PBIE       (53)  /* 21 */
+#define IRQ_IOP13XX_ATU_CRW    (54)  /* 22 */
+#define IRQ_IOP13XX_ATU_ERR    (55)  /* 23 */
+#define IRQ_IOP13XX_MCU_ERR    (56)  /* 24 */
+#define IRQ_IOP13XX_ADMA0_ERR  (57)  /* 25 */
+#define IRQ_IOP13XX_ADMA1_ERR  (58)  /* 26 */
+#define IRQ_IOP13XX_ADMA2_ERR  (59)  /* 27 */
+#define IRQ_IOP13XX_RSVD_60    (60)  /* 28 */
+#define IRQ_IOP13XX_RSVD_61    (61)  /* 29 */
+#define IRQ_IOP13XX_MSG_ERR    (62)  /* 30 */
+#define IRQ_IOP13XX_RSVD_63    (63)  /* 31 */
+                                     /* IINTSRC2 bit */
+#define IRQ_IOP13XX_INTERPROC  (64)  /* 0  */
+#define IRQ_IOP13XX_RSVD_65    (65)  /* 1  */
+#define IRQ_IOP13XX_RSVD_66    (66)  /* 2  */
+#define IRQ_IOP13XX_RSVD_67    (67)  /* 3  */
+#define IRQ_IOP13XX_RSVD_68    (68)  /* 4  */
+#define IRQ_IOP13XX_RSVD_69    (69)  /* 5  */
+#define IRQ_IOP13XX_RSVD_70    (70)  /* 6  */
+#define IRQ_IOP13XX_RSVD_71    (71)  /* 7  */
+#define IRQ_IOP13XX_RSVD_72    (72)  /* 8  */
+#define IRQ_IOP13XX_RSVD_73    (73)  /* 9  */
+#define IRQ_IOP13XX_RSVD_74    (74)  /* 10 */
+#define IRQ_IOP13XX_RSVD_75    (75)  /* 11 */
+#define IRQ_IOP13XX_RSVD_76    (76)  /* 12 */
+#define IRQ_IOP13XX_RSVD_77    (77)  /* 13 */
+#define IRQ_IOP13XX_RSVD_78    (78)  /* 14 */
+#define IRQ_IOP13XX_RSVD_79    (79)  /* 15 */
+#define IRQ_IOP13XX_RSVD_80    (80)  /* 16 */
+#define IRQ_IOP13XX_RSVD_81    (81)  /* 17 */
+#define IRQ_IOP13XX_RSVD_82    (82)  /* 18 */
+#define IRQ_IOP13XX_RSVD_83    (83)  /* 19 */
+#define IRQ_IOP13XX_RSVD_84    (84)  /* 20 */
+#define IRQ_IOP13XX_RSVD_85    (85)  /* 21 */
+#define IRQ_IOP13XX_RSVD_86    (86)  /* 22 */
+#define IRQ_IOP13XX_RSVD_87    (87)  /* 23 */
+#define IRQ_IOP13XX_RSVD_88    (88)  /* 24 */
+#define IRQ_IOP13XX_RSVD_89    (89)  /* 25 */
+#define IRQ_IOP13XX_RSVD_90    (90)  /* 26 */
+#define IRQ_IOP13XX_RSVD_91    (91)  /* 27 */
+#define IRQ_IOP13XX_RSVD_92    (92)  /* 28 */
+#define IRQ_IOP13XX_RSVD_93    (93)  /* 29 */
+#define IRQ_IOP13XX_SIB_ERR    (94)  /* 30 */
+#define IRQ_IOP13XX_SRAM_ERR   (95)  /* 31 */
+                                     /* IINTSRC3 bit */
+#define IRQ_IOP13XX_I2C_2      (96)  /* 0  */
+#define IRQ_IOP13XX_ATUE_BIST  (97)  /* 1  */
+#define IRQ_IOP13XX_ATUE_CRW   (98)  /* 2  */
+#define IRQ_IOP13XX_ATUE_ERR   (99)  /* 3  */
+#define IRQ_IOP13XX_IMU        (100) /* 4  */
+#define IRQ_IOP13XX_RSVD_101   (101) /* 5  */
+#define IRQ_IOP13XX_RSVD_102   (102) /* 6  */
+#define IRQ_IOP13XX_TPMI0_OUT  (103) /* 7  */
+#define IRQ_IOP13XX_TPMI1_OUT  (104) /* 8  */
+#define IRQ_IOP13XX_TPMI2_OUT  (105) /* 9  */
+#define IRQ_IOP13XX_TPMI3_OUT  (106) /* 10 */
+#define IRQ_IOP13XX_ATUE_IMA   (107) /* 11 */
+#define IRQ_IOP13XX_ATUE_IMB   (108) /* 12 */
+#define IRQ_IOP13XX_ATUE_IMC   (109) /* 13 */
+#define IRQ_IOP13XX_ATUE_IMD   (110) /* 14 */
+#define IRQ_IOP13XX_MU_MSI_TB  (111) /* 15 */
+#define IRQ_IOP13XX_RSVD_112   (112) /* 16 */
+#define IRQ_IOP13XX_RSVD_113   (113) /* 17 */
+#define IRQ_IOP13XX_RSVD_114   (114) /* 18 */
+#define IRQ_IOP13XX_RSVD_115   (115) /* 19 */
+#define IRQ_IOP13XX_RSVD_116   (116) /* 20 */
+#define IRQ_IOP13XX_RSVD_117   (117) /* 21 */
+#define IRQ_IOP13XX_RSVD_118   (118) /* 22 */
+#define IRQ_IOP13XX_RSVD_119   (119) /* 23 */
+#define IRQ_IOP13XX_RSVD_120   (120) /* 24 */
+#define IRQ_IOP13XX_RSVD_121   (121) /* 25 */
+#define IRQ_IOP13XX_RSVD_122   (122) /* 26 */
+#define IRQ_IOP13XX_RSVD_123   (123) /* 27 */
+#define IRQ_IOP13XX_RSVD_124   (124) /* 28 */
+#define IRQ_IOP13XX_RSVD_125   (125) /* 29 */
+#define IRQ_IOP13XX_RSVD_126   (126) /* 30 */
+#define IRQ_IOP13XX_HPI        (127) /* 31 */
+
+#define NR_IOP13XX_IRQS        (IRQ_IOP13XX_HPI + 1)
+#define NR_IRQS                NR_IOP13XX_IRQS
+
+#endif /* _IOP13XX_IRQ_H_ */
diff --git a/include/asm-arm/arch-iop13xx/memory.h b/include/asm-arm/arch-iop13xx/memory.h
new file mode 100644 (file)
index 0000000..031a0fa
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef __ASM_ARCH_MEMORY_H
+#define __ASM_ARCH_MEMORY_H
+
+#include <asm/arch/hardware.h>
+
+/*
+ * Physical DRAM offset.
+ */
+#define PHYS_OFFSET    UL(0x00000000)
+#define TASK_SIZE      UL(0x3f000000)
+#define PAGE_OFFSET    UL(0x40000000)
+#define TASK_UNMAPPED_BASE ((TASK_SIZE + 0x01000000) / 3)
+
+#ifndef __ASSEMBLY__
+
+#if defined(CONFIG_ARCH_IOP13XX)
+#define IOP13XX_PMMR_V_START (IOP13XX_PMMR_VIRT_MEM_BASE)
+#define IOP13XX_PMMR_V_END   (IOP13XX_PMMR_VIRT_MEM_BASE + IOP13XX_PMMR_SIZE)
+#define IOP13XX_PMMR_P_START (IOP13XX_PMMR_PHYS_MEM_BASE)
+#define IOP13XX_PMMR_P_END   (IOP13XX_PMMR_PHYS_MEM_BASE + IOP13XX_PMMR_SIZE)
+
+/*
+ * Virtual view <-> PCI DMA view memory address translations
+ * virt_to_bus: Used to translate the virtual address to an
+ *             address suitable to be passed to set_dma_addr
+ * bus_to_virt: Used to convert an address for DMA operations
+ *             to an address that the kernel can use.
+ */
+
+/* RAM has 1:1 mapping on the PCIe/x Busses */
+#define __virt_to_bus(x)       (__virt_to_phys(x))
+#define __bus_to_virt(x)    (__phys_to_virt(x))
+
+#define virt_to_lbus(x)                                           \
+(( ((void*)(x) >= (void*)IOP13XX_PMMR_V_START) &&                 \
+((void*)(x) < (void*)IOP13XX_PMMR_V_END) ) ?                      \
+((x) - IOP13XX_PMMR_VIRT_MEM_BASE + IOP13XX_PMMR_PHYS_MEM_BASE) : \
+((x) - PAGE_OFFSET + PHYS_OFFSET))
+
+#define lbus_to_virt(x)                                            \
+(( ((x) >= IOP13XX_PMMR_P_START) && ((x) < IOP13XX_PMMR_P_END) ) ? \
+((x) - IOP13XX_PMMR_PHYS_MEM_BASE + IOP13XX_PMMR_VIRT_MEM_BASE ) : \
+((x) - PHYS_OFFSET + PAGE_OFFSET))
+
+/* Device is an lbus device if it is on the platform bus of the IOP13XX */
+#define is_lbus_device(dev) (dev &&\
+                            (strncmp(dev->bus->name, "platform", 8) == 0))
+
+#define __arch_page_to_dma(dev, page)                                  \
+({is_lbus_device(dev) ? (dma_addr_t)virt_to_lbus(page_address(page)) : \
+(dma_addr_t)__virt_to_bus(page_address(page));})
+
+#define __arch_dma_to_virt(dev, addr) \
+({is_lbus_device(dev) ? lbus_to_virt(addr) : __bus_to_virt(addr);})
+
+#define __arch_virt_to_dma(dev, addr) \
+({is_lbus_device(dev) ? virt_to_lbus(addr) : __virt_to_bus(addr);})
+
+#endif /* CONFIG_ARCH_IOP13XX */
+#endif /* !ASSEMBLY */
+
+#define PFN_TO_NID(addr)       (0)
+
+#endif
diff --git a/include/asm-arm/arch-iop13xx/pci.h b/include/asm-arm/arch-iop13xx/pci.h
new file mode 100644 (file)
index 0000000..4041f30
--- /dev/null
@@ -0,0 +1,57 @@
+#ifndef _IOP13XX_PCI_H_
+#define _IOP13XX_PCI_H_
+#include <asm/arch/irqs.h>
+#include <asm/io.h>
+
+struct pci_sys_data;
+struct hw_pci;
+int iop13xx_pci_setup(int nr, struct pci_sys_data *sys);
+struct pci_bus *iop13xx_scan_bus(int nr, struct pci_sys_data *);
+void iop13xx_atu_select(struct hw_pci *plat_pci);
+void iop13xx_pci_init(void);
+void iop13xx_map_pci_memory(void);
+
+#define IOP_PCI_STATUS_ERROR (PCI_STATUS_PARITY |           \
+                              PCI_STATUS_SIG_TARGET_ABORT | \
+                              PCI_STATUS_REC_TARGET_ABORT | \
+                              PCI_STATUS_REC_TARGET_ABORT | \
+                              PCI_STATUS_REC_MASTER_ABORT | \
+                              PCI_STATUS_SIG_SYSTEM_ERROR | \
+                              PCI_STATUS_DETECTED_PARITY)
+
+#define IOP13XX_ATUE_ATUISR_ERROR (IOP13XX_ATUE_STAT_HALT_ON_ERROR |  \
+                                   IOP13XX_ATUE_STAT_ROOT_SYS_ERR |   \
+                                   IOP13XX_ATUE_STAT_PCI_IFACE_ERR |  \
+                                   IOP13XX_ATUE_STAT_ERR_COR |        \
+                                   IOP13XX_ATUE_STAT_ERR_UNCOR |      \
+                                   IOP13XX_ATUE_STAT_CRS |            \
+                                   IOP13XX_ATUE_STAT_DET_PAR_ERR |    \
+                                   IOP13XX_ATUE_STAT_EXT_REC_MABORT | \
+                                   IOP13XX_ATUE_STAT_SIG_TABORT |     \
+                                   IOP13XX_ATUE_STAT_EXT_REC_TABORT | \
+                                   IOP13XX_ATUE_STAT_MASTER_DATA_PAR)
+
+#define IOP13XX_ATUX_ATUISR_ERROR (IOP13XX_ATUX_STAT_TX_SCEM |        \
+                                   IOP13XX_ATUX_STAT_REC_SCEM |       \
+                                   IOP13XX_ATUX_STAT_TX_SERR |        \
+                                   IOP13XX_ATUX_STAT_DET_PAR_ERR |    \
+                                   IOP13XX_ATUX_STAT_INT_REC_MABORT | \
+                                   IOP13XX_ATUX_STAT_REC_SERR |       \
+                                   IOP13XX_ATUX_STAT_EXT_REC_MABORT | \
+                                   IOP13XX_ATUX_STAT_EXT_REC_TABORT | \
+                                   IOP13XX_ATUX_STAT_EXT_SIG_TABORT | \
+                                   IOP13XX_ATUX_STAT_MASTER_DATA_PAR)
+
+/* PCI interrupts
+ */
+#define ATUX_INTA IRQ_IOP13XX_XINT0
+#define ATUX_INTB IRQ_IOP13XX_XINT1
+#define ATUX_INTC IRQ_IOP13XX_XINT2
+#define ATUX_INTD IRQ_IOP13XX_XINT3
+
+#define ATUE_INTA IRQ_IOP13XX_ATUE_IMA
+#define ATUE_INTB IRQ_IOP13XX_ATUE_IMB
+#define ATUE_INTC IRQ_IOP13XX_ATUE_IMC
+#define ATUE_INTD IRQ_IOP13XX_ATUE_IMD
+
+#endif /* _IOP13XX_PCI_H_ */
diff --git a/include/asm-arm/arch-iop13xx/system.h b/include/asm-arm/arch-iop13xx/system.h
new file mode 100644 (file)
index 0000000..ee3a625
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * linux/include/asm-arm/arch-iop13xx/system.h
+ *
+ *  Copyright (C) 2004 Intel Corp.
+ *
+ * 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 <asm/arch/iop13xx.h>
+static inline void arch_idle(void)
+{
+       cpu_do_idle();
+}
+
+/* WDTCR CP6 R7 Page 9 */
+static inline u32 read_wdtcr(void)
+{
+       u32 val;
+       asm volatile("mrc p6, 0, %0, c7, c9, 0":"=r" (val));
+       return val;
+}
+static inline void write_wdtcr(u32 val)
+{
+       asm volatile("mcr p6, 0, %0, c7, c9, 0"::"r" (val));
+}
+
+/* WDTSR CP6 R8 Page 9 */
+static inline u32 read_wdtsr(void)
+{
+       u32 val;
+       asm volatile("mrc p6, 0, %0, c8, c9, 0":"=r" (val));
+       return val;
+}
+static inline void write_wdtsr(u32 val)
+{
+       asm volatile("mcr p6, 0, %0, c8, c9, 0"::"r" (val));
+}
+
+#define IOP13XX_WDTCR_EN_ARM   0x1e1e1e1e
+#define IOP13XX_WDTCR_EN       0xe1e1e1e1
+#define IOP13XX_WDTCR_DIS_ARM  0x1f1f1f1f
+#define IOP13XX_WDTCR_DIS      0xf1f1f1f1
+#define IOP13XX_WDTSR_WRITE_EN (1 << 31)
+#define IOP13XX_WDTCR_IB_RESET (1 << 0)
+static inline void arch_reset(char mode)
+{
+       /*
+        * Reset the internal bus (warning both cores are reset)
+        */
+       u32 cp_flags = iop13xx_cp6_save();
+       write_wdtcr(IOP13XX_WDTCR_EN_ARM);
+       write_wdtcr(IOP13XX_WDTCR_EN);
+       write_wdtsr(IOP13XX_WDTSR_WRITE_EN | IOP13XX_WDTCR_IB_RESET);
+       write_wdtcr(0x1000);
+       iop13xx_cp6_restore(cp_flags);
+
+       for(;;);
+}
diff --git a/include/asm-arm/arch-iop13xx/timex.h b/include/asm-arm/arch-iop13xx/timex.h
new file mode 100644 (file)
index 0000000..f0c51dd
--- /dev/null
@@ -0,0 +1,3 @@
+#include <asm/hardware.h>
+
+#define CLOCK_TICK_RATE (100 * HZ)
diff --git a/include/asm-arm/arch-iop13xx/uncompress.h b/include/asm-arm/arch-iop13xx/uncompress.h
new file mode 100644 (file)
index 0000000..b9525d5
--- /dev/null
@@ -0,0 +1,24 @@
+#include <asm/types.h>
+#include <linux/serial_reg.h>
+#include <asm/hardware.h>
+#include <asm/processor.h>
+
+#define UART_BASE ((volatile u32 *)IOP13XX_UART1_PHYS)
+#define TX_DONE (UART_LSR_TEMT | UART_LSR_THRE)
+
+static inline void putc(char c)
+{
+       while ((UART_BASE[UART_LSR] & TX_DONE) != TX_DONE)
+               cpu_relax();
+       UART_BASE[UART_TX] = c;
+}
+
+static inline void flush(void)
+{
+}
+
+/*
+ * nothing to do
+ */
+#define arch_decomp_setup()
+#define arch_decomp_wdog()
diff --git a/include/asm-arm/arch-iop13xx/vmalloc.h b/include/asm-arm/arch-iop13xx/vmalloc.h
new file mode 100644 (file)
index 0000000..c534567
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _VMALLOC_H_
+#define _VMALLOC_H_
+#define VMALLOC_END    0xfa000000UL
+#endif
index 4281838873eff89156e49a0c0e4c7500fc9505f1..6b437f7c99550e8e56ba5f575ac3814a7efb9c8e 100644 (file)
@@ -76,6 +76,7 @@
 
 #define NSLU2_GPIO_BUZZ                4
 #define NSLU2_BZ_BM            (1L << NSLU2_GPIO_BUZZ)
+
 /* LEDs */
 
 #define NSLU2_LED_RED          NSLU2_GPIO0
@@ -84,8 +85,8 @@
 #define NSLU2_LED_RED_BM       (1L << NSLU2_LED_RED)
 #define NSLU2_LED_GRN_BM       (1L << NSLU2_LED_GRN)
 
-#define NSLU2_LED_DISK1                NSLU2_GPIO2
-#define NSLU2_LED_DISK2                NSLU2_GPIO3
+#define NSLU2_LED_DISK1                NSLU2_GPIO3
+#define NSLU2_LED_DISK2                NSLU2_GPIO2
 
 #define NSLU2_LED_DISK1_BM     (1L << NSLU2_GPIO2)
 #define NSLU2_LED_DISK2_BM     (1L << NSLU2_GPIO3)
diff --git a/include/asm-arm/arch-ixp4xx/udc.h b/include/asm-arm/arch-ixp4xx/udc.h
new file mode 100644 (file)
index 0000000..dbdec36
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+ * linux/include/asm-arm/arch-ixp4xx/udc.h
+ *
+ */
+#include <asm/mach/udc_pxa2xx.h>
+
+extern void ixp4xx_set_udc_info(struct pxa2xx_udc_mach_info *info);
+
index d744d97c18a5fee15f664302ed6085424a9c7f3d..645dbdfb3908d58ad4a8d11bc38e782169f48ce4 100644 (file)
 /*
  * There are not real ISA nor PCI buses, so we fake it.
  */
-#define __io_pci(a)            ((void __iomem *)(PCIO_BASE + (a)))
-#define __mem_pci(a)           (a)
-
-#define __ioaddr(p)             __io_pci(p)
-
-/*
- * Generic virtual read/write
- */
-#define __arch_getb(a)          (*(volatile unsigned char *)(a))
-#define __arch_getl(a)          (*(volatile unsigned int  *)(a))
-
-static inline unsigned int __arch_getw(unsigned long a)
-{
-       unsigned int value;
-       __asm__ __volatile__("ldrh    %0, [%1, #0]    @ getw"
-               : "=&r" (value)
-               : "r" (a) : "cc");
-       return value;
-}
-
-#define __arch_putb(v,a)        (*(volatile unsigned char *)(a) = (v))
-#define __arch_putl(v,a)        (*(volatile unsigned int  *)(a) = (v))
-
-static inline void __arch_putw(unsigned int value, unsigned long a)
+static inline void __iomem *__io(unsigned long addr)
 {
-        __asm__ __volatile__("strh    %0, [%1, #0]    @ putw"
-                : : "r" (value), "r" (a) : "cc");
+       return (void __iomem *)addr;
 }
-
-/*
- * Translated address IO functions
- *
- * IO address has already been translated to a virtual address
- */
-#define outb_t(v,p)            (*(volatile unsigned char *)(p) = (v))
-#define inb_t(p)               (*(volatile unsigned char *)(p))
-#define outw_t(v,p)            (*(volatile unsigned int *)(p) = (v))
-#define inw_t(p)               (*(volatile unsigned int *)(p))
-#define outl_t(v,p)            (*(volatile unsigned long *)(p) = (v))
-#define inl_t(p)               (*(volatile unsigned long *)(p))
-
-/*
- * FIXME - These are to allow for linking. On all the other
- *         ARM platforms, the entire IO space is contiguous.
- *         The 7200 has three separate IO spaces. The below
- *         macros will eventually become more involved. Use
- *         with caution and don't be surprised by kernel oopses!!!
- */
-#define inb(p)                 inb_t(p)
-#define inw(p)                 inw_t(p)
-#define inl(p)                 inl_t(p)
-#define outb(v,p)              outb_t(v,p)
-#define outw(v,p)              outw_t(v,p)
-#define outl(v,p)              outl_t(v,p)
+#define __io(a)        __io(a)
+#define __mem_pci(a)           (a)
 
 #endif
index 9f1a58cbf407dfa1a3b37b8caac598bd0c5aa872..9b0c8012e71351e164d715100550e9b8f08b6647 100644 (file)
     (((pfn) - PHYS_PFN_OFFSET) >> (26 - PAGE_SHIFT))
 #endif
 
-/*
- * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
- * and return the mem_map of that node.
- */
-# define ADDR_TO_MAPBASE(kaddr)        NODE_MEM_MAP(KVADDR_TO_NID(kaddr))
-
-/*
- * Given a page frame number, find the owning node of the memory
- * and return the mem_map of that node.
- */
-# define PFN_TO_MAPBASE(pfn)   NODE_MEM_MAP(PFN_TO_NID(pfn))
-
 /*
  * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
  * and returns the index corresponding to the appropriate page in the
index eaf6d43939e9ef74cf9ab371ee7f9f6d186b8e83..e17f9881faf0c55e9f7d3437b1dc08ad5cf1fbd2 100644 (file)
@@ -27,7 +27,6 @@
 #define __virt_to_bus(x)        __virt_to_phys(x)
 #define __bus_to_virt(x)        __phys_to_virt(x)
 
-#ifdef CONFIG_DISCONTIGMEM
 /*
  * The nodes are matched with the physical SDRAM banks as follows:
  *
  *     node 1:  0xa4000000-0xa7ffffff  -->  0xc4000000-0xc7ffffff
  *     node 2:  0xa8000000-0xabffffff  -->  0xc8000000-0xcbffffff
  *     node 3:  0xac000000-0xafffffff  -->  0xcc000000-0xcfffffff
+ *
+ * This needs a node mem size of 26 bits.
  */
-
-/*
- * Given a kernel address, find the home node of the underlying memory.
- */
-#define KVADDR_TO_NID(addr) (((unsigned long)(addr) - PAGE_OFFSET) >> 26)
-
-/*
- * Given a page frame number, convert it to a node id.
- */
-#define PFN_TO_NID(pfn)                (((pfn) - PHYS_PFN_OFFSET) >> (26 - PAGE_SHIFT))
-
-/*
- * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
- * and returns the mem_map of that node.
- */
-#define ADDR_TO_MAPBASE(kaddr) NODE_MEM_MAP(KVADDR_TO_NID(kaddr))
-
-/*
- * Given a page frame number, find the owning node of the memory
- * and returns the mem_map of that node.
- */
-#define PFN_TO_MAPBASE(pfn)    NODE_MEM_MAP(PFN_TO_NID(pfn))
-
-/*
- * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
- * and returns the index corresponding to the appropriate page in the
- * node's mem_map.
- */
-#define LOCAL_MAP_NR(addr) \
-       (((unsigned long)(addr) & 0x03ffffff) >> PAGE_SHIFT)
-
-#endif
+#define NODE_MEM_SIZE_BITS     26
 
 #endif
index cff752f35230766554a28d9c7241704a9b5e37a0..083e03c5639ff4a9c1dfd68364bb5144a7a4df11 100644 (file)
@@ -99,7 +99,7 @@
 #define DCSR_SETCMPST  (1 << 25)       /* Set Descriptor Compare Status */
 #define DCSR_CLRCMPST  (1 << 24)       /* Clear Descriptor Compare Status */
 #define DCSR_CMPST     (1 << 10)       /* The Descriptor Compare Status */
-#define DCSR_ENRINTR   (1 << 9)        /* The end of Receive */
+#define DCSR_EORINTR   (1 << 9)        /* The end of Receive */
 #endif
 #define DCSR_REQPEND   (1 << 8)        /* Request Pending (read-only) */
 #define DCSR_STOPSTATE (1 << 3)        /* Stop State (read-only) */
 #define UDCISR0         __REG(0x4060000C) /* UDC Interrupt Status Register 0 */
 #define UDCISR1         __REG(0x40600010) /* UDC Interrupt Status Register 1 */
 #define UDCISR_INT(n,intr) (((intr) & 0x03) << (((n) & 0x0F) * 2))
-#define UDCISR1_IECC   (1 << 31)       /* IntEn - Configuration Change */
-#define UDCISR1_IESOF  (1 << 30)       /* IntEn - Start of Frame */
-#define UDCISR1_IERU   (1 << 29)       /* IntEn - Resume */
-#define UDCISR1_IESU   (1 << 28)       /* IntEn - Suspend */
-#define UDCISR1_IERS   (1 << 27)       /* IntEn - Reset */
-
+#define UDCISR1_IRCC   (1 << 31)       /* IntReq - Configuration Change */
+#define UDCISR1_IRSOF  (1 << 30)       /* IntReq - Start of Frame */
+#define UDCISR1_IRRU   (1 << 29)       /* IntReq - Resume */
+#define UDCISR1_IRSU   (1 << 28)       /* IntReq - Suspend */
+#define UDCISR1_IRRS   (1 << 27)       /* IntReq - Reset */
 
 #define UDCFNR          __REG(0x40600014) /* UDC Frame Number Register */
 #define UDCOTGICR      __REG(0x40600018) /* UDC On-The-Go interrupt control */
index 90894214cace08f12b7c1c227e5ea5c65831050e..93a58e7862b050f6512d8249979e1b87caf083d4 100644 (file)
@@ -31,6 +31,9 @@ struct s3c2410fb_hw {
 struct s3c2410fb_mach_info {
        unsigned char   fixed_syncs;    /* do not update sync/border */
 
+       /* LCD types */
+       int             type;
+
        /* Screen size */
        int             width;
        int             height;
diff --git a/include/asm-arm/arch-s3c2410/h1940.h b/include/asm-arm/arch-s3c2410/h1940.h
new file mode 100644 (file)
index 0000000..6135592
--- /dev/null
@@ -0,0 +1,21 @@
+/* linux/include/asm-arm/arch-s3c2410/h1940.h
+ *
+ * Copyright 2006 Ben Dooks <ben-linux@fluff.org>
+ *
+ * H1940 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
+ * published by the Free Software Foundation.
+*/
+
+#ifndef __ASM_ARCH_H1940_H
+#define __ASM_ARCH_H1940_H
+
+#define H1940_SUSPEND_CHECKSUM         (0x30003ff8)
+#define H1940_SUSPEND_RESUMEAT         (0x30081000)
+#define H1940_SUSPEND_CHECK            (0x30080000)
+
+extern void h1940_pm_return(void);
+
+#endif /* __ASM_ARCH_H1940_H */
index 718246d85952d361958374b5200bf9af5e7577d3..4f72a853a5cfc76fbbb4a95fe7efdf283eb7d564 100644 (file)
@@ -71,7 +71,7 @@ arch_reset(char mode)
 
        /* set the watchdog to go and reset... */
        __raw_writel(S3C2410_WTCON_ENABLE|S3C2410_WTCON_DIV16|S3C2410_WTCON_RSTEN |
-                    S3C2410_WTCON_PRESCALE(0x80), S3C2410_WTCON);
+                    S3C2410_WTCON_PRESCALE(0x20), S3C2410_WTCON);
 
        /* wait for reset to assert... */
        mdelay(5000);
diff --git a/include/asm-arm/arch-sa1100/jornada720.h b/include/asm-arm/arch-sa1100/jornada720.h
deleted file mode 100644 (file)
index 3f37ca0..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * linux/include/asm-arm/arch-sa1100/jornada720.h
- *
- * Created 2000/11/29 by John Ankcorn <jca@lcs.mit.edu>
- *
- * This file contains the hardware specific definitions for HP Jornada 720
- *
- */
-
-#ifndef __ASM_ARCH_HARDWARE_H
-#error "include <asm/hardware.h> instead"
-#endif
-
-#define SA1111_BASE             (0x40000000)
-
-#define GPIO_JORNADA720_KEYBOARD       GPIO_GPIO(0)
-#define GPIO_JORNADA720_MOUSE          GPIO_GPIO(9)
-
-#define GPIO_JORNADA720_KEYBOARD_IRQ   IRQ_GPIO0
-#define GPIO_JORNADA720_MOUSE_IRQ              IRQ_GPIO9
-
-/* MCU COMMANDS */
-#define MCU_GetBatteryData  0xc0
-#define MCU_GetScanKeyCode  0x90
-#define MCU_GetTouchSamples 0xa0
-#define MCU_GetContrast     0xD0
-#define MCU_SetContrast     0xD1
-#define MCU_GetBrightness   0xD2
-#define MCU_SetBrightness   0xD3
-#define MCU_ContrastOff     0xD8
-#define MCU_BrightnessOff   0xD9
-#define MCU_PWMOFF          0xDF
-#define MCU_TxDummy         0x11
-#define MCU_ErrorCode       0x00
-
-#ifndef __ASSEMBLY__
-
-void jornada720_mcu_init(void);
-void jornada_contrast(int arg_contrast);
-void jornada720_battery(void);
-int jornada720_getkey(unsigned char *data, int size);
-#endif
index 1ff172dc8e33f21fd7375c359a29d31da831465d..0e907fc6d42a5694c27905de849b092ed783f3eb 100644 (file)
@@ -39,7 +39,6 @@ void sa1111_adjust_zones(int node, unsigned long *size, unsigned long *holes);
 #define __virt_to_bus(x)        __virt_to_phys(x)
 #define __bus_to_virt(x)        __phys_to_virt(x)
 
-#ifdef CONFIG_DISCONTIGMEM
 /*
  * 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 
@@ -57,38 +56,7 @@ void sa1111_adjust_zones(int node, unsigned long *size, unsigned long *holes);
  *     node 2:  0xd0000000 - 0xd7ffffff
  *     node 3:  0xd8000000 - 0xdfffffff
  */
-
-/*
- * Given a kernel address, find the home node of the underlying memory.
- */
-#define KVADDR_TO_NID(addr) (((unsigned long)(addr) - PAGE_OFFSET) >> 27)
-
-/*
- * Given a page frame number, convert it to a node id.
- */
-#define PFN_TO_NID(pfn)                (((pfn) - PHYS_PFN_OFFSET) >> (27 - PAGE_SHIFT))
-
-/*
- * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
- * and return the mem_map of that node.
- */
-#define ADDR_TO_MAPBASE(kaddr) NODE_MEM_MAP(KVADDR_TO_NID(kaddr))
-
-/*
- * Given a page frame number, find the owning node of the memory
- * and return the mem_map of that node.
- */
-#define PFN_TO_MAPBASE(pfn)    NODE_MEM_MAP(PFN_TO_NID(pfn))
-
-/*
- * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
- * and returns the index corresponding to the appropriate page in the
- * node's mem_map.
- */
-#define LOCAL_MAP_NR(addr) \
-       (((unsigned long)(addr) & 0x07ffffff) >> PAGE_SHIFT)
-
-#endif
+#define NODE_MEM_SIZE_BITS     27
 
 /*
  * Cache flushing area - SA1100 zero bank
index 0e36fd5d87df2f3d1771a9f34581cf82e17dfc2b..7b62351f097d2f49ff6fcfb7ea0e0c43e11d012f 100644 (file)
@@ -4,10 +4,10 @@
 
 #ifdef CONFIG_BUG
 #ifdef CONFIG_DEBUG_BUGVERBOSE
-extern void __bug(const char *file, int line, void *data) __attribute__((noreturn));
+extern void __bug(const char *file, int line) __attribute__((noreturn));
 
 /* give file/line information */
-#define BUG()          __bug(__FILE__, __LINE__, NULL)
+#define BUG()          __bug(__FILE__, __LINE__)
 
 #else
 
diff --git a/include/asm-arm/cnt32_to_63.h b/include/asm-arm/cnt32_to_63.h
new file mode 100644 (file)
index 0000000..480c873
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ *  include/asm/cnt32_to_63.h -- extend a 32-bit counter to 63 bits
+ *
+ *  Author:    Nicolas Pitre
+ *  Created:   December 3, 2006
+ *  Copyright: 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.
+ */
+
+#ifndef __INCLUDE_CNT32_TO_63_H__
+#define __INCLUDE_CNT32_TO_63_H__
+
+#include <linux/compiler.h>
+#include <asm/types.h>
+#include <asm/byteorder.h>
+
+/*
+ * Prototype: u64 cnt32_to_63(u32 cnt)
+ * Many hardware clock counters are only 32 bits wide and therefore have
+ * a relatively short period making wrap-arounds rather frequent.  This
+ * is a problem when implementing sched_clock() for example, where a 64-bit
+ * non-wrapping monotonic value is expected to be returned.
+ *
+ * To overcome that limitation, let's extend a 32-bit counter to 63 bits
+ * in a completely lock free fashion. Bits 0 to 31 of the clock are provided
+ * by the hardware while bits 32 to 62 are stored in memory.  The top bit in
+ * memory is used to synchronize with the hardware clock half-period.  When
+ * the top bit of both counters (hardware and in memory) differ then the
+ * memory is updated with a new value, incrementing it when the hardware
+ * counter wraps around.
+ *
+ * Because a word store in memory is atomic then the incremented value will
+ * always be in synch with the top bit indicating to any potential concurrent
+ * reader if the value in memory is up to date or not with regards to the
+ * needed increment.  And any race in updating the value in memory is harmless
+ * as the same value would simply be stored more than once.
+ *
+ * The only restriction for the algorithm to work properly is that this
+ * code must be executed at least once per each half period of the 32-bit
+ * counter to properly update the state bit in memory. This is usually not a
+ * problem in practice, but if it is then a kernel timer could be scheduled
+ * to manage for this code to be executed often enough.
+ *
+ * Note that the top bit (bit 63) in the returned value should be considered
+ * as garbage.  It is not cleared here because callers are likely to use a
+ * multiplier on the returned value which can get rid of the top bit
+ * implicitly by making the multiplier even, therefore saving on a runtime
+ * clear-bit instruction. Otherwise caller must remember to clear the top
+ * bit explicitly.
+ */
+
+/* this is used only to give gcc a clue about good code generation */
+typedef union {
+       struct {
+#if defined(__LITTLE_ENDIAN)
+               u32 lo, hi;
+#elif defined(__BIG_ENDIAN)
+               u32 hi, lo;
+#endif
+       };
+       u64 val;
+} cnt32_to_63_t;
+
+#define cnt32_to_63(cnt_lo) \
+({ \
+       static volatile u32 __m_cnt_hi = 0; \
+       cnt32_to_63_t __x; \
+       __x.hi = __m_cnt_hi; \
+       __x.lo = (cnt_lo); \
+       if (unlikely((s32)(__x.hi ^ __x.lo) < 0)) \
+               __m_cnt_hi = __x.hi = (__x.hi ^ 0x80000000) + (__x.hi >> 31); \
+       __x.val; \
+})
+
+#endif
index 3682616804ca42ef67014f9f400c97daaa1bf9de..37e0a96e8789b85280b42654931b084c41a5d5ed 100644 (file)
@@ -27,7 +27,7 @@
 #define __xh "r1"
 #endif
 
-#define do_div(n,base)                                         \
+#define __do_div_asm(n, base)                                  \
 ({                                                             \
        register unsigned int __base      asm("r4") = base;     \
        register unsigned long long __n   asm("r0") = n;        \
        __rem;                                                  \
 })
 
+#if __GNUC__ < 4
+
+/*
+ * gcc versions earlier than 4.0 are simply too problematic for the
+ * optimized implementation below. First there is gcc PR 15089 that
+ * tend to trig on more complex constructs, spurious .global __udivsi3
+ * are inserted even if none of those symbols are referenced in the
+ * generated code, and those gcc versions are not able to do constant
+ * propagation on long long values anyway.
+ */
+#define do_div(n, base) __do_div_asm(n, base)
+
+#elif __GNUC__ >= 4
+
+#include <asm/bug.h>
+
+/*
+ * If the divisor happens to be constant, we determine the appropriate
+ * inverse at compile time to turn the division into a few inline
+ * multiplications instead which is much faster. And yet only if compiling
+ * for ARMv4 or higher (we need umull/umlal) and if the gcc version is
+ * sufficiently recent to perform proper long long constant propagation.
+ * (It is unfortunate that gcc doesn't perform all this internally.)
+ */
+#define do_div(n, base)                                                        \
+({                                                                     \
+       unsigned int __r, __b = (base);                                 \
+       if (!__builtin_constant_p(__b) || __b == 0 ||                   \
+           (__LINUX_ARM_ARCH__ < 4 && (__b & (__b - 1)) != 0)) {       \
+               /* non-constant divisor (or zero): slow path */         \
+               __r = __do_div_asm(n, __b);                             \
+       } else if ((__b & (__b - 1)) == 0) {                            \
+               /* Trivial: __b is constant and a power of 2 */         \
+               /* gcc does the right thing with this code.  */         \
+               __r = n;                                                \
+               __r &= (__b - 1);                                       \
+               n /= __b;                                               \
+       } else {                                                        \
+               /* Multiply by inverse of __b: n/b = n*(p/b)/p       */ \
+               /* We rely on the fact that most of this code gets   */ \
+               /* optimized away at compile time due to constant    */ \
+               /* propagation and only a couple inline assembly     */ \
+               /* instructions should remain. Better avoid any      */ \
+               /* code construct that might prevent that.           */ \
+               unsigned long long __res, __x, __t, __m, __n = n;       \
+               unsigned int __c, __p, __z = 0;                         \
+               /* preserve low part of n for reminder computation */   \
+               __r = __n;                                              \
+               /* determine number of bits to represent __b */         \
+               __p = 1 << __div64_fls(__b);                            \
+               /* compute __m = ((__p << 64) + __b - 1) / __b */       \
+               __m = (~0ULL / __b) * __p;                              \
+               __m += (((~0ULL % __b + 1) * __p) + __b - 1) / __b;     \
+               /* compute __res = __m*(~0ULL/__b*__b-1)/(__p << 64) */ \
+               __x = ~0ULL / __b * __b - 1;                            \
+               __res = (__m & 0xffffffff) * (__x & 0xffffffff);        \
+               __res >>= 32;                                           \
+               __res += (__m & 0xffffffff) * (__x >> 32);              \
+               __t = __res;                                            \
+               __res += (__x & 0xffffffff) * (__m >> 32);              \
+               __t = (__res < __t) ? (1ULL << 32) : 0;                 \
+               __res = (__res >> 32) + __t;                            \
+               __res += (__m >> 32) * (__x >> 32);                     \
+               __res /= __p;                                           \
+               /* Now sanitize and optimize what we've got. */         \
+               if (~0ULL % (__b / (__b & -__b)) == 0) {                \
+                       /* those cases can be simplified with: */       \
+                       __n /= (__b & -__b);                            \
+                       __m = ~0ULL / (__b / (__b & -__b));             \
+                       __p = 1;                                        \
+                       __c = 1;                                        \
+               } else if (__res != __x / __b) {                        \
+                       /* We can't get away without a correction    */ \
+                       /* to compensate for bit truncation errors.  */ \
+                       /* To avoid it we'd need an additional bit   */ \
+                       /* to represent __m which would overflow it. */ \
+                       /* Instead we do m=p/b and n/b=(n*m+m)/p.    */ \
+                       __c = 1;                                        \
+                       /* Compute __m = (__p << 64) / __b */           \
+                       __m = (~0ULL / __b) * __p;                      \
+                       __m += ((~0ULL % __b + 1) * __p) / __b;         \
+               } else {                                                \
+                       /* Reduce __m/__p, and try to clear bit 31   */ \
+                       /* of __m when possible otherwise that'll    */ \
+                       /* need extra overflow handling later.       */ \
+                       unsigned int __bits = -(__m & -__m);            \
+                       __bits |= __m >> 32;                            \
+                       __bits = (~__bits) << 1;                        \
+                       /* If __bits == 0 then setting bit 31 is     */ \
+                       /* unavoidable.  Simply apply the maximum    */ \
+                       /* possible reduction in that case.          */ \
+                       /* Otherwise the MSB of __bits indicates the */ \
+                       /* best reduction we should apply.           */ \
+                       if (!__bits) {                                  \
+                               __p /= (__m & -__m);                    \
+                               __m /= (__m & -__m);                    \
+                       } else {                                        \
+                               __p >>= __div64_fls(__bits);            \
+                               __m >>= __div64_fls(__bits);            \
+                       }                                               \
+                       /* No correction needed. */                     \
+                       __c = 0;                                        \
+               }                                                       \
+               /* Now we have a combination of 2 conditions:        */ \
+               /* 1) whether or not we need a correction (__c), and */ \
+               /* 2) whether or not there might be an overflow in   */ \
+               /*    the cross product (__m & ((1<<63) | (1<<31)))  */ \
+               /* Select the best insn combination to perform the   */ \
+               /* actual __m * __n / (__p << 64) operation.         */ \
+               if (!__c) {                                             \
+                       asm (   "umull  %Q0, %R0, %1, %Q2\n\t"          \
+                               "mov    %Q0, #0"                        \
+                               : "=&r" (__res)                         \
+                               : "r" (__m), "r" (__n)                  \
+                               : "cc" );                               \
+               } else if (!(__m & ((1ULL << 63) | (1ULL << 31)))) {    \
+                       __res = __m;                                    \
+                       asm (   "umlal  %Q0, %R0, %Q1, %Q2\n\t"         \
+                               "mov    %Q0, #0"                        \
+                               : "+r" (__res)                          \
+                               : "r" (__m), "r" (__n)                  \
+                               : "cc" );                               \
+               } else {                                                \
+                       asm (   "umull  %Q0, %R0, %Q1, %Q2\n\t"         \
+                               "cmn    %Q0, %Q1\n\t"                   \
+                               "adcs   %R0, %R0, %R1\n\t"              \
+                               "adc    %Q0, %3, #0"                    \
+                               : "=&r" (__res)                         \
+                               : "r" (__m), "r" (__n), "r" (__z)       \
+                               : "cc" );                               \
+               }                                                       \
+               if (!(__m & ((1ULL << 63) | (1ULL << 31)))) {           \
+                       asm (   "umlal  %R0, %Q0, %R1, %Q2\n\t"         \
+                               "umlal  %R0, %Q0, %Q1, %R2\n\t"         \
+                               "mov    %R0, #0\n\t"                    \
+                               "umlal  %Q0, %R0, %R1, %R2"             \
+                               : "+r" (__res)                          \
+                               : "r" (__m), "r" (__n)                  \
+                               : "cc" );                               \
+               } else {                                                \
+                       asm (   "umlal  %R0, %Q0, %R2, %Q3\n\t"         \
+                               "umlal  %R0, %1, %Q2, %R3\n\t"          \
+                               "mov    %R0, #0\n\t"                    \
+                               "adds   %Q0, %1, %Q0\n\t"               \
+                               "adc    %R0, %R0, #0\n\t"               \
+                               "umlal  %Q0, %R0, %R2, %R3"             \
+                               : "+r" (__res), "+r" (__z)              \
+                               : "r" (__m), "r" (__n)                  \
+                               : "cc" );                               \
+               }                                                       \
+               __res /= __p;                                           \
+               /* The reminder can be computed with 32-bit regs     */ \
+               /* only, and gcc is good at that.                    */ \
+               {                                                       \
+                       unsigned int __res0 = __res;                    \
+                       unsigned int __b0 = __b;                        \
+                       __r -= __res0 * __b0;                           \
+               }                                                       \
+               /* BUG_ON(__r >= __b || __res * __b + __r != n); */     \
+               n = __res;                                              \
+       }                                                               \
+       __r;                                                            \
+})
+
+/* our own fls implementation to make sure constant propagation is fine */
+#define __div64_fls(bits)                                              \
+({                                                                     \
+       unsigned int __left = (bits), __nr = 0;                         \
+       if (__left & 0xffff0000) __nr += 16, __left >>= 16;             \
+       if (__left & 0x0000ff00) __nr +=  8, __left >>=  8;             \
+       if (__left & 0x000000f0) __nr +=  4, __left >>=  4;             \
+       if (__left & 0x0000000c) __nr +=  2, __left >>=  2;             \
+       if (__left & 0x00000002) __nr +=  1;                            \
+       __nr;                                                           \
+})
+
+#endif
+
 #endif
index 666617711c81d259745ba2b0dc12d935c4d4fb0a..9bc46b486afba7a5970e93b5c938a3be33c4684e 100644 (file)
@@ -48,7 +48,7 @@ static inline int dma_get_cache_alignment(void)
        return 32;
 }
 
-static inline int dma_is_consistent(dma_addr_t handle)
+static inline int dma_is_consistent(struct device *dev, dma_addr_t handle)
 {
        return !!arch_is_coherent();
 }
index 17f0c656d2724ced3166ac37e43bc73c6fc44ad3..642382d2c9f051eec79f4b13ffcfc7cbc4a42432 100644 (file)
@@ -1,17 +1,22 @@
 #ifndef __ASMARM_ELF_H
 #define __ASMARM_ELF_H
 
-
+#ifndef __ASSEMBLY__
 /*
  * ELF register definitions..
  */
-
 #include <asm/ptrace.h>
 #include <asm/user.h>
 
 typedef unsigned long elf_greg_t;
 typedef unsigned long elf_freg_t[3];
 
+#define ELF_NGREG (sizeof (struct pt_regs) / sizeof(elf_greg_t))
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+typedef struct user_fp elf_fpregset_t;
+#endif
+
 #define EM_ARM 40
 #define EF_ARM_APCS26 0x08
 #define EF_ARM_SOFT_FLOAT 0x200
@@ -23,11 +28,6 @@ typedef unsigned long elf_freg_t[3];
 #define R_ARM_CALL     28
 #define R_ARM_JUMP24   29
 
-#define ELF_NGREG (sizeof (struct pt_regs) / sizeof(elf_greg_t))
-typedef elf_greg_t elf_gregset_t[ELF_NGREG];
-
-typedef struct user_fp elf_fpregset_t;
-
 /*
  * These are used to set parameters in the core dumps.
  */
@@ -39,97 +39,99 @@ typedef struct user_fp elf_fpregset_t;
 #endif
 #define ELF_ARCH       EM_ARM
 
-#ifdef __KERNEL__
-#include <asm/procinfo.h>
-
 /*
- * This is used to ensure we don't load something for the wrong architecture.
+ * HWCAP flags - for elf_hwcap (in kernel) and AT_HWCAP
  */
-#define elf_check_arch(x) ( ((x)->e_machine == EM_ARM) && (ELF_PROC_OK((x))) )
-
-#define USE_ELF_CORE_DUMP
-#define ELF_EXEC_PAGESIZE      4096
-
-/* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
-   use of this is to invoke "./ld.so someprog" to test out a new version of
-   the loader.  We need to make sure that it is out of the way of the program
-   that it will "exec", and that there is sufficient room for the brk.  */
-
-#define ELF_ET_DYN_BASE        (2 * TASK_SIZE / 3)
-
-/* When the program starts, a1 contains a pointer to a function to be 
-   registered with atexit, as per the SVR4 ABI.  A value of 0 means we 
-   have no such handler.  */
-#define ELF_PLAT_INIT(_r, load_addr)   (_r)->ARM_r0 = 0
-
-/* This yields a mask that user programs can use to figure out what
-   instruction set this cpu supports. */
+#define HWCAP_SWP      1
+#define HWCAP_HALF     2
+#define HWCAP_THUMB    4
+#define HWCAP_26BIT    8       /* Play it safe */
+#define HWCAP_FAST_MULT        16
+#define HWCAP_FPA      32
+#define HWCAP_VFP      64
+#define HWCAP_EDSP     128
+#define HWCAP_JAVA     256
+#define HWCAP_IWMMXT   512
 
+#ifdef __KERNEL__
+#ifndef __ASSEMBLY__
+/*
+ * This yields a mask that user programs can use to figure out what
+ * instruction set this cpu supports.
+ */
 #define ELF_HWCAP      (elf_hwcap)
+extern unsigned int elf_hwcap;
 
-/* This yields a string that ld.so will use to load implementation
-   specific libraries for optimization.  This is more specific in
-   intent than poking at uname or /proc/cpuinfo. */
-
-/* For now we just provide a fairly general string that describes the
-   processor family.  This could be made more specific later if someone
-   implemented optimisations that require it.  26-bit CPUs give you
-   "v1l" for ARM2 (no SWP) and "v2l" for anything else (ARM1 isn't
-   supported).  32-bit CPUs give you "v3[lb]" for anything based on an
-   ARM6 or ARM7 core and "armv4[lb]" for anything based on a StrongARM-1
-   core.  */
-
+/*
+ * This yields a string that ld.so will use to load implementation
+ * specific libraries for optimization.  This is more specific in
+ * intent than poking at uname or /proc/cpuinfo.
+ *
+ * For now we just provide a fairly general string that describes the
+ * processor family.  This could be made more specific later if someone
+ * implemented optimisations that require it.  26-bit CPUs give you
+ * "v1l" for ARM2 (no SWP) and "v2l" for anything else (ARM1 isn't
+ * supported).  32-bit CPUs give you "v3[lb]" for anything based on an
+ * ARM6 or ARM7 core and "armv4[lb]" for anything based on a StrongARM-1
+ * core.
+ */
 #define ELF_PLATFORM_SIZE 8
-extern char elf_platform[];
 #define ELF_PLATFORM   (elf_platform)
 
+extern char elf_platform[];
+#endif
+
+/*
+ * This is used to ensure we don't load something for the wrong architecture.
+ */
+#define elf_check_arch(x) ((x)->e_machine == EM_ARM && ELF_PROC_OK(x))
+
 /*
  * 32-bit code is always OK.  Some cpus can do 26-bit, some can't.
  */
 #define ELF_PROC_OK(x) (ELF_THUMB_OK(x) && ELF_26BIT_OK(x))
 
 #define ELF_THUMB_OK(x) \
-       (( (elf_hwcap & HWCAP_THUMB) && ((x)->e_entry & 1) == 1) || \
+       ((elf_hwcap & HWCAP_THUMB && ((x)->e_entry & 1) == 1) || \
         ((x)->e_entry & 3) == 0)
 
 #define ELF_26BIT_OK(x) \
-       (( (elf_hwcap & HWCAP_26BIT) && (x)->e_flags & EF_ARM_APCS26) || \
+       ((elf_hwcap & HWCAP_26BIT && (x)->e_flags & EF_ARM_APCS26) || \
          ((x)->e_flags & EF_ARM_APCS26) == 0)
 
-#ifndef CONFIG_IWMMXT
+#define USE_ELF_CORE_DUMP
+#define ELF_EXEC_PAGESIZE      4096
 
-/* Old NetWinder binaries were compiled in such a way that the iBCS
-   heuristic always trips on them.  Until these binaries become uncommon
-   enough not to care, don't trust the `ibcs' flag here.  In any case
-   there is no other ELF system currently supported by iBCS.
-   @@ Could print a warning message to encourage users to upgrade.  */
-#define SET_PERSONALITY(ex,ibcs2) \
-       set_personality(((ex).e_flags&EF_ARM_APCS26 ?PER_LINUX :PER_LINUX_32BIT))
+/* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
+   use of this is to invoke "./ld.so someprog" to test out a new version of
+   the loader.  We need to make sure that it is out of the way of the program
+   that it will "exec", and that there is sufficient room for the brk.  */
 
-#else
+#define ELF_ET_DYN_BASE        (2 * TASK_SIZE / 3)
+
+/* When the program starts, a1 contains a pointer to a function to be 
+   registered with atexit, as per the SVR4 ABI.  A value of 0 means we 
+   have no such handler.  */
+#define ELF_PLAT_INIT(_r, load_addr)   (_r)->ARM_r0 = 0
 
 /*
- * All iWMMXt capable CPUs don't support 26-bit mode.  Yet they can run
- * legacy binaries which used to contain FPA11 floating point instructions
- * that have always been emulated by the kernel.  PFA11 and iWMMXt overlap
- * on coprocessor 1 space though.  We therefore must decide if given task
- * is allowed to use CP 0 and 1 for iWMMXt, or if they should be blocked
- * at all times for the prefetch exception handler to catch FPA11 opcodes
- * and emulate them.  The best indication to discriminate those two cases
- * is the SOFT_FLOAT flag in the ELF header.
+ * Since the FPA coprocessor uses CP1 and CP2, and iWMMXt uses CP0
+ * and CP1, we only enable access to the iWMMXt coprocessor if the
+ * binary is EABI or softfloat (and thus, guaranteed not to use
+ * FPA instructions.)
  */
-
-#define SET_PERSONALITY(ex,ibcs2) \
-do { \
-       set_personality(PER_LINUX_32BIT); \
-       if (((ex).e_flags & EF_ARM_EABI_MASK) || \
-           ((ex).e_flags & EF_ARM_SOFT_FLOAT)) \
-               set_thread_flag(TIF_USING_IWMMXT); \
-       else \
-               clear_thread_flag(TIF_USING_IWMMXT); \
-} while (0)
-
-#endif
+#define SET_PERSONALITY(ex, ibcs2)                                     \
+       do {                                                            \
+               if ((ex).e_flags & EF_ARM_APCS26) {                     \
+                       set_personality(PER_LINUX);                     \
+               } else {                                                \
+                       set_personality(PER_LINUX_32BIT);               \
+                       if (elf_hwcap & HWCAP_IWMMXT && (ex).e_flags & (EF_ARM_EABI_MASK | EF_ARM_SOFT_FLOAT)) \
+                               set_thread_flag(TIF_USING_IWMMXT);      \
+                       else                                            \
+                               clear_thread_flag(TIF_USING_IWMMXT);    \
+               }                                                       \
+       } while (0)
 
 #endif
 
index ae999fd5dc679e74108bd81678e2eeea1e90c11c..288f76b166d00709a73ce679e585cf2a7dcb266e 100644 (file)
@@ -75,14 +75,6 @@ extern void __readwrite_bug(const char *fn);
  */
 #include <asm/arch/io.h>
 
-#ifdef __io_pci
-#warning machine class uses buggy __io_pci
-#endif
-#if defined(__arch_putb) || defined(__arch_putw) || defined(__arch_putl) || \
-    defined(__arch_getb) || defined(__arch_getw) || defined(__arch_getl)
-#warning machine class uses old __arch_putw or __arch_getw
-#endif
-
 /*
  *  IO port access primitives
  *  -------------------------
index 0e017ecf20966f01a7a4d4abbb10926dc8c23c6f..eb0bfba6570d6ae294fa50adf0a349527ba2ad86 100644 (file)
@@ -21,12 +21,6 @@ extern void (*init_arch_irq)(void);
 extern void init_FIQ(void);
 extern int show_fiq_list(struct seq_file *, void *);
 
-/*
- * Function wrappers
- */
-#define set_irq_chipdata(irq, d)       set_irq_chip_data(irq, d)
-#define get_irq_chipdata(irq)          get_irq_chip_data(irq)
-
 /*
  * Obsolete inline function for calling irq descriptor handlers.
  */
@@ -44,12 +38,6 @@ void set_irq_flags(unsigned int irq, unsigned int flags);
 /*
  * This is for easy migration, but should be changed in the source
  */
-#define do_level_IRQ   handle_level_irq
-#define do_edge_IRQ    handle_edge_irq
-#define do_simple_IRQ  handle_simple_irq
-#define irqdesc                irq_desc
-#define irqchip                irq_chip
-
 #define do_bad_IRQ(irq,desc)                           \
 do {                                                   \
        spin_lock(&desc->lock);                         \
index 91d536c215d79fc700b5c79f0dfb185bc6003eba..d9bfb39adabf02650ad0d4410c8e8c461b508069 100644 (file)
@@ -215,6 +215,7 @@ static inline __deprecated void *bus_to_virt(unsigned long x)
  *  virt_addr_valid(k) indicates whether a virtual address is valid
  */
 #ifndef CONFIG_DISCONTIGMEM
+
 #define ARCH_PFN_OFFSET                PHYS_PFN_OFFSET
 #define pfn_valid(pfn)         ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr))
 
@@ -230,6 +231,7 @@ static inline __deprecated void *bus_to_virt(unsigned long x)
  * around in memory.
  */
 #include <linux/numa.h>
+
 #define arch_pfn_to_nid(pfn)   PFN_TO_NID(pfn)
 #define arch_local_page_offset(pfn, nid) LOCAL_MAP_NR((pfn) << PAGE_SHIFT)
 
@@ -256,6 +258,43 @@ static inline __deprecated void *bus_to_virt(unsigned long x)
  */
 #define PHYS_TO_NID(addr)      PFN_TO_NID((addr) >> PAGE_SHIFT)
 
+/*
+ * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
+ * and returns the mem_map of that node.
+ */
+#define ADDR_TO_MAPBASE(kaddr) NODE_MEM_MAP(KVADDR_TO_NID(kaddr))
+
+/*
+ * Given a page frame number, find the owning node of the memory
+ * and returns the mem_map of that node.
+ */
+#define PFN_TO_MAPBASE(pfn)    NODE_MEM_MAP(PFN_TO_NID(pfn))
+
+#ifdef NODE_MEM_SIZE_BITS
+#define NODE_MEM_SIZE_MASK     ((1 << NODE_MEM_SIZE_BITS) - 1)
+
+/*
+ * Given a kernel address, find the home node of the underlying memory.
+ */
+#define KVADDR_TO_NID(addr) \
+       (((unsigned long)(addr) - PAGE_OFFSET) >> NODE_MEM_SIZE_BITS)
+
+/*
+ * Given a page frame number, convert it to a node id.
+ */
+#define PFN_TO_NID(pfn) \
+       (((pfn) - PHYS_PFN_OFFSET) >> (NODE_MEM_SIZE_BITS - PAGE_SHIFT))
+
+/*
+ * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
+ * and returns the index corresponding to the appropriate page in the
+ * node's mem_map.
+ */
+#define LOCAL_MAP_NR(addr) \
+       (((unsigned long)(addr) & NODE_MEM_SIZE_MASK) >> PAGE_SHIFT)
+
+#endif /* NODE_MEM_SIZE_BITS */
+
 #endif /* !CONFIG_DISCONTIGMEM */
 
 /*
index c1b264dff2870f786887b686c44295282b75d4fa..7b1c9acdf79a876da4c81c1f26bd8c41b9784495 100644 (file)
@@ -44,7 +44,6 @@
 #define PAGE_READONLY  __pgprot(0)
 #define PAGE_KERNEL    __pgprot(0)
 
-//extern void paging_init(struct meminfo *, struct machine_desc *);
 #define swapper_pg_dir ((pgd_t *) 0)
 
 #define __swp_type(x)          (0)
index ed8cb5963e99cde381f94171b1f59a98aa1805d8..88cd5c784ef045801892456e7b0be54453915090 100644 (file)
@@ -169,8 +169,7 @@ extern void __pgd_error(const char *file, int line, unsigned long val);
 #define L_PTE_WRITE            (1 << 5)
 #define L_PTE_EXEC             (1 << 6)
 #define L_PTE_DIRTY            (1 << 7)
-#define L_PTE_COHERENT         (1 << 9)        /* I/O coherent (xsc3) */
-#define L_PTE_SHARED           (1 << 10)       /* shared between CPUs (v6) */
+#define L_PTE_SHARED           (1 << 10)       /* shared(v6), coherent(xsc3) */
 #define L_PTE_ASID             (1 << 11)       /* non-global (use ASID, v6) */
 
 #ifndef __ASSEMBLY__
index 04f4d34c63170736e9f6301f63a3b666c06f6303..b442e8e2a8094cc7952ef03ed398b773d45c820b 100644 (file)
@@ -20,7 +20,6 @@
 #ifdef __KERNEL__
 
 #include <asm/ptrace.h>
-#include <asm/procinfo.h>
 #include <asm/types.h>
 
 union debug_insn {
index 91a31adfa8a8ca50298088cb4031b3c21f200302..4d3c685075e08d9c1db94897cf4ab9ba1933681f 100644 (file)
@@ -10,7 +10,7 @@
 #ifndef __ASM_PROCINFO_H
 #define __ASM_PROCINFO_H
 
-#ifndef __ASSEMBLY__
+#ifdef __KERNEL__
 
 struct cpu_tlb_fns;
 struct cpu_user_fns;
@@ -42,19 +42,8 @@ struct proc_info_list {
        struct cpu_cache_fns    *cache;
 };
 
-extern unsigned int elf_hwcap;
-
-#endif /* __ASSEMBLY__ */
-
-#define HWCAP_SWP      1
-#define HWCAP_HALF     2
-#define HWCAP_THUMB    4
-#define HWCAP_26BIT    8       /* Play it safe */
-#define HWCAP_FAST_MULT        16
-#define HWCAP_FPA      32
-#define HWCAP_VFP      64
-#define HWCAP_EDSP     128
-#define HWCAP_JAVA     256
-#define HWCAP_IWMMXT   512
-
+#else  /* __KERNEL__ */
+#include <asm/elf.h>
+#warning "Please include asm/elf.h instead"
+#endif /* __KERNEL__ */
 #endif
index aa4b5782f0c9723cf1d604ca7756a09bea8e6829..e5407392afcad0413c0df46030f51e2c93c4fd5b 100644 (file)
 #ifndef __ASMARM_SETUP_H
 #define __ASMARM_SETUP_H
 
+#include <asm/types.h>
+
 #define COMMAND_LINE_SIZE 1024
 
 /* The list ends with an ATAG_NONE node. */
 #define ATAG_NONE      0x00000000
 
 struct tag_header {
-       u32 size;
-       u32 tag;
+       __u32 size;
+       __u32 tag;
 };
 
 /* The list must start with an ATAG_CORE node */
 #define ATAG_CORE      0x54410001
 
 struct tag_core {
-       u32 flags;              /* bit 0 = read-only */
-       u32 pagesize;
-       u32 rootdev;
+       __u32 flags;            /* bit 0 = read-only */
+       __u32 pagesize;
+       __u32 rootdev;
 };
 
 /* it is allowed to have multiple ATAG_MEM nodes */
 #define ATAG_MEM       0x54410002
 
 struct tag_mem32 {
-       u32     size;
-       u32     start;  /* physical start address */
+       __u32   size;
+       __u32   start;  /* physical start address */
 };
 
 /* VGA text type displays */
 #define ATAG_VIDEOTEXT 0x54410003
 
 struct tag_videotext {
-       u8              x;
-       u8              y;
-       u16             video_page;
-       u8              video_mode;
-       u8              video_cols;
-       u16             video_ega_bx;
-       u8              video_lines;
-       u8              video_isvga;
-       u16             video_points;
+       __u8            x;
+       __u8            y;
+       __u16           video_page;
+       __u8            video_mode;
+       __u8            video_cols;
+       __u16           video_ega_bx;
+       __u8            video_lines;
+       __u8            video_isvga;
+       __u16           video_points;
 };
 
 /* describes how the ramdisk will be used in kernel */
 #define ATAG_RAMDISK   0x54410004
 
 struct tag_ramdisk {
-       u32 flags;      /* bit 0 = load, bit 1 = prompt */
-       u32 size;       /* decompressed ramdisk size in _kilo_ bytes */
-       u32 start;      /* starting block of floppy-based RAM disk image */
+       __u32 flags;    /* bit 0 = load, bit 1 = prompt */
+       __u32 size;     /* decompressed ramdisk size in _kilo_ bytes */
+       __u32 start;    /* starting block of floppy-based RAM disk image */
 };
 
 /* describes where the compressed ramdisk image lives (virtual address) */
@@ -76,23 +78,23 @@ struct tag_ramdisk {
 #define ATAG_INITRD2   0x54420005
 
 struct tag_initrd {
-       u32 start;      /* physical start address */
-       u32 size;       /* size of compressed ramdisk image in bytes */
+       __u32 start;    /* physical start address */
+       __u32 size;     /* size of compressed ramdisk image in bytes */
 };
 
 /* board serial number. "64 bits should be enough for everybody" */
 #define ATAG_SERIAL    0x54410006
 
 struct tag_serialnr {
-       u32 low;
-       u32 high;
+       __u32 low;
+       __u32 high;
 };
 
 /* board revision */
 #define ATAG_REVISION  0x54410007
 
 struct tag_revision {
-       u32 rev;
+       __u32 rev;
 };
 
 /* initial values for vesafb-type framebuffers. see struct screen_info
@@ -101,20 +103,20 @@ struct tag_revision {
 #define ATAG_VIDEOLFB  0x54410008
 
 struct tag_videolfb {
-       u16             lfb_width;
-       u16             lfb_height;
-       u16             lfb_depth;
-       u16             lfb_linelength;
-       u32             lfb_base;
-       u32             lfb_size;
-       u8              red_size;
-       u8              red_pos;
-       u8              green_size;
-       u8              green_pos;
-       u8              blue_size;
-       u8              blue_pos;
-       u8              rsvd_size;
-       u8              rsvd_pos;
+       __u16           lfb_width;
+       __u16           lfb_height;
+       __u16           lfb_depth;
+       __u16           lfb_linelength;
+       __u32           lfb_base;
+       __u32           lfb_size;
+       __u8            red_size;
+       __u8            red_pos;
+       __u8            green_size;
+       __u8            green_pos;
+       __u8            blue_size;
+       __u8            blue_pos;
+       __u8            rsvd_size;
+       __u8            rsvd_pos;
 };
 
 /* command line: \0 terminated string */
@@ -128,17 +130,17 @@ struct tag_cmdline {
 #define ATAG_ACORN     0x41000101
 
 struct tag_acorn {
-       u32 memc_control_reg;
-       u32 vram_pages;
-       u8 sounddefault;
-       u8 adfsdrives;
+       __u32 memc_control_reg;
+       __u32 vram_pages;
+       __u8 sounddefault;
+       __u8 adfsdrives;
 };
 
 /* footbridge memory clock, see arch/arm/mach-footbridge/arch.c */
 #define ATAG_MEMCLK    0x41000402
 
 struct tag_memclk {
-       u32 fmemclk;
+       __u32 fmemclk;
 };
 
 struct tag {
@@ -167,24 +169,26 @@ struct tag {
 };
 
 struct tagtable {
-       u32 tag;
+       __u32 tag;
        int (*parse)(const struct tag *);
 };
 
-#define __tag __attribute_used__ __attribute__((__section__(".taglist.init")))
-#define __tagtable(tag, fn) \
-static struct tagtable __tagtable_##fn __tag = { tag, fn }
-
 #define tag_member_present(tag,member)                         \
        ((unsigned long)(&((struct tag *)0L)->member + 1)       \
                <= (tag)->hdr.size * 4)
 
-#define tag_next(t)    ((struct tag *)((u32 *)(t) + (t)->hdr.size))
+#define tag_next(t)    ((struct tag *)((__u32 *)(t) + (t)->hdr.size))
 #define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2)
 
 #define for_each_tag(t,base)           \
        for (t = base; t->hdr.size; t = tag_next(t))
 
+#ifdef __KERNEL__
+
+#define __tag __attribute_used__ __attribute__((__section__(".taglist.init")))
+#define __tagtable(tag, fn) \
+static struct tagtable __tagtable_##fn __tag = { tag, fn }
+
 /*
  * Memory map description
  */
@@ -217,4 +221,6 @@ struct early_params {
 static struct early_params __early_##fn __attribute_used__     \
 __attribute__((__section__(".early_param.init"))) = { name, fn }
 
+#endif  /*  __KERNEL__  */
+
 #endif
index bbc6e1d24d3fc742aa2b8ab12d9492dc1fa22fa8..a3f4fe1742d0ac84abb7a3dc9c2996579ab3e123 100644 (file)
@@ -15,6 +15,18 @@ struct termios {
        cc_t c_cc[NCCS];                /* control characters */
 };
 
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
+
 /* c_cc characters */
 #define VINTR 0
 #define VQUIT 1
index f28b236139ed4000ed907015601629bf99b26808..d9b8bddc8732ac3b75aa7d64653179c192ffb0ed 100644 (file)
@@ -94,8 +94,18 @@ static inline struct thread_info *current_thread_info(void)
        return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
 }
 
-extern struct thread_info *alloc_thread_info(struct task_struct *task);
-extern void free_thread_info(struct thread_info *);
+/* thread information allocation */
+#ifdef CONFIG_DEBUG_STACK_USAGE
+#define alloc_thread_info(tsk) \
+       ((struct thread_info *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, \
+               THREAD_SIZE_ORDER))
+#else
+#define alloc_thread_info(tsk) \
+       ((struct thread_info *)__get_free_pages(GFP_KERNEL, THREAD_SIZE_ORDER))
+#endif
+
+#define free_thread_info(info) \
+       free_pages((unsigned long)info, THREAD_SIZE_ORDER);
 
 #define thread_saved_pc(tsk)   \
        ((unsigned long)(pc_pointer(task_thread_info(tsk)->cpu_context.pc)))
index 14a87eec5a2dd28662173173316bf1a9ffa29ac6..d44c629d84249607d5689c6a2bc2dbf611f8e8fc 100644 (file)
 #endif
 
 #ifdef __KERNEL__
-#include <linux/err.h>
-#include <linux/linkage.h>
-
-#define __sys2(x) #x
-#define __sys1(x) __sys2(x)
-
-#ifndef __syscall
-#if defined(__thumb__) || defined(__ARM_EABI__)
-#define __SYS_REG(name) register long __sysreg __asm__("r7") = __NR_##name;
-#define __SYS_REG_LIST(regs...) "r" (__sysreg) , ##regs
-#define __syscall(name) "swi\t0"
-#else
-#define __SYS_REG(name)
-#define __SYS_REG_LIST(regs...) regs
-#define __syscall(name) "swi\t" __sys1(__NR_##name) ""
-#endif
-#endif
-
-#define __syscall_return(type, res)                                    \
-do {                                                                   \
-       if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) {      \
-               errno = -(res);                                         \
-               res = -1;                                               \
-       }                                                               \
-       return (type) (res);                                            \
-} while (0)
-
-#define _syscall0(type,name)                                           \
-type name(void) {                                                      \
-  __SYS_REG(name)                                                      \
-  register long __res_r0 __asm__("r0");                                        \
-  long __res;                                                          \
-  __asm__ __volatile__ (                                               \
-  __syscall(name)                                                      \
-       : "=r" (__res_r0)                                               \
-       : __SYS_REG_LIST()                                              \
-       : "memory" );                                                   \
-  __res = __res_r0;                                                    \
-  __syscall_return(type,__res);                                                \
-}
-
-#define _syscall1(type,name,type1,arg1)                                \
-type name(type1 arg1) {                                                \
-  __SYS_REG(name)                                                      \
-  register long __r0 __asm__("r0") = (long)arg1;                       \
-  register long __res_r0 __asm__("r0");                                        \
-  long __res;                                                          \
-  __asm__ __volatile__ (                                               \
-  __syscall(name)                                                      \
-       : "=r" (__res_r0)                                               \
-       : __SYS_REG_LIST( "0" (__r0) )                                  \
-       : "memory" );                                                   \
-  __res = __res_r0;                                                    \
-  __syscall_return(type,__res);                                                \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2)                     \
-type name(type1 arg1,type2 arg2) {                                     \
-  __SYS_REG(name)                                                      \
-  register long __r0 __asm__("r0") = (long)arg1;                       \
-  register long __r1 __asm__("r1") = (long)arg2;                       \
-  register long __res_r0 __asm__("r0");                                        \
-  long __res;                                                          \
-  __asm__ __volatile__ (                                               \
-  __syscall(name)                                                      \
-       : "=r" (__res_r0)                                               \
-       : __SYS_REG_LIST( "0" (__r0), "r" (__r1) )                      \
-       : "memory" );                                                   \
-  __res = __res_r0;                                                    \
-  __syscall_return(type,__res);                                                \
-}
-
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3)          \
-type name(type1 arg1,type2 arg2,type3 arg3) {                          \
-  __SYS_REG(name)                                                      \
-  register long __r0 __asm__("r0") = (long)arg1;                       \
-  register long __r1 __asm__("r1") = (long)arg2;                       \
-  register long __r2 __asm__("r2") = (long)arg3;                       \
-  register long __res_r0 __asm__("r0");                                        \
-  long __res;                                                          \
-  __asm__ __volatile__ (                                               \
-  __syscall(name)                                                      \
-       : "=r" (__res_r0)                                               \
-       : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2) )          \
-       : "memory" );                                                   \
-  __res = __res_r0;                                                    \
-  __syscall_return(type,__res);                                                \
-}
-
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4)\
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) {            \
-  __SYS_REG(name)                                                      \
-  register long __r0 __asm__("r0") = (long)arg1;                       \
-  register long __r1 __asm__("r1") = (long)arg2;                       \
-  register long __r2 __asm__("r2") = (long)arg3;                       \
-  register long __r3 __asm__("r3") = (long)arg4;                       \
-  register long __res_r0 __asm__("r0");                                        \
-  long __res;                                                          \
-  __asm__ __volatile__ (                                               \
-  __syscall(name)                                                      \
-       : "=r" (__res_r0)                                               \
-       : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2), "r" (__r3) ) \
-       : "memory" );                                                   \
-  __res = __res_r0;                                                    \
-  __syscall_return(type,__res);                                                \
-}
-  
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5)    \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) {        \
-  __SYS_REG(name)                                                      \
-  register long __r0 __asm__("r0") = (long)arg1;                       \
-  register long __r1 __asm__("r1") = (long)arg2;                       \
-  register long __r2 __asm__("r2") = (long)arg3;                       \
-  register long __r3 __asm__("r3") = (long)arg4;                       \
-  register long __r4 __asm__("r4") = (long)arg5;                       \
-  register long __res_r0 __asm__("r0");                                        \
-  long __res;                                                          \
-  __asm__ __volatile__ (                                               \
-  __syscall(name)                                                      \
-       : "=r" (__res_r0)                                               \
-       : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2),           \
-                         "r" (__r3), "r" (__r4) )                      \
-       : "memory" );                                                   \
-  __res = __res_r0;                                                    \
-  __syscall_return(type,__res);                                                \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) {    \
-  __SYS_REG(name)                                                      \
-  register long __r0 __asm__("r0") = (long)arg1;                       \
-  register long __r1 __asm__("r1") = (long)arg2;                       \
-  register long __r2 __asm__("r2") = (long)arg3;                       \
-  register long __r3 __asm__("r3") = (long)arg4;                       \
-  register long __r4 __asm__("r4") = (long)arg5;                       \
-  register long __r5 __asm__("r5") = (long)arg6;                       \
-  register long __res_r0 __asm__("r0");                                        \
-  long __res;                                                          \
-  __asm__ __volatile__ (                                               \
-  __syscall(name)                                                      \
-       : "=r" (__res_r0)                                               \
-       : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2),           \
-                         "r" (__r3), "r" (__r4), "r" (__r5) )          \
-       : "memory" );                                                   \
-  __res = __res_r0;                                                    \
-  __syscall_return(type,__res);                                                \
-}
 
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_STAT64
index 6437167b1ffe7f2988b3d00d54084f66067640d1..7725af3ddb4df972b69d71b9487f587b8e2fc1c0 100644 (file)
@@ -15,7 +15,7 @@
 #include <asm/tlbflush.h>
 #include <linux/slab.h>
 
-extern kmem_cache_t *pte_cache;
+extern struct kmem_cache *pte_cache;
 
 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr){
        return kmem_cache_alloc(pte_cache, GFP_KERNEL);
index 6348931be65d9333d19a427a2f6981684e2dde54..1a867b4e8d531e4f86b81feb4680e6ab15de7636 100644 (file)
@@ -16,6 +16,8 @@
 
 #define COMMAND_LINE_SIZE 1024
 
+#ifdef __KERNEL__
+
 /* The list ends with an ATAG_NONE node. */
 #define ATAG_NONE      0x00000000
 
@@ -202,4 +204,6 @@ struct meminfo {
 
 extern struct meminfo meminfo;
 
+#endif  /*  __KERNEL__  */
+
 #endif
index bbc6e1d24d3fc742aa2b8ab12d9492dc1fa22fa8..a3f4fe1742d0ac84abb7a3dc9c2996579ab3e123 100644 (file)
@@ -15,6 +15,18 @@ struct termios {
        cc_t c_cc[NCCS];                /* control characters */
 };
 
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
+
 /* c_cc characters */
 #define VINTR 0
 #define VQUIT 1
index 25a5eead85beaa4a26530f9d331519edc6270ffe..4c3b919177e5491feac582824afa877148718fce 100644 (file)
 #define __ARM_NR_usr26                 (__ARM_NR_BASE+3)
 
 #ifdef __KERNEL__
-#include <linux/err.h>
-#include <linux/linkage.h>
-
-#define __sys2(x) #x
-#define __sys1(x) __sys2(x)
-
-#ifndef __syscall
-#define __syscall(name) "swi\t" __sys1(__NR_##name) ""
-#endif
-
-#define __syscall_return(type, res)                                    \
-do {                                                                   \
-       if ((unsigned long)(res) >= (unsigned long)-MAX_ERRNO) {        \
-               errno = -(res);                                         \
-               res = -1;                                               \
-       }                                                               \
-       return (type) (res);                                            \
-} while (0)
-
-#define _syscall0(type,name)                                           \
-type name(void) {                                                      \
-  register long __res_r0 __asm__("r0");                                        \
-  long __res;                                                          \
-  __asm__ __volatile__ (                                               \
-  __syscall(name)                                                      \
-       : "=r" (__res_r0)                                               \
-       :                                                               \
-       : "lr");                                                        \
-  __res = __res_r0;                                                    \
-  __syscall_return(type,__res);                                                \
-}
-
-#define _syscall1(type,name,type1,arg1)                                \
-type name(type1 arg1) {                                                \
-  register long __r0 __asm__("r0") = (long)arg1;                       \
-  register long __res_r0 __asm__("r0");                                        \
-  long __res;                                                          \
-  __asm__ __volatile__ (                                               \
-  __syscall(name)                                                      \
-       : "=r" (__res_r0)                                               \
-       : "r" (__r0)                                                    \
-       : "lr");                                                        \
-  __res = __res_r0;                                                    \
-  __syscall_return(type,__res);                                                \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2)                     \
-type name(type1 arg1,type2 arg2) {                                     \
-  register long __r0 __asm__("r0") = (long)arg1;                       \
-  register long __r1 __asm__("r1") = (long)arg2;                       \
-  register long __res_r0 __asm__("r0");                                        \
-  long __res;                                                          \
-  __asm__ __volatile__ (                                               \
-  __syscall(name)                                                      \
-       : "=r" (__res_r0)                                               \
-       : "r" (__r0),"r" (__r1)                                         \
-       : "lr");                                                        \
-  __res = __res_r0;                                                    \
-  __syscall_return(type,__res);                                                \
-}
-
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3)          \
-type name(type1 arg1,type2 arg2,type3 arg3) {                          \
-  register long __r0 __asm__("r0") = (long)arg1;                       \
-  register long __r1 __asm__("r1") = (long)arg2;                       \
-  register long __r2 __asm__("r2") = (long)arg3;                       \
-  register long __res_r0 __asm__("r0");                                        \
-  long __res;                                                          \
-  __asm__ __volatile__ (                                               \
-  __syscall(name)                                                      \
-       : "=r" (__res_r0)                                               \
-       : "r" (__r0),"r" (__r1),"r" (__r2)                              \
-       : "lr");                                                        \
-  __res = __res_r0;                                                    \
-  __syscall_return(type,__res);                                                \
-}
-
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4)\
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) {            \
-  register long __r0 __asm__("r0") = (long)arg1;                       \
-  register long __r1 __asm__("r1") = (long)arg2;                       \
-  register long __r2 __asm__("r2") = (long)arg3;                       \
-  register long __r3 __asm__("r3") = (long)arg4;                       \
-  register long __res_r0 __asm__("r0");                                        \
-  long __res;                                                          \
-  __asm__ __volatile__ (                                               \
-  __syscall(name)                                                      \
-       : "=r" (__res_r0)                                               \
-       : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3)                   \
-       : "lr");                                                        \
-  __res = __res_r0;                                                    \
-  __syscall_return(type,__res);                                                \
-}
-  
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5)    \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) {        \
-  register long __r0 __asm__("r0") = (long)arg1;                       \
-  register long __r1 __asm__("r1") = (long)arg2;                       \
-  register long __r2 __asm__("r2") = (long)arg3;                       \
-  register long __r3 __asm__("r3") = (long)arg4;                       \
-  register long __r4 __asm__("r4") = (long)arg5;                       \
-  register long __res_r0 __asm__("r0");                                        \
-  long __res;                                                          \
-  __asm__ __volatile__ (                                               \
-  __syscall(name)                                                      \
-       : "=r" (__res_r0)                                               \
-       : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3),"r" (__r4)        \
-       : "lr");                                                        \
-  __res = __res_r0;                                                    \
-  __syscall_return(type,__res);                                                \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) {    \
-  register long __r0 __asm__("r0") = (long)arg1;                       \
-  register long __r1 __asm__("r1") = (long)arg2;                       \
-  register long __r2 __asm__("r2") = (long)arg3;                       \
-  register long __r3 __asm__("r3") = (long)arg4;                       \
-  register long __r4 __asm__("r4") = (long)arg5;                       \
-  register long __r5 __asm__("r5") = (long)arg6;                       \
-  register long __res_r0 __asm__("r0");                                        \
-  long __res;                                                          \
-  __asm__ __volatile__ (                                               \
-  __syscall(name)                                                      \
-       : "=r" (__res_r0)                                               \
-       : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3), "r" (__r4),"r" (__r5)            \
-       : "lr");                                                        \
-  __res = __res_r0;                                                    \
-  __syscall_return(type,__res);                                                \
-}
 
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
similarity index 92%
rename from include/asm-arm/arch-at91rm9200/at91rm9200_pdc.h
rename to include/asm-avr32/arch-at32ap/at91_pdc.h
index ce1150d4438d46de7fa3f9d3f7c0c08b80daeccb..79d6e02fa45e161958b64d7c51af5d3dd97d7819 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * include/asm-arm/arch-at91rm9200/at91rm9200_pdc.h
+ * include/asm-arm/arch-at91rm9200/at91_pdc.h
  *
  * Copyright (C) 2005 Ivan Kokshaysky
  * Copyright (C) SAN People
@@ -13,8 +13,8 @@
  * (at your option) any later version.
  */
 
-#ifndef AT91RM9200_PDC_H
-#define AT91RM9200_PDC_H
+#ifndef AT91_PDC_H
+#define AT91_PDC_H
 
 #define AT91_PDC_RPR           0x100   /* Receive Pointer Register */
 #define AT91_PDC_RCR           0x104   /* Receive Counter Register */
index 4c40cb41cdf8399a188e2da74bb379f25f113dbd..0580b5d62bba1385073f2b7a7d0218fc78a58f92 100644 (file)
@@ -8,7 +8,8 @@
 #include <asm/cacheflush.h>
 #include <asm/io.h>
 
-extern void dma_cache_sync(void *vaddr, size_t size, int direction);
+extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
+       int direction);
 
 /*
  * Return whether the given device DMA address mask can be supported
@@ -307,7 +308,7 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
 
-static inline int dma_is_consistent(dma_addr_t dma_addr)
+static inline int dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
 {
        return 1;
 }
index 10193da4113b8d92a0c02b5114339371517e82e4..0a5224245e44088bb69fb797d348f2de81e5f639 100644 (file)
@@ -13,6 +13,8 @@
 
 #define COMMAND_LINE_SIZE 256
 
+#ifdef __KERNEL__
+
 /* Magic number indicating that a tag table is present */
 #define ATAG_MAGIC     0xa2a25441
 
@@ -138,4 +140,6 @@ void chip_enable_sdram(void);
 
 #endif /* !__ASSEMBLY__ */
 
+#endif  /*  __KERNEL__  */
+
 #endif /* __ASM_AVR32_SETUP_H__ */
index 9dc6eacafa3388ff30d2d05704825c2d918e6e85..c215fafdae4d66e9960c0daa7a75a09c1dbd220b 100644 (file)
@@ -17,6 +17,17 @@ struct termios {
        cc_t c_cc[NCCS];                /* control characters */
 };
 
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
 /* c_cc characters */
 #define VINTR 0
 #define VQUIT 1
index b73f5396e5a6b6f634726d90515594341f8d219a..be85f6de25d36dcfac1242ad926d16764fe02d78 100644 (file)
@@ -10,7 +10,7 @@
  * number.  They differ in that the first function also inverts all bits
  * in the input.
  */
-extern inline unsigned long cris_swapnwbrlz(unsigned long w)
+static inline unsigned long cris_swapnwbrlz(unsigned long w)
 {
        /* Let's just say we return the result in the same register as the
           input.  Saying we clobber the input but can return the result
@@ -26,7 +26,7 @@ extern inline unsigned long cris_swapnwbrlz(unsigned long w)
        return res;
 }
 
-extern inline unsigned long cris_swapwbrlz(unsigned long w)
+static inline unsigned long cris_swapwbrlz(unsigned long w)
 {
        unsigned res;
        __asm__ ("swapwbr %0 \n\t"
@@ -40,7 +40,7 @@ extern inline unsigned long cris_swapwbrlz(unsigned long w)
  * ffz = Find First Zero in word. Undefined if no zero exists,
  * so code should check against ~0UL first..
  */
-extern inline unsigned long ffz(unsigned long w)
+static inline unsigned long ffz(unsigned long w)
 {
        return cris_swapnwbrlz(w);
 }
@@ -51,7 +51,7 @@ extern inline unsigned long ffz(unsigned long w)
  *
  * Undefined if no bit exists, so code should check against 0 first.
  */
-extern inline unsigned long __ffs(unsigned long word)
+static inline unsigned long __ffs(unsigned long word)
 {
        return cris_swapnwbrlz(~word);
 }
@@ -65,7 +65,7 @@ extern inline unsigned long __ffs(unsigned long word)
  * differs in spirit from the above ffz (man ffs).
  */
 
-extern inline unsigned long kernel_ffs(unsigned long w)
+static inline unsigned long kernel_ffs(unsigned long w)
 {
        return w ? cris_swapwbrlz (w) + 1 : 0;
 }
index cbf1a98f012975d67ca8b3b5efd04b896ccc38b8..662cea70152dc2ce2247f067625bd5ce00108bbe 100644 (file)
@@ -156,10 +156,10 @@ dma_get_cache_alignment(void)
        return (1 << INTERNODE_CACHE_SHIFT);
 }
 
-#define dma_is_consistent(d)   (1)
+#define dma_is_consistent(d, h)        (1)
 
 static inline void
-dma_cache_sync(void *vaddr, size_t size,
+dma_cache_sync(struct device *dev, void *vaddr, size_t size,
               enum dma_data_direction direction)
 {
 }
index dbd0f30b85b6aa7653da1e85edd9165d41c9d3a4..a8e1e6cb7cd02f816823b22261808e53bbb290bd 100644 (file)
 /*
  * These two _must_ execute atomically wrt each other.
  */
-extern inline void wake_one_more(struct semaphore * sem)
+static inline void wake_one_more(struct semaphore * sem)
 {
        atomic_inc(&sem->waking);
 }
 
-extern inline int waking_non_zero(struct semaphore *sem)
+static inline int waking_non_zero(struct semaphore *sem)
 {
        unsigned long flags;
        int ret = 0;
@@ -40,7 +40,7 @@ extern inline int waking_non_zero(struct semaphore *sem)
        return ret;
 }
 
-extern inline int waking_non_zero_interruptible(struct semaphore *sem,
+static inline int waking_non_zero_interruptible(struct semaphore *sem,
                                                struct task_struct *tsk)
 {
        int ret = 0;
@@ -59,7 +59,7 @@ extern inline int waking_non_zero_interruptible(struct semaphore *sem,
        return ret;
 }
 
-extern inline int waking_non_zero_trylock(struct semaphore *sem)
+static inline int waking_non_zero_trylock(struct semaphore *sem)
 {
         int ret = 1;
        unsigned long flags;
index be0836d2f2825fcf98df6710e6bd768b602cc1f0..8d8cec225fe1c37aed157383dc5f1c9c4152db79 100644 (file)
@@ -19,6 +19,17 @@ struct termios {
        cc_t c_cc[NCCS];                /* control characters */
 };
 
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
 /* c_cc characters */
 #define VINTR 0
 #define VQUIT 1
index 1f70d47148bdb702e55126a0e854731d565ee9cd..f8560edf59ff8f30859b78c7142f461803bee1ee 100644 (file)
@@ -256,6 +256,50 @@ int __ffs(unsigned long x)
        return 31 - bit;
 }
 
+/*
+ * special slimline version of fls() for calculating ilog2_u32()
+ * - note: no protection against n == 0
+ */
+#define ARCH_HAS_ILOG2_U32
+static inline __attribute__((const))
+int __ilog2_u32(u32 n)
+{
+       int bit;
+       asm("scan %1,gr0,%0" : "=r"(bit) : "r"(n));
+       return 31 - bit;
+}
+
+/*
+ * special slimline version of fls64() for calculating ilog2_u64()
+ * - note: no protection against n == 0
+ */
+#define ARCH_HAS_ILOG2_U64
+static inline __attribute__((const))
+int __ilog2_u64(u64 n)
+{
+       union {
+               u64 ll;
+               struct { u32 h, l; };
+       } _;
+       int bit, x, y;
+
+       _.ll = n;
+
+       asm("   subcc           %3,gr0,gr0,icc0         \n"
+           "   ckeq            icc0,cc4                \n"
+           "   cscan.p         %3,gr0,%0       ,cc4,0  \n"
+           "   setlos          #63,%1                  \n"
+           "   cscan.p         %4,gr0,%0       ,cc4,1  \n"
+           "   setlos          #31,%2                  \n"
+           "   csub.p          %1,%0,%0        ,cc4,0  \n"
+           "   csub            %2,%0,%0        ,cc4,1  \n"
+           : "=&r"(bit), "=r"(x), "=r"(y)
+           : "0r"(_.h), "r"(_.l)
+           : "icc0", "cc4"
+           );
+       return bit;
+}
+
 #include <asm-generic/bitops/sched.h>
 #include <asm-generic/bitops/hweight.h>
 
index e9fc1d47797e295664a0fa5f025b80bdce7fb50b..bcb2df68496e684d582f71d6a119f5398ee31c2f 100644 (file)
@@ -172,10 +172,10 @@ int dma_get_cache_alignment(void)
        return 1 << L1_CACHE_SHIFT;
 }
 
-#define dma_is_consistent(d)   (1)
+#define dma_is_consistent(d, h)        (1)
 
 static inline
-void dma_cache_sync(void *vaddr, size_t size,
+void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
                    enum dma_data_direction direction)
 {
        flush_write_buffers();
index 0f390f41f81680a70c12fe26cdae314644466344..ff4d6cdeb1522811bd4131da61d68575ff55502b 100644 (file)
@@ -115,7 +115,7 @@ static inline void *kmap_atomic(struct page *page, enum km_type type)
 {
        unsigned long paddr;
 
-       inc_preempt_count();
+       pagefault_disable();
        paddr = page_to_phys(page);
 
        switch (type) {
@@ -170,8 +170,7 @@ static inline void kunmap_atomic(void *kvaddr, enum km_type type)
        default:
                BUG();
        }
-       dec_preempt_count();
-       preempt_check_resched();
+       pagefault_enable();
 }
 
 #endif /* !__ASSEMBLY__ */
index 168381ebb41a51d680c01ce2b6081dfc008ca523..365653b1726c18892a3a1ea5efb760b50f64ddaa 100644 (file)
@@ -18,6 +18,5 @@
 #endif
 
 #define MAXHOSTNAMELEN         64      /* max length of hostname */
-#define COMMAND_LINE_SIZE      512
 
 #endif /* _ASM_PARAM_H */
index 0d293b9a585706806f6a05f6978b9cef0f6dcd5e..afd787ceede6687b131cd073c0ae315a31108d07 100644 (file)
 #ifndef _ASM_SETUP_H
 #define _ASM_SETUP_H
 
+#define COMMAND_LINE_SIZE       512
+
+#ifdef __KERNEL__
+
 #include <linux/init.h>
 
 #ifndef __ASSEMBLY__
@@ -22,4 +26,6 @@ extern unsigned long __initdata num_mappedpages;
 
 #endif /* !__ASSEMBLY__ */
 
+#endif  /*  __KERNEL__  */
+
 #endif /* _ASM_SETUP_H */
index 74f20d6e292f2e5c4d849b2ce09fefb5669c5e39..2d6d389cff49886f1aa6ac1bd1ddafcf918d5ead 100644 (file)
@@ -17,6 +17,17 @@ struct termios {
        cc_t c_cc[NCCS];                /* control characters */
 };
 
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
 /* c_cc characters */
 #define VINTR 0
 #define VQUIT 1
index 725e854928cf3cf60f79863fd2db64011ad0747c..584c0417ae4de9ed74a0e167e6afd7cc30fc9738 100644 (file)
 #ifdef __KERNEL__
 
 #define NR_syscalls 310
-#include <linux/err.h>
-
-/*
- * process the return value of a syscall, consigning it to one of two possible fates
- * - user-visible error numbers are in the range -1 - -4095: see <asm-frv/errno.h>
- */
-#undef __syscall_return
-#define __syscall_return(type, res)                                    \
-do {                                                                   \
-        unsigned long __sr2 = (res);                                   \
-       if (__builtin_expect(__sr2 >= (unsigned long)(-MAX_ERRNO), 0)) { \
-               errno = (-__sr2);                                       \
-               __sr2 = ~0UL;                                           \
-       }                                                               \
-       return (type) __sr2;                                            \
-} while (0)
-
-/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
-
-#undef _syscall0
-#define _syscall0(type,name)                                           \
-type name(void)                                                                \
-{                                                                      \
-       register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
-       register unsigned long __sc0 __asm__ ("gr8");                   \
-       __asm__ __volatile__ ("tira gr0,#0"                             \
-                             : "=r" (__sc0)                            \
-                             : "r" (__scnum));                         \
-       __syscall_return(type, __sc0);                                  \
-}
-
-#undef _syscall1
-#define _syscall1(type,name,type1,arg1)                                                \
-type name(type1 arg1)                                                          \
-{                                                                              \
-       register unsigned long __scnum __asm__ ("gr7") = (__NR_##name);         \
-       register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1;    \
-       __asm__ __volatile__ ("tira gr0,#0"                                     \
-                             : "+r" (__sc0)                                    \
-                             : "r" (__scnum));                                 \
-       __syscall_return(type, __sc0);                                          \
-}
-
-#undef _syscall2
-#define _syscall2(type,name,type1,arg1,type2,arg2)                             \
-type name(type1 arg1,type2 arg2)                                               \
-{                                                                              \
-       register unsigned long __scnum __asm__ ("gr7") = (__NR_##name);         \
-       register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1;    \
-       register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2;    \
-       __asm__ __volatile__ ("tira gr0,#0"                                     \
-                             : "+r" (__sc0)                                    \
-                             : "r" (__scnum), "r" (__sc1));                    \
-       __syscall_return(type, __sc0);                                          \
-}
-
-#undef _syscall3
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3)                  \
-type name(type1 arg1,type2 arg2,type3 arg3)                                    \
-{                                                                              \
-       register unsigned long __scnum __asm__ ("gr7") = (__NR_##name);         \
-       register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1;    \
-       register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2;    \
-       register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3;   \
-       __asm__ __volatile__ ("tira gr0,#0"                                     \
-                             : "+r" (__sc0)                                    \
-                             : "r" (__scnum), "r" (__sc1), "r" (__sc2));       \
-       __syscall_return(type, __sc0);                                          \
-}
-
-#undef _syscall4
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4)               \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4)                             \
-{                                                                                      \
-       register unsigned long __scnum __asm__ ("gr7") = (__NR_##name);                 \
-       register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1;            \
-       register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2;            \
-       register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3;           \
-       register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4;           \
-       __asm__ __volatile__ ("tira gr0,#0"                                             \
-                             : "+r" (__sc0)                                            \
-                             : "r" (__scnum), "r" (__sc1), "r" (__sc2), "r" (__sc3));  \
-       __syscall_return(type, __sc0);                                                  \
-}
-
-#undef _syscall5
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5)    \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5)                 \
-{                                                                                      \
-       register unsigned long __scnum __asm__ ("gr7") = (__NR_##name);                 \
-       register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1;            \
-       register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2;            \
-       register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3;           \
-       register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4;           \
-       register unsigned long __sc4 __asm__ ("gr12") = (unsigned long) arg5;           \
-       __asm__ __volatile__ ("tira gr0,#0"                                             \
-                             : "+r" (__sc0)                                            \
-                             : "r" (__scnum), "r" (__sc1), "r" (__sc2),                \
-                             "r" (__sc3), "r" (__sc4));                                \
-       __syscall_return(type, __sc0);                                                  \
-}
-
-#undef _syscall6
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5, type6, arg6) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6)              \
-{                                                                                               \
-       register unsigned long __scnum __asm__ ("gr7") = (__NR_##name);                          \
-       register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1;                     \
-       register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2;                     \
-       register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3;                    \
-       register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4;                    \
-       register unsigned long __sc4 __asm__ ("gr12") = (unsigned long) arg5;                    \
-       register unsigned long __sc5 __asm__ ("gr13") = (unsigned long) arg6;                    \
-       __asm__ __volatile__ ("tira gr0,#0"                                                      \
-                             : "+r" (__sc0)                                                     \
-                             : "r" (__scnum), "r" (__sc1), "r" (__sc2),                         \
-                             "r" (__sc3), "r" (__sc4), "r" (__sc5));                            \
-       __syscall_return(type, __sc0);                                                           \
-}
 
 #define __ARCH_WANT_IPC_PARSE_VERSION
 /* #define __ARCH_WANT_OLD_READDIR */
index 3c06be38170116d61436039cfb494df7d0fc88a8..fa14f8cd30c501a6b7e0c8e8e391210a9c62a759 100644 (file)
@@ -1,4 +1,3 @@
-header-y += atomic.h
 header-y += errno-base.h
 header-y += errno.h
 header-y += fcntl.h
index a84c3d88a18912af529d794c3de75a66ad675049..a37e95fe58d64734f0323ace02bf062ad155f8cd 100644 (file)
@@ -14,6 +14,7 @@ unifdef-y += posix_types.h
 unifdef-y += ptrace.h
 unifdef-y += resource.h
 unifdef-y += sembuf.h
+unifdef-y += setup.h
 unifdef-y += shmbuf.h
 unifdef-y += sigcontext.h
 unifdef-y += siginfo.h
index 42a95d9a0641b4059a96b464d7d0a0e38cbd1b33..b7e4a0467cb1283ed82b9cd74bf2238178376a87 100644 (file)
@@ -66,7 +66,7 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
        atomic64_sub(i, v);
 }
 
-#else
+#else  /*  BITS_PER_LONG == 64  */
 
 typedef atomic_t atomic_long_t;
 
@@ -113,5 +113,6 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
        atomic_sub(i, v);
 }
 
-#endif
-#endif
+#endif  /*  BITS_PER_LONG == 64  */
+
+#endif  /*  _ASM_GENERIC_ATOMIC_H  */
index c92ae0f166ff44f1757f456a132202b22f0f5368..a06eecd48292a68d4611b43e263390b4320f7c15 100644 (file)
@@ -4,6 +4,22 @@
 #include <linux/compiler.h>
 
 #ifdef CONFIG_BUG
+
+#ifdef CONFIG_GENERIC_BUG
+#ifndef __ASSEMBLY__
+struct bug_entry {
+       unsigned long   bug_addr;
+#ifdef CONFIG_DEBUG_BUGVERBOSE
+       const char      *file;
+       unsigned short  line;
+#endif
+       unsigned short  flags;
+};
+#endif         /* __ASSEMBLY__ */
+
+#define BUGFLAG_WARNING        (1<<0)
+#endif /* CONFIG_GENERIC_BUG */
+
 #ifndef HAVE_ARCH_BUG
 #define BUG() do { \
        printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
@@ -19,7 +35,7 @@
 #define WARN_ON(condition) ({                                          \
        typeof(condition) __ret_warn_on = (condition);                  \
        if (unlikely(__ret_warn_on)) {                                  \
-               printk("BUG: warning at %s:%d/%s()\n", __FILE__,        \
+               printk("WARNING at %s:%d %s()\n", __FILE__,     \
                        __LINE__, __FUNCTION__);                        \
                dump_stack();                                           \
        }                                                               \
index b541e48cc545f6c467bc5ca691731a8535df98bd..783ab9944d701234cfd80eeaf34da6ab90af6f04 100644 (file)
@@ -266,7 +266,7 @@ dma_error(dma_addr_t dma_addr)
 
 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
-#define dma_is_consistent(d)   (1)
+#define dma_is_consistent(d, h)        (1)
 
 static inline int
 dma_get_cache_alignment(void)
@@ -295,7 +295,7 @@ dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
 }
 
 static inline void
-dma_cache_sync(void *vaddr, size_t size,
+dma_cache_sync(struct device *dev, void *vaddr, size_t size,
               enum dma_data_direction direction)
 {
        /* could define this in terms of the dma_cache ... operations,
index df893c160318a6ac84ae076bc7ac5b98c33722ac..f422df0956a27025deb4c6cdbbc5a47646f74c9e 100644 (file)
@@ -21,7 +21,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
        if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
                return -EFAULT;
 
-       inc_preempt_count();
+       pagefault_disable();
 
        switch (op) {
        case FUTEX_OP_SET:
@@ -33,7 +33,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
                ret = -ENOSYS;
        }
 
-       dec_preempt_count();
+       pagefault_enable();
 
        if (!ret) {
                switch (cmp) {
index a96b5d986b6e8b1f05fb896adacae85b4243149c..b55052ce233035ff31b8bbe5909870d3be862f00 100644 (file)
@@ -4,21 +4,51 @@
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
 
-#include <linux/compiler.h>
+#include <linux/log2.h>
 
-/* Pure 2^n version of get_order */
-static __inline__ __attribute_const__ int get_order(unsigned long size)
+/*
+ * non-const pure 2^n version of get_order
+ * - the arch may override these in asm/bitops.h if they can be implemented
+ *   more efficiently than using the arch log2 routines
+ * - we use the non-const log2() instead if the arch has defined one suitable
+ */
+#ifndef ARCH_HAS_GET_ORDER
+static inline __attribute__((const))
+int __get_order(unsigned long size, int page_shift)
 {
+#if BITS_PER_LONG == 32 && defined(ARCH_HAS_ILOG2_U32)
+       int order = __ilog2_u32(size) - page_shift;
+       return order >= 0 ? order : 0;
+#elif BITS_PER_LONG == 64 && defined(ARCH_HAS_ILOG2_U64)
+       int order = __ilog2_u64(size) - page_shift;
+       return order >= 0 ? order : 0;
+#else
        int order;
 
-       size = (size - 1) >> (PAGE_SHIFT - 1);
+       size = (size - 1) >> (page_shift - 1);
        order = -1;
        do {
                size >>= 1;
                order++;
        } while (size);
        return order;
+#endif
 }
+#endif
+
+/**
+ * get_order - calculate log2(pages) to hold a block of the specified size
+ * @n - size
+ *
+ * calculate allocation order based on the current page size
+ * - this can be used to initialise global variables from constant data
+ */
+#define get_order(n)                                                   \
+(                                                                      \
+       __builtin_constant_p(n) ?                                       \
+       ((n < (1UL << PAGE_SHIFT)) ? 0 : ilog2(n) - PAGE_SHIFT) :       \
+       __get_order(n, PAGE_SHIFT)                                      \
+ )
 
 #endif /* __ASSEMBLY__ */
 #endif /* __KERNEL__ */
index 1e58ca39592c97eebbe9fe9551a43fa42e7a5cfe..3769e6bd63b17e1da41416fe13defc1d7107a0d1 100644 (file)
@@ -11,7 +11,7 @@
 /*
  * Translate a "termio" structure into a "termios". Ugh.
  */
-static inline int user_termio_to_kernel_termios(struct termios *termios,
+static inline int user_termio_to_kernel_termios(struct ktermios *termios,
                                                struct termio __user *termio)
 {
        unsigned short tmp;
@@ -48,7 +48,7 @@ static inline int user_termio_to_kernel_termios(struct termios *termios,
  * Translate a "termios" structure into a "termio". Ugh.
  */
 static inline int kernel_termios_to_user_termio(struct termio __user *termio,
-                                               struct termios *termios)
+                                               struct ktermios *termios)
 {
        if (put_user(termios->c_iflag, &termio->c_iflag) < 0 ||
            put_user(termios->c_oflag, &termio->c_oflag) < 0 ||
index e60d6f21fa62f25bee576f58b36fea2ead229a7b..6e9fcebbf89f3ab9cb7a42c74933afe28c3eee72 100644 (file)
@@ -11,8 +11,8 @@
 
 #define RODATA                                                         \
        . = ALIGN(4096);                                                \
-       __start_rodata = .;                                             \
        .rodata           : AT(ADDR(.rodata) - LOAD_OFFSET) {           \
+               VMLINUX_SYMBOL(__start_rodata) = .;                     \
                *(.rodata) *(.rodata.*)                                 \
                *(__vermagic)           /* Kernel version magic */      \
        }                                                               \
                *(__ksymtab_strings)                                    \
        }                                                               \
                                                                        \
+       EH_FRAME                                                        \
+                                                                       \
        /* Built-in module parameters. */                               \
        __param : AT(ADDR(__param) - LOAD_OFFSET) {                     \
                VMLINUX_SYMBOL(__start___param) = .;                    \
                *(__param)                                              \
                VMLINUX_SYMBOL(__stop___param) = .;                     \
+               VMLINUX_SYMBOL(__end_rodata) = .;                       \
        }                                                               \
                                                                        \
-       /* Unwind data binary search table */                           \
-       EH_FRAME_HDR                                                    \
-                                                                       \
-       __end_rodata = .;                                               \
        . = ALIGN(4096);
 
 #define SECURITY_INIT                                                  \
                VMLINUX_SYMBOL(__kprobes_text_end) = .;
 
 #ifdef CONFIG_STACK_UNWIND
-               /* Unwind data binary search table */
-#define EH_FRAME_HDR                                                   \
+#define EH_FRAME                                                       \
+               /* Unwind data binary search table */                   \
+               . = ALIGN(8);                                           \
                .eh_frame_hdr : AT(ADDR(.eh_frame_hdr) - LOAD_OFFSET) { \
                        VMLINUX_SYMBOL(__start_unwind_hdr) = .;         \
                        *(.eh_frame_hdr)                                \
                        VMLINUX_SYMBOL(__end_unwind_hdr) = .;           \
+               }                                                       \
+               /* Unwind data */                                       \
+               . = ALIGN(8);                                           \
+               .eh_frame : AT(ADDR(.eh_frame) - LOAD_OFFSET) {         \
+                       VMLINUX_SYMBOL(__start_unwind) = .;             \
+                       *(.eh_frame)                                    \
+                       VMLINUX_SYMBOL(__end_unwind) = .;               \
                }
 #else
-#define EH_FRAME_HDR
+#define EH_FRAME
 #endif
 
                /* DWARF debug sections.
                .stab.indexstr 0 : { *(.stab.indexstr) }                \
                .comment 0 : { *(.comment) }
 
+#define BUG_TABLE                                                      \
+       . = ALIGN(8);                                                   \
+       __bug_table : AT(ADDR(__bug_table) - LOAD_OFFSET) {             \
+               __start___bug_table = .;                                \
+               *(__bug_table)                                          \
+               __stop___bug_table = .;                                 \
+       }
+
 #define NOTES                                                          \
                .notes : { *(.note.*) } :note
 
index cbccbbdd640fab6218f23011e26679a3acb29dee..743beba70f82a71606d6c786e8e7d8257295fcc8 100644 (file)
@@ -9,7 +9,7 @@
  * Delay routines, using a pre-computed "loops_per_second" value.
  */
 
-extern __inline__ void __delay(unsigned long loops)
+static inline void __delay(unsigned long loops)
 {
        __asm__ __volatile__ ("1:\n\t"
                              "dec.l #1,%0\n\t"
@@ -27,7 +27,7 @@ extern __inline__ void __delay(unsigned long loops)
 
 extern unsigned long loops_per_jiffy;
 
-extern __inline__ void udelay(unsigned long usecs)
+static inline void udelay(unsigned long usecs)
 {
        usecs *= 4295;          /* 2**32 / 1000000 */
        usecs /= (loops_per_jiffy*HZ);
index 855721a5dcc973d0661e6e182301d958cdaf6606..5c165f7bee0edb4123bc015d4092ac71f4cf4071 100644 (file)
@@ -9,7 +9,7 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
 {
 }
 
-extern inline int
+static inline int
 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 {
        // mm->context = virt_to_phys(mm->pgd);
@@ -23,7 +23,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, str
 {
 }
 
-extern inline void activate_mm(struct mm_struct *prev_mm,
+static inline void activate_mm(struct mm_struct *prev_mm,
                               struct mm_struct *next_mm)
 {
 }
index 5edad5b70fd56dcf45c79a7b852b73d005d8ed4a..0c771b05fdd5db25bdb6210aa28fb0457f25c950 100644 (file)
 #define pcibios_assign_all_busses()    0
 #define pcibios_scan_all_fns(a, b)     0
 
-extern inline void pcibios_set_master(struct pci_dev *dev)
+static inline void pcibios_set_master(struct pci_dev *dev)
 {
        /* No special bus mastering setup handling */
 }
 
-extern inline void pcibios_penalize_isa_irq(int irq, int active)
+static inline void pcibios_penalize_isa_irq(int irq, int active)
 {
        /* We don't do dynamic PCI IRQ allocation */
 }
index fa69ae00eda3b647ac513672fc738e0073b5977d..6a1f4d3807b48fd5510f9ec79eccaad2480567f7 100644 (file)
@@ -17,6 +17,17 @@ struct termios {
        cc_t c_cc[NCCS];                /* control characters */
 };
 
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
 /* c_cc characters */
 #define VINTR 0
 #define VQUIT 1
index bbdffbeeedef9cbed6d0e763745469dbf2fb76ca..9a2c5c9fd700346ef514f37c57edba3f68a0dd57 100644 (file)
@@ -47,12 +47,12 @@ static inline void flush_tlb_range(struct mm_struct *mm,
        BUG();
 }
 
-extern inline void flush_tlb_kernel_page(unsigned long addr)
+static inline void flush_tlb_kernel_page(unsigned long addr)
 {
        BUG();
 }
 
-extern inline void flush_tlb_pgtables(struct mm_struct *mm,
+static inline void flush_tlb_pgtables(struct mm_struct *mm,
                                      unsigned long start, unsigned long end)
 {
        BUG();
index 747788d629ae1dc192d87356bb15a986dca95e75..7ddd414f8d16b37dd9068ddbd85ad2467eb7a6e1 100644 (file)
 #ifdef __KERNEL__
 
 #define NR_syscalls 289
-#include <linux/err.h>
-
-/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
-   <asm-m68k/errno.h> */
-
-#define __syscall_return(type, res) \
-do { \
-       if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
-       /* avoid using res which is declared to be in register d0; \
-          errno might expand to a function call and clobber it.  */ \
-               int __err = -(res); \
-               errno = __err; \
-               res = -1; \
-       } \
-       return (type) (res); \
-} while (0)
-
-#define _syscall0(type, name)                          \
-type name(void)                                                \
-{                                                      \
-  register long __res __asm__("er0");                  \
-  __asm__ __volatile__ ("mov.l %1,er0\n\t"             \
-                        "trapa #0\n\t"                 \
-                       : "=r" (__res)                  \
-                       : "g" (__NR_##name)             \
-                       : "cc", "memory");              \
-  __syscall_return(type, __res);                       \
-}
-
-#define _syscall1(type, name, atype, a)                        \
-type name(atype a)                                     \
-{                                                      \
-  register long __res __asm__("er0");                  \
-  register long _a __asm__("er1");                     \
-  _a = (long)a;                                                \
-  __asm__ __volatile__ ("mov.l %1,er0\n\t"             \
-                        "trapa #0\n\t"                 \
-                       : "=r" (__res)                  \
-                       : "g" (__NR_##name),            \
-                         "g" (_a)                      \
-                       : "cc", "memory");              \
-  __syscall_return(type, __res);                       \
-}
-
-#define _syscall2(type, name, atype, a, btype, b)      \
-type name(atype a, btype b)                            \
-{                                                      \
-  register long __res __asm__("er0");                  \
-  register long _a __asm__("er1");                     \
-  register long _b __asm__("er2");                     \
-  _a = (long)a;                                                \
-  _b = (long)b;                                                \
-  __asm__ __volatile__ ("mov.l %1,er0\n\t"             \
-                        "trapa #0\n\t"                 \
-                       : "=r" (__res)                  \
-                       : "g" (__NR_##name),            \
-                         "g" (_a),                     \
-                         "g" (_b)                      \
-                       : "cc", "memory");              \
-  __syscall_return(type, __res);                       \
-}
-
-#define _syscall3(type, name, atype, a, btype, b, ctype, c)    \
-type name(atype a, btype b, ctype c)                   \
-{                                                      \
-  register long __res __asm__("er0");                  \
-  register long _a __asm__("er1");                     \
-  register long _b __asm__("er2");                     \
-  register long _c __asm__("er3");                     \
-  _a = (long)a;                                                \
-  _b = (long)b;                                                \
-  _c = (long)c;                                                \
-  __asm__ __volatile__ ("mov.l %1,er0\n\t"             \
-                        "trapa #0\n\t"                 \
-                       : "=r" (__res)                  \
-                       : "g" (__NR_##name),            \
-                         "g" (_a),                     \
-                         "g" (_b),                     \
-                         "g" (_c)                      \
-                       : "cc", "memory");              \
-  __syscall_return(type, __res);                       \
-}
-
-#define _syscall4(type, name, atype, a, btype, b,      \
-                  ctype, c, dtype, d)                  \
-type name(atype a, btype b, ctype c, dtype d)          \
-{                                                      \
-  register long __res __asm__("er0");                  \
-  register long _a __asm__("er1");                     \
-  register long _b __asm__("er2");                     \
-  register long _c __asm__("er3");                     \
-  register long _d __asm__("er4");                     \
-  _a = (long)a;                                                \
-  _b = (long)b;                                                \
-  _c = (long)c;                                                \
-  _d = (long)d;                                                \
-  __asm__ __volatile__ ("mov.l %1,er0\n\t"             \
-                        "trapa #0\n\t"                 \
-                       : "=r" (__res)                  \
-                       : "g" (__NR_##name),            \
-                         "g" (_a),                     \
-                         "g" (_b),                     \
-                         "g" (_c),                     \
-                         "g" (_d)                      \
-                       : "cc", "memory");              \
-  __syscall_return(type, __res);                       \
-}
-
-#define _syscall5(type, name, atype, a, btype, b,      \
-                  ctype, c, dtype, d, etype, e)                \
-type name(atype a, btype b, ctype c, dtype d, etype e) \
-{                                                      \
-  register long __res __asm__("er0");                  \
-  register long _a __asm__("er1");                     \
-  register long _b __asm__("er2");                     \
-  register long _c __asm__("er3");                     \
-  register long _d __asm__("er4");                     \
-  register long _e __asm__("er5");                     \
-  _a = (long)a;                                        \
-  _b = (long)b;                                        \
-  _c = (long)c;                                        \
-  _d = (long)d;                                        \
-  _e = (long)e;                                        \
-  __asm__ __volatile__ ("mov.l %1,er0\n\t"             \
-                        "trapa #0\n\t"                 \
-                       : "=r" (__res)                  \
-                       : "g" (__NR_##name),            \
-                         "g" (_a),                     \
-                         "g" (_b),                     \
-                         "g" (_c),                     \
-                         "g" (_d),                     \
-                         "g" (_e)                      \
-                       : "cc", "memory");              \
-  __syscall_return(type, __res);                       \
-}
-
-#define _syscall6(type, name, atype, a, btype, b,      \
-                  ctype, c, dtype, d, etype, e, ftype, f)      \
-type name(atype a, btype b, ctype c, dtype d, etype e, ftype f)        \
-{                                                      \
-  register long __res __asm__("er0");                  \
-  register long _a __asm__("er1");                     \
-  register long _b __asm__("er2");                     \
-  register long _c __asm__("er3");                     \
-  register long _d __asm__("er4");                     \
-  register long _e __asm__("er5");                     \
-  register long _f __asm__("er6");                     \
-  _a = (long)a;                                        \
-  _b = (long)b;                                        \
-  _c = (long)c;                                        \
-  _d = (long)d;                                        \
-  _e = (long)e;                                        \
-  _f = (long)f;                                        \
-  __asm__ __volatile__ ("mov.l %1,er0\n\t"             \
-                        "trapa #0\n\t"                 \
-                       : "=r" (__res)                  \
-                       : "g" (__NR_##name),            \
-                         "g" (_a),                     \
-                         "g" (_b),                     \
-                         "g" (_c),                     \
-                         "g" (_d),                     \
-                         "g" (_e)                      \
-                         "g" (_f)                      \
-                       : "cc", "memory");              \
-  __syscall_return(type, __res);                       \
-}
 
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
index 147e4ac1ebf0e44880c91f7fa4d27e296259c93b..5ae93afc67e1f019d6ce6d902ccac733a18a79fb 100644 (file)
@@ -7,5 +7,4 @@ header-y += ptrace-abi.h
 header-y += ucontext.h
 
 unifdef-y += mtrr.h
-unifdef-y += setup.h
 unifdef-y += vm86.h
index b01a7ec409ced2397bc8529051930dd4e3413b67..b8fa9557c532ffdebcfa6324a2b3d722514e336f 100644 (file)
@@ -4,7 +4,7 @@
 #ifdef __KERNEL__
 
 #include <asm/types.h>
-
+#include <linux/stddef.h>
 #include <linux/types.h>
 
 struct alt_instr {
@@ -118,4 +118,15 @@ static inline void alternatives_smp_switch(int smp) {}
 #define LOCK_PREFIX ""
 #endif
 
+struct paravirt_patch;
+#ifdef CONFIG_PARAVIRT
+void apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end);
+#else
+static inline void
+apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end)
+{}
+#define __start_parainstructions NULL
+#define __stop_parainstructions NULL
+#endif
+
 #endif /* _I386_ALTERNATIVE_H */
index b9529578fc37e4549d89520266a9b9e1605906ce..41a44319905fa884d58f53384d00376c60d51fb8 100644 (file)
@@ -37,18 +37,27 @@ extern void generic_apic_probe(void);
 /*
  * Basic functions accessing APICs.
  */
+#ifdef CONFIG_PARAVIRT
+#include <asm/paravirt.h>
+#else
+#define apic_write native_apic_write
+#define apic_write_atomic native_apic_write_atomic
+#define apic_read native_apic_read
+#endif
 
-static __inline void apic_write(unsigned long reg, unsigned long v)
+static __inline fastcall void native_apic_write(unsigned long reg,
+                                               unsigned long v)
 {
        *((volatile unsigned long *)(APIC_BASE+reg)) = v;
 }
 
-static __inline void apic_write_atomic(unsigned long reg, unsigned long v)
+static __inline fastcall void native_apic_write_atomic(unsigned long reg,
+                                                      unsigned long v)
 {
        xchg((volatile unsigned long *)(APIC_BASE+reg), v);
 }
 
-static __inline unsigned long apic_read(unsigned long reg)
+static __inline fastcall unsigned long native_apic_read(unsigned long reg)
 {
        return *((volatile unsigned long *)(APIC_BASE+reg));
 }
index a6c024e2506f8126195c337b8ff8bc4759cb8e2c..c57441bb290502c449e4217684711a3b11c34a3f 100644 (file)
@@ -187,9 +187,9 @@ static __inline__ int atomic_add_return(int i, atomic_t *v)
        /* Modern 486+ processor */
        __i = i;
        __asm__ __volatile__(
-               LOCK_PREFIX "xaddl %0, %1;"
-               :"=r"(i)
-               :"m"(v->counter), "0"(i));
+               LOCK_PREFIX "xaddl %0, %1"
+               :"+r" (i), "+m" (v->counter)
+               : : "memory");
        return i + __i;
 
 #ifdef CONFIG_M386
index 96b228e6e79cd1c086df76d6c00f7646a06b98f9..8ce79a6fa8919a7bf7557f39aa60fb6e71d1af39 100644 (file)
@@ -12,4 +12,8 @@
 #define EXTENDED_VGA   0xfffe          /* 80x50 mode */
 #define ASK_VGA                0xfffd          /* ask for it at bootup */
 
-#endif
+/* Physical address where kenrel should be loaded. */
+#define LOAD_PHYSICAL_ADDR ((0x100000 + CONFIG_PHYSICAL_ALIGN - 1) \
+                               & ~(CONFIG_PHYSICAL_ALIGN - 1))
+
+#endif /* _LINUX_BOOT_H */
index 8062cdbf2587f9213a2f0e35c8b536fc92572dec..b0fd78ca2619908a84d0eca0fcfb7d81b6e3f377 100644 (file)
@@ -4,20 +4,32 @@
 
 /*
  * Tell the user there is some problem.
- * The offending file and line are encoded after the "officially
- * undefined" opcode for parsing in the trap handler.
+ * The offending file and line are encoded encoded in the __bug_table section.
  */
 
 #ifdef CONFIG_BUG
 #define HAVE_ARCH_BUG
+
 #ifdef CONFIG_DEBUG_BUGVERBOSE
-#define BUG()                          \
- __asm__ __volatile__( "ud2\n"         \
-                       "\t.word %c0\n" \
-                       "\t.long %c1\n" \
-                        : : "i" (__LINE__), "i" (__FILE__))
+#define BUG()                                                          \
+       do {                                                            \
+               asm volatile("1:\tud2\n"                                \
+                            ".pushsection __bug_table,\"a\"\n"         \
+                            "2:\t.long 1b, %c0\n"                      \
+                            "\t.word %c1, 0\n"                         \
+                            "\t.org 2b+%c2\n"                          \
+                            ".popsection"                              \
+                            : : "i" (__FILE__), "i" (__LINE__),        \
+                            "i" (sizeof(struct bug_entry)));           \
+               for(;;) ;                                               \
+       } while(0)
+
 #else
-#define BUG() __asm__ __volatile__("ud2\n")
+#define BUG()                                                          \
+       do {                                                            \
+               asm volatile("ud2");                                    \
+               for(;;) ;                                               \
+       } while(0)
 #endif
 #endif
 
index 592ffeeda45e7745c4554201ce8a78da1a80df38..38f1aebbbdb5f5587df51976e13fd1f352fd36eb 100644 (file)
@@ -21,6 +21,7 @@
 #include <asm/processor.h>
 #include <asm/i387.h>
 #include <asm/msr.h>
+#include <asm/paravirt.h>
 
 static int __init no_halt(char *s)
 {
@@ -91,6 +92,9 @@ static void __init check_fpu(void)
 
 static void __init check_hlt(void)
 {
+       if (paravirt_enabled())
+               return;
+
        printk(KERN_INFO "Checking 'hlt' instruction... ");
        if (!boot_cpu_data.hlt_works_ok) {
                printk("disabled\n");
index b1bc7b1b64b0e304d13f907e4d5cd607417bdfee..9d914e1e4aad446e649dd8678d856768e637a38d 100644 (file)
@@ -13,6 +13,9 @@ struct i386_cpu {
 extern int arch_register_cpu(int num);
 #ifdef CONFIG_HOTPLUG_CPU
 extern void arch_unregister_cpu(int);
+extern int enable_cpu_hotplug;
+#else
+#define enable_cpu_hotplug     0
 #endif
 
 DECLARE_PER_CPU(int, cpu_state);
index d314ebb3d59e0efad1f30f1b9546657787bf4758..3f92b94e0d75893e2e82e8de090cbdaff80a905f 100644 (file)
@@ -31,7 +31,7 @@
 #define X86_FEATURE_PSE36      (0*32+17) /* 36-bit PSEs */
 #define X86_FEATURE_PN         (0*32+18) /* Processor serial number */
 #define X86_FEATURE_CLFLSH     (0*32+19) /* Supports the CLFLUSH instruction */
-#define X86_FEATURE_DTES       (0*32+21) /* Debug Trace Store */
+#define X86_FEATURE_DS         (0*32+21) /* Debug Store */
 #define X86_FEATURE_ACPI       (0*32+22) /* ACPI via MSR */
 #define X86_FEATURE_MMX                (0*32+23) /* Multimedia Extensions */
 #define X86_FEATURE_FXSR       (0*32+24) /* FXSAVE and FXRSTOR instructions (fast save and restore */
@@ -73,6 +73,8 @@
 #define X86_FEATURE_UP         (3*32+ 9) /* smp kernel running on up */
 #define X86_FEATURE_FXSAVE_LEAK (3*32+10) /* FXSAVE leaks FOP/FIP/FOP */
 #define X86_FEATURE_ARCH_PERFMON (3*32+11) /* Intel Architectural PerfMon */
+#define X86_FEATURE_PEBS       (3*32+12)  /* Precise-Event Based Sampling */
+#define X86_FEATURE_BTS                (3*32+13)  /* Branch Trace Store */
 
 /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
 #define X86_FEATURE_XMM3       (4*32+ 0) /* Streaming SIMD Extensions-3 */
 #define cpu_has_phe_enabled    boot_cpu_has(X86_FEATURE_PHE_EN)
 #define cpu_has_pmm            boot_cpu_has(X86_FEATURE_PMM)
 #define cpu_has_pmm_enabled    boot_cpu_has(X86_FEATURE_PMM_EN)
+#define cpu_has_ds             boot_cpu_has(X86_FEATURE_DS)
+#define cpu_has_pebs           boot_cpu_has(X86_FEATURE_PEBS)
+#define cpu_has_clflush                boot_cpu_has(X86_FEATURE_CLFLSH)
+#define cpu_has_bts            boot_cpu_has(X86_FEATURE_BTS)
 
 #endif /* __ASM_I386_CPUFEATURE_H */
 
index 3cbbecd790161babf7fa1df4a7c549d4c2107276..5252ee0f6d7a9ce0fd4825ce4381051334b55aea 100644 (file)
@@ -1,13 +1,14 @@
 #ifndef _I386_CURRENT_H
 #define _I386_CURRENT_H
 
-#include <linux/thread_info.h>
+#include <asm/pda.h>
+#include <linux/compiler.h>
 
 struct task_struct;
 
-static __always_inline struct task_struct * get_current(void)
+static __always_inline struct task_struct *get_current(void)
 {
-       return current_thread_info()->task;
+       return read_pda(pcurrent);
 }
  
 #define current get_current()
index b1c7650dc7b9e1a841552b832a0d8a2badb6e7fb..32d6678d0bbf2b1815019f1eaec21b60c2f17fee 100644 (file)
@@ -7,6 +7,7 @@
  * Delay routines calling functions in arch/i386/lib/delay.c
  */
  
+/* Undefined functions to get compile-time errors */
 extern void __bad_udelay(void);
 extern void __bad_ndelay(void);
 
@@ -15,13 +16,23 @@ extern void __ndelay(unsigned long nsecs);
 extern void __const_udelay(unsigned long usecs);
 extern void __delay(unsigned long loops);
 
+#if defined(CONFIG_PARAVIRT) && !defined(USE_REAL_TIME_DELAY)
+#define udelay(n) paravirt_ops.const_udelay((n) * 0x10c7ul)
+
+#define ndelay(n) paravirt_ops.const_udelay((n) * 5ul)
+
+#else /* !PARAVIRT || USE_REAL_TIME_DELAY */
+
+/* 0x10c7 is 2**32 / 1000000 (rounded up) */
 #define udelay(n) (__builtin_constant_p(n) ? \
        ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c7ul)) : \
        __udelay(n))
-       
+
+/* 0x5 is 2**32 / 1000000000 (rounded up) */
 #define ndelay(n) (__builtin_constant_p(n) ? \
        ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \
        __ndelay(n))
+#endif
 
 void use_tsc_delay(void);
 
index 5874ef119ffdc0cf42886585c2c8aed229cfb91e..f398cc456448187bff38c53ad81a314d2d063212 100644 (file)
@@ -4,8 +4,6 @@
 #include <asm/ldt.h>
 #include <asm/segment.h>
 
-#define CPU_16BIT_STACK_SIZE 1024
-
 #ifndef __ASSEMBLY__
 
 #include <linux/preempt.h>
@@ -16,8 +14,6 @@
 
 extern struct desc_struct cpu_gdt_table[GDT_ENTRIES];
 
-DECLARE_PER_CPU(unsigned char, cpu_16bit_stack[CPU_16BIT_STACK_SIZE]);
-
 struct Xgt_desc_struct {
        unsigned short size;
        unsigned long address __attribute__((packed));
@@ -33,11 +29,6 @@ static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
        return (struct desc_struct *)per_cpu(cpu_gdt_descr, cpu).address;
 }
 
-/*
- * This is the ldt that every process will get unless we need
- * something other than this.
- */
-extern struct desc_struct default_ldt[];
 extern struct desc_struct idt_table[];
 extern void set_intr_gate(unsigned int irq, void * addr);
 
@@ -64,8 +55,10 @@ static inline void pack_gate(__u32 *a, __u32 *b,
 #define DESCTYPE_DPL3  0x60    /* DPL-3 */
 #define DESCTYPE_S     0x10    /* !system */
 
+#ifdef CONFIG_PARAVIRT
+#include <asm/paravirt.h>
+#else
 #define load_TR_desc() __asm__ __volatile__("ltr %w0"::"q" (GDT_ENTRY_TSS*8))
-#define load_LDT_desc() __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8))
 
 #define load_gdt(dtr) __asm__ __volatile("lgdt %0"::"m" (*dtr))
 #define load_idt(dtr) __asm__ __volatile("lidt %0"::"m" (*dtr))
@@ -88,6 +81,10 @@ static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
 #undef C
 }
 
+#define write_ldt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
+#define write_gdt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
+#define write_idt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
+
 static inline void write_dt_entry(void *dt, int entry, __u32 entry_a, __u32 entry_b)
 {
        __u32 *lp = (__u32 *)((char *)dt + entry*8);
@@ -95,9 +92,25 @@ static inline void write_dt_entry(void *dt, int entry, __u32 entry_a, __u32 entr
        *(lp+1) = entry_b;
 }
 
-#define write_ldt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
-#define write_gdt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
-#define write_idt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
+#define set_ldt native_set_ldt
+#endif /* CONFIG_PARAVIRT */
+
+static inline fastcall void native_set_ldt(const void *addr,
+                                          unsigned int entries)
+{
+       if (likely(entries == 0))
+               __asm__ __volatile__("lldt %w0"::"q" (0));
+       else {
+               unsigned cpu = smp_processor_id();
+               __u32 a, b;
+
+               pack_descriptor(&a, &b, (unsigned long)addr,
+                               entries * sizeof(struct desc_struct) - 1,
+                               DESCTYPE_LDT, 0);
+               write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, a, b);
+               __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8));
+       }
+}
 
 static inline void _set_gate(int gate, unsigned int type, void *addr, unsigned short seg)
 {
@@ -115,14 +128,6 @@ static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, const vo
        write_gdt_entry(get_cpu_gdt_table(cpu), entry, a, b);
 }
 
-static inline void set_ldt_desc(unsigned int cpu, void *addr, unsigned int entries)
-{
-       __u32 a, b;
-       pack_descriptor(&a, &b, (unsigned long)addr,
-                       entries * sizeof(struct desc_struct) - 1,
-                       DESCTYPE_LDT, 0);
-       write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, a, b);
-}
 
 #define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr)
 
@@ -153,35 +158,22 @@ static inline void set_ldt_desc(unsigned int cpu, void *addr, unsigned int entri
 
 static inline void clear_LDT(void)
 {
-       int cpu = get_cpu();
-
-       set_ldt_desc(cpu, &default_ldt[0], 5);
-       load_LDT_desc();
-       put_cpu();
+       set_ldt(NULL, 0);
 }
 
 /*
  * load one particular LDT into the current CPU
  */
-static inline void load_LDT_nolock(mm_context_t *pc, int cpu)
+static inline void load_LDT_nolock(mm_context_t *pc)
 {
-       void *segments = pc->ldt;
-       int count = pc->size;
-
-       if (likely(!count)) {
-               segments = &default_ldt[0];
-               count = 5;
-       }
-               
-       set_ldt_desc(cpu, segments, count);
-       load_LDT_desc();
+       set_ldt(pc->ldt, pc->size);
 }
 
 static inline void load_LDT(mm_context_t *pc)
 {
-       int cpu = get_cpu();
-       load_LDT_nolock(pc, cpu);
-       put_cpu();
+       preempt_disable();
+       load_LDT_nolock(pc);
+       preempt_enable();
 }
 
 static inline unsigned long get_desc_base(unsigned long *desc)
@@ -193,6 +185,29 @@ static inline unsigned long get_desc_base(unsigned long *desc)
        return base;
 }
 
+#else /* __ASSEMBLY__ */
+
+/*
+ * GET_DESC_BASE reads the descriptor base of the specified segment.
+ *
+ * Args:
+ *    idx - descriptor index
+ *    gdt - GDT pointer
+ *    base - 32bit register to which the base will be written
+ *    lo_w - lo word of the "base" register
+ *    lo_b - lo byte of the "base" register
+ *    hi_b - hi byte of the low word of the "base" register
+ *
+ * Example:
+ *    GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah)
+ *    Will read the base address of GDT_ENTRY_ESPFIX_SS and put it into %eax.
+ */
+#define GET_DESC_BASE(idx, gdt, base, lo_w, lo_b, hi_b) \
+       movb idx*8+4(gdt), lo_b; \
+       movb idx*8+7(gdt), hi_b; \
+       shll $16, base; \
+       movw idx*8+2(gdt), lo_w;
+
 #endif /* !__ASSEMBLY__ */
 
 #endif
index 81999a3ebe7c4c712ac91da21fc963e24c638270..183eebeebbdce7a3d1794e79c67862cf93e8f745 100644 (file)
@@ -156,10 +156,10 @@ dma_get_cache_alignment(void)
        return (1 << INTERNODE_CACHE_SHIFT);
 }
 
-#define dma_is_consistent(d)   (1)
+#define dma_is_consistent(d, h)        (1)
 
 static inline void
-dma_cache_sync(void *vaddr, size_t size,
+dma_cache_sync(struct device *dev, void *vaddr, size_t size,
               enum dma_data_direction direction)
 {
        flush_write_buffers();
index f7514fb6e8e48d5deef18e316823bf95815922b2..395077aba583000b5a22fe55f6dad22b04938c48 100644 (file)
@@ -38,6 +38,11 @@ extern struct e820map e820;
 
 extern int e820_all_mapped(unsigned long start, unsigned long end,
                           unsigned type);
+extern void find_max_pfn(void);
+extern void register_bootmem_low_pages(unsigned long max_low_pfn);
+extern void register_memory(void);
+extern void limit_regions(unsigned long long size);
+extern void print_memory_map(char *who);
 
 #endif/*!__ASSEMBLY__*/
 
index 3a05436f31c0e8252e01389f251d7d5225711583..45d21a0c95bf8127368f7fe273facaabf2f6a9ee 100644 (file)
@@ -91,7 +91,7 @@ typedef struct user_fxsr_struct elf_fpxregset_t;
        pr_reg[7] = regs->xds;                          \
        pr_reg[8] = regs->xes;                          \
        savesegment(fs,pr_reg[9]);                      \
-       savesegment(gs,pr_reg[10]);                     \
+       pr_reg[10] = regs->xgs;                         \
        pr_reg[11] = regs->orig_eax;                    \
        pr_reg[12] = regs->eip;                         \
        pr_reg[13] = regs->xcs;                         \
index 946d97cfea23841ccbf919fe7cba1df0fb7abe45..438ef0ec7101c2f4b2fcf4fb711f99e81494712e 100644 (file)
@@ -56,7 +56,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
        if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
                return -EFAULT;
 
-       inc_preempt_count();
+       pagefault_disable();
 
        if (op == FUTEX_OP_SET)
                __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
@@ -88,7 +88,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
                }
        }
 
-       dec_preempt_count();
+       pagefault_enable();
 
        if (!ret) {
                switch (cmp) {
index 8ffbb0f0745760f7747d850faf89d884c4cd93eb..fd2be593b06e76b20380d17214dc0c17736bd140 100644 (file)
@@ -122,6 +122,6 @@ struct genapic {
        APICFUNC(phys_pkg_id) \
        }
 
-extern struct genapic *genapic;
+extern struct genapic *genapic, apic_default;
 
 #endif
index bc1d6edae1edfe73b9d77c318fea69b9d0951328..434936c732d67f94f083bbec7198051243feba66 100644 (file)
@@ -76,7 +76,9 @@ static inline void __save_init_fpu( struct task_struct *tsk )
 
 #define __unlazy_fpu( tsk ) do { \
        if (task_thread_info(tsk)->status & TS_USEDFPU) \
-               save_init_fpu( tsk ); \
+               save_init_fpu( tsk );                   \
+       else                                            \
+               tsk->fpu_counter = 0;                   \
 } while (0)
 
 #define __clear_fpu( tsk )                                     \
@@ -118,6 +120,7 @@ static inline void save_init_fpu( struct task_struct *tsk )
 extern unsigned short get_fpu_cwd( struct task_struct *tsk );
 extern unsigned short get_fpu_swd( struct task_struct *tsk );
 extern unsigned short get_fpu_mxcsr( struct task_struct *tsk );
+extern asmlinkage void math_state_restore(void);
 
 /*
  * Signal frame handlers...
index 73465d2892b92e27183e3427dc0d4783c9b8f6b0..0fc240c80f49c146e2799ebb19fd8078d9c2bdef 100644 (file)
@@ -40,13 +40,14 @@ static __inline__ int ide_default_irq(unsigned long base)
 
 static __inline__ unsigned long ide_default_io_base(int index)
 {
+       struct pci_dev *pdev;
        /*
         *      If PCI is present then it is not safe to poke around
         *      the other legacy IDE ports. Only 0x1f0 and 0x170 are
         *      defined compatibility mode ports for PCI. A user can 
         *      override this using ide= but we must default safe.
         */
-       if (pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL) == NULL) {
+       if ((pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL)) == NULL) {
                switch(index) {
                        case 2: return 0x1e8;
                        case 3: return 0x168;
@@ -54,6 +55,7 @@ static __inline__ unsigned long ide_default_io_base(int index)
                        case 5: return 0x160;
                }
        }
+       pci_dev_put(pdev);
        switch (index) {
                case 0: return 0x1f0;
                case 1: return 0x170;
index 68df0dc3ab8ff3e52379a0e6a0afda589c9346b1..86ff5e83be2f6d45d1a209fb30be7eea2192a3df 100644 (file)
@@ -256,11 +256,11 @@ static inline void flush_write_buffers(void)
 
 #endif /* __KERNEL__ */
 
-#ifdef SLOW_IO_BY_JUMPING
-#define __SLOW_DOWN_IO "jmp 1f; 1: jmp 1f; 1:"
+#if defined(CONFIG_PARAVIRT)
+#include <asm/paravirt.h>
 #else
+
 #define __SLOW_DOWN_IO "outb %%al,$0x80;"
-#endif
 
 static inline void slow_down_io(void) {
        __asm__ __volatile__(
@@ -271,6 +271,8 @@ static inline void slow_down_io(void) {
                : : );
 }
 
+#endif
+
 #ifdef CONFIG_X86_NUMAQ
 extern void *xquad_portio;    /* Where the IO area was mapped */
 #define XQUAD_PORT_ADDR(port, quad) (xquad_portio + (XQUAD_PORTIO_QUAD*quad) + port)
index 331726b411282646928f286590963bcd0c865c7b..11761cdaae19a00c0faa83ce057ac68029c0b466 100644 (file)
@@ -37,8 +37,13 @@ static __inline__ int irq_canonicalize(int irq)
 extern int irqbalance_disable(char *str);
 #endif
 
+extern void quirk_intel_irqbalance(void);
+
 #ifdef CONFIG_HOTPLUG_CPU
 extern void fixup_irqs(cpumask_t map);
 #endif
 
+void init_IRQ(void);
+void __init native_init_IRQ(void);
+
 #endif /* _ASM_IRQ_H */
index 3dd9c0b702704abfe23c0b8085f0fd84dcd3f5d5..a1b3f7f594a26e87d0dcc9902bd45bd4af1eaaf7 100644 (file)
@@ -1 +1,27 @@
-#include <asm-generic/irq_regs.h>
+/*
+ * Per-cpu current frame pointer - the location of the last exception frame on
+ * the stack, stored in the PDA.
+ *
+ * Jeremy Fitzhardinge <jeremy@goop.org>
+ */
+#ifndef _ASM_I386_IRQ_REGS_H
+#define _ASM_I386_IRQ_REGS_H
+
+#include <asm/pda.h>
+
+static inline struct pt_regs *get_irq_regs(void)
+{
+       return read_pda(irq_regs);
+}
+
+static inline struct pt_regs *set_irq_regs(struct pt_regs *new_regs)
+{
+       struct pt_regs *old_regs;
+
+       old_regs = read_pda(irq_regs);
+       write_pda(irq_regs, new_regs);
+
+       return old_regs;
+}
+
+#endif /* _ASM_I386_IRQ_REGS_H */
index e1bdb97c07faca1952b7734fcd4069f75a8b933f..17b18cf4fe9dc6bc5fb31bca36b55c144cd954e6 100644 (file)
@@ -10,6 +10,9 @@
 #ifndef _ASM_IRQFLAGS_H
 #define _ASM_IRQFLAGS_H
 
+#ifdef CONFIG_PARAVIRT
+#include <asm/paravirt.h>
+#else
 #ifndef __ASSEMBLY__
 
 static inline unsigned long __raw_local_save_flags(void)
@@ -25,9 +28,6 @@ static inline unsigned long __raw_local_save_flags(void)
        return flags;
 }
 
-#define raw_local_save_flags(flags) \
-               do { (flags) = __raw_local_save_flags(); } while (0)
-
 static inline void raw_local_irq_restore(unsigned long flags)
 {
        __asm__ __volatile__(
@@ -66,18 +66,6 @@ static inline void halt(void)
        __asm__ __volatile__("hlt": : :"memory");
 }
 
-static inline int raw_irqs_disabled_flags(unsigned long flags)
-{
-       return !(flags & (1 << 9));
-}
-
-static inline int raw_irqs_disabled(void)
-{
-       unsigned long flags = __raw_local_save_flags();
-
-       return raw_irqs_disabled_flags(flags);
-}
-
 /*
  * For spinlocks, etc:
  */
@@ -90,9 +78,33 @@ static inline unsigned long __raw_local_irq_save(void)
        return flags;
 }
 
+#else
+#define DISABLE_INTERRUPTS(clobbers)   cli
+#define ENABLE_INTERRUPTS(clobbers)    sti
+#define ENABLE_INTERRUPTS_SYSEXIT      sti; sysexit
+#define INTERRUPT_RETURN               iret
+#define GET_CR0_INTO_EAX               movl %cr0, %eax
+#endif /* __ASSEMBLY__ */
+#endif /* CONFIG_PARAVIRT */
+
+#ifndef __ASSEMBLY__
+#define raw_local_save_flags(flags) \
+               do { (flags) = __raw_local_save_flags(); } while (0)
+
 #define raw_local_irq_save(flags) \
                do { (flags) = __raw_local_irq_save(); } while (0)
 
+static inline int raw_irqs_disabled_flags(unsigned long flags)
+{
+       return !(flags & (1 << 9));
+}
+
+static inline int raw_irqs_disabled(void)
+{
+       unsigned long flags = __raw_local_save_flags();
+
+       return raw_irqs_disabled_flags(flags);
+}
 #endif /* __ASSEMBLY__ */
 
 /*
index fb42099e7bd4eb043ceaaea57d12e5391c40dd7e..605e3ccb991bde9af67cda27af76fe8fc12b4fb9 100644 (file)
@@ -2,4 +2,6 @@
 
 /* no action for generic */
 
+#ifndef ARCH_SETUP
 #define ARCH_SETUP
+#endif
index 697673b555ce3335f4f84e9653e00e6e4685a999..a4b0aa3320e681f802cb7b297766ec58f26d7f9c 100644 (file)
@@ -21,6 +21,7 @@ struct info {
        long ___eax;
        long ___ds;
        long ___es;
+       long ___fs;
        long ___orig_eax;
        long ___eip;
        long ___cs;
index 62b7bf1840942013a0a258a039a03e90c8458a66..68ff102d6f5e9e19a92641ce43e40caff64a3e92 100644 (file)
@@ -44,7 +44,7 @@ static inline void switch_mm(struct mm_struct *prev,
                 * load the LDT, if the LDT is different:
                 */
                if (unlikely(prev->context.ldt != next->context.ldt))
-                       load_LDT_nolock(&next->context, cpu);
+                       load_LDT_nolock(&next->context);
        }
 #ifdef CONFIG_SMP
        else {
@@ -56,14 +56,14 @@ static inline void switch_mm(struct mm_struct *prev,
                         * tlb flush IPI delivery. We must reload %cr3.
                         */
                        load_cr3(next->pgd);
-                       load_LDT_nolock(&next->context, cpu);
+                       load_LDT_nolock(&next->context);
                }
        }
 #endif
 }
 
-#define deactivate_mm(tsk, mm) \
-       asm("movl %0,%%fs ; movl %0,%%gs": :"r" (0))
+#define deactivate_mm(tsk, mm)                 \
+       asm("movl %0,%%fs": :"r" (0));
 
 #define activate_mm(prev, next) \
        switch_mm((prev),(next),NULL)
index 61b07332200683de0a2a04d4072847416bd4ebf6..3503ad66945ec4a488cbd192635e5cc7c7db1b4f 100644 (file)
@@ -120,13 +120,26 @@ static inline int pfn_valid(int pfn)
        __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
 #define alloc_bootmem_low_pages(x) \
        __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
-#define alloc_bootmem_node(ignore, x) \
-       __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
-#define alloc_bootmem_pages_node(ignore, x) \
-       __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
-#define alloc_bootmem_low_pages_node(ignore, x) \
-       __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
-
+#define alloc_bootmem_node(pgdat, x)                                   \
+({                                                                     \
+       struct pglist_data  __attribute__ ((unused))                    \
+                               *__alloc_bootmem_node__pgdat = (pgdat); \
+       __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES,        \
+                                               __pa(MAX_DMA_ADDRESS)); \
+})
+#define alloc_bootmem_pages_node(pgdat, x)                             \
+({                                                                     \
+       struct pglist_data  __attribute__ ((unused))                    \
+                               *__alloc_bootmem_node__pgdat = (pgdat); \
+       __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE,              \
+                                               __pa(MAX_DMA_ADDRESS))  \
+})
+#define alloc_bootmem_low_pages_node(pgdat, x)                         \
+({                                                                     \
+       struct pglist_data  __attribute__ ((unused))                    \
+                               *__alloc_bootmem_node__pgdat = (pgdat); \
+       __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0);          \
+})
 #endif /* CONFIG_NEED_MULTIPLE_NODES */
 
 #endif /* _ASM_MMZONE_H_ */
index 424661d25bd320702f08c619c5404c6324647a08..02f8f541cbe021d0b795d9e260fe945e110e9e1a 100644 (file)
@@ -20,6 +20,8 @@ struct mod_arch_specific
 #define MODULE_PROC_FAMILY "586TSC "
 #elif defined CONFIG_M586MMX
 #define MODULE_PROC_FAMILY "586MMX "
+#elif defined CONFIG_MCORE2
+#define MODULE_PROC_FAMILY "CORE2 "
 #elif defined CONFIG_M686
 #define MODULE_PROC_FAMILY "686 "
 #elif defined CONFIG_MPENTIUMII
@@ -60,18 +62,12 @@ struct mod_arch_specific
 #error unknown processor family
 #endif
 
-#ifdef CONFIG_REGPARM
-#define MODULE_REGPARM "REGPARM "
-#else
-#define MODULE_REGPARM ""
-#endif
-
 #ifdef CONFIG_4KSTACKS
 #define MODULE_STACKSIZE "4KSTACKS "
 #else
 #define MODULE_STACKSIZE ""
 #endif
 
-#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_REGPARM MODULE_STACKSIZE
+#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_STACKSIZE
 
 #endif /* _ASM_I386_MODULE_H */
index 76feedf85a8a8ce41e8bd5611d3942661817b9dc..13bafb16e7afd516d7efc47cd164b5461ecc2eaa 100644 (file)
@@ -97,7 +97,6 @@ struct mpc_config_bus
 #define BUSTYPE_TC     "TC"
 #define BUSTYPE_VME    "VME"
 #define BUSTYPE_XPRESS "XPRESS"
-#define BUSTYPE_NEC98  "NEC98"
 
 struct mpc_config_ioapic
 {
@@ -182,7 +181,6 @@ enum mp_bustype {
        MP_BUS_EISA,
        MP_BUS_PCI,
        MP_BUS_MCA,
-       MP_BUS_NEC98
 };
 #endif
 
index 62b76cd96957da8ddfca0a0d1a1508b373be8ab5..5679d4993072650d3e1a77b53656b0f544904c58 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef __ASM_MSR_H
 #define __ASM_MSR_H
 
+#ifdef CONFIG_PARAVIRT
+#include <asm/paravirt.h>
+#else
+
 /*
  * Access to machine-specific registers (available on 586 and better only)
  * Note: the rd* operations modify the parameters directly (without using
@@ -77,6 +81,7 @@ static inline void wrmsrl (unsigned long msr, unsigned long long val)
      __asm__ __volatile__("rdpmc" \
                          : "=a" (low), "=d" (high) \
                          : "c" (counter))
+#endif /* !CONFIG_PARAVIRT */
 
 /* symbolic names for some interesting MSRs */
 /* Intel defined MSRs. */
@@ -141,6 +146,10 @@ static inline void wrmsrl (unsigned long msr, unsigned long long val)
 #define MSR_IA32_MC0_ADDR              0x402
 #define MSR_IA32_MC0_MISC              0x403
 
+#define MSR_IA32_PEBS_ENABLE           0x3f1
+#define MSR_IA32_DS_AREA               0x600
+#define MSR_IA32_PERF_CAPABILITIES     0x345
+
 /* Pentium IV performance counter MSRs */
 #define MSR_P4_BPU_PERFCTR0            0x300
 #define MSR_P4_BPU_PERFCTR1            0x301
@@ -284,4 +293,13 @@ static inline void wrmsrl (unsigned long msr, unsigned long long val)
 #define MSR_TMTA_LRTI_READOUT          0x80868018
 #define MSR_TMTA_LRTI_VOLT_MHZ         0x8086801a
 
+/* Intel Core-based CPU performance counters */
+#define MSR_CORE_PERF_FIXED_CTR0       0x309
+#define MSR_CORE_PERF_FIXED_CTR1       0x30a
+#define MSR_CORE_PERF_FIXED_CTR2       0x30b
+#define MSR_CORE_PERF_FIXED_CTR_CTRL   0x38d
+#define MSR_CORE_PERF_GLOBAL_STATUS    0x38e
+#define MSR_CORE_PERF_GLOBAL_CTRL      0x38f
+#define MSR_CORE_PERF_GLOBAL_OVF_CTRL  0x390
+
 #endif /* __ASM_MSR_H */
index 269d315719ca422d478e7d18cd441cf71c44438d..b04333ea6f31e9bd338b9842d1afeec1ea9f7ba4 100644 (file)
@@ -5,6 +5,9 @@
 #define ASM_NMI_H
 
 #include <linux/pm.h>
+#include <asm/irq.h>
+
+#ifdef ARCH_HAS_NMI_WATCHDOG
 
 /**
  * do_nmi_callback
@@ -42,4 +45,9 @@ extern int proc_nmi_enabled(struct ctl_table *, int , struct file *,
                        void __user *, size_t *, loff_t *);
 extern int unknown_nmi_panic;
 
+void __trigger_all_cpu_backtrace(void);
+#define trigger_all_cpu_backtrace() __trigger_all_cpu_backtrace()
+
+#endif
+
 #endif /* ASM_NMI_H */
index f5bf544c729a373aa4ec1832aa9fa3cd55a13800..fd3f64ace24872f1e0843049434c95fff4cf2516 100644 (file)
@@ -52,6 +52,7 @@ typedef struct { unsigned long long pgprot; } pgprot_t;
 #define pte_val(x)     ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
 #define __pmd(x) ((pmd_t) { (x) } )
 #define HPAGE_SHIFT    21
+#include <asm-generic/pgtable-nopud.h>
 #else
 typedef struct { unsigned long pte_low; } pte_t;
 typedef struct { unsigned long pgd; } pgd_t;
@@ -59,6 +60,7 @@ typedef struct { unsigned long pgprot; } pgprot_t;
 #define boot_pte_t pte_t /* or would you rather have a typedef */
 #define pte_val(x)     ((x).pte_low)
 #define HPAGE_SHIFT    22
+#include <asm-generic/pgtable-nopmd.h>
 #endif
 #define PTE_MASK       PAGE_MASK
 
@@ -112,18 +114,18 @@ extern int page_is_ram(unsigned long pagenr);
 
 #ifdef __ASSEMBLY__
 #define __PAGE_OFFSET          CONFIG_PAGE_OFFSET
-#define __PHYSICAL_START       CONFIG_PHYSICAL_START
 #else
 #define __PAGE_OFFSET          ((unsigned long)CONFIG_PAGE_OFFSET)
-#define __PHYSICAL_START       ((unsigned long)CONFIG_PHYSICAL_START)
 #endif
-#define __KERNEL_START         (__PAGE_OFFSET + __PHYSICAL_START)
 
 
 #define PAGE_OFFSET            ((unsigned long)__PAGE_OFFSET)
 #define VMALLOC_RESERVE                ((unsigned long)__VMALLOC_RESERVE)
 #define MAXMEM                 (-__PAGE_OFFSET-__VMALLOC_RESERVE)
 #define __pa(x)                        ((unsigned long)(x)-PAGE_OFFSET)
+/* __pa_symbol should be used for C visible symbols.
+   This seems to be the official gcc blessed way to do such arithmetic. */
+#define __pa_symbol(x)          __pa(RELOC_HIDE((unsigned long)(x),0))
 #define __va(x)                        ((void *)((unsigned long)(x)+PAGE_OFFSET))
 #define pfn_to_kaddr(pfn)      __va((pfn) << PAGE_SHIFT)
 #ifdef CONFIG_FLATMEM
index 745dc5bd0fbc159e835fe530c074682ca8223efe..21b32466fcdcbbe42882192a0acee77eeab71ae6 100644 (file)
@@ -18,6 +18,5 @@
 #endif
 
 #define MAXHOSTNAMELEN 64      /* max length of hostname */
-#define COMMAND_LINE_SIZE 256
 
 #endif
diff --git a/include/asm-i386/paravirt.h b/include/asm-i386/paravirt.h
new file mode 100644 (file)
index 0000000..9f06265
--- /dev/null
@@ -0,0 +1,505 @@
+#ifndef __ASM_PARAVIRT_H
+#define __ASM_PARAVIRT_H
+/* Various instructions on x86 need to be replaced for
+ * para-virtualization: those hooks are defined here. */
+#include <linux/linkage.h>
+#include <linux/stringify.h>
+#include <asm/page.h>
+
+#ifdef CONFIG_PARAVIRT
+/* These are the most performance critical ops, so we want to be able to patch
+ * callers */
+#define PARAVIRT_IRQ_DISABLE 0
+#define PARAVIRT_IRQ_ENABLE 1
+#define PARAVIRT_RESTORE_FLAGS 2
+#define PARAVIRT_SAVE_FLAGS 3
+#define PARAVIRT_SAVE_FLAGS_IRQ_DISABLE 4
+#define PARAVIRT_INTERRUPT_RETURN 5
+#define PARAVIRT_STI_SYSEXIT 6
+
+/* Bitmask of what can be clobbered: usually at least eax. */
+#define CLBR_NONE 0x0
+#define CLBR_EAX 0x1
+#define CLBR_ECX 0x2
+#define CLBR_EDX 0x4
+#define CLBR_ANY 0x7
+
+#ifndef __ASSEMBLY__
+struct thread_struct;
+struct Xgt_desc_struct;
+struct tss_struct;
+struct mm_struct;
+struct paravirt_ops
+{
+       unsigned int kernel_rpl;
+       int paravirt_enabled;
+       const char *name;
+
+       /*
+        * Patch may replace one of the defined code sequences with arbitrary
+        * code, subject to the same register constraints.  This generally
+        * means the code is not free to clobber any registers other than EAX.
+        * The patch function should return the number of bytes of code
+        * generated, as we nop pad the rest in generic code.
+        */
+       unsigned (*patch)(u8 type, u16 clobber, void *firstinsn, unsigned len);
+
+       void (*arch_setup)(void);
+       char *(*memory_setup)(void);
+       void (*init_IRQ)(void);
+
+       void (*banner)(void);
+
+       unsigned long (*get_wallclock)(void);
+       int (*set_wallclock)(unsigned long);
+       void (*time_init)(void);
+
+       /* All the function pointers here are declared as "fastcall"
+          so that we get a specific register-based calling
+          convention.  This makes it easier to implement inline
+          assembler replacements. */
+
+       void (fastcall *cpuid)(unsigned int *eax, unsigned int *ebx,
+                     unsigned int *ecx, unsigned int *edx);
+
+       unsigned long (fastcall *get_debugreg)(int regno);
+       void (fastcall *set_debugreg)(int regno, unsigned long value);
+
+       void (fastcall *clts)(void);
+
+       unsigned long (fastcall *read_cr0)(void);
+       void (fastcall *write_cr0)(unsigned long);
+
+       unsigned long (fastcall *read_cr2)(void);
+       void (fastcall *write_cr2)(unsigned long);
+
+       unsigned long (fastcall *read_cr3)(void);
+       void (fastcall *write_cr3)(unsigned long);
+
+       unsigned long (fastcall *read_cr4_safe)(void);
+       unsigned long (fastcall *read_cr4)(void);
+       void (fastcall *write_cr4)(unsigned long);
+
+       unsigned long (fastcall *save_fl)(void);
+       void (fastcall *restore_fl)(unsigned long);
+       void (fastcall *irq_disable)(void);
+       void (fastcall *irq_enable)(void);
+       void (fastcall *safe_halt)(void);
+       void (fastcall *halt)(void);
+       void (fastcall *wbinvd)(void);
+
+       /* err = 0/-EFAULT.  wrmsr returns 0/-EFAULT. */
+       u64 (fastcall *read_msr)(unsigned int msr, int *err);
+       int (fastcall *write_msr)(unsigned int msr, u64 val);
+
+       u64 (fastcall *read_tsc)(void);
+       u64 (fastcall *read_pmc)(void);
+
+       void (fastcall *load_tr_desc)(void);
+       void (fastcall *load_gdt)(const struct Xgt_desc_struct *);
+       void (fastcall *load_idt)(const struct Xgt_desc_struct *);
+       void (fastcall *store_gdt)(struct Xgt_desc_struct *);
+       void (fastcall *store_idt)(struct Xgt_desc_struct *);
+       void (fastcall *set_ldt)(const void *desc, unsigned entries);
+       unsigned long (fastcall *store_tr)(void);
+       void (fastcall *load_tls)(struct thread_struct *t, unsigned int cpu);
+       void (fastcall *write_ldt_entry)(void *dt, int entrynum,
+                                        u32 low, u32 high);
+       void (fastcall *write_gdt_entry)(void *dt, int entrynum,
+                                        u32 low, u32 high);
+       void (fastcall *write_idt_entry)(void *dt, int entrynum,
+                                        u32 low, u32 high);
+       void (fastcall *load_esp0)(struct tss_struct *tss,
+                                  struct thread_struct *thread);
+
+       void (fastcall *set_iopl_mask)(unsigned mask);
+
+       void (fastcall *io_delay)(void);
+       void (*const_udelay)(unsigned long loops);
+
+#ifdef CONFIG_X86_LOCAL_APIC
+       void (fastcall *apic_write)(unsigned long reg, unsigned long v);
+       void (fastcall *apic_write_atomic)(unsigned long reg, unsigned long v);
+       unsigned long (fastcall *apic_read)(unsigned long reg);
+#endif
+
+       void (fastcall *flush_tlb_user)(void);
+       void (fastcall *flush_tlb_kernel)(void);
+       void (fastcall *flush_tlb_single)(u32 addr);
+
+       void (fastcall *set_pte)(pte_t *ptep, pte_t pteval);
+       void (fastcall *set_pte_at)(struct mm_struct *mm, u32 addr, pte_t *ptep, pte_t pteval);
+       void (fastcall *set_pmd)(pmd_t *pmdp, pmd_t pmdval);
+       void (fastcall *pte_update)(struct mm_struct *mm, u32 addr, pte_t *ptep);
+       void (fastcall *pte_update_defer)(struct mm_struct *mm, u32 addr, pte_t *ptep);
+#ifdef CONFIG_X86_PAE
+       void (fastcall *set_pte_atomic)(pte_t *ptep, pte_t pteval);
+       void (fastcall *set_pte_present)(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte);
+       void (fastcall *set_pud)(pud_t *pudp, pud_t pudval);
+       void (fastcall *pte_clear)(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
+       void (fastcall *pmd_clear)(pmd_t *pmdp);
+#endif
+
+       /* These two are jmp to, not actually called. */
+       void (fastcall *irq_enable_sysexit)(void);
+       void (fastcall *iret)(void);
+};
+
+/* Mark a paravirt probe function. */
+#define paravirt_probe(fn)                                             \
+ static asmlinkage void (*__paravirtprobe_##fn)(void) __attribute_used__ \
+               __attribute__((__section__(".paravirtprobe"))) = fn
+
+extern struct paravirt_ops paravirt_ops;
+
+#define paravirt_enabled() (paravirt_ops.paravirt_enabled)
+
+static inline void load_esp0(struct tss_struct *tss,
+                            struct thread_struct *thread)
+{
+       paravirt_ops.load_esp0(tss, thread);
+}
+
+#define ARCH_SETUP                     paravirt_ops.arch_setup();
+static inline unsigned long get_wallclock(void)
+{
+       return paravirt_ops.get_wallclock();
+}
+
+static inline int set_wallclock(unsigned long nowtime)
+{
+       return paravirt_ops.set_wallclock(nowtime);
+}
+
+static inline void do_time_init(void)
+{
+       return paravirt_ops.time_init();
+}
+
+/* The paravirtualized CPUID instruction. */
+static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
+                          unsigned int *ecx, unsigned int *edx)
+{
+       paravirt_ops.cpuid(eax, ebx, ecx, edx);
+}
+
+/*
+ * These special macros can be used to get or set a debugging register
+ */
+#define get_debugreg(var, reg) var = paravirt_ops.get_debugreg(reg)
+#define set_debugreg(val, reg) paravirt_ops.set_debugreg(reg, val)
+
+#define clts() paravirt_ops.clts()
+
+#define read_cr0() paravirt_ops.read_cr0()
+#define write_cr0(x) paravirt_ops.write_cr0(x)
+
+#define read_cr2() paravirt_ops.read_cr2()
+#define write_cr2(x) paravirt_ops.write_cr2(x)
+
+#define read_cr3() paravirt_ops.read_cr3()
+#define write_cr3(x) paravirt_ops.write_cr3(x)
+
+#define read_cr4() paravirt_ops.read_cr4()
+#define read_cr4_safe(x) paravirt_ops.read_cr4_safe()
+#define write_cr4(x) paravirt_ops.write_cr4(x)
+
+static inline void raw_safe_halt(void)
+{
+       paravirt_ops.safe_halt();
+}
+
+static inline void halt(void)
+{
+       paravirt_ops.safe_halt();
+}
+#define wbinvd() paravirt_ops.wbinvd()
+
+#define get_kernel_rpl()  (paravirt_ops.kernel_rpl)
+
+#define rdmsr(msr,val1,val2) do {                              \
+       int _err;                                               \
+       u64 _l = paravirt_ops.read_msr(msr,&_err);              \
+       val1 = (u32)_l;                                         \
+       val2 = _l >> 32;                                        \
+} while(0)
+
+#define wrmsr(msr,val1,val2) do {                              \
+       u64 _l = ((u64)(val2) << 32) | (val1);                  \
+       paravirt_ops.write_msr((msr), _l);                      \
+} while(0)
+
+#define rdmsrl(msr,val) do {                                   \
+       int _err;                                               \
+       val = paravirt_ops.read_msr((msr),&_err);               \
+} while(0)
+
+#define wrmsrl(msr,val) (paravirt_ops.write_msr((msr),(val)))
+#define wrmsr_safe(msr,a,b) ({                                 \
+       u64 _l = ((u64)(b) << 32) | (a);                        \
+       paravirt_ops.write_msr((msr),_l);                       \
+})
+
+/* rdmsr with exception handling */
+#define rdmsr_safe(msr,a,b) ({                                 \
+       int _err;                                               \
+       u64 _l = paravirt_ops.read_msr(msr,&_err);              \
+       (*a) = (u32)_l;                                         \
+       (*b) = _l >> 32;                                        \
+       _err; })
+
+#define rdtsc(low,high) do {                                   \
+       u64 _l = paravirt_ops.read_tsc();                       \
+       low = (u32)_l;                                          \
+       high = _l >> 32;                                        \
+} while(0)
+
+#define rdtscl(low) do {                                       \
+       u64 _l = paravirt_ops.read_tsc();                       \
+       low = (int)_l;                                          \
+} while(0)
+
+#define rdtscll(val) (val = paravirt_ops.read_tsc())
+
+#define write_tsc(val1,val2) wrmsr(0x10, val1, val2)
+
+#define rdpmc(counter,low,high) do {                           \
+       u64 _l = paravirt_ops.read_pmc();                       \
+       low = (u32)_l;                                          \
+       high = _l >> 32;                                        \
+} while(0)
+
+#define load_TR_desc() (paravirt_ops.load_tr_desc())
+#define load_gdt(dtr) (paravirt_ops.load_gdt(dtr))
+#define load_idt(dtr) (paravirt_ops.load_idt(dtr))
+#define set_ldt(addr, entries) (paravirt_ops.set_ldt((addr), (entries)))
+#define store_gdt(dtr) (paravirt_ops.store_gdt(dtr))
+#define store_idt(dtr) (paravirt_ops.store_idt(dtr))
+#define store_tr(tr) ((tr) = paravirt_ops.store_tr())
+#define load_TLS(t,cpu) (paravirt_ops.load_tls((t),(cpu)))
+#define write_ldt_entry(dt, entry, low, high)                          \
+       (paravirt_ops.write_ldt_entry((dt), (entry), (low), (high)))
+#define write_gdt_entry(dt, entry, low, high)                          \
+       (paravirt_ops.write_gdt_entry((dt), (entry), (low), (high)))
+#define write_idt_entry(dt, entry, low, high)                          \
+       (paravirt_ops.write_idt_entry((dt), (entry), (low), (high)))
+#define set_iopl_mask(mask) (paravirt_ops.set_iopl_mask(mask))
+
+/* The paravirtualized I/O functions */
+static inline void slow_down_io(void) {
+       paravirt_ops.io_delay();
+#ifdef REALLY_SLOW_IO
+       paravirt_ops.io_delay();
+       paravirt_ops.io_delay();
+       paravirt_ops.io_delay();
+#endif
+}
+
+#ifdef CONFIG_X86_LOCAL_APIC
+/*
+ * Basic functions accessing APICs.
+ */
+static inline void apic_write(unsigned long reg, unsigned long v)
+{
+       paravirt_ops.apic_write(reg,v);
+}
+
+static inline void apic_write_atomic(unsigned long reg, unsigned long v)
+{
+       paravirt_ops.apic_write_atomic(reg,v);
+}
+
+static inline unsigned long apic_read(unsigned long reg)
+{
+       return paravirt_ops.apic_read(reg);
+}
+#endif
+
+
+#define __flush_tlb() paravirt_ops.flush_tlb_user()
+#define __flush_tlb_global() paravirt_ops.flush_tlb_kernel()
+#define __flush_tlb_single(addr) paravirt_ops.flush_tlb_single(addr)
+
+static inline void set_pte(pte_t *ptep, pte_t pteval)
+{
+       paravirt_ops.set_pte(ptep, pteval);
+}
+
+static inline void set_pte_at(struct mm_struct *mm, u32 addr, pte_t *ptep, pte_t pteval)
+{
+       paravirt_ops.set_pte_at(mm, addr, ptep, pteval);
+}
+
+static inline void set_pmd(pmd_t *pmdp, pmd_t pmdval)
+{
+       paravirt_ops.set_pmd(pmdp, pmdval);
+}
+
+static inline void pte_update(struct mm_struct *mm, u32 addr, pte_t *ptep)
+{
+       paravirt_ops.pte_update(mm, addr, ptep);
+}
+
+static inline void pte_update_defer(struct mm_struct *mm, u32 addr, pte_t *ptep)
+{
+       paravirt_ops.pte_update_defer(mm, addr, ptep);
+}
+
+#ifdef CONFIG_X86_PAE
+static inline void set_pte_atomic(pte_t *ptep, pte_t pteval)
+{
+       paravirt_ops.set_pte_atomic(ptep, pteval);
+}
+
+static inline void set_pte_present(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte)
+{
+       paravirt_ops.set_pte_present(mm, addr, ptep, pte);
+}
+
+static inline void set_pud(pud_t *pudp, pud_t pudval)
+{
+       paravirt_ops.set_pud(pudp, pudval);
+}
+
+static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
+{
+       paravirt_ops.pte_clear(mm, addr, ptep);
+}
+
+static inline void pmd_clear(pmd_t *pmdp)
+{
+       paravirt_ops.pmd_clear(pmdp);
+}
+#endif
+
+/* These all sit in the .parainstructions section to tell us what to patch. */
+struct paravirt_patch {
+       u8 *instr;              /* original instructions */
+       u8 instrtype;           /* type of this instruction */
+       u8 len;                 /* length of original instruction */
+       u16 clobbers;           /* what registers you may clobber */
+};
+
+#define paravirt_alt(insn_string, typenum, clobber)    \
+       "771:\n\t" insn_string "\n" "772:\n"            \
+       ".pushsection .parainstructions,\"a\"\n"        \
+       "  .long 771b\n"                                \
+       "  .byte " __stringify(typenum) "\n"            \
+       "  .byte 772b-771b\n"                           \
+       "  .short " __stringify(clobber) "\n"           \
+       ".popsection"
+
+static inline unsigned long __raw_local_save_flags(void)
+{
+       unsigned long f;
+
+       __asm__ __volatile__(paravirt_alt( "pushl %%ecx; pushl %%edx;"
+                                          "call *%1;"
+                                          "popl %%edx; popl %%ecx",
+                                         PARAVIRT_SAVE_FLAGS, CLBR_NONE)
+                            : "=a"(f): "m"(paravirt_ops.save_fl)
+                            : "memory", "cc");
+       return f;
+}
+
+static inline void raw_local_irq_restore(unsigned long f)
+{
+       __asm__ __volatile__(paravirt_alt( "pushl %%ecx; pushl %%edx;"
+                                          "call *%1;"
+                                          "popl %%edx; popl %%ecx",
+                                         PARAVIRT_RESTORE_FLAGS, CLBR_EAX)
+                            : "=a"(f) : "m" (paravirt_ops.restore_fl), "0"(f)
+                            : "memory", "cc");
+}
+
+static inline void raw_local_irq_disable(void)
+{
+       __asm__ __volatile__(paravirt_alt( "pushl %%ecx; pushl %%edx;"
+                                          "call *%0;"
+                                          "popl %%edx; popl %%ecx",
+                                         PARAVIRT_IRQ_DISABLE, CLBR_EAX)
+                            : : "m" (paravirt_ops.irq_disable)
+                            : "memory", "eax", "cc");
+}
+
+static inline void raw_local_irq_enable(void)
+{
+       __asm__ __volatile__(paravirt_alt( "pushl %%ecx; pushl %%edx;"
+                                          "call *%0;"
+                                          "popl %%edx; popl %%ecx",
+                                         PARAVIRT_IRQ_ENABLE, CLBR_EAX)
+                            : : "m" (paravirt_ops.irq_enable)
+                            : "memory", "eax", "cc");
+}
+
+static inline unsigned long __raw_local_irq_save(void)
+{
+       unsigned long f;
+
+       __asm__ __volatile__(paravirt_alt( "pushl %%ecx; pushl %%edx;"
+                                          "call *%1; pushl %%eax;"
+                                          "call *%2; popl %%eax;"
+                                          "popl %%edx; popl %%ecx",
+                                         PARAVIRT_SAVE_FLAGS_IRQ_DISABLE,
+                                         CLBR_NONE)
+                            : "=a"(f)
+                            : "m" (paravirt_ops.save_fl),
+                              "m" (paravirt_ops.irq_disable)
+                            : "memory", "cc");
+       return f;
+}
+
+#define CLI_STRING paravirt_alt("pushl %%ecx; pushl %%edx;"            \
+                    "call *paravirt_ops+%c[irq_disable];"              \
+                    "popl %%edx; popl %%ecx",                          \
+                    PARAVIRT_IRQ_DISABLE, CLBR_EAX)
+
+#define STI_STRING paravirt_alt("pushl %%ecx; pushl %%edx;"            \
+                    "call *paravirt_ops+%c[irq_enable];"               \
+                    "popl %%edx; popl %%ecx",                          \
+                    PARAVIRT_IRQ_ENABLE, CLBR_EAX)
+#define CLI_STI_CLOBBERS , "%eax"
+#define CLI_STI_INPUT_ARGS \
+       ,                                                               \
+       [irq_disable] "i" (offsetof(struct paravirt_ops, irq_disable)), \
+       [irq_enable] "i" (offsetof(struct paravirt_ops, irq_enable))
+
+#else  /* __ASSEMBLY__ */
+
+#define PARA_PATCH(ptype, clobbers, ops)       \
+771:;                                          \
+       ops;                                    \
+772:;                                          \
+       .pushsection .parainstructions,"a";     \
+        .long 771b;                            \
+        .byte ptype;                           \
+        .byte 772b-771b;                       \
+        .short clobbers;                       \
+       .popsection
+
+#define INTERRUPT_RETURN                               \
+       PARA_PATCH(PARAVIRT_INTERRUPT_RETURN, CLBR_ANY, \
+       jmp *%cs:paravirt_ops+PARAVIRT_iret)
+
+#define DISABLE_INTERRUPTS(clobbers)                   \
+       PARA_PATCH(PARAVIRT_IRQ_DISABLE, clobbers,      \
+       pushl %ecx; pushl %edx;                         \
+       call *paravirt_ops+PARAVIRT_irq_disable;        \
+       popl %edx; popl %ecx)                           \
+
+#define ENABLE_INTERRUPTS(clobbers)                    \
+       PARA_PATCH(PARAVIRT_IRQ_ENABLE, clobbers,       \
+       pushl %ecx; pushl %edx;                         \
+       call *%cs:paravirt_ops+PARAVIRT_irq_enable;     \
+       popl %edx; popl %ecx)
+
+#define ENABLE_INTERRUPTS_SYSEXIT                      \
+       PARA_PATCH(PARAVIRT_STI_SYSEXIT, CLBR_ANY,      \
+       jmp *%cs:paravirt_ops+PARAVIRT_irq_enable_sysexit)
+
+#define GET_CR0_INTO_EAX                       \
+       call *paravirt_ops+PARAVIRT_read_cr0
+
+#endif /* __ASSEMBLY__ */
+#endif /* CONFIG_PARAVIRT */
+#endif /* __ASM_PARAVIRT_H */
diff --git a/include/asm-i386/pda.h b/include/asm-i386/pda.h
new file mode 100644 (file)
index 0000000..2ba2736
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+   Per-processor Data Areas
+   Jeremy Fitzhardinge <jeremy@goop.org> 2006
+   Based on asm-x86_64/pda.h by Andi Kleen.
+ */
+#ifndef _I386_PDA_H
+#define _I386_PDA_H
+
+#include <linux/stddef.h>
+#include <linux/types.h>
+
+struct i386_pda
+{
+       struct i386_pda *_pda;          /* pointer to self */
+
+       int cpu_number;
+       struct task_struct *pcurrent;   /* current process */
+       struct pt_regs *irq_regs;
+};
+
+extern struct i386_pda *_cpu_pda[];
+
+#define cpu_pda(i)     (_cpu_pda[i])
+
+#define pda_offset(field) offsetof(struct i386_pda, field)
+
+extern void __bad_pda_field(void);
+
+/* This variable is never instantiated.  It is only used as a stand-in
+   for the real per-cpu PDA memory, so that gcc can understand what
+   memory operations the inline asms() below are performing.  This
+   eliminates the need to make the asms volatile or have memory
+   clobbers, so gcc can readily analyse them. */
+extern struct i386_pda _proxy_pda;
+
+#define pda_to_op(op,field,val)                                                \
+       do {                                                            \
+               typedef typeof(_proxy_pda.field) T__;                   \
+               if (0) { T__ tmp__; tmp__ = (val); }                    \
+               switch (sizeof(_proxy_pda.field)) {                     \
+               case 1:                                                 \
+                       asm(op "b %1,%%gs:%c2"                          \
+                           : "+m" (_proxy_pda.field)                   \
+                           :"ri" ((T__)val),                           \
+                            "i"(pda_offset(field)));                   \
+                       break;                                          \
+               case 2:                                                 \
+                       asm(op "w %1,%%gs:%c2"                          \
+                           : "+m" (_proxy_pda.field)                   \
+                           :"ri" ((T__)val),                           \
+                            "i"(pda_offset(field)));                   \
+                       break;                                          \
+               case 4:                                                 \
+                       asm(op "l %1,%%gs:%c2"                          \
+                           : "+m" (_proxy_pda.field)                   \
+                           :"ri" ((T__)val),                           \
+                            "i"(pda_offset(field)));                   \
+                       break;                                          \
+               default: __bad_pda_field();                             \
+               }                                                       \
+       } while (0)
+
+#define pda_from_op(op,field)                                          \
+       ({                                                              \
+               typeof(_proxy_pda.field) ret__;                         \
+               switch (sizeof(_proxy_pda.field)) {                     \
+               case 1:                                                 \
+                       asm(op "b %%gs:%c1,%0"                          \
+                           : "=r" (ret__)                              \
+                           : "i" (pda_offset(field)),                  \
+                             "m" (_proxy_pda.field));                  \
+                       break;                                          \
+               case 2:                                                 \
+                       asm(op "w %%gs:%c1,%0"                          \
+                           : "=r" (ret__)                              \
+                           : "i" (pda_offset(field)),                  \
+                             "m" (_proxy_pda.field));                  \
+                       break;                                          \
+               case 4:                                                 \
+                       asm(op "l %%gs:%c1,%0"                          \
+                           : "=r" (ret__)                              \
+                           : "i" (pda_offset(field)),                  \
+                             "m" (_proxy_pda.field));                  \
+                       break;                                          \
+               default: __bad_pda_field();                             \
+               }                                                       \
+               ret__; })
+
+/* Return a pointer to a pda field */
+#define pda_addr(field)                                                        \
+       ((typeof(_proxy_pda.field) *)((unsigned char *)read_pda(_pda) + \
+                                     pda_offset(field)))
+
+#define read_pda(field) pda_from_op("mov",field)
+#define write_pda(field,val) pda_to_op("mov",field,val)
+#define add_pda(field,val) pda_to_op("add",field,val)
+#define sub_pda(field,val) pda_to_op("sub",field,val)
+#define or_pda(field,val) pda_to_op("or",field,val)
+
+#endif /* _I386_PDA_H */
index 5764afa4b6a4b4a690a595cad8df504a8b43cf8c..510ae1d3486c7c289b80e765af719aa80c166c94 100644 (file)
@@ -1,6 +1,31 @@
 #ifndef __ARCH_I386_PERCPU__
 #define __ARCH_I386_PERCPU__
 
+#ifndef __ASSEMBLY__
 #include <asm-generic/percpu.h>
+#else
+
+/*
+ * PER_CPU finds an address of a per-cpu variable.
+ *
+ * Args:
+ *    var - variable name
+ *    cpu - 32bit register containing the current CPU number
+ *
+ * The resulting address is stored in the "cpu" argument.
+ *
+ * Example:
+ *    PER_CPU(cpu_gdt_descr, %ebx)
+ */
+#ifdef CONFIG_SMP
+#define PER_CPU(var, cpu) \
+       movl __per_cpu_offset(,cpu,4), cpu;     \
+       addl $per_cpu__/**/var, cpu;
+#else /* ! SMP */
+#define PER_CPU(var, cpu) \
+       movl $per_cpu__/**/var, cpu;
+#endif /* SMP */
+
+#endif /* !__ASSEMBLY__ */
 
 #endif /* __ARCH_I386_PERCPU__ */
index 8d8d3b9ecdb02d0437b0e0393fc8e753cd439178..38c3fcc0676d9810c1f1ca4d168bdb519c6e0438 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _I386_PGTABLE_2LEVEL_H
 #define _I386_PGTABLE_2LEVEL_H
 
-#include <asm-generic/pgtable-nopmd.h>
-
 #define pte_ERROR(e) \
        printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, (e).pte_low)
 #define pgd_ERROR(e) \
  * within a page table are directly modified.  Thus, the following
  * hook is made available.
  */
+#ifndef CONFIG_PARAVIRT
 #define set_pte(pteptr, pteval) (*(pteptr) = pteval)
 #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
+#define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval))
+#endif
+
 #define set_pte_atomic(pteptr, pteval) set_pte(pteptr,pteval)
 #define set_pte_present(mm,addr,ptep,pteval) set_pte_at(mm,addr,ptep,pteval)
-#define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval))
 
 #define pte_clear(mm,addr,xp)  do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
 #define pmd_clear(xp)  do { set_pmd(xp, __pmd(0)); } while (0)
 
-#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
-#define ptep_get_and_clear(mm,addr,xp) __pte(xchg(&(xp)->pte_low, 0))
+#define raw_ptep_get_and_clear(xp)     __pte(xchg(&(xp)->pte_low, 0))
 
 #define pte_page(x)            pfn_to_page(pte_pfn(x))
 #define pte_none(x)            (!(x).pte_low)
index c2d701ea35beb0650ecd0cd8360f857a1e90ca31..7a2318f3830316ccb5d542ff05b0fdbb009f00b2 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _I386_PGTABLE_3LEVEL_H
 #define _I386_PGTABLE_3LEVEL_H
 
-#include <asm-generic/pgtable-nopud.h>
-
 /*
  * Intel Physical Address Extension (PAE) Mode - three-level page
  * tables on PPro+ CPUs.
@@ -44,6 +42,7 @@ static inline int pte_exec_kernel(pte_t pte)
        return pte_x(pte);
 }
 
+#ifndef CONFIG_PARAVIRT
 /* Rules for using set_pte: the pte being assigned *must* be
  * either not present or in a state where the hardware will
  * not attempt to update the pte.  In places where this is
@@ -80,25 +79,6 @@ static inline void set_pte_present(struct mm_struct *mm, unsigned long addr, pte
 #define set_pud(pudptr,pudval) \
                (*(pudptr) = (pudval))
 
-/*
- * Pentium-II erratum A13: in PAE mode we explicitly have to flush
- * the TLB via cr3 if the top-level pgd is changed...
- * We do not let the generic code free and clear pgd entries due to
- * this erratum.
- */
-static inline void pud_clear (pud_t * pud) { }
-
-#define pud_page(pud) \
-((struct page *) __va(pud_val(pud) & PAGE_MASK))
-
-#define pud_page_vaddr(pud) \
-((unsigned long) __va(pud_val(pud) & PAGE_MASK))
-
-
-/* Find an entry in the second-level page table.. */
-#define pmd_offset(pud, address) ((pmd_t *) pud_page(*(pud)) + \
-                       pmd_index(address))
-
 /*
  * For PTEs and PDEs, we must clear the P-bit first when clearing a page table
  * entry, so clear the bottom half first and enforce ordering with a compiler
@@ -118,9 +98,28 @@ static inline void pmd_clear(pmd_t *pmd)
        smp_wmb();
        *(tmp + 1) = 0;
 }
+#endif
+
+/*
+ * Pentium-II erratum A13: in PAE mode we explicitly have to flush
+ * the TLB via cr3 if the top-level pgd is changed...
+ * We do not let the generic code free and clear pgd entries due to
+ * this erratum.
+ */
+static inline void pud_clear (pud_t * pud) { }
+
+#define pud_page(pud) \
+((struct page *) __va(pud_val(pud) & PAGE_MASK))
+
+#define pud_page_vaddr(pud) \
+((unsigned long) __va(pud_val(pud) & PAGE_MASK))
+
+
+/* Find an entry in the second-level page table.. */
+#define pmd_offset(pud, address) ((pmd_t *) pud_page(*(pud)) + \
+                       pmd_index(address))
 
-#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
-static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
+static inline pte_t raw_ptep_get_and_clear(pte_t *ptep)
 {
        pte_t res;
 
index 7d398f493ddeedfc2d5e826d595028767ae64b76..e6a4723f0eb1f088affdc67cd42a8f5d7c02ce21 100644 (file)
@@ -15,6 +15,7 @@
 #include <asm/processor.h>
 #include <asm/fixmap.h>
 #include <linux/threads.h>
+#include <asm/paravirt.h>
 
 #ifndef _I386_BITOPS_H
 #include <asm/bitops.h>
@@ -34,14 +35,14 @@ struct vm_area_struct;
 #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
 extern unsigned long empty_zero_page[1024];
 extern pgd_t swapper_pg_dir[1024];
-extern kmem_cache_t *pgd_cache;
-extern kmem_cache_t *pmd_cache;
+extern struct kmem_cache *pgd_cache;
+extern struct kmem_cache *pmd_cache;
 extern spinlock_t pgd_lock;
 extern struct page *pgd_list;
 
-void pmd_ctor(void *, kmem_cache_t *, unsigned long);
-void pgd_ctor(void *, kmem_cache_t *, unsigned long);
-void pgd_dtor(void *, kmem_cache_t *, unsigned long);
+void pmd_ctor(void *, struct kmem_cache *, unsigned long);
+void pgd_ctor(void *, struct kmem_cache *, unsigned long);
+void pgd_dtor(void *, struct kmem_cache *, unsigned long);
 void pgtable_cache_init(void);
 void paging_init(void);
 
@@ -246,6 +247,7 @@ static inline pte_t pte_mkhuge(pte_t pte)   { (pte).pte_low |= _PAGE_PSE; return p
 # include <asm/pgtable-2level.h>
 #endif
 
+#ifndef CONFIG_PARAVIRT
 /*
  * Rules for using pte_update - it must be called after any PTE update which
  * has not been done using the set_pte / clear_pte interfaces.  It is used by
@@ -261,7 +263,7 @@ static inline pte_t pte_mkhuge(pte_t pte)   { (pte).pte_low |= _PAGE_PSE; return p
  */
 #define pte_update(mm, addr, ptep)             do { } while (0)
 #define pte_update_defer(mm, addr, ptep)       do { } while (0)
-
+#endif
 
 /*
  * We only update the dirty/accessed state if we set
@@ -275,7 +277,7 @@ static inline pte_t pte_mkhuge(pte_t pte)   { (pte).pte_low |= _PAGE_PSE; return p
 do {                                                                   \
        if (dirty) {                                                    \
                (ptep)->pte_low = (entry).pte_low;                      \
-               pte_update_defer((vma)->vm_mm, (addr), (ptep));         \
+               pte_update_defer((vma)->vm_mm, (address), (ptep));      \
                flush_tlb_page(vma, address);                           \
        }                                                               \
 } while (0)
@@ -305,7 +307,7 @@ do {                                                                        \
        __dirty = pte_dirty(*(ptep));                                   \
        if (__dirty) {                                                  \
                clear_bit(_PAGE_BIT_DIRTY, &(ptep)->pte_low);           \
-               pte_update_defer((vma)->vm_mm, (addr), (ptep));         \
+               pte_update_defer((vma)->vm_mm, (address), (ptep));      \
                flush_tlb_page(vma, address);                           \
        }                                                               \
        __dirty;                                                        \
@@ -318,12 +320,20 @@ do {                                                                      \
        __young = pte_young(*(ptep));                                   \
        if (__young) {                                                  \
                clear_bit(_PAGE_BIT_ACCESSED, &(ptep)->pte_low);        \
-               pte_update_defer((vma)->vm_mm, (addr), (ptep));         \
+               pte_update_defer((vma)->vm_mm, (address), (ptep));      \
                flush_tlb_page(vma, address);                           \
        }                                                               \
        __young;                                                        \
 })
 
+#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
+static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
+{
+       pte_t pte = raw_ptep_get_and_clear(ptep);
+       pte_update(mm, addr, ptep);
+       return pte;
+}
+
 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL
 static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full)
 {
index e0ddca94d50c8f42c71e05e1796086fdf84ad0ef..a52d65440429b99520ff6fa355ccd95d92611619 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/threads.h>
 #include <asm/percpu.h>
 #include <linux/cpumask.h>
+#include <linux/init.h>
 
 /* flag for disabling the tsc */
 extern int tsc_disable;
@@ -72,6 +73,7 @@ struct cpuinfo_x86 {
 #endif
        unsigned char x86_max_cores;    /* cpuid returned max cores value */
        unsigned char apicid;
+       unsigned short x86_clflush_size;
 #ifdef CONFIG_SMP
        unsigned char booted_cores;     /* number of cores as seen by OS */
        __u8 phys_proc_id;              /* Physical processor id. */
@@ -111,6 +113,8 @@ extern struct cpuinfo_x86 cpu_data[];
 extern int cpu_llc_id[NR_CPUS];
 extern char ignore_fpu_irq;
 
+void __init cpu_detect(struct cpuinfo_x86 *c);
+
 extern void identify_cpu(struct cpuinfo_x86 *);
 extern void print_cpu_info(struct cpuinfo_x86 *);
 extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
@@ -143,8 +147,8 @@ static inline void detect_ht(struct cpuinfo_x86 *c) {}
 #define X86_EFLAGS_VIP 0x00100000 /* Virtual Interrupt Pending */
 #define X86_EFLAGS_ID  0x00200000 /* CPUID detection flag */
 
-static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
-                          unsigned int *ecx, unsigned int *edx)
+static inline fastcall void native_cpuid(unsigned int *eax, unsigned int *ebx,
+                                        unsigned int *ecx, unsigned int *edx)
 {
        /* ecx is often an input as well as an output. */
        __asm__("cpuid"
@@ -155,59 +159,6 @@ static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
                : "0" (*eax), "2" (*ecx));
 }
 
-/*
- * Generic CPUID function
- * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
- * resulting in stale register contents being returned.
- */
-static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx)
-{
-       *eax = op;
-       *ecx = 0;
-       __cpuid(eax, ebx, ecx, edx);
-}
-
-/* Some CPUID calls want 'count' to be placed in ecx */
-static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx,
-                              int *edx)
-{
-       *eax = op;
-       *ecx = count;
-       __cpuid(eax, ebx, ecx, edx);
-}
-
-/*
- * CPUID functions returning a single datum
- */
-static inline unsigned int cpuid_eax(unsigned int op)
-{
-       unsigned int eax, ebx, ecx, edx;
-
-       cpuid(op, &eax, &ebx, &ecx, &edx);
-       return eax;
-}
-static inline unsigned int cpuid_ebx(unsigned int op)
-{
-       unsigned int eax, ebx, ecx, edx;
-
-       cpuid(op, &eax, &ebx, &ecx, &edx);
-       return ebx;
-}
-static inline unsigned int cpuid_ecx(unsigned int op)
-{
-       unsigned int eax, ebx, ecx, edx;
-
-       cpuid(op, &eax, &ebx, &ecx, &edx);
-       return ecx;
-}
-static inline unsigned int cpuid_edx(unsigned int op)
-{
-       unsigned int eax, ebx, ecx, edx;
-
-       cpuid(op, &eax, &ebx, &ecx, &edx);
-       return edx;
-}
-
 #define load_cr3(pgdir) write_cr3(__pa(pgdir))
 
 /*
@@ -473,6 +424,7 @@ struct thread_struct {
        .vm86_info = NULL,                                              \
        .sysenter_cs = __KERNEL_CS,                                     \
        .io_bitmap_ptr = NULL,                                          \
+       .gs = __KERNEL_PDA,                                             \
 }
 
 /*
@@ -489,18 +441,9 @@ struct thread_struct {
        .io_bitmap      = { [ 0 ... IO_BITMAP_LONGS] = ~0 },            \
 }
 
-static inline void load_esp0(struct tss_struct *tss, struct thread_struct *thread)
-{
-       tss->esp0 = thread->esp0;
-       /* This can only happen when SEP is enabled, no need to test "SEP"arately */
-       if (unlikely(tss->ss1 != thread->sysenter_cs)) {
-               tss->ss1 = thread->sysenter_cs;
-               wrmsr(MSR_IA32_SYSENTER_CS, thread->sysenter_cs, 0);
-       }
-}
-
 #define start_thread(regs, new_eip, new_esp) do {              \
-       __asm__("movl %0,%%fs ; movl %0,%%gs": :"r" (0));       \
+       __asm__("movl %0,%%fs": :"r" (0));                      \
+       regs->xgs = 0;                                          \
        set_fs(USER_DS);                                        \
        regs->xds = __USER_DS;                                  \
        regs->xes = __USER_DS;                                  \
@@ -510,33 +453,6 @@ static inline void load_esp0(struct tss_struct *tss, struct thread_struct *threa
        regs->esp = new_esp;                                    \
 } while (0)
 
-/*
- * These special macros can be used to get or set a debugging register
- */
-#define get_debugreg(var, register)                            \
-               __asm__("movl %%db" #register ", %0"            \
-                       :"=r" (var))
-#define set_debugreg(value, register)                  \
-               __asm__("movl %0,%%db" #register                \
-                       : /* no output */                       \
-                       :"r" (value))
-
-/*
- * Set IOPL bits in EFLAGS from given mask
- */
-static inline void set_iopl_mask(unsigned mask)
-{
-       unsigned int reg;
-       __asm__ __volatile__ ("pushfl;"
-                             "popl %0;"
-                             "andl %1, %0;"
-                             "orl %2, %0;"
-                             "pushl %0;"
-                             "popfl"
-                               : "=&r" (reg)
-                               : "i" (~X86_EFLAGS_IOPL), "r" (mask));
-}
-
 /* Forward declaration, a strange C thing */
 struct task_struct;
 struct mm_struct;
@@ -628,6 +544,105 @@ static inline void rep_nop(void)
 
 #define cpu_relax()    rep_nop()
 
+#ifdef CONFIG_PARAVIRT
+#include <asm/paravirt.h>
+#else
+#define paravirt_enabled() 0
+#define __cpuid native_cpuid
+
+static inline void load_esp0(struct tss_struct *tss, struct thread_struct *thread)
+{
+       tss->esp0 = thread->esp0;
+       /* This can only happen when SEP is enabled, no need to test "SEP"arately */
+       if (unlikely(tss->ss1 != thread->sysenter_cs)) {
+               tss->ss1 = thread->sysenter_cs;
+               wrmsr(MSR_IA32_SYSENTER_CS, thread->sysenter_cs, 0);
+       }
+}
+
+/*
+ * These special macros can be used to get or set a debugging register
+ */
+#define get_debugreg(var, register)                            \
+               __asm__("movl %%db" #register ", %0"            \
+                       :"=r" (var))
+#define set_debugreg(value, register)                  \
+               __asm__("movl %0,%%db" #register                \
+                       : /* no output */                       \
+                       :"r" (value))
+
+#define set_iopl_mask native_set_iopl_mask
+#endif /* CONFIG_PARAVIRT */
+
+/*
+ * Set IOPL bits in EFLAGS from given mask
+ */
+static fastcall inline void native_set_iopl_mask(unsigned mask)
+{
+       unsigned int reg;
+       __asm__ __volatile__ ("pushfl;"
+                             "popl %0;"
+                             "andl %1, %0;"
+                             "orl %2, %0;"
+                             "pushl %0;"
+                             "popfl"
+                               : "=&r" (reg)
+                               : "i" (~X86_EFLAGS_IOPL), "r" (mask));
+}
+
+/*
+ * Generic CPUID function
+ * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
+ * resulting in stale register contents being returned.
+ */
+static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx)
+{
+       *eax = op;
+       *ecx = 0;
+       __cpuid(eax, ebx, ecx, edx);
+}
+
+/* Some CPUID calls want 'count' to be placed in ecx */
+static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx,
+                              int *edx)
+{
+       *eax = op;
+       *ecx = count;
+       __cpuid(eax, ebx, ecx, edx);
+}
+
+/*
+ * CPUID functions returning a single datum
+ */
+static inline unsigned int cpuid_eax(unsigned int op)
+{
+       unsigned int eax, ebx, ecx, edx;
+
+       cpuid(op, &eax, &ebx, &ecx, &edx);
+       return eax;
+}
+static inline unsigned int cpuid_ebx(unsigned int op)
+{
+       unsigned int eax, ebx, ecx, edx;
+
+       cpuid(op, &eax, &ebx, &ecx, &edx);
+       return ebx;
+}
+static inline unsigned int cpuid_ecx(unsigned int op)
+{
+       unsigned int eax, ebx, ecx, edx;
+
+       cpuid(op, &eax, &ebx, &ecx, &edx);
+       return ecx;
+}
+static inline unsigned int cpuid_edx(unsigned int op)
+{
+       unsigned int eax, ebx, ecx, edx;
+
+       cpuid(op, &eax, &ebx, &ecx, &edx);
+       return edx;
+}
+
 /* generic versions from gas */
 #define GENERIC_NOP1   ".byte 0x90\n"
 #define GENERIC_NOP2           ".byte 0x89,0xf6\n"
@@ -727,4 +742,7 @@ extern unsigned long boot_option_idle_override;
 extern void enable_sep_cpu(void);
 extern int sysenter_setup(void);
 
+extern int init_gdt(int cpu, struct task_struct *idle);
+extern void secondary_cpu_init(void);
+
 #endif /* __ASM_I386_PROCESSOR_H */
index d505f501077a67bc77b01729a724b61eb6e26b7a..bdbc894339b470b55fa6ed7848602bd8e5f4a071 100644 (file)
@@ -16,6 +16,8 @@ struct pt_regs {
        long eax;
        int  xds;
        int  xes;
+       /* int  xfs; */
+       int  xgs;
        long orig_eax;
        long eip;
        int  xcs;
index bc598d6388e30ad44db8ae857402d7af4a2db3aa..041906f3c6df73375abda597ba38e63922ffb542 100644 (file)
@@ -75,8 +75,8 @@ struct rw_semaphore {
 
 
 #define __RWSEM_INITIALIZER(name) \
-{ RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, LIST_HEAD_INIT((name).wait_list) \
-       __RWSEM_DEP_MAP_INIT(name) }
+{ RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \
+  LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) }
 
 #define DECLARE_RWSEM(name) \
        struct rw_semaphore name = __RWSEM_INITIALIZER(name)
index b7ab59685ba7f1784769f7247ba839c048e5f72a..3c796af337762629038d39bc4ecc2031c7fff2a6 100644 (file)
@@ -39,7 +39,7 @@
  *  25 - APM BIOS support 
  *
  *  26 - ESPFIX small SS
- *  27 - unused
+ *  27 - PDA                           [ per-cpu private data area ]
  *  28 - unused
  *  29 - unused
  *  30 - unused
@@ -74,6 +74,9 @@
 #define GDT_ENTRY_ESPFIX_SS            (GDT_ENTRY_KERNEL_BASE + 14)
 #define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)
 
+#define GDT_ENTRY_PDA                  (GDT_ENTRY_KERNEL_BASE + 15)
+#define __KERNEL_PDA (GDT_ENTRY_PDA * 8)
+
 #define GDT_ENTRY_DOUBLEFAULT_TSS      31
 
 /*
 #define SEGMENT_LDT            0x4
 #define SEGMENT_GDT            0x0
 
+#ifndef CONFIG_PARAVIRT
 #define get_kernel_rpl()  0
 #endif
+#endif
index 2734909eff840f82b676b8ed8cb7ab208ea6a473..67659dbaf120a8dd4ec816bcde1734736fd20026 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef _i386_SETUP_H
 #define _i386_SETUP_H
 
+#define COMMAND_LINE_SIZE 256
+
 #ifdef __KERNEL__
 #include <linux/pfn.h>
 
  */
 #define MAXMEM_PFN     PFN_DOWN(MAXMEM)
 #define MAX_NONPAE_PFN (1 << 20)
-#endif
 
 #define PARAM_SIZE 4096
-#define COMMAND_LINE_SIZE 256
 
 #define OLD_CL_MAGIC_ADDR      0x90020
 #define OLD_CL_MAGIC           0xA33F
@@ -70,6 +70,7 @@ extern unsigned char boot_params[PARAM_SIZE];
 struct e820entry;
 
 char * __init machine_specific_memory_setup(void);
+char *memory_setup(void);
 
 int __init copy_e820_map(struct e820entry * biosmap, int nr_map);
 int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map);
@@ -78,4 +79,6 @@ void __init add_memory_region(unsigned long long start,
 
 #endif /* __ASSEMBLY__ */
 
+#endif  /*  __KERNEL__  */
+
 #endif /* _i386_SETUP_H */
index bd59c1508e7127bd592bdd09d9d69e6a528ba3e9..64fe624c02caa5ed80838428a5366aa385924888 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/kernel.h>
 #include <linux/threads.h>
 #include <linux/cpumask.h>
+#include <asm/pda.h>
 #endif
 
 #ifdef CONFIG_X86_LOCAL_APIC
@@ -56,7 +57,7 @@ extern void cpu_uninit(void);
  * from the initial startup. We map APIC_BASE very early in page_setup(),
  * so this is correct in the x86 case.
  */
-#define raw_smp_processor_id() (current_thread_info()->cpu)
+#define raw_smp_processor_id() (read_pda(cpu_number))
 
 extern cpumask_t cpu_callout_map;
 extern cpumask_t cpu_callin_map;
index c18b71fae6b38f6ec0a524509deb4a229de002ad..d3bcebed60ca6ef4895b7a22ea139023f4a6d49f 100644 (file)
@@ -7,8 +7,14 @@
 #include <asm/processor.h>
 #include <linux/compiler.h>
 
+#ifdef CONFIG_PARAVIRT
+#include <asm/paravirt.h>
+#else
 #define CLI_STRING     "cli"
 #define STI_STRING     "sti"
+#define CLI_STI_CLOBBERS
+#define CLI_STI_INPUT_ARGS
+#endif /* CONFIG_PARAVIRT */
 
 /*
  * Your basic SMP spinlocks, allowing only a single CPU anywhere
@@ -53,25 +59,28 @@ static inline void __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long fla
 {
        asm volatile(
                "\n1:\t"
-               LOCK_PREFIX " ; decb %0\n\t"
+               LOCK_PREFIX " ; decb %[slock]\n\t"
                "jns 5f\n"
                "2:\t"
-               "testl $0x200, %1\n\t"
+               "testl $0x200, %[flags]\n\t"
                "jz 4f\n\t"
                STI_STRING "\n"
                "3:\t"
                "rep;nop\n\t"
-               "cmpb $0, %0\n\t"
+               "cmpb $0, %[slock]\n\t"
                "jle 3b\n\t"
                CLI_STRING "\n\t"
                "jmp 1b\n"
                "4:\t"
                "rep;nop\n\t"
-               "cmpb $0, %0\n\t"
+               "cmpb $0, %[slock]\n\t"
                "jg 1b\n\t"
                "jmp 4b\n"
                "5:\n\t"
-               : "+m" (lock->slock) : "r" (flags) : "memory");
+               : [slock] "+m" (lock->slock)
+               : [flags] "r" (flags)
+                 CLI_STI_INPUT_ARGS
+               : "memory" CLI_STI_CLOBBERS);
 }
 #endif
 
index 08be1e5009d4d773dbb77078674450ceb117f6ba..8dbaafe611ffc744b426d944bb893c54445f2e32 100644 (file)
@@ -6,29 +6,14 @@
 #include <asm/desc.h>
 #include <asm/i387.h>
 
-static inline int
-arch_prepare_suspend(void)
-{
-       /* If you want to make non-PSE machine work, turn off paging
-           in swsusp_arch_suspend. swsusp_pg_dir should have identity mapping, so
-           it could work...  */
-       if (!cpu_has_pse) {
-               printk(KERN_ERR "PSE is required for swsusp.\n");
-               return -EPERM;
-       }
-       return 0;
-}
+static inline int arch_prepare_suspend(void) { return 0; }
 
 /* image of the saved processor state */
 struct saved_context {
        u16 es, fs, gs, ss;
        unsigned long cr0, cr2, cr3, cr4;
-       u16 gdt_pad;
-       u16 gdt_limit;
-       unsigned long gdt_base;
-       u16 idt_pad;
-       u16 idt_limit;
-       unsigned long idt_base;
+       struct Xgt_desc_struct gdt;
+       struct Xgt_desc_struct idt;
        u16 ldt;
        u16 tss;
        unsigned long tr;
index a6dabbcd6e6a71ec61d06b3eb74d21d3181e1aad..a6d20d9a1a307b0f6bbf55351e91fb26f48ad6b0 100644 (file)
@@ -88,6 +88,9 @@ __asm__ __volatile__ ("movw %%dx,%1\n\t" \
 #define savesegment(seg, value) \
        asm volatile("mov %%" #seg ",%0":"=rm" (value))
 
+#ifdef CONFIG_PARAVIRT
+#include <asm/paravirt.h>
+#else
 #define read_cr0() ({ \
        unsigned int __dummy; \
        __asm__ __volatile__( \
@@ -139,17 +142,18 @@ __asm__ __volatile__ ("movw %%dx,%1\n\t" \
 #define write_cr4(x) \
        __asm__ __volatile__("movl %0,%%cr4": :"r" (x))
 
-/*
- * Clear and set 'TS' bit respectively
- */
+#define wbinvd() \
+       __asm__ __volatile__ ("wbinvd": : :"memory")
+
+/* Clear the 'TS' bit */
 #define clts() __asm__ __volatile__ ("clts")
+#endif/* CONFIG_PARAVIRT */
+
+/* Set the 'TS' bit */
 #define stts() write_cr0(8 | read_cr0())
 
 #endif /* __KERNEL__ */
 
-#define wbinvd() \
-       __asm__ __volatile__ ("wbinvd": : :"memory")
-
 static inline unsigned long get_limit(unsigned long segment)
 {
        unsigned long __limit;
index 72c10e3190f832c9140a51a6a9e461aad5110a2c..12baf1d6343ff7be1c6155cff33f650658f666bc 100644 (file)
@@ -17,6 +17,17 @@ struct termios {
        cc_t c_cc[NCCS];                /* control characters */
 };
 
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
 /* c_cc characters */
 #define VINTR 0
 #define VQUIT 1
index 54d6d7aea938cf4fb1d8266418f9df1f790274c0..46d32ad9208256ab045785cdc355b1253860a486 100644 (file)
@@ -95,15 +95,7 @@ static inline struct thread_info *current_thread_info(void)
 
 /* thread information allocation */
 #ifdef CONFIG_DEBUG_STACK_USAGE
-#define alloc_thread_info(tsk)                                 \
-       ({                                                      \
-               struct thread_info *ret;                        \
-                                                               \
-               ret = kmalloc(THREAD_SIZE, GFP_KERNEL);         \
-               if (ret)                                        \
-                       memset(ret, 0, THREAD_SIZE);            \
-               ret;                                            \
-       })
+#define alloc_thread_info(tsk) kzalloc(THREAD_SIZE, GFP_KERNEL)
 #else
 #define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
 #endif
diff --git a/include/asm-i386/time.h b/include/asm-i386/time.h
new file mode 100644 (file)
index 0000000..ea8065a
--- /dev/null
@@ -0,0 +1,41 @@
+#ifndef _ASMi386_TIME_H
+#define _ASMi386_TIME_H
+
+#include <linux/efi.h>
+#include "mach_time.h"
+
+static inline unsigned long native_get_wallclock(void)
+{
+       unsigned long retval;
+
+       if (efi_enabled)
+               retval = efi_get_time();
+       else
+               retval = mach_get_cmos_time();
+
+       return retval;
+}
+
+static inline int native_set_wallclock(unsigned long nowtime)
+{
+       int retval;
+
+       if (efi_enabled)
+               retval = efi_set_rtc_mmss(nowtime);
+       else
+               retval = mach_set_rtc_mmss(nowtime);
+
+       return retval;
+}
+
+#ifdef CONFIG_PARAVIRT
+#include <asm/paravirt.h>
+#else /* !CONFIG_PARAVIRT */
+
+#define get_wallclock() native_get_wallclock()
+#define set_wallclock(x) native_set_wallclock(x)
+#define do_time_init() time_init_hook()
+
+#endif /* CONFIG_PARAVIRT */
+
+#endif
index 360648b0f2b3888235e95f8b7420879934a9e0bc..4dd82840d53bafd18d3538f0a1a52ec1d1f204a5 100644 (file)
@@ -4,7 +4,15 @@
 #include <linux/mm.h>
 #include <asm/processor.h>
 
-#define __flush_tlb()                                                  \
+#ifdef CONFIG_PARAVIRT
+#include <asm/paravirt.h>
+#else
+#define __flush_tlb() __native_flush_tlb()
+#define __flush_tlb_global() __native_flush_tlb_global()
+#define __flush_tlb_single(addr) __native_flush_tlb_single(addr)
+#endif
+
+#define __native_flush_tlb()                                           \
        do {                                                            \
                unsigned int tmpreg;                                    \
                                                                        \
@@ -19,7 +27,7 @@
  * Global pages have to be flushed a bit differently. Not a real
  * performance problem because this does not happen often.
  */
-#define __flush_tlb_global()                                           \
+#define __native_flush_tlb_global()                                    \
        do {                                                            \
                unsigned int tmpreg, cr4, cr4_orig;                     \
                                                                        \
@@ -36,6 +44,9 @@
                        : "memory");                                    \
        } while (0)
 
+#define __native_flush_tlb_single(addr)                                \
+       __asm__ __volatile__("invlpg (%0)" ::"r" (addr) : "memory")
+
 # define __flush_tlb_all()                                             \
        do {                                                            \
                if (cpu_has_pge)                                        \
@@ -46,9 +57,6 @@
 
 #define cpu_has_invlpg (boot_cpu_data.x86 > 3)
 
-#define __flush_tlb_single(addr) \
-       __asm__ __volatile__("invlpg (%0)" ::"r" (addr) : "memory")
-
 #ifdef CONFIG_X86_INVLPG
 # define __flush_tlb_one(addr) __flush_tlb_single(addr)
 #else
index beeeaf6b054a178db754757b6b9547fa784725d3..833fa1704ff995c32a412f6fdf09b9f62a9cdf43 100644 (file)
 #ifdef __KERNEL__
 
 #define NR_syscalls 320
-#include <linux/err.h>
-
-/*
- * user-visible error numbers are in the range -1 - -MAX_ERRNO: see
- * <asm-i386/errno.h>
- */
-#define __syscall_return(type, res) \
-do { \
-       if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
-               errno = -(res); \
-               res = -1; \
-       } \
-       return (type) (res); \
-} while (0)
-
-/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-long __res; \
-__asm__ volatile ("int $0x80" \
-       : "=a" (__res) \
-       : "0" (__NR_##name)); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-long __res; \
-__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
-       : "=a" (__res) \
-       : "0" (__NR_##name),"ri" ((long)(arg1)) : "memory"); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-long __res; \
-__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
-       : "=a" (__res) \
-       : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)) \
-       : "memory"); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-long __res; \
-__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
-       : "=a" (__res) \
-       : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
-                 "d" ((long)(arg3)) : "memory"); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-long __res; \
-__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
-       : "=a" (__res) \
-       : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
-         "d" ((long)(arg3)),"S" ((long)(arg4)) : "memory"); \
-__syscall_return(type,__res); \
-} 
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-         type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-long __res; \
-__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; movl %1,%%eax ; " \
-                  "int $0x80 ; pop %%ebx" \
-       : "=a" (__res) \
-       : "i" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
-         "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) \
-       : "memory"); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-         type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
-{ \
-long __res; \
-  struct { long __a1; long __a6; } __s = { (long)arg1, (long)arg6 }; \
-__asm__ volatile ("push %%ebp ; push %%ebx ; movl 4(%2),%%ebp ; " \
-                  "movl 0(%2),%%ebx ; movl %1,%%eax ; int $0x80 ; " \
-                  "pop %%ebx ;  pop %%ebp" \
-       : "=a" (__res) \
-       : "i" (__NR_##name),"0" ((long)(&__s)),"c" ((long)(arg2)), \
-         "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) \
-       : "memory"); \
-__syscall_return(type,__res); \
-}
 
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
index 5031d693b89d35fb3f7cfce8db78a79bb1db5503..aa2c931e30dbd0f6540b894dc110021aa215e4bd 100644 (file)
@@ -71,6 +71,7 @@ static inline void arch_unw_init_blocked(struct unwind_frame_info *info)
        info->regs.xss = __KERNEL_DS;
        info->regs.xds = __USER_DS;
        info->regs.xes = __USER_DS;
+       info->regs.xgs = __KERNEL_PDA;
 }
 
 extern asmlinkage int arch_unwind_init_running(struct unwind_frame_info *,
@@ -78,17 +79,13 @@ extern asmlinkage int arch_unwind_init_running(struct unwind_frame_info *,
                                                                           void *arg),
                                                void *arg);
 
-static inline int arch_unw_user_mode(const struct unwind_frame_info *info)
+static inline int arch_unw_user_mode(/*const*/ struct unwind_frame_info *info)
 {
-#if 0 /* This can only work when selector register and EFLAGS saves/restores
-         are properly annotated (and tracked in UNW_REGISTER_INFO). */
-       return user_mode_vm(&info->regs);
-#else
-       return info->regs.eip < PAGE_OFFSET
+       return user_mode_vm(&info->regs)
+              || info->regs.eip < PAGE_OFFSET
               || (info->regs.eip >= __fix_to_virt(FIX_VDSO)
-                   && info->regs.eip < __fix_to_virt(FIX_VDSO) + PAGE_SIZE)
+                  && info->regs.eip < __fix_to_virt(FIX_VDSO) + PAGE_SIZE)
               || info->regs.esp < PAGE_OFFSET;
-#endif
 }
 
 #else
index 952fd695738073e0c5e4639a85ade992b3349b39..a5edf517b992d51a3689cb1539a7dd12f1368c13 100644 (file)
@@ -145,26 +145,13 @@ struct vm86plus_struct {
  * at the end of the structure. Look at ptrace.h to see the "normal"
  * setup. For user space layout see 'struct vm86_regs' above.
  */
+#include <asm/ptrace.h>
 
 struct kernel_vm86_regs {
 /*
  * normal regs, with special meaning for the segment descriptors..
  */
-       long ebx;
-       long ecx;
-       long edx;
-       long esi;
-       long edi;
-       long ebp;
-       long eax;
-       long __null_ds;
-       long __null_es;
-       long orig_eax;
-       long eip;
-       unsigned short cs, __csh;
-       long eflags;
-       long esp;
-       unsigned short ss, __ssh;
+       struct pt_regs pt;
 /*
  * these are specific to v86 mode:
  */
index 15818a18bc520930035aed74691c317706da2df1..4a1e48b9f4031b2808d973d2679e7a52cdbbab11 100644 (file)
@@ -10,7 +10,6 @@ header-y += intrinsics.h
 header-y += perfmon_default_smpl.h
 header-y += ptrace_offsets.h
 header-y += rse.h
-header-y += setup.h
 header-y += ucontext.h
 
 unifdef-y += perfmon.h
index bd40f4756ce1e7854d38bac8331ab93ca9a457ad..2b78582cbd61710807b3a38c38e81631aab1ca9d 100644 (file)
@@ -70,4 +70,10 @@ static inline __sum16 csum_fold(__wsum csum)
        return (__force __sum16)~sum;
 }
 
+#define _HAVE_ARCH_IPV6_CSUM   1
+struct in6_addr;
+extern unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
+       struct in6_addr *daddr, __u32 len, unsigned short proto,
+       unsigned int csum);
+
 #endif /* _ASM_IA64_CHECKSUM_H */
index 99a8f8e1218c18283fbfe96baf1547d5e3b500d9..ebd5887f4b1a39102e4070b190ee5b55a5500e56 100644 (file)
@@ -50,7 +50,8 @@ dma_set_mask (struct device *dev, u64 mask)
 extern int dma_get_cache_alignment(void);
 
 static inline void
-dma_cache_sync (void *vaddr, size_t size, enum dma_data_direction dir)
+dma_cache_sync (struct device *dev, void *vaddr, size_t size,
+       enum dma_data_direction dir)
 {
        /*
         * IA-64 is cache-coherent, so this is mostly a no-op.  However, we do need to
@@ -59,6 +60,6 @@ dma_cache_sync (void *vaddr, size_t size, enum dma_data_direction dir)
        mb();
 }
 
-#define dma_is_consistent(dma_handle)  (1)     /* all we do is coherent memory... */
+#define dma_is_consistent(d, h)        (1)     /* all we do is coherent memory... */
 
 #endif /* _ASM_IA64_DMA_MAPPING_H */
index 07d77f3a8cbe278bbad15d99e80442b86cbd7d83..8a98a26541391ed17cbcebf97b0b98ef5a1efa31 100644 (file)
@@ -59,7 +59,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
        if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
                return -EFAULT;
 
-       inc_preempt_count();
+       pagefault_disable();
 
        switch (op) {
        case FUTEX_OP_SET:
@@ -83,7 +83,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
                ret = -ENOSYS;
        }
 
-       dec_preempt_count();
+       pagefault_enable();
 
        if (!ret) {
                switch (cmp) {
diff --git a/include/asm-ia64/kexec.h b/include/asm-ia64/kexec.h
new file mode 100644 (file)
index 0000000..01c36b0
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef _ASM_IA64_KEXEC_H
+#define _ASM_IA64_KEXEC_H
+
+
+/* Maximum physical address we can use pages from */
+#define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
+/* Maximum address we can reach in physical address mode */
+#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
+/* Maximum address we can use for the control code buffer */
+#define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
+
+#define KEXEC_CONTROL_CODE_SIZE (8192 + 8192 + 4096)
+
+/* The native architecture */
+#define KEXEC_ARCH KEXEC_ARCH_IA_64
+
+#define MAX_NOTE_BYTES 1024
+
+#define kexec_flush_icache_page(page) do { \
+                unsigned long page_addr = (unsigned long)page_address(page); \
+                flush_icache_range(page_addr, page_addr + PAGE_SIZE); \
+        } while(0)
+
+extern struct kimage *ia64_kimage;
+DECLARE_PER_CPU(u64, ia64_mca_pal_base);
+const extern unsigned int relocate_new_kernel_size;
+extern void relocate_new_kernel(unsigned long, unsigned long,
+               struct ia64_boot_param *, unsigned long);
+static inline void
+crash_setup_regs(struct pt_regs *newregs, struct pt_regs *oldregs)
+{
+}
+extern struct resource efi_memmap_res;
+extern struct resource boot_param_res;
+extern void kdump_smp_send_stop(void);
+extern void kdump_smp_send_init(void);
+extern void kexec_disable_iosapic(void);
+extern void crash_save_this_cpu(void);
+struct rsvd_region;
+extern unsigned long kdump_find_rsvd_region(unsigned long size,
+               struct rsvd_region *rsvd_regions, int n);
+extern void kdump_cpu_freeze(struct unw_frame_info *info, void *arg);
+extern int kdump_status[];
+extern atomic_t kdump_cpu_freezed;
+extern atomic_t kdump_in_progress;
+
+#endif /* _ASM_IA64_KEXEC_H */
index 8f784f8e45b0f2db665dfd04085a39608333511a..a3891eb3f217bf1ba54160f780383a130566e1c8 100644 (file)
@@ -37,6 +37,7 @@ typedef int ia64_mv_pci_legacy_write_t (struct pci_bus *, u16 port, u32 val,
                                        u8 size);
 typedef void ia64_mv_migrate_t(struct task_struct * task);
 typedef void ia64_mv_pci_fixup_bus_t (struct pci_bus *);
+typedef void ia64_mv_kernel_launch_event_t(void);
 
 /* DMA-mapping interface: */
 typedef void ia64_mv_dma_init (void);
@@ -218,6 +219,7 @@ struct ia64_machine_vector {
        ia64_mv_setup_msi_irq_t *setup_msi_irq;
        ia64_mv_teardown_msi_irq_t *teardown_msi_irq;
        ia64_mv_pci_fixup_bus_t *pci_fixup_bus;
+       ia64_mv_kernel_launch_event_t *kernel_launch_event;
 } __attribute__((__aligned__(16))); /* align attrib? see above comment */
 
 #define MACHVEC_INIT(name)                     \
@@ -318,6 +320,9 @@ extern ia64_mv_dma_supported                swiotlb_dma_supported;
 #ifndef platform_tlb_migrate_finish
 # define platform_tlb_migrate_finish   machvec_noop_mm
 #endif
+#ifndef platform_kernel_launch_event
+# define platform_kernel_launch_event  machvec_noop
+#endif
 #ifndef platform_dma_init
 # define platform_dma_init             swiotlb_init
 #endif
index 83325f6db03e112a5b142b03ec2919106161e1a7..eaa2fce0fecde4e836def5815e13b619cb5db9ee 100644 (file)
@@ -67,6 +67,7 @@ extern ia64_mv_dma_sync_sg_for_device sn_dma_sync_sg_for_device;
 extern ia64_mv_dma_mapping_error       sn_dma_mapping_error;
 extern ia64_mv_dma_supported           sn_dma_supported;
 extern ia64_mv_migrate_t               sn_migrate;
+extern ia64_mv_kernel_launch_event_t   sn_kernel_launch_event;
 extern ia64_mv_setup_msi_irq_t         sn_setup_msi_irq;
 extern ia64_mv_teardown_msi_irq_t      sn_teardown_msi_irq;
 extern ia64_mv_pci_fixup_bus_t         sn_pci_fixup_bus;
@@ -121,6 +122,7 @@ extern ia64_mv_pci_fixup_bus_t              sn_pci_fixup_bus;
 #define platform_dma_mapping_error             sn_dma_mapping_error
 #define platform_dma_supported         sn_dma_supported
 #define platform_migrate               sn_migrate
+#define platform_kernel_launch_event    sn_kernel_launch_event
 #ifdef CONFIG_PCI_MSI
 #define platform_setup_msi_irq         sn_setup_msi_irq
 #define platform_teardown_msi_irq      sn_teardown_msi_irq
index c3b1f862e6e75dfda6b1f677d8f358df0cc4fbad..c8df75901083ed67611b18c5153996d0cd27f29c 100644 (file)
  *     - initrd (optional)
  *     - command line string
  *     - kernel code & data
+ *     - crash dumping code reserved region
  *     - Kernel memory map built from EFI memory map
  *
  * More could be added if necessary
  */
-#define IA64_MAX_RSVD_REGIONS 6
+#define IA64_MAX_RSVD_REGIONS 7
 
 struct rsvd_region {
        unsigned long start;    /* virtual address of beginning of element */
index 947cb72b520e4b37bf189510687500eb2b757b84..485759ba9e36e5ce538721f6f5e63b7bb1af51fd 100644 (file)
@@ -101,7 +101,7 @@ do {                                                \
 
 #ifdef CONFIG_VIRTUAL_MEM_MAP
 extern int ia64_pfn_valid (unsigned long pfn);
-#elif defined(CONFIG_FLATMEM)
+#else
 # define ia64_pfn_valid(pfn) 1
 #endif
 
@@ -110,12 +110,11 @@ extern struct page *vmem_map;
 #ifdef CONFIG_DISCONTIGMEM
 # define page_to_pfn(page)     ((unsigned long) (page - vmem_map))
 # define pfn_to_page(pfn)      (vmem_map + (pfn))
+#else
+# include <asm-generic/memory_model.h>
 #endif
-#endif
-
-#if defined(CONFIG_FLATMEM) || defined(CONFIG_SPARSEMEM)
-/* FLATMEM always configures mem_map (mem_map = vmem_map if necessary) */
-#include <asm-generic/memory_model.h>
+#else
+# include <asm-generic/memory_model.h>
 #endif
 
 #ifdef CONFIG_FLATMEM
index 4283ddcc25fbf69a50cfce33483fbbf203023ff9..bc768153f3c95a9cb55020888463f245baaea9d0 100644 (file)
@@ -20,6 +20,8 @@
  * 00/05/24     eranian Updated to latest PAL spec, fix structures bugs, added
  * 00/05/25    eranian Support for stack calls, and static physical calls
  * 00/06/18    eranian Support for stacked physical calls
+ * 06/10/26    rja     Support for Intel Itanium Architecture Software Developer's
+ *                     Manual Rev 2.2 (Jan 2006)
  */
 
 /*
@@ -69,6 +71,8 @@
 #define PAL_PREFETCH_VISIBILITY        41      /* Make Processor Prefetches Visible */
 #define PAL_LOGICAL_TO_PHYSICAL 42     /* returns information on logical to physical processor mapping */
 #define PAL_CACHE_SHARED_INFO  43      /* returns information on caches shared by logical processor */
+#define PAL_GET_HW_POLICY      48      /* Get current hardware resource sharing policy */
+#define PAL_SET_HW_POLICY      49      /* Set current hardware resource sharing policy */
 
 #define PAL_COPY_PAL           256     /* relocate PAL procedures and PAL PMI */
 #define PAL_HALT_INFO          257     /* return the low power capabilities of processor */
 #define PAL_SET_PSTATE         263     /* set the P-state */
 #define PAL_BRAND_INFO         274     /* Processor branding information */
 
+#define PAL_GET_PSTATE_TYPE_LASTSET    0
+#define PAL_GET_PSTATE_TYPE_AVGANDRESET        1
+#define PAL_GET_PSTATE_TYPE_AVGNORESET 2
+#define PAL_GET_PSTATE_TYPE_INSTANT    3
+
 #ifndef __ASSEMBLY__
 
 #include <linux/types.h>
@@ -102,6 +111,7 @@ typedef s64                         pal_status_t;
                                                 * cache without sideeffects
                                                 * and "restrict" was 1
                                                 */
+#define PAL_STATUS_REQUIRES_MEMORY     (-9)    /* Call requires PAL memory buffer */
 
 /* Processor cache level in the heirarchy */
 typedef u64                            pal_cache_level_t;
@@ -456,7 +466,9 @@ typedef struct pal_process_state_info_s {
                                                 * by the processor
                                                 */
 
-                       reserved2       : 11,
+                       se              : 1,    /* Shared error.  MCA in a
+                                                  shared structure */
+                       reserved2       : 10,
                        cc              : 1,    /* Cache check */
                        tc              : 1,    /* TLB check */
                        bc              : 1,    /* Bus check */
@@ -487,10 +499,12 @@ typedef struct pal_cache_check_info_s {
                                                 * error occurred
                                                 */
                        wiv             : 1,    /* Way field valid */
-                       reserved2       : 10,
+                       reserved2       : 1,
+                       dp              : 1,    /* Data poisoned on MBE */
+                       reserved3       : 8,
 
                        index           : 20,   /* Cache line index */
-                       reserved3       : 2,
+                       reserved4       : 2,
 
                        is              : 1,    /* instruction set (1 == ia32) */
                        iv              : 1,    /* instruction set field valid */
@@ -557,7 +571,7 @@ typedef struct pal_bus_check_info_s {
                        type            : 8,    /* Bus xaction type*/
                        sev             : 5,    /* Bus error severity*/
                        hier            : 2,    /* Bus hierarchy level */
-                       reserved1       : 1,
+                       dp              : 1,    /* Data poisoned on MBE */
                        bsi             : 8,    /* Bus error status
                                                 * info
                                                 */
@@ -834,7 +848,9 @@ typedef union pal_bus_features_u {
                u64     pbf_req_bus_parking                     :       1;
                u64     pbf_bus_lock_mask                       :       1;
                u64     pbf_enable_half_xfer_rate               :       1;
-               u64     pbf_reserved2                           :       22;
+               u64     pbf_reserved2                           :       20;
+               u64     pbf_enable_shared_line_replace          :       1;
+               u64     pbf_enable_exclusive_line_replace       :       1;
                u64     pbf_disable_xaction_queueing            :       1;
                u64     pbf_disable_resp_err_check              :       1;
                u64     pbf_disable_berr_check                  :       1;
@@ -1077,6 +1093,24 @@ ia64_pal_freq_ratios (struct pal_freq_ratio *proc_ratio, struct pal_freq_ratio *
        return iprv.status;
 }
 
+/*
+ * Get the current hardware resource sharing policy of the processor
+ */
+static inline s64
+ia64_pal_get_hw_policy (u64 proc_num, u64 *cur_policy, u64 *num_impacted,
+                       u64 *la)
+{
+       struct ia64_pal_retval iprv;
+       PAL_CALL(iprv, PAL_GET_HW_POLICY, proc_num, 0, 0);
+       if (cur_policy)
+               *cur_policy = iprv.v0;
+       if (num_impacted)
+               *num_impacted = iprv.v1;
+       if (la)
+               *la = iprv.v2;
+       return iprv.status;
+}
+
 /* Make the processor enter HALT or one of the implementation dependent low
  * power states where prefetching and execution are suspended and cache and
  * TLB coherency is not maintained.
@@ -1112,10 +1146,10 @@ ia64_pal_halt_info (pal_power_mgmt_info_u_t *power_buf)
 
 /* Get the current P-state information */
 static inline s64
-ia64_pal_get_pstate (u64 *pstate_index)
+ia64_pal_get_pstate (u64 *pstate_index, unsigned long type)
 {
        struct ia64_pal_retval iprv;
-       PAL_CALL_STK(iprv, PAL_GET_PSTATE, 0, 0, 0);
+       PAL_CALL_STK(iprv, PAL_GET_PSTATE, type, 0, 0);
        *pstate_index = iprv.v0;
        return iprv.status;
 }
@@ -1401,6 +1435,17 @@ ia64_pal_rse_info (u64 *num_phys_stacked, pal_hints_u_t *hints)
        return iprv.status;
 }
 
+/*
+ * Set the current hardware resource sharing policy of the processor
+ */
+static inline s64
+ia64_pal_set_hw_policy (u64 policy)
+{
+       struct ia64_pal_retval iprv;
+       PAL_CALL(iprv, PAL_SET_HW_POLICY, policy, 0, 0);
+       return iprv.status;
+}
+
 /* Cause the processor to enter        SHUTDOWN state, where prefetching and execution are
  * suspended, but cause cache and TLB coherency to be maintained.
  * This is usually called in IA-32 mode.
@@ -1524,12 +1569,15 @@ typedef union pal_vm_info_1_u {
        } pal_vm_info_1_s;
 } pal_vm_info_1_u_t;
 
+#define PAL_MAX_PURGES         0xFFFF          /* all ones is means unlimited */
+
 typedef union pal_vm_info_2_u {
        u64                     pvi2_val;
        struct {
                u64             impl_va_msb     : 8,
                                rid_size        : 8,
-                               reserved        : 48;
+                               max_purges      : 16,
+                               reserved        : 32;
        } pal_vm_info_2_s;
 } pal_vm_info_2_u_t;
 
index 9cb68e9b377e2c831f71187dc1314643b83fc933..393e04c42a2c127affc71db782b51214221e0934 100644 (file)
@@ -60,7 +60,7 @@ static inline void *pgtable_quicklist_alloc(void)
 static inline void pgtable_quicklist_free(void *pgtable_entry)
 {
 #ifdef CONFIG_NUMA
-       unsigned long nid = page_to_nid(virt_to_page(pgtable_entry));
+       int nid = page_to_nid(virt_to_page(pgtable_entry));
 
        if (unlikely(nid != numa_node_id())) {
                free_page((unsigned long)pgtable_entry);
index be5d83ad7cb1418a19b86aa16542c3fb48ce94c8..2c4004eb5a68bf68f2ef7ddfc70943bcc7e91219 100644 (file)
@@ -88,6 +88,8 @@
 #define  SN_SAL_INJECT_ERROR                      0x02000067
 #define  SN_SAL_SET_CPU_NUMBER                    0x02000068
 
+#define  SN_SAL_KERNEL_LAUNCH_EVENT               0x02000069
+
 /*
  * Service-specific constants
  */
@@ -1155,4 +1157,11 @@ ia64_sn_set_cpu_number(int cpu)
        SAL_CALL_NOLOCK(rv, SN_SAL_SET_CPU_NUMBER, cpu, 0, 0, 0, 0, 0, 0);
        return rv.status;
 }
+static inline int
+ia64_sn_kernel_launch_event(void)
+{
+       struct ia64_sal_retval rv;
+       SAL_CALL_NOLOCK(rv, SN_SAL_KERNEL_LAUNCH_EVENT, 0, 0, 0, 0, 0, 0, 0);
+       return rv.status;
+}
 #endif /* _ASM_IA64_SN_SN_SAL_H */
index b9e843f7dc421ec1ce0f11f5d442504da5e70fca..4531a511bde58ca49e1f051264051d10fa690d8d 100644 (file)
@@ -26,6 +26,17 @@ struct termios {
        cc_t c_cc[NCCS];                /* control characters */
 };
 
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
 /* c_cc characters */
 #define VINTR 0
 #define VQUIT 1
index 219a0f74eff316e525e464c4c9c75f8f73040846..c82ebe8f250d6fadc84b913a1a48fc9af13bceab 100644 (file)
@@ -32,7 +32,8 @@
 static __inline__ int ide_default_irq(unsigned long base)
 {
        switch (base) {
-#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2)
+#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2) \
+       || defined(CONFIG_PLAT_OPSPUT)
                case 0x1f0: return PLD_IRQ_CFIREQ;
                default:
                        return 0;
index a1f0d1fe9eb81f9969cc385183592a84d620b0b5..52807f8db1660793bfcab02d5c787beff80b8f8b 100644 (file)
 #define M32R_MFT5RLD_PORTL     (0x0C+M32R_MFT5_OFFSET)  /* MFT4 reload */
 #define M32R_MFT5CMPRLD_PORTL  (0x10+M32R_MFT5_OFFSET)  /* MFT4 compare reload */
 
-#if defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_M32104)
+#if (defined(CONFIG_CHIP_M32700) && !defined(CONFIG_PLAT_MAPPI2)) \
+       || defined(CONFIG_CHIP_M32104)
 #define M32R_MFTCR_MFT0MSK  (1UL<<31)  /* b0 */
 #define M32R_MFTCR_MFT1MSK  (1UL<<30)  /* b1 */
 #define M32R_MFTCR_MFT2MSK  (1UL<<29)  /* b2 */
 #define M32R_MFTCR_MFT3EN   (1UL<<20)  /* b11 */
 #define M32R_MFTCR_MFT4EN   (1UL<<19)  /* b12 */
 #define M32R_MFTCR_MFT5EN   (1UL<<18)  /* b13 */
-#else  /* not CONFIG_CHIP_M32700 && not CONFIG_CHIP_M32104 */
+#else
 #define M32R_MFTCR_MFT0MSK  (1UL<<15)  /* b16 */
 #define M32R_MFTCR_MFT1MSK  (1UL<<14)  /* b17 */
 #define M32R_MFTCR_MFT2MSK  (1UL<<13)  /* b18 */
 #define M32R_MFTCR_MFT3EN   (1UL<<4)   /* b27 */
 #define M32R_MFTCR_MFT4EN   (1UL<<3)   /* b28 */
 #define M32R_MFTCR_MFT5EN   (1UL<<2)   /* b29 */
-#endif /* not CONFIG_CHIP_M32700 && not CONFIG_CHIP_M32104 */
+#endif
 
 #define M32R_MFTMOD_CC_MASK    (1UL<<15)  /* b16 */
 #define M32R_MFTMOD_TCCR       (1UL<<13)  /* b18 */
index 2d2a6c97331e11b7ac2eb03407de1cb87ff3909c..632b4ce4269aac846de9b49fcab11aa3925c1af4 100644 (file)
 #define PT_R15         PT_SP
 
 /* processor status and miscellaneous context registers.  */
-#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
 #define PT_ACC0H       15
 #define PT_ACC0L       16
-#define PT_ACC1H       17
-#define PT_ACC1L       18
-#define PT_ACCH                PT_ACC0H
-#define PT_ACCL                PT_ACC0L
-#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
-#define PT_ACCH                15
-#define PT_ACCL                16
-#define PT_DUMMY_ACC1H 17
-#define PT_DUMMY_ACC1L 18
-#else
-#error unknown isa conifiguration
-#endif
+#define PT_ACC1H       17      /* ISA_DSP_LEVEL2 only */
+#define PT_ACC1L       18      /* ISA_DSP_LEVEL2 only */
 #define PT_PSW         19
 #define PT_BPC         20
 #define PT_BBPSW       21
@@ -103,19 +92,10 @@ struct pt_regs {
        long syscall_nr;
 
        /* Saved main processor status and miscellaneous context registers. */
-#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
        unsigned long acc0h;
        unsigned long acc0l;
-       unsigned long acc1h;
-       unsigned long acc1l;
-#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
-       unsigned long acch;
-       unsigned long accl;
-       unsigned long dummy_acc1h;
-       unsigned long dummy_acc1l;
-#else
-#error unknown isa configuration
-#endif
+       unsigned long acc1h;    /* ISA_DSP_LEVEL2 only */
+       unsigned long acc1l;    /* ISA_DSP_LEVEL2 only */
        unsigned long psw;
        unsigned long bpc;              /* saved PC for TRAP syscalls */
        unsigned long bbpsw;
index 52f4fa29abfc7e8854d672beb277dd46bba9f3d1..6a0b32202d4e0ee901b3c93f44dcd87d7761a738 100644 (file)
@@ -1,6 +1,11 @@
 /*
  * This is set up by the setup-routine at boot-time
  */
+
+#define COMMAND_LINE_SIZE       512
+
+#ifdef __KERNEL__
+
 #define PARAM                  ((unsigned char *)empty_zero_page)
 
 #define MOUNT_ROOT_RDONLY      (*(unsigned long *) (PARAM+0x000))
@@ -18,8 +23,6 @@
 
 #define SCREEN_INFO            (*(struct screen_info *) (PARAM+0x200))
 
-#define COMMAND_LINE_SIZE      (512)
-
 #define RAMDISK_IMAGE_START_MASK       (0x07FF)
 #define RAMDISK_PROMPT_FLAG            (0x8000)
 #define RAMDISK_LOAD_FLAG              (0x4000)
@@ -27,3 +30,5 @@
 extern unsigned long memory_start;
 extern unsigned long memory_end;
 
+#endif  /*  __KERNEL__  */
+
index 73025c0c41a1ff94a5ff5ac5e979a566011c7aad..62537dc4dec903cd3f9cfdc1cb08f578df8c24c0 100644 (file)
@@ -23,19 +23,10 @@ struct sigcontext {
        unsigned long sc_r12;
 
        /* Saved main processor status and miscellaneous context registers. */
-#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
        unsigned long sc_acc0h;
        unsigned long sc_acc0l;
-       unsigned long sc_acc1h;
-       unsigned long sc_acc1l;
-#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
-       unsigned long sc_acch;
-       unsigned long sc_accl;
-       unsigned long sc_dummy_acc1h;
-       unsigned long sc_dummy_acc1l;
-#else
-#error unknown isa configuration
-#endif
+       unsigned long sc_acc1h; /* ISA_DSP_LEVEL2 only */
+       unsigned long sc_acc1l; /* ISA_DSP_LEVEL2 only */
        unsigned long sc_psw;
        unsigned long sc_bpc;           /* saved PC for TRAP syscalls */
        unsigned long sc_bbpsw;
index 5ace3702df7579cfe9ea3b25703bd1016f369489..faf2bd0504c15153b84baa49ab3c507bdb738184 100644 (file)
@@ -19,6 +19,17 @@ struct termios {
        cc_t c_cc[NCCS];                /* control characters */
 };
 
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
 /* c_cc characters */
 #define VINTR 0
 #define VQUIT 1
index 95aa34298d8211d85252976da8931d49f9ef5665..5b66bd3c6ed663cd6cb9d9dd4f7cba21eaec66f7 100644 (file)
 #ifdef __KERNEL__
 
 #define NR_syscalls 285
-#include <linux/err.h>
-
-/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
- * <asm-m32r/errno.h>
- */
-
-#include <asm/syscall.h>       /* SYSCALL_* */
-
-#define __syscall_return(type, res) \
-do { \
-       if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
-       /* Avoid using "res" which is declared to be in register r0; \
-          errno might expand to a function call and clobber it.  */ \
-               int __err = -(res); \
-               errno = __err; \
-               res = -1; \
-       } \
-       return (type) (res); \
-} while (0)
-
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-register long __scno __asm__ ("r7") = __NR_##name; \
-register long __res __asm__("r0"); \
-__asm__ __volatile__ (\
-       "trap #" SYSCALL_VECTOR "|| nop"\
-       : "=r" (__res) \
-       : "r" (__scno) \
-       : "memory"); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-register long __scno __asm__ ("r7") = __NR_##name; \
-register long __res __asm__ ("r0") = (long)(arg1); \
-__asm__ __volatile__ (\
-       "trap #" SYSCALL_VECTOR "|| nop"\
-       : "=r" (__res) \
-       : "r" (__scno), "0" (__res) \
-       : "memory"); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-register long __scno __asm__ ("r7") = __NR_##name; \
-register long __arg2 __asm__ ("r1") = (long)(arg2); \
-register long __res __asm__ ("r0") = (long)(arg1); \
-__asm__ __volatile__ (\
-       "trap #" SYSCALL_VECTOR "|| nop"\
-       : "=r" (__res) \
-       : "r" (__scno), "0" (__res), "r" (__arg2) \
-       : "memory"); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-register long __scno __asm__ ("r7") = __NR_##name; \
-register long __arg3 __asm__ ("r2") = (long)(arg3); \
-register long __arg2 __asm__ ("r1") = (long)(arg2); \
-register long __res __asm__ ("r0") = (long)(arg1); \
-__asm__ __volatile__ (\
-       "trap #" SYSCALL_VECTOR "|| nop"\
-       : "=r" (__res) \
-       : "r" (__scno), "0" (__res), "r" (__arg2), \
-               "r" (__arg3) \
-       : "memory"); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name(type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
-{ \
-register long __scno __asm__ ("r7") = __NR_##name; \
-register long __arg4 __asm__ ("r3") = (long)(arg4); \
-register long __arg3 __asm__ ("r2") = (long)(arg3); \
-register long __arg2 __asm__ ("r1") = (long)(arg2); \
-register long __res __asm__ ("r0") = (long)(arg1); \
-__asm__ __volatile__ (\
-       "trap #" SYSCALL_VECTOR "|| nop"\
-       : "=r" (__res) \
-       : "r" (__scno), "0" (__res), "r" (__arg2), \
-               "r" (__arg3), "r" (__arg4) \
-       : "memory"); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-       type5,arg5) \
-type name(type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-register long __scno __asm__ ("r7") = __NR_##name; \
-register long __arg5 __asm__ ("r4") = (long)(arg5); \
-register long __arg4 __asm__ ("r3") = (long)(arg4); \
-register long __arg3 __asm__ ("r2") = (long)(arg3); \
-register long __arg2 __asm__ ("r1") = (long)(arg2); \
-register long __res __asm__ ("r0") = (long)(arg1); \
-__asm__ __volatile__ (\
-       "trap #" SYSCALL_VECTOR "|| nop"\
-       : "=r" (__res) \
-       : "r" (__scno), "0" (__res), "r" (__arg2), \
-               "r" (__arg3), "r" (__arg4), "r" (__arg5) \
-       : "memory"); \
-__syscall_return(type,__res); \
-}
 
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_STAT64
index d90d841d3dfde278269de086af882d87346a9892..00259ed6fc9532487dda91ec8873febfe0d33a59 100644 (file)
@@ -21,7 +21,7 @@ static inline int dma_get_cache_alignment(void)
        return 1 << L1_CACHE_SHIFT;
 }
 
-static inline int dma_is_consistent(dma_addr_t dma_addr)
+static inline int dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
 {
        return 0;
 }
@@ -41,7 +41,7 @@ static inline void dma_free_noncoherent(struct device *dev, size_t size,
 {
        dma_free_coherent(dev, size, addr, handle);
 }
-static inline void dma_cache_sync(void *vaddr, size_t size,
+static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
                                  enum dma_data_direction dir)
 {
        /* we use coherent allocation, so not much to do here. */
index 7facc9a46e74dde0ce6f792cab5fd3189fa1e003..2a8853cd655455b1cedbd639e4e8fcd0b146014f 100644 (file)
 #define MACH_Q40     10
 #define MACH_SUN3X   11
 
+#define COMMAND_LINE_SIZE 256
+
 #ifdef __KERNEL__
 
+#define CL_SIZE COMMAND_LINE_SIZE
+
 #ifndef __ASSEMBLY__
 extern unsigned long m68k_machtype;
 #endif /* !__ASSEMBLY__ */
@@ -355,8 +359,6 @@ extern int m68k_is040or060;
      */
 
 #define NUM_MEMINFO    4
-#define CL_SIZE                256
-#define COMMAND_LINE_SIZE      CL_SIZE
 
 #ifndef __ASSEMBLY__
 struct mem_info {
index f799d95bad5365f44b391572612c6b7d578948c9..e74f384e269ff326841e6ca8a6c857cc4329cdb4 100644 (file)
@@ -4,7 +4,6 @@
 
 #define KERNBASE        0xE000000  /* First address the kernel will eventually be */
 #define LOAD_ADDR       0x4000      /* prom jumps to us here unless this is elf /boot */
-#define BI_START (KERNBASE + 0x3000) /* beginning of the bootinfo records */
 #define FC_CONTROL  3
 #define FC_SUPERD    5
 #define FC_CPU      7
index de91fa071b995f3d1aa5fbac3bcc48cb7177dfac..309d6e6a1374736e203f8c7cf166d8d6ff6693ed 100644 (file)
@@ -16,6 +16,7 @@
 #include <asm/intersil.h>
 #include <asm/oplib.h>
 #include <asm/traps.h>
+#include <asm/irq.h>
 
 #define SUN3_INT_VECS 192
 
index e9eec3eb07182baac5709828a1ce1b312d93a988..a194092240fb9a895483c1265f2782f119b921d9 100644 (file)
@@ -17,6 +17,17 @@ struct termios {
        cc_t c_cc[NCCS];                /* control characters */
 };
 
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
 /* c_cc characters */
 #define VINTR 0
 #define VQUIT 1
index ad4348058c66f18779e61b3f8a607b45cdd78f27..fdbb60e6a0d4310a2b61e75649ea4ca32ed45ac1 100644 (file)
 #ifdef __KERNEL__
 
 #define NR_syscalls            311
-#include <linux/err.h>
-
-/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
-   <asm-m68k/errno.h> */
-
-#define __syscall_return(type, res) \
-do { \
-       if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
-       /* avoid using res which is declared to be in register d0; \
-          errno might expand to a function call and clobber it.  */ \
-               int __err = -(res); \
-               errno = __err; \
-               res = -1; \
-       } \
-       return (type) (res); \
-} while (0)
-
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-__asm__ __volatile__ ("trap  #0" \
-                      : "+d" (__res) ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall1(type,name,atype,a) \
-type name(atype a) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-__asm__ __volatile__ ("trap  #0" \
-                     : "+d" (__res) \
-                     : "d" (__a)  ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall2(type,name,atype,a,btype,b) \
-type name(atype a,btype b) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-__asm__ __volatile__ ("trap  #0" \
-                     : "+d" (__res) \
-                      : "d" (__a), "d" (__b) \
-                    ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
-type name(atype a,btype b,ctype c) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-register long __c __asm__ ("%d3") = (long)(c); \
-__asm__ __volatile__ ("trap  #0" \
-                     : "+d" (__res) \
-                      : "d" (__a), "d" (__b), \
-                       "d" (__c) \
-                    ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
-type name (atype a, btype b, ctype c, dtype d) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-register long __c __asm__ ("%d3") = (long)(c); \
-register long __d __asm__ ("%d4") = (long)(d); \
-__asm__ __volatile__ ("trap  #0" \
-                      : "+d" (__res) \
-                      : "d" (__a), "d" (__b), \
-                       "d" (__c), "d" (__d)  \
-                    ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
-type name (atype a,btype b,ctype c,dtype d,etype e) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-register long __c __asm__ ("%d3") = (long)(c); \
-register long __d __asm__ ("%d4") = (long)(d); \
-register long __e __asm__ ("%d5") = (long)(e); \
-__asm__ __volatile__ ("trap  #0" \
-                     : "+d" (__res) \
-                     : "d" (__a), "d" (__b), \
-                       "d" (__c), "d" (__d), "d" (__e)  \
-                     ); \
-__syscall_return(type,__res); \
-}
 
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
index d2b0fcce41b2d71e935d53c2341a3dbbaadc5479..fb86bb2a6078712d907a2f3705d4147538a503de 100644 (file)
@@ -1,5 +1,10 @@
+#ifdef __KERNEL__
+
 #include <asm-m68k/setup.h>
 
 /* We have a bigger command line buffer. */
 #undef COMMAND_LINE_SIZE
+
+#endif  /*  __KERNEL__  */
+
 #define COMMAND_LINE_SIZE      512
index ebaf03197114d0cd831a85cdddf3a11dec6db3c2..82e03195f325730531775529bdc5d8bbfb50120e 100644 (file)
 #ifdef __KERNEL__
 
 #define NR_syscalls            311
-#include <linux/err.h>
-
-/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
-   <asm-m68k/errno.h> */
-
-#define __syscall_return(type, res) \
-do { \
-       if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
-       /* avoid using res which is declared to be in register d0; \
-          errno might expand to a function call and clobber it.  */ \
-               int __err = -(res); \
-               errno = __err; \
-               res = -1; \
-       } \
-       return (type) (res); \
-} while (0)
-
-#define _syscall0(type, name)                                                  \
-type name(void)                                                                        \
-{                                                                              \
-  long __res;                                                                  \
-  __asm__ __volatile__ ("movel %1, %%d0\n\t"                                   \
-                       "trap   #0\n\t"                                         \
-                       "movel  %%d0, %0"                                       \
-                       : "=g" (__res)                                          \
-                       : "i" (__NR_##name)                                     \
-                       : "cc", "%d0");                                         \
-  if ((unsigned long)(__res) >= (unsigned long)(-125)) {                               \
-    errno = -__res;                                                            \
-    __res = -1;                                                                        \
-  }                                                                            \
-  return (type)__res;                                                          \
-}
-
-#define _syscall1(type, name, atype, a)                                                \
-type name(atype a)                                                             \
-{                                                                              \
-  long __res;                                                                  \
-  __asm__ __volatile__ ("movel %2, %%d1\n\t"                                   \
-                       "movel  %1, %%d0\n\t"                                   \
-                       "trap   #0\n\t"                                         \
-                       "movel  %%d0, %0"                                       \
-                       : "=g" (__res)                                          \
-                       : "i" (__NR_##name),                                    \
-                         "g" ((long)a)                                         \
-                       : "cc", "%d0", "%d1");                                  \
-  if ((unsigned long)(__res) >= (unsigned long)(-125)) {                               \
-    errno = -__res;                                                            \
-    __res = -1;                                                                        \
-  }                                                                            \
-  return (type)__res;                                                          \
-}
-
-#define _syscall2(type, name, atype, a, btype, b)                              \
-type name(atype a, btype b)                                                    \
-{                                                                              \
-  long __res;                                                                  \
-  __asm__ __volatile__ ("movel %3, %%d2\n\t"                                   \
-                       "movel  %2, %%d1\n\t"                                   \
-                       "movel  %1, %%d0\n\t"                                   \
-                       "trap   #0\n\t"                                         \
-                       "movel  %%d0, %0"                                       \
-                       : "=g" (__res)                                          \
-                       : "i" (__NR_##name),                                    \
-                         "a" ((long)a),                                        \
-                         "g" ((long)b)                                         \
-                       : "cc", "%d0", "%d1", "%d2");                           \
-  if ((unsigned long)(__res) >= (unsigned long)(-125)) {                               \
-    errno = -__res;                                                            \
-    __res = -1;                                                                        \
-  }                                                                            \
-  return (type)__res;                                                          \
-}
-
-#define _syscall3(type, name, atype, a, btype, b, ctype, c)                    \
-type name(atype a, btype b, ctype c)                                           \
-{                                                                              \
-  long __res;                                                                  \
-  __asm__ __volatile__ ("movel %4, %%d3\n\t"                                   \
-                       "movel  %3, %%d2\n\t"                                   \
-                       "movel  %2, %%d1\n\t"                                   \
-                       "movel  %1, %%d0\n\t"                                   \
-                       "trap   #0\n\t"                                         \
-                       "movel  %%d0, %0"                                       \
-                       : "=g" (__res)                                          \
-                       : "i" (__NR_##name),                                    \
-                         "a" ((long)a),                                        \
-                         "a" ((long)b),                                        \
-                         "g" ((long)c)                                         \
-                       : "cc", "%d0", "%d1", "%d2", "%d3");                    \
-  if ((unsigned long)(__res) >= (unsigned long)(-125)) {                               \
-    errno = -__res;                                                            \
-    __res = -1;                                                                        \
-  }                                                                            \
-  return (type)__res;                                                          \
-}
-
-#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d)          \
-type name(atype a, btype b, ctype c, dtype d)                                  \
-{                                                                              \
-  long __res;                                                                  \
-  __asm__ __volatile__ ("movel %5, %%d4\n\t"                                   \
-                       "movel  %4, %%d3\n\t"                                   \
-                       "movel  %3, %%d2\n\t"                                   \
-                       "movel  %2, %%d1\n\t"                                   \
-                       "movel  %1, %%d0\n\t"                                   \
-                       "trap   #0\n\t"                                         \
-                       "movel  %%d0, %0"                                       \
-                       : "=g" (__res)                                          \
-                       : "i" (__NR_##name),                                    \
-                         "a" ((long)a),                                        \
-                         "a" ((long)b),                                        \
-                         "a" ((long)c),                                        \
-                         "g" ((long)d)                                         \
-                       : "cc", "%d0", "%d1", "%d2", "%d3",                     \
-                         "%d4");                                               \
-  if ((unsigned long)(__res) >= (unsigned long)(-125)) {                               \
-    errno = -__res;                                                            \
-    __res = -1;                                                                        \
-  }                                                                            \
-  return (type)__res;                                                          \
-}
-
-#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e)        \
-type name(atype a, btype b, ctype c, dtype d, etype e)                         \
-{                                                                              \
-  long __res;                                                                  \
-  __asm__ __volatile__ ("movel %6, %%d5\n\t"                                   \
-                       "movel  %5, %%d4\n\t"                                   \
-                       "movel  %4, %%d3\n\t"                                   \
-                       "movel  %3, %%d2\n\t"                                   \
-                       "movel  %2, %%d1\n\t"                                   \
-                       "movel  %1, %%d0\n\t"                                   \
-                       "trap   #0\n\t"                                         \
-                       "movel  %%d0, %0"                                       \
-                       : "=g" (__res)                                          \
-                       : "i" (__NR_##name),                                    \
-                         "a" ((long)a),                                        \
-                         "a" ((long)b),                                        \
-                         "a" ((long)c),                                        \
-                         "a" ((long)d),                                        \
-                         "g" ((long)e)                                         \
-                       : "cc", "%d0", "%d1", "%d2", "%d3",                     \
-                         "%d4", "%d5");                                        \
-  if ((unsigned long)(__res) >= (unsigned long)(-125)) {                               \
-    errno = -__res;                                                            \
-    __res = -1;                                                                        \
-  }                                                                            \
-  return (type)__res;                                                          \
-}
 
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
index 1e5ccdad3b0213db17810f813b649357a147aa17..8e321f53a38270570056b9d1bc5ae1fec70deaea 100644 (file)
 #define  MACH_PHILIPS_NINO     0       /* Nino */
 #define  MACH_PHILIPS_VELO     1       /* Velo */
 #define  MACH_PHILIPS_JBS      2       /* JBS */
+#define  MACH_PHILIPS_STB810   3       /* STB810 */
 
 /*
  * Valid machtype for group SIBYTE
index 43288634c38a7bbca2793d295f801de22ffaf2ea..236d1a467cc7fb49ae8dd028c8b66c1d2e3cd471 100644 (file)
@@ -63,9 +63,9 @@ dma_get_cache_alignment(void)
        return 128;
 }
 
-extern int dma_is_consistent(dma_addr_t dma_addr);
+extern int dma_is_consistent(struct device *dev, dma_addr_t dma_addr);
 
-extern void dma_cache_sync(void *vaddr, size_t size,
+extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
               enum dma_data_direction direction);
 
 #define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
index 927a216bd530d2f07cc6c5392089b666935f461b..47e5679c235303f5812eb1d4cd39a2140af89016 100644 (file)
@@ -88,7 +88,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
        if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
                return -EFAULT;
 
-       inc_preempt_count();
+       pagefault_disable();
 
        switch (op) {
        case FUTEX_OP_SET:
@@ -115,7 +115,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
                ret = -ENOSYS;
        }
 
-       dec_preempt_count();
+       pagefault_enable();
 
        if (!ret) {
                switch (cmp) {
index c976bfaaba83a1bafec7f40df8c806a845aec442..f8c8182f7f2e642a0326af17534c43d6fcd3fe8e 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/uaccess.h>
 #include <asm/kmap_types.h>
 
 /* undef for production */
@@ -70,11 +71,16 @@ static inline void *kmap(struct page *page)
 
 static inline void *kmap_atomic(struct page *page, enum km_type type)
 {
+       pagefault_disable();
        return page_address(page);
 }
 
-static inline void kunmap_atomic(void *kvaddr, enum km_type type) { }
-#define kmap_atomic_pfn(pfn, idx)      page_address(pfn_to_page(pfn))
+static inline void kunmap_atomic(void *kvaddr, enum km_type type)
+{
+       pagefault_enable();
+}
+
+#define kmap_atomic_pfn(pfn, idx) kmap_atomic(pfn_to_page(pfn), (idx))
 
 #define kmap_atomic_to_page(ptr) virt_to_page(ptr)
 
index 737fa4a6912e4c94316fb8f363dba738b77d77c8..70009a902639170fcf929938228e320635803f74 100644 (file)
@@ -1,8 +1,6 @@
-#ifdef __KERNEL__
 #ifndef _MIPS_SETUP_H
 #define _MIPS_SETUP_H
 
 #define COMMAND_LINE_SIZE      256
 
 #endif /* __SETUP_H */
-#endif /* __KERNEL__ */
index b62ec7c521cc3807793aa552e41fc0a20591c6ba..0bbe07b42a0767b41bfb0cf3ebb069f7905e1611 100644 (file)
@@ -30,6 +30,17 @@ struct termios {
        cc_t c_cc[NCCS];                /* control characters */
 };
 
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
 /* c_cc characters */
 #define VINTR           0              /* Interrupt character [ISIG].  */
 #define VQUIT           1              /* Quit character [ISIG].  */
index ec56aa52f669f2092847290b9fccb8309d6ae35e..696cff39a1d3e38dc7de8e49e77f55ebc172281d 100644 (file)
 
 #ifndef __ASSEMBLY__
 
-/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-       register unsigned long __a3 asm("$7"); \
-       unsigned long __v0; \
-       \
-       __asm__ volatile ( \
-       ".set\tnoreorder\n\t" \
-       "li\t$2, %2\t\t\t# " #name "\n\t" \
-       "syscall\n\t" \
-       "move\t%0, $2\n\t" \
-       ".set\treorder" \
-       : "=&r" (__v0), "=r" (__a3) \
-       : "i" (__NR_##name) \
-       : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
-         "memory"); \
-       \
-       if (__a3 == 0) \
-               return (type) __v0; \
-       errno = __v0; \
-       return (type) -1; \
-}
-
-/*
- * DANGER: This macro isn't usable for the pipe(2) call
- * which has a unusual return convention.
- */
-#define _syscall1(type,name,atype,a) \
-type name(atype a) \
-{ \
-       register unsigned long __a0 asm("$4") = (unsigned long) a; \
-       register unsigned long __a3 asm("$7"); \
-       unsigned long __v0; \
-       \
-       __asm__ volatile ( \
-       ".set\tnoreorder\n\t" \
-       "li\t$2, %3\t\t\t# " #name "\n\t" \
-       "syscall\n\t" \
-       "move\t%0, $2\n\t" \
-       ".set\treorder" \
-       : "=&r" (__v0), "=r" (__a3) \
-       : "r" (__a0), "i" (__NR_##name) \
-       : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
-         "memory"); \
-       \
-       if (__a3 == 0) \
-               return (type) __v0; \
-       errno = __v0; \
-       return (type) -1; \
-}
-
-#define _syscall2(type,name,atype,a,btype,b) \
-type name(atype a, btype b) \
-{ \
-       register unsigned long __a0 asm("$4") = (unsigned long) a; \
-       register unsigned long __a1 asm("$5") = (unsigned long) b; \
-       register unsigned long __a3 asm("$7"); \
-       unsigned long __v0; \
-       \
-       __asm__ volatile ( \
-       ".set\tnoreorder\n\t" \
-       "li\t$2, %4\t\t\t# " #name "\n\t" \
-       "syscall\n\t" \
-       "move\t%0, $2\n\t" \
-       ".set\treorder" \
-       : "=&r" (__v0), "=r" (__a3) \
-       : "r" (__a0), "r" (__a1), "i" (__NR_##name) \
-       : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
-         "memory"); \
-       \
-       if (__a3 == 0) \
-               return (type) __v0; \
-       errno = __v0; \
-       return (type) -1; \
-}
-
-#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
-type name(atype a, btype b, ctype c) \
-{ \
-       register unsigned long __a0 asm("$4") = (unsigned long) a; \
-       register unsigned long __a1 asm("$5") = (unsigned long) b; \
-       register unsigned long __a2 asm("$6") = (unsigned long) c; \
-       register unsigned long __a3 asm("$7"); \
-       unsigned long __v0; \
-       \
-       __asm__ volatile ( \
-       ".set\tnoreorder\n\t" \
-       "li\t$2, %5\t\t\t# " #name "\n\t" \
-       "syscall\n\t" \
-       "move\t%0, $2\n\t" \
-       ".set\treorder" \
-       : "=&r" (__v0), "=r" (__a3) \
-       : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name) \
-       : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
-         "memory"); \
-       \
-       if (__a3 == 0) \
-               return (type) __v0; \
-       errno = __v0; \
-       return (type) -1; \
-}
-
-#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
-type name(atype a, btype b, ctype c, dtype d) \
-{ \
-       register unsigned long __a0 asm("$4") = (unsigned long) a; \
-       register unsigned long __a1 asm("$5") = (unsigned long) b; \
-       register unsigned long __a2 asm("$6") = (unsigned long) c; \
-       register unsigned long __a3 asm("$7") = (unsigned long) d; \
-       unsigned long __v0; \
-       \
-       __asm__ volatile ( \
-       ".set\tnoreorder\n\t" \
-       "li\t$2, %5\t\t\t# " #name "\n\t" \
-       "syscall\n\t" \
-       "move\t%0, $2\n\t" \
-       ".set\treorder" \
-       : "=&r" (__v0), "+r" (__a3) \
-       : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name) \
-       : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
-         "memory"); \
-       \
-       if (__a3 == 0) \
-               return (type) __v0; \
-       errno = __v0; \
-       return (type) -1; \
-}
-
-#if (_MIPS_SIM == _MIPS_SIM_ABI32)
-
-/*
- * Using those means your brain needs more than an oil change ;-)
- */
-
-#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
-type name(atype a, btype b, ctype c, dtype d, etype e) \
-{ \
-       register unsigned long __a0 asm("$4") = (unsigned long) a; \
-       register unsigned long __a1 asm("$5") = (unsigned long) b; \
-       register unsigned long __a2 asm("$6") = (unsigned long) c; \
-       register unsigned long __a3 asm("$7") = (unsigned long) d; \
-       unsigned long __v0; \
-       \
-       __asm__ volatile ( \
-       ".set\tnoreorder\n\t" \
-       "lw\t$2, %6\n\t" \
-       "subu\t$29, 32\n\t" \
-       "sw\t$2, 16($29)\n\t" \
-       "li\t$2, %5\t\t\t# " #name "\n\t" \
-       "syscall\n\t" \
-       "move\t%0, $2\n\t" \
-       "addiu\t$29, 32\n\t" \
-       ".set\treorder" \
-       : "=&r" (__v0), "+r" (__a3) \
-       : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name), \
-         "m" ((unsigned long)e) \
-       : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
-         "memory"); \
-       \
-       if (__a3 == 0) \
-               return (type) __v0; \
-       errno = __v0; \
-       return (type) -1; \
-}
-
-#define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \
-type name(atype a, btype b, ctype c, dtype d, etype e, ftype f) \
-{ \
-       register unsigned long __a0 asm("$4") = (unsigned long) a; \
-       register unsigned long __a1 asm("$5") = (unsigned long) b; \
-       register unsigned long __a2 asm("$6") = (unsigned long) c; \
-       register unsigned long __a3 asm("$7") = (unsigned long) d; \
-       unsigned long __v0; \
-       \
-       __asm__ volatile ( \
-       ".set\tnoreorder\n\t" \
-       "lw\t$2, %6\n\t" \
-       "lw\t$8, %7\n\t" \
-       "subu\t$29, 32\n\t" \
-       "sw\t$2, 16($29)\n\t" \
-       "sw\t$8, 20($29)\n\t" \
-       "li\t$2, %5\t\t\t# " #name "\n\t" \
-       "syscall\n\t" \
-       "move\t%0, $2\n\t" \
-       "addiu\t$29, 32\n\t" \
-       ".set\treorder" \
-       : "=&r" (__v0), "+r" (__a3) \
-       : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name), \
-         "m" ((unsigned long)e), "m" ((unsigned long)f) \
-       : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
-         "memory"); \
-       \
-       if (__a3 == 0) \
-               return (type) __v0; \
-       errno = __v0; \
-       return (type) -1; \
-}
-
-#endif /* (_MIPS_SIM == _MIPS_SIM_ABI32) */
-
-#if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
-
-#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
-type name (atype a,btype b,ctype c,dtype d,etype e) \
-{ \
-       register unsigned long __a0 asm("$4") = (unsigned long) a; \
-       register unsigned long __a1 asm("$5") = (unsigned long) b; \
-       register unsigned long __a2 asm("$6") = (unsigned long) c; \
-       register unsigned long __a3 asm("$7") = (unsigned long) d; \
-       register unsigned long __a4 asm("$8") = (unsigned long) e; \
-       unsigned long __v0; \
-       \
-       __asm__ volatile ( \
-       ".set\tnoreorder\n\t" \
-       "li\t$2, %6\t\t\t# " #name "\n\t" \
-       "syscall\n\t" \
-       "move\t%0, $2\n\t" \
-       ".set\treorder" \
-       : "=&r" (__v0), "+r" (__a3) \
-       : "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), "i" (__NR_##name) \
-       : "$2", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
-         "memory"); \
-       \
-       if (__a3 == 0) \
-               return (type) __v0; \
-       errno = __v0; \
-       return (type) -1; \
-}
-
-#define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \
-type name (atype a,btype b,ctype c,dtype d,etype e,ftype f) \
-{ \
-       register unsigned long __a0 asm("$4") = (unsigned long) a; \
-       register unsigned long __a1 asm("$5") = (unsigned long) b; \
-       register unsigned long __a2 asm("$6") = (unsigned long) c; \
-       register unsigned long __a3 asm("$7") = (unsigned long) d; \
-       register unsigned long __a4 asm("$8") = (unsigned long) e; \
-       register unsigned long __a5 asm("$9") = (unsigned long) f; \
-       unsigned long __v0; \
-       \
-       __asm__ volatile ( \
-       ".set\tnoreorder\n\t" \
-       "li\t$2, %7\t\t\t# " #name "\n\t" \
-       "syscall\n\t" \
-       "move\t%0, $2\n\t" \
-       ".set\treorder" \
-       : "=&r" (__v0), "+r" (__a3) \
-       : "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), "r" (__a5), \
-         "i" (__NR_##name) \
-       : "$2", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
-         "memory"); \
-       \
-       if (__a3 == 0) \
-               return (type) __v0; \
-       errno = __v0; \
-       return (type) -1; \
-}
-
-#endif /* (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64) */
-
-
 #define __ARCH_OMIT_COMPAT_SYS_GETDENTS64
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
index 3ac146c019c9eab7d3fda08c72d9e3bd98252b13..13a3502eef44691e02f44b17b5f19132b933f2bb 100644 (file)
@@ -76,7 +76,7 @@
 /*
  * But the RM200C seems to have been shipped only with V2.0 R4600s
  */
-#ifdef CONFIG_SNI_RM200_PCI
+#ifdef CONFIG_SNI_RM
 
 #define R4600_V2_HIT_CACHEOP_WAR       1
 
index 1e387e1dad3044a99a718c7ca5b86142b4a0b844..66f0b408c66907cd90b42ee8861507760ac5b67d 100644 (file)
@@ -191,13 +191,13 @@ dma_get_cache_alignment(void)
 }
 
 static inline int
-dma_is_consistent(dma_addr_t dma_addr)
+dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
 {
        return (hppa_dma_ops->dma_sync_single_for_cpu == NULL);
 }
 
 static inline void
-dma_cache_sync(void *vaddr, size_t size,
+dma_cache_sync(struct device *dev, void *vaddr, size_t size,
               enum dma_data_direction direction)
 {
        if(hppa_dma_ops->dma_sync_single_for_cpu)
index d84bbb283fd17c7a8e9fb92d4a30a660efe86263..dbee6e60aa8139e66897ba65ba4ac9155bf00dab 100644 (file)
@@ -21,7 +21,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
        if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
                return -EFAULT;
 
-       inc_preempt_count();
+       pagefault_disable();
 
        switch (op) {
        case FUTEX_OP_SET:
@@ -33,7 +33,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
                ret = -ENOSYS;
        }
 
-       dec_preempt_count();
+       pagefault_enable();
 
        if (!ret) {
                switch (cmp) {
index 372b634892c9eadefba5d30ee4fbe644598c72b6..a46e299a93912ae61393b8e9a0083e55c370b7df 100644 (file)
@@ -17,6 +17,17 @@ struct termios {
        cc_t c_cc[NCCS];                /* control characters */
 };
 
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
 /* c_cc characters */
 #define VINTR 0
 #define VQUIT 1
index c341063d08049b0dfbf4050617c013c46daff0ab..0288144ea024aac5882d92bc47d24af01ee6b706 100644 (file)
@@ -190,7 +190,8 @@ static __inline__ void set_bits(unsigned long mask, unsigned long *addr)
  * Return the zero-based bit position (LE, not IBM bit numbering) of
  * the most significant 1-bit in a double word.
  */
-static __inline__ int __ilog2(unsigned long x)
+static __inline__ __attribute__((const))
+int __ilog2(unsigned long x)
 {
        int lz;
 
@@ -198,6 +199,24 @@ static __inline__ int __ilog2(unsigned long x)
        return BITS_PER_LONG - 1 - lz;
 }
 
+static inline __attribute__((const))
+int __ilog2_u32(u32 n)
+{
+       int bit;
+       asm ("cntlzw %0,%1" : "=r" (bit) : "r" (n));
+       return 31 - bit;
+}
+
+#ifdef __powerpc64__
+static inline __attribute__((const))
+int __ilog2_u64(u32 n)
+{
+       int bit;
+       asm ("cntlzd %0,%1" : "=r" (bit) : "r" (n));
+       return 63 - bit;
+}
+#endif
+
 /*
  * Determines the bit position of the least significant 0 bit in the
  * specified double word. The returned bit position will be
index 7e38b5fddada918a8b7decdafa9c87139e5d4aff..7c7de87bd8ae55391e703a5a2a76fa0866e3238b 100644 (file)
@@ -342,9 +342,9 @@ static inline int dma_mapping_error(dma_addr_t dma_addr)
 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
 #ifdef CONFIG_NOT_COHERENT_CACHE
-#define dma_is_consistent(d)   (0)
+#define dma_is_consistent(d, h)        (0)
 #else
-#define dma_is_consistent(d)   (1)
+#define dma_is_consistent(d, h)        (1)
 #endif
 
 static inline int dma_get_cache_alignment(void)
@@ -378,7 +378,7 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
        dma_sync_single_for_device(dev, dma_handle, offset + size, direction);
 }
 
-static inline void dma_cache_sync(void *vaddr, size_t size,
+static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
                enum dma_data_direction direction)
 {
        BUG_ON(direction == DMA_NONE);
index b5436642a109085e00edb4bf06710c4cbd2777bb..d36426c01b6b95efe784c7d567b5f58a2212ecbf 100644 (file)
@@ -124,12 +124,10 @@ typedef elf_greg_t32 elf_gregset_t32[ELF_NGREG];
 # define ELF_DATA      ELFDATA2MSB
   typedef elf_greg_t64 elf_greg_t;
   typedef elf_gregset_t64 elf_gregset_t;
-# define elf_addr_t unsigned long
 #else
   /* Assumption: ELF_ARCH == EM_PPC and ELF_CLASS == ELFCLASS32 */
   typedef elf_greg_t32 elf_greg_t;
   typedef elf_gregset_t32 elf_gregset_t;
-# define elf_addr_t __u32
 #endif /* ELF_ARCH */
 
 /* Floating point registers */
index 936422e54891f0cab44229639f8321e9d47a270e..3f3673fd3ff34abef169c139c71302084b2cc874 100644 (file)
@@ -43,7 +43,7 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
        if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
                return -EFAULT;
 
-       inc_preempt_count();
+       pagefault_disable();
 
        switch (op) {
        case FUTEX_OP_SET:
@@ -65,7 +65,7 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
                ret = -ENOSYS;
        }
 
-       dec_preempt_count();
+       pagefault_enable();
 
        if (!ret) {
                switch (cmp) {
index 2677bad70f401c92236170f1fe27a1c3f4ceee51..07f6d3cf5e5aac4338dc44ce3be37c1660ba2680 100644 (file)
@@ -26,15 +26,7 @@ extern void clear_pages(void *page, int order);
 static inline void clear_page(void *page) { clear_pages(page, 0); }
 extern void copy_page(void *to, void *from);
 
-/* Pure 2^n version of get_order */
-extern __inline__ int get_order(unsigned long size)
-{
-       int lz;
-
-       size = (size-1) >> PAGE_SHIFT;
-       asm ("cntlzw %0,%1" : "=r" (lz) : "r" (size));
-       return 32 - lz;
-}
+#include <asm-generic/page.h>
 
 #endif /* __ASSEMBLY__ */
 
index ae63db7b3e7d724af37878901a079a97167ab68c..b0830db68f8af1a6ad87b6dd6aa87413aa4d0a90 100644 (file)
@@ -11,7 +11,7 @@
 #include <linux/cpumask.h>
 #include <linux/percpu.h>
 
-extern kmem_cache_t *pgtable_cache[];
+extern struct kmem_cache *pgtable_cache[];
 
 #ifdef CONFIG_PPC_64K_PAGES
 #define PTE_CACHE_NUM  0
index 3d9740aae018d76b877ad935673568da1663bb81..817fac0a0714a8705d6b6d8ce1bd85ef85523822 100644 (file)
@@ -1,9 +1,6 @@
 #ifndef _ASM_POWERPC_SETUP_H
 #define _ASM_POWERPC_SETUP_H
 
-#ifdef __KERNEL__
-
 #define COMMAND_LINE_SIZE      512
 
-#endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_SETUP_H */
index 6d533b07aaf52daa3e1911df34fffcc6bf788d4d..5e79198f7d18d2ad6223bc0f6aeea191ee6190ea 100644 (file)
@@ -30,6 +30,19 @@ struct termios {
        speed_t c_ospeed;               /* output speed */
 };
 
+/* For PowerPC the termios and ktermios are the same */
+
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_cc[NCCS];                /* control characters */
+       cc_t c_line;                    /* line discipline (== c_cc[19]) */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
 /* c_cc characters */
 #define VINTR           0
 #define VQUIT           1
index 04b6c17cc59b84acfacf4fcfd4100f014ceeb470..0ae954e3d2584e86a95ae717bdc8956e049b3d46 100644 (file)
 
 #ifndef __ASSEMBLY__
 
-/* On powerpc a system call basically clobbers the same registers like a
- * function call, with the exception of LR (which is needed for the
- * "sc; bnslr" sequence) and CR (where only CR0.SO is clobbered to signal
- * an error return status).
- */
-
-#define __syscall_nr(nr, type, name, args...)                          \
-       unsigned long __sc_ret, __sc_err;                               \
-       {                                                               \
-               register unsigned long __sc_0  __asm__ ("r0");          \
-               register unsigned long __sc_3  __asm__ ("r3");          \
-               register unsigned long __sc_4  __asm__ ("r4");          \
-               register unsigned long __sc_5  __asm__ ("r5");          \
-               register unsigned long __sc_6  __asm__ ("r6");          \
-               register unsigned long __sc_7  __asm__ ("r7");          \
-               register unsigned long __sc_8  __asm__ ("r8");          \
-                                                                       \
-               __sc_loadargs_##nr(name, args);                         \
-               __asm__ __volatile__                                    \
-                       ("sc           \n\t"                            \
-                        "mfcr %0      "                                \
-                       : "=&r" (__sc_0),                               \
-                         "=&r" (__sc_3),  "=&r" (__sc_4),              \
-                         "=&r" (__sc_5),  "=&r" (__sc_6),              \
-                         "=&r" (__sc_7),  "=&r" (__sc_8)               \
-                       : __sc_asm_input_##nr                           \
-                       : "cr0", "ctr", "memory",                       \
-                         "r9", "r10","r11", "r12");                    \
-               __sc_ret = __sc_3;                                      \
-               __sc_err = __sc_0;                                      \
-       }                                                               \
-       if (__sc_err & 0x10000000)                                      \
-       {                                                               \
-               errno = __sc_ret;                                       \
-               __sc_ret = -1;                                          \
-       }                                                               \
-       return (type) __sc_ret
-
-#define __sc_loadargs_0(name, dummy...)                                        \
-       __sc_0 = __NR_##name
-#define __sc_loadargs_1(name, arg1)                                    \
-       __sc_loadargs_0(name);                                          \
-       __sc_3 = (unsigned long) (arg1)
-#define __sc_loadargs_2(name, arg1, arg2)                              \
-       __sc_loadargs_1(name, arg1);                                    \
-       __sc_4 = (unsigned long) (arg2)
-#define __sc_loadargs_3(name, arg1, arg2, arg3)                                \
-       __sc_loadargs_2(name, arg1, arg2);                              \
-       __sc_5 = (unsigned long) (arg3)
-#define __sc_loadargs_4(name, arg1, arg2, arg3, arg4)                  \
-       __sc_loadargs_3(name, arg1, arg2, arg3);                        \
-       __sc_6 = (unsigned long) (arg4)
-#define __sc_loadargs_5(name, arg1, arg2, arg3, arg4, arg5)            \
-       __sc_loadargs_4(name, arg1, arg2, arg3, arg4);                  \
-       __sc_7 = (unsigned long) (arg5)
-#define __sc_loadargs_6(name, arg1, arg2, arg3, arg4, arg5, arg6)      \
-       __sc_loadargs_5(name, arg1, arg2, arg3, arg4, arg5);            \
-       __sc_8 = (unsigned long) (arg6)
-
-#define __sc_asm_input_0 "0" (__sc_0)
-#define __sc_asm_input_1 __sc_asm_input_0, "1" (__sc_3)
-#define __sc_asm_input_2 __sc_asm_input_1, "2" (__sc_4)
-#define __sc_asm_input_3 __sc_asm_input_2, "3" (__sc_5)
-#define __sc_asm_input_4 __sc_asm_input_3, "4" (__sc_6)
-#define __sc_asm_input_5 __sc_asm_input_4, "5" (__sc_7)
-#define __sc_asm_input_6 __sc_asm_input_5, "6" (__sc_8)
-
-#define _syscall0(type,name)                                           \
-type name(void)                                                                \
-{                                                                      \
-       __syscall_nr(0, type, name);                                    \
-}
-
-#define _syscall1(type,name,type1,arg1)                                        \
-type name(type1 arg1)                                                  \
-{                                                                      \
-       __syscall_nr(1, type, name, arg1);                              \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2)                     \
-type name(type1 arg1, type2 arg2)                                      \
-{                                                                      \
-       __syscall_nr(2, type, name, arg1, arg2);                        \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3)          \
-type name(type1 arg1, type2 arg2, type3 arg3)                          \
-{                                                                      \
-       __syscall_nr(3, type, name, arg1, arg2, arg3);                  \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4)              \
-{                                                                      \
-       __syscall_nr(4, type, name, arg1, arg2, arg3, arg4);            \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5)  \
-{                                                                      \
-       __syscall_nr(5, type, name, arg1, arg2, arg3, arg4, arg5);      \
-}
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
-{                                                                      \
-       __syscall_nr(6, type, name, arg1, arg2, arg3, arg4, arg5, arg6); \
-}
-
-
 #include <linux/types.h>
 #include <linux/compiler.h>
 #include <linux/linkage.h>
index 1d2c4ef81c2233673fa64e8569e78b08ed923121..f7b21ee302b4f1b7fcd1e923fa14c3da0e708f6e 100644 (file)
@@ -79,7 +79,7 @@ static inline void *kmap_atomic(struct page *page, enum km_type type)
        unsigned long vaddr;
 
        /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
-       inc_preempt_count();
+       pagefault_disable();
        if (!PageHighMem(page))
                return page_address(page);
 
@@ -101,8 +101,7 @@ static inline void kunmap_atomic(void *kvaddr, enum km_type type)
        unsigned int idx = type + KM_TYPE_NR*smp_processor_id();
 
        if (vaddr < KMAP_FIX_BEGIN) { // FIXME
-               dec_preempt_count();
-               preempt_check_resched();
+               pagefault_enable();
                return;
        }
 
@@ -115,8 +114,7 @@ static inline void kunmap_atomic(void *kvaddr, enum km_type type)
        pte_clear(&init_mm, vaddr, kmap_pte+idx);
        flush_tlb_page(NULL, vaddr);
 #endif
-       dec_preempt_count();
-       preempt_check_resched();
+       pagefault_enable();
 }
 
 static inline struct page *kmap_atomic_to_page(void *ptr)
index c042f9578081a4ece5e06afb1b996bd558ed3416..604f68fa6f56d0c3974a46aa47ad34d4bccc1f2e 100644 (file)
@@ -69,11 +69,13 @@ typedef struct dasd_information2_t {
  * 0x01: readonly (ro)
  * 0x02: use diag discipline (diag)
  * 0x04: set the device initially online (internal use only)
+ * 0x08: enable ERP related logging
  */
 #define DASD_FEATURE_DEFAULT        0x00
 #define DASD_FEATURE_READONLY       0x01
 #define DASD_FEATURE_USEDIAG        0x02
 #define DASD_FEATURE_INITIAL_ONLINE  0x04
+#define DASD_FEATURE_ERPLOG         0x08
 
 #define DASD_PARTN_BITS 2
 
index 363ea761d5eebe3371d469f4804ec2e9192bb145..05ea6f172786524b31a189f5dc29303ddb3edf70 100644 (file)
@@ -127,6 +127,26 @@ page_get_storage_key(unsigned long addr)
        return skey;
 }
 
+extern unsigned long max_pfn;
+
+static inline int pfn_valid(unsigned long pfn)
+{
+       unsigned long dummy;
+       int ccode;
+
+       if (pfn >= max_pfn)
+               return 0;
+
+       asm volatile(
+               "       lra     %0,0(%2)\n"
+               "       ipm     %1\n"
+               "       srl     %1,28\n"
+               : "=d" (dummy), "=d" (ccode)
+               : "a" (pfn << PAGE_SHIFT)
+               : "cc");
+       return !ccode;
+}
+
 #endif /* !__ASSEMBLY__ */
 
 /* to align the pointer to the (next) page boundary */
@@ -138,8 +158,6 @@ page_get_storage_key(unsigned long addr)
 #define __va(x)                 (void *)(unsigned long)(x)
 #define virt_to_page(kaddr)    pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
 #define page_to_phys(page)     (page_to_pfn(page) << PAGE_SHIFT)
-
-#define pfn_valid(pfn)         ((pfn) < max_mapnr)
 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
 
 #define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
index 28619de5ecae21a63709cd8993733cc1f216aa9a..0707a7e2fc16dacb2fadc435dac8d50b2985a40a 100644 (file)
@@ -25,8 +25,11 @@ extern void diag10(unsigned long addr);
  * Page allocation orders.
  */
 #ifndef __s390x__
+# define PTE_ALLOC_ORDER       0
+# define PMD_ALLOC_ORDER       0
 # define PGD_ALLOC_ORDER       1
 #else /* __s390x__ */
+# define PTE_ALLOC_ORDER       0
 # define PMD_ALLOC_ORDER       2
 # define PGD_ALLOC_ORDER       2
 #endif /* __s390x__ */
index 2d968a69ed1f3753dc507d72e1352c5c40e565bf..ae61aca5d483e25a5242a18ca69718de142c7d9c 100644 (file)
@@ -107,23 +107,25 @@ extern char empty_zero_page[PAGE_SIZE];
  * The vmalloc() routines leaves a hole of 4kB between each vmalloced
  * area for the same reason. ;)
  */
+extern unsigned long vmalloc_end;
 #define VMALLOC_OFFSET  (8*1024*1024)
 #define VMALLOC_START   (((unsigned long) high_memory + VMALLOC_OFFSET) \
                         & ~(VMALLOC_OFFSET-1))
+#define VMALLOC_END    vmalloc_end
 
 /*
  * We need some free virtual space to be able to do vmalloc.
  * VMALLOC_MIN_SIZE defines the minimum size of the vmalloc
  * area. On a machine with 2GB memory we make sure that we
  * have at least 128MB free space for vmalloc. On a machine
- * with 4TB we make sure we have at least 1GB.
+ * with 4TB we make sure we have at least 128GB.
  */
 #ifndef __s390x__
 #define VMALLOC_MIN_SIZE       0x8000000UL
-#define VMALLOC_END            0x80000000UL
+#define VMALLOC_END_INIT       0x80000000UL
 #else /* __s390x__ */
-#define VMALLOC_MIN_SIZE       0x40000000UL
-#define VMALLOC_END            0x40000000000UL
+#define VMALLOC_MIN_SIZE       0x2000000000UL
+#define VMALLOC_END_INIT       0x40000000000UL
 #endif /* __s390x__ */
 
 /*
@@ -815,11 +817,17 @@ static inline pte_t mk_swap_pte(unsigned long type, unsigned long offset)
 
 #define kern_addr_valid(addr)   (1)
 
+extern int add_shared_memory(unsigned long start, unsigned long size);
+extern int remove_shared_memory(unsigned long start, unsigned long size);
+
 /*
  * No page table caches to initialise
  */
 #define pgtable_cache_init()   do { } while (0)
 
+#define __HAVE_ARCH_MEMMAP_INIT
+extern void memmap_init(unsigned long, int, unsigned long, unsigned long);
+
 #define __HAVE_ARCH_PTEP_ESTABLISH
 #define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
index 7664bacdd832f0ce1eacbb20cc406ba946f9bb49..9574fe80a04667d89c951adfd8c226084f0e242f 100644 (file)
@@ -8,12 +8,13 @@
 #ifndef _ASM_S390_SETUP_H
 #define _ASM_S390_SETUP_H
 
+#define COMMAND_LINE_SIZE      896
+
 #ifdef __KERNEL__
 
 #include <asm/types.h>
 
 #define PARMAREA               0x10400
-#define COMMAND_LINE_SIZE      896
 #define MEMORY_CHUNKS          16      /* max 0x7fff */
 #define IPL_PARMBLOCK_ORIGIN   0x2000
 
index eb3f8bfabf6150a2f8516248073407802494a4c8..585c78a6e4070b9ff63413271646120f28f31178 100644 (file)
@@ -25,6 +25,17 @@ struct termios {
        cc_t c_cc[NCCS];                /* control characters */
 };
 
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
 /* c_cc characters */
 #define VINTR 0
 #define VQUIT 1
index 71d3c21b84f0a4169202680053c3f51cb028ec74..fb6fef97d739c55e5ff32bf1eca477c4697a35e8 100644 (file)
 
 #ifdef __KERNEL__
 
-#include <linux/err.h>
-
-#define __syscall_return(type, res)                         \
-do {                                                        \
-       if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
-               errno = -(res);                              \
-               res = -1;                                    \
-       }                                                    \
-       return (type) (res);                                 \
-} while (0)
-
-#define _svc_clobber "1", "cc", "memory"
-
-#define _syscall0(type,name)                                   \
-type name(void) {                                              \
-       register long __svcres asm("2");                        \
-       long __res;                                             \
-       asm volatile(                                           \
-               "       .if     %1 < 256\n"                     \
-               "       svc     %b1\n"                          \
-               "       .else\n"                                \
-               "       la      %%r1,%1\n"                      \
-               "       svc     0\n"                            \
-               "       .endif"                                 \
-               : "=d" (__svcres)                               \
-               : "i" (__NR_##name)                             \
-               : _svc_clobber);                                \
-       __res = __svcres;                                       \
-       __syscall_return(type,__res);                           \
-}
-
-#define _syscall1(type,name,type1,arg1)                                \
-type name(type1 arg1) {                                                \
-       register type1 __arg1 asm("2") = arg1;                  \
-       register long __svcres asm("2");                        \
-       long __res;                                             \
-       asm volatile(                                           \
-               "       .if     %1 < 256\n"                     \
-               "       svc     %b1\n"                          \
-               "       .else\n"                                \
-               "       la      %%r1,%1\n"                      \
-               "       svc     0\n"                            \
-               "       .endif"                                 \
-               : "=d" (__svcres)                               \
-               : "i" (__NR_##name),                            \
-                 "0" (__arg1)                                  \
-               : _svc_clobber);                                \
-       __res = __svcres;                                       \
-       __syscall_return(type,__res);                           \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2)             \
-type name(type1 arg1, type2 arg2) {                            \
-       register type1 __arg1 asm("2") = arg1;                  \
-       register type2 __arg2 asm("3") = arg2;                  \
-       register long __svcres asm("2");                        \
-       long __res;                                             \
-       asm volatile(                                           \
-               "       .if     %1 < 256\n"                     \
-               "       svc     %b1\n"                          \
-               "       .else\n"                                \
-               "       la      %%r1,%1\n"                      \
-               "       svc     0\n"                            \
-               "       .endif"                                 \
-               : "=d" (__svcres)                               \
-               : "i" (__NR_##name),                            \
-                 "0" (__arg1),                                 \
-                 "d" (__arg2)                                  \
-               : _svc_clobber );                               \
-       __res = __svcres;                                       \
-       __syscall_return(type,__res);                           \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3)  \
-type name(type1 arg1, type2 arg2, type3 arg3) {                        \
-       register type1 __arg1 asm("2") = arg1;                  \
-       register type2 __arg2 asm("3") = arg2;                  \
-       register type3 __arg3 asm("4") = arg3;                  \
-       register long __svcres asm("2");                        \
-       long __res;                                             \
-       asm volatile(                                           \
-               "       .if     %1 < 256\n"                     \
-               "       svc     %b1\n"                          \
-               "       .else\n"                                \
-               "       la      %%r1,%1\n"                      \
-               "       svc     0\n"                            \
-               "       .endif"                                 \
-               : "=d" (__svcres)                               \
-               : "i" (__NR_##name),                            \
-                 "0" (__arg1),                                 \
-                 "d" (__arg2),                                 \
-                 "d" (__arg3)                                  \
-               : _svc_clobber);                                \
-       __res = __svcres;                                       \
-       __syscall_return(type,__res);                           \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,  \
-                 type4,name4)                                  \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) {    \
-       register type1 __arg1 asm("2") = arg1;                  \
-       register type2 __arg2 asm("3") = arg2;                  \
-       register type3 __arg3 asm("4") = arg3;                  \
-       register type4 __arg4 asm("5") = arg4;                  \
-       register long __svcres asm("2");                        \
-       long __res;                                             \
-       asm volatile(                                           \
-               "       .if     %1 < 256\n"                     \
-               "       svc     %b1\n"                          \
-               "       .else\n"                                \
-               "       la      %%r1,%1\n"                      \
-               "       svc     0\n"                            \
-               "       .endif"                                 \
-               : "=d" (__svcres)                               \
-               : "i" (__NR_##name),                            \
-                 "0" (__arg1),                                 \
-                 "d" (__arg2),                                 \
-                 "d" (__arg3),                                 \
-                 "d" (__arg4)                                  \
-               : _svc_clobber);                                \
-       __res = __svcres;                                       \
-       __syscall_return(type,__res);                           \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,  \
-                 type4,name4,type5,name5)                      \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4,      \
-         type5 arg5) {                                         \
-       register type1 __arg1 asm("2") = arg1;                  \
-       register type2 __arg2 asm("3") = arg2;                  \
-       register type3 __arg3 asm("4") = arg3;                  \
-       register type4 __arg4 asm("5") = arg4;                  \
-       register type5 __arg5 asm("6") = arg5;                  \
-       register long __svcres asm("2");                        \
-       long __res;                                             \
-       asm volatile(                                           \
-               "       .if     %1 < 256\n"                     \
-               "       svc     %b1\n"                          \
-               "       .else\n"                                \
-               "       la      %%r1,%1\n"                      \
-               "       svc     0\n"                            \
-               "       .endif"                                 \
-               : "=d" (__svcres)                               \
-               : "i" (__NR_##name),                            \
-                 "0" (__arg1),                                 \
-                 "d" (__arg2),                                 \
-                 "d" (__arg3),                                 \
-                 "d" (__arg4),                                 \
-                 "d" (__arg5)                                  \
-               : _svc_clobber);                                \
-       __res = __svcres;                                       \
-       __syscall_return(type,__res);                           \
-}
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_SYS_ALARM
index 56cd4b97723212bd2a3cd988464f202b34911f91..37ab0c131a4d9913036ab1997db036877bec3fda 100644 (file)
@@ -53,7 +53,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size,
        consistent_free(vaddr, size);
 }
 
-static inline void dma_cache_sync(void *vaddr, size_t size,
+static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
                                  enum dma_data_direction dir)
 {
        consistent_sync(vaddr, size, (int)dir);
index 34ca8a7f06ba86bec5bfc45b2f778c71b3164536..1583c6b7bdaa6a4d411895a5af7e4311185b2a0a 100644 (file)
@@ -1,10 +1,12 @@
-#ifdef __KERNEL__
 #ifndef _SH_SETUP_H
 #define _SH_SETUP_H
 
 #define COMMAND_LINE_SIZE 256
 
+#ifdef __KERNEL__
+
 int setup_early_printk(char *);
 
-#endif /* _SH_SETUP_H */
 #endif /* __KERNEL__ */
+
+#endif /* _SH_SETUP_H */
index 4f9822a8e7b4834d11a67b90d822fefd2a2047ec..f1b7b46f4e9a46549a41648716e27e0071783c69 100644 (file)
@@ -17,6 +17,17 @@ struct termios {
        cc_t c_cc[NCCS];                /* control characters */
 };
 
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
 /* c_cc characters */
 #define VINTR 0
 #define VQUIT 1
index 0cae1d248761f5b4a47db13a47bd06f2c0bd62d1..f982073dc6c68250b580b11c814a5d77afed72dc 100644 (file)
 
 #ifdef __KERNEL__
 
-#include <linux/err.h>
-
-/* user-visible error numbers are in the range -1 - -MAX_ERRNO:
- * see <asm-sh/errno.h> */
-
-#define __syscall_return(type, res) \
-do { \
-       if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
-       /* Avoid using "res" which is declared to be in register r0; \
-          errno might expand to a function call and clobber it.  */ \
-               int __err = -(res); \
-               errno = __err; \
-               res = -1; \
-       } \
-       return (type) (res); \
-} while (0)
-
-#if defined(__sh2__) || defined(__SH2E__) || defined(__SH2A__)
-#define SYSCALL_ARG0   "trapa #0x20"
-#define SYSCALL_ARG1   "trapa #0x21"
-#define SYSCALL_ARG2   "trapa #0x22"
-#define SYSCALL_ARG3   "trapa #0x23"
-#define SYSCALL_ARG4   "trapa #0x24"
-#define SYSCALL_ARG5   "trapa #0x25"
-#define SYSCALL_ARG6   "trapa #0x26"
-#else
-#define SYSCALL_ARG0   "trapa #0x10"
-#define SYSCALL_ARG1   "trapa #0x11"
-#define SYSCALL_ARG2   "trapa #0x12"
-#define SYSCALL_ARG3   "trapa #0x13"
-#define SYSCALL_ARG4   "trapa #0x14"
-#define SYSCALL_ARG5   "trapa #0x15"
-#define SYSCALL_ARG6   "trapa #0x16"
-#endif
-
-/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-register long __sc0 __asm__ ("r3") = __NR_##name; \
-__asm__ __volatile__ (SYSCALL_ARG0 \
-       : "=z" (__sc0) \
-       : "0" (__sc0) \
-       : "memory" ); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-register long __sc0 __asm__ ("r3") = __NR_##name; \
-register long __sc4 __asm__ ("r4") = (long) arg1; \
-__asm__ __volatile__ (SYSCALL_ARG1 \
-       : "=z" (__sc0) \
-       : "0" (__sc0), "r" (__sc4) \
-       : "memory"); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-register long __sc0 __asm__ ("r3") = __NR_##name; \
-register long __sc4 __asm__ ("r4") = (long) arg1; \
-register long __sc5 __asm__ ("r5") = (long) arg2; \
-__asm__ __volatile__ (SYSCALL_ARG2 \
-       : "=z" (__sc0) \
-       : "0" (__sc0), "r" (__sc4), "r" (__sc5) \
-       : "memory"); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-register long __sc0 __asm__ ("r3") = __NR_##name; \
-register long __sc4 __asm__ ("r4") = (long) arg1; \
-register long __sc5 __asm__ ("r5") = (long) arg2; \
-register long __sc6 __asm__ ("r6") = (long) arg3; \
-__asm__ __volatile__ (SYSCALL_ARG3 \
-       : "=z" (__sc0) \
-       : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6) \
-       : "memory"); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-register long __sc0 __asm__ ("r3") = __NR_##name; \
-register long __sc4 __asm__ ("r4") = (long) arg1; \
-register long __sc5 __asm__ ("r5") = (long) arg2; \
-register long __sc6 __asm__ ("r6") = (long) arg3; \
-register long __sc7 __asm__ ("r7") = (long) arg4; \
-__asm__ __volatile__ (SYSCALL_ARG4 \
-       : "=z" (__sc0) \
-       : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6),  \
-         "r" (__sc7) \
-       : "memory" ); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
-{ \
-register long __sc3 __asm__ ("r3") = __NR_##name; \
-register long __sc4 __asm__ ("r4") = (long) arg1; \
-register long __sc5 __asm__ ("r5") = (long) arg2; \
-register long __sc6 __asm__ ("r6") = (long) arg3; \
-register long __sc7 __asm__ ("r7") = (long) arg4; \
-register long __sc0 __asm__ ("r0") = (long) arg5; \
-__asm__ __volatile__ (SYSCALL_ARG5 \
-       : "=z" (__sc0) \
-       : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7),  \
-         "r" (__sc3) \
-       : "memory" ); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
-{ \
-register long __sc3 __asm__ ("r3") = __NR_##name; \
-register long __sc4 __asm__ ("r4") = (long) arg1; \
-register long __sc5 __asm__ ("r5") = (long) arg2; \
-register long __sc6 __asm__ ("r6") = (long) arg3; \
-register long __sc7 __asm__ ("r7") = (long) arg4; \
-register long __sc0 __asm__ ("r0") = (long) arg5; \
-register long __sc1 __asm__ ("r1") = (long) arg6; \
-__asm__ __volatile__ (SYSCALL_ARG6 \
-       : "=z" (__sc0) \
-       : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7),  \
-         "r" (__sc3), "r" (__sc1) \
-       : "memory" ); \
-__syscall_return(type,__sc0); \
-}
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_OLD_STAT
index 68e27a8fca31f20d90257d454251a31b58e180b5..5efe906c59f7afe5888dbf71293bc1dc7545f10a 100644 (file)
@@ -35,7 +35,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size,
        consistent_free(NULL, size, vaddr, dma_handle);
 }
 
-static inline void dma_cache_sync(void *vaddr, size_t size,
+static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
                                  enum dma_data_direction dir)
 {
        dma_cache_wback_inv((unsigned long)vaddr, size);
index ebd42eb1b709b914f04d9bbd6339703a7777d941..5b07b14c2927c24212692f9b1334fc81f58ce492 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef __ASM_SH64_SETUP_H
 #define __ASM_SH64_SETUP_H
 
+#define COMMAND_LINE_SIZE 256
+
+#ifdef __KERNEL__
+
 #define PARAM ((unsigned char *)empty_zero_page)
 #define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000))
 #define RAMDISK_FLAGS (*(unsigned long *) (PARAM+0x004))
@@ -12,5 +16,7 @@
 #define COMMAND_LINE ((char *) (PARAM+256))
 #define COMMAND_LINE_SIZE 256
 
+#endif  /*  __KERNEL__  */
+
 #endif /* __ASM_SH64_SETUP_H */
 
index ee7828b27ad19334f694a440330cfb03ee56298a..1f38a7aacaafc8a2343821452c9ac5c092c03fab 100644 (file)
 #ifdef __KERNEL__ 
 
 #define NR_syscalls 321
-#include <linux/err.h>
-
-/* user-visible error numbers are in the range -1 - -MAX_ERRNO:
- * see <asm-sh64/errno.h> */
-
-#define __syscall_return(type, res) \
-do { \
-       /* Note: when returning from kernel the return value is in r9       \
-       **       This prevents conflicts between return value and arg1      \
-       **       when dispatching signal handler, in other words makes      \
-       **       life easier in the system call epilogue (see entry.S)      \
-       */                                                                  \
-        register unsigned long __sr2 __asm__ ("r2") = res;                 \
-       if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) {          \
-               errno = -(res);                                             \
-               __sr2 = -1;                                                 \
-       } \
-       return (type) (__sr2);                                              \
-} while (0)
-
-/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
-
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x10 << 16) | __NR_##name); \
-__asm__ __volatile__ ("trapa   %1 !\t\t\t" #name "()"                      \
-       : "=r" (__sc0)                                                      \
-       : "r" (__sc0) );                                                    \
-__syscall_return(type,__sc0);                                              \
-}
-
-       /*
-        * The apparent spurious "dummy" assembler comment is *needed*,
-        * as without it, the compiler treats the arg<n> variables
-        * as no longer live just before the asm. The compiler can
-        * then optimize the storage into any registers it wishes.
-        * The additional dummy statement forces the compiler to put
-        * the arguments into the correct registers before the TRAPA.
-        */
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x11 << 16) | __NR_##name); \
-register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1;        \
-__asm__ __volatile__ ("trapa   %1 !\t\t\t" #name "(%2)"                    \
-       : "=r" (__sc0)                                                      \
-       : "r" (__sc0), "r" (__sc2));                                        \
-__asm__ __volatile__ ("!dummy  %0 %1"                                      \
-       :                                                                   \
-       : "r" (__sc0), "r" (__sc2));                                        \
-__syscall_return(type,__sc0);                                              \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x12 << 16) | __NR_##name); \
-register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1;        \
-register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2;        \
-__asm__ __volatile__ ("trapa   %1 !\t\t\t" #name "(%2,%3)"                 \
-       : "=r" (__sc0)                                                      \
-       : "r" (__sc0), "r" (__sc2), "r" (__sc3) );                          \
-__asm__ __volatile__ ("!dummy  %0 %1 %2"                                   \
-       :                                                                   \
-       : "r" (__sc0), "r" (__sc2), "r" (__sc3) );                          \
-__syscall_return(type,__sc0);                                              \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x13 << 16) | __NR_##name); \
-register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1;        \
-register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2;        \
-register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3;        \
-__asm__ __volatile__ ("trapa   %1 !\t\t\t" #name "(%2,%3,%4)"              \
-       : "=r" (__sc0)                                                      \
-       : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) );             \
-__asm__ __volatile__ ("!dummy  %0 %1 %2 %3"                                \
-       :                                                                   \
-       : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) );             \
-__syscall_return(type,__sc0);                                              \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x14 << 16) | __NR_##name); \
-register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1;        \
-register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2;        \
-register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3;        \
-register unsigned long __sc5 __asm__ ("r5") = (unsigned long) arg4;        \
-__asm__ __volatile__ ("trapa   %1 !\t\t\t" #name "(%2,%3,%4,%5)"           \
-       : "=r" (__sc0)                                                      \
-       : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5) );\
-__asm__ __volatile__ ("!dummy  %0 %1 %2 %3 %4"                             \
-       :                                                                   \
-       : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5) );\
-__syscall_return(type,__sc0);                                              \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x15 << 16) | __NR_##name); \
-register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1;        \
-register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2;        \
-register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3;        \
-register unsigned long __sc5 __asm__ ("r5") = (unsigned long) arg4;        \
-register unsigned long __sc6 __asm__ ("r6") = (unsigned long) arg5;        \
-__asm__ __volatile__ ("trapa   %1 !\t\t\t" #name "(%2,%3,%4,%5,%6)"        \
-       : "=r" (__sc0)                                                      \
-       : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5),  \
-         "r" (__sc6));                                                     \
-__asm__ __volatile__ ("!dummy  %0 %1 %2 %3 %4 %5"                          \
-       :                                                                   \
-       : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5),  \
-         "r" (__sc6));                                                     \
-__syscall_return(type,__sc0);                                              \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5, type6, arg6) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x16 << 16) | __NR_##name); \
-register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1;        \
-register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2;        \
-register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3;        \
-register unsigned long __sc5 __asm__ ("r5") = (unsigned long) arg4;        \
-register unsigned long __sc6 __asm__ ("r6") = (unsigned long) arg5;        \
-register unsigned long __sc7 __asm__ ("r7") = (unsigned long) arg6;        \
-__asm__ __volatile__ ("trapa   %1 !\t\t\t" #name "(%2,%3,%4,%5,%6,%7)"     \
-       : "=r" (__sc0)                                                      \
-       : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5),  \
-         "r" (__sc6), "r" (__sc7));                                        \
-__asm__ __volatile__ ("!dummy  %0 %1 %2 %3 %4 %5 %6"                       \
-       :                                                                   \
-       : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5),  \
-         "r" (__sc6), "r" (__sc7));                                        \
-__syscall_return(type,__sc0);                                              \
-}
 
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
index 1794d71134b73599fdbd17129f5396a58216ae41..5eb00a105d7c0f70764223e162fc05a4e6d6054a 100644 (file)
@@ -31,6 +31,18 @@ struct termios {
 #endif
 };
 
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       cc_t _x_cc[2];                  /* We need them to hold vmin/vtime */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
 /* c_cc characters */
 #define VINTR    0
 #define VQUIT    1
index f7827fa4cd5e79e5404f63568a3d60ed68d72381..d5b2f8053b3b8af9f921caf414b6b5430d19c048 100644 (file)
  *          find a free slot in the 0-302 range.
  */
 
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-__asm__ __volatile__ ("t 0x10\n\t" \
-                     "bcc 1f\n\t" \
-                     "mov %%o0, %0\n\t" \
-                     "sub %%g0, %%o0, %0\n\t" \
-                     "1:\n\t" \
-                     : "=r" (__res)\
-                     : "r" (__g1) \
-                     : "o0", "cc"); \
-if (__res < -255 || __res >= 0) \
-    return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-__asm__ __volatile__ ("t 0x10\n\t" \
-                     "bcc 1f\n\t" \
-                     "mov %%o0, %0\n\t" \
-                     "sub %%g0, %%o0, %0\n\t" \
-                     "1:\n\t" \
-                     : "=r" (__res), "=&r" (__o0) \
-                     : "1" (__o0), "r" (__g1) \
-                     : "cc"); \
-if (__res < -255 || __res >= 0) \
-       return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-__asm__ __volatile__ ("t 0x10\n\t" \
-                     "bcc 1f\n\t" \
-                     "mov %%o0, %0\n\t" \
-                     "sub %%g0, %%o0, %0\n\t" \
-                     "1:\n\t" \
-                     : "=r" (__res), "=&r" (__o0) \
-                     : "1" (__o0), "r" (__o1), "r" (__g1) \
-                     : "cc"); \
-if (__res < -255 || __res >= 0) \
-       return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-register long __o2 __asm__ ("o2") = (long)(arg3); \
-__asm__ __volatile__ ("t 0x10\n\t" \
-                     "bcc 1f\n\t" \
-                     "mov %%o0, %0\n\t" \
-                     "sub %%g0, %%o0, %0\n\t" \
-                     "1:\n\t" \
-                     : "=r" (__res), "=&r" (__o0) \
-                     : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
-                     : "cc"); \
-if (__res < -255 || __res>=0) \
-       return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-register long __o2 __asm__ ("o2") = (long)(arg3); \
-register long __o3 __asm__ ("o3") = (long)(arg4); \
-__asm__ __volatile__ ("t 0x10\n\t" \
-                     "bcc 1f\n\t" \
-                     "mov %%o0, %0\n\t" \
-                     "sub %%g0, %%o0, %0\n\t" \
-                     "1:\n\t" \
-                     : "=r" (__res), "=&r" (__o0) \
-                     : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
-                     : "cc"); \
-if (__res < -255 || __res>=0) \
-       return (type) __res; \
-errno = -__res; \
-return -1; \
-} 
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-         type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-register long __o2 __asm__ ("o2") = (long)(arg3); \
-register long __o3 __asm__ ("o3") = (long)(arg4); \
-register long __o4 __asm__ ("o4") = (long)(arg5); \
-__asm__ __volatile__ ("t 0x10\n\t" \
-                     "bcc 1f\n\t" \
-                     "mov %%o0, %0\n\t" \
-                     "sub %%g0, %%o0, %0\n\t" \
-                     "1:\n\t" \
-                     : "=r" (__res), "=&r" (__o0) \
-                     : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
-                     : "cc"); \
-if (__res < -255 || __res>=0) \
-       return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_STAT64
index 27c46fbeebd6cd5c8ec59491d14114ac686a23b3..2f858a2df94a8e2f3d4b33eba0b4731c31a27216 100644 (file)
@@ -181,7 +181,7 @@ dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t siz
 
 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
-#define dma_is_consistent(d)   (1)
+#define dma_is_consistent(d, h)        (1)
 
 static inline int
 dma_get_cache_alignment(void)
@@ -210,7 +210,7 @@ dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
 }
 
 static inline void
-dma_cache_sync(void *vaddr, size_t size,
+dma_cache_sync(struct device *dev, void *vaddr, size_t size,
               enum dma_data_direction direction)
 {
        /* could define this in terms of the dma_cache ... operations,
index 7392fc4a954e2d603805c319071bc1cbb89e2d19..876312fe82ccf9dbf894a100a26978a5f8267f10 100644 (file)
@@ -45,7 +45,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
        if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
                oparg = 1 << oparg;
 
-       inc_preempt_count();
+       pagefault_disable();
 
        switch (op) {
        case FUTEX_OP_SET:
@@ -67,7 +67,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
                ret = -ENOSYS;
        }
 
-       dec_preempt_count();
+       pagefault_enable();
 
        if (!ret) {
                switch (cmp) {
index 010f9cd0a672137d89ed4569549e78dd6868197e..5891ff7ba7609db6a57cf6f11ae65417e887b94f 100644 (file)
@@ -13,7 +13,7 @@
 #include <asm/page.h>
 
 /* Page table allocation/freeing. */
-extern kmem_cache_t *pgtable_cache;
+extern struct kmem_cache *pgtable_cache;
 
 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 {
index b07715273ed434ab1159cf4231bb1e4501c5e58f..705cd44b41730d0bd8f5604f854c6fc53e76b922 100644 (file)
@@ -33,6 +33,18 @@ struct termios {
 #endif
 };
 
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       cc_t _x_cc[2];                  /* We need them to hold vmin/vtime */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
 /* c_cc characters */
 #define VINTR    0
 #define VQUIT    1
index 63669dad0d72b5d4feae55137d11703791432020..47047536f261f6b5696e2d47c1e17609081aa0c9 100644 (file)
  *          find a free slot in the 0-302 range.
  */
 
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-__asm__ __volatile__ ("t 0x6d\n\t" \
-                     "sub %%g0, %%o0, %0\n\t" \
-                     "movcc %%xcc, %%o0, %0\n\t" \
-                     : "=r" (__res)\
-                     : "r" (__g1) \
-                     : "o0", "cc"); \
-if (__res >= 0) \
-    return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-__asm__ __volatile__ ("t 0x6d\n\t" \
-                     "sub %%g0, %%o0, %0\n\t" \
-                     "movcc %%xcc, %%o0, %0\n\t" \
-                     : "=r" (__res), "=&r" (__o0) \
-                     : "1" (__o0), "r" (__g1) \
-                     : "cc"); \
-if (__res >= 0) \
-       return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-__asm__ __volatile__ ("t 0x6d\n\t" \
-                     "sub %%g0, %%o0, %0\n\t" \
-                     "movcc %%xcc, %%o0, %0\n\t" \
-                     : "=r" (__res), "=&r" (__o0) \
-                     : "1" (__o0), "r" (__o1), "r" (__g1) \
-                     : "cc"); \
-if (__res >= 0) \
-       return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-register long __o2 __asm__ ("o2") = (long)(arg3); \
-__asm__ __volatile__ ("t 0x6d\n\t" \
-                     "sub %%g0, %%o0, %0\n\t" \
-                     "movcc %%xcc, %%o0, %0\n\t" \
-                     : "=r" (__res), "=&r" (__o0) \
-                     : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
-                     : "cc"); \
-if (__res>=0) \
-       return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-register long __o2 __asm__ ("o2") = (long)(arg3); \
-register long __o3 __asm__ ("o3") = (long)(arg4); \
-__asm__ __volatile__ ("t 0x6d\n\t" \
-                     "sub %%g0, %%o0, %0\n\t" \
-                     "movcc %%xcc, %%o0, %0\n\t" \
-                     : "=r" (__res), "=&r" (__o0) \
-                     : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
-                     : "cc"); \
-if (__res>=0) \
-       return (type) __res; \
-errno = -__res; \
-return -1; \
-} 
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-         type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-register long __o2 __asm__ ("o2") = (long)(arg3); \
-register long __o3 __asm__ ("o3") = (long)(arg4); \
-register long __o4 __asm__ ("o4") = (long)(arg5); \
-__asm__ __volatile__ ("t 0x6d\n\t" \
-                     "sub %%g0, %%o0, %0\n\t" \
-                     "movcc %%xcc, %%o0, %0\n\t" \
-                     : "=r" (__res), "=&r" (__o0) \
-                     : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
-                     : "cc"); \
-if (__res>=0) \
-       return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
 /* sysconf options, for SunOS compatibility */
 #define   _SC_ARG_MAX             1
 #define   _SC_CHILD_MAX           2
index 1e22fa26ff061cb1c3ccb9c9395154d66062d908..3357c5e2468e7868b14cc8c7efe63494afaa3f6b 100644 (file)
@@ -1,4 +1,6 @@
 #ifndef __UM_BUG_H
 #define __UM_BUG_H
-#include <asm-generic/bug.h>
+
+#include <asm/arch/bug.h>
+
 #endif
index babd2989511465887973098e1619e6d20a067669..f0ee4fb55911e7441c73710eda5ef0a0c11f621d 100644 (file)
@@ -94,7 +94,7 @@ dma_sync_sg(struct device *dev, struct scatterlist *sg, int nelems,
 
 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
-#define dma_is_consistent(d) (1)
+#define dma_is_consistent(d, h) (1)
 
 static inline int
 dma_get_cache_alignment(void)
@@ -112,7 +112,7 @@ dma_sync_single_range(struct device *dev, dma_addr_t dma_handle,
 }
 
 static inline void
-dma_cache_sync(void *vaddr, size_t size,
+dma_cache_sync(struct device *dev, void *vaddr, size_t size,
               enum dma_data_direction direction)
 {
        BUG();
index 1bf096db8f4c258f2d71abd83414bb4611ee79bf..88687c181f01234e8463ef0581f93e983c0542fe 100644 (file)
@@ -46,8 +46,6 @@ extern void
 init_irq_handlers (int base_irq, int num, int interval,
                   struct hw_interrupt_type *irq_type);
 
-typedef void (*irq_handler_t)(int irq, void *data, struct pt_regs *regs);
-
 /* Handle interrupt IRQ.  REGS are the registers at the time of ther
    interrupt.  */
 extern unsigned int handle_irq (int irq, struct pt_regs *regs);
index 212d4e279263c56318fb7be1112880eea0a741e3..f3b433032089411f272e8c9484a8f54885c8067c 100644 (file)
@@ -17,6 +17,17 @@ struct termios {
        cc_t c_cc[NCCS];                /* control characters */
 };
 
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
 /* c_cc characters */
 #define VINTR 0
 #define VQUIT 1
index 737401e7d3ad33a5c398577bfb465354d6e6b7dc..2241ed45ecfeb9a315253636cc12b52af8723f48 100644 (file)
 #define __NR_gettid            201
 #define __NR_tkill             202
 
-
-/* Syscall protocol:
-   Syscall number in r12, args in r6-r9, r13-r14
-   Return value in r10
-   Trap 0 for `short' syscalls, where all the args can fit in function
-   call argument registers, and trap 1 when there are additional args in
-   r13-r14.  */
-
-#define SYSCALL_NUM    "r12"
-#define SYSCALL_ARG0   "r6"
-#define SYSCALL_ARG1   "r7"
-#define SYSCALL_ARG2   "r8"
-#define SYSCALL_ARG3   "r9"
-#define SYSCALL_ARG4   "r13"
-#define SYSCALL_ARG5   "r14"
-#define SYSCALL_RET    "r10"
-
-#define SYSCALL_SHORT_TRAP     "0"
-#define SYSCALL_LONG_TRAP      "1"
-
-/* Registers clobbered by any syscall.  This _doesn't_ include the syscall
-   number (r12) or the `extended arg' registers (r13, r14), even though
-   they are actually clobbered too (this is because gcc's `asm' statement
-   doesn't allow a clobber to be used as an input or output).  */
-#define SYSCALL_CLOBBERS       "r1", "r5", "r11", "r15", "r16", \
-                               "r17", "r18", "r19"
-
-/* Registers clobbered by a `short' syscall.  This includes all clobbers
-   except the syscall number (r12).  */
-#define SYSCALL_SHORT_CLOBBERS SYSCALL_CLOBBERS, "r13", "r14"
-
 #ifdef __KERNEL__
 
-#include <asm/clinkage.h>
-#include <linux/err.h>
-
-#define __syscall_return(type, res)                                          \
-  do {                                                                       \
-         /* user-visible error numbers are in the range -1 - -MAX_ERRNO:      \
-            see <asm-v850/errno.h> */                                        \
-         if (__builtin_expect ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO), 0)) { \
-                 errno = -(res);                                             \
-                 res = -1;                                                   \
-         }                                                                   \
-         return (type) (res);                                                \
-  } while (0)
-
-
-#define _syscall0(type, name)                                                \
-type name (void)                                                             \
-{                                                                            \
-  register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name;              \
-  register unsigned long __ret __asm__ (SYSCALL_RET);                        \
-  __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP                           \
-                       : "=r" (__ret), "=r" (__syscall)                      \
-                       : "1" (__syscall)                                     \
-                       : SYSCALL_SHORT_CLOBBERS);                            \
-  __syscall_return (type, __ret);                                            \
-}
-
-#define _syscall1(type, name, atype, a)                                              \
-type name (atype a)                                                          \
-{                                                                            \
-  register atype __a __asm__ (SYSCALL_ARG0) = a;                             \
-  register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name;              \
-  register unsigned long __ret __asm__ (SYSCALL_RET);                        \
-  __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP                           \
-                       : "=r" (__ret), "=r" (__syscall)                      \
-                       : "1" (__syscall), "r" (__a)                          \
-                       : SYSCALL_SHORT_CLOBBERS);                            \
-  __syscall_return (type, __ret);                                            \
-}
-
-#define _syscall2(type, name, atype, a, btype, b)                            \
-type name (atype a, btype b)                                                 \
-{                                                                            \
-  register atype __a __asm__ (SYSCALL_ARG0) = a;                             \
-  register btype __b __asm__ (SYSCALL_ARG1) = b;                             \
-  register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name;              \
-  register unsigned long __ret __asm__ (SYSCALL_RET);                        \
-  __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP                           \
-                       : "=r" (__ret), "=r" (__syscall)                      \
-                       : "1" (__syscall), "r" (__a), "r" (__b)               \
-                       : SYSCALL_SHORT_CLOBBERS);                            \
-  __syscall_return (type, __ret);                                            \
-}
-
-#define _syscall3(type, name, atype, a, btype, b, ctype, c)                  \
-type name (atype a, btype b, ctype c)                                        \
-{                                                                            \
-  register atype __a __asm__ (SYSCALL_ARG0) = a;                             \
-  register btype __b __asm__ (SYSCALL_ARG1) = b;                             \
-  register ctype __c __asm__ (SYSCALL_ARG2) = c;                             \
-  register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name;              \
-  register unsigned long __ret __asm__ (SYSCALL_RET);                        \
-  __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP                           \
-                       : "=r" (__ret), "=r" (__syscall)                      \
-                       : "1" (__syscall), "r" (__a), "r" (__b), "r" (__c)    \
-                       : SYSCALL_SHORT_CLOBBERS);                            \
-  __syscall_return (type, __ret);                                            \
-}
-
-#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d)        \
-type name (atype a, btype b, ctype c, dtype d)                               \
-{                                                                            \
-  register atype __a __asm__ (SYSCALL_ARG0) = a;                             \
-  register btype __b __asm__ (SYSCALL_ARG1) = b;                             \
-  register ctype __c __asm__ (SYSCALL_ARG2) = c;                             \
-  register dtype __d __asm__ (SYSCALL_ARG3) = d;                             \
-  register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name;              \
-  register unsigned long __ret __asm__ (SYSCALL_RET);                        \
-  __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP                           \
-                       : "=r" (__ret), "=r" (__syscall)                      \
-                       : "1" (__syscall),                                    \
-                       "r" (__a), "r" (__b), "r" (__c), "r" (__d)            \
-                       : SYSCALL_SHORT_CLOBBERS);                            \
-  __syscall_return (type, __ret);                                            \
-}
-
-#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype,e)\
-type name (atype a, btype b, ctype c, dtype d, etype e)                              \
-{                                                                            \
-  register atype __a __asm__ (SYSCALL_ARG0) = a;                             \
-  register btype __b __asm__ (SYSCALL_ARG1) = b;                             \
-  register ctype __c __asm__ (SYSCALL_ARG2) = c;                             \
-  register dtype __d __asm__ (SYSCALL_ARG3) = d;                             \
-  register etype __e __asm__ (SYSCALL_ARG4) = e;                             \
-  register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name;              \
-  register unsigned long __ret __asm__ (SYSCALL_RET);                        \
-  __asm__ __volatile__ ("trap " SYSCALL_LONG_TRAP                            \
-                       : "=r" (__ret), "=r" (__syscall), "=r" (__e)          \
-                       : "1" (__syscall),                                    \
-                       "r" (__a), "r" (__b), "r" (__c), "r" (__d), "2" (__e) \
-                       : SYSCALL_CLOBBERS);                                  \
-  __syscall_return (type, __ret);                                            \
-}
-
-#define __SYSCALL6_TRAP(syscall, ret, a, b, c, d, e, f)                              \
-  __asm__ __volatile__ ("trap " SYSCALL_LONG_TRAP                            \
-                       : "=r" (ret), "=r" (syscall),                         \
-                       "=r" (e), "=r" (f)                                    \
-                       : "1" (syscall),                                      \
-                       "r" (a), "r" (b), "r" (c), "r" (d),                   \
-                       "2" (e), "3" (f)                                      \
-                       : SYSCALL_CLOBBERS);
-
-#define _syscall6(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e, ftype, f) \
-type name (atype a, btype b, ctype c, dtype d, etype e, ftype f)             \
-{                                                                            \
-  register atype __a __asm__ (SYSCALL_ARG0) = a;                             \
-  register btype __b __asm__ (SYSCALL_ARG1) = b;                             \
-  register ctype __c __asm__ (SYSCALL_ARG2) = c;                             \
-  register dtype __d __asm__ (SYSCALL_ARG3) = d;                             \
-  register etype __e __asm__ (SYSCALL_ARG4) = e;                             \
-  register etype __f __asm__ (SYSCALL_ARG5) = f;                             \
-  register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name;              \
-  register unsigned long __ret __asm__ (SYSCALL_RET);                        \
-  __SYSCALL6_TRAP(__syscall, __ret, __a, __b, __c, __d, __e, __f);           \
-  __syscall_return (type, __ret);                                            \
-}
-               
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_STAT64
index 1ee9b07f3fe6adcc2d936566b237147821289e81..ebd7117782a67f1dfe4995a3165a947ce80bc7b7 100644 (file)
@@ -6,13 +6,11 @@ ALTARCHDEF := defined __i386__
 
 header-y += boot.h
 header-y += bootsetup.h
-header-y += cpufeature.h
 header-y += debugreg.h
 header-y += ldt.h
 header-y += msr.h
 header-y += prctl.h
 header-y += ptrace-abi.h
-header-y += setup.h
 header-y += sigcontext32.h
 header-y += ucontext.h
 header-y += vsyscall32.h
index a584826cc570f6aa6415b62d255a789feb8b22a6..a6657b4f3e0eccc7660983382c378b67813d16d3 100644 (file)
@@ -4,6 +4,7 @@
 #ifdef __KERNEL__
 
 #include <linux/types.h>
+#include <linux/stddef.h>
 #include <asm/cpufeature.h>
 
 struct alt_instr {
@@ -133,4 +134,15 @@ static inline void alternatives_smp_switch(int smp) {}
 #define LOCK_PREFIX ""
 #endif
 
+struct paravirt_patch;
+#ifdef CONFIG_PARAVIRT
+void apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end);
+#else
+static inline void
+apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end)
+{}
+#define __start_parainstructions NULL
+#define __stop_parainstructions NULL
+#endif
+
 #endif /* _X86_64_ALTERNATIVE_H */
index 93849f7abc2480fe8f730f129ba00970d71fac2c..706ca4b60000ec2091efa2a45e096a4f5fef0c5e 100644 (file)
@@ -189,9 +189,9 @@ static __inline__ int atomic_add_return(int i, atomic_t *v)
 {
        int __i = i;
        __asm__ __volatile__(
-               LOCK_PREFIX "xaddl %0, %1;"
-               :"=r"(i)
-               :"m"(v->counter), "0"(i));
+               LOCK_PREFIX "xaddl %0, %1"
+               :"+r" (i), "+m" (v->counter)
+               : : "memory");
        return i + __i;
 }
 
index 80ac1fe966ac13ec3be908b2ec94bfaccefb40cc..68260641491339a27d516cd7ca2b9d724ae01901 100644 (file)
@@ -1,30 +1,30 @@
 #ifndef __ASM_X8664_BUG_H
 #define __ASM_X8664_BUG_H 1
 
-#include <linux/stringify.h>
-
-/*
- * Tell the user there is some problem.  The exception handler decodes 
- * this frame.
- */
-struct bug_frame {
-       unsigned char ud2[2];
-       unsigned char push;
-       signed int filename;
-       unsigned char ret;
-       unsigned short line;
-} __attribute__((packed));
-
 #ifdef CONFIG_BUG
 #define HAVE_ARCH_BUG
-/* We turn the bug frame into valid instructions to not confuse
-   the disassembler. Thanks to Jan Beulich & Suresh Siddha
-   for nice instruction selection.
-   The magic numbers generate mov $64bitimm,%eax ; ret $offset. */
-#define BUG()                                                          \
-       asm volatile(                                                   \
-       "ud2 ; pushq $%c1 ; ret $%c0" ::                                \
-                    "i"(__LINE__), "i" (__FILE__))
+
+#ifdef CONFIG_DEBUG_BUGVERBOSE
+#define BUG()                                                          \
+       do {                                                            \
+               asm volatile("1:\tud2\n"                                \
+                            ".pushsection __bug_table,\"a\"\n"         \
+                            "2:\t.quad 1b, %c0\n"                      \
+                            "\t.word %c1, 0\n"                         \
+                            "\t.org 2b+%c2\n"                          \
+                            ".popsection"                              \
+                            : : "i" (__FILE__), "i" (__LINE__),        \
+                               "i" (sizeof(struct bug_entry)));        \
+               for(;;) ;                                               \
+       } while(0)
+#else
+#define BUG()                                                          \
+       do {                                                            \
+               asm volatile("ud2");                                    \
+               for(;;) ;                                               \
+       } while(0)
+#endif
+
 void out_of_line_bug(void);
 #else
 static inline void out_of_line_bug(void) { }
index 6b93f5a3a5c8ee81eff80cf96ed40653338f58ed..7ee90064571955ca938b43b6b1c77364037c0978 100644 (file)
@@ -51,6 +51,8 @@ struct iommu_table {
 #define TCE_TABLE_SIZE_4M              6
 #define TCE_TABLE_SIZE_8M              7
 
+extern int use_calgary;
+
 #ifdef CONFIG_CALGARY_IOMMU
 extern int calgary_iommu_init(void);
 extern void detect_calgary(void);
index ee792faaca013fa17cf0887f2008a278eac5fe17..0b3c686139f1505340db96be8dc52585f584a9fc 100644 (file)
@@ -29,7 +29,7 @@
 #define X86_FEATURE_PSE36      (0*32+17) /* 36-bit PSEs */
 #define X86_FEATURE_PN         (0*32+18) /* Processor serial number */
 #define X86_FEATURE_CLFLSH     (0*32+19) /* Supports the CLFLUSH instruction */
-#define X86_FEATURE_DTES       (0*32+21) /* Debug Trace Store */
+#define X86_FEATURE_DS         (0*32+21) /* Debug Store */
 #define X86_FEATURE_ACPI       (0*32+22) /* ACPI via MSR */
 #define X86_FEATURE_MMX                (0*32+23) /* Multimedia Extensions */
 #define X86_FEATURE_FXSR       (0*32+24) /* FXSAVE and FXRSTOR instructions (fast save and restore */
@@ -68,6 +68,8 @@
 #define X86_FEATURE_FXSAVE_LEAK (3*32+7)  /* FIP/FOP/FDP leaks through FXSAVE */
 #define X86_FEATURE_UP         (3*32+8) /* SMP kernel running on UP */
 #define X86_FEATURE_ARCH_PERFMON (3*32+9) /* Intel Architectural PerfMon */
+#define X86_FEATURE_PEBS       (3*32+10) /* Precise-Event Based Sampling */
+#define X86_FEATURE_BTS                (3*32+11) /* Branch Trace Store */
 
 /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
 #define X86_FEATURE_XMM3       (4*32+ 0) /* Streaming SIMD Extensions-3 */
 #define cpu_has_cyrix_arr      0
 #define cpu_has_centaur_mcr    0
 #define cpu_has_clflush               boot_cpu_has(X86_FEATURE_CLFLSH)
+#define cpu_has_ds            boot_cpu_has(X86_FEATURE_DS)
+#define cpu_has_pebs          boot_cpu_has(X86_FEATURE_PEBS)
+#define cpu_has_bts           boot_cpu_has(X86_FEATURE_BTS)
 
 #endif /* __ASM_X8664_CPUFEATURE_H */
index 65f64acc53192946592d189463508d7f1e9d4c09..c2669f1f5529065e83e6eaf58a17943aff5e81c0 100644 (file)
@@ -7,18 +7,21 @@
  * Delay routines calling functions in arch/x86_64/lib/delay.c
  */
  
+/* Undefined functions to get compile-time errors */
 extern void __bad_udelay(void);
 extern void __bad_ndelay(void);
 
 extern void __udelay(unsigned long usecs);
-extern void __ndelay(unsigned long usecs);
+extern void __ndelay(unsigned long nsecs);
 extern void __const_udelay(unsigned long usecs);
 extern void __delay(unsigned long loops);
 
+/* 0x10c7 is 2**32 / 1000000 (rounded up) */
 #define udelay(n) (__builtin_constant_p(n) ? \
-       ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c6ul)) : \
+       ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c7ul)) : \
        __udelay(n))
 
+/* 0x5 is 2**32 / 1000000000 (rounded up) */
 #define ndelay(n) (__builtin_constant_p(n) ? \
        ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \
        __ndelay(n))
index eb7723a467908b5f86cb0e2fc2dd24168c8e523d..913d6ac0003381a5ea01d3dcc35b20a0fca0bcac 100644 (file)
@@ -9,64 +9,13 @@
 
 #include <linux/string.h>
 #include <linux/smp.h>
+#include <asm/desc_defs.h>
 
 #include <asm/segment.h>
 #include <asm/mmu.h>
 
-// 8 byte segment descriptor
-struct desc_struct { 
-       u16 limit0;
-       u16 base0;
-       unsigned base1 : 8, type : 4, s : 1, dpl : 2, p : 1;
-       unsigned limit : 4, avl : 1, l : 1, d : 1, g : 1, base2 : 8;
-} __attribute__((packed)); 
-
-struct n_desc_struct { 
-       unsigned int a,b;
-};     
-
 extern struct desc_struct cpu_gdt_table[GDT_ENTRIES];
 
-enum { 
-       GATE_INTERRUPT = 0xE, 
-       GATE_TRAP = 0xF,        
-       GATE_CALL = 0xC,
-};     
-
-// 16byte gate
-struct gate_struct {          
-       u16 offset_low;
-       u16 segment; 
-       unsigned ist : 3, zero0 : 5, type : 5, dpl : 2, p : 1;
-       u16 offset_middle;
-       u32 offset_high;
-       u32 zero1; 
-} __attribute__((packed));
-
-#define PTR_LOW(x) ((unsigned long)(x) & 0xFFFF) 
-#define PTR_MIDDLE(x) (((unsigned long)(x) >> 16) & 0xFFFF)
-#define PTR_HIGH(x) ((unsigned long)(x) >> 32)
-
-enum { 
-       DESC_TSS = 0x9,
-       DESC_LDT = 0x2,
-}; 
-
-// LDT or TSS descriptor in the GDT. 16 bytes.
-struct ldttss_desc { 
-       u16 limit0;
-       u16 base0;
-       unsigned base1 : 8, type : 5, dpl : 2, p : 1;
-       unsigned limit1 : 4, zero0 : 3, g : 1, base2 : 8;
-       u32 base3;
-       u32 zero1; 
-} __attribute__((packed)); 
-
-struct desc_ptr {
-       unsigned short size;
-       unsigned long address;
-} __attribute__((packed)) ;
-
 #define load_TR_desc() asm volatile("ltr %w0"::"r" (GDT_ENTRY_TSS*8))
 #define load_LDT_desc() asm volatile("lldt %w0"::"r" (GDT_ENTRY_LDT*8))
 #define clear_LDT()  asm volatile("lldt %w0"::"r" (0))
diff --git a/include/asm-x86_64/desc_defs.h b/include/asm-x86_64/desc_defs.h
new file mode 100644 (file)
index 0000000..0890040
--- /dev/null
@@ -0,0 +1,69 @@
+/* Written 2000 by Andi Kleen */
+#ifndef __ARCH_DESC_DEFS_H
+#define __ARCH_DESC_DEFS_H
+
+/*
+ * Segment descriptor structure definitions, usable from both x86_64 and i386
+ * archs.
+ */
+
+#ifndef __ASSEMBLY__
+
+#include <linux/types.h>
+
+// 8 byte segment descriptor
+struct desc_struct {
+       u16 limit0;
+       u16 base0;
+       unsigned base1 : 8, type : 4, s : 1, dpl : 2, p : 1;
+       unsigned limit : 4, avl : 1, l : 1, d : 1, g : 1, base2 : 8;
+} __attribute__((packed));
+
+struct n_desc_struct {
+       unsigned int a,b;
+};
+
+enum {
+       GATE_INTERRUPT = 0xE,
+       GATE_TRAP = 0xF,
+       GATE_CALL = 0xC,
+};
+
+// 16byte gate
+struct gate_struct {
+       u16 offset_low;
+       u16 segment;
+       unsigned ist : 3, zero0 : 5, type : 5, dpl : 2, p : 1;
+       u16 offset_middle;
+       u32 offset_high;
+       u32 zero1;
+} __attribute__((packed));
+
+#define PTR_LOW(x) ((unsigned long)(x) & 0xFFFF)
+#define PTR_MIDDLE(x) (((unsigned long)(x) >> 16) & 0xFFFF)
+#define PTR_HIGH(x) ((unsigned long)(x) >> 32)
+
+enum {
+       DESC_TSS = 0x9,
+       DESC_LDT = 0x2,
+};
+
+// LDT or TSS descriptor in the GDT. 16 bytes.
+struct ldttss_desc {
+       u16 limit0;
+       u16 base0;
+       unsigned base1 : 8, type : 5, dpl : 2, p : 1;
+       unsigned limit1 : 4, zero0 : 3, g : 1, base2 : 8;
+       u32 base3;
+       u32 zero1;
+} __attribute__((packed));
+
+struct desc_ptr {
+       unsigned short size;
+       unsigned long address;
+} __attribute__((packed)) ;
+
+
+#endif /* !__ASSEMBLY__ */
+
+#endif
index 10174b110a5cf9bb332b531c24f2cedef3b35c0a..be9ec68907237f4690101216d0b5f93c5616ed95 100644 (file)
@@ -180,12 +180,13 @@ static inline int dma_get_cache_alignment(void)
        return boot_cpu_data.x86_clflush_size;
 }
 
-#define dma_is_consistent(h) 1
+#define dma_is_consistent(d, h) 1
 
 extern int dma_set_mask(struct device *dev, u64 mask);
 
 static inline void
-dma_cache_sync(void *vaddr, size_t size, enum dma_data_direction dir)
+dma_cache_sync(struct device *dev, void *vaddr, size_t size,
+       enum dma_data_direction dir)
 {
        flush_write_buffers();
 }
index 9804bf07b092f4bb154f19284047a9a9711bc989..5cdfb08013c38889dc8a42a2dff4c4a3c1833ff8 100644 (file)
@@ -55,7 +55,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
        if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
                return -EFAULT;
 
-       inc_preempt_count();
+       pagefault_disable();
 
        switch (op) {
        case FUTEX_OP_SET:
@@ -78,7 +78,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
                ret = -ENOSYS;
        }
 
-       dec_preempt_count();
+       pagefault_enable();
 
        if (!ret) {
                switch (cmp) {
index a0e9a4b934844a96c4dced8b8cdd293e2b5decfb..b80f4bb5f2733554f096788cb067b06519f1053c 100644 (file)
@@ -30,6 +30,6 @@ struct genapic {
 };
 
 
-extern struct genapic *genapic;
+extern struct genapic *genapic, *genapic_force, apic_flat;
 
 #endif
index 62caf8b6e4e171dcac87295fa577f6d1f49d1163..3fc0b15a0d7e3b98c4d58fdbb1ec9ba3deed95d7 100644 (file)
 #define TIOCSBRK       0x5427  /* BSD compatibility */
 #define TIOCCBRK       0x5428  /* BSD compatibility */
 #define TIOCGSID       0x5429  /* Return the session ID of FD */
+#define TCGETS2                _IOR('T',0x2A, struct termios2)
+#define TCSETS2                _IOW('T',0x2B, struct termios2)
+#define TCSETSW2       _IOW('T',0x2C, struct termios2)
+#define TCSETSF2       _IOW('T',0x2D, struct termios2)
 #define TIOCGPTN       _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
 #define TIOCSPTLCK     _IOW('T',0x31, int)  /* Lock/unlock Pty */
 
index 37e194169fac2f2793894331eb9ec34d81401dfa..952783d35c7b4ceea3a3b898af80be5e142736f8 100644 (file)
@@ -169,8 +169,8 @@ static inline unsigned int cpuid_edx(unsigned int op)
 #define MSR_LSTAR 0xc0000082           /* long mode SYSCALL target */
 #define MSR_CSTAR 0xc0000083           /* compatibility mode SYSCALL target */
 #define MSR_SYSCALL_MASK 0xc0000084    /* EFLAGS mask for syscall */
-#define MSR_FS_BASE 0xc0000100         /* 64bit GS base */
-#define MSR_GS_BASE 0xc0000101         /* 64bit FS base */
+#define MSR_FS_BASE 0xc0000100         /* 64bit FS base */
+#define MSR_GS_BASE 0xc0000101         /* 64bit GS base */
 #define MSR_KERNEL_GS_BASE  0xc0000102 /* SwapGS GS shadow (or USER_GS from kernel) */ 
 /* EFER bits: */ 
 #define _EFER_SCE 0  /* SYSCALL/SYSRET */
@@ -210,6 +210,10 @@ static inline unsigned int cpuid_edx(unsigned int op)
 #define MSR_IA32_LASTINTFROMIP     0x1dd
 #define MSR_IA32_LASTINTTOIP       0x1de
 
+#define MSR_IA32_PEBS_ENABLE           0x3f1
+#define MSR_IA32_DS_AREA               0x600
+#define MSR_IA32_PERF_CAPABILITIES     0x345
+
 #define MSR_MTRRfix64K_00000   0x250
 #define MSR_MTRRfix16K_80000   0x258
 #define MSR_MTRRfix16K_A0000   0x259
@@ -407,4 +411,13 @@ static inline unsigned int cpuid_edx(unsigned int op)
 #define MSR_P4_U2L_ESCR0               0x3b0
 #define MSR_P4_U2L_ESCR1               0x3b1
 
+/* Intel Core-based CPU performance counters */
+#define MSR_CORE_PERF_FIXED_CTR0       0x309
+#define MSR_CORE_PERF_FIXED_CTR1       0x30a
+#define MSR_CORE_PERF_FIXED_CTR2       0x30b
+#define MSR_CORE_PERF_FIXED_CTR_CTRL   0x38d
+#define MSR_CORE_PERF_GLOBAL_STATUS    0x38e
+#define MSR_CORE_PERF_GLOBAL_CTRL      0x38f
+#define MSR_CORE_PERF_GLOBAL_OVF_CTRL  0x390
+
 #endif
index f367d4014b423b5298df04dfc556ff4d5aeaf3fb..72375e7d32a895846200ff921ebfd5e8776296bf 100644 (file)
@@ -77,4 +77,7 @@ extern int proc_nmi_enabled(struct ctl_table *, int , struct file *,
 
 extern int unknown_nmi_panic;
 
+void __trigger_all_cpu_backtrace(void);
+#define trigger_all_cpu_backtrace() __trigger_all_cpu_backtrace()
+
 #endif /* ASM_NMI_H */
index eba9cb471df38b1bee0b4893482fccb576411795..6823fa4f1afa3c8a43a17697cba5ce4ecf63cb36 100644 (file)
@@ -10,6 +10,7 @@ extern u32 read_pci_config(u8 bus, u8 slot, u8 func, u8 offset);
 extern u8 read_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset);
 extern u16 read_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset);
 extern void write_pci_config(u8 bus, u8 slot, u8 func, u8 offset, u32 val);
+extern void write_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset, u8 val);
 
 extern int early_pci_allowed(void);
 
index 0555c1c4d8fa9fcda13c280997c076decc85d708..59901c690a0d4882744c770c4aabfa39ad605bb7 100644 (file)
@@ -221,20 +221,19 @@ static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long
 #define __S110 PAGE_SHARED_EXEC
 #define __S111 PAGE_SHARED_EXEC
 
-static inline unsigned long pgd_bad(pgd_t pgd) 
-{ 
-       unsigned long val = pgd_val(pgd);
-       val &= ~PTE_MASK; 
-       val &= ~(_PAGE_USER | _PAGE_DIRTY); 
-       return val & ~(_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED);      
-} 
+static inline unsigned long pgd_bad(pgd_t pgd)
+{
+       return pgd_val(pgd) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER);
+}
 
 static inline unsigned long pud_bad(pud_t pud)
 {
-       unsigned long val = pud_val(pud);
-       val &= ~PTE_MASK;
-       val &= ~(_PAGE_USER | _PAGE_DIRTY);
-       return val & ~(_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED);
+       return pud_val(pud) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER);
+}
+
+static inline unsigned long pmd_bad(pmd_t pmd)
+{
+       return pmd_val(pmd) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER);
 }
 
 #define pte_none(x)    (!pte_val(x))
@@ -347,7 +346,6 @@ static inline int pmd_large(pmd_t pte) {
 #define pmd_none(x)    (!pmd_val(x))
 #define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
 #define pmd_clear(xp)  do { set_pmd(xp, __pmd(0)); } while (0)
-#define        pmd_bad(x)      ((pmd_val(x) & (~PTE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE )
 #define pfn_pmd(nr,prot) (__pmd(((nr) << PAGE_SHIFT) | pgprot_val(prot)))
 #define pmd_pfn(x)  ((pmd_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT)
 
index cef17e0f828cc5d0080cf967d11e80a228f4d18b..76552d72804c6368ed210fd02811c0f9608308e7 100644 (file)
@@ -475,6 +475,14 @@ static inline void __mwait(unsigned long eax, unsigned long ecx)
                : :"a" (eax), "c" (ecx));
 }
 
+static inline void __sti_mwait(unsigned long eax, unsigned long ecx)
+{
+       /* "mwait %eax,%ecx;" */
+       asm volatile(
+               "sti; .byte 0x0f,0x01,0xc9;"
+               : :"a" (eax), "c" (ecx));
+}
+
 extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx);
 
 #define stack_current() \
index e72cfcdf53448d262ce0b549de267ae470f8ebe1..6d324b83897207f56f9e348bc6ef6feae8c553ef 100644 (file)
@@ -61,7 +61,6 @@ extern void numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn);
 extern unsigned long numa_free_all_bootmem(void);
 
 extern void reserve_bootmem_generic(unsigned long phys, unsigned len);
-extern void free_bootmem_generic(unsigned long phys, unsigned len);
 
 extern void load_gs_index(unsigned gs);
 
@@ -88,6 +87,7 @@ extern void syscall32_cpu_init(void);
 extern void setup_node_bootmem(int nodeid, unsigned long start, unsigned long end);
 
 extern void early_quirks(void);
+extern void quirk_intel_irqbalance(void);
 extern void check_efer(void);
 
 extern int unhandled_signal(struct task_struct *tsk, int sig);
diff --git a/include/asm-x86_64/rio.h b/include/asm-x86_64/rio.h
new file mode 100644 (file)
index 0000000..c7350f6
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Derived from include/asm-i386/mach-summit/mach_mpparse.h
+ *          and include/asm-i386/mach-default/bios_ebda.h
+ *
+ * Author: Laurent Vivier <Laurent.Vivier@bull.net>
+ */
+
+#ifndef __ASM_RIO_H
+#define __ASM_RIO_H
+
+#define RIO_TABLE_VERSION      3
+
+struct rio_table_hdr {
+       u8 version;      /* Version number of this data structure  */
+       u8 num_scal_dev; /* # of Scalability devices               */
+       u8 num_rio_dev;  /* # of RIO I/O devices                   */
+} __attribute__((packed));
+
+struct scal_detail {
+       u8 node_id;      /* Scalability Node ID                    */
+       u32 CBAR;        /* Address of 1MB register space          */
+       u8 port0node;    /* Node ID port connected to: 0xFF=None   */
+       u8 port0port;    /* Port num port connected to: 0,1,2, or  */
+                        /* 0xFF=None                              */
+       u8 port1node;    /* Node ID port connected to: 0xFF = None */
+       u8 port1port;    /* Port num port connected to: 0,1,2, or  */
+                        /* 0xFF=None                              */
+       u8 port2node;    /* Node ID port connected to: 0xFF = None */
+       u8 port2port;    /* Port num port connected to: 0,1,2, or  */
+                        /* 0xFF=None                              */
+       u8 chassis_num;  /* 1 based Chassis number (1 = boot node) */
+} __attribute__((packed));
+
+struct rio_detail {
+       u8 node_id;      /* RIO Node ID                            */
+       u32 BBAR;        /* Address of 1MB register space          */
+       u8 type;         /* Type of device                         */
+       u8 owner_id;     /* Node ID of Hurricane that owns this    */
+                        /* node                                   */
+       u8 port0node;    /* Node ID port connected to: 0xFF=None   */
+       u8 port0port;    /* Port num port connected to: 0,1,2, or  */
+                        /* 0xFF=None                              */
+       u8 port1node;    /* Node ID port connected to: 0xFF=None   */
+       u8 port1port;    /* Port num port connected to: 0,1,2, or  */
+                        /* 0xFF=None                              */
+       u8 first_slot;   /* Lowest slot number below this Calgary  */
+       u8 status;       /* Bit 0 = 1 : the XAPIC is used          */
+                        /*       = 0 : the XAPIC is not used, ie: */
+                        /*            ints fwded to another XAPIC */
+                        /*           Bits1:7 Reserved             */
+       u8 WP_index;     /* instance index - lower ones have       */
+                        /*     lower slot numbers/PCI bus numbers */
+       u8 chassis_num;  /* 1 based Chassis number                 */
+} __attribute__((packed));
+
+enum {
+       HURR_SCALABILTY = 0,  /* Hurricane Scalability info */
+       HURR_RIOIB      = 2,  /* Hurricane RIOIB info       */
+       COMPAT_CALGARY  = 4,  /* Compatibility Calgary      */
+       ALT_CALGARY     = 5,  /* Second Planar Calgary      */
+};
+
+/*
+ * there is a real-mode segmented pointer pointing to the
+ * 4K EBDA area at 0x40E.
+ */
+static inline unsigned long get_bios_ebda(void)
+{
+       unsigned long address = *(unsigned short *)phys_to_virt(0x40EUL);
+       address <<= 4;
+       return address;
+}
+
+#endif /* __ASM_RIO_H */
index d6b7c057edbaf281ddb97963e027e17931a01211..e17b9ec42e98d105d61d373ce47a828f8e6eaabc 100644 (file)
@@ -82,11 +82,6 @@ extern u8 x86_cpu_to_apicid[NR_CPUS];        /* physical ID */
 extern u8 x86_cpu_to_log_apicid[NR_CPUS];
 extern u8 bios_cpu_apicid[];
 
-static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
-{
-       return cpus_addr(cpumask)[0];
-}
-
 static inline int cpu_present_to_apicid(int mps_cpu)
 {
        if (mps_cpu < NR_CPUS)
@@ -118,13 +113,6 @@ static __inline int logical_smp_processor_id(void)
 #define cpu_physical_id(cpu)           x86_cpu_to_apicid[cpu]
 #else
 #define cpu_physical_id(cpu)           boot_cpu_id
-static inline int smp_call_function_single(int cpuid, void (*func) (void *info),
-                               void *info, int retry, int wait)
-{
-       /* Disable interrupts here? */
-       func(info);
-       return 0;
-}
 #endif /* !CONFIG_SMP */
 #endif
 
index 05ef097ba55b26dccd45d997417228ad79a110ba..88bf981e73cf45c084c66d6d60c25e066fa53340 100644 (file)
@@ -36,7 +36,34 @@ static inline void __raw_spin_lock(raw_spinlock_t *lock)
                "2:\t" : "=m" (lock->slock) : : "memory");
 }
 
-#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
+/*
+ * Same as __raw_spin_lock, but reenable interrupts during spinning.
+ */
+#ifndef CONFIG_PROVE_LOCKING
+static inline void __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags)
+{
+       asm volatile(
+               "\n1:\t"
+               LOCK_PREFIX " ; decl %0\n\t"
+               "jns 5f\n"
+               "testl $0x200, %1\n\t"  /* interrupts were disabled? */
+               "jz 4f\n\t"
+               "sti\n"
+               "3:\t"
+               "rep;nop\n\t"
+               "cmpl $0, %0\n\t"
+               "jle 3b\n\t"
+               "cli\n\t"
+               "jmp 1b\n"
+               "4:\t"
+               "rep;nop\n\t"
+               "cmpl $0, %0\n\t"
+               "jg 1b\n\t"
+               "jmp 4b\n"
+               "5:\n\t"
+               : "+m" (lock->slock) : "r" ((unsigned)flags) : "memory");
+}
+#endif
 
 static inline int __raw_spin_trylock(raw_spinlock_t *lock)
 {
index 5eb9799bef76fcc77053c2529d5177b08ca6a541..6f0b5459430739c0d60b936a28233e6841b23aa5 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef _ASM_STACKTRACE_H
 #define _ASM_STACKTRACE_H 1
 
+extern int kstack_depth_to_print;
+
 /* Generic stack tracer with callbacks */
 
 struct stacktrace_ops {
index bd950946e52c7979005a21814322e86abbc8a20e..6cfc3bb10c1a48ff49c11e33e117ef94b31a8033 100644 (file)
@@ -17,6 +17,28 @@ struct termios {
        cc_t c_cc[NCCS];                /* control characters */
 };
 
+struct termios2 {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
+struct ktermios {
+       tcflag_t c_iflag;               /* input mode flags */
+       tcflag_t c_oflag;               /* output mode flags */
+       tcflag_t c_cflag;               /* control mode flags */
+       tcflag_t c_lflag;               /* local mode flags */
+       cc_t c_line;                    /* line discipline */
+       cc_t c_cc[NCCS];                /* control characters */
+       speed_t c_ispeed;               /* input speed */
+       speed_t c_ospeed;               /* output speed */
+};
+
 /* c_cc characters */
 #define VINTR 0
 #define VQUIT 1
@@ -118,6 +140,7 @@ struct termios {
 #define HUPCL  0002000
 #define CLOCAL 0004000
 #define CBAUDEX 0010000
+#define           BOTHER 0010000               /* non standard rate */
 #define    B57600 0010001
 #define   B115200 0010002
 #define   B230400 0010003
@@ -133,10 +156,12 @@ struct termios {
 #define  B3000000 0010015
 #define  B3500000 0010016
 #define  B4000000 0010017
-#define CIBAUD   002003600000  /* input baud rate (not used) */
+#define CIBAUD   002003600000  /* input baud rate */
 #define CMSPAR   010000000000          /* mark or space (stick) parity */
 #define CRTSCTS          020000000000          /* flow control */
 
+#define IBSHIFT          8             /* Shift from CBAUD to CIBAUD */
+
 /* c_lflag bits */
 #define ISIG   0000001
 #define ICANON 0000002
index 041a91f7ddfb9779c18156e3a5287b36a4f96a37..443b225537f0bd61ecc4e18f22b5d0997a67bdb1 100644 (file)
@@ -98,8 +98,10 @@ struct termio {
        copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
 })
 
-#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
-#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
+#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios2))
+#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios2))
+#define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios))
+#define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios))
 
 #endif /* __KERNEL__ */
 
index 777288eb7e75ecc5272599a3995874162ab4c1b2..c5f596e71faa71f9cf03d127119f5599653fe11e 100644 (file)
@@ -622,25 +622,7 @@ __SYSCALL(__NR_move_pages, sys_move_pages)
 
 #define __NR_syscall_max __NR_move_pages
 
-#ifdef __KERNEL__
-#include <linux/err.h>
-#endif
-
 #ifndef __NO_STUBS
-
-/* user-visible error numbers are in the range -1 - -MAX_ERRNO */
-
-#define __syscall_clobber "r11","rcx","memory" 
-
-#define __syscall_return(type, res) \
-do { \
-       if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
-               errno = -(res); \
-               res = -1; \
-       } \
-       return (type) (res); \
-} while (0)
-
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_OLD_STAT
 #define __ARCH_WANT_SYS_ALARM
@@ -664,87 +646,6 @@ do { \
 #define __ARCH_WANT_SYS_TIME
 #define __ARCH_WANT_COMPAT_SYS_TIME
 
-#define __syscall "syscall"
-
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-long __res; \
-__asm__ volatile (__syscall \
-       : "=a" (__res) \
-       : "0" (__NR_##name) : __syscall_clobber ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-long __res; \
-__asm__ volatile (__syscall \
-       : "=a" (__res) \
-       : "0" (__NR_##name),"D" ((long)(arg1)) : __syscall_clobber ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-long __res; \
-__asm__ volatile (__syscall \
-       : "=a" (__res) \
-       : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)) : __syscall_clobber ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-long __res; \
-__asm__ volatile (__syscall \
-       : "=a" (__res) \
-       : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
-                 "d" ((long)(arg3)) : __syscall_clobber); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-long __res; \
-__asm__ volatile ("movq %5,%%r10 ;" __syscall \
-       : "=a" (__res) \
-       : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
-         "d" ((long)(arg3)),"g" ((long)(arg4)) : __syscall_clobber,"r10" ); \
-__syscall_return(type,__res); \
-} 
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-         type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-long __res; \
-__asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " __syscall \
-       : "=a" (__res) \
-       : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
-         "d" ((long)(arg3)),"g" ((long)(arg4)),"g" ((long)(arg5)) : \
-       __syscall_clobber,"r8","r10" ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-         type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
-{ \
-long __res; \
-__asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; movq %7,%%r9 ; " __syscall \
-       : "=a" (__res) \
-       : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
-         "d" ((long)(arg3)), "g" ((long)(arg4)), "g" ((long)(arg5)), \
-         "g" ((long)(arg6)) : \
-       __syscall_clobber,"r8","r10","r9" ); \
-__syscall_return(type,__res); \
-}
-
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
 
index 2e7ff10fd7751db2e967101c4b7749ad32b7f3a8..2f6349e4871765aaee69e23275c0755e4a9d98da 100644 (file)
@@ -87,14 +87,10 @@ extern int arch_unwind_init_running(struct unwind_frame_info *,
 
 static inline int arch_unw_user_mode(const struct unwind_frame_info *info)
 {
-#if 0 /* This can only work when selector register saves/restores
-         are properly annotated (and tracked in UNW_REGISTER_INFO). */
-       return user_mode(&info->regs);
-#else
-       return (long)info->regs.rip >= 0
+       return user_mode(&info->regs)
+              || (long)info->regs.rip >= 0
               || (info->regs.rip >= VSYSCALL_START && info->regs.rip < VSYSCALL_END)
               || (long)info->regs.rsp >= 0;
-#endif
 }
 
 #else
index 01d1c17e2849abb50a2bf4bffb4185a726d886f5..05cb8dd200de7742456de435aa31c586b5df2776 100644 (file)
@@ -10,6 +10,7 @@ enum vsyscall_num {
 #define VSYSCALL_START (-10UL << 20)
 #define VSYSCALL_SIZE 1024
 #define VSYSCALL_END (-2UL << 20)
+#define VSYSCALL_MAPPED_PAGES 1
 #define VSYSCALL_ADDR(vsyscall_nr) (VSYSCALL_START+VSYSCALL_SIZE*(vsyscall_nr))
 
 #ifdef __KERNEL__
index c39c91dfcc695a55e16933d60974310460987151..82b03b3a2ee6a4103726e69006319ba84158fb1e 100644 (file)
@@ -170,10 +170,10 @@ dma_get_cache_alignment(void)
        return L1_CACHE_BYTES;
 }
 
-#define dma_is_consistent(d)   (1)
+#define dma_is_consistent(d, h)        (1)
 
 static inline void
-dma_cache_sync(void *vaddr, size_t size,
+dma_cache_sync(struct device *dev, void *vaddr, size_t size,
               enum dma_data_direction direction)
 {
        consistent_sync(vaddr, size, direction);
index 411f810a55c604e0e5e5e77eede58f69dab8ddd8..2e1a1b997e7d7f89ede319c9029ec8ef90437458 100644 (file)
 
 #define SYSXTENSA_COUNT                   5    /* count of syscall0 functions*/
 
-#ifdef __KERNEL__
-#include <linux/linkage.h>
-
-#define __syscall_return(type, res) return ((type)(res))
-
-/* Tensilica's xt-xcc compiler is much more agressive at code
- * optimization than gcc.  Multiple __asm__ statements are
- * insufficient for xt-xcc because subsequent optimization passes
- * (beyond the front-end that knows of __asm__ statements and other
- * such GNU Extensions to C) can modify the register selection for
- * containment of C variables.
- *
- * xt-xcc cannot modify the contents of a single __asm__ statement, so
- * we create single-asm versions of the syscall macros that are
- * suitable and optimal for both xt-xcc and gcc.
- *
- * Linux takes system-call arguments in registers.  The following
- * design is optimized for user-land apps (e.g., glibc) which
- * typically have a function wrapper around the "syscall" assembly
- * instruction.  It satisfies the Xtensa ABI while minizing argument
- * shifting.
- *
- * The Xtensa ABI and software conventions require the system-call
- * number in a2.  If an argument exists in a2, we move it to the next
- * available register.  Note that for improved efficiency, we do NOT
- * shift all parameters down one register to maintain the original
- * order.
- *
- * At best case (zero arguments), we just write the syscall number to
- * a2.  At worst case (1 to 6 arguments), we move the argument in a2
- * to the next available register, then write the syscall number to
- * a2.
- *
- * For clarity, the following truth table enumerates all possibilities.
- *
- * arguments   syscall number  arg0, arg1, arg2, arg3, arg4, arg5
- * ---------   --------------  ----------------------------------
- *     0             a2
- *     1             a2        a3
- *     2             a2        a4,   a3
- *     3             a2        a5,   a3,   a4
- *     4             a2        a6,   a3,   a4,   a5
- *     5             a2        a7,   a3,   a4,   a5,   a6
- *     6             a2        a8,   a3,   a4,   a5,   a6,   a7
- */
-
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-long __res; \
-__asm__ __volatile__ ( \
-       "  movi  a2, %1 \n" \
-       "  syscall      \n" \
-       "  mov   %0, a2 \n" \
-       : "=a" (__res) \
-       : "i" (__NR_##name) \
-       : "a2" \
-       ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall1(type,name,type0,arg0) \
-type name(type0 arg0) \
-{ \
-long __res; \
-__asm__ __volatile__ ( \
-       "  mov   a3, %2 \n" \
-       "  movi  a2, %1 \n" \
-       "  syscall      \n" \
-       "  mov   %0, a2 \n" \
-       : "=a" (__res) \
-       : "i" (__NR_##name), "a" (arg0) \
-       : "a2", "a3" \
-       ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall2(type,name,type0,arg0,type1,arg1) \
-type name(type0 arg0,type1 arg1) \
-{ \
-long __res; \
-__asm__ __volatile__ ( \
-       "  mov   a4, %2 \n" \
-       "  mov   a3, %3 \n" \
-       "  movi  a2, %1 \n" \
-       "  syscall      \n" \
-       "  mov   %0, a2 \n" \
-       : "=a" (__res) \
-       : "i" (__NR_##name), "a" (arg0), "a" (arg1) \
-       : "a2", "a3", "a4" \
-       ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall3(type,name,type0,arg0,type1,arg1,type2,arg2) \
-type name(type0 arg0,type1 arg1,type2 arg2) \
-{ \
-long __res; \
-__asm__ __volatile__ ( \
-       "  mov   a5, %2 \n" \
-       "  mov   a4, %4 \n" \
-       "  mov   a3, %3 \n" \
-       "  movi  a2, %1 \n" \
-       "  syscall      \n" \
-       "  mov   %0, a2 \n" \
-       : "=a" (__res) \
-       : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2) \
-       : "a2", "a3", "a4", "a5" \
-       ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall4(type,name,type0,arg0,type1,arg1,type2,arg2,type3,arg3) \
-type name(type0 arg0,type1 arg1,type2 arg2,type3 arg3) \
-{ \
-long __res; \
-__asm__ __volatile__ ( \
-       "  mov   a6, %2 \n" \
-       "  mov   a5, %5 \n" \
-       "  mov   a4, %4 \n" \
-       "  mov   a3, %3 \n" \
-       "  movi  a2, %1 \n" \
-       "  syscall      \n" \
-       "  mov   %0, a2 \n" \
-       : "=a" (__res) \
-       : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2), "a" (arg3) \
-       : "a2", "a3", "a4", "a5", "a6" \
-       ); \
-__syscall_return(type,__res); \
-}
-
-/* Note that we save and restore the a7 frame pointer.
- * Including a7 in the clobber list doesn't do what you'd expect.
- */
-#define _syscall5(type,name,type0,arg0,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name(type0 arg0,type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
-{ \
-long __res; \
-__asm__ __volatile__ ( \
-       "  mov   a9, a7 \n" \
-       "  mov   a7, %2 \n" \
-       "  mov   a6, %6 \n" \
-       "  mov   a5, %5 \n" \
-       "  mov   a4, %4 \n" \
-       "  mov   a3, %3 \n" \
-       "  movi  a2, %1 \n" \
-       "  syscall      \n" \
-       "  mov   a7, a9 \n" \
-       "  mov   %0, a2 \n" \
-       : "=a" (__res) \
-       : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2), \
-                             "a" (arg3), "a" (arg4) \
-       : "a2", "a3", "a4", "a5", "a6", "a9" \
-       ); \
-__syscall_return(type,__res); \
-}
-
-/* Note that we save and restore the a7 frame pointer.
- * Including a7 in the clobber list doesn't do what you'd expect.
- */
-#define _syscall6(type,name,type0,arg0,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
-type name(type0 arg0,type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-long __res; \
-__asm__ __volatile__ ( \
-       "  mov   a9, a7 \n" \
-       "  mov   a8, %2 \n" \
-       "  mov   a7, %7 \n" \
-       "  mov   a6, %6 \n" \
-       "  mov   a5, %5 \n" \
-       "  mov   a4, %4 \n" \
-       "  mov   a3, %3 \n" \
-       "  movi  a2, %1 \n" \
-       "  syscall      \n" \
-       "  mov   a7, a9 \n" \
-       "  mov   %0, a2 \n" \
-       : "=a" (__res) \
-       : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2), \
-                             "a" (arg3), "a" (arg4), "a" (arg5)  \
-       : "a2", "a3", "a4", "a5", "a6", "a8", "a9" \
-       ); \
-__syscall_return(type,__res); \
-}
-
 /*
  * "Conditional" syscalls
  *
diff --git a/include/crypto/b128ops.h b/include/crypto/b128ops.h
new file mode 100644 (file)
index 0000000..0b8e6bc
--- /dev/null
@@ -0,0 +1,80 @@
+/* b128ops.h - common 128-bit block operations
+ *
+ * Copyright (c) 2003, Dr Brian Gladman, Worcester, UK.
+ * Copyright (c) 2006, Rik Snel <rsnel@cube.dyndns.org>
+ *
+ * Based on Dr Brian Gladman's (GPL'd) work published at
+ * http://fp.gladman.plus.com/cryptography_technology/index.htm
+ * See the original copyright notice below.
+ *
+ * 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.
+ */
+/*
+ ---------------------------------------------------------------------------
+ Copyright (c) 2003, Dr Brian Gladman, Worcester, UK.   All rights reserved.
+
+ LICENSE TERMS
+
+ The free distribution and use of this software in both source and binary
+ form is allowed (with or without changes) provided that:
+
+   1. distributions of this source code include the above copyright
+      notice, this list of conditions and the following disclaimer;
+
+   2. distributions in binary form include the above copyright
+      notice, this list of conditions and the following disclaimer
+      in the documentation and/or other associated materials;
+
+   3. the copyright holder's name is not used to endorse products
+      built using this software without specific written permission.
+
+ ALTERNATIVELY, provided that this notice is retained in full, this product
+ may be distributed under the terms of the GNU General Public License (GPL),
+ in which case the provisions of the GPL apply INSTEAD OF those given above.
+
+ DISCLAIMER
+
+ This software is provided 'as is' with no explicit or implied warranties
+ in respect of its properties, including, but not limited to, correctness
+ and/or fitness for purpose.
+ ---------------------------------------------------------------------------
+ Issue Date: 13/06/2006
+*/
+
+#ifndef _CRYPTO_B128OPS_H
+#define _CRYPTO_B128OPS_H
+
+#include <linux/types.h>
+
+typedef struct {
+       u64 a, b;
+} u128;
+
+typedef struct {
+       __be64 a, b;
+} be128;
+
+typedef struct {
+       __le64 b, a;
+} le128;
+
+static inline void u128_xor(u128 *r, const u128 *p, const u128 *q)
+{
+       r->a = p->a ^ q->a;
+       r->b = p->b ^ q->b;
+}
+
+static inline void be128_xor(be128 *r, const be128 *p, const be128 *q)
+{
+       u128_xor((u128 *)r, (u128 *)p, (u128 *)q);
+}
+
+static inline void le128_xor(le128 *r, const le128 *p, const le128 *q)
+{
+       u128_xor((u128 *)r, (u128 *)p, (u128 *)q);
+}
+
+#endif /* _CRYPTO_B128OPS_H */
diff --git a/include/crypto/gf128mul.h b/include/crypto/gf128mul.h
new file mode 100644 (file)
index 0000000..4fd3152
--- /dev/null
@@ -0,0 +1,198 @@
+/* gf128mul.h - GF(2^128) multiplication functions
+ *
+ * Copyright (c) 2003, Dr Brian Gladman, Worcester, UK.
+ * Copyright (c) 2006 Rik Snel <rsnel@cube.dyndns.org>
+ *
+ * Based on Dr Brian Gladman's (GPL'd) work published at
+ * http://fp.gladman.plus.com/cryptography_technology/index.htm
+ * See the original copyright notice below.
+ *
+ * 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.
+ */
+/*
+ ---------------------------------------------------------------------------
+ Copyright (c) 2003, Dr Brian Gladman, Worcester, UK.   All rights reserved.
+
+ LICENSE TERMS
+
+ The free distribution and use of this software in both source and binary
+ form is allowed (with or without changes) provided that:
+
+   1. distributions of this source code include the above copyright
+      notice, this list of conditions and the following disclaimer;
+
+   2. distributions in binary form include the above copyright
+      notice, this list of conditions and the following disclaimer
+      in the documentation and/or other associated materials;
+
+   3. the copyright holder's name is not used to endorse products
+      built using this software without specific written permission.
+
+ ALTERNATIVELY, provided that this notice is retained in full, this product
+ may be distributed under the terms of the GNU General Public License (GPL),
+ in which case the provisions of the GPL apply INSTEAD OF those given above.
+
+ DISCLAIMER
+
+ This software is provided 'as is' with no explicit or implied warranties
+ in respect of its properties, including, but not limited to, correctness
+ and/or fitness for purpose.
+ ---------------------------------------------------------------------------
+ Issue Date: 31/01/2006
+
+ An implementation of field multiplication in Galois Field GF(128)
+*/
+
+#ifndef _CRYPTO_GF128MUL_H
+#define _CRYPTO_GF128MUL_H
+
+#include <crypto/b128ops.h>
+#include <linux/slab.h>
+
+/* Comment by Rik:
+ *
+ * For some background on GF(2^128) see for example: http://-
+ * csrc.nist.gov/CryptoToolkit/modes/proposedmodes/gcm/gcm-revised-spec.pdf
+ *
+ * The elements of GF(2^128) := GF(2)[X]/(X^128-X^7-X^2-X^1-1) can
+ * be mapped to computer memory in a variety of ways. Let's examine
+ * three common cases.
+ *
+ * Take a look at the 16 binary octets below in memory order. The msb's
+ * are left and the lsb's are right. char b[16] is an array and b[0] is
+ * the first octet.
+ *
+ * 80000000 00000000 00000000 00000000 .... 00000000 00000000 00000000
+ *   b[0]     b[1]     b[2]     b[3]          b[13]    b[14]    b[15]
+ *
+ * Every bit is a coefficient of some power of X. We can store the bits
+ * in every byte in little-endian order and the bytes themselves also in
+ * little endian order. I will call this lle (little-little-endian).
+ * The above buffer represents the polynomial 1, and X^7+X^2+X^1+1 looks
+ * like 11100001 00000000 .... 00000000 = { 0xE1, 0x00, }.
+ * This format was originally implemented in gf128mul and is used
+ * in GCM (Galois/Counter mode) and in ABL (Arbitrary Block Length).
+ *
+ * Another convention says: store the bits in bigendian order and the
+ * bytes also. This is bbe (big-big-endian). Now the buffer above
+ * represents X^127. X^7+X^2+X^1+1 looks like 00000000 .... 10000111,
+ * b[15] = 0x87 and the rest is 0. LRW uses this convention and bbe
+ * is partly implemented.
+ *
+ * Both of the above formats are easy to implement on big-endian
+ * machines.
+ *
+ * EME (which is patent encumbered) uses the ble format (bits are stored
+ * in big endian order and the bytes in little endian). The above buffer
+ * represents X^7 in this case and the primitive polynomial is b[0] = 0x87.
+ *
+ * The common machine word-size is smaller than 128 bits, so to make
+ * an efficient implementation we must split into machine word sizes.
+ * This file uses one 32bit for the moment. Machine endianness comes into
+ * play. The lle format in relation to machine endianness is discussed
+ * below by the original author of gf128mul Dr Brian Gladman.
+ *
+ * Let's look at the bbe and ble format on a little endian machine.
+ *
+ * bbe on a little endian machine u32 x[4]:
+ *
+ *  MS            x[0]           LS  MS            x[1]                  LS
+ *  ms   ls ms   ls ms   ls ms   ls  ms   ls ms   ls ms   ls ms   ls
+ *  103..96 111.104 119.112 127.120  71...64 79...72 87...80 95...88
+ *
+ *  MS            x[2]           LS  MS            x[3]                  LS
+ *  ms   ls ms   ls ms   ls ms   ls  ms   ls ms   ls ms   ls ms   ls
+ *  39...32 47...40 55...48 63...56  07...00 15...08 23...16 31...24
+ *
+ * ble on a little endian machine
+ *
+ *  MS            x[0]           LS  MS            x[1]                  LS
+ *  ms   ls ms   ls ms   ls ms   ls  ms   ls ms   ls ms   ls ms   ls
+ *  31...24 23...16 15...08 07...00  63...56 55...48 47...40 39...32
+ *
+ *  MS            x[2]           LS  MS            x[3]                  LS
+ *  ms   ls ms   ls ms   ls ms   ls  ms   ls ms   ls ms   ls ms   ls
+ *  95...88 87...80 79...72 71...64  127.120 199.112 111.104 103..96
+ *
+ * Multiplications in GF(2^128) are mostly bit-shifts, so you see why
+ * ble (and lbe also) are easier to implement on a little-endian
+ * machine than on a big-endian machine. The converse holds for bbe
+ * and lle.
+ *
+ * Note: to have good alignment, it seems to me that it is sufficient
+ * to keep elements of GF(2^128) in type u64[2]. On 32-bit wordsize
+ * machines this will automatically aligned to wordsize and on a 64-bit
+ * machine also.
+ */
+/*     Multiply a GF128 field element by x. Field elements are held in arrays
+    of bytes in which field bits 8n..8n + 7 are held in byte[n], with lower
+    indexed bits placed in the more numerically significant bit positions
+    within bytes.
+
+    On little endian machines the bit indexes translate into the bit
+    positions within four 32-bit words in the following way
+
+    MS            x[0]           LS  MS            x[1]                  LS
+    ms   ls ms   ls ms   ls ms   ls  ms   ls ms   ls ms   ls ms   ls
+    24...31 16...23 08...15 00...07  56...63 48...55 40...47 32...39
+
+    MS            x[2]           LS  MS            x[3]                  LS
+    ms   ls ms   ls ms   ls ms   ls  ms   ls ms   ls ms   ls ms   ls
+    88...95 80...87 72...79 64...71  120.127 112.119 104.111 96..103
+
+    On big endian machines the bit indexes translate into the bit
+    positions within four 32-bit words in the following way
+
+    MS            x[0]           LS  MS            x[1]                  LS
+    ms   ls ms   ls ms   ls ms   ls  ms   ls ms   ls ms   ls ms   ls
+    00...07 08...15 16...23 24...31  32...39 40...47 48...55 56...63
+
+    MS            x[2]           LS  MS            x[3]                  LS
+    ms   ls ms   ls ms   ls ms   ls  ms   ls ms   ls ms   ls ms   ls
+    64...71 72...79 80...87 88...95  96..103 104.111 112.119 120.127
+*/
+
+/*     A slow generic version of gf_mul, implemented for lle and bbe
+ *     It multiplies a and b and puts the result in a */
+void gf128mul_lle(be128 *a, const be128 *b);
+
+void gf128mul_bbe(be128 *a, const be128 *b);
+
+
+/* 4k table optimization */
+
+struct gf128mul_4k {
+       be128 t[256];
+};
+
+struct gf128mul_4k *gf128mul_init_4k_lle(const be128 *g);
+struct gf128mul_4k *gf128mul_init_4k_bbe(const be128 *g);
+void gf128mul_4k_lle(be128 *a, struct gf128mul_4k *t);
+void gf128mul_4k_bbe(be128 *a, struct gf128mul_4k *t);
+
+static inline void gf128mul_free_4k(struct gf128mul_4k *t)
+{
+       kfree(t);
+}
+
+
+/* 64k table optimization, implemented for lle and bbe */
+
+struct gf128mul_64k {
+       struct gf128mul_4k *t[16];
+};
+
+/* first initialize with the constant factor with which you
+ * want to multiply and then call gf128_64k_lle with the other
+ * factor in the first argument, the table in the second and a
+ * scratch register in the third. Afterwards *a = *r. */
+struct gf128mul_64k *gf128mul_init_64k_lle(const be128 *g);
+struct gf128mul_64k *gf128mul_init_64k_bbe(const be128 *g);
+void gf128mul_free_64k(struct gf128mul_64k *t);
+void gf128mul_64k_lle(be128 *a, struct gf128mul_64k *t);
+void gf128mul_64k_bbe(be128 *a, struct gf128mul_64k *t);
+
+#endif /* _CRYPTO_GF128MUL_H */
index ff433126361fc51cd12e2063814dba2a96365262..e618b25b5addc94d65e8926aa9161e6ed24e6a05 100644 (file)
@@ -221,6 +221,7 @@ unifdef-y += if_bridge.h
 unifdef-y += if_ec.h
 unifdef-y += if_eql.h
 unifdef-y += if_ether.h
+unifdef-y += if_fddi.h
 unifdef-y += if_frad.h
 unifdef-y += if_ltalk.h
 unifdef-y += if_pppox.h
@@ -282,6 +283,7 @@ unifdef-y += nvram.h
 unifdef-y += parport.h
 unifdef-y += patchkey.h
 unifdef-y += pci.h
+unifdef-y += personality.h
 unifdef-y += pktcdvd.h
 unifdef-y += pmu.h
 unifdef-y += poll.h
@@ -337,6 +339,7 @@ unifdef-y += videodev.h
 unifdef-y += wait.h
 unifdef-y += wanrouter.h
 unifdef-y += watchdog.h
+unifdef-y += wireless.h
 unifdef-y += xfrm.h
 
 objhdr-y += version.h
index 9e350fd44d7787d061393d7512e65513d4cf960f..3372ec6bf53a25d5d65d540008f75bde975e1c13 100644 (file)
@@ -111,7 +111,6 @@ struct kiocb {
        size_t                  ki_nbytes;      /* copy of iocb->aio_nbytes */
        char                    __user *ki_buf; /* remaining iocb->aio_buf */
        size_t                  ki_left;        /* remaining bytes */
-       long                    ki_retried;     /* just for testing */
        struct iovec            ki_inline_vec;  /* inline vector */
        struct iovec            *ki_iovec;
        unsigned long           ki_nr_segs;
@@ -238,7 +237,6 @@ do {                                                                        \
 } while (0)
 
 #define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait)
-#define is_retried_kiocb(iocb) ((iocb)->ki_retried > 1)
 
 #include <linux/aio_abi.h>
 
index b2ca666d9997ce35025fd85f57c655639bdab0d2..0e07db6cc0d0eeefc1c58e2f4980016afe713d05 100644 (file)
 #define AUDIT_MAC_CIPSOV4_DEL  1408    /* NetLabel: del CIPSOv4 DOI entry */
 #define AUDIT_MAC_MAP_ADD      1409    /* NetLabel: add LSM domain mapping */
 #define AUDIT_MAC_MAP_DEL      1410    /* NetLabel: del LSM domain mapping */
+#define AUDIT_MAC_IPSEC_ADDSA  1411    /* Add a XFRM state */
+#define AUDIT_MAC_IPSEC_DELSA  1412    /* Delete a XFRM state */
+#define AUDIT_MAC_IPSEC_ADDSPD 1413    /* Add a XFRM policy */
+#define AUDIT_MAC_IPSEC_DELSPD 1414    /* Delete a XFRM policy */
 
 #define AUDIT_FIRST_KERN_ANOM_MSG   1700
 #define AUDIT_LAST_KERN_ANOM_MSG    1799
@@ -377,6 +381,7 @@ extern void auditsc_get_stamp(struct audit_context *ctx,
                              struct timespec *t, unsigned int *serial);
 extern int  audit_set_loginuid(struct task_struct *task, uid_t loginuid);
 extern uid_t audit_get_loginuid(struct audit_context *ctx);
+extern void audit_log_task_context(struct audit_buffer *ab);
 extern int __audit_ipc_obj(struct kern_ipc_perm *ipcp);
 extern int __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode);
 extern int audit_bprm(struct linux_binprm *bprm);
@@ -449,6 +454,7 @@ extern int audit_n_rules;
 #define audit_inode_update(i) do { ; } while (0)
 #define auditsc_get_stamp(c,t,s) do { BUG(); } while (0)
 #define audit_get_loginuid(c) ({ -1; })
+#define audit_log_task_context(b) do { ; } while (0)
 #define audit_ipc_obj(i) ({ 0; })
 #define audit_ipc_set_perm(q,u,g,m) ({ 0; })
 #define audit_bprm(p) ({ 0; })
diff --git a/include/linux/bitrev.h b/include/linux/bitrev.h
new file mode 100644 (file)
index 0000000..05e540d
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef _LINUX_BITREV_H
+#define _LINUX_BITREV_H
+
+#include <linux/types.h>
+
+extern u8 const byte_rev_table[256];
+
+static inline u8 bitrev8(u8 byte)
+{
+       return byte_rev_table[byte];
+}
+
+extern u32 bitrev32(u32 in);
+
+#endif /* _LINUX_BITREV_H */
index 31e9abb6d9775246c2533e4b89a39d41c896a907..2275f2748708045eddb6a41a21de4b2a60f0677b 100644 (file)
@@ -119,8 +119,7 @@ extern void *alloc_large_system_hash(const char *tablename,
                                     unsigned int *_hash_mask,
                                     unsigned long limit);
 
-#define HASH_HIGHMEM   0x00000001      /* Consider highmem? */
-#define HASH_EARLY     0x00000002      /* Allocating during early boot? */
+#define HASH_EARLY     0x00000001      /* Allocating during early boot? */
 
 /* Only NUMA needs hash distribution.
  * IA64 is known to have sufficient vmalloc space.
diff --git a/include/linux/bottom_half.h b/include/linux/bottom_half.h
new file mode 100644 (file)
index 0000000..777dbf6
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef _LINUX_BH_H
+#define _LINUX_BH_H
+
+extern void local_bh_disable(void);
+extern void __local_bh_enable(void);
+extern void _local_bh_enable(void);
+extern void local_bh_enable(void);
+extern void local_bh_enable_ip(unsigned long ip);
+
+#endif /* _LINUX_BH_H */
diff --git a/include/linux/bug.h b/include/linux/bug.h
new file mode 100644 (file)
index 0000000..42aa0a5
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef _LINUX_BUG_H
+#define _LINUX_BUG_H
+
+#include <linux/module.h>
+#include <asm/bug.h>
+
+enum bug_trap_type {
+       BUG_TRAP_TYPE_NONE = 0,
+       BUG_TRAP_TYPE_WARN = 1,
+       BUG_TRAP_TYPE_BUG = 2,
+};
+
+#ifdef CONFIG_GENERIC_BUG
+#include <asm-generic/bug.h>
+
+static inline int is_warning_bug(const struct bug_entry *bug)
+{
+       return bug->flags & BUGFLAG_WARNING;
+}
+
+const struct bug_entry *find_bug(unsigned long bugaddr);
+
+enum bug_trap_type report_bug(unsigned long bug_addr);
+
+int  module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *,
+                        struct module *);
+void module_bug_cleanup(struct module *);
+
+/* These are defined by the architecture */
+int is_valid_bugaddr(unsigned long addr);
+
+#else  /* !CONFIG_GENERIC_BUG */
+
+static inline enum bug_trap_type report_bug(unsigned long bug_addr)
+{
+       return BUG_TRAP_TYPE_BUG;
+}
+static inline int  module_bug_finalize(const Elf_Ehdr *hdr,
+                                       const Elf_Shdr *sechdrs,
+                                       struct module *mod)
+{
+       return 0;
+}
+static inline void module_bug_cleanup(struct module *mod) {}
+
+#endif /* CONFIG_GENERIC_BUG */
+#endif /* _LINUX_BUG_H */
diff --git a/include/linux/carta_random32.h b/include/linux/carta_random32.h
deleted file mode 100644 (file)
index f6f3bd9..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Fast, simple, yet decent quality random number generator based on
- * a paper by David G. Carta ("Two Fast Implementations of the
- * `Minimal Standard' Random Number Generator," Communications of the
- * ACM, January, 1990).
- *
- * Copyright (c) 2002-2006 Hewlett-Packard Development Company, L.P.
- *     Contributed by Stephane Eranian <eranian@hpl.hp.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * 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
- */
-#ifndef _LINUX_CARTA_RANDOM32_H_
-#define _LINUX_CARTA_RANDOM32_H_
-
-u64 carta_random32(u64 seed);
-
-#endif /* _LINUX_CARTA_RANDOM32_H_ */
index 6e27f42e3a57d12059800a088112b979aa7d5516..cb57c30081a8b0ee751d8c132b5af6bab3ac9da7 100644 (file)
@@ -80,7 +80,7 @@ typedef __u32 DriverVer_type;
 #define HWORD __u16
 #define DWORD __u32
 
-#define CISS_MAX_LUN   16      
+#define CISS_MAX_LUN   1024
 
 #define LEVEL2LUN   1   // index into Target(x) structure, due to byte swapping
 #define LEVEL3LUN   0
index ee5f53f2ca15a171c74cf3ec392b2b407dc22b8c..f309b00e986e2f6132cab0ec2d4f9ea5e3d9e7c3 100644 (file)
@@ -2,6 +2,10 @@
 #define _LINUX_CDEV_H
 #ifdef __KERNEL__
 
+#include <linux/kobject.h>
+#include <linux/kdev_t.h>
+#include <linux/list.h>
+
 struct cdev {
        struct kobject kobj;
        struct module *owner;
index f02d71bf6894ab769e0fa1bb55afc7b250ba140b..bfb520212d7109eafb9811d9df5f827dc0a9b5f6 100644 (file)
 #include <linux/compiler.h>
 #include <linux/cpumask.h>
 #include <asm/semaphore.h>
+#include <linux/mutex.h>
 
 struct cpu {
        int node_id;            /* The node which contains the CPU */
-       int no_control;         /* Should the sysfs control file be created? */
+       int hotpluggable;       /* creates sysfs control file if hotpluggable */
        struct sys_device sysdev;
 };
 
@@ -74,6 +75,17 @@ extern struct sysdev_class cpu_sysdev_class;
 
 #ifdef CONFIG_HOTPLUG_CPU
 /* Stop CPUs going up and down. */
+
+static inline void cpuhotplug_mutex_lock(struct mutex *cpu_hp_mutex)
+{
+       mutex_lock(cpu_hp_mutex);
+}
+
+static inline void cpuhotplug_mutex_unlock(struct mutex *cpu_hp_mutex)
+{
+       mutex_unlock(cpu_hp_mutex);
+}
+
 extern void lock_cpu_hotplug(void);
 extern void unlock_cpu_hotplug(void);
 #define hotcpu_notifier(fn, pri) {                             \
@@ -85,17 +97,24 @@ extern void unlock_cpu_hotplug(void);
 #define unregister_hotcpu_notifier(nb) unregister_cpu_notifier(nb)
 int cpu_down(unsigned int cpu);
 #define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
-#else
+
+#else          /* CONFIG_HOTPLUG_CPU */
+
+static inline void cpuhotplug_mutex_lock(struct mutex *cpu_hp_mutex)
+{ }
+static inline void cpuhotplug_mutex_unlock(struct mutex *cpu_hp_mutex)
+{ }
+
 #define lock_cpu_hotplug()     do { } while (0)
 #define unlock_cpu_hotplug()   do { } while (0)
 #define lock_cpu_hotplug_interruptible() 0
-#define hotcpu_notifier(fn, pri)       do { } while (0)
-#define register_hotcpu_notifier(nb)   do { } while (0)
-#define unregister_hotcpu_notifier(nb) do { } while (0)
+#define hotcpu_notifier(fn, pri)       do { (void)(fn); } while (0)
+#define register_hotcpu_notifier(nb)   do { (void)(nb); } while (0)
+#define unregister_hotcpu_notifier(nb) do { (void)(nb); } while (0)
 
 /* CPUs don't go offline once they're online w/o CONFIG_HOTPLUG_CPU */
 static inline int cpu_is_offline(int cpu) { return 0; }
-#endif
+#endif         /* CONFIG_HOTPLUG_CPU */
 
 #ifdef CONFIG_SUSPEND_SMP
 extern int disable_nonboot_cpus(void);
index 4d8adf6636810875b00f070dd548193e620b7015..8821e1f75b447856a041435d966eb12fb5c94941 100644 (file)
@@ -23,6 +23,7 @@ extern void cpuset_fork(struct task_struct *p);
 extern void cpuset_exit(struct task_struct *p);
 extern cpumask_t cpuset_cpus_allowed(struct task_struct *p);
 extern nodemask_t cpuset_mems_allowed(struct task_struct *p);
+#define cpuset_current_mems_allowed (current->mems_allowed)
 void cpuset_init_current_mems_allowed(void);
 void cpuset_update_task_memory_state(void);
 #define cpuset_nodes_subset_current_mems_allowed(nodes) \
@@ -45,7 +46,7 @@ extern int cpuset_excl_nodes_overlap(const struct task_struct *p);
 extern int cpuset_memory_pressure_enabled;
 extern void __cpuset_memory_pressure_bump(void);
 
-extern struct file_operations proc_cpuset_operations;
+extern const struct file_operations proc_cpuset_operations;
 extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer);
 
 extern void cpuset_lock(void);
@@ -83,6 +84,7 @@ static inline nodemask_t cpuset_mems_allowed(struct task_struct *p)
        return node_possible_map;
 }
 
+#define cpuset_current_mems_allowed (node_online_map)
 static inline void cpuset_init_current_mems_allowed(void) {}
 static inline void cpuset_update_task_memory_state(void) {}
 #define cpuset_nodes_subset_current_mems_allowed(nodes) (1)
index 56c0645789a9b3a3cd85d4ada7df068904aae907..e20dd1f9b40a75ed05e52ac7e40de8f3c5e6e151 100644 (file)
@@ -6,10 +6,10 @@
 #define _LINUX_CRC32_H
 
 #include <linux/types.h>
+#include <linux/bitrev.h>
 
 extern u32  crc32_le(u32 crc, unsigned char const *p, size_t len);
 extern u32  crc32_be(u32 crc, unsigned char const *p, size_t len);
-extern u32  bitreverse(u32 in);
 
 #define crc32(seed, data, length)  crc32_le(seed, (unsigned char const *)data, length)
 
@@ -21,7 +21,7 @@ extern u32  bitreverse(u32 in);
  * is in bit nr 0], thus it must be reversed before use. Except for
  * nics that bit swap the result internally...
  */
-#define ether_crc(length, data)    bitreverse(crc32_le(~0, data, length))
+#define ether_crc(length, data)    bitrev32(crc32_le(~0, data, length))
 #define ether_crc_le(length, data) crc32_le(~0, data, length)
 
 #endif /* _LINUX_CRC32_H */
index 6485e9716b36abbc9e0998a95eb35d3b313d41ae..4aa9046601da18e8c7d18a26b661197887bd6aec 100644 (file)
@@ -241,12 +241,8 @@ int crypto_unregister_alg(struct crypto_alg *alg);
  * Algorithm query interface.
  */
 #ifdef CONFIG_CRYPTO
-int crypto_alg_available(const char *name, u32 flags)
-       __deprecated_for_modules;
 int crypto_has_alg(const char *name, u32 type, u32 mask);
 #else
-static int crypto_alg_available(const char *name, u32 flags)
-       __deprecated_for_modules;
 static inline int crypto_alg_available(const char *name, u32 flags)
 {
        return 0;
@@ -707,16 +703,6 @@ static inline void crypto_cipher_decrypt_one(struct crypto_cipher *tfm,
                                                dst, src);
 }
 
-void crypto_digest_init(struct crypto_tfm *tfm) __deprecated_for_modules;
-void crypto_digest_update(struct crypto_tfm *tfm,
-                         struct scatterlist *sg, unsigned int nsg)
-       __deprecated_for_modules;
-void crypto_digest_final(struct crypto_tfm *tfm, u8 *out)
-       __deprecated_for_modules;
-void crypto_digest_digest(struct crypto_tfm *tfm,
-                         struct scatterlist *sg, unsigned int nsg, u8 *out)
-       __deprecated_for_modules;
-
 static inline struct crypto_hash *__crypto_hash_cast(struct crypto_tfm *tfm)
 {
        return (struct crypto_hash *)tfm;
@@ -729,14 +715,6 @@ static inline struct crypto_hash *crypto_hash_cast(struct crypto_tfm *tfm)
        return __crypto_hash_cast(tfm);
 }
 
-static int crypto_digest_setkey(struct crypto_tfm *tfm, const u8 *key,
-                               unsigned int keylen) __deprecated;
-static inline int crypto_digest_setkey(struct crypto_tfm *tfm,
-                                       const u8 *key, unsigned int keylen)
-{
-       return tfm->crt_hash.setkey(crypto_hash_cast(tfm), key, keylen);
-}
-
 static inline struct crypto_hash *crypto_alloc_hash(const char *alg_name,
                                                    u32 type, u32 mask)
 {
index 952bee79a8f30902328277a6d16920a53e4da12f..a1c10b0c4cf02ae072eea67d312dbd21c236557f 100644 (file)
@@ -24,7 +24,7 @@ extern int debug_locks_off(void);
        int __ret = 0;                                                  \
                                                                        \
        if (unlikely(c)) {                                              \
-               if (debug_locks_off())                                  \
+               if (debug_locks_silent || debug_locks_off())            \
                        WARN_ON(1);                                     \
                __ret = 1;                                              \
        }                                                               \
index 561e2a77805c582fdebcd3d588a222d8adec9a6c..55d1ca5e60f54f11efcfe7078a5e02cf3bb450fd 100644 (file)
@@ -30,7 +30,7 @@
 #ifdef CONFIG_TASK_DELAY_ACCT
 
 extern int delayacct_on;       /* Delay accounting turned on/off */
-extern kmem_cache_t *delayacct_cache;
+extern struct kmem_cache *delayacct_cache;
 extern void delayacct_init(void);
 extern void __delayacct_tsk_init(struct task_struct *);
 extern void __delayacct_tsk_exit(struct task_struct *);
index 03ef41c1eaac346b441a00a54048818b7f35c60f..499f5373e2134d7a1a0fa8b9a84bddc3ad23b26b 100644 (file)
@@ -39,7 +39,8 @@ typedef void (*dm_dtr_fn) (struct dm_target *ti);
  * The map function must return:
  * < 0: error
  * = 0: The target will handle the io by resubmitting it later
- * > 0: simple remap complete
+ * = 1: simple remap complete
+ * = 2: The target wants to push back the io
  */
 typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio,
                          union map_info *map_context);
@@ -50,6 +51,7 @@ typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio,
  * 0   : ended successfully
  * 1   : for some reason the io has still not completed (eg,
  *       multipath target might want to requeue a failed io).
+ * 2   : The target wants to push back the io
  */
 typedef int (*dm_endio_fn) (struct dm_target *ti,
                            struct bio *bio, int error,
@@ -173,7 +175,7 @@ void *dm_get_mdptr(struct mapped_device *md);
 /*
  * A device can still be used while suspended, but I/O is deferred.
  */
-int dm_suspend(struct mapped_device *md, int with_lockfs);
+int dm_suspend(struct mapped_device *md, unsigned suspend_flags);
 int dm_resume(struct mapped_device *md);
 
 /*
@@ -188,6 +190,7 @@ int dm_wait_event(struct mapped_device *md, int event_nr);
 const char *dm_device_name(struct mapped_device *md);
 struct gendisk *dm_disk(struct mapped_device *md);
 int dm_suspended(struct mapped_device *md);
+int dm_noflush_suspending(struct dm_target *ti);
 
 /*
  * Geometry functions.
index 583a341e016cea229ad8b04d4213d59974e3cbd3..49ab53ce92dc5d79a55218192de5a9b60d8934a0 100644 (file)
@@ -371,6 +371,9 @@ struct device {
                                           core doesn't touch it */
        struct dev_pm_info      power;
 
+#ifdef CONFIG_NUMA
+       int             numa_node;      /* NUMA node this device is close to */
+#endif
        u64             *dma_mask;      /* dma mask (if dma'able device) */
        u64             coherent_dma_mask;/* Like dma_mask, but for
                                             alloc_coherent mappings as
@@ -394,6 +397,25 @@ struct device {
        void    (*release)(struct device * dev);
 };
 
+#ifdef CONFIG_NUMA
+static inline int dev_to_node(struct device *dev)
+{
+       return dev->numa_node;
+}
+static inline void set_dev_node(struct device *dev, int node)
+{
+       dev->numa_node = node;
+}
+#else
+static inline int dev_to_node(struct device *dev)
+{
+       return -1;
+}
+static inline void set_dev_node(struct device *dev, int node)
+{
+}
+#endif
+
 static inline void *
 dev_get_drvdata (struct device *dev)
 {
index 8853fc4d1c5ebcd3b4f56749208057935955a208..b9348610782181429e24bc682627612d1bae7184 100644 (file)
@@ -285,9 +285,9 @@ typedef char ioctl_struct[308];
 #define DM_DEV_SET_GEOMETRY    _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
 
 #define DM_VERSION_MAJOR       4
-#define DM_VERSION_MINOR       10
+#define DM_VERSION_MINOR       11
 #define DM_VERSION_PATCHLEVEL  0
-#define DM_VERSION_EXTRA       "-ioctl (2006-09-14)"
+#define DM_VERSION_EXTRA       "-ioctl (2006-10-12)"
 
 /* Status bits */
 #define DM_READONLY_FLAG       (1 << 0) /* In/Out */
@@ -323,4 +323,9 @@ typedef char ioctl_struct[308];
  */
 #define DM_SKIP_LOCKFS_FLAG    (1 << 10) /* In */
 
+/*
+ * Set this to suspend without flushing queued ios.
+ */
+#define DM_NOFLUSH_FLAG                (1 << 11) /* In */
+
 #endif                         /* _LINUX_DM_IOCTL_H */
index 66d621dbcb6c850c9a2042338ba0732f79c5f637..df1c91855f0efa1336181a4552e9b6fa7cfb725e 100644 (file)
@@ -300,8 +300,9 @@ extern int efi_mem_attribute_range (unsigned long phys_addr, unsigned long size,
 extern int __init efi_uart_console_only (void);
 extern void efi_initialize_iomem_resources(struct resource *code_resource,
                                        struct resource *data_resource);
-extern unsigned long __init efi_get_time(void);
+extern unsigned long efi_get_time(void);
 extern int __init efi_set_rtc_mmss(unsigned long nowtime);
+extern int is_available_memory(efi_memory_desc_t * md);
 extern struct efi_memory_map memmap;
 
 /**
index 743d5c8e6d365ff1dfd52e12c3f74258c56d2753..60713e6ea2974f926b7cc52b9e2df143805bea32 100644 (file)
@@ -6,6 +6,8 @@
 #include <linux/elf-em.h>
 #include <asm/elf.h>
 
+struct file;
+
 #ifndef elf_read_implies_exec
   /* Executables for which elf_read_implies_exec() returns TRUE will
      have the READ_IMPLIES_EXEC personality flag set automatically.
@@ -358,6 +360,7 @@ extern Elf32_Dyn _DYNAMIC [];
 #define elfhdr         elf32_hdr
 #define elf_phdr       elf32_phdr
 #define elf_note       elf32_note
+#define elf_addr_t     Elf32_Off
 
 #else
 
@@ -365,6 +368,7 @@ extern Elf64_Dyn _DYNAMIC [];
 #define elfhdr         elf64_hdr
 #define elf_phdr       elf64_phdr
 #define elf_note       elf64_note
+#define elf_addr_t     Elf64_Off
 
 #endif
 
index ce0e6109aff0cdb83e05cd350909da82b5a50d99..8c43b13a02fe1df033f161ab91d69cdd7a389858 100644 (file)
@@ -109,74 +109,32 @@ int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode);
  * been done yet.
  */
 
-void ext3_journal_abort_handle(const char *caller, const char *err_fn,
-               struct buffer_head *bh, handle_t *handle, int err);
-
-static inline int
-__ext3_journal_get_undo_access(const char *where, handle_t *handle,
-                               struct buffer_head *bh)
+static inline void ext3_journal_release_buffer(handle_t *handle,
+                                               struct buffer_head *bh)
 {
-       int err = journal_get_undo_access(handle, bh);
-       if (err)
-               ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
-       return err;
+       journal_release_buffer(handle, bh);
 }
 
-static inline int
-__ext3_journal_get_write_access(const char *where, handle_t *handle,
-                               struct buffer_head *bh)
-{
-       int err = journal_get_write_access(handle, bh);
-       if (err)
-               ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
-       return err;
-}
+void ext3_journal_abort_handle(const char *caller, const char *err_fn,
+               struct buffer_head *bh, handle_t *handle, int err);
 
-static inline void
-ext3_journal_release_buffer(handle_t *handle, struct buffer_head *bh)
-{
-       journal_release_buffer(handle, bh);
-}
+int __ext3_journal_get_undo_access(const char *where, handle_t *handle,
+                               struct buffer_head *bh);
 
-static inline int
-__ext3_journal_forget(const char *where, handle_t *handle, struct buffer_head *bh)
-{
-       int err = journal_forget(handle, bh);
-       if (err)
-               ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
-       return err;
-}
+int __ext3_journal_get_write_access(const char *where, handle_t *handle,
+                               struct buffer_head *bh);
 
-static inline int
-__ext3_journal_revoke(const char *where, handle_t *handle,
-                     unsigned long blocknr, struct buffer_head *bh)
-{
-       int err = journal_revoke(handle, blocknr, bh);
-       if (err)
-               ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
-       return err;
-}
+int __ext3_journal_forget(const char *where, handle_t *handle,
+                               struct buffer_head *bh);
 
-static inline int
-__ext3_journal_get_create_access(const char *where,
-                                handle_t *handle, struct buffer_head *bh)
-{
-       int err = journal_get_create_access(handle, bh);
-       if (err)
-               ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
-       return err;
-}
+int __ext3_journal_revoke(const char *where, handle_t *handle,
+                               unsigned long blocknr, struct buffer_head *bh);
 
-static inline int
-__ext3_journal_dirty_metadata(const char *where,
-                             handle_t *handle, struct buffer_head *bh)
-{
-       int err = journal_dirty_metadata(handle, bh);
-       if (err)
-               ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
-       return err;
-}
+int __ext3_journal_get_create_access(const char *where,
+                               handle_t *handle, struct buffer_head *bh);
 
+int __ext3_journal_dirty_metadata(const char *where,
+                               handle_t *handle, struct buffer_head *bh);
 
 #define ext3_journal_get_undo_access(handle, bh) \
        __ext3_journal_get_undo_access(__FUNCTION__, (handle), (bh))
index 72dd631912e4aaee12ed65e6fb343bb7dfb5f4e0..d716e6392cf6e7e5d6215da354b20a1c96e1d495 100644 (file)
@@ -114,74 +114,32 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode);
  * been done yet.
  */
 
-void ext4_journal_abort_handle(const char *caller, const char *err_fn,
-               struct buffer_head *bh, handle_t *handle, int err);
-
-static inline int
-__ext4_journal_get_undo_access(const char *where, handle_t *handle,
-                               struct buffer_head *bh)
+static inline void ext4_journal_release_buffer(handle_t *handle,
+                                               struct buffer_head *bh)
 {
-       int err = jbd2_journal_get_undo_access(handle, bh);
-       if (err)
-               ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
-       return err;
+       jbd2_journal_release_buffer(handle, bh);
 }
 
-static inline int
-__ext4_journal_get_write_access(const char *where, handle_t *handle,
-                               struct buffer_head *bh)
-{
-       int err = jbd2_journal_get_write_access(handle, bh);
-       if (err)
-               ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
-       return err;
-}
+void ext4_journal_abort_handle(const char *caller, const char *err_fn,
+               struct buffer_head *bh, handle_t *handle, int err);
 
-static inline void
-ext4_journal_release_buffer(handle_t *handle, struct buffer_head *bh)
-{
-       jbd2_journal_release_buffer(handle, bh);
-}
+int __ext4_journal_get_undo_access(const char *where, handle_t *handle,
+                               struct buffer_head *bh);
 
-static inline int
-__ext4_journal_forget(const char *where, handle_t *handle, struct buffer_head *bh)
-{
-       int err = jbd2_journal_forget(handle, bh);
-       if (err)
-               ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
-       return err;
-}
+int __ext4_journal_get_write_access(const char *where, handle_t *handle,
+                               struct buffer_head *bh);
 
-static inline int
-__ext4_journal_revoke(const char *where, handle_t *handle,
-                     ext4_fsblk_t blocknr, struct buffer_head *bh)
-{
-       int err = jbd2_journal_revoke(handle, blocknr, bh);
-       if (err)
-               ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
-       return err;
-}
+int __ext4_journal_forget(const char *where, handle_t *handle,
+                               struct buffer_head *bh);
 
-static inline int
-__ext4_journal_get_create_access(const char *where,
-                                handle_t *handle, struct buffer_head *bh)
-{
-       int err = jbd2_journal_get_create_access(handle, bh);
-       if (err)
-               ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
-       return err;
-}
+int __ext4_journal_revoke(const char *where, handle_t *handle,
+                               ext4_fsblk_t blocknr, struct buffer_head *bh);
 
-static inline int
-__ext4_journal_dirty_metadata(const char *where,
-                             handle_t *handle, struct buffer_head *bh)
-{
-       int err = jbd2_journal_dirty_metadata(handle, bh);
-       if (err)
-               ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
-       return err;
-}
+int __ext4_journal_get_create_access(const char *where,
+                               handle_t *handle, struct buffer_head *bh);
 
+int __ext4_journal_dirty_metadata(const char *where,
+                               handle_t *handle, struct buffer_head *bh);
 
 #define ext4_journal_get_undo_access(handle, bh) \
        __ext4_journal_get_undo_access(__FUNCTION__, (handle), (bh))
diff --git a/include/linux/fault-inject.h b/include/linux/fault-inject.h
new file mode 100644 (file)
index 0000000..32368c4
--- /dev/null
@@ -0,0 +1,84 @@
+#ifndef _LINUX_FAULT_INJECT_H
+#define _LINUX_FAULT_INJECT_H
+
+#ifdef CONFIG_FAULT_INJECTION
+
+#include <linux/types.h>
+#include <linux/debugfs.h>
+#include <asm/atomic.h>
+
+/*
+ * For explanation of the elements of this struct, see
+ * Documentation/fault-injection/fault-injection.txt
+ */
+struct fault_attr {
+       unsigned long probability;
+       unsigned long interval;
+       atomic_t times;
+       atomic_t space;
+       unsigned long verbose;
+       u32 task_filter;
+       unsigned long stacktrace_depth;
+       unsigned long require_start;
+       unsigned long require_end;
+       unsigned long reject_start;
+       unsigned long reject_end;
+
+       unsigned long count;
+
+#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
+
+       struct {
+               struct dentry *dir;
+
+               struct dentry *probability_file;
+               struct dentry *interval_file;
+               struct dentry *times_file;
+               struct dentry *space_file;
+               struct dentry *verbose_file;
+               struct dentry *task_filter_file;
+               struct dentry *stacktrace_depth_file;
+               struct dentry *require_start_file;
+               struct dentry *require_end_file;
+               struct dentry *reject_start_file;
+               struct dentry *reject_end_file;
+       } dentries;
+
+#endif
+};
+
+#define FAULT_ATTR_INITIALIZER {                               \
+               .interval = 1,                                  \
+               .times = ATOMIC_INIT(1),                        \
+               .require_end = ULONG_MAX,                       \
+               .stacktrace_depth = 32,                         \
+               .verbose = 2,                                   \
+       }
+
+#define DECLARE_FAULT_ATTR(name) struct fault_attr name = FAULT_ATTR_INITIALIZER
+int setup_fault_attr(struct fault_attr *attr, char *str);
+void should_fail_srandom(unsigned long entropy);
+bool should_fail(struct fault_attr *attr, ssize_t size);
+
+#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
+
+int init_fault_attr_dentries(struct fault_attr *attr, const char *name);
+void cleanup_fault_attr_dentries(struct fault_attr *attr);
+
+#else /* CONFIG_FAULT_INJECTION_DEBUG_FS */
+
+static inline int init_fault_attr_dentries(struct fault_attr *attr,
+                                         const char *name)
+{
+       return -ENODEV;
+}
+
+static inline void cleanup_fault_attr_dentries(struct fault_attr *attr)
+{
+}
+
+#endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */
+
+#endif /* CONFIG_FAULT_INJECTION */
+
+#endif /* _LINUX_FAULT_INJECT_H */
index fa23e0671bb3be7a2423d486c8b028b3cdccdee3..6fe56aaa6685c3f2c04bd6ceb2f4af1d2c5bbd27 100644 (file)
@@ -970,11 +970,11 @@ extern struct fb_videomode *fb_find_best_display(struct fb_monspecs *specs,
 /* drivers/video/fbcmap.c */
 extern int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp);
 extern void fb_dealloc_cmap(struct fb_cmap *cmap);
-extern int fb_copy_cmap(struct fb_cmap *from, struct fb_cmap *to);
-extern int fb_cmap_to_user(struct fb_cmap *from, struct fb_cmap_user *to);
+extern int fb_copy_cmap(const struct fb_cmap *from, struct fb_cmap *to);
+extern int fb_cmap_to_user(const struct fb_cmap *from, struct fb_cmap_user *to);
 extern int fb_set_cmap(struct fb_cmap *cmap, struct fb_info *fb_info);
 extern int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *fb_info);
-extern struct fb_cmap *fb_default_cmap(int len);
+extern const struct fb_cmap *fb_default_cmap(int len);
 extern void fb_invert_cmaps(void);
 
 struct fb_videomode {
index 74183e6f7f458052c72d0bf3e8297c83a32ff18c..6e77b9177f9e86ffd552fd9dcae491bc6715a6b1 100644 (file)
@@ -64,6 +64,8 @@ struct files_struct {
 
 #define files_fdtable(files) (rcu_dereference((files)->fdt))
 
+extern struct kmem_cache *filp_cachep;
+
 extern void FASTCALL(__fput(struct file *));
 extern void FASTCALL(fput(struct file *));
 
@@ -114,4 +116,6 @@ struct files_struct *get_files_struct(struct task_struct *);
 void FASTCALL(put_files_struct(struct files_struct *fs));
 void reset_files_struct(struct task_struct *, struct files_struct *);
 
+extern struct kmem_cache *files_cachep;
+
 #endif /* __LINUX_FILE_H */
diff --git a/include/linux/freezer.h b/include/linux/freezer.h
new file mode 100644 (file)
index 0000000..6e05e3e
--- /dev/null
@@ -0,0 +1,87 @@
+/* Freezer declarations */
+
+#ifdef CONFIG_PM
+/*
+ * Check if a process has been frozen
+ */
+static inline int frozen(struct task_struct *p)
+{
+       return p->flags & PF_FROZEN;
+}
+
+/*
+ * Check if there is a request to freeze a process
+ */
+static inline int freezing(struct task_struct *p)
+{
+       return p->flags & PF_FREEZE;
+}
+
+/*
+ * Request that a process be frozen
+ * FIXME: SMP problem. We may not modify other process' flags!
+ */
+static inline void freeze(struct task_struct *p)
+{
+       p->flags |= PF_FREEZE;
+}
+
+/*
+ * Sometimes we may need to cancel the previous 'freeze' request
+ */
+static inline void do_not_freeze(struct task_struct *p)
+{
+       p->flags &= ~PF_FREEZE;
+}
+
+/*
+ * Wake up a frozen process
+ */
+static inline int thaw_process(struct task_struct *p)
+{
+       if (frozen(p)) {
+               p->flags &= ~PF_FROZEN;
+               wake_up_process(p);
+               return 1;
+       }
+       return 0;
+}
+
+/*
+ * freezing is complete, mark process as frozen
+ */
+static inline void frozen_process(struct task_struct *p)
+{
+       p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN;
+}
+
+extern void refrigerator(void);
+extern int freeze_processes(void);
+extern void thaw_processes(void);
+
+static inline int try_to_freeze(void)
+{
+       if (freezing(current)) {
+               refrigerator();
+               return 1;
+       } else
+               return 0;
+}
+
+extern void thaw_some_processes(int all);
+
+#else
+static inline int frozen(struct task_struct *p) { return 0; }
+static inline int freezing(struct task_struct *p) { return 0; }
+static inline void freeze(struct task_struct *p) { BUG(); }
+static inline int thaw_process(struct task_struct *p) { return 1; }
+static inline void frozen_process(struct task_struct *p) { BUG(); }
+
+static inline void refrigerator(void) {}
+static inline int freeze_processes(void) { BUG(); return 0; }
+static inline void thaw_processes(void) {}
+
+static inline int try_to_freeze(void) { return 0; }
+
+
+#endif
index cac7b1ef95435d5d1d2f67ae1bb0e1c8d2c51a7c..adce6e1d70c2cf0c20ec97ce628df2307e025d55 100644 (file)
@@ -269,6 +269,7 @@ extern int dir_notify_enable;
 #include <linux/types.h>
 #include <linux/kdev_t.h>
 #include <linux/dcache.h>
+#include <linux/namei.h>
 #include <linux/stat.h>
 #include <linux/cache.h>
 #include <linux/kobject.h>
@@ -481,21 +482,6 @@ struct block_device {
        unsigned long           bd_private;
 };
 
-/*
- * bdev->bd_mutex nesting subclasses for the lock validator:
- *
- * 0: normal
- * 1: 'whole'
- * 2: 'partition'
- */
-enum bdev_bd_mutex_lock_class
-{
-       BD_MUTEX_NORMAL,
-       BD_MUTEX_WHOLE,
-       BD_MUTEX_PARTITION
-};
-
-
 /*
  * Radix-tree tags, for tagging dirty and writeback pages within the pagecache
  * radix trees
@@ -543,19 +529,22 @@ struct inode {
        struct list_head        i_dentry;
        unsigned long           i_ino;
        atomic_t                i_count;
-       umode_t                 i_mode;
        unsigned int            i_nlink;
        uid_t                   i_uid;
        gid_t                   i_gid;
        dev_t                   i_rdev;
+       unsigned long           i_version;
        loff_t                  i_size;
+#ifdef __NEED_I_SIZE_ORDERED
+       seqcount_t              i_size_seqcount;
+#endif
        struct timespec         i_atime;
        struct timespec         i_mtime;
        struct timespec         i_ctime;
        unsigned int            i_blkbits;
-       unsigned long           i_version;
        blkcnt_t                i_blocks;
        unsigned short          i_bytes;
+       umode_t                 i_mode;
        spinlock_t              i_lock; /* i_blocks, i_bytes, maybe i_size */
        struct mutex            i_mutex;
        struct rw_semaphore     i_alloc_sem;
@@ -598,9 +587,6 @@ struct inode {
        void                    *i_security;
 #endif
        void                    *i_private; /* fs or device private pointer */
-#ifdef __NEED_I_SIZE_ORDERED
-       seqcount_t              i_size_seqcount;
-#endif
 };
 
 /*
@@ -636,7 +622,7 @@ extern void inode_double_unlock(struct inode *inode1, struct inode *inode2);
  * cmpxchg8b without the need of the lock prefix). For SMP compiles
  * and 64bit archs it makes no difference if preempt is enabled or not.
  */
-static inline loff_t i_size_read(struct inode *inode)
+static inline loff_t i_size_read(const struct inode *inode)
 {
 #if BITS_PER_LONG==32 && defined(CONFIG_SMP)
        loff_t i_size;
@@ -679,12 +665,12 @@ static inline void i_size_write(struct inode *inode, loff_t i_size)
 #endif
 }
 
-static inline unsigned iminor(struct inode *inode)
+static inline unsigned iminor(const struct inode *inode)
 {
        return MINOR(inode->i_rdev);
 }
 
-static inline unsigned imajor(struct inode *inode)
+static inline unsigned imajor(const struct inode *inode)
 {
        return MAJOR(inode->i_rdev);
 }
@@ -726,8 +712,9 @@ struct file {
                struct list_head        fu_list;
                struct rcu_head         fu_rcuhead;
        } f_u;
-       struct dentry           *f_dentry;
-       struct vfsmount         *f_vfsmnt;
+       struct path             f_path;
+#define f_dentry       f_path.dentry
+#define f_vfsmnt       f_path.mnt
        const struct file_operations    *f_op;
        atomic_t                f_count;
        unsigned int            f_flags;
@@ -1239,7 +1226,7 @@ extern void touch_atime(struct vfsmount *mnt, struct dentry *dentry);
 static inline void file_accessed(struct file *file)
 {
        if (!(file->f_flags & O_NOATIME))
-               touch_atime(file->f_vfsmnt, file->f_dentry);
+               touch_atime(file->f_path.mnt, file->f_path.dentry);
 }
 
 int sync_inode(struct inode *inode, struct writeback_control *wbc);
@@ -1481,7 +1468,9 @@ extern char * getname(const char __user *);
 extern void __init vfs_caches_init_early(void);
 extern void __init vfs_caches_init(unsigned long);
 
-#define __getname()    kmem_cache_alloc(names_cachep, SLAB_KERNEL)
+extern struct kmem_cache *names_cachep;
+
+#define __getname()    kmem_cache_alloc(names_cachep, GFP_KERNEL)
 #define __putname(name) kmem_cache_free(names_cachep, (void *)(name))
 #ifndef CONFIG_AUDITSYSCALL
 #define putname(name)   __putname(name)
@@ -1497,7 +1486,6 @@ extern void bd_set_size(struct block_device *, loff_t size);
 extern void bd_forget(struct inode *inode);
 extern void bdput(struct block_device *);
 extern struct block_device *open_by_devnum(dev_t, unsigned);
-extern struct block_device *open_partition_by_devnum(dev_t, unsigned);
 extern const struct address_space_operations def_blk_aops;
 #else
 static inline void bd_forget(struct inode *inode) {}
@@ -1515,7 +1503,6 @@ extern int blkdev_driver_ioctl(struct inode *inode, struct file *file,
 extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long);
 extern int blkdev_get(struct block_device *, mode_t, unsigned);
 extern int blkdev_put(struct block_device *);
-extern int blkdev_put_partition(struct block_device *);
 extern int bd_claim(struct block_device *, void *);
 extern void bd_release(struct block_device *);
 #ifdef CONFIG_SYSFS
@@ -1630,7 +1617,7 @@ static inline void put_write_access(struct inode * inode)
 static inline void allow_write_access(struct file *file)
 {
        if (file)
-               atomic_inc(&file->f_dentry->d_inode->i_writecount);
+               atomic_inc(&file->f_path.dentry->d_inode->i_writecount);
 }
 extern int do_pipe(int *);
 extern struct file *create_read_pipe(struct file *f);
diff --git a/include/linux/fs_stack.h b/include/linux/fs_stack.h
new file mode 100644 (file)
index 0000000..bb516ce
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef _LINUX_FS_STACK_H
+#define _LINUX_FS_STACK_H
+
+/* This file defines generic functions used primarily by stackable
+ * filesystems; none of these functions require i_mutex to be held.
+ */
+
+#include <linux/fs.h>
+
+/* externs for fs/stack.c */
+extern void fsstack_copy_attr_all(struct inode *dest, const struct inode *src,
+                               int (*get_nlinks)(struct inode *));
+
+extern void fsstack_copy_inode_size(struct inode *dst, const struct inode *src);
+
+/* inlines */
+static inline void fsstack_copy_attr_atime(struct inode *dest,
+                                          const struct inode *src)
+{
+       dest->i_atime = src->i_atime;
+}
+
+static inline void fsstack_copy_attr_times(struct inode *dest,
+                                          const struct inode *src)
+{
+       dest->i_atime = src->i_atime;
+       dest->i_mtime = src->i_mtime;
+       dest->i_ctime = src->i_ctime;
+}
+
+#endif /* _LINUX_FS_STACK_H */
index c623d12a486e6e1deb90a6ab65d4b71e6b81aab3..11a36ceddf73a1e8670c1efb81a10cd8c0bf3e67 100644 (file)
@@ -18,6 +18,8 @@ struct fs_struct {
        .umask          = 0022, \
 }
 
+extern struct kmem_cache *fs_cachep;
+
 extern void exit_fs(struct task_struct *);
 extern void set_fs_altroot(void);
 extern void set_fs_root(struct fs_struct *, struct vfsmount *, struct dentry *);
index d4f219ffaa5dbffa831e0eefcfb27cc7949b6f83..dfc4e4f68da4b3a301080463e4ef41c52f8d604b 100644 (file)
@@ -164,7 +164,7 @@ static inline void fsnotify_open(struct dentry *dentry)
  */
 static inline void fsnotify_close(struct file *file)
 {
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        const char *name = dentry->d_name.name;
        mode_t mode = file->f_mode;
index 9fc48a674b82dc31c78aeb438b88862a9d28fbab..534744efe30d764abaf8c8aa10baa03821153c24 100644 (file)
@@ -15,7 +15,7 @@
 #define FUSE_KERNEL_VERSION 7
 
 /** Minor version number of this interface */
-#define FUSE_KERNEL_MINOR_VERSION 7
+#define FUSE_KERNEL_MINOR_VERSION 8
 
 /** The node ID of the root inode */
 #define FUSE_ROOT_ID 1
@@ -92,6 +92,11 @@ struct fuse_file_lock {
 #define FUSE_ASYNC_READ                (1 << 0)
 #define FUSE_POSIX_LOCKS       (1 << 1)
 
+/**
+ * Release flags
+ */
+#define FUSE_RELEASE_FLUSH     (1 << 0)
+
 enum fuse_opcode {
        FUSE_LOOKUP        = 1,
        FUSE_FORGET        = 2,  /* no reply */
@@ -127,6 +132,8 @@ enum fuse_opcode {
        FUSE_ACCESS        = 34,
        FUSE_CREATE        = 35,
        FUSE_INTERRUPT     = 36,
+       FUSE_BMAP          = 37,
+       FUSE_DESTROY       = 38,
 };
 
 /* The read buffer is required to be at least 8k, but may be much larger */
@@ -205,12 +212,13 @@ struct fuse_open_out {
 struct fuse_release_in {
        __u64   fh;
        __u32   flags;
-       __u32   padding;
+       __u32   release_flags;
+       __u64   lock_owner;
 };
 
 struct fuse_flush_in {
        __u64   fh;
-       __u32   flush_flags;
+       __u32   unused;
        __u32   padding;
        __u64   lock_owner;
 };
@@ -296,6 +304,16 @@ struct fuse_interrupt_in {
        __u64   unique;
 };
 
+struct fuse_bmap_in {
+       __u64   block;
+       __u32   blocksize;
+       __u32   padding;
+};
+
+struct fuse_bmap_out {
+       __u64   block;
+};
+
 struct fuse_in_header {
        __u32   len;
        __u32   opcode;
index e2538456195568141da767ace0da9ec5abe08a3d..5412da28fa4749daa9822bd4b99f82a61628388a 100644 (file)
@@ -91,7 +91,7 @@ void gs_hangup(struct tty_struct *tty);
 int  gs_block_til_ready(void *port, struct file *filp);
 void gs_close(struct tty_struct *tty, struct file *filp);
 void gs_set_termios (struct tty_struct * tty, 
-                     struct termios * old_termios);
+                     struct ktermios * old_termios);
 int  gs_init_port(struct gs_port *port);
 int  gs_setserial(struct gs_port *port, struct serial_struct __user *sp);
 int  gs_getserial(struct gs_port *port, struct serial_struct __user *sp);
index 9049dc65ae51b6b34751c4011e43e36646d56bcb..f7a93770e1be864cd6f1ddb152784597fdac0101 100644 (file)
@@ -17,6 +17,9 @@ struct genlmsghdr {
 #define GENL_HDRLEN    NLMSG_ALIGN(sizeof(struct genlmsghdr))
 
 #define GENL_ADMIN_PERM                0x01
+#define GENL_CMD_CAP_DO                0x02
+#define GENL_CMD_CAP_DUMP      0x04
+#define GENL_CMD_CAP_HASPOL    0x08
 
 /*
  * List of reserved static generic netlink identifiers:
@@ -58,9 +61,6 @@ enum {
        CTRL_ATTR_OP_UNSPEC,
        CTRL_ATTR_OP_ID,
        CTRL_ATTR_OP_FLAGS,
-       CTRL_ATTR_OP_POLICY,
-       CTRL_ATTR_OP_DOIT,
-       CTRL_ATTR_OP_DUMPIT,
        __CTRL_ATTR_OP_MAX,
 };
 
index 41f276fdd185f6b16b4edb280041a23fa642440c..0a022b2f63fc0fa95fa35df16784e2fcaef225b3 100644 (file)
@@ -83,6 +83,9 @@ struct hd_struct {
        struct kobject *holder_dir;
        unsigned ios[2], sectors[2];    /* READs and WRITEs */
        int policy, partno;
+#ifdef CONFIG_FAIL_MAKE_REQUEST
+       int make_it_fail;
+#endif
 };
 
 #define GENHD_FL_REMOVABLE                     1
@@ -90,6 +93,7 @@ struct hd_struct {
 #define GENHD_FL_CD                            8
 #define GENHD_FL_UP                            16
 #define GENHD_FL_SUPPRESS_PARTITION_INFO       32
+#define GENHD_FL_FAIL                          64
 
 struct disk_stats {
        unsigned long sectors[2];       /* READs and WRITEs */
index bf2b6bc3f6fd4fc35dec4dc8072b26c160458dfe..00c314aedab7d8f9487112e9a4d16182185b6332 100644 (file)
@@ -116,6 +116,9 @@ static inline enum zone_type gfp_zone(gfp_t flags)
 #ifndef HAVE_ARCH_FREE_PAGE
 static inline void arch_free_page(struct page *page, int order) { }
 #endif
+#ifndef HAVE_ARCH_ALLOC_PAGE
+static inline void arch_alloc_page(struct page *page, int order) { }
+#endif
 
 extern struct page *
 FASTCALL(__alloc_pages(gfp_t, unsigned int, struct zonelist *));
index a7ae7c177cacbb3044ed372976f09b7cfe48338f..8b7e4c1e32ae2c8f80d2f8182e2452add7c18451 100644 (file)
@@ -54,8 +54,13 @@ struct gfs2_inum {
        __be64 no_addr;
 };
 
-static inline int gfs2_inum_equal(const struct gfs2_inum *ino1,
-                                 const struct gfs2_inum *ino2)
+struct gfs2_inum_host {
+       __u64 no_formal_ino;
+       __u64 no_addr;
+};
+
+static inline int gfs2_inum_equal(const struct gfs2_inum_host *ino1,
+                                 const struct gfs2_inum_host *ino2)
 {
        return ino1->no_formal_ino == ino2->no_formal_ino &&
               ino1->no_addr == ino2->no_addr;
@@ -89,6 +94,12 @@ struct gfs2_meta_header {
        __be32 __pad1;          /* Was incarnation number in gfs1 */
 };
 
+struct gfs2_meta_header_host {
+       __u32 mh_magic;
+       __u32 mh_type;
+       __u32 mh_format;
+};
+
 /*
  * super-block structure
  *
@@ -128,6 +139,23 @@ struct gfs2_sb {
        /* In gfs1, quota and license dinodes followed */
 };
 
+struct gfs2_sb_host {
+       struct gfs2_meta_header_host sb_header;
+
+       __u32 sb_fs_format;
+       __u32 sb_multihost_format;
+
+       __u32 sb_bsize;
+       __u32 sb_bsize_shift;
+
+       struct gfs2_inum_host sb_master_dir; /* Was jindex dinode in gfs1 */
+       struct gfs2_inum_host sb_root_dir;
+
+       char sb_lockproto[GFS2_LOCKNAME_LEN];
+       char sb_locktable[GFS2_LOCKNAME_LEN];
+       /* In gfs1, quota and license dinodes followed */
+};
+
 /*
  * resource index structure
  */
@@ -145,6 +173,14 @@ struct gfs2_rindex {
        __u8 ri_reserved[64];
 };
 
+struct gfs2_rindex_host {
+       __u64 ri_addr;  /* grp block disk address */
+       __u64 ri_data0; /* first data location */
+       __u32 ri_length;        /* length of rgrp header in fs blocks */
+       __u32 ri_data;  /* num of data blocks in rgrp */
+       __u32 ri_bitbytes;      /* number of bytes in data bitmaps */
+};
+
 /*
  * resource group header structure
  */
@@ -176,6 +212,13 @@ struct gfs2_rgrp {
        __u8 rg_reserved[80]; /* Several fields from gfs1 now reserved */
 };
 
+struct gfs2_rgrp_host {
+       __u32 rg_flags;
+       __u32 rg_free;
+       __u32 rg_dinodes;
+       __u64 rg_igeneration;
+};
+
 /*
  * quota structure
  */
@@ -187,6 +230,12 @@ struct gfs2_quota {
        __u8 qu_reserved[64];
 };
 
+struct gfs2_quota_host {
+       __u64 qu_limit;
+       __u64 qu_warn;
+       __u64 qu_value;
+};
+
 /*
  * dinode structure
  */
@@ -270,6 +319,27 @@ struct gfs2_dinode {
        __u8 di_reserved[56];
 };
 
+struct gfs2_dinode_host {
+       __u64 di_size;  /* number of bytes in file */
+       __u64 di_blocks;        /* number of blocks in file */
+
+       /* This section varies from gfs1. Padding added to align with
+         * remainder of dinode
+        */
+       __u64 di_goal_meta;     /* rgrp to alloc from next */
+       __u64 di_goal_data;     /* data block goal */
+       __u64 di_generation;    /* generation number for NFS */
+
+       __u32 di_flags; /* GFS2_DIF_... */
+       __u16 di_height;        /* height of metadata */
+
+       /* These only apply to directories  */
+       __u16 di_depth; /* Number of bits in the table */
+       __u32 di_entries;       /* The number of entries in the directory */
+
+       __u64 di_eattr; /* extended attribute block number */
+};
+
 /*
  * directory structure - many of these per directory file
  */
@@ -344,6 +414,16 @@ struct gfs2_log_header {
        __be32 lh_hash;
 };
 
+struct gfs2_log_header_host {
+       struct gfs2_meta_header_host lh_header;
+
+       __u64 lh_sequence;      /* Sequence number of this transaction */
+       __u32 lh_flags; /* GFS2_LOG_HEAD_... */
+       __u32 lh_tail;          /* Block number of log tail */
+       __u32 lh_blkno;
+       __u32 lh_hash;
+};
+
 /*
  * Log type descriptor
  */
@@ -384,6 +464,11 @@ struct gfs2_inum_range {
        __be64 ir_length;
 };
 
+struct gfs2_inum_range_host {
+       __u64 ir_start;
+       __u64 ir_length;
+};
+
 /*
  * Statfs change
  * Describes an change to the pool of free and allocated
@@ -396,6 +481,12 @@ struct gfs2_statfs_change {
        __be64 sc_dinodes;
 };
 
+struct gfs2_statfs_change_host {
+       __u64 sc_total;
+       __u64 sc_free;
+       __u64 sc_dinodes;
+};
+
 /*
  * Quota change
  * Describes an allocation change for a particular
@@ -410,33 +501,38 @@ struct gfs2_quota_change {
        __be32 qc_id;
 };
 
+struct gfs2_quota_change_host {
+       __u64 qc_change;
+       __u32 qc_flags; /* GFS2_QCF_... */
+       __u32 qc_id;
+};
+
 #ifdef __KERNEL__
 /* Translation functions */
 
-extern void gfs2_inum_in(struct gfs2_inum *no, const void *buf);
-extern void gfs2_inum_out(const struct gfs2_inum *no, void *buf);
-extern void gfs2_sb_in(struct gfs2_sb *sb, const void *buf);
-extern void gfs2_rindex_in(struct gfs2_rindex *ri, const void *buf);
-extern void gfs2_rindex_out(const struct gfs2_rindex *ri, void *buf);
-extern void gfs2_rgrp_in(struct gfs2_rgrp *rg, const void *buf);
-extern void gfs2_rgrp_out(const struct gfs2_rgrp *rg, void *buf);
-extern void gfs2_quota_in(struct gfs2_quota *qu, const void *buf);
-extern void gfs2_quota_out(const struct gfs2_quota *qu, void *buf);
-extern void gfs2_dinode_in(struct gfs2_dinode *di, const void *buf);
-extern void gfs2_dinode_out(const struct gfs2_dinode *di, void *buf);
+extern void gfs2_inum_in(struct gfs2_inum_host *no, const void *buf);
+extern void gfs2_inum_out(const struct gfs2_inum_host *no, void *buf);
+extern void gfs2_sb_in(struct gfs2_sb_host *sb, const void *buf);
+extern void gfs2_rindex_in(struct gfs2_rindex_host *ri, const void *buf);
+extern void gfs2_rindex_out(const struct gfs2_rindex_host *ri, void *buf);
+extern void gfs2_rgrp_in(struct gfs2_rgrp_host *rg, const void *buf);
+extern void gfs2_rgrp_out(const struct gfs2_rgrp_host *rg, void *buf);
+extern void gfs2_quota_in(struct gfs2_quota_host *qu, const void *buf);
+struct gfs2_inode;
+extern void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf);
 extern void gfs2_ea_header_in(struct gfs2_ea_header *ea, const void *buf);
 extern void gfs2_ea_header_out(const struct gfs2_ea_header *ea, void *buf);
-extern void gfs2_log_header_in(struct gfs2_log_header *lh, const void *buf);
-extern void gfs2_inum_range_in(struct gfs2_inum_range *ir, const void *buf);
-extern void gfs2_inum_range_out(const struct gfs2_inum_range *ir, void *buf);
-extern void gfs2_statfs_change_in(struct gfs2_statfs_change *sc, const void *buf);
-extern void gfs2_statfs_change_out(const struct gfs2_statfs_change *sc, void *buf);
-extern void gfs2_quota_change_in(struct gfs2_quota_change *qc, const void *buf);
+extern void gfs2_log_header_in(struct gfs2_log_header_host *lh, const void *buf);
+extern void gfs2_inum_range_in(struct gfs2_inum_range_host *ir, const void *buf);
+extern void gfs2_inum_range_out(const struct gfs2_inum_range_host *ir, void *buf);
+extern void gfs2_statfs_change_in(struct gfs2_statfs_change_host *sc, const void *buf);
+extern void gfs2_statfs_change_out(const struct gfs2_statfs_change_host *sc, void *buf);
+extern void gfs2_quota_change_in(struct gfs2_quota_change_host *qc, const void *buf);
 
 /* Printing functions */
 
-extern void gfs2_rindex_print(const struct gfs2_rindex *ri);
-extern void gfs2_dinode_print(const struct gfs2_dinode *di);
+extern void gfs2_rindex_print(const struct gfs2_rindex_host *ri);
+extern void gfs2_dinode_print(const struct gfs2_inode *ip);
 
 #endif /* __KERNEL__ */
 
similarity index 86%
rename from drivers/usb/input/hid.h
rename to include/linux/hid.h
index 2a9bf07944c03b94adfc62ed5aa989c197fb04fe..770120add15a50d6fdb9a8d1c28fa076fa4370ea 100644 (file)
@@ -6,6 +6,7 @@
  *
  *  Copyright (c) 1999 Andreas Gal
  *  Copyright (c) 2000-2001 Vojtech Pavlik
+ *  Copyright (c) 2006 Jiri Kosina
  */
 
 /*
@@ -33,6 +34,7 @@
 #include <linux/list.h>
 #include <linux/timer.h>
 #include <linux/workqueue.h>
+#include <linux/input.h>
 
 /*
  * USB HID (Human Interface Device) interface class code
@@ -260,7 +262,8 @@ struct hid_item {
 #define HID_QUIRK_POWERBOOK_HAS_FN             0x00001000
 #define HID_QUIRK_POWERBOOK_FN_ON              0x00002000
 #define HID_QUIRK_INVERT_HWHEEL                        0x00004000
-#define HID_QUIRK_POWERBOOK_ISO_KEYBOARD       0x00008000
+#define HID_QUIRK_POWERBOOK_ISO_KEYBOARD        0x00008000
+#define HID_QUIRK_BAD_RELATIVE_KEYS            0x00010000
 
 /*
  * This is the global environment of the parser. This information is
@@ -400,42 +403,14 @@ struct hid_device {                                                       /* device report descriptor */
        unsigned collection_size;                                       /* Number of allocated hid_collections */
        unsigned maxcollection;                                         /* Number of parsed collections */
        unsigned maxapplication;                                        /* Number of applications */
+       unsigned short bus;                                             /* BUS ID */
+       unsigned short vendor;                                          /* Vendor ID */
+       unsigned short product;                                         /* Product ID */
        unsigned version;                                               /* HID version */
        unsigned country;                                               /* HID country */
        struct hid_report_enum report_enum[HID_REPORT_TYPES];
 
-       struct usb_device *dev;                                         /* USB device */
-       struct usb_interface *intf;                                     /* USB interface */
-       int ifnum;                                                      /* USB interface number */
-
-       unsigned long iofl;                                             /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */
-       struct timer_list io_retry;                                     /* Retry timer */
-       unsigned long stop_retry;                                       /* Time to give up, in jiffies */
-       unsigned int retry_delay;                                       /* Delay length in ms */
-       struct work_struct reset_work;                                  /* Task context for resets */
-
-       unsigned int bufsize;                                           /* URB buffer size */
-
-       struct urb *urbin;                                              /* Input URB */
-       char *inbuf;                                                    /* Input buffer */
-       dma_addr_t inbuf_dma;                                           /* Input buffer dma */
-       spinlock_t inlock;                                              /* Input fifo spinlock */
-
-       struct urb *urbctrl;                                            /* Control URB */
-       struct usb_ctrlrequest *cr;                                     /* Control request struct */
-       dma_addr_t cr_dma;                                              /* Control request struct dma */
-       struct hid_control_fifo ctrl[HID_CONTROL_FIFO_SIZE];            /* Control fifo */
-       unsigned char ctrlhead, ctrltail;                               /* Control fifo head & tail */
-       char *ctrlbuf;                                                  /* Control buffer */
-       dma_addr_t ctrlbuf_dma;                                         /* Control buffer dma */
-       spinlock_t ctrllock;                                            /* Control fifo spinlock */
-
-       struct urb *urbout;                                             /* Output URB */
-       struct hid_report *out[HID_CONTROL_FIFO_SIZE];                  /* Output pipe fifo */
-       unsigned char outhead, outtail;                                 /* Output pipe fifo head & tail */
-       char *outbuf;                                                   /* Output buffer */
-       dma_addr_t outbuf_dma;                                          /* Output buffer dma */
-       spinlock_t outlock;                                             /* Output fifo spinlock */
+       struct device *dev;                                             /* device */
 
        unsigned claimed;                                               /* Claimed by hidinput, hiddev? */
        unsigned quirks;                                                /* Various quirks the device can pull on us */
@@ -451,7 +426,19 @@ struct hid_device {                                                        /* device report descriptor */
        char phys[64];                                                  /* Device physical location */
        char uniq[64];                                                  /* Device unique identifier (serial #) */
 
+       void *driver_data;
+
+       /* device-specific function pointers */
+       int (*hidinput_input_event) (struct input_dev *, unsigned int, unsigned int, int);
+       int (*hidinput_open) (struct input_dev *);
+       void (*hidinput_close) (struct input_dev *);
+
+       /* hiddev event handler */
+       void (*hiddev_hid_event) (struct hid_device *, struct hid_field *field,
+                                 struct hid_usage *, __s32);
+       void (*hiddev_report_event) (struct hid_device *, struct hid_report *);
 #ifdef CONFIG_USB_HIDINPUT_POWERBOOK
+       unsigned int  pb_fnmode;
        unsigned long pb_pressed_fn[NBITS(KEY_MAX)];
        unsigned long pb_pressed_numlock[NBITS(KEY_MAX)];
 #endif
@@ -495,31 +482,23 @@ struct hid_descriptor {
 #define resolv_event(a,b)      do { } while (0)
 #endif
 
-#endif
-
-#ifdef CONFIG_USB_HIDINPUT
 /* Applications from HID Usage Tables 4/8/99 Version 1.1 */
 /* We ignore a few input applications that are not widely used */
 #define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || (a == 0x000c0001))
+
+/* HID core API */
 extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32);
 extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report);
 extern int hidinput_connect(struct hid_device *);
 extern void hidinput_disconnect(struct hid_device *);
-#else
-#define IS_INPUT_APPLICATION(a) (0)
-static inline void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value) { }
-static inline void hidinput_report_event(struct hid_device *hid, struct hid_report *report) { }
-static inline int hidinput_connect(struct hid_device *hid) { return -ENODEV; }
-static inline void hidinput_disconnect(struct hid_device *hid) { }
-#endif
 
-int hid_open(struct hid_device *);
-void hid_close(struct hid_device *);
 int hid_set_field(struct hid_field *, unsigned, __s32);
-void hid_submit_report(struct hid_device *, struct hid_report *, unsigned char dir);
-void hid_init_reports(struct hid_device *hid);
-int hid_wait_io(struct hid_device* hid);
-
+int hid_input_report(struct hid_device *, int type, u8 *, int, int);
+int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field);
+void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, int interrupt);
+void hid_output_report(struct hid_report *report, __u8 *data);
+void hid_free_device(struct hid_device *device);
+struct hid_device *hid_parse_report(__u8 *start, unsigned size);
 
 #ifdef CONFIG_HID_FF
 int hid_ff_init(struct hid_device *hid);
@@ -536,4 +515,14 @@ static inline int hid_pidff_init(struct hid_device *hid) { return -ENODEV; }
 #else
 static inline int hid_ff_init(struct hid_device *hid) { return -1; }
 #endif
+#ifdef DEBUG
+#define dbg(format, arg...) printk(KERN_DEBUG "%s: " format "\n" , \
+               __FILE__ , ## arg)
+#else
+#define dbg(format, arg...) do {} while (0)
+#endif
+
+#define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , \
+               __FILE__ , ## arg)
+#endif
 
index fd7d12daa94ff3e0c066ccc789b6878739c9a022..3d8768b619e9ef71f71e60ae90205971298ffef8 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <linux/fs.h>
 #include <linux/mm.h>
+#include <linux/uaccess.h>
 
 #include <asm/cacheflush.h>
 
@@ -41,9 +42,10 @@ static inline void *kmap(struct page *page)
 
 #define kunmap(page) do { (void) (page); } while (0)
 
-#define kmap_atomic(page, idx)         page_address(page)
-#define kunmap_atomic(addr, idx)       do { } while (0)
-#define kmap_atomic_pfn(pfn, idx)      page_address(pfn_to_page(pfn))
+#define kmap_atomic(page, idx) \
+       ({ pagefault_disable(); page_address(page); })
+#define kunmap_atomic(addr, idx)       do { pagefault_enable(); } while (0)
+#define kmap_atomic_pfn(pfn, idx)      kmap_atomic(pfn_to_page(pfn), (idx))
 #define kmap_atomic_to_page(ptr)       virt_to_page(ptr)
 #endif
 
index ace64e57e17f4291a813c7a9f61d1779fb560d43..a60995afe3348a7ce3ebd0808252679a17164c98 100644 (file)
@@ -35,6 +35,7 @@ extern int sysctl_hugetlb_shm_group;
 
 pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr);
 pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr);
+int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep);
 struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address,
                              int write);
 struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address,
index 5f3eaf8022235d625e3a29f69cfaf7bedccd7d8c..41dcdfe7f625d7e45aedbb1efa7f2259214bc19a 100644 (file)
@@ -1,29 +1,6 @@
 #ifndef _LINUX_I2C_ALGO_PXA_H
 #define _LINUX_I2C_ALGO_PXA_H
 
-struct i2c_eeprom_emu_watcher {
-       void (*write)(void *, unsigned int addr, unsigned char newval);
-};
-
-struct i2c_eeprom_emu_watch {
-       struct list_head node;
-       unsigned int start;
-       unsigned int end;
-       struct i2c_eeprom_emu_watcher *ops;
-       void *data;
-};
-
-#define I2C_EEPROM_EMU_SIZE (256)
-
-struct i2c_eeprom_emu {
-       unsigned int size;
-       unsigned int ptr;
-       unsigned int seen_start;
-       struct list_head watch;
-
-       unsigned char bytes[I2C_EEPROM_EMU_SIZE];
-};
-
 typedef enum i2c_slave_event_e {
        I2C_SLAVE_EVENT_START_READ,
        I2C_SLAVE_EVENT_START_WRITE,
@@ -37,12 +14,4 @@ struct i2c_slave_client {
        void (*write)(void *ptr, unsigned int val);
 };
 
-extern int i2c_eeprom_emu_addwatcher(struct i2c_eeprom_emu *, void *data,
-                                    unsigned int addr, unsigned int size,
-                                    struct i2c_eeprom_emu_watcher *);
-
-extern void i2c_eeprom_emu_delwatcher(struct i2c_eeprom_emu *, void *data, struct i2c_eeprom_emu_watcher *watcher);
-
-extern struct i2c_eeprom_emu *i2c_pxa_get_eeprom(void);
-
 #endif /* _LINUX_I2C_ALGO_PXA_H */
index 1fb02e17f6f642b9880ce814d00c11160219ddb7..52f53e2e70c3c2cf6e89e8069f93dddbec24c806 100644 (file)
@@ -490,7 +490,7 @@ struct i2o_dma {
  */
 struct i2o_pool {
        char *name;
-       kmem_cache_t *slab;
+       struct kmem_cache *slab;
        mempool_t *mempool;
 };
 
@@ -986,7 +986,8 @@ extern void i2o_driver_unregister(struct i2o_driver *);
 
 /**
  *     i2o_driver_notify_controller_add - Send notification of added controller
- *                                        to a single I2O driver
+ *     @drv: I2O driver
+ *     @c: I2O controller
  *
  *     Send notification of added controller to a single registered driver.
  */
@@ -998,8 +999,9 @@ static inline void i2o_driver_notify_controller_add(struct i2o_driver *drv,
 };
 
 /**
- *     i2o_driver_notify_controller_remove - Send notification of removed
- *                                           controller to a single I2O driver
+ *     i2o_driver_notify_controller_remove - Send notification of removed controller
+ *     @drv: I2O driver
+ *     @c: I2O controller
  *
  *     Send notification of removed controller to a single registered driver.
  */
@@ -1011,8 +1013,9 @@ static inline void i2o_driver_notify_controller_remove(struct i2o_driver *drv,
 };
 
 /**
- *     i2o_driver_notify_device_add - Send notification of added device to a
- *                                    single I2O driver
+ *     i2o_driver_notify_device_add - Send notification of added device
+ *     @drv: I2O driver
+ *     @i2o_dev: the added i2o_device
  *
  *     Send notification of added device to a single registered driver.
  */
@@ -1025,7 +1028,8 @@ static inline void i2o_driver_notify_device_add(struct i2o_driver *drv,
 
 /**
  *     i2o_driver_notify_device_remove - Send notification of removed device
- *                                       to a single I2O driver
+ *     @drv: I2O driver
+ *     @i2o_dev: the added i2o_device
  *
  *     Send notification of removed device to a single registered driver.
  */
@@ -1148,7 +1152,7 @@ static inline void i2o_msg_post(struct i2o_controller *c,
 /**
  *     i2o_msg_post_wait - Post and wait a message and wait until return
  *     @c: controller
- *     @m: message to post
+ *     @msg: message to post
  *     @timeout: time in seconds to wait
  *
  *     This API allows an OSM to post a message and then be told whether or
index dbe8f6120a40ba4bc8c93cfecd0707dd65d865c4..d557e4ce9b6b5d34be16db10ca21c1311fc67d34 100644 (file)
@@ -52,4 +52,10 @@ struct ifa_cacheinfo
        __u32   tstamp; /* updated timestamp, hundredths of seconds */
 };
 
+/* backwards compatibility for userspace */
+#ifndef __KERNEL__
+#define IFA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
+#define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
+#endif
+
 #endif
index e963a077e6f5164cb19ef3431c896653c741b4dc..35ed3b5467f33e6524cd68a9d82d35e04e829f8b 100644 (file)
@@ -82,6 +82,12 @@ enum
 
 #define IFLA_MAX (__IFLA_MAX - 1)
 
+/* backwards compatibility for userspace */
+#ifndef __KERNEL__
+#define IFLA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
+#define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
+#endif
+
 /* ifi_flags.
 
    IFF_* flags.
index 33c5daacc74338dd0d479f976892659ab308eab8..7272ff9ee77c58617c0897ddc222018ae89b3d41 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/utsname.h>
 #include <linux/lockdep.h>
 #include <linux/ipc.h>
+#include <linux/pid_namespace.h>
 
 #define INIT_FDTABLE \
 {                                                      \
        .cpu_vm_mask    = CPU_MASK_ALL,                         \
 }
 
-#define INIT_SIGNALS(sig) {    \
-       .count          = ATOMIC_INIT(1),               \
+#define INIT_SIGNALS(sig) {                                            \
+       .count          = ATOMIC_INIT(1),                               \
        .wait_chldexit  = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\
-       .shared_pending = {                             \
+       .shared_pending = {                                             \
                .list = LIST_HEAD_INIT(sig.shared_pending.list),        \
-               .signal =  {{0}}}, \
+               .signal =  {{0}}},                                      \
        .posix_timers    = LIST_HEAD_INIT(sig.posix_timers),            \
        .cpu_timers     = INIT_CPU_TIMERS(sig.cpu_timers),              \
        .rlim           = INIT_RLIMITS,                                 \
        .pgrp           = 1,                                            \
-       .session        = 1,                                            \
+       .tty_old_pgrp   = 0,                                            \
+       { .__session      = 1},                                         \
 }
 
 extern struct nsproxy init_nsproxy;
 #define INIT_NSPROXY(nsproxy) {                                                \
+       .pid_ns         = &init_pid_ns,                                 \
        .count          = ATOMIC_INIT(1),                               \
-       .nslock         = SPIN_LOCK_UNLOCKED,                           \
+       .nslock         = __SPIN_LOCK_UNLOCKED(nsproxy.nslock),         \
+       .id             = 0,                                            \
        .uts_ns         = &init_uts_ns,                                 \
-       .namespace      = NULL,                                         \
+       .mnt_ns         = NULL,                                         \
        INIT_IPC_NS(ipc_ns)                                             \
 }
 
index c38507ba38b51bab3e48c0a4cb75758c930b145a..4e61158b06a07c65e65bca49955f3f47117391c9 100644 (file)
@@ -663,7 +663,7 @@ struct input_absinfo {
 #define BUS_GSC                        0x1A
 
 /*
- * Values describing the status of an effect
+ * Values describing the status of a force-feedback effect
  */
 #define FF_STATUS_STOPPED      0x00
 #define FF_STATUS_PLAYING      0x01
@@ -680,7 +680,7 @@ struct input_absinfo {
  */
 
 /**
- * struct ff_replay - defines scheduling of the effect
+ * struct ff_replay - defines scheduling of the force-feedback effect
  * @length: duration of the effect
  * @delay: delay before effect should start playing
  */
@@ -690,7 +690,7 @@ struct ff_replay {
 };
 
 /**
- * struct ff_trigger - defines what triggers the effect
+ * struct ff_trigger - defines what triggers the force-feedback effect
  * @button: number of the button triggering the effect
  * @interval: controls how soon the effect can be re-triggered
  */
@@ -700,7 +700,7 @@ struct ff_trigger {
 };
 
 /**
- * struct ff_envelope - generic effect envelope
+ * struct ff_envelope - generic force-feedback effect envelope
  * @attack_length: duration of the attack (ms)
  * @attack_level: level at the beginning of the attack
  * @fade_length: duration of fade (ms)
@@ -719,7 +719,7 @@ struct ff_envelope {
 };
 
 /**
- * struct ff_constant_effect - defines parameters of a constant effect
+ * struct ff_constant_effect - defines parameters of a constant force-feedback effect
  * @level: strength of the effect; may be negative
  * @envelope: envelope data
  */
@@ -729,7 +729,7 @@ struct ff_constant_effect {
 };
 
 /**
- * struct ff_ramp_effect - defines parameters of a ramp effect
+ * struct ff_ramp_effect - defines parameters of a ramp force-feedback effect
  * @start_level: beginning strength of the effect; may be negative
  * @end_level: final strength of the effect; may be negative
  * @envelope: envelope data
@@ -741,7 +741,7 @@ struct ff_ramp_effect {
 };
 
 /**
- * struct ff_condition_effect - defines a spring or friction effect
+ * struct ff_condition_effect - defines a spring or friction force-feedback effect
  * @right_saturation: maximum level when joystick moved all way to the right
  * @left_saturation: same for the left side
  * @right_coeff: controls how fast the force grows when the joystick moves
@@ -762,7 +762,7 @@ struct ff_condition_effect {
 };
 
 /**
- * struct ff_periodic_effect - defines parameters of a periodic effect
+ * struct ff_periodic_effect - defines parameters of a periodic force-feedback effect
  * @waveform: kind of the effect (wave)
  * @period: period of the wave (ms)
  * @magnitude: peak value
@@ -793,7 +793,7 @@ struct ff_periodic_effect {
 };
 
 /**
- * struct ff_rumble_effect - defines parameters of a periodic effect
+ * struct ff_rumble_effect - defines parameters of a periodic force-feedback effect
  * @strong_magnitude: magnitude of the heavy motor
  * @weak_magnitude: magnitude of the light one
  *
index 5b83e7b59621e22e365da7cd923921846e1d987f..de7593f4e895b4bfaa77c7e22051e372a5b5a48c 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/hardirq.h>
 #include <linux/sched.h>
 #include <linux/irqflags.h>
+#include <linux/bottom_half.h>
 #include <asm/atomic.h>
 #include <asm/ptrace.h>
 #include <asm/system.h>
@@ -217,12 +218,6 @@ static inline void __deprecated save_and_cli(unsigned long *x)
 #define save_and_cli(x)        save_and_cli(&x)
 #endif /* CONFIG_SMP */
 
-extern void local_bh_disable(void);
-extern void __local_bh_enable(void);
-extern void _local_bh_enable(void);
-extern void local_bh_enable(void);
-extern void local_bh_enable_ip(unsigned long ip);
-
 /* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
    frequency threaded job scheduling. For almost all the purposes
    tasklets are more than enough. F.e. all serial device BHs et
index 796ca009fd468a8716cd8d6b31570bcc83ca4faf..7a9db390c56a491e3221ed8154ac76ed89295c8f 100644 (file)
@@ -208,6 +208,15 @@ struct kernel_ipmi_msg
    code as the first byte of the incoming data, unlike a response. */
 
 
+/*
+ * Modes for ipmi_set_maint_mode() and the userland IOCTL.  The AUTO
+ * setting is the default and means it will be set on certain
+ * commands.  Hard setting it on and off will override automatic
+ * operation.
+ */
+#define IPMI_MAINTENANCE_MODE_AUTO     0
+#define IPMI_MAINTENANCE_MODE_OFF      1
+#define IPMI_MAINTENANCE_MODE_ON       2
 
 #ifdef __KERNEL__
 
@@ -373,6 +382,35 @@ int ipmi_unregister_for_cmd(ipmi_user_t   user,
                            unsigned char cmd,
                            unsigned int  chans);
 
+/*
+ * Go into a mode where the driver will not autonomously attempt to do
+ * things with the interface.  It will still respond to attentions and
+ * interrupts, and it will expect that commands will complete.  It
+ * will not automatcially check for flags, events, or things of that
+ * nature.
+ *
+ * This is primarily used for firmware upgrades.  The idea is that
+ * when you go into firmware upgrade mode, you do this operation
+ * and the driver will not attempt to do anything but what you tell
+ * it or what the BMC asks for.
+ *
+ * Note that if you send a command that resets the BMC, the driver
+ * will still expect a response from that command.  So the BMC should
+ * reset itself *after* the response is sent.  Resetting before the
+ * response is just silly.
+ *
+ * If in auto maintenance mode, the driver will automatically go into
+ * maintenance mode for 30 seconds if it sees a cold reset, a warm
+ * reset, or a firmware NetFN.  This means that code that uses only
+ * firmware NetFN commands to do upgrades will work automatically
+ * without change, assuming it sends a message every 30 seconds or
+ * less.
+ *
+ * See the IPMI_MAINTENANCE_MODE_xxx defines for what the mode means.
+ */
+int ipmi_get_maintenance_mode(ipmi_user_t user);
+int ipmi_set_maintenance_mode(ipmi_user_t user, int mode);
+
 /*
  * Allow run-to-completion mode to be set for the interface of
  * a specific user.
@@ -656,4 +694,11 @@ struct ipmi_timing_parms
 #define IPMICTL_GET_TIMING_PARMS_CMD   _IOR(IPMI_IOC_MAGIC, 23, \
                                             struct ipmi_timing_parms)
 
+/*
+ * Set the maintenance mode.  See ipmi_set_maintenance_mode() above
+ * for a description of what this does.
+ */
+#define IPMICTL_GET_MAINTENANCE_MODE_CMD       _IOR(IPMI_IOC_MAGIC, 30, int)
+#define IPMICTL_SET_MAINTENANCE_MODE_CMD       _IOW(IPMI_IOC_MAGIC, 31, int)
+
 #endif /* __LINUX_IPMI_H */
index 4d04d8b58a0a55a13a59ef9055cdd5eac81e4d08..b56a158d587a50e0c9ab0c8712f308bf01ecda74 100644 (file)
@@ -46,6 +46,8 @@
 #define IPMI_NETFN_APP_REQUEST                 0x06
 #define IPMI_NETFN_APP_RESPONSE                        0x07
 #define IPMI_GET_DEVICE_ID_CMD         0x01
+#define IPMI_COLD_RESET_CMD            0x02
+#define IPMI_WARM_RESET_CMD            0x03
 #define IPMI_CLEAR_MSG_FLAGS_CMD       0x30
 #define IPMI_GET_DEVICE_GUID_CMD       0x08
 #define IPMI_GET_MSG_FLAGS_CMD         0x31
 #define IPMI_NETFN_STORAGE_RESPONSE            0x0b
 #define IPMI_ADD_SEL_ENTRY_CMD         0x44
 
+#define IPMI_NETFN_FIRMWARE_REQUEST            0x08
+#define IPMI_NETFN_FIRMWARE_RESPONSE           0x09
+
 /* The default slave address */
 #define IPMI_BMC_SLAVE_ADDR    0x20
 
 /* The BT interface on high-end HP systems supports up to 255 bytes in
  * one transfer.  Its "virtual" BMC supports some commands that are longer
  * than 128 bytes.  Use the full 256, plus NetFn/LUN, Cmd, cCode, plus
- * some overhead.  It would be nice to base this on the "BT Capabilities"
- * but that's too hard to propagate to the rest of the driver. */
+ * some overhead; it's not worth the effort to dynamically size this based
+ * on the results of the "Get BT Capabilities" command. */
 #define IPMI_MAX_MSG_LENGTH    272     /* multiple of 16 */
 
 #define IPMI_CC_NO_ERROR               0x00
 #define IPMI_NODE_BUSY_ERR             0xc0
 #define IPMI_INVALID_COMMAND_ERR       0xc1
+#define IPMI_TIMEOUT_ERR               0xc3
 #define IPMI_ERR_MSG_TRUNCATED         0xc6
+#define IPMI_REQ_LEN_INVALID_ERR       0xc7
+#define IPMI_REQ_LEN_EXCEEDED_ERR      0xc8
+#define IPMI_NOT_IN_MY_STATE_ERR       0xd5    /* IPMI 2.0 */
 #define IPMI_LOST_ARBITRATION_ERR      0x81
 #define IPMI_BUS_ERR                   0x82
 #define IPMI_NAK_ON_WRITE_ERR          0x83
index 6d9c7e4da4720a538fcc7f97ca30240d70cbabcf..c0633108d05dc3c4f5addcee52b5d44a66d86af4 100644 (file)
@@ -115,6 +115,13 @@ struct ipmi_smi_handlers
           poll for operations during things like crash dumps. */
        void (*poll)(void *send_info);
 
+       /* Enable/disable firmware maintenance mode.  Note that this
+          is *not* the modes defined, this is simply an on/off
+          setting.  The message handler does the mode handling.  Note
+          that this is called from interupt context, so it cannot
+          block. */
+       void (*set_maintenance_mode)(void *send_info, int enable);
+
        /* Tell the handler that we are using it/not using it.  The
           message handler get the modules that this handler belongs
           to; this function lets the SMI claim any modules that it
@@ -173,6 +180,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
                      void                     *send_info,
                      struct ipmi_device_id    *device_id,
                      struct device            *dev,
+                     const char               *sysfs_name,
                      unsigned char            slave_addr);
 
 /*
index 62991148d5a53aa8df83180ce0e61a6943b7bc36..3c7875b7ab5be00cd0ee375cf61904be3c6ca122 100644 (file)
@@ -511,8 +511,8 @@ typedef struct modem_info {
 #endif
   struct tty_struct    *tty;            /* Pointer to corresponding tty   */
   atemu                 emu;             /* AT-emulator data               */
-  struct termios       normal_termios;  /* For saving termios structs     */
-  struct termios       callout_termios;
+  struct ktermios      normal_termios;  /* For saving termios structs     */
+  struct ktermios      callout_termios;
   wait_queue_head_t    open_wait, close_wait;
   struct semaphore      write_sem;
   spinlock_t           readlock;
@@ -525,8 +525,8 @@ typedef struct _isdn_modem {
   int                refcount;                         /* Number of opens        */
   struct tty_driver  *tty_modem;                       /* tty-device             */
   struct tty_struct  *modem_table[ISDN_MAX_CHANNELS];  /* ?? copied from Orig    */
-  struct termios     *modem_termios[ISDN_MAX_CHANNELS];
-  struct termios     *modem_termios_locked[ISDN_MAX_CHANNELS];
+  struct ktermios     *modem_termios[ISDN_MAX_CHANNELS];
+  struct ktermios     *modem_termios_locked[ISDN_MAX_CHANNELS];
   modem_info         info[ISDN_MAX_CHANNELS];     /* Private data           */
 } isdn_modem_t;
 
index b55e2a035605af23dfec9040f9102b5cdebc2892..106a5e85e5c434e2fa784bb94c217d5864e6f609 100644 (file)
  *     communication with the slave board will always be on a per port
  *     basis.
  */
-typedef struct {
+struct stliport {
        unsigned long           magic;
-       int                     portnr;
-       int                     panelnr;
-       int                     brdnr;
+       unsigned int            portnr;
+       unsigned int            panelnr;
+       unsigned int            brdnr;
        unsigned long           state;
-       int                     devnr;
+       unsigned int            devnr;
        int                     flags;
        int                     baud_base;
        int                     custom_divisor;
@@ -72,7 +72,7 @@ typedef struct {
        wait_queue_head_t       close_wait;
        wait_queue_head_t       raw_wait;
        struct work_struct      tqhangup;
-       asysigs_t               asig;
+       struct asysigs          asig;
        unsigned long           addr;
        unsigned long           rxoffset;
        unsigned long           txoffset;
@@ -83,31 +83,31 @@ typedef struct {
        unsigned char           reqbit;
        unsigned char           portidx;
        unsigned char           portbit;
-} stliport_t;
+};
 
 /*
  *     Use a structure of function pointers to do board level operations.
  *     These include, enable/disable, paging shared memory, interrupting, etc.
  */
-typedef struct stlibrd {
+struct stlibrd {
        unsigned long   magic;
-       int             brdnr;
-       int             brdtype;
-       int             state;
-       int             nrpanels;
-       int             nrports;
-       int             nrdevs;
+       unsigned int    brdnr;
+       unsigned int    brdtype;
+       unsigned int    state;
+       unsigned int    nrpanels;
+       unsigned int    nrports;
+       unsigned int    nrdevs;
        unsigned int    iobase;
        int             iosize;
        unsigned long   memaddr;
        void            __iomem *membase;
-       int             memsize;
+       unsigned long   memsize;
        int             pagesize;
        int             hostoffset;
        int             slaveoffset;
        int             bitsize;
        int             enabval;
-       int             panels[STL_MAXPANELS];
+       unsigned int    panels[STL_MAXPANELS];
        int             panelids[STL_MAXPANELS];
        void            (*init)(struct stlibrd *brdp);
        void            (*enable)(struct stlibrd *brdp);
@@ -116,8 +116,8 @@ typedef struct stlibrd {
        void            __iomem *(*getmemptr)(struct stlibrd *brdp, unsigned long offset, int line);
        void            (*intr)(struct stlibrd *brdp);
        void            (*reset)(struct stlibrd *brdp);
-       stliport_t      *ports[STL_MAXPORTS];
-} stlibrd_t;
+       struct stliport *ports[STL_MAXPORTS];
+};
 
 
 /*
index fe89444b1c6f32145f4a0a02d1e8f13258e3f299..452737551260ef1663caa93d6ca5d7526dacd275 100644 (file)
@@ -839,7 +839,6 @@ struct journal_s
  */
 
 /* Filing buffers */
-extern void __journal_temp_unlink_buffer(struct journal_head *jh);
 extern void journal_unfile_buffer(journal_t *, struct journal_head *);
 extern void __journal_unfile_buffer(struct journal_head *);
 extern void __journal_refile_buffer(struct journal_head *);
@@ -949,7 +948,7 @@ void journal_put_journal_head(struct journal_head *jh);
 /*
  * handle management
  */
-extern kmem_cache_t *jbd_handle_cache;
+extern struct kmem_cache *jbd_handle_cache;
 
 static inline handle_t *jbd_alloc_handle(gfp_t gfp_flags)
 {
index ddb1287957817ced495fe662a235f93b704bcd6c..0e0fedd2039a3866a51fe093fb6792ef527c1804 100644 (file)
@@ -848,7 +848,6 @@ struct journal_s
  */
 
 /* Filing buffers */
-extern void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh);
 extern void jbd2_journal_unfile_buffer(journal_t *, struct journal_head *);
 extern void __jbd2_journal_unfile_buffer(struct journal_head *);
 extern void __jbd2_journal_refile_buffer(struct journal_head *);
@@ -958,7 +957,7 @@ void jbd2_journal_put_journal_head(struct journal_head *jh);
 /*
  * handle management
  */
-extern kmem_cache_t *jbd2_handle_cache;
+extern struct kmem_cache *jbd2_handle_cache;
 
 static inline handle_t *jbd_alloc_handle(gfp_t gfp_flags)
 {
index 6738283ac38550a1258b69fdf6b9e537c6abe1b2..e8bfac34d2ba1cdd6192b5c270ef9d41159df883 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/types.h>
 #include <linux/compiler.h>
 #include <linux/bitops.h>
+#include <linux/log2.h>
 #include <asm/byteorder.h>
 #include <asm/bug.h>
 
@@ -157,20 +158,6 @@ static inline int printk(const char *s, ...) { return 0; }
 
 unsigned long int_sqrt(unsigned long);
 
-static inline int __attribute_pure__ long_log2(unsigned long x)
-{
-       int r = 0;
-       for (x >>= 1; x > 0; x >>= 1)
-               r++;
-       return r;
-}
-
-static inline unsigned long
-__attribute_const__ roundup_pow_of_two(unsigned long x)
-{
-       return 1UL << fls_long(x - 1);
-}
-
 extern int printk_ratelimit(void);
 extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst);
 extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
index a4ede62b339d360b7845933b913e11ac6084a157..d02425cdd801c28d94cef85666bdc564ae6c867e 100644 (file)
@@ -105,9 +105,14 @@ extern struct page *kimage_alloc_control_pages(struct kimage *image,
                                                unsigned int order);
 extern void crash_kexec(struct pt_regs *);
 int kexec_should_crash(struct task_struct *);
+void crash_save_cpu(struct pt_regs *regs, int cpu);
 extern struct kimage *kexec_image;
 extern struct kimage *kexec_crash_image;
 
+#ifndef kexec_flush_icache_page
+#define kexec_flush_icache_page(page)
+#endif
+
 #define KEXEC_ON_CRASH  0x00000001
 #define KEXEC_ARCH_MASK 0xffff0000
 
@@ -133,6 +138,7 @@ extern struct resource crashk_res;
 typedef u32 note_buf_t[MAX_NOTE_BYTES/4];
 extern note_buf_t *crash_notes;
 
+
 #else /* !CONFIG_KEXEC */
 struct pt_regs;
 struct task_struct;
index ac4c0559f7510e16c8b2c6113964284f762fcc9d..769be39b96810414ebdec4fec05d94e997eba5eb 100644 (file)
@@ -165,7 +165,7 @@ extern void arch_disarm_kprobe(struct kprobe *p);
 extern int arch_init_kprobes(void);
 extern void show_registers(struct pt_regs *regs);
 extern kprobe_opcode_t *get_insn_slot(void);
-extern void free_insn_slot(kprobe_opcode_t *slot);
+extern void free_insn_slot(kprobe_opcode_t *slot, int dirty);
 extern void kprobes_inc_nmissed_count(struct kprobe *p);
 
 /* Get the kprobe at this addr (if any) - called with preemption disabled */
index 84eeecd60a02644a6cc64563747a594b8bafbb54..611f17f79eefe32f78605589f175db8a77616474 100644 (file)
@@ -248,9 +248,9 @@ static inline struct timeval ktime_to_timeval(const ktime_t kt)
  *
  * Returns the scalar nanoseconds representation of kt
  */
-static inline u64 ktime_to_ns(const ktime_t kt)
+static inline s64 ktime_to_ns(const ktime_t kt)
 {
-       return (u64) kt.tv.sec * NSEC_PER_SEC + kt.tv.nsec;
+       return (s64) kt.tv.sec * NSEC_PER_SEC + kt.tv.nsec;
 }
 
 #endif
index 862d9730a60dd4e4b4de43d60363c4434b11f94a..0c962b82a9debb6d0ada12f09370fe152390cde9 100644 (file)
@@ -164,14 +164,12 @@ void                nlmclnt_next_cookie(struct nlm_cookie *);
  */
 struct nlm_host * nlmclnt_lookup_host(const struct sockaddr_in *, int, int, const char *, int);
 struct nlm_host * nlmsvc_lookup_host(struct svc_rqst *, const char *, int);
-struct nlm_host * nlm_lookup_host(int server, const struct sockaddr_in *, int, int, const char *, int);
 struct rpc_clnt * nlm_bind_host(struct nlm_host *);
 void             nlm_rebind_host(struct nlm_host *);
 struct nlm_host * nlm_get_host(struct nlm_host *);
 void             nlm_release_host(struct nlm_host *);
 void             nlm_shutdown_hosts(void);
 extern void      nlm_host_rebooted(const struct sockaddr_in *, const char *, int, u32);
-struct nsm_handle *nsm_find(const struct sockaddr_in *, const char *, int);
 void             nsm_release(struct nsm_handle *);
 
 
@@ -208,7 +206,7 @@ void                  nlmsvc_invalidate_all(void);
 static __inline__ struct inode *
 nlmsvc_file_inode(struct nlm_file *file)
 {
-       return file->f_file->f_dentry->d_inode;
+       return file->f_file->f_path.dentry->d_inode;
 }
 
 /*
index 819f08f1310db878f753e7656da2ce32590a5a69..498bfbd3b4e1acfdd0ba200e21e6a91c3eab2e3f 100644 (file)
@@ -193,7 +193,6 @@ extern void lockdep_free_key_range(void *start, unsigned long size);
 
 extern void lockdep_off(void);
 extern void lockdep_on(void);
-extern int lockdep_internal(void);
 
 /*
  * These methods are used by specific locking variants (spinlocks,
@@ -243,6 +242,8 @@ extern void lock_release(struct lockdep_map *lock, int nested,
 
 # define INIT_LOCKDEP                          .lockdep_recursion = 0,
 
+#define lockdep_depth(tsk)     ((tsk)->lockdep_depth)
+
 #else /* !LOCKDEP */
 
 static inline void lockdep_off(void)
@@ -253,11 +254,6 @@ static inline void lockdep_on(void)
 {
 }
 
-static inline int lockdep_internal(void)
-{
-       return 0;
-}
-
 # define lock_acquire(l, s, t, r, c, i)                do { } while (0)
 # define lock_release(l, n, i)                 do { } while (0)
 # define lockdep_init()                                do { } while (0)
@@ -277,6 +273,9 @@ static inline int lockdep_internal(void)
  * The class key takes no space if lockdep is disabled:
  */
 struct lock_class_key { };
+
+#define lockdep_depth(tsk)     (0)
+
 #endif /* !LOCKDEP */
 
 #if defined(CONFIG_TRACE_IRQFLAGS) && defined(CONFIG_GENERIC_HARDIRQS)
diff --git a/include/linux/log2.h b/include/linux/log2.h
new file mode 100644 (file)
index 0000000..d02e1a5
--- /dev/null
@@ -0,0 +1,157 @@
+/* Integer base 2 logarithm calculation
+ *
+ * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.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.
+ */
+
+#ifndef _LINUX_LOG2_H
+#define _LINUX_LOG2_H
+
+#include <linux/types.h>
+#include <linux/bitops.h>
+
+/*
+ * deal with unrepresentable constant logarithms
+ */
+extern __attribute__((const, noreturn))
+int ____ilog2_NaN(void);
+
+/*
+ * non-constant log of base 2 calculators
+ * - the arch may override these in asm/bitops.h if they can be implemented
+ *   more efficiently than using fls() and fls64()
+ * - the arch is not required to handle n==0 if implementing the fallback
+ */
+#ifndef CONFIG_ARCH_HAS_ILOG2_U32
+static inline __attribute__((const))
+int __ilog2_u32(u32 n)
+{
+       return fls(n) - 1;
+}
+#endif
+
+#ifndef CONFIG_ARCH_HAS_ILOG2_U64
+static inline __attribute__((const))
+int __ilog2_u64(u64 n)
+{
+       return fls64(n) - 1;
+}
+#endif
+
+/*
+ * round up to nearest power of two
+ */
+static inline __attribute__((const))
+unsigned long __roundup_pow_of_two(unsigned long n)
+{
+       return 1UL << fls_long(n - 1);
+}
+
+/**
+ * ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value
+ * @n - parameter
+ *
+ * constant-capable log of base 2 calculation
+ * - this can be used to initialise global variables from constant data, hence
+ *   the massive ternary operator construction
+ *
+ * selects the appropriately-sized optimised version depending on sizeof(n)
+ */
+#define ilog2(n)                               \
+(                                              \
+       __builtin_constant_p(n) ? (             \
+               (n) < 1 ? ____ilog2_NaN() :     \
+               (n) & (1ULL << 63) ? 63 :       \
+               (n) & (1ULL << 62) ? 62 :       \
+               (n) & (1ULL << 61) ? 61 :       \
+               (n) & (1ULL << 60) ? 60 :       \
+               (n) & (1ULL << 59) ? 59 :       \
+               (n) & (1ULL << 58) ? 58 :       \
+               (n) & (1ULL << 57) ? 57 :       \
+               (n) & (1ULL << 56) ? 56 :       \
+               (n) & (1ULL << 55) ? 55 :       \
+               (n) & (1ULL << 54) ? 54 :       \
+               (n) & (1ULL << 53) ? 53 :       \
+               (n) & (1ULL << 52) ? 52 :       \
+               (n) & (1ULL << 51) ? 51 :       \
+               (n) & (1ULL << 50) ? 50 :       \
+               (n) & (1ULL << 49) ? 49 :       \
+               (n) & (1ULL << 48) ? 48 :       \
+               (n) & (1ULL << 47) ? 47 :       \
+               (n) & (1ULL << 46) ? 46 :       \
+               (n) & (1ULL << 45) ? 45 :       \
+               (n) & (1ULL << 44) ? 44 :       \
+               (n) & (1ULL << 43) ? 43 :       \
+               (n) & (1ULL << 42) ? 42 :       \
+               (n) & (1ULL << 41) ? 41 :       \
+               (n) & (1ULL << 40) ? 40 :       \
+               (n) & (1ULL << 39) ? 39 :       \
+               (n) & (1ULL << 38) ? 38 :       \
+               (n) & (1ULL << 37) ? 37 :       \
+               (n) & (1ULL << 36) ? 36 :       \
+               (n) & (1ULL << 35) ? 35 :       \
+               (n) & (1ULL << 34) ? 34 :       \
+               (n) & (1ULL << 33) ? 33 :       \
+               (n) & (1ULL << 32) ? 32 :       \
+               (n) & (1ULL << 31) ? 31 :       \
+               (n) & (1ULL << 30) ? 30 :       \
+               (n) & (1ULL << 29) ? 29 :       \
+               (n) & (1ULL << 28) ? 28 :       \
+               (n) & (1ULL << 27) ? 27 :       \
+               (n) & (1ULL << 26) ? 26 :       \
+               (n) & (1ULL << 25) ? 25 :       \
+               (n) & (1ULL << 24) ? 24 :       \
+               (n) & (1ULL << 23) ? 23 :       \
+               (n) & (1ULL << 22) ? 22 :       \
+               (n) & (1ULL << 21) ? 21 :       \
+               (n) & (1ULL << 20) ? 20 :       \
+               (n) & (1ULL << 19) ? 19 :       \
+               (n) & (1ULL << 18) ? 18 :       \
+               (n) & (1ULL << 17) ? 17 :       \
+               (n) & (1ULL << 16) ? 16 :       \
+               (n) & (1ULL << 15) ? 15 :       \
+               (n) & (1ULL << 14) ? 14 :       \
+               (n) & (1ULL << 13) ? 13 :       \
+               (n) & (1ULL << 12) ? 12 :       \
+               (n) & (1ULL << 11) ? 11 :       \
+               (n) & (1ULL << 10) ? 10 :       \
+               (n) & (1ULL <<  9) ?  9 :       \
+               (n) & (1ULL <<  8) ?  8 :       \
+               (n) & (1ULL <<  7) ?  7 :       \
+               (n) & (1ULL <<  6) ?  6 :       \
+               (n) & (1ULL <<  5) ?  5 :       \
+               (n) & (1ULL <<  4) ?  4 :       \
+               (n) & (1ULL <<  3) ?  3 :       \
+               (n) & (1ULL <<  2) ?  2 :       \
+               (n) & (1ULL <<  1) ?  1 :       \
+               (n) & (1ULL <<  0) ?  0 :       \
+               ____ilog2_NaN()                 \
+                                  ) :          \
+       (sizeof(n) <= 4) ?                      \
+       __ilog2_u32(n) :                        \
+       __ilog2_u64(n)                          \
+ )
+
+/**
+ * roundup_pow_of_two - round the given value up to nearest power of two
+ * @n - parameter
+ *
+ * round the given balue up to the nearest power of two
+ * - the result is undefined when n == 0
+ * - this can be used to initialise global variables from constant data
+ */
+#define roundup_pow_of_two(n)                  \
+(                                              \
+       __builtin_constant_p(n) ? (             \
+               (n == 1) ? 0 :                  \
+               (1UL << (ilog2((n) - 1) + 1))   \
+                                  ) :          \
+       __roundup_pow_of_two(n)                 \
+ )
+
+#endif /* _LINUX_LOG2_H */
index d538de9019652c851fc6afc281cc1eaa0969268e..a17b147c61e74853e51268c3eaf144aee8c37006 100644 (file)
@@ -114,6 +114,8 @@ struct vm_area_struct {
 #endif
 };
 
+extern struct kmem_cache *vm_area_cachep;
+
 /*
  * This struct defines the per-mm list of VMAs for uClinux. If CONFIG_MMU is
  * disabled, then there's a single shared list of VMAs maintained by the
@@ -293,6 +295,24 @@ void put_pages_list(struct list_head *pages);
 
 void split_page(struct page *page, unsigned int order);
 
+/*
+ * Compound pages have a destructor function.  Provide a
+ * prototype for that function and accessor functions.
+ * These are _only_ valid on the head of a PG_compound page.
+ */
+typedef void compound_page_dtor(struct page *);
+
+static inline void set_compound_page_dtor(struct page *page,
+                                               compound_page_dtor *dtor)
+{
+       page[1].lru.next = (void *)dtor;
+}
+
+static inline compound_page_dtor *get_compound_page_dtor(struct page *page)
+{
+       return (compound_page_dtor *)page[1].lru.next;
+}
+
 /*
  * Multiple processes may "see" the same page. E.g. for untouched
  * mappings of /dev/null, all processes see the same page full of
@@ -396,7 +416,9 @@ void split_page(struct page *page, unsigned int order);
  * We are going to use the flags for the page to node mapping if its in
  * there.  This includes the case where there is no node, so it is implicit.
  */
-#define FLAGS_HAS_NODE         (NODES_WIDTH > 0 || NODES_SHIFT == 0)
+#if !(NODES_WIDTH > 0 || NODES_SHIFT == 0)
+#define NODE_NOT_IN_PAGE_FLAGS
+#endif
 
 #ifndef PFN_SECTION_SHIFT
 #define PFN_SECTION_SHIFT 0
@@ -411,13 +433,18 @@ void split_page(struct page *page, unsigned int order);
 #define NODES_PGSHIFT          (NODES_PGOFF * (NODES_WIDTH != 0))
 #define ZONES_PGSHIFT          (ZONES_PGOFF * (ZONES_WIDTH != 0))
 
-/* NODE:ZONE or SECTION:ZONE is used to lookup the zone from a page. */
-#if FLAGS_HAS_NODE
-#define ZONETABLE_SHIFT                (NODES_SHIFT + ZONES_SHIFT)
+/* NODE:ZONE or SECTION:ZONE is used to ID a zone for the buddy allcator */
+#ifdef NODE_NOT_IN_PAGEFLAGS
+#define ZONEID_SHIFT           (SECTIONS_SHIFT + ZONES_SHIFT)
+#else
+#define ZONEID_SHIFT           (NODES_SHIFT + ZONES_SHIFT)
+#endif
+
+#if ZONES_WIDTH > 0
+#define ZONEID_PGSHIFT         ZONES_PGSHIFT
 #else
-#define ZONETABLE_SHIFT                (SECTIONS_SHIFT + ZONES_SHIFT)
+#define ZONEID_PGSHIFT         NODES_PGOFF
 #endif
-#define ZONETABLE_PGSHIFT      ZONES_PGSHIFT
 
 #if SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > FLAGS_RESERVED
 #error SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > FLAGS_RESERVED
@@ -426,26 +453,28 @@ void split_page(struct page *page, unsigned int order);
 #define ZONES_MASK             ((1UL << ZONES_WIDTH) - 1)
 #define NODES_MASK             ((1UL << NODES_WIDTH) - 1)
 #define SECTIONS_MASK          ((1UL << SECTIONS_WIDTH) - 1)
-#define ZONETABLE_MASK         ((1UL << ZONETABLE_SHIFT) - 1)
+#define ZONEID_MASK            ((1UL << ZONEID_SHIFT) - 1)
 
 static inline enum zone_type page_zonenum(struct page *page)
 {
        return (page->flags >> ZONES_PGSHIFT) & ZONES_MASK;
 }
 
-struct zone;
-extern struct zone *zone_table[];
-
+/*
+ * The identification function is only used by the buddy allocator for
+ * determining if two pages could be buddies. We are not really
+ * identifying a zone since we could be using a the section number
+ * id if we have not node id available in page flags.
+ * We guarantee only that it will return the same value for two
+ * combinable pages in a zone.
+ */
 static inline int page_zone_id(struct page *page)
 {
-       return (page->flags >> ZONETABLE_PGSHIFT) & ZONETABLE_MASK;
-}
-static inline struct zone *page_zone(struct page *page)
-{
-       return zone_table[page_zone_id(page)];
+       BUILD_BUG_ON(ZONEID_PGSHIFT == 0 && ZONEID_MASK);
+       return (page->flags >> ZONEID_PGSHIFT) & ZONEID_MASK;
 }
 
-static inline unsigned long zone_to_nid(struct zone *zone)
+static inline int zone_to_nid(struct zone *zone)
 {
 #ifdef CONFIG_NUMA
        return zone->node;
@@ -454,13 +483,20 @@ static inline unsigned long zone_to_nid(struct zone *zone)
 #endif
 }
 
-static inline unsigned long page_to_nid(struct page *page)
+#ifdef NODE_NOT_IN_PAGE_FLAGS
+extern int page_to_nid(struct page *page);
+#else
+static inline int page_to_nid(struct page *page)
+{
+       return (page->flags >> NODES_PGSHIFT) & NODES_MASK;
+}
+#endif
+
+static inline struct zone *page_zone(struct page *page)
 {
-       if (FLAGS_HAS_NODE)
-               return (page->flags >> NODES_PGSHIFT) & NODES_MASK;
-       else
-               return zone_to_nid(page_zone(page));
+       return &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)];
 }
+
 static inline unsigned long page_to_section(struct page *page)
 {
        return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK;
@@ -477,6 +513,7 @@ static inline void set_page_node(struct page *page, unsigned long node)
        page->flags &= ~(NODES_MASK << NODES_PGSHIFT);
        page->flags |= (node & NODES_MASK) << NODES_PGSHIFT;
 }
+
 static inline void set_page_section(struct page *page, unsigned long section)
 {
        page->flags &= ~(SECTIONS_MASK << SECTIONS_PGSHIFT);
@@ -947,8 +984,6 @@ extern void mem_init(void);
 extern void show_mem(void);
 extern void si_meminfo(struct sysinfo * val);
 extern void si_meminfo_node(struct sysinfo *val, int nid);
-extern void zonetable_add(struct zone *zone, int nid, enum zone_type zid,
-                                       unsigned long pfn, unsigned long size);
 
 #ifdef CONFIG_NUMA
 extern void setup_per_cpu_pageset(void);
index e06683e2bea39fb61fc02803aff1e5fcee2ce7fd..e339a7345f25ed88cce27e5e50544aa085a4a465 100644 (file)
@@ -278,7 +278,7 @@ struct zone {
        /*
         * rarely used fields:
         */
-       char                    *name;
+       const char              *name;
 } ____cacheline_internodealigned_in_smp;
 
 /*
@@ -288,19 +288,94 @@ struct zone {
  */
 #define DEF_PRIORITY 12
 
+/* Maximum number of zones on a zonelist */
+#define MAX_ZONES_PER_ZONELIST (MAX_NUMNODES * MAX_NR_ZONES)
+
+#ifdef CONFIG_NUMA
+/*
+ * We cache key information from each zonelist for smaller cache
+ * footprint when scanning for free pages in get_page_from_freelist().
+ *
+ * 1) The BITMAP fullzones tracks which zones in a zonelist have come
+ *    up short of free memory since the last time (last_fullzone_zap)
+ *    we zero'd fullzones.
+ * 2) The array z_to_n[] maps each zone in the zonelist to its node
+ *    id, so that we can efficiently evaluate whether that node is
+ *    set in the current tasks mems_allowed.
+ *
+ * Both fullzones and z_to_n[] are one-to-one with the zonelist,
+ * indexed by a zones offset in the zonelist zones[] array.
+ *
+ * The get_page_from_freelist() routine does two scans.  During the
+ * first scan, we skip zones whose corresponding bit in 'fullzones'
+ * is set or whose corresponding node in current->mems_allowed (which
+ * comes from cpusets) is not set.  During the second scan, we bypass
+ * this zonelist_cache, to ensure we look methodically at each zone.
+ *
+ * Once per second, we zero out (zap) fullzones, forcing us to
+ * reconsider nodes that might have regained more free memory.
+ * The field last_full_zap is the time we last zapped fullzones.
+ *
+ * This mechanism reduces the amount of time we waste repeatedly
+ * reexaming zones for free memory when they just came up low on
+ * memory momentarilly ago.
+ *
+ * The zonelist_cache struct members logically belong in struct
+ * zonelist.  However, the mempolicy zonelists constructed for
+ * MPOL_BIND are intentionally variable length (and usually much
+ * shorter).  A general purpose mechanism for handling structs with
+ * multiple variable length members is more mechanism than we want
+ * here.  We resort to some special case hackery instead.
+ *
+ * The MPOL_BIND zonelists don't need this zonelist_cache (in good
+ * part because they are shorter), so we put the fixed length stuff
+ * at the front of the zonelist struct, ending in a variable length
+ * zones[], as is needed by MPOL_BIND.
+ *
+ * Then we put the optional zonelist cache on the end of the zonelist
+ * struct.  This optional stuff is found by a 'zlcache_ptr' pointer in
+ * the fixed length portion at the front of the struct.  This pointer
+ * both enables us to find the zonelist cache, and in the case of
+ * MPOL_BIND zonelists, (which will just set the zlcache_ptr to NULL)
+ * to know that the zonelist cache is not there.
+ *
+ * The end result is that struct zonelists come in two flavors:
+ *  1) The full, fixed length version, shown below, and
+ *  2) The custom zonelists for MPOL_BIND.
+ * The custom MPOL_BIND zonelists have a NULL zlcache_ptr and no zlcache.
+ *
+ * Even though there may be multiple CPU cores on a node modifying
+ * fullzones or last_full_zap in the same zonelist_cache at the same
+ * time, we don't lock it.  This is just hint data - if it is wrong now
+ * and then, the allocator will still function, perhaps a bit slower.
+ */
+
+
+struct zonelist_cache {
+       unsigned short z_to_n[MAX_ZONES_PER_ZONELIST];          /* zone->nid */
+       DECLARE_BITMAP(fullzones, MAX_ZONES_PER_ZONELIST);      /* zone full? */
+       unsigned long last_full_zap;            /* when last zap'd (jiffies) */
+};
+#else
+struct zonelist_cache;
+#endif
+
 /*
  * One allocation request operates on a zonelist. A zonelist
  * is a list of zones, the first one is the 'goal' of the
  * allocation, the other zones are fallback zones, in decreasing
  * priority.
  *
- * Right now a zonelist takes up less than a cacheline. We never
- * modify it apart from boot-up, and only a few indices are used,
- * so despite the zonelist table being relatively big, the cache
- * footprint of this construct is very small.
+ * If zlcache_ptr is not NULL, then it is just the address of zlcache,
+ * as explained above.  If zlcache_ptr is NULL, there is no zlcache.
  */
+
 struct zonelist {
-       struct zone *zones[MAX_NUMNODES * MAX_NR_ZONES + 1]; // NULL delimited
+       struct zonelist_cache *zlcache_ptr;                  // NULL or &zlcache
+       struct zone *zones[MAX_ZONES_PER_ZONELIST + 1];      // NULL delimited
+#ifdef CONFIG_NUMA
+       struct zonelist_cache zlcache;                       // optional ...
+#endif
 };
 
 #ifdef CONFIG_ARCH_POPULATES_NODE_MAP
diff --git a/include/linux/mnt_namespace.h b/include/linux/mnt_namespace.h
new file mode 100644 (file)
index 0000000..4af0b1f
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef _NAMESPACE_H_
+#define _NAMESPACE_H_
+#ifdef __KERNEL__
+
+#include <linux/mount.h>
+#include <linux/sched.h>
+#include <linux/nsproxy.h>
+
+struct mnt_namespace {
+       atomic_t                count;
+       struct vfsmount *       root;
+       struct list_head        list;
+       wait_queue_head_t poll;
+       int event;
+};
+
+extern int copy_mnt_ns(int, struct task_struct *);
+extern void __put_mnt_ns(struct mnt_namespace *ns);
+extern struct mnt_namespace *dup_mnt_ns(struct task_struct *,
+               struct fs_struct *);
+
+static inline void put_mnt_ns(struct mnt_namespace *ns)
+{
+       if (atomic_dec_and_lock(&ns->count, &vfsmount_lock))
+               /* releases vfsmount_lock */
+               __put_mnt_ns(ns);
+}
+
+static inline void exit_mnt_ns(struct task_struct *p)
+{
+       struct mnt_namespace *ns = p->nsproxy->mnt_ns;
+       if (ns)
+               put_mnt_ns(ns);
+}
+
+static inline void get_mnt_ns(struct mnt_namespace *ns)
+{
+       atomic_inc(&ns->count);
+}
+
+#endif
+#endif
index d33df2408e0518033ecd846637bfa77309296872..10f771a49997e6d4f289c4be1b0013f099eb9db4 100644 (file)
@@ -319,6 +319,13 @@ struct module
 
        unsigned int taints;    /* same bits as kernel:tainted */
 
+#ifdef CONFIG_GENERIC_BUG
+       /* Support for BUG */
+       struct list_head bug_list;
+       struct bug_entry *bug_table;
+       unsigned num_bugs;
+#endif
+
 #ifdef CONFIG_MODULE_UNLOAD
        /* Reference counts */
        struct module_ref ref[NR_CPUS];
index 7c0c2c198f1f64400cb269d2e9608031e690ea30..4a189dadb1607a0984cb41cac9f389d2a86afc65 100644 (file)
@@ -63,6 +63,9 @@ struct kparam_array
    not there, read bits mean it's readable, write bits mean it's
    writable. */
 #define __module_param_call(prefix, name, set, get, arg, perm)         \
+       /* Default value instead of permissions? */                     \
+       static int __param_perm_check_##name __attribute__((unused)) =  \
+       BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)); \
        static char __param_str_##name[] = prefix #name;                \
        static struct kernel_param const __param_##name                 \
        __attribute_used__                                              \
index 403d1a97c512909c311815c4a282af8ea541351f..e357dc86a4de304c0fd77cdcc83fce0ffa475319 100644 (file)
@@ -20,7 +20,7 @@
 struct super_block;
 struct vfsmount;
 struct dentry;
-struct namespace;
+struct mnt_namespace;
 
 #define MNT_NOSUID     0x01
 #define MNT_NODEV      0x02
@@ -52,7 +52,7 @@ struct vfsmount {
        struct list_head mnt_slave_list;/* list of slave mounts */
        struct list_head mnt_slave;     /* slave list entry */
        struct vfsmount *mnt_master;    /* slave is on master->mnt_slave_list */
-       struct namespace *mnt_namespace; /* containing namespace */
+       struct mnt_namespace *mnt_ns;   /* containing namespace */
        int mnt_pinned;
 };
 
index acc7c174ff0091aeb8f46bed30e378633c48ef21..f1b60740d641c5a61daaed95f68b12e465b331ed 100644 (file)
@@ -92,6 +92,12 @@ struct msg_queue {
        struct list_head q_senders;
 };
 
+/* Helper routines for sys_msgsnd and sys_msgrcv */
+extern long do_msgsnd(int msqid, long mtype, void __user *mtext,
+                       size_t msgsz, int msgflg);
+extern long do_msgrcv(int msqid, long *pmtype, void __user *mtext,
+                       size_t msgsz, long msgtyp, int msgflg);
+
 #endif /* __KERNEL__ */
 
 #endif /* _LINUX_MSG_H */
index 27c48daa3183297dd84e0d6345093c8a12c14145..a7544afd7582cff85c1aa374f6073cb99a331f6e 100644 (file)
@@ -94,7 +94,7 @@ do {                                                  \
 
 #define __MUTEX_INITIALIZER(lockname) \
                { .count = ATOMIC_INIT(1) \
-               , .wait_lock = SPIN_LOCK_UNLOCKED \
+               , .wait_lock = __SPIN_LOCK_UNLOCKED(lockname.wait_lock) \
                , .wait_list = LIST_HEAD_INIT(lockname.wait_list) \
                __DEBUG_MUTEX_INITIALIZER(lockname) \
                __DEP_MAP_MUTEX_INITIALIZER(lockname) }
@@ -125,8 +125,10 @@ extern int fastcall mutex_lock_interruptible(struct mutex *lock);
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass);
+extern int mutex_lock_interruptible_nested(struct mutex *lock, unsigned int subclass);
 #else
 # define mutex_lock_nested(lock, subclass) mutex_lock(lock)
+# define mutex_lock_interruptible_nested(lock, subclass) mutex_lock_interruptible(lock)
 #endif
 
 /*
index f5f19606effbd0c84f74007aaf25c145e76d9eef..d39a5a67e97988ff423b0b458161f1409e9edece 100644 (file)
@@ -29,6 +29,11 @@ struct nameidata {
        } intent;
 };
 
+struct path {
+       struct vfsmount *mnt;
+       struct dentry *dentry;
+};
+
 /*
  * Type of the last component on LOOKUP_PARENT
  */
diff --git a/include/linux/namespace.h b/include/linux/namespace.h
deleted file mode 100644 (file)
index d137009..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef _NAMESPACE_H_
-#define _NAMESPACE_H_
-#ifdef __KERNEL__
-
-#include <linux/mount.h>
-#include <linux/sched.h>
-#include <linux/nsproxy.h>
-
-struct namespace {
-       atomic_t                count;
-       struct vfsmount *       root;
-       struct list_head        list;
-       wait_queue_head_t poll;
-       int event;
-};
-
-extern int copy_namespace(int, struct task_struct *);
-extern void __put_namespace(struct namespace *namespace);
-extern struct namespace *dup_namespace(struct task_struct *, struct fs_struct *);
-
-static inline void put_namespace(struct namespace *namespace)
-{
-       if (atomic_dec_and_lock(&namespace->count, &vfsmount_lock))
-               /* releases vfsmount_lock */
-               __put_namespace(namespace);
-}
-
-static inline void exit_namespace(struct task_struct *p)
-{
-       struct namespace *namespace = p->nsproxy->namespace;
-       if (namespace) {
-               put_namespace(namespace);
-       }
-}
-
-static inline void get_namespace(struct namespace *namespace)
-{
-       atomic_inc(&namespace->count);
-}
-
-#endif
-#endif
index d6b6dc09ad972d9f844da2e64d765d254ee8f87f..0f3e69302540d71222d61fa22e2fbdbd2706aae9 100644 (file)
@@ -64,6 +64,7 @@ struct nbd_device {
        struct gendisk *disk;
        int blksize;
        u64 bytesize;
+       pid_t pid; /* pid of nbd-client, if attached */
 };
 
 #endif
index c57088f575a37d9961bab86e25bcbcc8658f424f..6be767c76b37df983084121cf9e2d21a448831c4 100644 (file)
@@ -193,13 +193,20 @@ struct hh_cache
 {
        struct hh_cache *hh_next;       /* Next entry                        */
        atomic_t        hh_refcnt;      /* number of users                   */
-       __be16          hh_type;        /* protocol identifier, f.e ETH_P_IP
+/*
+ * We want hh_output, hh_len, hh_lock and hh_data be a in a separate
+ * cache line on SMP.
+ * They are mostly read, but hh_refcnt may be changed quite frequently,
+ * incurring cache line ping pongs.
+ */
+       __be16          hh_type ____cacheline_aligned_in_smp;
+                                       /* protocol identifier, f.e ETH_P_IP
                                          *  NOTE:  For VLANs, this will be the
                                          *  encapuslated type. --BLG
                                          */
        u16             hh_len;         /* length of header */
        int             (*hh_output)(struct sk_buff *skb);
-       rwlock_t        hh_lock;
+       seqlock_t       hh_lock;
 
        /* cached hardware header; allow for machine alignment needs.        */
 #define HH_DATA_MOD    16
index fb049ec11ff26ab6e6230a884fd57e7c4b9afed3..9d8144a488cd5bfa5a29910b8d1684cb0ace2386 100644 (file)
@@ -2,6 +2,8 @@
 #ifndef _NF_CONNTRACK_PPTP_H
 #define _NF_CONNTRACK_PPTP_H
 
+#include <linux/netfilter/nf_conntrack_common.h>
+
 /* state of the control session */
 enum pptp_ctrlsess_state {
        PPTP_SESSION_NONE,                      /* no session present */
@@ -295,7 +297,6 @@ union pptp_ctrl_union {
 /* crap needed for nf_conntrack_compat.h */
 struct nf_conn;
 struct nf_conntrack_expect;
-enum ip_conntrack_info;
 
 extern int
 (*nf_nat_pptp_hook_outbound)(struct sk_buff **pskb,
index 625ffea98561e4ca340636c1e5610ed66931d5a1..04963063e6200023dd0524f023b30f4973317df1 100644 (file)
@@ -33,6 +33,7 @@
 #define FLUSH_HIGHPRI          16      /* high priority memory reclaim flush */
 #define FLUSH_NOCOMMIT         32      /* Don't send the NFSv3/v4 COMMIT */
 #define FLUSH_INVALIDATE       64      /* Invalidate the page cache */
+#define FLUSH_NOWRITEPAGE      128     /* Don't call writepage() */
 
 #ifdef __KERNEL__
 
@@ -427,19 +428,21 @@ extern int  nfs_flush_incompatible(struct file *file, struct page *page);
 extern int  nfs_updatepage(struct file *, struct page *, unsigned int, unsigned int);
 extern int nfs_writeback_done(struct rpc_task *, struct nfs_write_data *);
 extern void nfs_writedata_release(void *);
-
-#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
-struct nfs_write_data *nfs_commit_alloc(void);
-void nfs_commit_free(struct nfs_write_data *p);
-#endif
+extern int nfs_set_page_dirty(struct page *);
 
 /*
  * Try to write back everything synchronously (but check the
  * return value!)
  */
-extern int  nfs_sync_inode_wait(struct inode *, unsigned long, unsigned int, int);
+extern long nfs_sync_mapping_wait(struct address_space *, struct writeback_control *, int);
+extern int nfs_sync_mapping_range(struct address_space *, loff_t, loff_t, int);
+extern int nfs_wb_all(struct inode *inode);
+extern int nfs_wb_page(struct inode *inode, struct page* page);
+extern int nfs_wb_page_priority(struct inode *inode, struct page* page, int how);
 #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
 extern int  nfs_commit_inode(struct inode *, int);
+extern struct nfs_write_data *nfs_commit_alloc(void);
+extern void nfs_commit_free(struct nfs_write_data *wdata);
 extern void nfs_commit_release(void *wdata);
 #else
 static inline int
@@ -455,28 +458,6 @@ nfs_have_writebacks(struct inode *inode)
        return NFS_I(inode)->npages != 0;
 }
 
-static inline int
-nfs_wb_all(struct inode *inode)
-{
-       int error = nfs_sync_inode_wait(inode, 0, 0, 0);
-       return (error < 0) ? error : 0;
-}
-
-/*
- * Write back all requests on one page - we do this before reading it.
- */
-static inline int nfs_wb_page_priority(struct inode *inode, struct page* page, int how)
-{
-       int error = nfs_sync_inode_wait(inode, page->index, 1,
-                       how | FLUSH_STABLE);
-       return (error < 0) ? error : 0;
-}
-
-static inline int nfs_wb_page(struct inode *inode, struct page* page)
-{
-       return nfs_wb_page_priority(inode, page, 0);
-}
-
 /*
  * Allocate nfs_write_data structures
  */
index 1f7bd287c230e5cc78cc2cd079b39d77f3768c99..2e555d49c9b732fa4379b8b1c17a98cb430ce857 100644 (file)
@@ -30,6 +30,8 @@
 #define PG_BUSY                        0
 #define PG_NEED_COMMIT         1
 #define PG_NEED_RESCHED                2
+#define PG_NEED_FLUSH          3
+#define PG_FLUSHING            4
 
 struct nfs_inode;
 struct nfs_page {
@@ -60,8 +62,9 @@ extern        void nfs_clear_request(struct nfs_page *req);
 extern void nfs_release_request(struct nfs_page *req);
 
 
-extern  int nfs_scan_lock_dirty(struct nfs_inode *nfsi, struct list_head *dst,
-                               unsigned long idx_start, unsigned int npages);
+extern long nfs_scan_dirty(struct address_space *mapping,
+                               struct writeback_control *wbc,
+                               struct list_head *dst);
 extern int nfs_scan_list(struct nfs_inode *nfsi, struct list_head *head, struct list_head *dst,
                          unsigned long idx_start, unsigned int npages);
 extern int nfs_coalesce_requests(struct list_head *, struct list_head *,
index 768c1ad5ff6f93e1859ca7771fb20fbf36c4faf2..9ee9da5e1cc9de834a4e81c9155b3e9e6b0f57ca 100644 (file)
@@ -785,8 +785,6 @@ struct nfs_rpc_ops {
        int     (*readlink)(struct inode *, struct page *, unsigned int,
                            unsigned int);
        int     (*read)    (struct nfs_read_data *);
-       int     (*write)   (struct nfs_write_data *);
-       int     (*commit)  (struct nfs_write_data *);
        int     (*create)  (struct inode *, struct dentry *,
                            struct iattr *, int, struct nameidata *);
        int     (*remove)  (struct inode *, struct qstr *);
index e16904e28c3a39b57480d5bc5e64f5923cc5434a..acb4ed1302479ac4f1833466905024e013de41e7 100644 (file)
  * disables interrupts for a long time. This call is stateless.
  */
 #ifdef ARCH_HAS_NMI_WATCHDOG
+#include <asm/nmi.h>
 extern void touch_nmi_watchdog(void);
 #else
 # define touch_nmi_watchdog() touch_softlockup_watchdog()
 #endif
 
+#ifndef trigger_all_cpu_backtrace
+#define trigger_all_cpu_backtrace() do { } while (0)
+#endif
+
 #endif
index 971d1c6dfc4bf0dbffff439c5ee643fc5547832e..fdfb0e44912f1ce68794e52f6ca5cf5756f45ae7 100644 (file)
@@ -4,9 +4,10 @@
 #include <linux/spinlock.h>
 #include <linux/sched.h>
 
-struct namespace;
+struct mnt_namespace;
 struct uts_namespace;
 struct ipc_namespace;
+struct pid_namespace;
 
 /*
  * A structure to contain pointers to all per-process
@@ -23,9 +24,11 @@ struct ipc_namespace;
 struct nsproxy {
        atomic_t count;
        spinlock_t nslock;
+       unsigned long id;
        struct uts_namespace *uts_ns;
        struct ipc_namespace *ipc_ns;
-       struct namespace *namespace;
+       struct mnt_namespace *mnt_ns;
+       struct pid_namespace *pid_ns;
 };
 extern struct nsproxy init_nsproxy;
 
index c09da1e30c54f8f7d2274899d4e9be179c5efe85..51180dba9a98167eb0976f0e4d22bb9246580677 100644 (file)
 #define PCI_DEVICE_ID_NS_CS5535_IDE    0x002d
 #define PCI_DEVICE_ID_NS_CS5535_AUDIO  0x002e
 #define PCI_DEVICE_ID_NS_CS5535_USB    0x002f
-#define PCI_DEVICE_ID_NS_CS5535_VIDEO  0x0030
+#define PCI_DEVICE_ID_NS_GX_VIDEO      0x0030
 #define PCI_DEVICE_ID_NS_SATURN                0x0035
 #define PCI_DEVICE_ID_NS_SCx200_BRIDGE 0x0500
 #define PCI_DEVICE_ID_NS_SCx200_SMI    0x0501
 #define PCI_DEVICE_ID_NS_SC1100_XBUS   0x0515
 #define PCI_DEVICE_ID_NS_87410         0xd001
 
-#define PCI_DEVICE_ID_NS_CS5535_HOST_BRIDGE  0x0028
-#define PCI_DEVICE_ID_NS_CS5535_ISA_BRIDGE   0x002b
+#define PCI_DEVICE_ID_NS_GX_HOST_BRIDGE  0x0028
 
 #define PCI_VENDOR_ID_TSENG            0x100c
 #define PCI_DEVICE_ID_TSENG_W32P_2     0x3202
 #define PCI_DEVICE_ID_MOXA_C104                0x1040
 #define PCI_DEVICE_ID_MOXA_CP104U      0x1041
 #define PCI_DEVICE_ID_MOXA_CP104JU     0x1042
+#define PCI_DEVICE_ID_MOXA_CP104EL     0x1043
 #define PCI_DEVICE_ID_MOXA_CT114       0x1140
 #define PCI_DEVICE_ID_MOXA_CP114       0x1141
 #define PCI_DEVICE_ID_MOXA_CP118U      0x1180
+#define PCI_DEVICE_ID_MOXA_CP118EL     0x1181
 #define PCI_DEVICE_ID_MOXA_CP132       0x1320
 #define PCI_DEVICE_ID_MOXA_CP132U      0x1321
 #define PCI_DEVICE_ID_MOXA_CP134U      0x1340
 #define PCI_DEVICE_ID_MOXA_C168                0x1680
 #define PCI_DEVICE_ID_MOXA_CP168U      0x1681
+#define PCI_DEVICE_ID_MOXA_CP168EL     0x1682
 
 #define PCI_VENDOR_ID_CCD              0x1397
 #define PCI_DEVICE_ID_CCD_2BD0         0x2bd0
 #define PCI_DEVICE_ID_OXSEMI_16PCI95N  0x9511
 #define PCI_DEVICE_ID_OXSEMI_16PCI954PP        0x9513
 #define PCI_DEVICE_ID_OXSEMI_16PCI952  0x9521
+#define PCI_DEVICE_ID_OXSEMI_16PCI952PP        0x9523
 
 #define PCI_VENDOR_ID_SAMSUNG          0x144d
 
 #define PCI_DEVICE_ID_TIGON3_5750M     0x167c
 #define PCI_DEVICE_ID_TIGON3_5751M     0x167d
 #define PCI_DEVICE_ID_TIGON3_5751F     0x167e
+#define PCI_DEVICE_ID_TIGON3_5787F     0x167f
 #define PCI_DEVICE_ID_TIGON3_5787M     0x1693
 #define PCI_DEVICE_ID_TIGON3_5782      0x1696
 #define PCI_DEVICE_ID_TIGON3_5786      0x169a
 #define PCI_DEVICE_ID_FARSITE_TE1       0x1610
 #define PCI_DEVICE_ID_FARSITE_TE1C      0x1612
 
+#define PCI_VENDOR_ID_ARIMA            0x161f
+
 #define PCI_VENDOR_ID_SIBYTE           0x166d
 #define PCI_DEVICE_ID_BCM1250_PCI      0x0001
 #define PCI_DEVICE_ID_BCM1250_HT       0x0002
index 0f0b880c428034f66f9a6203fa58d1f5962541fe..265bafab64941225f0cad5900e349e4849bdde42 100644 (file)
@@ -285,6 +285,7 @@ struct sadb_x_sec_ctx {
 #define SADB_X_AALG_SHA2_384HMAC       6
 #define SADB_X_AALG_SHA2_512HMAC       7
 #define SADB_X_AALG_RIPEMD160HMAC      8
+#define SADB_X_AALG_AES_XCBC_MAC       9
 #define SADB_X_AALG_NULL               251     /* kame */
 #define SADB_AALG_MAX                  251
 
index 2c0007d172189390911779471f54db752e3dd50d..4dec047b1837f1d7e365d1127dbbc68e4937d201 100644 (file)
@@ -35,8 +35,9 @@ enum pid_type
  *
  * Holding a reference to struct pid solves both of these problems.
  * It is small so holding a reference does not consume a lot of
- * resources, and since a new struct pid is allocated when the numeric
- * pid value is reused we don't mistakenly refer to new processes.
+ * resources, and since a new struct pid is allocated when the numeric pid
+ * value is reused (when pids wrap around) we don't mistakenly refer to new
+ * processes.
  */
 
 struct pid
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
new file mode 100644 (file)
index 0000000..d2a9d41
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef _LINUX_PID_NS_H
+#define _LINUX_PID_NS_H
+
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/threads.h>
+#include <linux/pid.h>
+#include <linux/nsproxy.h>
+#include <linux/kref.h>
+
+struct pidmap {
+       atomic_t nr_free;
+       void *page;
+};
+
+#define PIDMAP_ENTRIES         ((PID_MAX_LIMIT + 8*PAGE_SIZE - 1)/PAGE_SIZE/8)
+
+struct pid_namespace {
+       struct kref kref;
+       struct pidmap pidmap[PIDMAP_ENTRIES];
+       int last_pid;
+       struct task_struct *child_reaper;
+};
+
+extern struct pid_namespace init_pid_ns;
+
+static inline void get_pid_ns(struct pid_namespace *ns)
+{
+       kref_get(&ns->kref);
+}
+
+extern int copy_pid_ns(int flags, struct task_struct *tsk);
+extern void free_pid_ns(struct kref *kref);
+
+static inline void put_pid_ns(struct pid_namespace *ns)
+{
+       kref_put(&ns->kref, free_pid_ns);
+}
+
+static inline struct task_struct *child_reaper(struct task_struct *tsk)
+{
+       return tsk->nsproxy->pid_ns->child_reaper;
+}
+
+#endif /* _LINUX_PID_NS_H */
index 8a94c717c26636fb6e21f54db6c1c63e1a066f2d..5ea4f05683f6c838df23f48c2b8381a054ae7938 100644 (file)
@@ -111,6 +111,13 @@ struct pkt_ctrl_command {
 #include <linux/blkdev.h>
 #include <linux/completion.h>
 #include <linux/cdrom.h>
+#include <linux/kobject.h>
+#include <linux/sysfs.h>
+
+/* default bio write queue congestion marks */
+#define PKT_WRITE_CONGESTION_ON    10000
+#define PKT_WRITE_CONGESTION_OFF   9000
+
 
 struct packet_settings
 {
@@ -241,6 +248,14 @@ struct packet_stacked_data
 };
 #define PSD_POOL_SIZE          64
 
+struct pktcdvd_kobj
+{
+       struct kobject          kobj;
+       struct pktcdvd_device   *pd;
+};
+#define to_pktcdvdkobj(_k) \
+  ((struct pktcdvd_kobj*)container_of(_k,struct pktcdvd_kobj,kobj))
+
 struct pktcdvd_device
 {
        struct block_device     *bdev;          /* dev attached */
@@ -271,6 +286,16 @@ struct pktcdvd_device
 
        struct packet_iosched   iosched;
        struct gendisk          *disk;
+
+       int                     write_congestion_off;
+       int                     write_congestion_on;
+
+       struct class_device     *clsdev;        /* sysfs pktcdvd[0-7] class dev */
+       struct pktcdvd_kobj     *kobj_stat;     /* sysfs pktcdvd[0-7]/stat/     */
+       struct pktcdvd_kobj     *kobj_wqueue;   /* sysfs pktcdvd[0-7]/write_queue/ */
+
+       struct dentry           *dfs_d_root;    /* debugfs: devname directory */
+       struct dentry           *dfs_f_info;    /* debugfs: info file */
 };
 
 #endif /* __KERNEL__ */
index acce53fd38b6484416ddc855996c0974bada2e81..5670b340c4ef4d7b5561f7d5635e4386a135b11b 100644 (file)
@@ -6,10 +6,15 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/cpumask.h>
+#include <linux/cache.h>
+
 #include <asm/errno.h>
 
+extern int prof_on __read_mostly;
+
 #define CPU_PROFILING  1
 #define SCHED_PROFILING        2
+#define SLEEP_PROFILING        3
 
 struct proc_dir_entry;
 struct pt_regs;
@@ -18,7 +23,24 @@ struct notifier_block;
 /* init basic kernel profiler */
 void __init profile_init(void);
 void profile_tick(int);
-void profile_hit(int, void *);
+
+/*
+ * Add multiple profiler hits to a given address:
+ */
+void profile_hits(int, void *ip, unsigned int nr_hits);
+
+/*
+ * Single profiler hit:
+ */
+static inline void profile_hit(int type, void *ip)
+{
+       /*
+        * Speedup for the common (no profiling enabled) case:
+        */
+       if (unlikely(prof_on == type))
+               profile_hits(type, ip, 1);
+}
+
 #ifdef CONFIG_PROC_FS
 void create_prof_cpu_mask(struct proc_dir_entry *);
 #else
diff --git a/include/linux/pspace.h b/include/linux/pspace.h
deleted file mode 100644 (file)
index 91d48b8..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef _LINUX_PSPACE_H
-#define _LINUX_PSPACE_H
-
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/threads.h>
-#include <linux/pid.h>
-
-struct pidmap {
-       atomic_t nr_free;
-       void *page;
-};
-
-#define PIDMAP_ENTRIES         ((PID_MAX_LIMIT + 8*PAGE_SIZE - 1)/PAGE_SIZE/8)
-
-struct pspace {
-       struct pidmap pidmap[PIDMAP_ENTRIES];
-       int last_pid;
-};
-
-extern struct pspace init_pspace;
-
-#endif /* _LINUX_PSPACE_H */
index 5110201a415949e5e10bd8381ff4f38e120320cf..90c23f690c0deab4fedeb6f5126dfbb4838cb54d 100644 (file)
@@ -37,6 +37,9 @@ extern int dquot_release(struct dquot *dquot);
 extern int dquot_commit_info(struct super_block *sb, int type);
 extern int dquot_mark_dquot_dirty(struct dquot *dquot);
 
+int remove_inode_dquot_ref(struct inode *inode, int type,
+                          struct list_head *tofree_head);
+
 extern int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path);
 extern int vfs_quota_on_mount(struct super_block *sb, char *qf_name,
                int format_id, int type);
index cbfa1153742120d4a01798e181a06815555281e6..0deb842541acee1aad74d1e742895ba9812d0661 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2001 Momchil Velikov
  * Portions Copyright (C) 2001 Christoph Hellwig
+ * Copyright (C) 2006 Nick Piggin
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
 
 #include <linux/preempt.h>
 #include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/rcupdate.h>
+
+/*
+ * A direct pointer (root->rnode pointing directly to a data item,
+ * rather than another radix_tree_node) is signalled by the low bit
+ * set in the root->rnode pointer.
+ *
+ * In this case root->height is also NULL, but the direct pointer tests are
+ * needed for RCU lookups when root->height is unreliable.
+ */
+#define RADIX_TREE_DIRECT_PTR  1
+
+static inline void *radix_tree_ptr_to_direct(void *ptr)
+{
+       return (void *)((unsigned long)ptr | RADIX_TREE_DIRECT_PTR);
+}
+
+static inline void *radix_tree_direct_to_ptr(void *ptr)
+{
+       return (void *)((unsigned long)ptr & ~RADIX_TREE_DIRECT_PTR);
+}
+
+static inline int radix_tree_is_direct_ptr(void *ptr)
+{
+       return (int)((unsigned long)ptr & RADIX_TREE_DIRECT_PTR);
+}
+
+/*** radix-tree API starts here ***/
 
 #define RADIX_TREE_MAX_TAGS 2
 
@@ -47,6 +77,77 @@ do {                                                                 \
        (root)->rnode = NULL;                                           \
 } while (0)
 
+/**
+ * Radix-tree synchronization
+ *
+ * The radix-tree API requires that users provide all synchronisation (with
+ * specific exceptions, noted below).
+ *
+ * Synchronization of access to the data items being stored in the tree, and
+ * management of their lifetimes must be completely managed by API users.
+ *
+ * For API usage, in general,
+ * - any function _modifying_ the the tree or tags (inserting or deleting
+ *   items, setting or clearing tags must exclude other modifications, and
+ *   exclude any functions reading the tree.
+ * - any function _reading_ the the tree or tags (looking up items or tags,
+ *   gang lookups) must exclude modifications to the tree, but may occur
+ *   concurrently with other readers.
+ *
+ * The notable exceptions to this rule are the following functions:
+ * radix_tree_lookup
+ * radix_tree_tag_get
+ * radix_tree_gang_lookup
+ * radix_tree_gang_lookup_tag
+ * radix_tree_tagged
+ *
+ * The first 4 functions are able to be called locklessly, using RCU. The
+ * caller must ensure calls to these functions are made within rcu_read_lock()
+ * regions. Other readers (lock-free or otherwise) and modifications may be
+ * running concurrently.
+ *
+ * It is still required that the caller manage the synchronization and lifetimes
+ * of the items. So if RCU lock-free lookups are used, typically this would mean
+ * that the items have their own locks, or are amenable to lock-free access; and
+ * that the items are freed by RCU (or only freed after having been deleted from
+ * the radix tree *and* a synchronize_rcu() grace period).
+ *
+ * (Note, rcu_assign_pointer and rcu_dereference are not needed to control
+ * access to data items when inserting into or looking up from the radix tree)
+ *
+ * radix_tree_tagged is able to be called without locking or RCU.
+ */
+
+/**
+ * radix_tree_deref_slot       - dereference a slot
+ * @pslot:     pointer to slot, returned by radix_tree_lookup_slot
+ * Returns:    item that was stored in that slot with any direct pointer flag
+ *             removed.
+ *
+ * For use with radix_tree_lookup_slot().  Caller must hold tree at least read
+ * locked across slot lookup and dereference.  More likely, will be used with
+ * radix_tree_replace_slot(), as well, so caller will hold tree write locked.
+ */
+static inline void *radix_tree_deref_slot(void **pslot)
+{
+       return radix_tree_direct_to_ptr(*pslot);
+}
+/**
+ * radix_tree_replace_slot     - replace item in a slot
+ * @pslot:     pointer to slot, returned by radix_tree_lookup_slot
+ * @item:      new item to store in the slot.
+ *
+ * For use with radix_tree_lookup_slot().  Caller must hold tree write locked
+ * across slot lookup and replacement.
+ */
+static inline void radix_tree_replace_slot(void **pslot, void *item)
+{
+       BUG_ON(radix_tree_is_direct_ptr(item));
+       rcu_assign_pointer(*pslot,
+               (void *)((unsigned long)item |
+                       ((unsigned long)*pslot & RADIX_TREE_DIRECT_PTR)));
+}
+
 int radix_tree_insert(struct radix_tree_root *, unsigned long, void *);
 void *radix_tree_lookup(struct radix_tree_root *, unsigned long);
 void **radix_tree_lookup_slot(struct radix_tree_root *, unsigned long);
index f13299a15591ed6170bb440495b69edd6262104a..03636d7918fef80b565b0e1141247be35c79bd88 100644 (file)
@@ -235,7 +235,7 @@ struct raid5_private_data {
         */
        int                     active_name;
        char                    cache_name[2][20];
-       kmem_cache_t            *slab_cache; /* for allocating stripes */
+       struct kmem_cache               *slab_cache; /* for allocating stripes */
 
        int                     seq_flush, seq_write;
        int                     quiesce;
index 7bc6bfb86253899c9ad088ffa39e9f4c81c71147..c3fc6caaad3f94bb196457feb20fa563c43f0848 100644 (file)
@@ -739,7 +739,7 @@ struct block_head {
 #define PUT_B_FREE_SPACE(p_s_bh,val)  do { set_blkh_free_space(B_BLK_HEAD(p_s_bh),val); } while (0)
 
 /* Get right delimiting key. -- little endian */
-#define B_PRIGHT_DELIM_KEY(p_s_bh)   (&(blk_right_delim_key(B_BLK_HEAD(p_s_bh))
+#define B_PRIGHT_DELIM_KEY(p_s_bh)   (&(blk_right_delim_key(B_BLK_HEAD(p_s_bh))))
 
 /* Does the buffer contain a disk leaf. */
 #define B_IS_ITEMS_LEVEL(p_s_bh)     (B_LEVEL(p_s_bh) == DISK_LEAF_NODE_LEVEL)
@@ -1159,7 +1159,7 @@ znodes are the way! */
 #define PATH_READA     0x1     /* do read ahead */
 #define PATH_READA_BACK 0x2    /* read backwards */
 
-struct path {
+struct treepath {
        int path_length;        /* Length of the array above.   */
        int reada;
        struct path_element path_elements[EXTENDED_MAX_HEIGHT]; /* Array of the path elements.  */
@@ -1169,7 +1169,7 @@ struct path {
 #define pos_in_item(path) ((path)->pos_in_item)
 
 #define INITIALIZE_PATH(var) \
-struct path var = {.path_length = ILLEGAL_PATH_ELEMENT_OFFSET, .reada = 0,}
+struct treepath var = {.path_length = ILLEGAL_PATH_ELEMENT_OFFSET, .reada = 0,}
 
 /* Get path element by path and path position. */
 #define PATH_OFFSET_PELEMENT(p_s_path,n_offset)  ((p_s_path)->path_elements +(n_offset))
@@ -1327,7 +1327,7 @@ struct tree_balance {
        int need_balance_dirty;
        struct super_block *tb_sb;
        struct reiserfs_transaction_handle *transaction_handle;
-       struct path *tb_path;
+       struct treepath *tb_path;
        struct buffer_head *L[MAX_HEIGHT];      /* array of left neighbors of nodes in the path */
        struct buffer_head *R[MAX_HEIGHT];      /* array of right neighbors of nodes in the path */
        struct buffer_head *FL[MAX_HEIGHT];     /* array of fathers of the left  neighbors      */
@@ -1793,41 +1793,41 @@ static inline void copy_key(struct reiserfs_key *to,
        memcpy(to, from, KEY_SIZE);
 }
 
-int comp_items(const struct item_head *stored_ih, const struct path *p_s_path);
-const struct reiserfs_key *get_rkey(const struct path *p_s_chk_path,
+int comp_items(const struct item_head *stored_ih, const struct treepath *p_s_path);
+const struct reiserfs_key *get_rkey(const struct treepath *p_s_chk_path,
                                    const struct super_block *p_s_sb);
 int search_by_key(struct super_block *, const struct cpu_key *,
-                 struct path *, int);
+                 struct treepath *, int);
 #define search_item(s,key,path) search_by_key (s, key, path, DISK_LEAF_NODE_LEVEL)
 int search_for_position_by_key(struct super_block *p_s_sb,
                               const struct cpu_key *p_s_cpu_key,
-                              struct path *p_s_search_path);
+                              struct treepath *p_s_search_path);
 extern void decrement_bcount(struct buffer_head *p_s_bh);
-void decrement_counters_in_path(struct path *p_s_search_path);
-void pathrelse(struct path *p_s_search_path);
-int reiserfs_check_path(struct path *p);
-void pathrelse_and_restore(struct super_block *s, struct path *p_s_search_path);
+void decrement_counters_in_path(struct treepath *p_s_search_path);
+void pathrelse(struct treepath *p_s_search_path);
+int reiserfs_check_path(struct treepath *p);
+void pathrelse_and_restore(struct super_block *s, struct treepath *p_s_search_path);
 
 int reiserfs_insert_item(struct reiserfs_transaction_handle *th,
-                        struct path *path,
+                        struct treepath *path,
                         const struct cpu_key *key,
                         struct item_head *ih,
                         struct inode *inode, const char *body);
 
 int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th,
-                            struct path *path,
+                            struct treepath *path,
                             const struct cpu_key *key,
                             struct inode *inode,
                             const char *body, int paste_size);
 
 int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th,
-                          struct path *path,
+                          struct treepath *path,
                           struct cpu_key *key,
                           struct inode *inode,
                           struct page *page, loff_t new_file_size);
 
 int reiserfs_delete_item(struct reiserfs_transaction_handle *th,
-                        struct path *path,
+                        struct treepath *path,
                         const struct cpu_key *key,
                         struct inode *inode, struct buffer_head *p_s_un_bh);
 
@@ -1858,7 +1858,7 @@ void padd_item(char *item, int total_length, int length);
 #define GET_BLOCK_NO_DANGLE   16       /* don't leave any transactions running */
 
 int restart_transaction(struct reiserfs_transaction_handle *th,
-                       struct inode *inode, struct path *path);
+                       struct inode *inode, struct treepath *path);
 void reiserfs_read_locked_inode(struct inode *inode,
                                struct reiserfs_iget_args *args);
 int reiserfs_find_actor(struct inode *inode, void *p);
@@ -1905,7 +1905,7 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
 /* namei.c */
 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
 int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
-                       struct path *path, struct reiserfs_dir_entry *de);
+                       struct treepath *path, struct reiserfs_dir_entry *de);
 struct dentry *reiserfs_get_parent(struct dentry *);
 /* procfs.c */
 
@@ -1956,9 +1956,9 @@ extern const struct file_operations reiserfs_dir_operations;
 
 /* tail_conversion.c */
 int direct2indirect(struct reiserfs_transaction_handle *, struct inode *,
-                   struct path *, struct buffer_head *, loff_t);
+                   struct treepath *, struct buffer_head *, loff_t);
 int indirect2direct(struct reiserfs_transaction_handle *, struct inode *,
-                   struct page *, struct path *, const struct cpu_key *,
+                   struct page *, struct treepath *, const struct cpu_key *,
                    loff_t, char *);
 void reiserfs_unmap_buffer(struct buffer_head *);
 
@@ -2045,7 +2045,7 @@ struct __reiserfs_blocknr_hint {
        struct inode *inode;    /* inode passed to allocator, if we allocate unf. nodes */
        long block;             /* file offset, in blocks */
        struct in_core_key key;
-       struct path *path;      /* search path, used by allocator to deternine search_start by
+       struct treepath *path;  /* search path, used by allocator to deternine search_start by
                                 * various ways */
        struct reiserfs_transaction_handle *th; /* transaction handle is needed to log super blocks and
                                                 * bitmap blocks changes  */
@@ -2101,7 +2101,7 @@ static inline int reiserfs_new_form_blocknrs(struct tree_balance *tb,
 static inline int reiserfs_new_unf_blocknrs(struct reiserfs_transaction_handle
                                            *th, struct inode *inode,
                                            b_blocknr_t * new_blocknrs,
-                                           struct path *path, long block)
+                                           struct treepath *path, long block)
 {
        reiserfs_blocknr_hint_t hint = {
                .th = th,
@@ -2118,7 +2118,7 @@ static inline int reiserfs_new_unf_blocknrs(struct reiserfs_transaction_handle
 static inline int reiserfs_new_unf_blocknrs2(struct reiserfs_transaction_handle
                                             *th, struct inode *inode,
                                             b_blocknr_t * new_blocknrs,
-                                            struct path *path, long block)
+                                            struct treepath *path, long block)
 {
        reiserfs_blocknr_hint_t hint = {
                .th = th,
index 0e3d91b76996ad80b5b5e69f921fdd922cba8939..c6a48bfc8b14700b5dee19e9b6630744c5187129 100644 (file)
@@ -274,7 +274,7 @@ static inline void subbuf_start_reserve(struct rchan_buf *buf,
 /*
  * exported relay file operations, kernel/relay.c
  */
-extern struct file_operations relay_file_operations;
+extern const struct file_operations relay_file_operations;
 
 #endif /* _LINUX_RELAY_H */
 
index db2c1df4fef96acdc9715b5fb7baaa88f27c8e0f..36f850373d2c85180c0e71f523f6f70eb66463e5 100644 (file)
@@ -30,11 +30,11 @@ struct anon_vma {
 
 #ifdef CONFIG_MMU
 
-extern kmem_cache_t *anon_vma_cachep;
+extern struct kmem_cache *anon_vma_cachep;
 
 static inline struct anon_vma *anon_vma_alloc(void)
 {
-       return kmem_cache_alloc(anon_vma_cachep, SLAB_KERNEL);
+       return kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL);
 }
 
 static inline void anon_vma_free(struct anon_vma *anon_vma)
index 5d41dee82f80310d333aa2ee5ba67a07bbc54d63..b0090e9f788432f84a1d67b86d2879ad4a74e031 100644 (file)
@@ -63,7 +63,7 @@ struct hrtimer_sleeper;
 #endif
 
 #define __RT_MUTEX_INITIALIZER(mutexname) \
-       { .wait_lock = SPIN_LOCK_UNLOCKED \
+       { .wait_lock = __SPIN_LOCK_UNLOCKED(mutexname.wait_lock) \
        , .wait_list = PLIST_HEAD_INIT(mutexname.wait_list, mutexname.wait_lock) \
        , .owner = NULL \
        __DEBUG_RT_MUTEX_INITIALIZER(mutexname)}
index 493297acdae8011ee1f30a0242ba7d551dd3f669..4a629ea70cc4ca60a6f486f8653974af68dbe8cd 100644 (file)
@@ -3,6 +3,8 @@
 
 #include <linux/netlink.h>
 #include <linux/if_link.h>
+#include <linux/if_addr.h>
+#include <linux/neighbour.h>
 
 /****
  *             Routing/neighbour discovery messages.
index ae1fcadd598e222aa8f572e768aa5a331ca986a7..813cee13da0db4335a38a504916286b1550a7efb 100644 (file)
@@ -44,7 +44,8 @@ struct rw_semaphore {
 #endif
 
 #define __RWSEM_INITIALIZER(name) \
-{ 0, SPIN_LOCK_UNLOCKED, LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) }
+{ 0, __SPIN_LOCK_UNLOCKED(name.wait_lock), LIST_HEAD_INIT((name).wait_list) \
+  __RWSEM_DEP_MAP_INIT(name) }
 
 #define DECLARE_RWSEM(name) \
        struct rw_semaphore name = __RWSEM_INITIALIZER(name)
index eafe4a7b8237d902e31eef13aaacd212ea5b84f4..ad9c46071ff8bf43195f104ab842b27698f8f5e7 100644 (file)
@@ -194,7 +194,16 @@ extern void init_idle(struct task_struct *idle, int cpu);
 
 extern cpumask_t nohz_cpu_mask;
 
-extern void show_state(void);
+/*
+ * Only dump TASK_* tasks. (-1 for all tasks)
+ */
+extern void show_state_filter(unsigned long state_filter);
+
+static inline void show_state(void)
+{
+       show_state_filter(-1);
+}
+
 extern void show_regs(struct pt_regs *);
 
 /*
@@ -338,15 +347,23 @@ struct mm_struct {
 
        unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */
 
-       unsigned dumpable:2;
        cpumask_t cpu_vm_mask;
 
        /* Architecture-specific MM context */
        mm_context_t context;
 
-       /* Token based thrashing protection. */
-       unsigned long swap_token_time;
-       char recent_pagein;
+       /* Swap token stuff */
+       /*
+        * Last value of global fault stamp as seen by this process.
+        * In other words, this value gives an indication of how long
+        * it has been since this task got the token.
+        * Look at mm/thrash.c
+        */
+       unsigned int faultstamp;
+       unsigned int token_priority;
+       unsigned int last_interval;
+
+       unsigned char dumpable:2;
 
        /* coredumping support */
        int core_waiters;
@@ -419,7 +436,12 @@ struct signal_struct {
        /* job control IDs */
        pid_t pgrp;
        pid_t tty_old_pgrp;
-       pid_t session;
+
+       union {
+               pid_t session __deprecated;
+               pid_t __session;
+       };
+
        /* boolean value for session group leader */
        int leader;
 
@@ -556,7 +578,7 @@ struct sched_info {
 #endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */
 
 #ifdef CONFIG_SCHEDSTATS
-extern struct file_operations proc_schedstat_operations;
+extern const struct file_operations proc_schedstat_operations;
 #endif /* CONFIG_SCHEDSTATS */
 
 #ifdef CONFIG_TASK_DELAY_ACCT
@@ -1023,6 +1045,9 @@ struct task_struct {
 #ifdef CONFIG_TASK_DELAY_ACCT
        struct task_delay_info *delays;
 #endif
+#ifdef CONFIG_FAULT_INJECTION
+       int make_it_fail;
+#endif
 };
 
 static inline pid_t process_group(struct task_struct *tsk)
@@ -1030,6 +1055,21 @@ static inline pid_t process_group(struct task_struct *tsk)
        return tsk->signal->pgrp;
 }
 
+static inline pid_t signal_session(struct signal_struct *sig)
+{
+       return sig->__session;
+}
+
+static inline pid_t process_session(struct task_struct *tsk)
+{
+       return signal_session(tsk->signal);
+}
+
+static inline void set_signal_session(struct signal_struct *sig, pid_t session)
+{
+       sig->__session = session;
+}
+
 static inline struct pid *task_pid(struct task_struct *task)
 {
        return task->pids[PIDTYPE_PID].pid;
@@ -1223,7 +1263,6 @@ extern struct   mm_struct init_mm;
 
 #define find_task_by_pid(nr)   find_task_by_pid_type(PIDTYPE_PID, nr)
 extern struct task_struct *find_task_by_pid_type(int type, int pid);
-extern void set_special_pids(pid_t session, pid_t pgrp);
 extern void __set_special_pids(pid_t session, pid_t pgrp);
 
 /* per-UID process charging. */
@@ -1288,7 +1327,6 @@ extern int kill_pgrp(struct pid *pid, int sig, int priv);
 extern int kill_pid(struct pid *pid, int sig, int priv);
 extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp);
 extern int kill_pg_info(int, struct siginfo *, pid_t);
-extern int kill_proc_info(int, struct siginfo *, pid_t);
 extern void do_notify_parent(struct task_struct *, int);
 extern void force_sig(int, struct task_struct *);
 extern void force_sig_specific(int, struct task_struct *);
@@ -1365,7 +1403,6 @@ extern NORET_TYPE void do_group_exit(int);
 extern void daemonize(const char *, ...);
 extern int allow_signal(int);
 extern int disallow_signal(int);
-extern struct task_struct *child_reaper;
 
 extern int do_execve(char *, char __user * __user *, char __user * __user *, struct pt_regs *);
 extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *);
@@ -1610,87 +1647,6 @@ extern int sched_create_sysfs_power_savings_entries(struct sysdev_class *cls);
 
 extern void normalize_rt_tasks(void);
 
-#ifdef CONFIG_PM
-/*
- * Check if a process has been frozen
- */
-static inline int frozen(struct task_struct *p)
-{
-       return p->flags & PF_FROZEN;
-}
-
-/*
- * Check if there is a request to freeze a process
- */
-static inline int freezing(struct task_struct *p)
-{
-       return p->flags & PF_FREEZE;
-}
-
-/*
- * Request that a process be frozen
- * FIXME: SMP problem. We may not modify other process' flags!
- */
-static inline void freeze(struct task_struct *p)
-{
-       p->flags |= PF_FREEZE;
-}
-
-/*
- * Sometimes we may need to cancel the previous 'freeze' request
- */
-static inline void do_not_freeze(struct task_struct *p)
-{
-       p->flags &= ~PF_FREEZE;
-}
-
-/*
- * Wake up a frozen process
- */
-static inline int thaw_process(struct task_struct *p)
-{
-       if (frozen(p)) {
-               p->flags &= ~PF_FROZEN;
-               wake_up_process(p);
-               return 1;
-       }
-       return 0;
-}
-
-/*
- * freezing is complete, mark process as frozen
- */
-static inline void frozen_process(struct task_struct *p)
-{
-       p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN;
-}
-
-extern void refrigerator(void);
-extern int freeze_processes(void);
-extern void thaw_processes(void);
-
-static inline int try_to_freeze(void)
-{
-       if (freezing(current)) {
-               refrigerator();
-               return 1;
-       } else
-               return 0;
-}
-#else
-static inline int frozen(struct task_struct *p) { return 0; }
-static inline int freezing(struct task_struct *p) { return 0; }
-static inline void freeze(struct task_struct *p) { BUG(); }
-static inline int thaw_process(struct task_struct *p) { return 1; }
-static inline void frozen_process(struct task_struct *p) { BUG(); }
-
-static inline void refrigerator(void) {}
-static inline int freeze_processes(void) { BUG(); return 0; }
-static inline void thaw_processes(void) {}
-
-static inline int try_to_freeze(void) { return 0; }
-
-#endif /* CONFIG_PM */
 #endif /* __KERNEL__ */
 
 #endif
index 2925e66a6732937f1693e2e5fd1868ec6d86c3df..b02308ee7667790c78aed464aaddbea9e65c4fb9 100644 (file)
@@ -42,7 +42,8 @@ struct screen_info {
        u16 pages;              /* 0x32 */
        u16 vesa_attributes;    /* 0x34 */
        u32 capabilities;       /* 0x36 */
-                               /* 0x3a -- 0x3f reserved for future expansion */
+                               /* 0x3a -- 0x3b reserved for future expansion */
+                               /* 0x3c -- 0x3f micro stack for relocatable kernels */
 };
 
 extern struct screen_info screen_info;
index b95f6eb7254cd889bfc5c9db9ab2d6029e0f2994..3e3cccbb1cac355f385f474477f2222015e1e528 100644 (file)
@@ -20,7 +20,7 @@ struct seq_file {
        loff_t index;
        loff_t version;
        struct mutex lock;
-       struct seq_operations *op;
+       const struct seq_operations *op;
        void *private;
 };
 
@@ -31,7 +31,7 @@ struct seq_operations {
        int (*show) (struct seq_file *m, void *v);
 };
 
-int seq_open(struct file *, struct seq_operations *);
+int seq_open(struct file *, const struct seq_operations *);
 ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
 loff_t seq_lseek(struct file *, loff_t, int);
 int seq_release(struct inode *, struct file *);
index 8e9681413726bc5db22b6ffb031870f8bf3e91bf..71310d80c09aae4d866f743baeb6e5ae932651e2 100644 (file)
@@ -41,6 +41,7 @@ enum {
        PLAT8250_DEV_FOURPORT,
        PLAT8250_DEV_ACCENT,
        PLAT8250_DEV_BOCA,
+       PLAT8250_DEV_EXAR_ST16C554,
        PLAT8250_DEV_HUB6,
        PLAT8250_DEV_MCA,
        PLAT8250_DEV_AU1X00,
index 463ab953b0925f2607b52e20d70bc06f4fdced38..cf23813cbec2a449cadec31f9d68e50e4a4f0bf3 100644 (file)
 
 #define PORT_S3C2412   73
 
+/* Xilinx uartlite */
+#define PORT_UARTLITE  74
 
 #ifdef __KERNEL__
 
@@ -164,8 +166,8 @@ struct uart_ops {
        void            (*break_ctl)(struct uart_port *, int ctl);
        int             (*startup)(struct uart_port *);
        void            (*shutdown)(struct uart_port *);
-       void            (*set_termios)(struct uart_port *, struct termios *new,
-                                      struct termios *old);
+       void            (*set_termios)(struct uart_port *, struct ktermios *new,
+                                      struct ktermios *old);
        void            (*pm)(struct uart_port *, unsigned int state,
                              unsigned int oldstate);
        int             (*set_wake)(struct uart_port *, unsigned int state);
@@ -359,8 +361,8 @@ void uart_write_wakeup(struct uart_port *port);
  */
 void uart_update_timeout(struct uart_port *port, unsigned int cflag,
                         unsigned int baud);
-unsigned int uart_get_baud_rate(struct uart_port *port, struct termios *termios,
-                               struct termios *old, unsigned int min,
+unsigned int uart_get_baud_rate(struct uart_port *port, struct ktermios *termios,
+                               struct ktermios *old, unsigned int min,
                                unsigned int max);
 unsigned int uart_get_divisor(struct uart_port *port, unsigned int baud);
 
index b99c5ca9708d42b7aa03e8c016cb03d1a1c6bbfc..0f478a8791a2852993c82e0baea459561a947116 100644 (file)
@@ -85,18 +85,8 @@ static inline void serio_register_port(struct serio *serio)
 
 void serio_unregister_port(struct serio *serio);
 void serio_unregister_child_port(struct serio *serio);
-void __serio_unregister_port_delayed(struct serio *serio, struct module *owner);
-static inline void serio_unregister_port_delayed(struct serio *serio)
-{
-       __serio_unregister_port_delayed(serio, THIS_MODULE);
-}
-
-void __serio_register_driver(struct serio_driver *drv, struct module *owner);
-static inline void serio_register_driver(struct serio_driver *drv)
-{
-       __serio_register_driver(drv, THIS_MODULE);
-}
 
+int serio_register_driver(struct serio_driver *drv);
 void serio_unregister_driver(struct serio_driver *drv);
 
 static inline int serio_write(struct serio *serio, unsigned char data)
index 117135e33d67116e4cf303b2f3872d2c6e63a1b8..14749056dd630ac0072439ed53225caac9025c2f 100644 (file)
@@ -241,6 +241,8 @@ extern int sigprocmask(int, sigset_t *, sigset_t *);
 struct pt_regs;
 extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
 
+extern struct kmem_cache *sighand_cachep;
+
 #endif /* __KERNEL__ */
 
 #endif /* _LINUX_SIGNAL_H */
index a05a5f7c0b738ff8527dd97e1572cdcee32b69f7..4ff3940210d8f5518788d965bc1c7a73406bab36 100644 (file)
@@ -332,20 +332,20 @@ struct sk_buff {
 extern void kfree_skb(struct sk_buff *skb);
 extern void           __kfree_skb(struct sk_buff *skb);
 extern struct sk_buff *__alloc_skb(unsigned int size,
-                                  gfp_t priority, int fclone);
+                                  gfp_t priority, int fclone, int node);
 static inline struct sk_buff *alloc_skb(unsigned int size,
                                        gfp_t priority)
 {
-       return __alloc_skb(size, priority, 0);
+       return __alloc_skb(size, priority, 0, -1);
 }
 
 static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
                                               gfp_t priority)
 {
-       return __alloc_skb(size, priority, 1);
+       return __alloc_skb(size, priority, 1, -1);
 }
 
-extern struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp,
+extern struct sk_buff *alloc_skb_from_cache(struct kmem_cache *cp,
                                            unsigned int size,
                                            gfp_t priority);
 extern void           kfree_skbmem(struct sk_buff *skb);
index c4947b8a2c0333f00a520fb83db5b77a725e09fe..2271886744f87a5fb43d5f307b7c062dc54528c1 100644 (file)
@@ -7,27 +7,17 @@
 #ifndef _LINUX_SLAB_H
 #define        _LINUX_SLAB_H
 
-#if    defined(__KERNEL__)
+#ifdef __KERNEL__
 
-typedef struct kmem_cache kmem_cache_t;
+#include <linux/gfp.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <asm/page.h>          /* kmalloc_sizes.h needs PAGE_SIZE */
+#include <asm/cache.h>         /* kmalloc_sizes.h needs L1_CACHE_BYTES */
+#include <linux/compiler.h>
 
-#include       <linux/gfp.h>
-#include       <linux/init.h>
-#include       <linux/types.h>
-#include       <asm/page.h>            /* kmalloc_sizes.h needs PAGE_SIZE */
-#include       <asm/cache.h>           /* kmalloc_sizes.h needs L1_CACHE_BYTES */
-
-/* flags for kmem_cache_alloc() */
-#define        SLAB_NOFS               GFP_NOFS
-#define        SLAB_NOIO               GFP_NOIO
-#define        SLAB_ATOMIC             GFP_ATOMIC
-#define        SLAB_USER               GFP_USER
-#define        SLAB_KERNEL             GFP_KERNEL
-#define        SLAB_DMA                GFP_DMA
-
-#define SLAB_LEVEL_MASK                GFP_LEVEL_MASK
-
-#define        SLAB_NO_GROW            __GFP_NO_GROW   /* don't grow a cache */
+/* kmem_cache_t exists for legacy reasons and is not used by code in mm */
+typedef struct kmem_cache kmem_cache_t __deprecated;
 
 /* flags to pass to kmem_cache_create().
  * The first 3 are only valid when the allocator as been build
@@ -57,22 +47,23 @@ typedef struct kmem_cache kmem_cache_t;
 /* prototypes */
 extern void __init kmem_cache_init(void);
 
-extern kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned long,
-                                      void (*)(void *, kmem_cache_t *, unsigned long),
-                                      void (*)(void *, kmem_cache_t *, unsigned long));
-extern void kmem_cache_destroy(kmem_cache_t *);
-extern int kmem_cache_shrink(kmem_cache_t *);
-extern void *kmem_cache_alloc(kmem_cache_t *, gfp_t);
+extern struct kmem_cache *kmem_cache_create(const char *, size_t, size_t,
+                       unsigned long,
+                       void (*)(void *, struct kmem_cache *, unsigned long),
+                       void (*)(void *, struct kmem_cache *, unsigned long));
+extern void kmem_cache_destroy(struct kmem_cache *);
+extern int kmem_cache_shrink(struct kmem_cache *);
+extern void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
 extern void *kmem_cache_zalloc(struct kmem_cache *, gfp_t);
-extern void kmem_cache_free(kmem_cache_t *, void *);
-extern unsigned int kmem_cache_size(kmem_cache_t *);
-extern const char *kmem_cache_name(kmem_cache_t *);
+extern void kmem_cache_free(struct kmem_cache *, void *);
+extern unsigned int kmem_cache_size(struct kmem_cache *);
+extern const char *kmem_cache_name(struct kmem_cache *);
 
 /* Size description struct for general caches. */
 struct cache_sizes {
-       size_t           cs_size;
-       kmem_cache_t    *cs_cachep;
-       kmem_cache_t    *cs_dmacachep;
+       size_t                  cs_size;
+       struct kmem_cache       *cs_cachep;
+       struct kmem_cache       *cs_dmacachep;
 };
 extern struct cache_sizes malloc_sizes[];
 
@@ -211,7 +202,7 @@ extern unsigned int ksize(const void *);
 extern int slab_is_available(void);
 
 #ifdef CONFIG_NUMA
-extern void *kmem_cache_alloc_node(kmem_cache_t *, gfp_t flags, int node);
+extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
 extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
 
 static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
@@ -236,8 +227,27 @@ found:
        }
        return __kmalloc_node(size, flags, node);
 }
+
+/*
+ * kmalloc_node_track_caller is a special version of kmalloc_node that
+ * records the calling function of the routine calling it for slab leak
+ * tracking instead of just the calling function (confusing, eh?).
+ * It's useful when the call to kmalloc_node comes from a widely-used
+ * standard allocator where we care about the real place the memory
+ * allocation request comes from.
+ */
+#ifndef CONFIG_DEBUG_SLAB
+#define kmalloc_node_track_caller(size, flags, node) \
+       __kmalloc_node(size, flags, node)
 #else
-static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, gfp_t flags, int node)
+extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, void *);
+#define kmalloc_node_track_caller(size, flags, node) \
+       __kmalloc_node_track_caller(size, flags, node, \
+                       __builtin_return_address(0))
+#endif
+#else /* CONFIG_NUMA */
+static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
+                                       gfp_t flags, int node)
 {
        return kmem_cache_alloc(cachep, flags);
 }
@@ -245,10 +255,13 @@ static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
 {
        return kmalloc(size, flags);
 }
+
+#define kmalloc_node_track_caller(size, flags, node) \
+       kmalloc_track_caller(size, flags)
 #endif
 
 extern int FASTCALL(kmem_cache_reap(int));
-extern int FASTCALL(kmem_ptr_validate(kmem_cache_t *cachep, void *ptr));
+extern int FASTCALL(kmem_ptr_validate(struct kmem_cache *cachep, void *ptr));
 
 #else /* CONFIG_SLOB */
 
@@ -283,16 +296,9 @@ static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
 #define kzalloc(s, f) __kzalloc(s, f)
 #define kmalloc_track_caller kmalloc
 
-#endif /* CONFIG_SLOB */
+#define kmalloc_node_track_caller kmalloc_node
 
-/* System wide caches */
-extern kmem_cache_t    *vm_area_cachep;
-extern kmem_cache_t    *names_cachep;
-extern kmem_cache_t    *files_cachep;
-extern kmem_cache_t    *filp_cachep;
-extern kmem_cache_t    *fs_cachep;
-extern kmem_cache_t    *sighand_cachep;
-extern kmem_cache_t    *bio_cachep;
+#endif /* CONFIG_SLOB */
 
 #endif /* __KERNEL__ */
 
index 51649987f691dad9b339d3ac8d8770ac2d5ede08..7ba23ec8211b11f22edd21369f824d81b5a2ee52 100644 (file)
@@ -99,6 +99,13 @@ static inline int up_smp_call_function(void)
 static inline void smp_send_reschedule(int cpu) { }
 #define num_booting_cpus()                     1
 #define smp_prepare_boot_cpu()                 do {} while (0)
+static inline int smp_call_function_single(int cpuid, void (*func) (void *info),
+                               void *info, int retry, int wait)
+{
+       /* Disable interrupts here? */
+       func(info);
+       return 0;
+}
 
 #endif /* !SMP */
 
index 8451052ca66f4ad14da7bc1bc120578d455fb626..94b767d6427561297772ad556d9466333f424732 100644 (file)
@@ -52,6 +52,7 @@
 #include <linux/thread_info.h>
 #include <linux/kernel.h>
 #include <linux/stringify.h>
+#include <linux/bottom_half.h>
 
 #include <asm/system.h>
 
index 13a37f137ea2169dd911551b8ac4d3f4a89c06c6..4a0a329beafb5c39038473498aa60465fde05087 100644 (file)
  *     protection - since "write" code only needs to change the head, and
  *     interrupt code only needs to change the tail.
  */
-typedef struct {
+struct stlrq {
        char    *buf;
        char    *head;
        char    *tail;
-} stlrq_t;
+};
 
 /*
  *     Port, panel and board structures to hold status info about each.
@@ -67,14 +67,14 @@ typedef struct {
  *     is associated with, this makes it (fairly) easy to get back to the
  *     board/panel info for a port.
  */
-typedef struct stlport {
+struct stlport {
        unsigned long           magic;
-       int                     portnr;
-       int                     panelnr;
-       int                     brdnr;
+       unsigned int            portnr;
+       unsigned int            panelnr;
+       unsigned int            brdnr;
        int                     ioaddr;
        int                     uartaddr;
-       int                     pagenr;
+       unsigned int            pagenr;
        long                    istate;
        int                     flags;
        int                     baud_base;
@@ -97,31 +97,31 @@ typedef struct stlport {
        wait_queue_head_t       close_wait;
        struct work_struct      tqueue;
        comstats_t              stats;
-       stlrq_t                 tx;
-} stlport_t;
+       struct stlrq            tx;
+};
 
-typedef struct stlpanel {
+struct stlpanel {
        unsigned long   magic;
-       int             panelnr;
-       int             brdnr;
-       int             pagenr;
-       int             nrports;
+       unsigned int    panelnr;
+       unsigned int    brdnr;
+       unsigned int    pagenr;
+       unsigned int    nrports;
        int             iobase;
        void            *uartp;
        void            (*isr)(struct stlpanel *panelp, unsigned int iobase);
        unsigned int    hwid;
        unsigned int    ackmask;
-       stlport_t       *ports[STL_PORTSPERPANEL];
-} stlpanel_t;
+       struct stlport  *ports[STL_PORTSPERPANEL];
+};
 
-typedef struct stlbrd {
+struct stlbrd {
        unsigned long   magic;
-       int             brdnr;
-       int             brdtype;
-       int             state;
-       int             nrpanels;
-       int             nrports;
-       int             nrbnks;
+       unsigned int    brdnr;
+       unsigned int    brdtype;
+       unsigned int    state;
+       unsigned int    nrpanels;
+       unsigned int    nrports;
+       unsigned int    nrbnks;
        int             irq;
        int             irqtype;
        int             (*isr)(struct stlbrd *brdp);
@@ -136,9 +136,9 @@ typedef struct stlbrd {
        unsigned long   clk;
        unsigned int    bnkpageaddr[STL_MAXBANKS];
        unsigned int    bnkstataddr[STL_MAXBANKS];
-       stlpanel_t      *bnk2panel[STL_MAXBANKS];
-       stlpanel_t      *panels[STL_MAXPANELS];
-} stlbrd_t;
+       struct stlpanel *bnk2panel[STL_MAXBANKS];
+       struct stlpanel *panels[STL_MAXPANELS];
+};
 
 
 /*
diff --git a/include/linux/start_kernel.h b/include/linux/start_kernel.h
new file mode 100644 (file)
index 0000000..d3e5f27
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef _LINUX_START_KERNEL_H
+#define _LINUX_START_KERNEL_H
+
+#include <linux/linkage.h>
+#include <linux/init.h>
+
+/* Define the prototype for start_kernel here, rather than cluttering
+   up something else. */
+
+extern asmlinkage void __init start_kernel(void);
+
+#endif /* _LINUX_START_KERNEL_H */
index 97b62e97dd8d3fcaef89e0332005d97abd397c5c..2db2fbf349472e3760a003f6d046e35687658ed6 100644 (file)
@@ -90,8 +90,6 @@ struct gss_cred {
 #define gc_flags               gc_base.cr_flags
 #define gc_expire              gc_base.cr_expire
 
-void print_hexl(u32 *p, u_int length, u_int offset);
-
 #endif /* __KERNEL__ */
 #endif /* _LINUX_SUNRPC_AUTH_GSS_H */
 
index f6d1d646ce05c1039437ff7af52155df9afbe353..a1be89deb3af7cb0f5d592b5bbfcdb82e216ccd0 100644 (file)
@@ -53,6 +53,7 @@ struct rpc_clnt {
        struct dentry *         cl_dentry;      /* inode */
        struct rpc_clnt *       cl_parent;      /* Points to parent of clones */
        struct rpc_rtt          cl_rtt_default;
+       struct rpc_program *    cl_program;
        char                    cl_inline_name[32];
 };
 
index e4729aa676547d49926d9fe798204eb7f7910972..60fce3c928570166fdf354eee838adc22dc24d37 100644 (file)
@@ -62,12 +62,6 @@ extern unsigned int          nlm_debug;
 # define RPC_IFDEBUG(x)
 #endif
 
-#ifdef RPC_PROFILE
-# define pprintk(args...)      printk(## args)
-#else
-# define pprintk(args...)      do ; while (0)
-#endif
-
 /*
  * Sysctl interface for RPC debugging
  */
index e30ba201910ae8c24dde51bd01451a6fca6e0614..5a4b1e0206e3a8afff8bf8f7a7fc00051f121ba0 100644 (file)
 
 struct krb5_ctx {
        int                     initiate; /* 1 = initiating, 0 = accepting */
-       int                     seed_init;
-       unsigned char           seed[16];
-       int                     signalg;
-       int                     sealalg;
        struct crypto_blkcipher *enc;
        struct crypto_blkcipher *seq;
        s32                     endtime;
@@ -117,7 +113,7 @@ enum seal_alg {
 #define ENCTYPE_UNKNOWN         0x01ff
 
 s32
-make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
+make_checksum(char *, char *header, int hdrlen, struct xdr_buf *body,
                   int body_offset, struct xdr_netobj *cksum);
 
 u32 gss_get_mic_kerberos(struct gss_ctx *, struct xdr_buf *,
index 2cf3fbb40b4fe1e9617153e86be151ac44c62c0b..e3e6a3437f8b20b63c31bfdc792a16a906ebe2f9 100644 (file)
 #include <linux/sunrpc/gss_asn1.h>
 
 struct spkm3_ctx {
-       struct xdr_netobj       ctx_id; /* per message context id */
-       int                     qop;         /* negotiated qop */
+       struct xdr_netobj       ctx_id;  /* per message context id */
+       int                     endtime; /* endtime of the context */
        struct xdr_netobj       mech_used;
        unsigned int            ret_flags ;
-       unsigned int            req_flags ;
-       struct xdr_netobj       share_key;
-       int                     conf_alg;
-       struct crypto_blkcipher *derived_conf_key;
-       int                     intg_alg;
-       struct crypto_blkcipher *derived_integ_key;
-       int                     keyestb_alg;   /* alg used to get share_key */
-       int                     owf_alg;   /* one way function */
+       struct xdr_netobj       conf_alg;
+       struct xdr_netobj       derived_conf_key;
+       struct xdr_netobj       intg_alg;
+       struct xdr_netobj       derived_integ_key;
 };
 
-/* from openssl/objects.h */
-/* XXX need SEAL_ALG_NONE */
-#define NID_md5                4
-#define NID_dhKeyAgreement     28 
-#define NID_des_cbc            31 
-#define NID_sha1               64
-#define NID_cast5_cbc          108
+/* OIDs declarations for K-ALG, I-ALG, C-ALG, and OWF-ALG */
+extern const struct xdr_netobj hmac_md5_oid;
+extern const struct xdr_netobj cast5_cbc_oid;
 
 /* SPKM InnerContext Token types */
 
@@ -46,11 +38,13 @@ u32 spkm3_make_token(struct spkm3_ctx *ctx, struct xdr_buf * text, struct xdr_ne
 u32 spkm3_read_token(struct spkm3_ctx *ctx, struct xdr_netobj *read_token, struct xdr_buf *message_buffer, int toktype);
 
 #define CKSUMTYPE_RSA_MD5            0x0007
+#define CKSUMTYPE_HMAC_MD5           0x0008
 
-s32 make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
-                   int body_offset, struct xdr_netobj *cksum);
+s32 make_spkm3_checksum(s32 cksumtype, struct xdr_netobj *key, char *header,
+               unsigned int hdrlen, struct xdr_buf *body,
+               unsigned int body_offset, struct xdr_netobj *cksum);
 void asn1_bitstring_len(struct xdr_netobj *in, int *enclen, int *zerobits);
-int decode_asn1_bitstring(struct xdr_netobj *out, char *in, int enclen, 
+int decode_asn1_bitstring(struct xdr_netobj *out, char *in, int enclen,
                    int explen);
 void spkm3_mic_header(unsigned char **hdrbuf, unsigned int *hdrlen, 
                    unsigned char *ctxhdr, int elen, int zbit);
index f399c138f79dec7cb39cf95c1d80a107a16937f5..97c761652581a722b7872bab49445e37521a8ea7 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/timer.h>
 #include <linux/sunrpc/types.h>
+#include <linux/rcupdate.h>
 #include <linux/spinlock.h>
 #include <linux/wait.h>
 #include <linux/workqueue.h>
@@ -85,6 +86,7 @@ struct rpc_task {
        union {
                struct work_struct      tk_work;        /* Async task work queue */
                struct rpc_wait         tk_wait;        /* RPC wait */
+               struct rcu_head         tk_rcu;         /* for task deletion */
        } u;
 
        unsigned short          tk_timeouts;    /* maj timeouts */
@@ -178,13 +180,6 @@ struct rpc_call_ops {
        } while (0)
 
 #define RPC_IS_ACTIVATED(t)    (test_bit(RPC_TASK_ACTIVE, &(t)->tk_runstate))
-#define rpc_set_active(t)      (set_bit(RPC_TASK_ACTIVE, &(t)->tk_runstate))
-#define rpc_clear_active(t)    \
-       do { \
-               smp_mb__before_clear_bit(); \
-               clear_bit(RPC_TASK_ACTIVE, &(t)->tk_runstate); \
-               smp_mb__after_clear_bit(); \
-       } while(0)
 
 /*
  * Task priorities.
@@ -222,7 +217,7 @@ struct rpc_wait_queue {
 
 #ifndef RPC_DEBUG
 # define RPC_WAITQ_INIT(var,qname) { \
-               .lock = SPIN_LOCK_UNLOCKED, \
+               .lock = __SPIN_LOCK_UNLOCKED(var.lock), \
                .tasks = { \
                        [0] = LIST_HEAD_INIT(var.tasks[0]), \
                        [1] = LIST_HEAD_INIT(var.tasks[1]), \
@@ -231,7 +226,7 @@ struct rpc_wait_queue {
        }
 #else
 # define RPC_WAITQ_INIT(var,qname) { \
-               .lock = SPIN_LOCK_UNLOCKED, \
+               .lock = __SPIN_LOCK_UNLOCKED(var.lock), \
                .tasks = { \
                        [0] = LIST_HEAD_INIT(var.tasks[0]), \
                        [1] = LIST_HEAD_INIT(var.tasks[1]), \
@@ -254,8 +249,10 @@ struct rpc_task *rpc_run_task(struct rpc_clnt *clnt, int flags,
 void           rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt,
                                int flags, const struct rpc_call_ops *ops,
                                void *data);
+void           rpc_put_task(struct rpc_task *);
 void           rpc_release_task(struct rpc_task *);
 void           rpc_exit_task(struct rpc_task *);
+void           rpc_release_calldata(const struct rpc_call_ops *, void *);
 void           rpc_killall_tasks(struct rpc_clnt *);
 int            rpc_execute(struct rpc_task *);
 void           rpc_init_priority_wait_queue(struct rpc_wait_queue *, const char *);
index 9a527c3643948a266bdcc862c2537e5f277a2f56..9e340fa23c0633f55c6e152d049874c41282f78a 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/uio.h>
 #include <asm/byteorder.h>
+#include <linux/scatterlist.h>
 
 /*
  * Buffer adjustment
@@ -139,29 +140,30 @@ xdr_adjust_iovec(struct kvec *iov, __be32 *p)
  */
 extern void xdr_shift_buf(struct xdr_buf *, size_t);
 extern void xdr_buf_from_iov(struct kvec *, struct xdr_buf *);
-extern int xdr_buf_subsegment(struct xdr_buf *, struct xdr_buf *, int, int);
-extern int xdr_buf_read_netobj(struct xdr_buf *, struct xdr_netobj *, int);
-extern int read_bytes_from_xdr_buf(struct xdr_buf *, int, void *, int);
-extern int write_bytes_to_xdr_buf(struct xdr_buf *, int, void *, int);
+extern int xdr_buf_subsegment(struct xdr_buf *, struct xdr_buf *, unsigned int, unsigned int);
+extern int xdr_buf_read_netobj(struct xdr_buf *, struct xdr_netobj *, unsigned int);
+extern int read_bytes_from_xdr_buf(struct xdr_buf *, unsigned int, void *, unsigned int);
+extern int write_bytes_to_xdr_buf(struct xdr_buf *, unsigned int, void *, unsigned int);
 
 /*
  * Helper structure for copying from an sk_buff.
  */
-typedef struct {
+struct xdr_skb_reader {
        struct sk_buff  *skb;
        unsigned int    offset;
        size_t          count;
        __wsum          csum;
-} skb_reader_t;
+};
 
-typedef size_t (*skb_read_actor_t)(skb_reader_t *desc, void *to, size_t len);
+typedef size_t (*xdr_skb_read_actor)(struct xdr_skb_reader *desc, void *to, size_t len);
 
+size_t xdr_skb_read_bits(struct xdr_skb_reader *desc, void *to, size_t len);
 extern int csum_partial_copy_to_xdr(struct xdr_buf *, struct sk_buff *);
 extern ssize_t xdr_partial_copy_from_skb(struct xdr_buf *, unsigned int,
-               skb_reader_t *, skb_read_actor_t);
+               struct xdr_skb_reader *, xdr_skb_read_actor);
 
-extern int xdr_encode_word(struct xdr_buf *, int, u32);
-extern int xdr_decode_word(struct xdr_buf *, int, u32 *);
+extern int xdr_encode_word(struct xdr_buf *, unsigned int, u32);
+extern int xdr_decode_word(struct xdr_buf *, unsigned int, u32 *);
 
 struct xdr_array2_desc;
 typedef int (*xdr_xcode_elem_t)(struct xdr_array2_desc *desc, void *elem);
@@ -196,6 +198,7 @@ extern void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32
 extern __be32 *xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes);
 extern void xdr_read_pages(struct xdr_stream *xdr, unsigned int len);
 extern void xdr_enter_page(struct xdr_stream *xdr, unsigned int len);
+extern int xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len, int (*actor)(struct scatterlist *, void *), void *data);
 
 #endif /* __KERNEL__ */
 
index 3e04c1512fc444f6a8330612165f3d4626aad0a9..f780e72fc417e44b1701edd63d9af1ef271f703e 100644 (file)
@@ -106,7 +106,6 @@ struct rpc_rqst {
 
 struct rpc_xprt_ops {
        void            (*set_buffer_size)(struct rpc_xprt *xprt, size_t sndsize, size_t rcvsize);
-       char *          (*print_addr)(struct rpc_xprt *xprt, enum rpc_display_format_t format);
        int             (*reserve_xprt)(struct rpc_task *task);
        void            (*release_xprt)(struct rpc_xprt *xprt, struct rpc_task *task);
        void            (*rpcbind)(struct rpc_task *task);
@@ -126,8 +125,6 @@ struct rpc_xprt_ops {
 struct rpc_xprt {
        struct kref             kref;           /* Reference count */
        struct rpc_xprt_ops *   ops;            /* transport methods */
-       struct socket *         sock;           /* BSD socket layer */
-       struct sock *           inet;           /* INET layer */
 
        struct rpc_timeout      timeout;        /* timeout parms */
        struct sockaddr_storage addr;           /* server address */
@@ -137,9 +134,6 @@ struct rpc_xprt {
        unsigned long           cong;           /* current congestion */
        unsigned long           cwnd;           /* congestion window */
 
-       size_t                  rcvsize,        /* transport rcv buffer size */
-                               sndsize;        /* transport send buffer size */
-
        size_t                  max_payload;    /* largest RPC payload size,
                                                   in bytes */
        unsigned int            tsh_size;       /* size of transport specific
@@ -157,28 +151,12 @@ struct rpc_xprt {
        unsigned char           shutdown   : 1, /* being shut down */
                                resvport   : 1; /* use a reserved port */
 
-       /*
-        * XID
-        */
-       __u32                   xid;            /* Next XID value to use */
-
-       /*
-        * State of TCP reply receive stuff
-        */
-       __be32                  tcp_recm,       /* Fragment header */
-                               tcp_xid;        /* Current XID */
-       u32                     tcp_reclen,     /* fragment length */
-                               tcp_offset;     /* fragment offset */
-       unsigned long           tcp_copied,     /* copied to request */
-                               tcp_flags;
        /*
         * Connection of transports
         */
        unsigned long           connect_timeout,
                                bind_timeout,
                                reestablish_timeout;
-       struct delayed_work     connect_worker;
-       unsigned short          port;
 
        /*
         * Disconnection of idle transports
@@ -193,8 +171,8 @@ struct rpc_xprt {
         */
        spinlock_t              transport_lock; /* lock transport info */
        spinlock_t              reserve_lock;   /* lock slot table */
+       u32                     xid;            /* Next XID value to use */
        struct rpc_task *       snd_task;       /* Task blocked in send */
-
        struct list_head        recv;
 
        struct {
@@ -210,18 +188,9 @@ struct rpc_xprt {
                                        bklog_u;        /* backlog queue utilization */
        } stat;
 
-       void                    (*old_data_ready)(struct sock *, int);
-       void                    (*old_state_change)(struct sock *);
-       void                    (*old_write_space)(struct sock *);
-
        char *                  address_strings[RPC_DISPLAY_MAX];
 };
 
-#define XPRT_LAST_FRAG         (1 << 0)
-#define XPRT_COPY_RECM         (1 << 1)
-#define XPRT_COPY_XID          (1 << 2)
-#define XPRT_COPY_DATA         (1 << 3)
-
 #ifdef __KERNEL__
 
 /*
@@ -270,8 +239,8 @@ void                        xprt_disconnect(struct rpc_xprt *xprt);
 /*
  * Socket transport setup operations
  */
-int                    xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to);
-int                    xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to);
+struct rpc_xprt *      xs_setup_udp(struct sockaddr *addr, size_t addrlen, struct rpc_timeout *to);
+struct rpc_xprt *      xs_setup_tcp(struct sockaddr *addr, size_t addrlen, struct rpc_timeout *to);
 
 /*
  * Reserved bit positions in xprt->state
index b1237f16ecde3008c2f5a5ee592c78a97fefee20..bf99bd49f8efd3af5f13004ca3c84c57bc532e91 100644 (file)
@@ -9,10 +9,13 @@
 #include <linux/init.h>
 #include <linux/pm.h>
 
-/* page backup entry */
+/* struct pbe is used for creating lists of pages that should be restored
+ * atomically during the resume from disk, because the page frames they have
+ * occupied before the suspend are in use.
+ */
 struct pbe {
-       unsigned long address;          /* address of the copy */
-       unsigned long orig_address;     /* original address of page */
+       void *address;          /* address of the copy */
+       void *orig_address;     /* original address of a page */
        struct pbe *next;
 };
 
index e7c36ba2a2dbe2466b5aa8ea4e4b6e406f4ed4e4..add51cebc8d9dad3999f2b9842a55f7fcce24f47 100644 (file)
@@ -218,8 +218,6 @@ extern void swap_unplug_io_fn(struct backing_dev_info *, struct page *);
 /* linux/mm/page_io.c */
 extern int swap_readpage(struct file *, struct page *);
 extern int swap_writepage(struct page *page, struct writeback_control *wbc);
-extern int rw_swap_page_sync(int rw, swp_entry_t entry, struct page *page,
-                               struct bio **bio_chain);
 extern int end_swap_bio_read(struct bio *bio, unsigned int bytes_done, int err);
 
 /* linux/mm/swap_state.c */
@@ -247,9 +245,10 @@ extern int swap_duplicate(swp_entry_t);
 extern int valid_swaphandles(swp_entry_t, unsigned long *);
 extern void swap_free(swp_entry_t);
 extern void free_swap_and_cache(swp_entry_t);
-extern int swap_type_of(dev_t);
+extern int swap_type_of(dev_t, sector_t);
 extern unsigned int count_swap_pages(int, int);
 extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t);
+extern sector_t swapdev_block(int, pgoff_t);
 extern struct swap_info_struct *get_swap_info_struct(unsigned);
 extern int can_share_swap_page(struct page *);
 extern int remove_exclusive_swap_page(struct page *);
@@ -259,7 +258,6 @@ extern spinlock_t swap_lock;
 
 /* linux/mm/thrash.c */
 extern struct mm_struct * swap_token_mm;
-extern unsigned long swap_token_default_timeout;
 extern void grab_swap_token(void);
 extern void __put_swap_token(struct mm_struct *);
 
index 6562a2050a25a6c0d5762b338d80ea8e1c81d476..7e9680f4afdd9290415c1a8b4ccf8594bf29bd14 100644 (file)
 #include <net/genetlink.h>
 
 #ifdef CONFIG_TASKSTATS
-extern kmem_cache_t *taskstats_cache;
+extern struct kmem_cache *taskstats_cache;
 extern struct mutex taskstats_exit_mutex;
 
-static inline void taskstats_exit_free(struct taskstats *tidstats)
-{
-       if (tidstats)
-               kmem_cache_free(taskstats_cache, tidstats);
-}
-
 static inline void taskstats_tgid_init(struct signal_struct *sig)
 {
        sig->stats = NULL;
 }
 
-static inline void taskstats_tgid_alloc(struct task_struct *tsk)
-{
-       struct signal_struct *sig = tsk->signal;
-       struct taskstats *stats;
-
-       if (sig->stats != NULL)
-               return;
-
-       /* No problem if kmem_cache_zalloc() fails */
-       stats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL);
-
-       spin_lock_irq(&tsk->sighand->siglock);
-       if (!sig->stats) {
-               sig->stats = stats;
-               stats = NULL;
-       }
-       spin_unlock_irq(&tsk->sighand->siglock);
-
-       if (stats)
-               kmem_cache_free(taskstats_cache, stats);
-}
-
 static inline void taskstats_tgid_free(struct signal_struct *sig)
 {
        if (sig->stats)
                kmem_cache_free(taskstats_cache, sig->stats);
 }
 
-extern void taskstats_exit_alloc(struct taskstats **, unsigned int *);
-extern void taskstats_exit_send(struct task_struct *, struct taskstats *, int, unsigned int);
+extern void taskstats_exit(struct task_struct *, int group_dead);
 extern void taskstats_init_early(void);
 #else
-static inline void taskstats_exit_alloc(struct taskstats **ptidstats, unsigned int *mycpu)
-{}
-static inline void taskstats_exit_free(struct taskstats *ptidstats)
-{}
-static inline void taskstats_exit_send(struct task_struct *tsk,
-                                      struct taskstats *tidstats,
-                                      int group_dead, unsigned int cpu)
+static inline void taskstats_exit(struct task_struct *tsk, int group_dead)
 {}
 static inline void taskstats_tgid_init(struct signal_struct *sig)
 {}
-static inline void taskstats_tgid_alloc(struct task_struct *tsk)
-{}
 static inline void taskstats_tgid_free(struct signal_struct *sig)
 {}
 static inline void taskstats_init_early(void)
index f717f0898238c33236415dabbc362d80e4f712bf..65cbcf22c31e1e8ab7aef22b3b8da180825cf7cc 100644 (file)
@@ -175,7 +175,7 @@ struct tty_struct {
        int index;
        struct tty_ldisc ldisc;
        struct mutex termios_mutex;
-       struct termios *termios, *termios_locked;
+       struct ktermios *termios, *termios_locked;
        char name[64];
        int pgrp;
        int session;
@@ -258,7 +258,7 @@ struct tty_struct {
 
 extern void tty_write_flush(struct tty_struct *);
 
-extern struct termios tty_std_termios;
+extern struct ktermios tty_std_termios;
 
 extern int kmsg_redirect;
 
@@ -293,8 +293,9 @@ extern int tty_hung_up_p(struct file * filp);
 extern void do_SAK(struct tty_struct *tty);
 extern void disassociate_ctty(int priv);
 extern void tty_flip_buffer_push(struct tty_struct *tty);
-extern int tty_get_baud_rate(struct tty_struct *tty);
-extern int tty_termios_baud_rate(struct termios *termios);
+extern speed_t tty_get_baud_rate(struct tty_struct *tty);
+extern speed_t tty_termios_baud_rate(struct ktermios *termios);
+extern speed_t tty_termios_input_baud_rate(struct ktermios *termios);
 
 extern struct tty_ldisc *tty_ldisc_ref(struct tty_struct *);
 extern void tty_ldisc_deref(struct tty_ldisc *);
@@ -309,6 +310,12 @@ extern void tty_ldisc_flush(struct tty_struct *tty);
 extern int tty_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
                     unsigned long arg);
 
+extern dev_t tty_devnum(struct tty_struct *tty);
+extern void proc_clear_tty(struct task_struct *p);
+extern void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty);
+extern void proc_set_tty(struct task_struct *tsk, struct tty_struct *tty);
+extern struct tty_struct *get_current_tty(void);
+
 extern struct mutex tty_mutex;
 
 /* n_tty.c */
@@ -335,10 +342,5 @@ extern void console_print(const char *);
 extern int vt_ioctl(struct tty_struct *tty, struct file * file,
                    unsigned int cmd, unsigned long arg);
 
-static inline dev_t tty_devnum(struct tty_struct *tty)
-{
-       return MKDEV(tty->driver->major, tty->driver->minor_start) + tty->index;
-}
-
 #endif /* __KERNEL__ */
 #endif
index 5c8473bb6882e7cc4f7dfe03a33072e94f6bceb2..659487e3ebeb0c99fcb60526b41cf90a1712877a 100644 (file)
@@ -53,7 +53,7 @@
  *     device-specific ioctl's.  If the ioctl number passed in cmd
  *     is not recognized by the driver, it should return ENOIOCTLCMD.
  * 
- * void (*set_termios)(struct tty_struct *tty, struct termios * old);
+ * void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
  *
  *     This routine allows the tty driver to be notified when
  *     device's termios settings have changed.  Note that a
@@ -132,7 +132,7 @@ struct tty_operations {
        int  (*chars_in_buffer)(struct tty_struct *tty);
        int  (*ioctl)(struct tty_struct *tty, struct file * file,
                    unsigned int cmd, unsigned long arg);
-       void (*set_termios)(struct tty_struct *tty, struct termios * old);
+       void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
        void (*throttle)(struct tty_struct * tty);
        void (*unthrottle)(struct tty_struct * tty);
        void (*stop)(struct tty_struct *tty);
@@ -165,7 +165,7 @@ struct tty_driver {
        int     num;            /* number of devices allocated */
        short   type;           /* type of tty driver */
        short   subtype;        /* subtype of tty driver */
-       struct termios init_termios; /* Initial termios */
+       struct ktermios init_termios; /* Initial termios */
        int     flags;          /* tty driver flags */
        int     refcount;       /* for loadable tty drivers */
        struct proc_dir_entry *proc_entry; /* /proc fs entry */
@@ -175,8 +175,8 @@ struct tty_driver {
         * Pointer to the tty data structures
         */
        struct tty_struct **ttys;
-       struct termios **termios;
-       struct termios **termios_locked;
+       struct ktermios **termios;
+       struct ktermios **termios_locked;
        void *driver_state;     /* only used for the PTY driver */
        
        /*
@@ -193,7 +193,7 @@ struct tty_driver {
        int  (*chars_in_buffer)(struct tty_struct *tty);
        int  (*ioctl)(struct tty_struct *tty, struct file * file,
                    unsigned int cmd, unsigned long arg);
-       void (*set_termios)(struct tty_struct *tty, struct termios * old);
+       void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
        void (*throttle)(struct tty_struct * tty);
        void (*unthrottle)(struct tty_struct * tty);
        void (*stop)(struct tty_struct *tty);
index 83c6e6c10ebb57b52ed41742fcf6a0bd830668a6..d75932e2771094c7066667a0c6357eb079f480b5 100644 (file)
@@ -59,7 +59,7 @@
  *     low-level driver can "grab" an ioctl request before the line
  *     discpline has a chance to see it.
  * 
- * void        (*set_termios)(struct tty_struct *tty, struct termios * old);
+ * void        (*set_termios)(struct tty_struct *tty, struct ktermios * old);
  *
  *     This function notifies the line discpline that a change has
  *     been made to the termios structure.
@@ -118,7 +118,7 @@ struct tty_ldisc {
                         const unsigned char * buf, size_t nr); 
        int     (*ioctl)(struct tty_struct * tty, struct file * file,
                         unsigned int cmd, unsigned long arg);
-       void    (*set_termios)(struct tty_struct *tty, struct termios * old);
+       void    (*set_termios)(struct tty_struct *tty, struct ktermios * old);
        unsigned int (*poll)(struct tty_struct *, struct file *,
                             struct poll_table_struct *);
        int     (*hangup)(struct tty_struct *tty);
index a48d7f11c7be06772327604dc40c3f91b0b57145..975c963e57898aee95fed95e129bd91a1578a414 100644 (file)
@@ -1,8 +1,43 @@
 #ifndef __LINUX_UACCESS_H__
 #define __LINUX_UACCESS_H__
 
+#include <linux/preempt.h>
 #include <asm/uaccess.h>
 
+/*
+ * These routines enable/disable the pagefault handler in that
+ * it will not take any locks and go straight to the fixup table.
+ *
+ * They have great resemblance to the preempt_disable/enable calls
+ * and in fact they are identical; this is because currently there is
+ * no other way to make the pagefault handlers do this. So we do
+ * disable preemption but we don't necessarily care about that.
+ */
+static inline void pagefault_disable(void)
+{
+       inc_preempt_count();
+       /*
+        * make sure to have issued the store before a pagefault
+        * can hit.
+        */
+       barrier();
+}
+
+static inline void pagefault_enable(void)
+{
+       /*
+        * make sure to issue those last loads/stores before enabling
+        * the pagefault handler again.
+        */
+       barrier();
+       dec_preempt_count();
+       /*
+        * make sure we do..
+        */
+       barrier();
+       preempt_check_resched();
+}
+
 #ifndef ARCH_HAS_NOCACHE_UACCESS
 
 static inline unsigned long __copy_from_user_inatomic_nocache(void *to,
@@ -30,14 +65,22 @@ static inline unsigned long __copy_from_user_nocache(void *to,
  * do_page_fault() doesn't attempt to take mmap_sem.  This makes
  * probe_kernel_address() suitable for use within regions where the caller
  * already holds mmap_sem, or other locks which nest inside mmap_sem.
+ * This must be a macro because __get_user() needs to know the types of the
+ * args.
+ *
+ * We don't include enough header files to be able to do the set_fs().  We
+ * require that the probe_kernel_address() caller will do that.
  */
 #define probe_kernel_address(addr, retval)             \
        ({                                              \
                long ret;                               \
+               mm_segment_t old_fs = get_fs();         \
                                                        \
-               inc_preempt_count();                    \
-               ret = __get_user(retval, addr);         \
-               dec_preempt_count();                    \
+               set_fs(KERNEL_DS);                      \
+               pagefault_disable();                    \
+               ret = __get_user(retval, (__force typeof(retval) __user *)(addr));              \
+               pagefault_enable();                     \
+               set_fs(old_fs);                         \
                ret;                                    \
        })
 
index 91b3ea2bbb149fbbf283cc8b297abddb8cca08ae..10f99e5f1a971fc85cdd7b6bed897afce6acdbf8 100644 (file)
@@ -218,7 +218,7 @@ struct usb_serial_driver {
        int  (*write)           (struct usb_serial_port *port, const unsigned char *buf, int count);
        int  (*write_room)      (struct usb_serial_port *port);
        int  (*ioctl)           (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
-       void (*set_termios)     (struct usb_serial_port *port, struct termios * old);
+       void (*set_termios)     (struct usb_serial_port *port, struct ktermios * old);
        void (*break_ctl)       (struct usb_serial_port *port, int break_state);
        int  (*chars_in_buffer) (struct usb_serial_port *port);
        void (*throttle)        (struct usb_serial_port *port);
index 4a3ea83c6d16fc5e9bd60c7ec72bf30967f96d53..edef8d50b26bd668b415e0758f16961068e28339 100644 (file)
@@ -147,9 +147,11 @@ struct execute_work {
 
 
 extern struct workqueue_struct *__create_workqueue(const char *name,
-                                                   int singlethread);
-#define create_workqueue(name) __create_workqueue((name), 0)
-#define create_singlethread_workqueue(name) __create_workqueue((name), 1)
+                                                   int singlethread,
+                                                   int freezeable);
+#define create_workqueue(name) __create_workqueue((name), 0, 0)
+#define create_freezeable_workqueue(name) __create_workqueue((name), 0, 1)
+#define create_singlethread_workqueue(name) __create_workqueue((name), 1, 0)
 
 extern void destroy_workqueue(struct workqueue_struct *wq);
 
@@ -160,6 +162,7 @@ extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
 extern void FASTCALL(flush_workqueue(struct workqueue_struct *wq));
 
 extern int FASTCALL(schedule_work(struct work_struct *work));
+extern int FASTCALL(run_scheduled_work(struct work_struct *work));
 extern int FASTCALL(schedule_delayed_work(struct delayed_work *work, unsigned long delay));
 
 extern int schedule_delayed_work_on(int cpu, struct delayed_work *work, unsigned long delay);
index 088ba8113f7ea479997b77305c9ce91bfa7ed691..9529ea1ae39253563b02c04a493b3ccc5a3b55fe 100644 (file)
@@ -357,7 +357,7 @@ struct xfrm_user_report {
 #define XFRMGRP_EXPIRE         2
 #define XFRMGRP_SA             4
 #define XFRMGRP_POLICY         8
-#define XFRMGRP_REPORT         0x10
+#define XFRMGRP_REPORT         0x20
 #endif
 
 enum xfrm_nlgroups {
index 69374cd1a857a05e1a8c8d0673afcb75f7badbfb..e1d116f1192359d2c037d74693200ac374adeb1a 100644 (file)
@@ -282,15 +282,17 @@ extern void ax25_fillin_cb(ax25_cb *, ax25_dev *);
 extern struct sock *ax25_make_new(struct sock *, struct ax25_dev *);
 
 /* ax25_addr.c */
-extern ax25_address null_ax25_address;
-extern char *ax2asc(char *buf, ax25_address *);
-extern void asc2ax(ax25_address *addr, char *callsign);
-extern int  ax25cmp(ax25_address *, ax25_address *);
-extern int  ax25digicmp(ax25_digi *, ax25_digi *);
-extern unsigned char *ax25_addr_parse(unsigned char *, int, ax25_address *, ax25_address *, ax25_digi *, int *, int *);
-extern int  ax25_addr_build(unsigned char *, ax25_address *, ax25_address *, ax25_digi *, int, int);
-extern int  ax25_addr_size(ax25_digi *);
-extern void ax25_digi_invert(ax25_digi *, ax25_digi *);
+extern const ax25_address ax25_bcast;
+extern const ax25_address ax25_defaddr;
+extern const ax25_address null_ax25_address;
+extern int ax25cmp(const ax25_address *, const ax25_address *);
+extern int ax25digicmp(const ax25_digi *, const ax25_digi *);
+extern const unsigned char *ax25_addr_parse(const unsigned char *, int,
+       ax25_address *, ax25_address *, ax25_digi *, int *, int *);
+extern int  ax25_addr_build(unsigned char *, const ax25_address *,
+       const ax25_address *, const ax25_digi *, int, int);
+extern int  ax25_addr_size(const ax25_digi *);
+extern void ax25_digi_invert(const ax25_digi *, ax25_digi *);
 
 /* ax25_dev.c */
 extern ax25_dev *ax25_dev_list;
index e156e38e4ac37db61db754822e59877299e2f9a0..62b7e7598e9adfbb246abb5a692515fbf0e99e0e 100644 (file)
@@ -98,7 +98,7 @@ struct dst_ops
        int                     entry_size;
 
        atomic_t                entries;
-       kmem_cache_t            *kmem_cachep;
+       struct kmem_cache               *kmem_cachep;
 };
 
 #ifdef __KERNEL__
index a9eb2eaf094eaf1e9d54c61f070359118309aac8..34cc76e3ddb42139bdd7d9b48971bb5d174c7130 100644 (file)
@@ -125,7 +125,7 @@ struct inet_hashinfo {
        rwlock_t                        lhash_lock ____cacheline_aligned;
        atomic_t                        lhash_users;
        wait_queue_head_t               lhash_wait;
-       kmem_cache_t                    *bind_bucket_cachep;
+       struct kmem_cache                       *bind_bucket_cachep;
 };
 
 static inline struct inet_ehash_bucket *inet_ehash_bucket(
@@ -136,10 +136,10 @@ static inline struct inet_ehash_bucket *inet_ehash_bucket(
 }
 
 extern struct inet_bind_bucket *
-                   inet_bind_bucket_create(kmem_cache_t *cachep,
+                   inet_bind_bucket_create(struct kmem_cache *cachep,
                                            struct inet_bind_hashbucket *head,
                                            const unsigned short snum);
-extern void inet_bind_bucket_destroy(kmem_cache_t *cachep,
+extern void inet_bind_bucket_destroy(struct kmem_cache *cachep,
                                     struct inet_bind_bucket *tb);
 
 static inline int inet_bhashfn(const __u16 lport, const int bhash_size)
index 87699cb4ef8ce02abfc3658b77b2979f1c3c2e58..8dabdd603fe158782de0adbcad9988df3eaed51b 100644 (file)
@@ -126,7 +126,7 @@ extern int ircomm_tty_tiocmset(struct tty_struct *tty, struct file *file,
 extern int ircomm_tty_ioctl(struct tty_struct *tty, struct file *file, 
                            unsigned int cmd, unsigned long arg);
 extern void ircomm_tty_set_termios(struct tty_struct *tty, 
-                                  struct termios *old_termios);
+                                  struct ktermios *old_termios);
 extern hashbin_t *ircomm_tty;
 
 #endif
index 492dedaa8ac16dacd4cbab84484293a61e636f72..1720539ac2c1b0270e1358e6a6541e34dc709005 100644 (file)
@@ -28,6 +28,8 @@
 void irlan_check_command_param(struct irlan_cb *self, char *param, 
                               char *value);
 void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb);
+#ifdef CONFIG_PROC_FS
 void irlan_print_filter(struct seq_file *seq, int filter_type);
+#endif
 
 #endif /* IRLAN_FILTER_H */
index c8aacbd2e3331198fbde8125b1829e61f779a043..3725b93c52f3efabf4abe8519fcb0d03a723bb9c 100644 (file)
@@ -160,7 +160,7 @@ struct neigh_table
        atomic_t                entries;
        rwlock_t                lock;
        unsigned long           last_rand;
-       kmem_cache_t            *kmem_cachep;
+       struct kmem_cache               *kmem_cachep;
        struct neigh_statistics *stats;
        struct neighbour        **hash_buckets;
        unsigned int            hash_mask;
@@ -309,6 +309,24 @@ static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
        return 0;
 }
 
+static inline int neigh_hh_output(struct hh_cache *hh, struct sk_buff *skb)
+{
+       unsigned seq;
+       int hh_len;
+
+       do {
+               int hh_alen;
+
+               seq = read_seqbegin(&hh->hh_lock);
+               hh_len = hh->hh_len;
+               hh_alen = HH_DATA_ALIGN(hh_len);
+               memcpy(skb->data - hh_alen, hh->hh_data, hh_alen);
+       } while (read_seqretry(&hh->hh_lock, seq));
+
+       skb_push(skb, hh_len);
+       return hh->hh_output(skb);
+}
+
 static inline struct neighbour *
 __neigh_lookup(struct neigh_table *tbl, const void *pkey, struct net_device *dev, int creat)
 {
index cef3136e22a32b0799ca7bbbb50012dd9c93e90a..41bcc9eb42062044a3bb47c7442884002e0f1136 100644 (file)
@@ -7,7 +7,7 @@
 #include <net/netfilter/nf_conntrack.h>
 
 extern struct list_head nf_conntrack_expect_list;
-extern kmem_cache_t *nf_conntrack_expect_cachep;
+extern struct kmem_cache *nf_conntrack_expect_cachep;
 extern struct file_operations exp_file_ops;
 
 struct nf_conntrack_expect
index e37baaf2080b24c780662fa59a7c1da5f6030ea8..7aed02ce2b65b502dd97f72f91417ed5c78e5ca8 100644 (file)
@@ -29,7 +29,7 @@ struct proto;
 struct request_sock_ops {
        int             family;
        int             obj_size;
-       kmem_cache_t    *slab;
+       struct kmem_cache       *slab;
        int             (*rtx_syn_ack)(struct sock *sk,
                                       struct request_sock *req,
                                       struct dst_entry *dst);
@@ -60,7 +60,7 @@ struct request_sock {
 
 static inline struct request_sock *reqsk_alloc(const struct request_sock_ops *ops)
 {
-       struct request_sock *req = kmem_cache_alloc(ops->slab, SLAB_ATOMIC);
+       struct request_sock *req = kmem_cache_alloc(ops->slab, GFP_ATOMIC);
 
        if (req != NULL)
                req->rsk_ops = ops;
index fe3a33fad03fcd1a553babe753a427e057269123..03684e702d13464cbc0a48b95354dc540341f504 100644 (file)
@@ -571,7 +571,7 @@ struct proto {
        int                     *sysctl_rmem;
        int                     max_header;
 
-       kmem_cache_t            *slab;
+       struct kmem_cache               *slab;
        unsigned int            obj_size;
 
        atomic_t                *orphan_count;
@@ -746,6 +746,25 @@ static inline int sk_stream_wmem_schedule(struct sock *sk, int size)
  */
 #define sock_owned_by_user(sk) ((sk)->sk_lock.owner)
 
+/*
+ * Macro so as to not evaluate some arguments when
+ * lockdep is not enabled.
+ *
+ * Mark both the sk_lock and the sk_lock.slock as a
+ * per-address-family lock class.
+ */
+#define sock_lock_init_class_and_name(sk, sname, skey, name, key)      \
+do {                                                                   \
+       sk->sk_lock.owner = NULL;                                       \
+       init_waitqueue_head(&sk->sk_lock.wq);                           \
+       spin_lock_init(&(sk)->sk_lock.slock);                           \
+       debug_check_no_locks_freed((void *)&(sk)->sk_lock,              \
+                       sizeof((sk)->sk_lock));                         \
+       lockdep_set_class_and_name(&(sk)->sk_lock.slock,                \
+                       (skey), (sname));                               \
+       lockdep_init_map(&(sk)->sk_lock.dep_map, (name), (key), 0);     \
+} while (0)
+
 extern void FASTCALL(lock_sock_nested(struct sock *sk, int subclass));
 
 static inline void lock_sock(struct sock *sk)
index d7a306ea560d96b94eb8c28c11c8ee958d1f0655..1e1ee3253fd8fd9a46d24778f9534e7c042f98a4 100644 (file)
@@ -15,7 +15,7 @@
 #include <net/sock.h>
 
 struct timewait_sock_ops {
-       kmem_cache_t    *twsk_slab;
+       struct kmem_cache       *twsk_slab;
        unsigned int    twsk_obj_size;
        int             (*twsk_unique)(struct sock *sk,
                                       struct sock *sktw, void *twp);
index 15ec19dcf9c886864374a044e636c941ab8e0903..e4765413cf80c7ee9a5f4997796f6ee7ef93a206 100644 (file)
@@ -392,6 +392,20 @@ extern int xfrm_unregister_km(struct xfrm_mgr *km);
 
 extern unsigned int xfrm_policy_count[XFRM_POLICY_MAX*2];
 
+/* Audit Information */
+struct xfrm_audit
+{
+       uid_t   loginuid;
+       u32     secid;
+};
+
+#ifdef CONFIG_AUDITSYSCALL
+extern void xfrm_audit_log(uid_t auid, u32 secid, int type, int result,
+                   struct xfrm_policy *xp, struct xfrm_state *x);
+#else
+#define xfrm_audit_log(a,s,t,r,p,x) do { ; } while (0)
+#endif /* CONFIG_AUDITSYSCALL */
+
 static inline void xfrm_pol_hold(struct xfrm_policy *policy)
 {
        if (likely(policy != NULL))
@@ -906,7 +920,7 @@ static inline int xfrm_state_sort(struct xfrm_state **dst, struct xfrm_state **s
 #endif
 extern struct xfrm_state *xfrm_find_acq_byseq(u32 seq);
 extern int xfrm_state_delete(struct xfrm_state *x);
-extern void xfrm_state_flush(u8 proto);
+extern void xfrm_state_flush(u8 proto, struct xfrm_audit *audit_info);
 extern int xfrm_replay_check(struct xfrm_state *x, __be32 seq);
 extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq);
 extern void xfrm_replay_notify(struct xfrm_state *x, int event);
@@ -959,13 +973,13 @@ struct xfrm_policy *xfrm_policy_bysel_ctx(u8 type, int dir,
                                          struct xfrm_selector *sel,
                                          struct xfrm_sec_ctx *ctx, int delete);
 struct xfrm_policy *xfrm_policy_byid(u8, int dir, u32 id, int delete);
-void xfrm_policy_flush(u8 type);
+void xfrm_policy_flush(u8 type, struct xfrm_audit *audit_info);
 u32 xfrm_get_acqseq(void);
 void xfrm_alloc_spi(struct xfrm_state *x, __be32 minspi, __be32 maxspi);
-struct xfrm_state * xfrm_find_acq(u8 mode, u32 reqid, u8 proto, 
-                                 xfrm_address_t *daddr, xfrm_address_t *saddr, 
+struct xfrm_state * xfrm_find_acq(u8 mode, u32 reqid, u8 proto,
+                                 xfrm_address_t *daddr, xfrm_address_t *saddr,
                                  int create, unsigned short family);
-extern void xfrm_policy_flush(u8 type);
+extern void xfrm_policy_flush(u8 type, struct xfrm_audit *audit_info);
 extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol);
 extern int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *xdst,
                          struct flowi *fl, int family, int strict);
index 9233ed5de664625f0d780974b1be17047c728d22..0c775fceb675b052bece78b80c885aaf64f0723e 100644 (file)
@@ -557,7 +557,7 @@ struct sas_task {
 
 static inline struct sas_task *sas_alloc_task(gfp_t flags)
 {
-       extern kmem_cache_t *sas_task_cache;
+       extern struct kmem_cache *sas_task_cache;
        struct sas_task *task = kmem_cache_alloc(sas_task_cache, flags);
 
        if (task) {
@@ -575,7 +575,7 @@ static inline struct sas_task *sas_alloc_task(gfp_t flags)
 static inline void sas_free_task(struct sas_task *task)
 {
        if (task) {
-               extern kmem_cache_t *sas_task_cache;
+               extern struct kmem_cache *sas_task_cache;
                BUG_ON(!list_empty(&task->list));
                kmem_cache_free(sas_task_cache, task);
        }
index 3bde0f5cd55ce961fc49a7f4d71102fb8f950c9c..20b9002712ef23505d5261b9d192dd5c30de627e 100644 (file)
@@ -1,6 +1,9 @@
 #ifndef __MBX_FB_H
 #define __MBX_FB_H
 
+#include <asm/ioctl.h>
+#include <asm/types.h>
+
 struct mbxfb_val {
        unsigned int    defval;
        unsigned int    min;
@@ -25,4 +28,32 @@ struct mbxfb_platform_data {
                int (*remove)(struct fb_info *fb);
 };
 
+/* planar */
+#define MBXFB_FMT_YUV12                0
+
+/* packed */
+#define MBXFB_FMT_UY0VY1       1
+#define MBXFB_FMT_VY0UY1       2
+#define MBXFB_FMT_Y0UY1V       3
+#define MBXFB_FMT_Y0VY1U       4
+struct mbxfb_overlaySetup {
+       __u32 enable;
+       __u32 x, y;
+       __u32 width, height;
+       __u32 alpha;
+       __u32 fmt;
+       __u32 mem_offset;
+       __u32 scaled_width;
+       __u32 scaled_height;
+
+       /* Filled by the driver */
+       __u32 U_offset;
+       __u32 V_offset;
+
+       __u16 Y_stride;
+       __u16 UV_stride;
+};
+
+#define MBXFB_IOCX_OVERLAY     _IOWR(0xF4, 0x00,struct mbxfb_overlaySetup)
+
 #endif /* __MBX_FB_H */
index ac021379ac40abb0b1c7767a69d90ce33d412b88..94c7d2da90eae37d8601b8f6b07e17382ab8b309 100644 (file)
 #define PM3FBDestReadModeOr                                    0xac98
        #define PM3FBDestReadMode_ReadDisable                   0<<0
        #define PM3FBDestReadMode_ReadEnable                    1<<0
-       #define PM3FBDestReadMode_StripePitch(sp)       (((sp)&0x7)<<2
-       #define PM3FBDestReadMode_StripeHeight(sh)      (((sh)&0x7)<<7
+       #define PM3FBDestReadMode_StripePitch(sp)       (((sp)&0x7)<<2)
+       #define PM3FBDestReadMode_StripeHeight(sh)      (((sh)&0x7)<<7)
        #define PM3FBDestReadMode_Enable0                       1<<8
        #define PM3FBDestReadMode_Enable1                       1<<9
        #define PM3FBDestReadMode_Enable2                       1<<10
        #define PM3FBDestReadMode_Enable3                       1<<11
-       #define PM3FBDestReadMode_Layout0(l)            (((l)&0x3)<<12
-       #define PM3FBDestReadMode_Layout1(l)            (((l)&0x3)<<14
-       #define PM3FBDestReadMode_Layout2(l)            (((l)&0x3)<<16
-       #define PM3FBDestReadMode_Layout3(l)            (((l)&0x3)<<18
+       #define PM3FBDestReadMode_Layout0(l)            (((l)&0x3)<<12)
+       #define PM3FBDestReadMode_Layout1(l)            (((l)&0x3)<<14)
+       #define PM3FBDestReadMode_Layout2(l)            (((l)&0x3)<<16)
+       #define PM3FBDestReadMode_Layout3(l)            (((l)&0x3)<<18)
        #define PM3FBDestReadMode_Origin0                       1<<20
        #define PM3FBDestReadMode_Origin1                       1<<21
        #define PM3FBDestReadMode_Origin2                       1<<22
 #define PM3FBSourceReadModeOr                                  0xaca8
        #define PM3FBSourceReadMode_ReadDisable                 (0<<0)
        #define PM3FBSourceReadMode_ReadEnable                  (1<<0)
-       #define PM3FBSourceReadMode_StripePitch(sp)     (((sp)&0x7)<<2
-       #define PM3FBSourceReadMode_StripeHeight(sh)    (((sh)&0x7)<<7
-       #define PM3FBSourceReadMode_Layout(l)           (((l)&0x3)<<8
+       #define PM3FBSourceReadMode_StripePitch(sp)     (((sp)&0x7)<<2)
+       #define PM3FBSourceReadMode_StripeHeight(sh)    (((sh)&0x7)<<7)
+       #define PM3FBSourceReadMode_Layout(l)           (((l)&0x3)<<8)
        #define PM3FBSourceReadMode_Origin                      1<<10
        #define PM3FBSourceReadMode_Blocking                    1<<11
        #define PM3FBSourceReadMode_UserTexelCoord              1<<13
        #define PM3FBSourceReadMode_WrapXEnable                 1<<14
        #define PM3FBSourceReadMode_WrapYEnable                 1<<15
-       #define PM3FBSourceReadMode_WrapX(w)            (((w)&0xf)<<16
-       #define PM3FBSourceReadMode_WrapY(w)            (((w)&0xf)<<20
+       #define PM3FBSourceReadMode_WrapX(w)            (((w)&0xf)<<16)
+       #define PM3FBSourceReadMode_WrapY(w)            (((w)&0xf)<<20)
        #define PM3FBSourceReadMode_ExternalSourceData          1<<24
 #define PM3FBWriteBufferAddr0                                   0xb000
 #define PM3FBWriteBufferAddr1                                   0xb008
 #define PM3Window                                              0x8980
        #define PM3Window_ForceLBUpdate                         1<<3
        #define PM3Window_LBUpdateSource                        1<<4
-       #define PM3Window_FrameCount(c)                         (((c)&0xff)<<9
+       #define PM3Window_FrameCount(c)                         (((c)&0xff)<<9)
        #define PM3Window_StencilFCP                            1<<17
        #define PM3Window_DepthFCP                              1<<18
        #define PM3Window_OverrideWriteFiltering                1<<19
index 633a268d270d3cc8bfa906c1a22476caa9645360..d6c764d0eabbefcd01afb7dfaced7b277bdaa581 100644 (file)
@@ -15,6 +15,7 @@ clean-files := ../include/linux/compile.h
 
 # dependencies on generated files need to be listed explicitly
 
+$(obj)/main.o: include/linux/compile.h
 $(obj)/version.o: include/linux/compile.h
 
 # compile.h changes depending on hostname, generation number, etc,
index 919a80cb322e6f57dfa2be0a3bb727251bcd7e0e..2cfd7cb36e7963bee6987c826c39a3411459666d 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/romfs_fs.h>
 #include <linux/initrd.h>
 #include <linux/sched.h>
+#include <linux/freezer.h>
 
 #include "do_mounts.h"
 
index d28c1094d7e5ca8be38b50109161470ef2b27537..85f04037ade137c6ce452f3183db87527f80e6cf 100644 (file)
@@ -182,6 +182,10 @@ static int __init do_collect(void)
 
 static int __init do_header(void)
 {
+       if (memcmp(collected, "070707", 6)==0) {
+               error("incorrect cpio method used: use -H newc option");
+               return 1;
+       }
        if (memcmp(collected, "070701", 6)) {
                error("no cpio magic");
                return 1;
index 36f608a7cfbaf0fe1e2d3b1f37ff42e945bc100d..036f97c0c34c80bf26a55079e69dcda8f7f0e37d 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/percpu.h>
 #include <linux/kmod.h>
 #include <linux/kernel_stat.h>
+#include <linux/start_kernel.h>
 #include <linux/security.h>
 #include <linux/workqueue.h>
 #include <linux/profile.h>
@@ -49,6 +50,9 @@
 #include <linux/buffer_head.h>
 #include <linux/debug_locks.h>
 #include <linux/lockdep.h>
+#include <linux/utsrelease.h>
+#include <linux/pid_namespace.h>
+#include <linux/compile.h>
 
 #include <asm/io.h>
 #include <asm/bugs.h>
 #error Sorry, your GCC is too old. It builds incorrect kernels.
 #endif
 
+#if __GNUC__ == 4 && __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ == 0
+#warning gcc-4.1.0 is known to miscompile the kernel.  A different compiler version is recommended.
+#endif
+
 static int init(void *);
 
 extern void init_IRQ(void);
@@ -501,7 +509,7 @@ asmlinkage void __init start_kernel(void)
        boot_cpu_init();
        page_address_init();
        printk(KERN_NOTICE);
-       printk(linux_banner);
+       printk(linux_banner, UTS_RELEASE, UTS_VERSION);
        setup_arch(&command_line);
        unwind_setup();
        setup_per_cpu_areas();
@@ -619,8 +627,6 @@ static int __init initcall_debug_setup(char *str)
 }
 __setup("initcall_debug", initcall_debug_setup);
 
-struct task_struct *child_reaper = &init_task;
-
 extern initcall_t __initcall_start[], __initcall_end[];
 
 static void __init do_initcalls(void)
@@ -720,7 +726,7 @@ static int init(void * unused)
         * assumptions about where in the task array this
         * can be found.
         */
-       child_reaper = current;
+       init_pid_ns.child_reaper = current;
 
        cad_pid = task_pid(current);
 
index 8f28344d9c70fda49300ac1455e98e086913b481..2a5dfcd1c2e6a373bb81dfa100b786e133066316 100644 (file)
@@ -35,5 +35,6 @@ struct uts_namespace init_uts_ns = {
 EXPORT_SYMBOL_GPL(init_uts_ns);
 
 const char linux_banner[] =
-       "Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "@"
-       LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n";
+       "Linux version %s (" LINUX_COMPILE_BY "@"
+       LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") %s\n";
+
index 4d20cfd38f0abbc6c9311deaa829e7b79aa12839..fa18141539fb38d4f6980c5b1f74b4c4dafa66e9 100644 (file)
@@ -115,7 +115,6 @@ struct compat_shm_info {
 
 extern int sem_ctls[];
 #define sc_semopm      (sem_ctls[2])
-#define MAXBUF (64*1024)
 
 static inline int compat_ipc_parse_version(int *cmd)
 {
@@ -307,35 +306,30 @@ long compat_sys_semctl(int first, int second, int third, void __user *uptr)
 
 long compat_sys_msgsnd(int first, int second, int third, void __user *uptr)
 {
-       struct msgbuf __user *p;
        struct compat_msgbuf __user *up = uptr;
        long type;
 
        if (first < 0)
                return -EINVAL;
-       if (second < 0 || (second >= MAXBUF - sizeof(struct msgbuf)))
+       if (second < 0)
                return -EINVAL;
 
-       p = compat_alloc_user_space(second + sizeof(struct msgbuf));
-       if (get_user(type, &up->mtype) ||
-           put_user(type, &p->mtype) ||
-           copy_in_user(p->mtext, up->mtext, second))
+       if (get_user(type, &up->mtype))
                return -EFAULT;
 
-       return sys_msgsnd(first, p, second, third);
+       return do_msgsnd(first, type, up->mtext, second, third);
 }
 
 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
                           int version, void __user *uptr)
 {
-       struct msgbuf __user *p;
        struct compat_msgbuf __user *up;
        long type;
        int err;
 
        if (first < 0)
                return -EINVAL;
-       if (second < 0 || (second >= MAXBUF - sizeof(struct msgbuf)))
+       if (second < 0)
                return -EINVAL;
 
        if (!version) {
@@ -349,14 +343,11 @@ long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
                uptr = compat_ptr(ipck.msgp);
                msgtyp = ipck.msgtyp;
        }
-       p = compat_alloc_user_space(second + sizeof(struct msgbuf));
-       err = sys_msgrcv(first, p, second, msgtyp, third);
+       up = uptr;
+       err = do_msgrcv(first, &type, up->mtext, second, msgtyp, third);
        if (err < 0)
                goto out;
-       up = uptr;
-       if (get_user(type, &p->mtype) ||
-           put_user(type, &up->mtype) ||
-           copy_in_user(up->mtext, p->mtext, err))
+       if (put_user(type, &up->mtype))
                err = -EFAULT;
 out:
        return err;
index 7c274002c9f5911d21a5f6a704e85be40d1e1777..02717f71d8d0ca325684d26d8bb79fe87c586ae1 100644 (file)
@@ -90,7 +90,7 @@ static struct super_operations mqueue_super_ops;
 static void remove_notification(struct mqueue_inode_info *info);
 
 static spinlock_t mq_lock;
-static kmem_cache_t *mqueue_inode_cachep;
+static struct kmem_cache *mqueue_inode_cachep;
 static struct vfsmount *mqueue_mnt;
 
 static unsigned int queues_count;
@@ -211,7 +211,7 @@ static int mqueue_get_sb(struct file_system_type *fs_type,
        return get_sb_single(fs_type, flags, data, mqueue_fill_super, mnt);
 }
 
-static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void *foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct mqueue_inode_info *p = (struct mqueue_inode_info *) foo;
 
@@ -224,7 +224,7 @@ static struct inode *mqueue_alloc_inode(struct super_block *sb)
 {
        struct mqueue_inode_info *ei;
 
-       ei = kmem_cache_alloc(mqueue_inode_cachep, SLAB_KERNEL);
+       ei = kmem_cache_alloc(mqueue_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        return &ei->vfs_inode;
@@ -322,7 +322,7 @@ static int mqueue_unlink(struct inode *dir, struct dentry *dentry)
 static ssize_t mqueue_read_file(struct file *filp, char __user *u_data,
                                size_t count, loff_t * off)
 {
-       struct mqueue_inode_info *info = MQUEUE_I(filp->f_dentry->d_inode);
+       struct mqueue_inode_info *info = MQUEUE_I(filp->f_path.dentry->d_inode);
        char buffer[FILENT_SIZE];
        size_t slen;
        loff_t o;
@@ -354,13 +354,13 @@ static ssize_t mqueue_read_file(struct file *filp, char __user *u_data,
                return -EFAULT;
 
        *off = o + count;
-       filp->f_dentry->d_inode->i_atime = filp->f_dentry->d_inode->i_ctime = CURRENT_TIME;
+       filp->f_path.dentry->d_inode->i_atime = filp->f_path.dentry->d_inode->i_ctime = CURRENT_TIME;
        return count;
 }
 
 static int mqueue_flush_file(struct file *filp, fl_owner_t id)
 {
-       struct mqueue_inode_info *info = MQUEUE_I(filp->f_dentry->d_inode);
+       struct mqueue_inode_info *info = MQUEUE_I(filp->f_path.dentry->d_inode);
 
        spin_lock(&info->lock);
        if (task_tgid(current) == info->notify_owner)
@@ -372,7 +372,7 @@ static int mqueue_flush_file(struct file *filp, fl_owner_t id)
 
 static unsigned int mqueue_poll_file(struct file *filp, struct poll_table_struct *poll_tab)
 {
-       struct mqueue_inode_info *info = MQUEUE_I(filp->f_dentry->d_inode);
+       struct mqueue_inode_info *info = MQUEUE_I(filp->f_path.dentry->d_inode);
        int retval = 0;
 
        poll_wait(filp, &info->wait_q, poll_tab);
@@ -836,7 +836,7 @@ asmlinkage long sys_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr,
        if (unlikely(!filp))
                goto out;
 
-       inode = filp->f_dentry->d_inode;
+       inode = filp->f_path.dentry->d_inode;
        if (unlikely(filp->f_op != &mqueue_file_operations))
                goto out_fput;
        info = MQUEUE_I(inode);
@@ -919,7 +919,7 @@ asmlinkage ssize_t sys_mq_timedreceive(mqd_t mqdes, char __user *u_msg_ptr,
        if (unlikely(!filp))
                goto out;
 
-       inode = filp->f_dentry->d_inode;
+       inode = filp->f_path.dentry->d_inode;
        if (unlikely(filp->f_op != &mqueue_file_operations))
                goto out_fput;
        info = MQUEUE_I(inode);
@@ -1056,7 +1056,7 @@ retry:
        if (!filp)
                goto out;
 
-       inode = filp->f_dentry->d_inode;
+       inode = filp->f_path.dentry->d_inode;
        if (unlikely(filp->f_op != &mqueue_file_operations))
                goto out_fput;
        info = MQUEUE_I(inode);
@@ -1126,7 +1126,7 @@ asmlinkage long sys_mq_getsetattr(mqd_t mqdes,
        if (!filp)
                goto out;
 
-       inode = filp->f_dentry->d_inode;
+       inode = filp->f_path.dentry->d_inode;
        if (unlikely(filp->f_op != &mqueue_file_operations))
                goto out_fput;
        info = MQUEUE_I(inode);
index 1266b1d0c8e33d47f25e46a692b53afd5186d5e6..a388824740e7e9c1e770dde9d3082609c0e8f017 100644 (file)
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -626,12 +626,11 @@ static inline int pipelined_send(struct msg_queue *msq, struct msg_msg *msg)
        return 0;
 }
 
-asmlinkage long
-sys_msgsnd(int msqid, struct msgbuf __user *msgp, size_t msgsz, int msgflg)
+long do_msgsnd(int msqid, long mtype, void __user *mtext,
+               size_t msgsz, int msgflg)
 {
        struct msg_queue *msq;
        struct msg_msg *msg;
-       long mtype;
        int err;
        struct ipc_namespace *ns;
 
@@ -639,12 +638,10 @@ sys_msgsnd(int msqid, struct msgbuf __user *msgp, size_t msgsz, int msgflg)
 
        if (msgsz > ns->msg_ctlmax || (long) msgsz < 0 || msqid < 0)
                return -EINVAL;
-       if (get_user(mtype, &msgp->mtype))
-               return -EFAULT;
        if (mtype < 1)
                return -EINVAL;
 
-       msg = load_msg(msgp->mtext, msgsz);
+       msg = load_msg(mtext, msgsz);
        if (IS_ERR(msg))
                return PTR_ERR(msg);
 
@@ -723,6 +720,16 @@ out_free:
        return err;
 }
 
+asmlinkage long
+sys_msgsnd(int msqid, struct msgbuf __user *msgp, size_t msgsz, int msgflg)
+{
+       long mtype;
+
+       if (get_user(mtype, &msgp->mtype))
+               return -EFAULT;
+       return do_msgsnd(msqid, mtype, msgp->mtext, msgsz, msgflg);
+}
+
 static inline int convert_mode(long *msgtyp, int msgflg)
 {
        /*
@@ -742,8 +749,8 @@ static inline int convert_mode(long *msgtyp, int msgflg)
        return SEARCH_EQUAL;
 }
 
-asmlinkage long sys_msgrcv(int msqid, struct msgbuf __user *msgp, size_t msgsz,
-                          long msgtyp, int msgflg)
+long do_msgrcv(int msqid, long *pmtype, void __user *mtext,
+               size_t msgsz, long msgtyp, int msgflg)
 {
        struct msg_queue *msq;
        struct msg_msg *msg;
@@ -889,15 +896,30 @@ out_unlock:
                return PTR_ERR(msg);
 
        msgsz = (msgsz > msg->m_ts) ? msg->m_ts : msgsz;
-       if (put_user (msg->m_type, &msgp->mtype) ||
-           store_msg(msgp->mtext, msg, msgsz)) {
+       *pmtype = msg->m_type;
+       if (store_msg(mtext, msg, msgsz))
                msgsz = -EFAULT;
-       }
+
        free_msg(msg);
 
        return msgsz;
 }
 
+asmlinkage long sys_msgrcv(int msqid, struct msgbuf __user *msgp, size_t msgsz,
+                          long msgtyp, int msgflg)
+{
+       long err, mtype;
+
+       err =  do_msgrcv(msqid, &mtype, msgp->mtext, msgsz, msgtyp, msgflg);
+       if (err < 0)
+               goto out;
+
+       if (put_user(mtype, &msgp->mtype))
+               err = -EFAULT;
+out:
+       return err;
+}
+
 #ifdef CONFIG_PROC_FS
 static int sysvipc_msg_proc_show(struct seq_file *s, void *it)
 {
index 21b3289d640c1eb0989457f42f1eb4b62b675aff..d3e12efd55cb39e6cdce7cd48ac73833100f60cf 100644 (file)
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1070,14 +1070,13 @@ static struct sem_undo *find_undo(struct ipc_namespace *ns, int semid)
        ipc_rcu_getref(sma);
        sem_unlock(sma);
 
-       new = (struct sem_undo *) kmalloc(sizeof(struct sem_undo) + sizeof(short)*nsems, GFP_KERNEL);
+       new = kzalloc(sizeof(struct sem_undo) + sizeof(short)*nsems, GFP_KERNEL);
        if (!new) {
                ipc_lock_by_ptr(&sma->sem_perm);
                ipc_rcu_putref(sma);
                sem_unlock(sma);
                return ERR_PTR(-ENOMEM);
        }
-       memset(new, 0, sizeof(struct sem_undo) + sizeof(short)*nsems);
        new->semadj = (short *) &new[1];
        new->semid = semid;
 
index d1198dd07a1a2294ae8eb25e44eecfc3e902070f..6d16bb6de7d296889b015b8ab6c8d480d2c14aa4 100644 (file)
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -168,7 +168,7 @@ static inline void shm_inc(struct ipc_namespace *ns, int id)
 static void shm_open(struct vm_area_struct *shmd)
 {
        shm_inc(shm_file_ns(shmd->vm_file),
-                       shmd->vm_file->f_dentry->d_inode->i_ino);
+                       shmd->vm_file->f_path.dentry->d_inode->i_ino);
 }
 
 /*
@@ -187,7 +187,7 @@ static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
        if (!is_file_hugepages(shp->shm_file))
                shmem_lock(shp->shm_file, 0, shp->mlock_user);
        else
-               user_shm_unlock(shp->shm_file->f_dentry->d_inode->i_size,
+               user_shm_unlock(shp->shm_file->f_path.dentry->d_inode->i_size,
                                                shp->mlock_user);
        fput (shp->shm_file);
        security_shm_free(shp);
@@ -203,7 +203,7 @@ static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
 static void shm_close (struct vm_area_struct *shmd)
 {
        struct file * file = shmd->vm_file;
-       int id = file->f_dentry->d_inode->i_ino;
+       int id = file->f_path.dentry->d_inode->i_ino;
        struct shmid_kernel *shp;
        struct ipc_namespace *ns;
 
@@ -233,7 +233,7 @@ static int shm_mmap(struct file * file, struct vm_area_struct * vma)
                vma->vm_ops = &shm_vm_ops;
                if (!(vma->vm_flags & VM_WRITE))
                        vma->vm_flags &= ~VM_MAYWRITE;
-               shm_inc(shm_file_ns(file), file->f_dentry->d_inode->i_ino);
+               shm_inc(shm_file_ns(file), file->f_path.dentry->d_inode->i_ino);
        }
 
        return ret;
@@ -330,7 +330,7 @@ static int newseg (struct ipc_namespace *ns, key_t key, int shmflg, size_t size)
        shp->shm_nattch = 0;
        shp->id = shm_buildid(ns, id, shp->shm_perm.seq);
        shp->shm_file = file;
-       file->f_dentry->d_inode->i_ino = shp->id;
+       file->f_path.dentry->d_inode->i_ino = shp->id;
 
        shm_file_ns(file) = get_ipc_ns(ns);
 
@@ -495,7 +495,7 @@ static void shm_get_stat(struct ipc_namespace *ns, unsigned long *rss,
                if(!shp)
                        continue;
 
-               inode = shp->shm_file->f_dentry->d_inode;
+               inode = shp->shm_file->f_path.dentry->d_inode;
 
                if (is_file_hugepages(shp->shm_file)) {
                        struct address_space *mapping = inode->i_mapping;
@@ -843,7 +843,7 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
        }
                
        file = shp->shm_file;
-       size = i_size_read(file->f_dentry->d_inode);
+       size = i_size_read(file->f_path.dentry->d_inode);
        shp->shm_nattch++;
        shm_unlock(shp);
 
@@ -948,7 +948,7 @@ asmlinkage long sys_shmdt(char __user *shmaddr)
                        (vma->vm_start - addr)/PAGE_SIZE == vma->vm_pgoff) {
 
 
-                       size = vma->vm_file->f_dentry->d_inode->i_size;
+                       size = vma->vm_file->f_path.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
index 248e1c396f8b062f9a0e30b3e607336be40cd967..4af15802ccd46e960a857c04db9afe2c0ba49dc3 100644 (file)
@@ -7,7 +7,7 @@ choice
        default HZ_250
        help
         Allows the configuration of the timer frequency. It is customary
-        to have the timer interrupt run at 1000 HZ but 100 HZ may be more
+        to have the timer interrupt run at 1000 Hz but 100 Hz may be more
         beneficial for servers and NUMA systems that do not need to have
         a fast response for user interaction and that may experience bus
         contention and cacheline bounces as a result of timer interrupts.
@@ -19,21 +19,30 @@ choice
        config HZ_100
                bool "100 HZ"
        help
-         100 HZ is a typical choice for servers, SMP and NUMA systems
+         100 Hz is a typical choice for servers, SMP and NUMA systems
          with lots of processors that may show reduced performance if
          too many timer interrupts are occurring.
 
        config HZ_250
                bool "250 HZ"
        help
-        250 HZ is a good compromise choice allowing server performance
+        250 Hz is a good compromise choice allowing server performance
         while also showing good interactive responsiveness even
-        on SMP and NUMA systems.
+        on SMP and NUMA systems. If you are going to be using NTSC video
+        or multimedia, selected 300Hz instead.
+
+       config HZ_300
+               bool "300 HZ"
+       help
+        300 Hz is a good compromise choice allowing server performance
+        while also showing good interactive responsiveness even
+        on SMP and NUMA systems and exactly dividing by both PAL and
+        NTSC frame rates for video and multimedia work.
 
        config HZ_1000
                bool "1000 HZ"
        help
-        1000 HZ is the preferred choice for desktop systems and other
+        1000 Hz is the preferred choice for desktop systems and other
         systems requiring fast interactive responses to events.
 
 endchoice
@@ -42,5 +51,6 @@ config HZ
        int
        default 100 if HZ_100
        default 250 if HZ_250
+       default 300 if HZ_300
        default 1000 if HZ_1000
 
index 0aad5ca36a8125e205e85978aa32e8712ddc957a..70d0d88e55541821ff0fd9561e30fcae12e49e17 100644 (file)
@@ -89,7 +89,8 @@ struct acct_glbs {
        struct timer_list       timer;
 };
 
-static struct acct_glbs acct_globals __cacheline_aligned = {SPIN_LOCK_UNLOCKED};
+static struct acct_glbs acct_globals __cacheline_aligned =
+       {__SPIN_LOCK_UNLOCKED(acct_globals.lock)};
 
 /*
  * Called whenever the timer says to check the free space.
@@ -117,7 +118,7 @@ static int check_free_space(struct file *file)
        spin_unlock(&acct_globals.lock);
 
        /* May block */
-       if (vfs_statfs(file->f_dentry, &sbuf))
+       if (vfs_statfs(file->f_path.dentry, &sbuf))
                return res;
        suspend = sbuf.f_blocks * SUSPEND;
        resume = sbuf.f_blocks * RESUME;
@@ -193,7 +194,7 @@ static void acct_file_reopen(struct file *file)
                add_timer(&acct_globals.timer);
        }
        if (old_acct) {
-               mnt_unpin(old_acct->f_vfsmnt);
+               mnt_unpin(old_acct->f_path.mnt);
                spin_unlock(&acct_globals.lock);
                do_acct_process(old_acct);
                filp_close(old_acct, NULL);
@@ -211,7 +212,7 @@ static int acct_on(char *name)
        if (IS_ERR(file))
                return PTR_ERR(file);
 
-       if (!S_ISREG(file->f_dentry->d_inode->i_mode)) {
+       if (!S_ISREG(file->f_path.dentry->d_inode->i_mode)) {
                filp_close(file, NULL);
                return -EACCES;
        }
@@ -228,11 +229,11 @@ static int acct_on(char *name)
        }
 
        spin_lock(&acct_globals.lock);
-       mnt_pin(file->f_vfsmnt);
+       mnt_pin(file->f_path.mnt);
        acct_file_reopen(file);
        spin_unlock(&acct_globals.lock);
 
-       mntput(file->f_vfsmnt); /* it's pinned, now give up active reference */
+       mntput(file->f_path.mnt); /* it's pinned, now give up active reference */
 
        return 0;
 }
@@ -282,7 +283,7 @@ asmlinkage long sys_acct(const char __user *name)
 void acct_auto_close_mnt(struct vfsmount *m)
 {
        spin_lock(&acct_globals.lock);
-       if (acct_globals.file && acct_globals.file->f_vfsmnt == m)
+       if (acct_globals.file && acct_globals.file->f_path.mnt == m)
                acct_file_reopen(NULL);
        spin_unlock(&acct_globals.lock);
 }
@@ -298,7 +299,7 @@ void acct_auto_close(struct super_block *sb)
 {
        spin_lock(&acct_globals.lock);
        if (acct_globals.file &&
-           acct_globals.file->f_vfsmnt->mnt_sb == sb) {
+           acct_globals.file->f_path.mnt->mnt_sb == sb) {
                acct_file_reopen(NULL);
        }
        spin_unlock(&acct_globals.lock);
@@ -427,6 +428,7 @@ static void do_acct_process(struct file *file)
        u64 elapsed;
        u64 run_time;
        struct timespec uptime;
+       struct tty_struct *tty;
 
        /*
         * First check to see if there is enough free_space to continue
@@ -483,16 +485,9 @@ static void do_acct_process(struct file *file)
        ac.ac_ppid = current->parent->tgid;
 #endif
 
-       mutex_lock(&tty_mutex);
-       /* FIXME: Whoever is responsible for current->signal locking needs
-          to use the same locking all over the kernel and document it */
-       read_lock(&tasklist_lock);
-       ac.ac_tty = current->signal->tty ?
-               old_encode_dev(tty_devnum(current->signal->tty)) : 0;
-       read_unlock(&tasklist_lock);
-       mutex_unlock(&tty_mutex);
-
        spin_lock_irq(&current->sighand->siglock);
+       tty = current->signal->tty;
+       ac.ac_tty = tty ? old_encode_dev(tty_devnum(tty)) : 0;
        ac.ac_utime = encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_utime)));
        ac.ac_stime = encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_stime)));
        ac.ac_flag = pacct->ac_flag;
index 98106f6078b0005a89ef889574441c663f40732f..d9b690ac684b9c6a638cee37d11949d62ef22992 100644 (file)
@@ -57,6 +57,7 @@
 #include <linux/netlink.h>
 #include <linux/selinux.h>
 #include <linux/inotify.h>
+#include <linux/freezer.h>
 
 #include "audit.h"
 
index 4f40d923af8ea2a349736c793d2164c72aa4fa63..2e896f8ae29e4ce81886f115395dcedd9f898acf 100644 (file)
@@ -636,10 +636,9 @@ static struct audit_rule *audit_krule_to_rule(struct audit_krule *krule)
        struct audit_rule *rule;
        int i;
 
-       rule = kmalloc(sizeof(*rule), GFP_KERNEL);
+       rule = kzalloc(sizeof(*rule), GFP_KERNEL);
        if (unlikely(!rule))
                return NULL;
-       memset(rule, 0, sizeof(*rule));
 
        rule->flags = krule->flags | krule->listnr;
        rule->action = krule->action;
index ab97e51012325b24191ec5a6f2c1e2514968dd02..298897559ca4ab9d346566cfac6d50791371e9d3 100644 (file)
@@ -731,7 +731,7 @@ static inline void audit_free_context(struct audit_context *context)
                printk(KERN_ERR "audit: freed %d contexts\n", count);
 }
 
-static void audit_log_task_context(struct audit_buffer *ab)
+void audit_log_task_context(struct audit_buffer *ab)
 {
        char *ctx = NULL;
        ssize_t len = 0;
@@ -760,6 +760,8 @@ error_path:
        return;
 }
 
+EXPORT_SYMBOL(audit_log_task_context);
+
 static void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk)
 {
        char name[sizeof(tsk->comm)];
@@ -779,8 +781,8 @@ static void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk
                        if ((vma->vm_flags & VM_EXECUTABLE) &&
                            vma->vm_file) {
                                audit_log_d_path(ab, "exe=",
-                                                vma->vm_file->f_dentry,
-                                                vma->vm_file->f_vfsmnt);
+                                                vma->vm_file->f_path.dentry,
+                                                vma->vm_file->f_path.mnt);
                                break;
                        }
                        vma = vma->vm_next;
@@ -824,10 +826,12 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
                                 context->return_code);
 
        mutex_lock(&tty_mutex);
+       read_lock(&tasklist_lock);
        if (tsk->signal && tsk->signal->tty && tsk->signal->tty->name)
                tty = tsk->signal->tty->name;
        else
                tty = "(none)";
+       read_unlock(&tasklist_lock);
        audit_log_format(ab,
                  " a0=%lx a1=%lx a2=%lx a3=%lx items=%d"
                  " ppid=%d pid=%d auid=%u uid=%u gid=%u"
@@ -1488,6 +1492,8 @@ uid_t audit_get_loginuid(struct audit_context *ctx)
        return ctx ? ctx->loginuid : -1;
 }
 
+EXPORT_SYMBOL(audit_get_loginuid);
+
 /**
  * __audit_mq_open - record audit data for a POSIX MQ open
  * @oflag: open flag
index f9e31974f4addf262cee19d1049f6b1fd55bc47e..8fa1fb28f8a79b895d6438a2485466d2ac8efda1 100644 (file)
@@ -75,7 +75,7 @@ ikconfig_read_current(struct file *file, char __user *buf,
        return count;
 }
 
-static struct file_operations ikconfig_file_ops = {
+static const struct file_operations ikconfig_file_ops = {
        .owner = THIS_MODULE,
        .read = ikconfig_read_current,
 };
index 272254f20d9744b4844cde0c6da1dc13210283c4..9124669f45860cac40c7b03060ef582b94d595ec 100644 (file)
@@ -270,11 +270,7 @@ int disable_nonboot_cpus(void)
                        goto out;
                }
        }
-       error = set_cpus_allowed(current, cpumask_of_cpu(first_cpu));
-       if (error) {
-               printk(KERN_ERR "Could not run on CPU%d\n", first_cpu);
-               goto out;
-       }
+
        /* We take down all of the non-boot CPUs in one shot to avoid races
         * with the userspace trying to use the CPU hotplug at the same time
         */
index 6313c38c930e62025c0e76a057d83023b77a6bb5..2c3b4431472bec305dc41dec0c180c23d009ad58 100644 (file)
@@ -413,8 +413,8 @@ static struct file_system_type cpuset_fs_type = {
  *
  *
  * When reading/writing to a file:
- *     - the cpuset to use in file->f_dentry->d_parent->d_fsdata
- *     - the 'cftype' of the file is file->f_dentry->d_fsdata
+ *     - the cpuset to use in file->f_path.dentry->d_parent->d_fsdata
+ *     - the 'cftype' of the file is file->f_path.dentry->d_fsdata
  */
 
 struct cftype {
@@ -729,9 +729,11 @@ static int validate_change(const struct cpuset *cur, const struct cpuset *trial)
        }
 
        /* Remaining checks don't apply to root cpuset */
-       if ((par = cur->parent) == NULL)
+       if (cur == &top_cpuset)
                return 0;
 
+       par = cur->parent;
+
        /* We must be a subset of our parent cpuset */
        if (!is_cpuset_subset(trial, par))
                return -EACCES;
@@ -1060,10 +1062,7 @@ static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs, char *buf)
        cpu_exclusive_changed =
                (is_cpu_exclusive(cs) != is_cpu_exclusive(&trialcs));
        mutex_lock(&callback_mutex);
-       if (turning_on)
-               set_bit(bit, &cs->flags);
-       else
-               clear_bit(bit, &cs->flags);
+       cs->flags = trialcs.flags;
        mutex_unlock(&callback_mutex);
 
        if (cpu_exclusive_changed)
@@ -1281,18 +1280,19 @@ typedef enum {
        FILE_TASKLIST,
 } cpuset_filetype_t;
 
-static ssize_t cpuset_common_file_write(struct file *file, const char __user *userbuf,
+static ssize_t cpuset_common_file_write(struct file *file,
+                                       const char __user *userbuf,
                                        size_t nbytes, loff_t *unused_ppos)
 {
-       struct cpuset *cs = __d_cs(file->f_dentry->d_parent);
-       struct cftype *cft = __d_cft(file->f_dentry);
+       struct cpuset *cs = __d_cs(file->f_path.dentry->d_parent);
+       struct cftype *cft = __d_cft(file->f_path.dentry);
        cpuset_filetype_t type = cft->private;
        char *buffer;
        char *pathbuf = NULL;
        int retval = 0;
 
        /* Crude upper limit on largest legitimate cpulist user might write. */
-       if (nbytes > 100 + 6 * NR_CPUS)
+       if (nbytes > 100 + 6 * max(NR_CPUS, MAX_NUMNODES))
                return -E2BIG;
 
        /* +1 for nul-terminator */
@@ -1367,7 +1367,7 @@ static ssize_t cpuset_file_write(struct file *file, const char __user *buf,
                                                size_t nbytes, loff_t *ppos)
 {
        ssize_t retval = 0;
-       struct cftype *cft = __d_cft(file->f_dentry);
+       struct cftype *cft = __d_cft(file->f_path.dentry);
        if (!cft)
                return -ENODEV;
 
@@ -1417,8 +1417,8 @@ static int cpuset_sprintf_memlist(char *page, struct cpuset *cs)
 static ssize_t cpuset_common_file_read(struct file *file, char __user *buf,
                                size_t nbytes, loff_t *ppos)
 {
-       struct cftype *cft = __d_cft(file->f_dentry);
-       struct cpuset *cs = __d_cs(file->f_dentry->d_parent);
+       struct cftype *cft = __d_cft(file->f_path.dentry);
+       struct cpuset *cs = __d_cs(file->f_path.dentry->d_parent);
        cpuset_filetype_t type = cft->private;
        char *page;
        ssize_t retval = 0;
@@ -1476,7 +1476,7 @@ static ssize_t cpuset_file_read(struct file *file, char __user *buf, size_t nbyt
                                                                loff_t *ppos)
 {
        ssize_t retval = 0;
-       struct cftype *cft = __d_cft(file->f_dentry);
+       struct cftype *cft = __d_cft(file->f_path.dentry);
        if (!cft)
                return -ENODEV;
 
@@ -1498,7 +1498,7 @@ static int cpuset_file_open(struct inode *inode, struct file *file)
        if (err)
                return err;
 
-       cft = __d_cft(file->f_dentry);
+       cft = __d_cft(file->f_path.dentry);
        if (!cft)
                return -ENODEV;
        if (cft->open)
@@ -1511,7 +1511,7 @@ static int cpuset_file_open(struct inode *inode, struct file *file)
 
 static int cpuset_file_release(struct inode *inode, struct file *file)
 {
-       struct cftype *cft = __d_cft(file->f_dentry);
+       struct cftype *cft = __d_cft(file->f_path.dentry);
        if (cft->release)
                return cft->release(inode, file);
        return 0;
@@ -1532,7 +1532,7 @@ static int cpuset_rename(struct inode *old_dir, struct dentry *old_dentry,
        return simple_rename(old_dir, old_dentry, new_dir, new_dentry);
 }
 
-static struct file_operations cpuset_file_operations = {
+static const struct file_operations cpuset_file_operations = {
        .read = cpuset_file_read,
        .write = cpuset_file_write,
        .llseek = generic_file_llseek,
@@ -1700,7 +1700,7 @@ static int pid_array_to_buf(char *buf, int sz, pid_t *a, int npids)
  */
 static int cpuset_tasks_open(struct inode *unused, struct file *file)
 {
-       struct cpuset *cs = __d_cs(file->f_dentry->d_parent);
+       struct cpuset *cs = __d_cs(file->f_path.dentry->d_parent);
        struct ctr_struct *ctr;
        pid_t *pidarray;
        int npids;
@@ -2045,7 +2045,6 @@ out:
        return err;
 }
 
-#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_MEMORY_HOTPLUG)
 /*
  * If common_cpu_mem_hotplug_unplug(), below, unplugs any CPUs
  * or memory nodes, we need to walk over the cpuset hierarchy,
@@ -2109,9 +2108,7 @@ static void common_cpu_mem_hotplug_unplug(void)
        mutex_unlock(&callback_mutex);
        mutex_unlock(&manage_mutex);
 }
-#endif
 
-#ifdef CONFIG_HOTPLUG_CPU
 /*
  * The top_cpuset tracks what CPUs and Memory Nodes are online,
  * period.  This is necessary in order to make cpusets transparent
@@ -2128,7 +2125,6 @@ static int cpuset_handle_cpuhp(struct notifier_block *nb,
        common_cpu_mem_hotplug_unplug();
        return 0;
 }
-#endif
 
 #ifdef CONFIG_MEMORY_HOTPLUG
 /*
@@ -2610,7 +2606,7 @@ static int cpuset_open(struct inode *inode, struct file *file)
        return single_open(file, proc_cpuset_show, pid);
 }
 
-struct file_operations proc_cpuset_operations = {
+const struct file_operations proc_cpuset_operations = {
        .open           = cpuset_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
index 66a0ea48751d647abb56f7e4741e3f0d02dd7b4e..766d5912b26a4533edd2b07ac767dd36db581ca3 100644 (file)
@@ -20,7 +20,7 @@
 #include <linux/delayacct.h>
 
 int delayacct_on __read_mostly = 1;    /* Delay accounting turned on/off */
-kmem_cache_t *delayacct_cache;
+struct kmem_cache *delayacct_cache;
 
 static int __init delayacct_setup_disable(char *str)
 {
@@ -41,7 +41,7 @@ void delayacct_init(void)
 
 void __delayacct_tsk_init(struct task_struct *tsk)
 {
-       tsk->delays = kmem_cache_zalloc(delayacct_cache, SLAB_KERNEL);
+       tsk->delays = kmem_cache_zalloc(delayacct_cache, GFP_KERNEL);
        if (tsk->delays)
                spin_lock_init(&tsk->delays->lock);
 }
index 2020644c938a48d0f34670765e788b32fed8900d..937b13ca33baaac6a3ab01437b4016f9995a11f9 100644 (file)
@@ -140,7 +140,7 @@ static int proc_dma_open(struct inode *inode, struct file *file)
        return single_open(file, proc_dma_show, NULL);
 }
 
-static struct file_operations proc_dma_operations = {
+static const struct file_operations proc_dma_operations = {
        .open           = proc_dma_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
index 06de6c4e8ca3a66937ce8763d33ca42852fbb698..03e64fe4a14af6b12a1b3638e6d54263a589af47 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/completion.h>
 #include <linux/personality.h>
 #include <linux/tty.h>
-#include <linux/namespace.h>
+#include <linux/mnt_namespace.h>
 #include <linux/key.h>
 #include <linux/security.h>
 #include <linux/cpu.h>
@@ -22,6 +22,7 @@
 #include <linux/file.h>
 #include <linux/binfmts.h>
 #include <linux/nsproxy.h>
+#include <linux/pid_namespace.h>
 #include <linux/ptrace.h>
 #include <linux/profile.h>
 #include <linux/mount.h>
@@ -48,7 +49,6 @@
 #include <asm/mmu_context.h>
 
 extern void sem_exit (void);
-extern struct task_struct *child_reaper;
 
 static void exit_mm(struct task_struct * tsk);
 
@@ -189,21 +189,18 @@ repeat:
 int session_of_pgrp(int pgrp)
 {
        struct task_struct *p;
-       int sid = -1;
+       int sid = 0;
 
        read_lock(&tasklist_lock);
-       do_each_task_pid(pgrp, PIDTYPE_PGID, p) {
-               if (p->signal->session > 0) {
-                       sid = p->signal->session;
-                       goto out;
-               }
-       } while_each_task_pid(pgrp, PIDTYPE_PGID, p);
-       p = find_task_by_pid(pgrp);
-       if (p)
-               sid = p->signal->session;
-out:
+
+       p = find_task_by_pid_type(PIDTYPE_PGID, pgrp);
+       if (p == NULL)
+               p = find_task_by_pid(pgrp);
+       if (p != NULL)
+               sid = process_session(p);
+
        read_unlock(&tasklist_lock);
-       
+
        return sid;
 }
 
@@ -225,8 +222,8 @@ static int will_become_orphaned_pgrp(int pgrp, struct task_struct *ignored_task)
                                || p->exit_state
                                || is_init(p->real_parent))
                        continue;
-               if (process_group(p->real_parent) != pgrp
-                           && p->real_parent->signal->session == p->signal->session) {
+               if (process_group(p->real_parent) != pgrp &&
+                   process_session(p->real_parent) == process_session(p)) {
                        ret = 0;
                        break;
                }
@@ -260,7 +257,8 @@ static int has_stopped_jobs(int pgrp)
 }
 
 /**
- * reparent_to_init - Reparent the calling kernel thread to the init task.
+ * reparent_to_init - Reparent the calling kernel thread to the init task
+ * of the pid space that the thread belongs to.
  *
  * If a kernel thread is launched as a result of a system call, or if
  * it ever exits, it should generally reparent itself to init so that
@@ -278,8 +276,8 @@ static void reparent_to_init(void)
        ptrace_unlink(current);
        /* Reparent to init */
        remove_parent(current);
-       current->parent = child_reaper;
-       current->real_parent = child_reaper;
+       current->parent = child_reaper(current);
+       current->real_parent = child_reaper(current);
        add_parent(current);
 
        /* Set the exit signal to SIGCHLD so we signal init on exit */
@@ -302,9 +300,9 @@ void __set_special_pids(pid_t session, pid_t pgrp)
 {
        struct task_struct *curr = current->group_leader;
 
-       if (curr->signal->session != session) {
+       if (process_session(curr) != session) {
                detach_pid(curr, PIDTYPE_SID);
-               curr->signal->session = session;
+               set_signal_session(curr->signal, session);
                attach_pid(curr, PIDTYPE_SID, session);
        }
        if (process_group(curr) != pgrp) {
@@ -314,7 +312,7 @@ void __set_special_pids(pid_t session, pid_t pgrp)
        }
 }
 
-void set_special_pids(pid_t session, pid_t pgrp)
+static void set_special_pids(pid_t session, pid_t pgrp)
 {
        write_lock_irq(&tasklist_lock);
        __set_special_pids(session, pgrp);
@@ -384,9 +382,7 @@ void daemonize(const char *name, ...)
        exit_mm(current);
 
        set_special_pids(1, 1);
-       mutex_lock(&tty_mutex);
-       current->signal->tty = NULL;
-       mutex_unlock(&tty_mutex);
+       proc_clear_tty(current);
 
        /* Block and flush all signals */
        sigfillset(&blocked);
@@ -649,10 +645,11 @@ reparent_thread(struct task_struct *p, struct task_struct *father, int traced)
         * outside, so the child pgrp is now orphaned.
         */
        if ((process_group(p) != process_group(father)) &&
-           (p->signal->session == father->signal->session)) {
+           (process_session(p) == process_session(father))) {
                int pgrp = process_group(p);
 
-               if (will_become_orphaned_pgrp(pgrp, NULL) && has_stopped_jobs(pgrp)) {
+               if (will_become_orphaned_pgrp(pgrp, NULL) &&
+                   has_stopped_jobs(pgrp)) {
                        __kill_pg_info(SIGHUP, SEND_SIG_PRIV, pgrp);
                        __kill_pg_info(SIGCONT, SEND_SIG_PRIV, pgrp);
                }
@@ -663,7 +660,8 @@ reparent_thread(struct task_struct *p, struct task_struct *father, int traced)
  * When we die, we re-parent all our children.
  * Try to give them to another thread in our thread
  * group, and if no such member exists, give it to
- * the global child reaper process (ie "init")
+ * the child reaper process (ie "init") in our pid
+ * space.
  */
 static void
 forget_original_parent(struct task_struct *father, struct list_head *to_release)
@@ -674,7 +672,7 @@ forget_original_parent(struct task_struct *father, struct list_head *to_release)
        do {
                reaper = next_thread(reaper);
                if (reaper == father) {
-                       reaper = child_reaper;
+                       reaper = child_reaper(father);
                        break;
                }
        } while (reaper->exit_state);
@@ -786,7 +784,7 @@ static void exit_notify(struct task_struct *tsk)
        t = tsk->real_parent;
        
        if ((process_group(t) != process_group(tsk)) &&
-           (t->signal->session == tsk->signal->session) &&
+           (process_session(t) == process_session(tsk)) &&
            will_become_orphaned_pgrp(process_group(tsk), tsk) &&
            has_stopped_jobs(process_group(tsk))) {
                __kill_pg_info(SIGHUP, SEND_SIG_PRIV, process_group(tsk));
@@ -850,9 +848,7 @@ static void exit_notify(struct task_struct *tsk)
 fastcall NORET_TYPE void do_exit(long code)
 {
        struct task_struct *tsk = current;
-       struct taskstats *tidstats;
        int group_dead;
-       unsigned int mycpu;
 
        profile_task_exit(tsk);
 
@@ -862,8 +858,13 @@ fastcall NORET_TYPE void do_exit(long code)
                panic("Aiee, killing interrupt handler!");
        if (unlikely(!tsk->pid))
                panic("Attempted to kill the idle task!");
-       if (unlikely(tsk == child_reaper))
-               panic("Attempted to kill init!");
+       if (unlikely(tsk == child_reaper(tsk))) {
+               if (tsk->nsproxy->pid_ns != &init_pid_ns)
+                       tsk->nsproxy->pid_ns->child_reaper = init_pid_ns.child_reaper;
+               else
+                       panic("Attempted to kill init!");
+       }
+
 
        if (unlikely(current->ptrace & PT_TRACE_EXIT)) {
                current->ptrace_message = code;
@@ -890,8 +891,6 @@ fastcall NORET_TYPE void do_exit(long code)
                                current->comm, current->pid,
                                preempt_count());
 
-       taskstats_exit_alloc(&tidstats, &mycpu);
-
        acct_update_integrals(tsk);
        if (tsk->mm) {
                update_hiwater_rss(tsk->mm);
@@ -911,8 +910,8 @@ fastcall NORET_TYPE void do_exit(long code)
 #endif
        if (unlikely(tsk->audit_context))
                audit_free(tsk);
-       taskstats_exit_send(tsk, tidstats, group_dead, mycpu);
-       taskstats_exit_free(tidstats);
+
+       taskstats_exit(tsk, group_dead);
 
        exit_mm(tsk);
 
index 8cdd3e72ba55f9ee52b098e67b1b7d4fcd04aa58..8c859eef8e6a5b825612b750608f452459626643 100644 (file)
@@ -18,7 +18,7 @@
 #include <linux/module.h>
 #include <linux/vmalloc.h>
 #include <linux/completion.h>
-#include <linux/namespace.h>
+#include <linux/mnt_namespace.h>
 #include <linux/personality.h>
 #include <linux/mempolicy.h>
 #include <linux/sem.h>
@@ -82,26 +82,26 @@ int nr_processes(void)
 #ifndef __HAVE_ARCH_TASK_STRUCT_ALLOCATOR
 # define alloc_task_struct()   kmem_cache_alloc(task_struct_cachep, GFP_KERNEL)
 # define free_task_struct(tsk) kmem_cache_free(task_struct_cachep, (tsk))
-static kmem_cache_t *task_struct_cachep;
+static struct kmem_cache *task_struct_cachep;
 #endif
 
 /* SLAB cache for signal_struct structures (tsk->signal) */
-static kmem_cache_t *signal_cachep;
+static struct kmem_cache *signal_cachep;
 
 /* SLAB cache for sighand_struct structures (tsk->sighand) */
-kmem_cache_t *sighand_cachep;
+struct kmem_cache *sighand_cachep;
 
 /* SLAB cache for files_struct structures (tsk->files) */
-kmem_cache_t *files_cachep;
+struct kmem_cache *files_cachep;
 
 /* SLAB cache for fs_struct structures (tsk->fs) */
-kmem_cache_t *fs_cachep;
+struct kmem_cache *fs_cachep;
 
 /* SLAB cache for vm_area_struct structures */
-kmem_cache_t *vm_area_cachep;
+struct kmem_cache *vm_area_cachep;
 
 /* SLAB cache for mm_struct structures (tsk->mm) */
-static kmem_cache_t *mm_cachep;
+static struct kmem_cache *mm_cachep;
 
 void free_task(struct task_struct *tsk)
 {
@@ -237,7 +237,7 @@ static inline int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
                                goto fail_nomem;
                        charge = len;
                }
-               tmp = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+               tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
                if (!tmp)
                        goto fail_nomem;
                *tmp = *mpnt;
@@ -252,7 +252,7 @@ static inline int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
                anon_vma_link(tmp);
                file = tmp->vm_file;
                if (file) {
-                       struct inode *inode = file->f_dentry->d_inode;
+                       struct inode *inode = file->f_path.dentry->d_inode;
                        get_file(file);
                        if (tmp->vm_flags & VM_DENYWRITE)
                                atomic_dec(&inode->i_writecount);
@@ -319,7 +319,7 @@ static inline void mm_free_pgd(struct mm_struct * mm)
 
  __cacheline_aligned_in_smp DEFINE_SPINLOCK(mmlist_lock);
 
-#define allocate_mm()  (kmem_cache_alloc(mm_cachep, SLAB_KERNEL))
+#define allocate_mm()  (kmem_cache_alloc(mm_cachep, GFP_KERNEL))
 #define free_mm(mm)    (kmem_cache_free(mm_cachep, (mm)))
 
 #include <linux/init_task.h>
@@ -448,7 +448,16 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
                tsk->vfork_done = NULL;
                complete(vfork_done);
        }
-       if (tsk->clear_child_tid && atomic_read(&mm->mm_users) > 1) {
+
+       /*
+        * If we're exiting normally, clear a user-space tid field if
+        * requested.  We leave this alone when dying by signal, to leave
+        * the value intact in a core dump, and to save the unnecessary
+        * trouble otherwise.  Userland only wants this done for a sys_exit.
+        */
+       if (tsk->clear_child_tid
+           && !(tsk->flags & PF_SIGNALED)
+           && atomic_read(&mm->mm_users) > 1) {
                u32 __user * tidptr = tsk->clear_child_tid;
                tsk->clear_child_tid = NULL;
 
@@ -479,6 +488,10 @@ static struct mm_struct *dup_mm(struct task_struct *tsk)
 
        memcpy(mm, oldmm, sizeof(*mm));
 
+       /* Initializing for Swap token stuff */
+       mm->token_priority = 0;
+       mm->last_interval = 0;
+
        if (!mm_init(mm))
                goto fail_nomem;
 
@@ -542,6 +555,10 @@ static int copy_mm(unsigned long clone_flags, struct task_struct * tsk)
                goto fail_nomem;
 
 good_mm:
+       /* Initializing for Swap token stuff */
+       mm->token_priority = 0;
+       mm->last_interval = 0;
+
        tsk->mm = mm;
        tsk->active_mm = mm;
        return 0;
@@ -613,7 +630,7 @@ static struct files_struct *alloc_files(void)
        struct files_struct *newf;
        struct fdtable *fdt;
 
-       newf = kmem_cache_alloc(files_cachep, SLAB_KERNEL);
+       newf = kmem_cache_alloc(files_cachep, GFP_KERNEL);
        if (!newf)
                goto out;
 
@@ -830,7 +847,6 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts
        if (clone_flags & CLONE_THREAD) {
                atomic_inc(&current->signal->count);
                atomic_inc(&current->signal->live);
-               taskstats_tgid_alloc(current);
                return 0;
        }
        sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL);
@@ -1243,9 +1259,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
                if (thread_group_leader(p)) {
                        p->signal->tty = current->signal->tty;
                        p->signal->pgrp = process_group(current);
-                       p->signal->session = current->signal->session;
+                       set_signal_session(p->signal, process_session(current));
                        attach_pid(p, PIDTYPE_PGID, process_group(p));
-                       attach_pid(p, PIDTYPE_SID, p->signal->session);
+                       attach_pid(p, PIDTYPE_SID, process_session(p));
 
                        list_add_tail_rcu(&p->tasks, &init_task.tasks);
                        __get_cpu_var(process_counts)++;
@@ -1303,7 +1319,7 @@ fork_out:
        return ERR_PTR(retval);
 }
 
-struct pt_regs * __devinit __attribute__((weak)) idle_regs(struct pt_regs *regs)
+noinline struct pt_regs * __devinit __attribute__((weak)) idle_regs(struct pt_regs *regs)
 {
        memset(regs, 0, sizeof(struct pt_regs));
        return regs;
@@ -1413,7 +1429,7 @@ long do_fork(unsigned long clone_flags,
 #define ARCH_MIN_MMSTRUCT_ALIGN 0
 #endif
 
-static void sighand_ctor(void *data, kmem_cache_t *cachep, unsigned long flags)
+static void sighand_ctor(void *data, struct kmem_cache *cachep, unsigned long flags)
 {
        struct sighand_struct *sighand = data;
 
@@ -1509,17 +1525,18 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
 }
 
 /*
- * Unshare the namespace structure if it is being shared
+ * Unshare the mnt_namespace structure if it is being shared
  */
-static int unshare_namespace(unsigned long unshare_flags, struct namespace **new_nsp, struct fs_struct *new_fs)
+static int unshare_mnt_namespace(unsigned long unshare_flags,
+               struct mnt_namespace **new_nsp, struct fs_struct *new_fs)
 {
-       struct namespace *ns = current->nsproxy->namespace;
+       struct mnt_namespace *ns = current->nsproxy->mnt_ns;
 
        if ((unshare_flags & CLONE_NEWNS) && ns) {
                if (!capable(CAP_SYS_ADMIN))
                        return -EPERM;
 
-               *new_nsp = dup_namespace(current, new_fs ? new_fs : current->fs);
+               *new_nsp = dup_mnt_ns(current, new_fs ? new_fs : current->fs);
                if (!*new_nsp)
                        return -ENOMEM;
        }
@@ -1528,15 +1545,13 @@ static int unshare_namespace(unsigned long unshare_flags, struct namespace **new
 }
 
 /*
- * Unsharing of sighand for tasks created with CLONE_SIGHAND is not
- * supported yet
+ * Unsharing of sighand is not supported yet
  */
 static int unshare_sighand(unsigned long unshare_flags, struct sighand_struct **new_sighp)
 {
        struct sighand_struct *sigh = current->sighand;
 
-       if ((unshare_flags & CLONE_SIGHAND) &&
-           (sigh && atomic_read(&sigh->count) > 1))
+       if ((unshare_flags & CLONE_SIGHAND) && atomic_read(&sigh->count) > 1)
                return -EINVAL;
        else
                return 0;
@@ -1609,8 +1624,8 @@ asmlinkage long sys_unshare(unsigned long unshare_flags)
 {
        int err = 0;
        struct fs_struct *fs, *new_fs = NULL;
-       struct namespace *ns, *new_ns = NULL;
-       struct sighand_struct *sigh, *new_sigh = NULL;
+       struct mnt_namespace *ns, *new_ns = NULL;
+       struct sighand_struct *new_sigh = NULL;
        struct mm_struct *mm, *new_mm = NULL, *active_mm = NULL;
        struct files_struct *fd, *new_fd = NULL;
        struct sem_undo_list *new_ulist = NULL;
@@ -1631,7 +1646,7 @@ asmlinkage long sys_unshare(unsigned long unshare_flags)
                goto bad_unshare_out;
        if ((err = unshare_fs(unshare_flags, &new_fs)))
                goto bad_unshare_cleanup_thread;
-       if ((err = unshare_namespace(unshare_flags, &new_ns, new_fs)))
+       if ((err = unshare_mnt_namespace(unshare_flags, &new_ns, new_fs)))
                goto bad_unshare_cleanup_fs;
        if ((err = unshare_sighand(unshare_flags, &new_sigh)))
                goto bad_unshare_cleanup_ns;
@@ -1655,7 +1670,7 @@ asmlinkage long sys_unshare(unsigned long unshare_flags)
                }
        }
 
-       if (new_fs || new_ns || new_sigh || new_mm || new_fd || new_ulist ||
+       if (new_fs || new_ns || new_mm || new_fd || new_ulist ||
                                new_uts || new_ipc) {
 
                task_lock(current);
@@ -1672,17 +1687,11 @@ asmlinkage long sys_unshare(unsigned long unshare_flags)
                }
 
                if (new_ns) {
-                       ns = current->nsproxy->namespace;
-                       current->nsproxy->namespace = new_ns;
+                       ns = current->nsproxy->mnt_ns;
+                       current->nsproxy->mnt_ns = new_ns;
                        new_ns = ns;
                }
 
-               if (new_sigh) {
-                       sigh = current->sighand;
-                       rcu_assign_pointer(current->sighand, new_sigh);
-                       new_sigh = sigh;
-               }
-
                if (new_mm) {
                        mm = current->mm;
                        active_mm = current->active_mm;
@@ -1740,7 +1749,7 @@ bad_unshare_cleanup_sigh:
 
 bad_unshare_cleanup_ns:
        if (new_ns)
-               put_namespace(new_ns);
+               put_mnt_ns(new_ns);
 
 bad_unshare_cleanup_fs:
        if (new_fs)
index 93ef30ba209fc865c7507459f0995849d5d6e336..5a737de857d37e5d84bd7da9044c92ce22170a94 100644 (file)
@@ -166,7 +166,7 @@ static inline int match_futex(union futex_key *key1, union futex_key *key2)
 /*
  * Get parameters which are the keys for a futex.
  *
- * For shared mappings, it's (page->index, vma->vm_file->f_dentry->d_inode,
+ * For shared mappings, it's (page->index, vma->vm_file->f_path.dentry->d_inode,
  * offset_within_page).  For private mappings, it's (uaddr, current->mm).
  * We can usually work out the index without swapping in the page.
  *
@@ -223,7 +223,7 @@ static int get_futex_key(u32 __user *uaddr, union futex_key *key)
        /*
         * Linear file mappings are also simple.
         */
-       key->shared.inode = vma->vm_file->f_dentry->d_inode;
+       key->shared.inode = vma->vm_file->f_path.dentry->d_inode;
        key->both.offset++; /* Bit 0 of offset indicates inode-based key. */
        if (likely(!(vma->vm_flags & VM_NONLINEAR))) {
                key->shared.pgoff = (((address - vma->vm_start) >> PAGE_SHIFT)
@@ -282,9 +282,9 @@ static inline int get_futex_value_locked(u32 *dest, u32 __user *from)
 {
        int ret;
 
-       inc_preempt_count();
+       pagefault_disable();
        ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
-       dec_preempt_count();
+       pagefault_enable();
 
        return ret ? -EFAULT : 0;
 }
@@ -324,12 +324,11 @@ static int refill_pi_state_cache(void)
        if (likely(current->pi_state_cache))
                return 0;
 
-       pi_state = kmalloc(sizeof(*pi_state), GFP_KERNEL);
+       pi_state = kzalloc(sizeof(*pi_state), GFP_KERNEL);
 
        if (!pi_state)
                return -ENOMEM;
 
-       memset(pi_state, 0, sizeof(*pi_state));
        INIT_LIST_HEAD(&pi_state->list);
        /* pi_mutex gets initialized later */
        pi_state->owner = NULL;
@@ -553,7 +552,7 @@ static void wake_futex(struct futex_q *q)
         * at the end of wake_up_all() does not prevent this store from
         * moving.
         */
-       wmb();
+       smp_wmb();
        q->lock_ptr = NULL;
 }
 
@@ -585,9 +584,9 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this)
        if (!(uval & FUTEX_OWNER_DIED)) {
                newval = FUTEX_WAITERS | new_owner->pid;
 
-               inc_preempt_count();
+               pagefault_disable();
                curval = futex_atomic_cmpxchg_inatomic(uaddr, uval, newval);
-               dec_preempt_count();
+               pagefault_enable();
                if (curval == -EFAULT)
                        return -EFAULT;
                if (curval != uval)
@@ -618,9 +617,9 @@ static int unlock_futex_pi(u32 __user *uaddr, u32 uval)
         * There is no waiter, so we unlock the futex. The owner died
         * bit has not to be preserved here. We are the owner:
         */
-       inc_preempt_count();
+       pagefault_disable();
        oldval = futex_atomic_cmpxchg_inatomic(uaddr, uval, 0);
-       dec_preempt_count();
+       pagefault_enable();
 
        if (oldval == -EFAULT)
                return oldval;
@@ -1158,9 +1157,9 @@ static int futex_lock_pi(u32 __user *uaddr, int detect, unsigned long sec,
         */
        newval = current->pid;
 
-       inc_preempt_count();
+       pagefault_disable();
        curval = futex_atomic_cmpxchg_inatomic(uaddr, 0, newval);
-       dec_preempt_count();
+       pagefault_enable();
 
        if (unlikely(curval == -EFAULT))
                goto uaddr_faulted;
@@ -1183,9 +1182,9 @@ static int futex_lock_pi(u32 __user *uaddr, int detect, unsigned long sec,
        uval = curval;
        newval = uval | FUTEX_WAITERS;
 
-       inc_preempt_count();
+       pagefault_disable();
        curval = futex_atomic_cmpxchg_inatomic(uaddr, uval, newval);
-       dec_preempt_count();
+       pagefault_enable();
 
        if (unlikely(curval == -EFAULT))
                goto uaddr_faulted;
@@ -1215,10 +1214,10 @@ static int futex_lock_pi(u32 __user *uaddr, int detect, unsigned long sec,
                        newval = current->pid |
                                FUTEX_OWNER_DIED | FUTEX_WAITERS;
 
-                       inc_preempt_count();
+                       pagefault_disable();
                        curval = futex_atomic_cmpxchg_inatomic(uaddr,
                                                               uval, newval);
-                       dec_preempt_count();
+                       pagefault_enable();
 
                        if (unlikely(curval == -EFAULT))
                                goto uaddr_faulted;
@@ -1390,9 +1389,9 @@ retry_locked:
         * anyone else up:
         */
        if (!(uval & FUTEX_OWNER_DIED)) {
-               inc_preempt_count();
+               pagefault_disable();
                uval = futex_atomic_cmpxchg_inatomic(uaddr, current->pid, 0);
-               dec_preempt_count();
+               pagefault_enable();
        }
 
        if (unlikely(uval == -EFAULT))
@@ -1493,7 +1492,7 @@ static unsigned int futex_poll(struct file *filp,
        return ret;
 }
 
-static struct file_operations futex_fops = {
+static const struct file_operations futex_fops = {
        .release        = futex_close,
        .poll           = futex_poll,
 };
@@ -1529,9 +1528,9 @@ static int futex_fd(u32 __user *uaddr, int signal)
                goto out;
        }
        filp->f_op = &futex_fops;
-       filp->f_vfsmnt = mntget(futex_mnt);
-       filp->f_dentry = dget(futex_mnt->mnt_root);
-       filp->f_mapping = filp->f_dentry->d_inode->i_mapping;
+       filp->f_path.mnt = mntget(futex_mnt);
+       filp->f_path.dentry = dget(futex_mnt->mnt_root);
+       filp->f_mapping = filp->f_path.dentry->d_inode->i_mapping;
 
        if (signal) {
                err = __f_setown(filp, task_pid(current), PIDTYPE_PID, 1);
@@ -1858,10 +1857,16 @@ static struct file_system_type futex_fs_type = {
 
 static int __init init(void)
 {
-       unsigned int i;
+       int i = register_filesystem(&futex_fs_type);
+
+       if (i)
+               return i;
 
-       register_filesystem(&futex_fs_type);
        futex_mnt = kern_mount(&futex_fs_type);
+       if (IS_ERR(futex_mnt)) {
+               unregister_filesystem(&futex_fs_type);
+               return PTR_ERR(futex_mnt);
+       }
 
        for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
                INIT_LIST_HEAD(&futex_queues[i].chain);
index a681912bc89a10388e6a4eeecd44dfe05416aff9..aff1f0fabb0df0b462c0d83ea4eb35d0ecc24fe0 100644 (file)
@@ -54,7 +54,7 @@ struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned = {
                .chip = &no_irq_chip,
                .handle_irq = handle_bad_irq,
                .depth = 1,
-               .lock = SPIN_LOCK_UNLOCKED,
+               .lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock),
 #ifdef CONFIG_SMP
                .affinity = CPU_MASK_ALL
 #endif
index 9a352667007ce52fe610c7c72cc190772cb126dd..61f5c717a8f579cbe5dd3c9b3991b7ef2fb5cead 100644 (file)
@@ -54,7 +54,8 @@ static int irq_affinity_write_proc(struct file *file, const char __user *buffer,
        unsigned int irq = (int)(long)data, full_count = count, err;
        cpumask_t new_value, tmp;
 
-       if (!irq_desc[irq].chip->set_affinity || no_irq_affinity)
+       if (!irq_desc[irq].chip->set_affinity || no_irq_affinity ||
+                               CHECK_IRQ_PER_CPU(irq_desc[irq].status))
                return -EIO;
 
        err = cpumask_parse_user(buffer, count, new_value);
index eeac3e313b2bfa41f26a4ccd9235232593fb947c..6f294ff4f9eec46f448dd9eb30fcb0b2ed47e6dc 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/proc_fs.h>
 #include <linux/sched.h>       /* for cond_resched */
 #include <linux/mm.h>
+#include <linux/ctype.h>
 
 #include <asm/sections.h>
 
 #endif
 
 /* These will be re-linked against their real values during the second link stage */
-extern unsigned long kallsyms_addresses[] __attribute__((weak));
-extern unsigned long kallsyms_num_syms __attribute__((weak,section("data")));
-extern u8 kallsyms_names[] __attribute__((weak));
+extern const unsigned long kallsyms_addresses[] __attribute__((weak));
+extern const unsigned long kallsyms_num_syms __attribute__((weak));
+extern const u8 kallsyms_names[] __attribute__((weak));
 
-extern u8 kallsyms_token_table[] __attribute__((weak));
-extern u16 kallsyms_token_index[] __attribute__((weak));
+extern const u8 kallsyms_token_table[] __attribute__((weak));
+extern const u16 kallsyms_token_index[] __attribute__((weak));
 
-extern unsigned long kallsyms_markers[] __attribute__((weak));
+extern const unsigned long kallsyms_markers[] __attribute__((weak));
 
 static inline int is_kernel_inittext(unsigned long addr)
 {
@@ -83,7 +84,7 @@ static int is_ksym_addr(unsigned long addr)
 static unsigned int kallsyms_expand_symbol(unsigned int off, char *result)
 {
        int len, skipped_first = 0;
-       u8 *tptr, *data;
+       const u8 *tptr, *data;
 
        /* get the compressed symbol length from the first symbol byte */
        data = &kallsyms_names[off];
@@ -131,7 +132,7 @@ static char kallsyms_get_symbol_type(unsigned int off)
  * kallsyms array */
 static unsigned int get_symbol_offset(unsigned long pos)
 {
-       u8 *name;
+       const u8 *name;
        int i;
 
        /* use the closest marker we have. We have markers every 256 positions,
@@ -301,13 +302,6 @@ struct kallsym_iter
        char name[KSYM_NAME_LEN+1];
 };
 
-/* Only label it "global" if it is exported. */
-static void upcase_if_global(struct kallsym_iter *iter)
-{
-       if (is_exported(iter->name, iter->owner))
-               iter->type += 'A' - 'a';
-}
-
 static int get_ksymbol_mod(struct kallsym_iter *iter)
 {
        iter->owner = module_get_kallsym(iter->pos - kallsyms_num_syms,
@@ -316,7 +310,10 @@ static int get_ksymbol_mod(struct kallsym_iter *iter)
        if (iter->owner == NULL)
                return 0;
 
-       upcase_if_global(iter);
+       /* Label it "global" if it is exported, "local" if not exported. */
+       iter->type = is_exported(iter->name, iter->owner)
+               ? toupper(iter->type) : tolower(iter->type);
+
        return 1;
 }
 
@@ -401,7 +398,7 @@ static int s_show(struct seq_file *m, void *p)
        return 0;
 }
 
-static struct seq_operations kallsyms_op = {
+static const struct seq_operations kallsyms_op = {
        .start = s_start,
        .next = s_next,
        .stop = s_stop,
@@ -436,7 +433,7 @@ static int kallsyms_release(struct inode *inode, struct file *file)
        return seq_release(inode, file);
 }
 
-static struct file_operations kallsyms_operations = {
+static const struct file_operations kallsyms_operations = {
        .open = kallsyms_open,
        .read = seq_read,
        .llseek = seq_lseek,
index fcdd5d2bc3f4b47b57854c41a1cec882939c02ed..2a59c8a01ae0010da5ef5b80b39fad2ec1da14ae 100644 (file)
@@ -20,6 +20,8 @@
 #include <linux/syscalls.h>
 #include <linux/ioport.h>
 #include <linux/hardirq.h>
+#include <linux/elf.h>
+#include <linux/elfcore.h>
 
 #include <asm/page.h>
 #include <asm/uaccess.h>
@@ -108,11 +110,10 @@ static int do_kimage_alloc(struct kimage **rimage, unsigned long entry,
 
        /* Allocate a controlling structure */
        result = -ENOMEM;
-       image = kmalloc(sizeof(*image), GFP_KERNEL);
+       image = kzalloc(sizeof(*image), GFP_KERNEL);
        if (!image)
                goto out;
 
-       memset(image, 0, sizeof(*image));
        image->head = 0;
        image->entry = &image->head;
        image->last_entry = &image->head;
@@ -851,6 +852,7 @@ static int kimage_load_crash_segment(struct kimage *image,
                        memset(ptr + uchunk, 0, mchunk - uchunk);
                }
                result = copy_from_user(ptr, buf, uchunk);
+               kexec_flush_icache_page(page);
                kunmap(page);
                if (result) {
                        result = (result < 0) ? result : -EIO;
@@ -1067,6 +1069,60 @@ void crash_kexec(struct pt_regs *regs)
        }
 }
 
+static u32 *append_elf_note(u32 *buf, char *name, unsigned type, void *data,
+                           size_t data_len)
+{
+       struct elf_note note;
+
+       note.n_namesz = strlen(name) + 1;
+       note.n_descsz = data_len;
+       note.n_type   = type;
+       memcpy(buf, &note, sizeof(note));
+       buf += (sizeof(note) + 3)/4;
+       memcpy(buf, name, note.n_namesz);
+       buf += (note.n_namesz + 3)/4;
+       memcpy(buf, data, note.n_descsz);
+       buf += (note.n_descsz + 3)/4;
+
+       return buf;
+}
+
+static void final_note(u32 *buf)
+{
+       struct elf_note note;
+
+       note.n_namesz = 0;
+       note.n_descsz = 0;
+       note.n_type   = 0;
+       memcpy(buf, &note, sizeof(note));
+}
+
+void crash_save_cpu(struct pt_regs *regs, int cpu)
+{
+       struct elf_prstatus prstatus;
+       u32 *buf;
+
+       if ((cpu < 0) || (cpu >= NR_CPUS))
+               return;
+
+       /* Using ELF notes here is opportunistic.
+        * I need a well defined structure format
+        * for the data I pass, and I need tags
+        * on the data to indicate what information I have
+        * squirrelled away.  ELF notes happen to provide
+        * all of that, so there is no need to invent something new.
+        */
+       buf = (u32*)per_cpu_ptr(crash_notes, cpu);
+       if (!buf)
+               return;
+       memset(&prstatus, 0, sizeof(prstatus));
+       prstatus.pr_pid = current->pid;
+       elf_core_copy_regs(&prstatus.pr_reg, regs);
+       buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
+                               sizeof(prstatus));
+       final_note(buf);
+}
+
 static int __init crash_notes_memory_init(void)
 {
        /* Allocate memory for saving cpu registers. */
index 8d2bea09a4ec9b44f86f5574defa6af2a043917d..3a7379aa31ca6b0a92bec377a23e5c9debed72db 100644 (file)
@@ -25,7 +25,7 @@
 #include <linux/kmod.h>
 #include <linux/smp_lock.h>
 #include <linux/slab.h>
-#include <linux/namespace.h>
+#include <linux/mnt_namespace.h>
 #include <linux/completion.h>
 #include <linux/file.h>
 #include <linux/workqueue.h>
index 610c837ad9e0aa8923f48541aaa7ea903c6b2fd2..17ec4afb0994e48adc1c7a9cfde971f04b08d512 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/module.h>
 #include <linux/moduleloader.h>
 #include <linux/kallsyms.h>
+#include <linux/freezer.h>
 #include <asm-generic/sections.h>
 #include <asm/cacheflush.h>
 #include <asm/errno.h>
@@ -83,9 +84,36 @@ struct kprobe_insn_page {
        kprobe_opcode_t *insns;         /* Page of instruction slots */
        char slot_used[INSNS_PER_PAGE];
        int nused;
+       int ngarbage;
 };
 
 static struct hlist_head kprobe_insn_pages;
+static int kprobe_garbage_slots;
+static int collect_garbage_slots(void);
+
+static int __kprobes check_safety(void)
+{
+       int ret = 0;
+#if defined(CONFIG_PREEMPT) && defined(CONFIG_PM)
+       ret = freeze_processes();
+       if (ret == 0) {
+               struct task_struct *p, *q;
+               do_each_thread(p, q) {
+                       if (p != current && p->state == TASK_RUNNING &&
+                           p->pid != 0) {
+                               printk("Check failed: %s is running\n",p->comm);
+                               ret = -1;
+                               goto loop_end;
+                       }
+               } while_each_thread(p, q);
+       }
+loop_end:
+       thaw_processes();
+#else
+       synchronize_sched();
+#endif
+       return ret;
+}
 
 /**
  * get_insn_slot() - Find a slot on an executable page for an instruction.
@@ -96,6 +124,7 @@ kprobe_opcode_t __kprobes *get_insn_slot(void)
        struct kprobe_insn_page *kip;
        struct hlist_node *pos;
 
+      retry:
        hlist_for_each(pos, &kprobe_insn_pages) {
                kip = hlist_entry(pos, struct kprobe_insn_page, hlist);
                if (kip->nused < INSNS_PER_PAGE) {
@@ -112,7 +141,11 @@ kprobe_opcode_t __kprobes *get_insn_slot(void)
                }
        }
 
-       /* All out of space.  Need to allocate a new page. Use slot 0.*/
+       /* If there are any garbage slots, collect it and try again. */
+       if (kprobe_garbage_slots && collect_garbage_slots() == 0) {
+               goto retry;
+       }
+       /* All out of space.  Need to allocate a new page. Use slot 0. */
        kip = kmalloc(sizeof(struct kprobe_insn_page), GFP_KERNEL);
        if (!kip) {
                return NULL;
@@ -133,10 +166,62 @@ kprobe_opcode_t __kprobes *get_insn_slot(void)
        memset(kip->slot_used, 0, INSNS_PER_PAGE);
        kip->slot_used[0] = 1;
        kip->nused = 1;
+       kip->ngarbage = 0;
        return kip->insns;
 }
 
-void __kprobes free_insn_slot(kprobe_opcode_t *slot)
+/* Return 1 if all garbages are collected, otherwise 0. */
+static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
+{
+       kip->slot_used[idx] = 0;
+       kip->nused--;
+       if (kip->nused == 0) {
+               /*
+                * Page is no longer in use.  Free it unless
+                * it's the last one.  We keep the last one
+                * so as not to have to set it up again the
+                * next time somebody inserts a probe.
+                */
+               hlist_del(&kip->hlist);
+               if (hlist_empty(&kprobe_insn_pages)) {
+                       INIT_HLIST_NODE(&kip->hlist);
+                       hlist_add_head(&kip->hlist,
+                                      &kprobe_insn_pages);
+               } else {
+                       module_free(NULL, kip->insns);
+                       kfree(kip);
+               }
+               return 1;
+       }
+       return 0;
+}
+
+static int __kprobes collect_garbage_slots(void)
+{
+       struct kprobe_insn_page *kip;
+       struct hlist_node *pos, *next;
+
+       /* Ensure no-one is preepmted on the garbages */
+       if (check_safety() != 0)
+               return -EAGAIN;
+
+       hlist_for_each_safe(pos, next, &kprobe_insn_pages) {
+               int i;
+               kip = hlist_entry(pos, struct kprobe_insn_page, hlist);
+               if (kip->ngarbage == 0)
+                       continue;
+               kip->ngarbage = 0;      /* we will collect all garbages */
+               for (i = 0; i < INSNS_PER_PAGE; i++) {
+                       if (kip->slot_used[i] == -1 &&
+                           collect_one_slot(kip, i))
+                               break;
+               }
+       }
+       kprobe_garbage_slots = 0;
+       return 0;
+}
+
+void __kprobes free_insn_slot(kprobe_opcode_t * slot, int dirty)
 {
        struct kprobe_insn_page *kip;
        struct hlist_node *pos;
@@ -146,28 +231,18 @@ void __kprobes free_insn_slot(kprobe_opcode_t *slot)
                if (kip->insns <= slot &&
                    slot < kip->insns + (INSNS_PER_PAGE * MAX_INSN_SIZE)) {
                        int i = (slot - kip->insns) / MAX_INSN_SIZE;
-                       kip->slot_used[i] = 0;
-                       kip->nused--;
-                       if (kip->nused == 0) {
-                               /*
-                                * Page is no longer in use.  Free it unless
-                                * it's the last one.  We keep the last one
-                                * so as not to have to set it up again the
-                                * next time somebody inserts a probe.
-                                */
-                               hlist_del(&kip->hlist);
-                               if (hlist_empty(&kprobe_insn_pages)) {
-                                       INIT_HLIST_NODE(&kip->hlist);
-                                       hlist_add_head(&kip->hlist,
-                                               &kprobe_insn_pages);
-                               } else {
-                                       module_free(NULL, kip->insns);
-                                       kfree(kip);
-                               }
+                       if (dirty) {
+                               kip->slot_used[i] = -1;
+                               kip->ngarbage++;
+                       } else {
+                               collect_one_slot(kip, i);
                        }
-                       return;
+                       break;
                }
        }
+       if (dirty && (++kprobe_garbage_slots > INSNS_PER_PAGE)) {
+               collect_garbage_slots();
+       }
 }
 #endif
 
index c9fefdb1a7db45df9658dd32d963e7f28bbdfdf4..b02032476dc2e88967940060a84b5bc5742f1a5e 100644 (file)
@@ -140,13 +140,6 @@ void lockdep_on(void)
 
 EXPORT_SYMBOL(lockdep_on);
 
-int lockdep_internal(void)
-{
-       return current->lockdep_recursion != 0;
-}
-
-EXPORT_SYMBOL(lockdep_internal);
-
 /*
  * Debugging switches:
  */
@@ -228,17 +221,15 @@ static int save_trace(struct stack_trace *trace)
        trace->skip = 3;
        trace->all_contexts = 0;
 
-       /* Make sure to not recurse in case the the unwinder needs to tak
-e         locks. */
-       lockdep_off();
        save_stack_trace(trace, NULL);
-       lockdep_on();
 
        trace->max_entries = trace->nr_entries;
 
        nr_stack_trace_entries += trace->nr_entries;
-       if (DEBUG_LOCKS_WARN_ON(nr_stack_trace_entries > MAX_STACK_TRACE_ENTRIES))
+       if (DEBUG_LOCKS_WARN_ON(nr_stack_trace_entries > MAX_STACK_TRACE_ENTRIES)) {
+               __raw_spin_unlock(&hash_lock);
                return 0;
+       }
 
        if (nr_stack_trace_entries == MAX_STACK_TRACE_ENTRIES) {
                __raw_spin_unlock(&hash_lock);
@@ -357,7 +348,7 @@ get_usage_chars(struct lock_class *class, char *c1, char *c2, char *c3, char *c4
 
 static void print_lock_name(struct lock_class *class)
 {
-       char str[128], c1, c2, c3, c4;
+       char str[KSYM_NAME_LEN + 1], c1, c2, c3, c4;
        const char *name;
 
        get_usage_chars(class, &c1, &c2, &c3, &c4);
@@ -379,7 +370,7 @@ static void print_lock_name(struct lock_class *class)
 static void print_lockdep_cache(struct lockdep_map *lock)
 {
        const char *name;
-       char str[128];
+       char str[KSYM_NAME_LEN + 1];
 
        name = lock->name;
        if (!name)
@@ -449,7 +440,9 @@ static void print_lock_dependencies(struct lock_class *class, int depth)
        print_lock_class_header(class, depth);
 
        list_for_each_entry(entry, &class->locks_after, entry) {
-               DEBUG_LOCKS_WARN_ON(!entry->class);
+               if (DEBUG_LOCKS_WARN_ON(!entry->class))
+                       return;
+
                print_lock_dependencies(entry->class, depth + 1);
 
                printk("%*s ... acquired at:\n",depth,"");
@@ -474,7 +467,8 @@ static int add_lock_to_list(struct lock_class *class, struct lock_class *this,
                return 0;
 
        entry->class = this;
-       save_trace(&entry->trace);
+       if (!save_trace(&entry->trace))
+               return 0;
 
        /*
         * Since we never remove from the dependency list, the list can
@@ -562,8 +556,12 @@ static noinline int print_circular_bug_tail(void)
        if (debug_locks_silent)
                return 0;
 
+       /* hash_lock unlocked by the header */
+       __raw_spin_lock(&hash_lock);
        this.class = check_source->class;
-       save_trace(&this.trace);
+       if (!save_trace(&this.trace))
+               return 0;
+       __raw_spin_unlock(&hash_lock);
        print_circular_bug_entry(&this, 0);
 
        printk("\nother info that might help us debug this:\n\n");
@@ -966,14 +964,11 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev,
                               &prev->class->locks_after, next->acquire_ip);
        if (!ret)
                return 0;
-       /*
-        * Return value of 2 signals 'dependency already added',
-        * in that case we dont have to add the backlink either.
-        */
-       if (ret == 2)
-               return 2;
+
        ret = add_lock_to_list(next->class, prev->class,
                               &next->class->locks_before, next->acquire_ip);
+       if (!ret)
+               return 0;
 
        /*
         * Debugging printouts:
@@ -1025,7 +1020,8 @@ check_prevs_add(struct task_struct *curr, struct held_lock *next)
                 * added:
                 */
                if (hlock->read != 2) {
-                       check_prev_add(curr, hlock, next);
+                       if (!check_prev_add(curr, hlock, next))
+                               return 0;
                        /*
                         * Stop after the first non-trylock entry,
                         * as non-trylock entries have added their
@@ -1182,6 +1178,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
        struct lockdep_subclass_key *key;
        struct list_head *hash_head;
        struct lock_class *class;
+       unsigned long flags;
 
        class = look_up_lock_class(lock, subclass);
        if (likely(class))
@@ -1203,6 +1200,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
        key = lock->key->subkeys + subclass;
        hash_head = classhashentry(key);
 
+       raw_local_irq_save(flags);
        __raw_spin_lock(&hash_lock);
        /*
         * We have to do the hash-walk again, to avoid races
@@ -1217,6 +1215,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
         */
        if (nr_lock_classes >= MAX_LOCKDEP_KEYS) {
                __raw_spin_unlock(&hash_lock);
+               raw_local_irq_restore(flags);
                debug_locks_off();
                printk("BUG: MAX_LOCKDEP_KEYS too low!\n");
                printk("turning off the locking correctness validator.\n");
@@ -1239,15 +1238,18 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
 
        if (verbose(class)) {
                __raw_spin_unlock(&hash_lock);
+               raw_local_irq_restore(flags);
                printk("\nnew class %p: %s", class->key, class->name);
                if (class->name_version > 1)
                        printk("#%d", class->name_version);
                printk("\n");
                dump_stack();
+               raw_local_irq_save(flags);
                __raw_spin_lock(&hash_lock);
        }
 out_unlock_set:
        __raw_spin_unlock(&hash_lock);
+       raw_local_irq_restore(flags);
 
        if (!subclass || force)
                lock->class_cache = class;
@@ -1728,6 +1730,7 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
                debug_atomic_dec(&nr_unused_locks);
                break;
        default:
+               __raw_spin_unlock(&hash_lock);
                debug_locks_off();
                WARN_ON(1);
                return 0;
@@ -2645,6 +2648,7 @@ void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
        }
        local_irq_restore(flags);
 }
+EXPORT_SYMBOL_GPL(debug_check_no_locks_freed);
 
 static void print_held_locks_bug(struct task_struct *curr)
 {
index eab043c83bb2d1859e2e1c295737f8ac9386bcca..8ce09bc4613dc1ea72566bb0a2a7822ac802930f 100644 (file)
@@ -20,7 +20,7 @@
 #define MAX_LOCKDEP_KEYS_BITS  11
 #define MAX_LOCKDEP_KEYS       (1UL << MAX_LOCKDEP_KEYS_BITS)
 
-#define MAX_LOCKDEP_CHAINS_BITS        13
+#define MAX_LOCKDEP_CHAINS_BITS        14
 #define MAX_LOCKDEP_CHAINS     (1UL << MAX_LOCKDEP_CHAINS_BITS)
 
 /*
index f6e72eaab3faf08b18c65092ef1906ed696a1dd7..b554b40a4aa6ca1872f7225a47bc2829300e24b5 100644 (file)
@@ -113,7 +113,7 @@ static int l_show(struct seq_file *m, void *v)
        return 0;
 }
 
-static struct seq_operations lockdep_ops = {
+static const struct seq_operations lockdep_ops = {
        .start  = l_start,
        .next   = l_next,
        .stop   = l_stop,
@@ -135,7 +135,7 @@ static int lockdep_open(struct inode *inode, struct file *file)
        return res;
 }
 
-static struct file_operations proc_lockdep_operations = {
+static const struct file_operations proc_lockdep_operations = {
        .open           = lockdep_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
@@ -319,7 +319,7 @@ static int lockdep_stats_open(struct inode *inode, struct file *file)
        return single_open(file, lockdep_stats_show, NULL);
 }
 
-static struct file_operations proc_lockdep_stats_operations = {
+static const struct file_operations proc_lockdep_stats_operations = {
        .open           = lockdep_stats_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
index e2d09d604ca08a7f7e73cd20eb972dcb02525115..d9eae45d0145a077d6b32d2b29156f9d3b18bfdd 100644 (file)
@@ -2209,7 +2209,7 @@ static int m_show(struct seq_file *m, void *p)
    Where refcount is a number or -, and deps is a comma-separated list
    of depends or -.
 */
-struct seq_operations modules_op = {
+const struct seq_operations modules_op = {
        .start  = m_start,
        .next   = m_next,
        .stop   = m_stop,
index 18651641a7b5aa6482e0aa73ce03b5133e6ffa91..841539d72c55cdbb674b7a91786847c37ec5acdb 100644 (file)
@@ -77,6 +77,9 @@ void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
 
 void debug_mutex_unlock(struct mutex *lock)
 {
+       if (unlikely(!debug_locks))
+               return;
+
        DEBUG_LOCKS_WARN_ON(lock->owner != current_thread_info());
        DEBUG_LOCKS_WARN_ON(lock->magic != lock);
        DEBUG_LOCKS_WARN_ON(!lock->wait_list.prev && !lock->wait_list.next);
index 8c71cf72a497de63ec5672f3f5f8f728fbb9f9df..e7cbbb82765b4f66348e927fd2911ac4d9078078 100644 (file)
@@ -206,6 +206,15 @@ mutex_lock_nested(struct mutex *lock, unsigned int subclass)
 }
 
 EXPORT_SYMBOL_GPL(mutex_lock_nested);
+
+int __sched
+mutex_lock_interruptible_nested(struct mutex *lock, unsigned int subclass)
+{
+       might_sleep();
+       return __mutex_lock_common(lock, TASK_INTERRUPTIBLE, subclass);
+}
+
+EXPORT_SYMBOL_GPL(mutex_lock_interruptible_nested);
 #endif
 
 /*
index 674aceb7335ad56f7a2a8ba2996d0faa4ed850db..e2ce748e96afaca08cf0e5b2821d4cf6e8cab823 100644 (file)
@@ -17,8 +17,9 @@
 #include <linux/version.h>
 #include <linux/nsproxy.h>
 #include <linux/init_task.h>
-#include <linux/namespace.h>
+#include <linux/mnt_namespace.h>
 #include <linux/utsname.h>
+#include <linux/pid_namespace.h>
 
 struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy);
 
@@ -45,8 +46,10 @@ static inline struct nsproxy *clone_namespaces(struct nsproxy *orig)
        struct nsproxy *ns;
 
        ns = kmemdup(orig, sizeof(struct nsproxy), GFP_KERNEL);
-       if (ns)
+       if (ns) {
                atomic_set(&ns->count, 1);
+               ns->id = -1;
+       }
        return ns;
 }
 
@@ -60,12 +63,14 @@ struct nsproxy *dup_namespaces(struct nsproxy *orig)
        struct nsproxy *ns = clone_namespaces(orig);
 
        if (ns) {
-               if (ns->namespace)
-                       get_namespace(ns->namespace);
+               if (ns->mnt_ns)
+                       get_mnt_ns(ns->mnt_ns);
                if (ns->uts_ns)
                        get_uts_ns(ns->uts_ns);
                if (ns->ipc_ns)
                        get_ipc_ns(ns->ipc_ns);
+               if (ns->pid_ns)
+                       get_pid_ns(ns->pid_ns);
        }
 
        return ns;
@@ -97,7 +102,7 @@ int copy_namespaces(int flags, struct task_struct *tsk)
 
        tsk->nsproxy = new_ns;
 
-       err = copy_namespace(flags, tsk);
+       err = copy_mnt_ns(flags, tsk);
        if (err)
                goto out_ns;
 
@@ -109,16 +114,23 @@ int copy_namespaces(int flags, struct task_struct *tsk)
        if (err)
                goto out_ipc;
 
+       err = copy_pid_ns(flags, tsk);
+       if (err)
+               goto out_pid;
+
 out:
        put_nsproxy(old_ns);
        return err;
 
+out_pid:
+       if (new_ns->ipc_ns)
+               put_ipc_ns(new_ns->ipc_ns);
 out_ipc:
        if (new_ns->uts_ns)
                put_uts_ns(new_ns->uts_ns);
 out_uts:
-       if (new_ns->namespace)
-               put_namespace(new_ns->namespace);
+       if (new_ns->mnt_ns)
+               put_mnt_ns(new_ns->mnt_ns);
 out_ns:
        tsk->nsproxy = old_ns;
        kfree(new_ns);
@@ -127,11 +139,13 @@ out_ns:
 
 void free_nsproxy(struct nsproxy *ns)
 {
-               if (ns->namespace)
-                       put_namespace(ns->namespace);
-               if (ns->uts_ns)
-                       put_uts_ns(ns->uts_ns);
-               if (ns->ipc_ns)
-                       put_ipc_ns(ns->ipc_ns);
-               kfree(ns);
+       if (ns->mnt_ns)
+               put_mnt_ns(ns->mnt_ns);
+       if (ns->uts_ns)
+               put_uts_ns(ns->uts_ns);
+       if (ns->ipc_ns)
+               put_ipc_ns(ns->ipc_ns);
+       if (ns->pid_ns)
+               put_pid_ns(ns->pid_ns);
+       kfree(ns);
 }
index b914392085f9a171f08a3e202dc14145e1563929..2efe9d8d367b9346e1a38bc92027f0a24345029d 100644 (file)
 #include <linux/init.h>
 #include <linux/bootmem.h>
 #include <linux/hash.h>
-#include <linux/pspace.h>
+#include <linux/pid_namespace.h>
 
 #define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift)
 static struct hlist_head *pid_hash;
 static int pidhash_shift;
-static kmem_cache_t *pid_cachep;
+static struct kmem_cache *pid_cachep;
 
 int pid_max = PID_MAX_DEFAULT;
 
@@ -43,9 +43,10 @@ int pid_max_max = PID_MAX_LIMIT;
 #define BITS_PER_PAGE          (PAGE_SIZE*8)
 #define BITS_PER_PAGE_MASK     (BITS_PER_PAGE-1)
 
-static inline int mk_pid(struct pspace *pspace, struct pidmap *map, int off)
+static inline int mk_pid(struct pid_namespace *pid_ns,
+               struct pidmap *map, int off)
 {
-       return (map - pspace->pidmap)*BITS_PER_PAGE + off;
+       return (map - pid_ns->pidmap)*BITS_PER_PAGE + off;
 }
 
 #define find_next_offset(map, off)                                     \
@@ -57,11 +58,15 @@ static inline int mk_pid(struct pspace *pspace, struct pidmap *map, int off)
  * value does not cause lots of bitmaps to be allocated, but
  * the scheme scales to up to 4 million PIDs, runtime.
  */
-struct pspace init_pspace = {
+struct pid_namespace init_pid_ns = {
+       .kref = {
+               .refcount       = ATOMIC_INIT(2),
+       },
        .pidmap = {
                [ 0 ... PIDMAP_ENTRIES-1] = { ATOMIC_INIT(BITS_PER_PAGE), NULL }
        },
-       .last_pid = 0
+       .last_pid = 0,
+       .child_reaper = &init_task
 };
 
 /*
@@ -80,25 +85,25 @@ struct pspace init_pspace = {
 
 static  __cacheline_aligned_in_smp DEFINE_SPINLOCK(pidmap_lock);
 
-static fastcall void free_pidmap(struct pspace *pspace, int pid)
+static fastcall void free_pidmap(struct pid_namespace *pid_ns, int pid)
 {
-       struct pidmap *map = pspace->pidmap + pid / BITS_PER_PAGE;
+       struct pidmap *map = pid_ns->pidmap + pid / BITS_PER_PAGE;
        int offset = pid & BITS_PER_PAGE_MASK;
 
        clear_bit(offset, map->page);
        atomic_inc(&map->nr_free);
 }
 
-static int alloc_pidmap(struct pspace *pspace)
+static int alloc_pidmap(struct pid_namespace *pid_ns)
 {
-       int i, offset, max_scan, pid, last = pspace->last_pid;
+       int i, offset, max_scan, pid, last = pid_ns->last_pid;
        struct pidmap *map;
 
        pid = last + 1;
        if (pid >= pid_max)
                pid = RESERVED_PIDS;
        offset = pid & BITS_PER_PAGE_MASK;
-       map = &pspace->pidmap[pid/BITS_PER_PAGE];
+       map = &pid_ns->pidmap[pid/BITS_PER_PAGE];
        max_scan = (pid_max + BITS_PER_PAGE - 1)/BITS_PER_PAGE - !offset;
        for (i = 0; i <= max_scan; ++i) {
                if (unlikely(!map->page)) {
@@ -120,11 +125,11 @@ static int alloc_pidmap(struct pspace *pspace)
                        do {
                                if (!test_and_set_bit(offset, map->page)) {
                                        atomic_dec(&map->nr_free);
-                                       pspace->last_pid = pid;
+                                       pid_ns->last_pid = pid;
                                        return pid;
                                }
                                offset = find_next_offset(map, offset);
-                               pid = mk_pid(pspace, map, offset);
+                               pid = mk_pid(pid_ns, map, offset);
                        /*
                         * find_next_offset() found a bit, the pid from it
                         * is in-bounds, and if we fell back to the last
@@ -135,34 +140,34 @@ static int alloc_pidmap(struct pspace *pspace)
                                        (i != max_scan || pid < last ||
                                            !((last+1) & BITS_PER_PAGE_MASK)));
                }
-               if (map < &pspace->pidmap[(pid_max-1)/BITS_PER_PAGE]) {
+               if (map < &pid_ns->pidmap[(pid_max-1)/BITS_PER_PAGE]) {
                        ++map;
                        offset = 0;
                } else {
-                       map = &pspace->pidmap[0];
+                       map = &pid_ns->pidmap[0];
                        offset = RESERVED_PIDS;
                        if (unlikely(last == offset))
                                break;
                }
-               pid = mk_pid(pspace, map, offset);
+               pid = mk_pid(pid_ns, map, offset);
        }
        return -1;
 }
 
-static int next_pidmap(struct pspace *pspace, int last)
+static int next_pidmap(struct pid_namespace *pid_ns, int last)
 {
        int offset;
        struct pidmap *map, *end;
 
        offset = (last + 1) & BITS_PER_PAGE_MASK;
-       map = &pspace->pidmap[(last + 1)/BITS_PER_PAGE];
-       end = &pspace->pidmap[PIDMAP_ENTRIES];
+       map = &pid_ns->pidmap[(last + 1)/BITS_PER_PAGE];
+       end = &pid_ns->pidmap[PIDMAP_ENTRIES];
        for (; map < end; map++, offset = 0) {
                if (unlikely(!map->page))
                        continue;
                offset = find_next_bit((map)->page, BITS_PER_PAGE, offset);
                if (offset < BITS_PER_PAGE)
-                       return mk_pid(pspace, map, offset);
+                       return mk_pid(pid_ns, map, offset);
        }
        return -1;
 }
@@ -192,7 +197,7 @@ fastcall void free_pid(struct pid *pid)
        hlist_del_rcu(&pid->pid_chain);
        spin_unlock_irqrestore(&pidmap_lock, flags);
 
-       free_pidmap(&init_pspace, pid->nr);
+       free_pidmap(current->nsproxy->pid_ns, pid->nr);
        call_rcu(&pid->rcu, delayed_put_pid);
 }
 
@@ -206,7 +211,7 @@ struct pid *alloc_pid(void)
        if (!pid)
                goto out;
 
-       nr = alloc_pidmap(&init_pspace);
+       nr = alloc_pidmap(current->nsproxy->pid_ns);
        if (nr < 0)
                goto out_free;
 
@@ -348,13 +353,33 @@ struct pid *find_ge_pid(int nr)
                pid = find_pid(nr);
                if (pid)
                        break;
-               nr = next_pidmap(&init_pspace, nr);
+               nr = next_pidmap(current->nsproxy->pid_ns, nr);
        } while (nr > 0);
 
        return pid;
 }
 EXPORT_SYMBOL_GPL(find_get_pid);
 
+int copy_pid_ns(int flags, struct task_struct *tsk)
+{
+       struct pid_namespace *old_ns = tsk->nsproxy->pid_ns;
+       int err = 0;
+
+       if (!old_ns)
+               return 0;
+
+       get_pid_ns(old_ns);
+       return err;
+}
+
+void free_pid_ns(struct kref *kref)
+{
+       struct pid_namespace *ns;
+
+       ns = container_of(kref, struct pid_namespace, kref);
+       kfree(ns);
+}
+
 /*
  * The pid hash table is scaled according to the amount of memory in the
  * machine.  From a minimum of 16 slots up to 4096 slots at one gigabyte or
@@ -382,10 +407,10 @@ void __init pidhash_init(void)
 
 void __init pidmap_init(void)
 {
-       init_pspace.pidmap[0].page = kzalloc(PAGE_SIZE, GFP_KERNEL);
+       init_pid_ns.pidmap[0].page = kzalloc(PAGE_SIZE, GFP_KERNEL);
        /* Reserve PID 0. We never call free_pidmap(0) */
-       set_bit(0, init_pspace.pidmap[0].page);
-       atomic_dec(&init_pspace.pidmap[0].nr_free);
+       set_bit(0, init_pid_ns.pidmap[0].page);
+       atomic_dec(&init_pid_ns.pidmap[0].nr_free);
 
        pid_cachep = kmem_cache_create("pid", sizeof(struct pid),
                                        __alignof__(struct pid),
index 9cbb5d1be06f7420005bdf32538777deb844af03..5fe87de10ff07ae1afbecc8e076360c4f6005424 100644 (file)
@@ -70,7 +70,7 @@
 /*
  * Lets keep our timers in a slab cache :-)
  */
-static kmem_cache_t *posix_timers_cache;
+static struct kmem_cache *posix_timers_cache;
 static struct idr posix_timers_id;
 static DEFINE_SPINLOCK(idr_lock);
 
index 825068ca347994570680e15f8858d590d244e61c..710ed084e7c5667b96da2362f67025fb8e521d50 100644 (file)
@@ -78,7 +78,7 @@ config PM_SYSFS_DEPRECATED
 
 config SOFTWARE_SUSPEND
        bool "Software Suspend"
-       depends on PM && SWAP && ((X86 && (!SMP || SUSPEND_SMP) && !X86_PAE) || ((FRV || PPC32) && !SMP))
+       depends on PM && SWAP && ((X86 && (!SMP || SUSPEND_SMP)) || ((FRV || PPC32) && !SMP))
        ---help---
          Enable the possibility of suspending the machine.
          It doesn't need ACPI or APM.
index b1fb7866b0b31d65ccea5946aa22e9c2881e0322..0b00f56c2ad0ad369fdaa42d40e24c6f56720881 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/pm.h>
 #include <linux/console.h>
 #include <linux/cpu.h>
+#include <linux/freezer.h>
 
 #include "power.h"
 
 static int noresume = 0;
 char resume_file[256] = CONFIG_PM_STD_PARTITION;
 dev_t swsusp_resume_device;
+sector_t swsusp_resume_block;
+
+/**
+ *     platform_prepare - prepare the machine for hibernation using the
+ *     platform driver if so configured and return an error code if it fails
+ */
+
+static inline int platform_prepare(void)
+{
+       int error = 0;
+
+       if (pm_disk_mode == PM_DISK_PLATFORM) {
+               if (pm_ops && pm_ops->prepare)
+                       error = pm_ops->prepare(PM_SUSPEND_DISK);
+       }
+       return error;
+}
 
 /**
  *     power_down - Shut machine down for hibernate.
@@ -40,12 +58,10 @@ dev_t swsusp_resume_device;
 
 static void power_down(suspend_disk_method_t mode)
 {
-       int error = 0;
-
        switch(mode) {
        case PM_DISK_PLATFORM:
                kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK);
-               error = pm_ops->enter(PM_SUSPEND_DISK);
+               pm_ops->enter(PM_SUSPEND_DISK);
                break;
        case PM_DISK_SHUTDOWN:
                kernel_power_off();
@@ -90,12 +106,18 @@ static int prepare_processes(void)
                goto thaw;
        }
 
+       error = platform_prepare();
+       if (error)
+               goto thaw;
+
        /* Free memory before shutting down devices. */
        if (!(error = swsusp_shrink_memory()))
                return 0;
-thaw:
+
+       platform_finish();
+ thaw:
        thaw_processes();
-enable_cpus:
+ enable_cpus:
        enable_nonboot_cpus();
        pm_restore_console();
        return error;
@@ -127,7 +149,7 @@ int pm_suspend_disk(void)
                return error;
 
        if (pm_disk_mode == PM_DISK_TESTPROC)
-               goto Thaw;
+               return 0;
 
        suspend_console();
        error = device_suspend(PMSG_FREEZE);
@@ -189,10 +211,10 @@ static int software_resume(void)
 {
        int error;
 
-       down(&pm_sem);
+       mutex_lock(&pm_mutex);
        if (!swsusp_resume_device) {
                if (!strlen(resume_file)) {
-                       up(&pm_sem);
+                       mutex_unlock(&pm_mutex);
                        return -ENOENT;
                }
                swsusp_resume_device = name_to_dev_t(resume_file);
@@ -207,7 +229,7 @@ static int software_resume(void)
                 * FIXME: If noresume is specified, we need to find the partition
                 * and reset it back to normal swap space.
                 */
-               up(&pm_sem);
+               mutex_unlock(&pm_mutex);
                return 0;
        }
 
@@ -251,7 +273,7 @@ static int software_resume(void)
        unprepare_processes();
  Done:
        /* For success case, the suspend path will release the lock */
-       up(&pm_sem);
+       mutex_unlock(&pm_mutex);
        pr_debug("PM: Resume from disk failed.\n");
        return 0;
 }
@@ -312,7 +334,7 @@ static ssize_t disk_store(struct subsystem * s, const char * buf, size_t n)
        p = memchr(buf, '\n', n);
        len = p ? p - buf : n;
 
-       down(&pm_sem);
+       mutex_lock(&pm_mutex);
        for (i = PM_DISK_FIRMWARE; i < PM_DISK_MAX; i++) {
                if (!strncmp(buf, pm_disk_modes[i], len)) {
                        mode = i;
@@ -336,7 +358,7 @@ static ssize_t disk_store(struct subsystem * s, const char * buf, size_t n)
 
        pr_debug("PM: suspend-to-disk mode set to '%s'\n",
                 pm_disk_modes[mode]);
-       up(&pm_sem);
+       mutex_unlock(&pm_mutex);
        return error ? error : n;
 }
 
@@ -361,14 +383,14 @@ static ssize_t resume_store(struct subsystem *subsys, const char *buf, size_t n)
        if (maj != MAJOR(res) || min != MINOR(res))
                goto out;
 
-       down(&pm_sem);
+       mutex_lock(&pm_mutex);
        swsusp_resume_device = res;
-       up(&pm_sem);
+       mutex_unlock(&pm_mutex);
        printk("Attempting manual resume\n");
        noresume = 0;
        software_resume();
        ret = n;
-out:
+ out:
        return ret;
 }
 
@@ -423,6 +445,19 @@ static int __init resume_setup(char *str)
        return 1;
 }
 
+static int __init resume_offset_setup(char *str)
+{
+       unsigned long long offset;
+
+       if (noresume)
+               return 1;
+
+       if (sscanf(str, "%llu", &offset) == 1)
+               swsusp_resume_block = offset;
+
+       return 1;
+}
+
 static int __init noresume_setup(char *str)
 {
        noresume = 1;
@@ -430,4 +465,5 @@ static int __init noresume_setup(char *str)
 }
 
 __setup("noresume", noresume_setup);
+__setup("resume_offset=", resume_offset_setup);
 __setup("resume=", resume_setup);
index 873228c71dabdf700abcf2e6c19dcb3cc96315b7..500eb87f643dd9ff56d08079a29c506e7140b777 100644 (file)
@@ -8,6 +8,7 @@
  *
  */
 
+#include <linux/module.h>
 #include <linux/suspend.h>
 #include <linux/kobject.h>
 #include <linux/string.h>
 #include <linux/console.h>
 #include <linux/cpu.h>
 #include <linux/resume-trace.h>
+#include <linux/freezer.h>
 
 #include "power.h"
 
 /*This is just an arbitrary number */
 #define FREE_PAGE_NUMBER (100)
 
-DECLARE_MUTEX(pm_sem);
+DEFINE_MUTEX(pm_mutex);
 
 struct pm_ops *pm_ops;
 suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN;
@@ -36,9 +38,9 @@ suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN;
 
 void pm_set_ops(struct pm_ops * ops)
 {
-       down(&pm_sem);
+       mutex_lock(&pm_mutex);
        pm_ops = ops;
-       up(&pm_sem);
+       mutex_unlock(&pm_mutex);
 }
 
 
@@ -182,7 +184,7 @@ static int enter_state(suspend_state_t state)
 
        if (!valid_state(state))
                return -ENODEV;
-       if (down_trylock(&pm_sem))
+       if (!mutex_trylock(&pm_mutex))
                return -EBUSY;
 
        if (state == PM_SUSPEND_DISK) {
@@ -200,7 +202,7 @@ static int enter_state(suspend_state_t state)
        pr_debug("PM: Finishing wakeup.\n");
        suspend_finish(state);
  Unlock:
-       up(&pm_sem);
+       mutex_unlock(&pm_mutex);
        return error;
 }
 
@@ -229,7 +231,7 @@ int pm_suspend(suspend_state_t state)
        return -EINVAL;
 }
 
-
+EXPORT_SYMBOL(pm_suspend);
 
 decl_subsys(power,NULL,NULL);
 
index bfe999f7b2720b9b3fa1b0a667103e35282922d1..eb461b816bf430cd4336a249ce16812e260a19b1 100644 (file)
@@ -22,7 +22,9 @@ static inline int pm_suspend_disk(void)
        return -EPERM;
 }
 #endif
-extern struct semaphore pm_sem;
+
+extern struct mutex pm_mutex;
+
 #define power_attr(_name) \
 static struct subsys_attribute _name##_attr = {        \
        .attr   = {                             \
@@ -42,6 +44,7 @@ extern const void __nosave_begin, __nosave_end;
 extern unsigned long image_size;
 extern int in_suspend;
 extern dev_t swsusp_resume_device;
+extern sector_t swsusp_resume_block;
 
 extern asmlinkage int swsusp_arch_suspend(void);
 extern asmlinkage int swsusp_arch_resume(void);
@@ -102,8 +105,18 @@ struct snapshot_handle {
 extern unsigned int snapshot_additional_pages(struct zone *zone);
 extern int snapshot_read_next(struct snapshot_handle *handle, size_t count);
 extern int snapshot_write_next(struct snapshot_handle *handle, size_t count);
+extern void snapshot_write_finalize(struct snapshot_handle *handle);
 extern int snapshot_image_loaded(struct snapshot_handle *handle);
-extern void snapshot_free_unused_memory(struct snapshot_handle *handle);
+
+/*
+ * This structure is used to pass the values needed for the identification
+ * of the resume swap area from a user space to the kernel via the
+ * SNAPSHOT_SET_SWAP_AREA ioctl
+ */
+struct resume_swap_area {
+       loff_t offset;
+       u_int32_t dev;
+} __attribute__((packed));
 
 #define SNAPSHOT_IOC_MAGIC     '3'
 #define SNAPSHOT_FREEZE                        _IO(SNAPSHOT_IOC_MAGIC, 1)
@@ -117,7 +130,14 @@ extern void snapshot_free_unused_memory(struct snapshot_handle *handle);
 #define SNAPSHOT_FREE_SWAP_PAGES       _IO(SNAPSHOT_IOC_MAGIC, 9)
 #define SNAPSHOT_SET_SWAP_FILE         _IOW(SNAPSHOT_IOC_MAGIC, 10, unsigned int)
 #define SNAPSHOT_S2RAM                 _IO(SNAPSHOT_IOC_MAGIC, 11)
-#define SNAPSHOT_IOC_MAXNR     11
+#define SNAPSHOT_PMOPS                 _IOW(SNAPSHOT_IOC_MAGIC, 12, unsigned int)
+#define SNAPSHOT_SET_SWAP_AREA         _IOW(SNAPSHOT_IOC_MAGIC, 13, \
+                                                       struct resume_swap_area)
+#define SNAPSHOT_IOC_MAXNR     13
+
+#define PMOPS_PREPARE  1
+#define PMOPS_ENTER    2
+#define PMOPS_FINISH   3
 
 /**
  *     The bitmap is used for tracing allocated swap pages
@@ -141,7 +161,7 @@ struct bitmap_page {
 
 extern void free_bitmap(struct bitmap_page *bitmap);
 extern struct bitmap_page *alloc_bitmap(unsigned int nr_bits);
-extern unsigned long alloc_swap_page(int swap, struct bitmap_page *bitmap);
+extern sector_t alloc_swapdev_block(int swap, struct bitmap_page *bitmap);
 extern void free_all_swap_pages(int swap, struct bitmap_page *bitmap);
 
 extern int swsusp_check(void);
@@ -153,3 +173,7 @@ extern int swsusp_read(void);
 extern int swsusp_write(void);
 extern void swsusp_close(void);
 extern int suspend_enter(suspend_state_t state);
+
+struct timeval;
+extern void swsusp_show_speed(struct timeval *, struct timeval *,
+                               unsigned int, char *);
index 72e72d2c61e6e412106c2e58733087b9ba16ac81..99eeb119b06db1d350d04de044fdb624f4627a19 100644 (file)
 #include <linux/suspend.h>
 #include <linux/module.h>
 #include <linux/syscalls.h>
+#include <linux/freezer.h>
 
 /* 
  * Timeout for stopping processes
  */
 #define TIMEOUT        (20 * HZ)
 
+#define FREEZER_KERNEL_THREADS 0
+#define FREEZER_USER_SPACE 1
 
 static inline int freezeable(struct task_struct * p)
 {
@@ -39,7 +42,6 @@ void refrigerator(void)
        long save;
        save = current->state;
        pr_debug("%s entered refrigerator\n", current->comm);
-       printk("=");
 
        frozen_process(current);
        spin_lock_irq(&current->sighand->siglock);
@@ -79,96 +81,136 @@ static void cancel_freezing(struct task_struct *p)
        }
 }
 
-/* 0 = success, else # of processes that we failed to stop */
-int freeze_processes(void)
+static inline int is_user_space(struct task_struct *p)
+{
+       return p->mm && !(p->flags & PF_BORROWED_MM);
+}
+
+static unsigned int try_to_freeze_tasks(int freeze_user_space)
 {
-       int todo, nr_user, user_frozen;
-       unsigned long start_time;
        struct task_struct *g, *p;
+       unsigned long end_time;
+       unsigned int todo;
 
-       printk( "Stopping tasks: " );
-       start_time = jiffies;
-       user_frozen = 0;
+       end_time = jiffies + TIMEOUT;
        do {
-               nr_user = todo = 0;
+               todo = 0;
                read_lock(&tasklist_lock);
                do_each_thread(g, p) {
                        if (!freezeable(p))
                                continue;
+
                        if (frozen(p))
                                continue;
-                       if (p->state == TASK_TRACED && frozen(p->parent)) {
+
+                       if (p->state == TASK_TRACED &&
+                           (frozen(p->parent) ||
+                            p->parent->state == TASK_STOPPED)) {
                                cancel_freezing(p);
                                continue;
                        }
-                       if (p->mm && !(p->flags & PF_BORROWED_MM)) {
-                               /* The task is a user-space one.
-                                * Freeze it unless there's a vfork completion
-                                * pending
+                       if (is_user_space(p)) {
+                               if (!freeze_user_space)
+                                       continue;
+
+                               /* Freeze the task unless there is a vfork
+                                * completion pending
                                 */
                                if (!p->vfork_done)
                                        freeze_process(p);
-                               nr_user++;
                        } else {
-                               /* Freeze only if the user space is frozen */
-                               if (user_frozen)
-                                       freeze_process(p);
-                               todo++;
+                               if (freeze_user_space)
+                                       continue;
+
+                               freeze_process(p);
                        }
+                       todo++;
                } while_each_thread(g, p);
                read_unlock(&tasklist_lock);
-               todo += nr_user;
-               if (!user_frozen && !nr_user) {
-                       sys_sync();
-                       start_time = jiffies;
-               }
-               user_frozen = !nr_user;
                yield();                        /* Yield is okay here */
-               if (todo && time_after(jiffies, start_time + TIMEOUT))
+               if (todo && time_after(jiffies, end_time))
                        break;
-       } while(todo);
+       } while (todo);
 
-       /* This does not unfreeze processes that are already frozen
-        * (we have slightly ugly calling convention in that respect,
-        * and caller must call thaw_processes() if something fails),
-        * but it cleans up leftover PF_FREEZE requests.
-        */
        if (todo) {
-               printk( "\n" );
-               printk(KERN_ERR " stopping tasks timed out "
-                       "after %d seconds (%d tasks remaining):\n",
-                       TIMEOUT / HZ, todo);
+               /* This does not unfreeze processes that are already frozen
+                * (we have slightly ugly calling convention in that respect,
+                * and caller must call thaw_processes() if something fails),
+                * but it cleans up leftover PF_FREEZE requests.
+                */
+               printk("\n");
+               printk(KERN_ERR "Stopping %s timed out after %d seconds "
+                               "(%d tasks refusing to freeze):\n",
+                               freeze_user_space ? "user space processes" :
+                                       "kernel threads",
+                               TIMEOUT / HZ, todo);
                read_lock(&tasklist_lock);
                do_each_thread(g, p) {
+                       if (is_user_space(p) == !freeze_user_space)
+                               continue;
+
                        if (freezeable(p) && !frozen(p))
-                               printk(KERN_ERR "  %s\n", p->comm);
+                               printk(KERN_ERR " %s\n", p->comm);
+
                        cancel_freezing(p);
                } while_each_thread(g, p);
                read_unlock(&tasklist_lock);
-               return todo;
        }
 
-       printk( "|\n" );
+       return todo;
+}
+
+/**
+ *     freeze_processes - tell processes to enter the refrigerator
+ *
+ *     Returns 0 on success, or the number of processes that didn't freeze,
+ *     although they were told to.
+ */
+int freeze_processes(void)
+{
+       unsigned int nr_unfrozen;
+
+       printk("Stopping tasks ... ");
+       nr_unfrozen = try_to_freeze_tasks(FREEZER_USER_SPACE);
+       if (nr_unfrozen)
+               return nr_unfrozen;
+
+       sys_sync();
+       nr_unfrozen = try_to_freeze_tasks(FREEZER_KERNEL_THREADS);
+       if (nr_unfrozen)
+               return nr_unfrozen;
+
+       printk("done.\n");
        BUG_ON(in_atomic());
        return 0;
 }
 
-void thaw_processes(void)
+static void thaw_tasks(int thaw_user_space)
 {
        struct task_struct *g, *p;
 
-       printk( "Restarting tasks..." );
        read_lock(&tasklist_lock);
        do_each_thread(g, p) {
                if (!freezeable(p))
                        continue;
+
+               if (is_user_space(p) == !thaw_user_space)
+                       continue;
+
                if (!thaw_process(p))
-                       printk(KERN_INFO " Strange, %s not stopped\n", p->comm );
+                       printk(KERN_WARNING " Strange, %s not stopped\n",
+                               p->comm );
        } while_each_thread(g, p);
-
        read_unlock(&tasklist_lock);
+}
+
+void thaw_processes(void)
+{
+       printk("Restarting tasks ... ");
+       thaw_tasks(FREEZER_KERNEL_THREADS);
+       thaw_tasks(FREEZER_USER_SPACE);
        schedule();
-       printk( " done\n" );
+       printk("done.\n");
 }
 
 EXPORT_SYMBOL(refrigerator);
index 99f9b7d177d6a843f5bcb3ade50e67379e169013..c024606221c4f9d6dd7ba35f3634f9f944fda23e 100644 (file)
@@ -1,15 +1,15 @@
 /*
  * linux/kernel/power/snapshot.c
  *
- * This file provide system snapshot/restore functionality.
+ * This file provides system snapshot/restore functionality for swsusp.
  *
  * Copyright (C) 1998-2005 Pavel Machek <pavel@suse.cz>
+ * Copyright (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
  *
- * This file is released under the GPLv2, and is based on swsusp.c.
+ * This file is released under the GPLv2.
  *
  */
 
-
 #include <linux/version.h>
 #include <linux/module.h>
 #include <linux/mm.h>
 
 #include "power.h"
 
-/* List of PBEs used for creating and restoring the suspend image */
+/* List of PBEs needed for restoring the pages that were allocated before
+ * the suspend and included in the suspend image, but have also been
+ * allocated by the "resume" kernel, so their contents cannot be written
+ * directly to their "original" page frames.
+ */
 struct pbe *restore_pblist;
 
-static unsigned int nr_copy_pages;
-static unsigned int nr_meta_pages;
+/* Pointer to an auxiliary buffer (1 page) */
 static void *buffer;
 
-#ifdef CONFIG_HIGHMEM
-unsigned int count_highmem_pages(void)
-{
-       struct zone *zone;
-       unsigned long zone_pfn;
-       unsigned int n = 0;
-
-       for_each_zone (zone)
-               if (is_highmem(zone)) {
-                       mark_free_pages(zone);
-                       for (zone_pfn = 0; zone_pfn < zone->spanned_pages; zone_pfn++) {
-                               struct page *page;
-                               unsigned long pfn = zone_pfn + zone->zone_start_pfn;
-                               if (!pfn_valid(pfn))
-                                       continue;
-                               page = pfn_to_page(pfn);
-                               if (PageReserved(page))
-                                       continue;
-                               if (PageNosaveFree(page))
-                                       continue;
-                               n++;
-                       }
-               }
-       return n;
-}
-
-struct highmem_page {
-       char *data;
-       struct page *page;
-       struct highmem_page *next;
-};
-
-static struct highmem_page *highmem_copy;
-
-static int save_highmem_zone(struct zone *zone)
-{
-       unsigned long zone_pfn;
-       mark_free_pages(zone);
-       for (zone_pfn = 0; zone_pfn < zone->spanned_pages; ++zone_pfn) {
-               struct page *page;
-               struct highmem_page *save;
-               void *kaddr;
-               unsigned long pfn = zone_pfn + zone->zone_start_pfn;
-
-               if (!(pfn%10000))
-                       printk(".");
-               if (!pfn_valid(pfn))
-                       continue;
-               page = pfn_to_page(pfn);
-               /*
-                * This condition results from rvmalloc() sans vmalloc_32()
-                * and architectural memory reservations. This should be
-                * corrected eventually when the cases giving rise to this
-                * are better understood.
-                */
-               if (PageReserved(page))
-                       continue;
-               BUG_ON(PageNosave(page));
-               if (PageNosaveFree(page))
-                       continue;
-               save = kmalloc(sizeof(struct highmem_page), GFP_ATOMIC);
-               if (!save)
-                       return -ENOMEM;
-               save->next = highmem_copy;
-               save->page = page;
-               save->data = (void *) get_zeroed_page(GFP_ATOMIC);
-               if (!save->data) {
-                       kfree(save);
-                       return -ENOMEM;
-               }
-               kaddr = kmap_atomic(page, KM_USER0);
-               memcpy(save->data, kaddr, PAGE_SIZE);
-               kunmap_atomic(kaddr, KM_USER0);
-               highmem_copy = save;
-       }
-       return 0;
-}
-
-int save_highmem(void)
-{
-       struct zone *zone;
-       int res = 0;
-
-       pr_debug("swsusp: Saving Highmem");
-       drain_local_pages();
-       for_each_zone (zone) {
-               if (is_highmem(zone))
-                       res = save_highmem_zone(zone);
-               if (res)
-                       return res;
-       }
-       printk("\n");
-       return 0;
-}
-
-int restore_highmem(void)
-{
-       printk("swsusp: Restoring Highmem\n");
-       while (highmem_copy) {
-               struct highmem_page *save = highmem_copy;
-               void *kaddr;
-               highmem_copy = save->next;
-
-               kaddr = kmap_atomic(save->page, KM_USER0);
-               memcpy(kaddr, save->data, PAGE_SIZE);
-               kunmap_atomic(kaddr, KM_USER0);
-               free_page((long) save->data);
-               kfree(save);
-       }
-       return 0;
-}
-#else
-static inline unsigned int count_highmem_pages(void) {return 0;}
-static inline int save_highmem(void) {return 0;}
-static inline int restore_highmem(void) {return 0;}
-#endif
-
 /**
  *     @safe_needed - on resume, for storing the PBE list and the image,
  *     we can only use memory pages that do not conflict with the pages
- *     used before suspend.
+ *     used before suspend.  The unsafe pages have PageNosaveFree set
+ *     and we count them using unsafe_pages.
  *
- *     The unsafe pages are marked with the PG_nosave_free flag
- *     and we count them using unsafe_pages
+ *     Each allocated image page is marked as PageNosave and PageNosaveFree
+ *     so that swsusp_free() can release it.
  */
 
 #define PG_ANY         0
@@ -174,7 +61,7 @@ static inline int restore_highmem(void) {return 0;}
 
 static unsigned int allocated_unsafe_pages;
 
-static void *alloc_image_page(gfp_t gfp_mask, int safe_needed)
+static void *get_image_page(gfp_t gfp_mask, int safe_needed)
 {
        void *res;
 
@@ -195,20 +82,39 @@ static void *alloc_image_page(gfp_t gfp_mask, int safe_needed)
 
 unsigned long get_safe_page(gfp_t gfp_mask)
 {
-       return (unsigned long)alloc_image_page(gfp_mask, PG_SAFE);
+       return (unsigned long)get_image_page(gfp_mask, PG_SAFE);
+}
+
+static struct page *alloc_image_page(gfp_t gfp_mask)
+{
+       struct page *page;
+
+       page = alloc_page(gfp_mask);
+       if (page) {
+               SetPageNosave(page);
+               SetPageNosaveFree(page);
+       }
+       return page;
 }
 
 /**
  *     free_image_page - free page represented by @addr, allocated with
- *     alloc_image_page (page flags set by it must be cleared)
+ *     get_image_page (page flags set by it must be cleared)
  */
 
 static inline void free_image_page(void *addr, int clear_nosave_free)
 {
-       ClearPageNosave(virt_to_page(addr));
+       struct page *page;
+
+       BUG_ON(!virt_addr_valid(addr));
+
+       page = virt_to_page(addr);
+
+       ClearPageNosave(page);
        if (clear_nosave_free)
-               ClearPageNosaveFree(virt_to_page(addr));
-       free_page((unsigned long)addr);
+               ClearPageNosaveFree(page);
+
+       __free_page(page);
 }
 
 /* struct linked_page is used to build chains of pages */
@@ -269,7 +175,7 @@ static void *chain_alloc(struct chain_allocator *ca, unsigned int size)
        if (LINKED_PAGE_DATA_SIZE - ca->used_space < size) {
                struct linked_page *lp;
 
-               lp = alloc_image_page(ca->gfp_mask, ca->safe_needed);
+               lp = get_image_page(ca->gfp_mask, ca->safe_needed);
                if (!lp)
                        return NULL;
 
@@ -446,8 +352,8 @@ memory_bm_create(struct memory_bitmap *bm, gfp_t gfp_mask, int safe_needed)
 
        /* Compute the number of zones */
        nr = 0;
-       for_each_zone (zone)
-               if (populated_zone(zone) && !is_highmem(zone))
+       for_each_zone(zone)
+               if (populated_zone(zone))
                        nr++;
 
        /* Allocate the list of zones bitmap objects */
@@ -459,10 +365,10 @@ memory_bm_create(struct memory_bitmap *bm, gfp_t gfp_mask, int safe_needed)
        }
 
        /* Initialize the zone bitmap objects */
-       for_each_zone (zone) {
+       for_each_zone(zone) {
                unsigned long pfn;
 
-               if (!populated_zone(zone) || is_highmem(zone))
+               if (!populated_zone(zone))
                        continue;
 
                zone_bm->start_pfn = zone->zone_start_pfn;
@@ -481,7 +387,7 @@ memory_bm_create(struct memory_bitmap *bm, gfp_t gfp_mask, int safe_needed)
                while (bb) {
                        unsigned long *ptr;
 
-                       ptr = alloc_image_page(gfp_mask, safe_needed);
+                       ptr = get_image_page(gfp_mask, safe_needed);
                        bb->data = ptr;
                        if (!ptr)
                                goto Free;
@@ -505,7 +411,7 @@ memory_bm_create(struct memory_bitmap *bm, gfp_t gfp_mask, int safe_needed)
        memory_bm_position_reset(bm);
        return 0;
 
-Free:
+ Free:
        bm->p_list = ca.chain;
        memory_bm_free(bm, PG_UNSAFE_CLEAR);
        return -ENOMEM;
@@ -651,7 +557,7 @@ static unsigned long memory_bm_next_pfn(struct memory_bitmap *bm)
        memory_bm_position_reset(bm);
        return BM_END_OF_MAP;
 
-Return_pfn:
+ Return_pfn:
        bm->cur.chunk = chunk;
        bm->cur.bit = bit;
        return bb->start_pfn + chunk * BM_BITS_PER_CHUNK + bit;
@@ -669,9 +575,81 @@ unsigned int snapshot_additional_pages(struct zone *zone)
 
        res = DIV_ROUND_UP(zone->spanned_pages, BM_BITS_PER_BLOCK);
        res += DIV_ROUND_UP(res * sizeof(struct bm_block), PAGE_SIZE);
-       return res;
+       return 2 * res;
+}
+
+#ifdef CONFIG_HIGHMEM
+/**
+ *     count_free_highmem_pages - compute the total number of free highmem
+ *     pages, system-wide.
+ */
+
+static unsigned int count_free_highmem_pages(void)
+{
+       struct zone *zone;
+       unsigned int cnt = 0;
+
+       for_each_zone(zone)
+               if (populated_zone(zone) && is_highmem(zone))
+                       cnt += zone->free_pages;
+
+       return cnt;
+}
+
+/**
+ *     saveable_highmem_page - Determine whether a highmem page should be
+ *     included in the suspend image.
+ *
+ *     We should save the page if it isn't Nosave or NosaveFree, or Reserved,
+ *     and it isn't a part of a free chunk of pages.
+ */
+
+static struct page *saveable_highmem_page(unsigned long pfn)
+{
+       struct page *page;
+
+       if (!pfn_valid(pfn))
+               return NULL;
+
+       page = pfn_to_page(pfn);
+
+       BUG_ON(!PageHighMem(page));
+
+       if (PageNosave(page) || PageReserved(page) || PageNosaveFree(page))
+               return NULL;
+
+       return page;
 }
 
+/**
+ *     count_highmem_pages - compute the total number of saveable highmem
+ *     pages.
+ */
+
+unsigned int count_highmem_pages(void)
+{
+       struct zone *zone;
+       unsigned int n = 0;
+
+       for_each_zone(zone) {
+               unsigned long pfn, max_zone_pfn;
+
+               if (!is_highmem(zone))
+                       continue;
+
+               mark_free_pages(zone);
+               max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
+               for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
+                       if (saveable_highmem_page(pfn))
+                               n++;
+       }
+       return n;
+}
+#else
+static inline void *saveable_highmem_page(unsigned long pfn) { return NULL; }
+static inline unsigned int count_highmem_pages(void) { return 0; }
+#endif /* CONFIG_HIGHMEM */
+
 /**
  *     pfn_is_nosave - check if given pfn is in the 'nosave' section
  */
@@ -684,12 +662,12 @@ static inline int pfn_is_nosave(unsigned long pfn)
 }
 
 /**
- *     saveable - Determine whether a page should be cloned or not.
- *     @pfn:   The page
+ *     saveable - Determine whether a non-highmem page should be included in
+ *     the suspend image.
  *
- *     We save a page if it isn't Nosave, and is not in the range of pages
- *     statically defined as 'unsaveable', and it
- *     isn't a part of a free chunk of pages.
+ *     We should save the page if it isn't Nosave, and is not in the range
+ *     of pages statically defined as 'unsaveable', and it isn't a part of
+ *     a free chunk of pages.
  */
 
 static struct page *saveable_page(unsigned long pfn)
@@ -701,76 +679,130 @@ static struct page *saveable_page(unsigned long pfn)
 
        page = pfn_to_page(pfn);
 
-       if (PageNosave(page))
+       BUG_ON(PageHighMem(page));
+
+       if (PageNosave(page) || PageNosaveFree(page))
                return NULL;
+
        if (PageReserved(page) && pfn_is_nosave(pfn))
                return NULL;
-       if (PageNosaveFree(page))
-               return NULL;
 
        return page;
 }
 
+/**
+ *     count_data_pages - compute the total number of saveable non-highmem
+ *     pages.
+ */
+
 unsigned int count_data_pages(void)
 {
        struct zone *zone;
        unsigned long pfn, max_zone_pfn;
        unsigned int n = 0;
 
-       for_each_zone (zone) {
+       for_each_zone(zone) {
                if (is_highmem(zone))
                        continue;
+
                mark_free_pages(zone);
                max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
                for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
-                       n += !!saveable_page(pfn);
+                       if(saveable_page(pfn))
+                               n++;
        }
        return n;
 }
 
-static inline void copy_data_page(long *dst, long *src)
+/* This is needed, because copy_page and memcpy are not usable for copying
+ * task structs.
+ */
+static inline void do_copy_page(long *dst, long *src)
 {
        int n;
 
-       /* copy_page and memcpy are not usable for copying task structs. */
        for (n = PAGE_SIZE / sizeof(long); n; n--)
                *dst++ = *src++;
 }
 
+#ifdef CONFIG_HIGHMEM
+static inline struct page *
+page_is_saveable(struct zone *zone, unsigned long pfn)
+{
+       return is_highmem(zone) ?
+                       saveable_highmem_page(pfn) : saveable_page(pfn);
+}
+
+static inline void
+copy_data_page(unsigned long dst_pfn, unsigned long src_pfn)
+{
+       struct page *s_page, *d_page;
+       void *src, *dst;
+
+       s_page = pfn_to_page(src_pfn);
+       d_page = pfn_to_page(dst_pfn);
+       if (PageHighMem(s_page)) {
+               src = kmap_atomic(s_page, KM_USER0);
+               dst = kmap_atomic(d_page, KM_USER1);
+               do_copy_page(dst, src);
+               kunmap_atomic(src, KM_USER0);
+               kunmap_atomic(dst, KM_USER1);
+       } else {
+               src = page_address(s_page);
+               if (PageHighMem(d_page)) {
+                       /* Page pointed to by src may contain some kernel
+                        * data modified by kmap_atomic()
+                        */
+                       do_copy_page(buffer, src);
+                       dst = kmap_atomic(pfn_to_page(dst_pfn), KM_USER0);
+                       memcpy(dst, buffer, PAGE_SIZE);
+                       kunmap_atomic(dst, KM_USER0);
+               } else {
+                       dst = page_address(d_page);
+                       do_copy_page(dst, src);
+               }
+       }
+}
+#else
+#define page_is_saveable(zone, pfn)    saveable_page(pfn)
+
+static inline void
+copy_data_page(unsigned long dst_pfn, unsigned long src_pfn)
+{
+       do_copy_page(page_address(pfn_to_page(dst_pfn)),
+                       page_address(pfn_to_page(src_pfn)));
+}
+#endif /* CONFIG_HIGHMEM */
+
 static void
 copy_data_pages(struct memory_bitmap *copy_bm, struct memory_bitmap *orig_bm)
 {
        struct zone *zone;
        unsigned long pfn;
 
-       for_each_zone (zone) {
+       for_each_zone(zone) {
                unsigned long max_zone_pfn;
 
-               if (is_highmem(zone))
-                       continue;
-
                mark_free_pages(zone);
                max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
                for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
-                       if (saveable_page(pfn))
+                       if (page_is_saveable(zone, pfn))
                                memory_bm_set_bit(orig_bm, pfn);
        }
        memory_bm_position_reset(orig_bm);
        memory_bm_position_reset(copy_bm);
        do {
                pfn = memory_bm_next_pfn(orig_bm);
-               if (likely(pfn != BM_END_OF_MAP)) {
-                       struct page *page;
-                       void *src;
-
-                       page = pfn_to_page(pfn);
-                       src = page_address(page);
-                       page = pfn_to_page(memory_bm_next_pfn(copy_bm));
-                       copy_data_page(page_address(page), src);
-               }
+               if (likely(pfn != BM_END_OF_MAP))
+                       copy_data_page(memory_bm_next_pfn(copy_bm), pfn);
        } while (pfn != BM_END_OF_MAP);
 }
 
+/* Total number of image pages */
+static unsigned int nr_copy_pages;
+/* Number of pages needed for saving the original pfns of the image pages */
+static unsigned int nr_meta_pages;
+
 /**
  *     swsusp_free - free pages allocated for the suspend.
  *
@@ -792,7 +824,7 @@ void swsusp_free(void)
                                if (PageNosave(page) && PageNosaveFree(page)) {
                                        ClearPageNosave(page);
                                        ClearPageNosaveFree(page);
-                                       free_page((long) page_address(page));
+                                       __free_page(page);
                                }
                        }
        }
@@ -802,34 +834,108 @@ void swsusp_free(void)
        buffer = NULL;
 }
 
+#ifdef CONFIG_HIGHMEM
+/**
+  *    count_pages_for_highmem - compute the number of non-highmem pages
+  *    that will be necessary for creating copies of highmem pages.
+  */
+
+static unsigned int count_pages_for_highmem(unsigned int nr_highmem)
+{
+       unsigned int free_highmem = count_free_highmem_pages();
+
+       if (free_highmem >= nr_highmem)
+               nr_highmem = 0;
+       else
+               nr_highmem -= free_highmem;
+
+       return nr_highmem;
+}
+#else
+static unsigned int
+count_pages_for_highmem(unsigned int nr_highmem) { return 0; }
+#endif /* CONFIG_HIGHMEM */
 
 /**
- *     enough_free_mem - Make sure we enough free memory to snapshot.
- *
- *     Returns TRUE or FALSE after checking the number of available
- *     free pages.
+ *     enough_free_mem - Make sure we have enough free memory for the
+ *     snapshot image.
  */
 
-static int enough_free_mem(unsigned int nr_pages)
+static int enough_free_mem(unsigned int nr_pages, unsigned int nr_highmem)
 {
        struct zone *zone;
        unsigned int free = 0, meta = 0;
 
-       for_each_zone (zone)
-               if (!is_highmem(zone)) {
+       for_each_zone(zone) {
+               meta += snapshot_additional_pages(zone);
+               if (!is_highmem(zone))
                        free += zone->free_pages;
-                       meta += snapshot_additional_pages(zone);
-               }
+       }
 
-       pr_debug("swsusp: pages needed: %u + %u + %u, available pages: %u\n",
+       nr_pages += count_pages_for_highmem(nr_highmem);
+       pr_debug("swsusp: Normal pages needed: %u + %u + %u, available pages: %u\n",
                nr_pages, PAGES_FOR_IO, meta, free);
 
        return free > nr_pages + PAGES_FOR_IO + meta;
 }
 
+#ifdef CONFIG_HIGHMEM
+/**
+ *     get_highmem_buffer - if there are some highmem pages in the suspend
+ *     image, we may need the buffer to copy them and/or load their data.
+ */
+
+static inline int get_highmem_buffer(int safe_needed)
+{
+       buffer = get_image_page(GFP_ATOMIC | __GFP_COLD, safe_needed);
+       return buffer ? 0 : -ENOMEM;
+}
+
+/**
+ *     alloc_highmem_image_pages - allocate some highmem pages for the image.
+ *     Try to allocate as many pages as needed, but if the number of free
+ *     highmem pages is lesser than that, allocate them all.
+ */
+
+static inline unsigned int
+alloc_highmem_image_pages(struct memory_bitmap *bm, unsigned int nr_highmem)
+{
+       unsigned int to_alloc = count_free_highmem_pages();
+
+       if (to_alloc > nr_highmem)
+               to_alloc = nr_highmem;
+
+       nr_highmem -= to_alloc;
+       while (to_alloc-- > 0) {
+               struct page *page;
+
+               page = alloc_image_page(__GFP_HIGHMEM);
+               memory_bm_set_bit(bm, page_to_pfn(page));
+       }
+       return nr_highmem;
+}
+#else
+static inline int get_highmem_buffer(int safe_needed) { return 0; }
+
+static inline unsigned int
+alloc_highmem_image_pages(struct memory_bitmap *bm, unsigned int n) { return 0; }
+#endif /* CONFIG_HIGHMEM */
+
+/**
+ *     swsusp_alloc - allocate memory for the suspend image
+ *
+ *     We first try to allocate as many highmem pages as there are
+ *     saveable highmem pages in the system.  If that fails, we allocate
+ *     non-highmem pages for the copies of the remaining highmem ones.
+ *
+ *     In this approach it is likely that the copies of highmem pages will
+ *     also be located in the high memory, because of the way in which
+ *     copy_data_pages() works.
+ */
+
 static int
 swsusp_alloc(struct memory_bitmap *orig_bm, struct memory_bitmap *copy_bm,
-               unsigned int nr_pages)
+               unsigned int nr_pages, unsigned int nr_highmem)
 {
        int error;
 
@@ -841,46 +947,61 @@ swsusp_alloc(struct memory_bitmap *orig_bm, struct memory_bitmap *copy_bm,
        if (error)
                goto Free;
 
+       if (nr_highmem > 0) {
+               error = get_highmem_buffer(PG_ANY);
+               if (error)
+                       goto Free;
+
+               nr_pages += alloc_highmem_image_pages(copy_bm, nr_highmem);
+       }
        while (nr_pages-- > 0) {
-               struct page *page = alloc_page(GFP_ATOMIC | __GFP_COLD);
+               struct page *page = alloc_image_page(GFP_ATOMIC | __GFP_COLD);
+
                if (!page)
                        goto Free;
 
-               SetPageNosave(page);
-               SetPageNosaveFree(page);
                memory_bm_set_bit(copy_bm, page_to_pfn(page));
        }
        return 0;
 
-Free:
+ Free:
        swsusp_free();
        return -ENOMEM;
 }
 
-/* Memory bitmap used for marking saveable pages */
+/* Memory bitmap used for marking saveable pages (during suspend) or the
+ * suspend image pages (during resume)
+ */
 static struct memory_bitmap orig_bm;
-/* Memory bitmap used for marking allocated pages that will contain the copies
- * of saveable pages
+/* Memory bitmap used on suspend for marking allocated pages that will contain
+ * the copies of saveable pages.  During resume it is initially used for
+ * marking the suspend image pages, but then its set bits are duplicated in
+ * @orig_bm and it is released.  Next, on systems with high memory, it may be
+ * used for marking "safe" highmem pages, but it has to be reinitialized for
+ * this purpose.
  */
 static struct memory_bitmap copy_bm;
 
 asmlinkage int swsusp_save(void)
 {
-       unsigned int nr_pages;
+       unsigned int nr_pages, nr_highmem;
 
-       pr_debug("swsusp: critical section: \n");
+       printk("swsusp: critical section: \n");
 
        drain_local_pages();
        nr_pages = count_data_pages();
-       printk("swsusp: Need to copy %u pages\n", nr_pages);
+       nr_highmem = count_highmem_pages();
+       printk("swsusp: Need to copy %u pages\n", nr_pages + nr_highmem);
 
-       if (!enough_free_mem(nr_pages)) {
+       if (!enough_free_mem(nr_pages, nr_highmem)) {
                printk(KERN_ERR "swsusp: Not enough free memory\n");
                return -ENOMEM;
        }
 
-       if (swsusp_alloc(&orig_bm, &copy_bm, nr_pages))
+       if (swsusp_alloc(&orig_bm, &copy_bm, nr_pages, nr_highmem)) {
+               printk(KERN_ERR "swsusp: Memory allocation failed\n");
                return -ENOMEM;
+       }
 
        /* During allocating of suspend pagedir, new cold pages may appear.
         * Kill them.
@@ -894,10 +1015,12 @@ asmlinkage int swsusp_save(void)
         * touch swap space! Except we must write out our image of course.
         */
 
+       nr_pages += nr_highmem;
        nr_copy_pages = nr_pages;
-       nr_meta_pages = (nr_pages * sizeof(long) + PAGE_SIZE - 1) >> PAGE_SHIFT;
+       nr_meta_pages = DIV_ROUND_UP(nr_pages * sizeof(long), PAGE_SIZE);
 
        printk("swsusp: critical section/: done (%d pages copied)\n", nr_pages);
+
        return 0;
 }
 
@@ -960,7 +1083,7 @@ int snapshot_read_next(struct snapshot_handle *handle, size_t count)
 
        if (!buffer) {
                /* This makes the buffer be freed by swsusp_free() */
-               buffer = alloc_image_page(GFP_ATOMIC, PG_ANY);
+               buffer = get_image_page(GFP_ATOMIC, PG_ANY);
                if (!buffer)
                        return -ENOMEM;
        }
@@ -975,9 +1098,23 @@ int snapshot_read_next(struct snapshot_handle *handle, size_t count)
                        memset(buffer, 0, PAGE_SIZE);
                        pack_pfns(buffer, &orig_bm);
                } else {
-                       unsigned long pfn = memory_bm_next_pfn(&copy_bm);
+                       struct page *page;
 
-                       handle->buffer = page_address(pfn_to_page(pfn));
+                       page = pfn_to_page(memory_bm_next_pfn(&copy_bm));
+                       if (PageHighMem(page)) {
+                               /* Highmem pages are copied to the buffer,
+                                * because we can't return with a kmapped
+                                * highmem page (we may not be called again).
+                                */
+                               void *kaddr;
+
+                               kaddr = kmap_atomic(page, KM_USER0);
+                               memcpy(buffer, kaddr, PAGE_SIZE);
+                               kunmap_atomic(kaddr, KM_USER0);
+                               handle->buffer = buffer;
+                       } else {
+                               handle->buffer = page_address(page);
+                       }
                }
                handle->prev = handle->cur;
        }
@@ -1005,7 +1142,7 @@ static int mark_unsafe_pages(struct memory_bitmap *bm)
        unsigned long pfn, max_zone_pfn;
 
        /* Clear page flags */
-       for_each_zone (zone) {
+       for_each_zone(zone) {
                max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
                for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
                        if (pfn_valid(pfn))
@@ -1101,6 +1238,218 @@ unpack_orig_pfns(unsigned long *buf, struct memory_bitmap *bm)
        }
 }
 
+/* List of "safe" pages that may be used to store data loaded from the suspend
+ * image
+ */
+static struct linked_page *safe_pages_list;
+
+#ifdef CONFIG_HIGHMEM
+/* struct highmem_pbe is used for creating the list of highmem pages that
+ * should be restored atomically during the resume from disk, because the page
+ * frames they have occupied before the suspend are in use.
+ */
+struct highmem_pbe {
+       struct page *copy_page; /* data is here now */
+       struct page *orig_page; /* data was here before the suspend */
+       struct highmem_pbe *next;
+};
+
+/* List of highmem PBEs needed for restoring the highmem pages that were
+ * allocated before the suspend and included in the suspend image, but have
+ * also been allocated by the "resume" kernel, so their contents cannot be
+ * written directly to their "original" page frames.
+ */
+static struct highmem_pbe *highmem_pblist;
+
+/**
+ *     count_highmem_image_pages - compute the number of highmem pages in the
+ *     suspend image.  The bits in the memory bitmap @bm that correspond to the
+ *     image pages are assumed to be set.
+ */
+
+static unsigned int count_highmem_image_pages(struct memory_bitmap *bm)
+{
+       unsigned long pfn;
+       unsigned int cnt = 0;
+
+       memory_bm_position_reset(bm);
+       pfn = memory_bm_next_pfn(bm);
+       while (pfn != BM_END_OF_MAP) {
+               if (PageHighMem(pfn_to_page(pfn)))
+                       cnt++;
+
+               pfn = memory_bm_next_pfn(bm);
+       }
+       return cnt;
+}
+
+/**
+ *     prepare_highmem_image - try to allocate as many highmem pages as
+ *     there are highmem image pages (@nr_highmem_p points to the variable
+ *     containing the number of highmem image pages).  The pages that are
+ *     "safe" (ie. will not be overwritten when the suspend image is
+ *     restored) have the corresponding bits set in @bm (it must be
+ *     unitialized).
+ *
+ *     NOTE: This function should not be called if there are no highmem
+ *     image pages.
+ */
+
+static unsigned int safe_highmem_pages;
+
+static struct memory_bitmap *safe_highmem_bm;
+
+static int
+prepare_highmem_image(struct memory_bitmap *bm, unsigned int *nr_highmem_p)
+{
+       unsigned int to_alloc;
+
+       if (memory_bm_create(bm, GFP_ATOMIC, PG_SAFE))
+               return -ENOMEM;
+
+       if (get_highmem_buffer(PG_SAFE))
+               return -ENOMEM;
+
+       to_alloc = count_free_highmem_pages();
+       if (to_alloc > *nr_highmem_p)
+               to_alloc = *nr_highmem_p;
+       else
+               *nr_highmem_p = to_alloc;
+
+       safe_highmem_pages = 0;
+       while (to_alloc-- > 0) {
+               struct page *page;
+
+               page = alloc_page(__GFP_HIGHMEM);
+               if (!PageNosaveFree(page)) {
+                       /* The page is "safe", set its bit the bitmap */
+                       memory_bm_set_bit(bm, page_to_pfn(page));
+                       safe_highmem_pages++;
+               }
+               /* Mark the page as allocated */
+               SetPageNosave(page);
+               SetPageNosaveFree(page);
+       }
+       memory_bm_position_reset(bm);
+       safe_highmem_bm = bm;
+       return 0;
+}
+
+/**
+ *     get_highmem_page_buffer - for given highmem image page find the buffer
+ *     that suspend_write_next() should set for its caller to write to.
+ *
+ *     If the page is to be saved to its "original" page frame or a copy of
+ *     the page is to be made in the highmem, @buffer is returned.  Otherwise,
+ *     the copy of the page is to be made in normal memory, so the address of
+ *     the copy is returned.
+ *
+ *     If @buffer is returned, the caller of suspend_write_next() will write
+ *     the page's contents to @buffer, so they will have to be copied to the
+ *     right location on the next call to suspend_write_next() and it is done
+ *     with the help of copy_last_highmem_page().  For this purpose, if
+ *     @buffer is returned, @last_highmem page is set to the page to which
+ *     the data will have to be copied from @buffer.
+ */
+
+static struct page *last_highmem_page;
+
+static void *
+get_highmem_page_buffer(struct page *page, struct chain_allocator *ca)
+{
+       struct highmem_pbe *pbe;
+       void *kaddr;
+
+       if (PageNosave(page) && PageNosaveFree(page)) {
+               /* We have allocated the "original" page frame and we can
+                * use it directly to store the loaded page.
+                */
+               last_highmem_page = page;
+               return buffer;
+       }
+       /* The "original" page frame has not been allocated and we have to
+        * use a "safe" page frame to store the loaded page.
+        */
+       pbe = chain_alloc(ca, sizeof(struct highmem_pbe));
+       if (!pbe) {
+               swsusp_free();
+               return NULL;
+       }
+       pbe->orig_page = page;
+       if (safe_highmem_pages > 0) {
+               struct page *tmp;
+
+               /* Copy of the page will be stored in high memory */
+               kaddr = buffer;
+               tmp = pfn_to_page(memory_bm_next_pfn(safe_highmem_bm));
+               safe_highmem_pages--;
+               last_highmem_page = tmp;
+               pbe->copy_page = tmp;
+       } else {
+               /* Copy of the page will be stored in normal memory */
+               kaddr = safe_pages_list;
+               safe_pages_list = safe_pages_list->next;
+               pbe->copy_page = virt_to_page(kaddr);
+       }
+       pbe->next = highmem_pblist;
+       highmem_pblist = pbe;
+       return kaddr;
+}
+
+/**
+ *     copy_last_highmem_page - copy the contents of a highmem image from
+ *     @buffer, where the caller of snapshot_write_next() has place them,
+ *     to the right location represented by @last_highmem_page .
+ */
+
+static void copy_last_highmem_page(void)
+{
+       if (last_highmem_page) {
+               void *dst;
+
+               dst = kmap_atomic(last_highmem_page, KM_USER0);
+               memcpy(dst, buffer, PAGE_SIZE);
+               kunmap_atomic(dst, KM_USER0);
+               last_highmem_page = NULL;
+       }
+}
+
+static inline int last_highmem_page_copied(void)
+{
+       return !last_highmem_page;
+}
+
+static inline void free_highmem_data(void)
+{
+       if (safe_highmem_bm)
+               memory_bm_free(safe_highmem_bm, PG_UNSAFE_CLEAR);
+
+       if (buffer)
+               free_image_page(buffer, PG_UNSAFE_CLEAR);
+}
+#else
+static inline int get_safe_write_buffer(void) { return 0; }
+
+static unsigned int
+count_highmem_image_pages(struct memory_bitmap *bm) { return 0; }
+
+static inline int
+prepare_highmem_image(struct memory_bitmap *bm, unsigned int *nr_highmem_p)
+{
+       return 0;
+}
+
+static inline void *
+get_highmem_page_buffer(struct page *page, struct chain_allocator *ca)
+{
+       return NULL;
+}
+
+static inline void copy_last_highmem_page(void) {}
+static inline int last_highmem_page_copied(void) { return 1; }
+static inline void free_highmem_data(void) {}
+#endif /* CONFIG_HIGHMEM */
+
 /**
  *     prepare_image - use the memory bitmap @bm to mark the pages that will
  *     be overwritten in the process of restoring the system memory state
@@ -1110,20 +1459,25 @@ unpack_orig_pfns(unsigned long *buf, struct memory_bitmap *bm)
  *     The idea is to allocate a new memory bitmap first and then allocate
  *     as many pages as needed for the image data, but not to assign these
  *     pages to specific tasks initially.  Instead, we just mark them as
- *     allocated and create a list of "safe" pages that will be used later.
+ *     allocated and create a lists of "safe" pages that will be used
+ *     later.  On systems with high memory a list of "safe" highmem pages is
+ *     also created.
  */
 
 #define PBES_PER_LINKED_PAGE   (LINKED_PAGE_DATA_SIZE / sizeof(struct pbe))
 
-static struct linked_page *safe_pages_list;
-
 static int
 prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm)
 {
-       unsigned int nr_pages;
+       unsigned int nr_pages, nr_highmem;
        struct linked_page *sp_list, *lp;
        int error;
 
+       /* If there is no highmem, the buffer will not be necessary */
+       free_image_page(buffer, PG_UNSAFE_CLEAR);
+       buffer = NULL;
+
+       nr_highmem = count_highmem_image_pages(bm);
        error = mark_unsafe_pages(bm);
        if (error)
                goto Free;
@@ -1134,6 +1488,11 @@ prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm)
 
        duplicate_memory_bitmap(new_bm, bm);
        memory_bm_free(bm, PG_UNSAFE_KEEP);
+       if (nr_highmem > 0) {
+               error = prepare_highmem_image(bm, &nr_highmem);
+               if (error)
+                       goto Free;
+       }
        /* Reserve some safe pages for potential later use.
         *
         * NOTE: This way we make sure there will be enough safe pages for the
@@ -1142,10 +1501,10 @@ prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm)
         */
        sp_list = NULL;
        /* nr_copy_pages cannot be lesser than allocated_unsafe_pages */
-       nr_pages = nr_copy_pages - allocated_unsafe_pages;
+       nr_pages = nr_copy_pages - nr_highmem - allocated_unsafe_pages;
        nr_pages = DIV_ROUND_UP(nr_pages, PBES_PER_LINKED_PAGE);
        while (nr_pages > 0) {
-               lp = alloc_image_page(GFP_ATOMIC, PG_SAFE);
+               lp = get_image_page(GFP_ATOMIC, PG_SAFE);
                if (!lp) {
                        error = -ENOMEM;
                        goto Free;
@@ -1156,7 +1515,7 @@ prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm)
        }
        /* Preallocate memory for the image */
        safe_pages_list = NULL;
-       nr_pages = nr_copy_pages - allocated_unsafe_pages;
+       nr_pages = nr_copy_pages - nr_highmem - allocated_unsafe_pages;
        while (nr_pages > 0) {
                lp = (struct linked_page *)get_zeroed_page(GFP_ATOMIC);
                if (!lp) {
@@ -1181,7 +1540,7 @@ prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm)
        }
        return 0;
 
-Free:
+ Free:
        swsusp_free();
        return error;
 }
@@ -1196,6 +1555,9 @@ static void *get_buffer(struct memory_bitmap *bm, struct chain_allocator *ca)
        struct pbe *pbe;
        struct page *page = pfn_to_page(memory_bm_next_pfn(bm));
 
+       if (PageHighMem(page))
+               return get_highmem_page_buffer(page, ca);
+
        if (PageNosave(page) && PageNosaveFree(page))
                /* We have allocated the "original" page frame and we can
                 * use it directly to store the loaded page.
@@ -1210,12 +1572,12 @@ static void *get_buffer(struct memory_bitmap *bm, struct chain_allocator *ca)
                swsusp_free();
                return NULL;
        }
-       pbe->orig_address = (unsigned long)page_address(page);
-       pbe->address = (unsigned long)safe_pages_list;
+       pbe->orig_address = page_address(page);
+       pbe->address = safe_pages_list;
        safe_pages_list = safe_pages_list->next;
        pbe->next = restore_pblist;
        restore_pblist = pbe;
-       return (void *)pbe->address;
+       return pbe->address;
 }
 
 /**
@@ -1249,14 +1611,16 @@ int snapshot_write_next(struct snapshot_handle *handle, size_t count)
        if (handle->prev && handle->cur > nr_meta_pages + nr_copy_pages)
                return 0;
 
-       if (!buffer) {
-               /* This makes the buffer be freed by swsusp_free() */
-               buffer = alloc_image_page(GFP_ATOMIC, PG_ANY);
+       if (handle->offset == 0) {
+               if (!buffer)
+                       /* This makes the buffer be freed by swsusp_free() */
+                       buffer = get_image_page(GFP_ATOMIC, PG_ANY);
+
                if (!buffer)
                        return -ENOMEM;
-       }
-       if (!handle->offset)
+
                handle->buffer = buffer;
+       }
        handle->sync_read = 1;
        if (handle->prev < handle->cur) {
                if (handle->prev == 0) {
@@ -1284,8 +1648,10 @@ int snapshot_write_next(struct snapshot_handle *handle, size_t count)
                                        return -ENOMEM;
                        }
                } else {
+                       copy_last_highmem_page();
                        handle->buffer = get_buffer(&orig_bm, &ca);
-                       handle->sync_read = 0;
+                       if (handle->buffer != buffer)
+                               handle->sync_read = 0;
                }
                handle->prev = handle->cur;
        }
@@ -1301,15 +1667,73 @@ int snapshot_write_next(struct snapshot_handle *handle, size_t count)
        return count;
 }
 
+/**
+ *     snapshot_write_finalize - must be called after the last call to
+ *     snapshot_write_next() in case the last page in the image happens
+ *     to be a highmem page and its contents should be stored in the
+ *     highmem.  Additionally, it releases the memory that will not be
+ *     used any more.
+ */
+
+void snapshot_write_finalize(struct snapshot_handle *handle)
+{
+       copy_last_highmem_page();
+       /* Free only if we have loaded the image entirely */
+       if (handle->prev && handle->cur > nr_meta_pages + nr_copy_pages) {
+               memory_bm_free(&orig_bm, PG_UNSAFE_CLEAR);
+               free_highmem_data();
+       }
+}
+
 int snapshot_image_loaded(struct snapshot_handle *handle)
 {
-       return !(!nr_copy_pages ||
+       return !(!nr_copy_pages || !last_highmem_page_copied() ||
                        handle->cur <= nr_meta_pages + nr_copy_pages);
 }
 
-void snapshot_free_unused_memory(struct snapshot_handle *handle)
+#ifdef CONFIG_HIGHMEM
+/* Assumes that @buf is ready and points to a "safe" page */
+static inline void
+swap_two_pages_data(struct page *p1, struct page *p2, void *buf)
 {
-       /* Free only if we have loaded the image entirely */
-       if (handle->prev && handle->cur > nr_meta_pages + nr_copy_pages)
-               memory_bm_free(&orig_bm, PG_UNSAFE_CLEAR);
+       void *kaddr1, *kaddr2;
+
+       kaddr1 = kmap_atomic(p1, KM_USER0);
+       kaddr2 = kmap_atomic(p2, KM_USER1);
+       memcpy(buf, kaddr1, PAGE_SIZE);
+       memcpy(kaddr1, kaddr2, PAGE_SIZE);
+       memcpy(kaddr2, buf, PAGE_SIZE);
+       kunmap_atomic(kaddr1, KM_USER0);
+       kunmap_atomic(kaddr2, KM_USER1);
+}
+
+/**
+ *     restore_highmem - for each highmem page that was allocated before
+ *     the suspend and included in the suspend image, and also has been
+ *     allocated by the "resume" kernel swap its current (ie. "before
+ *     resume") contents with the previous (ie. "before suspend") one.
+ *
+ *     If the resume eventually fails, we can call this function once
+ *     again and restore the "before resume" highmem state.
+ */
+
+int restore_highmem(void)
+{
+       struct highmem_pbe *pbe = highmem_pblist;
+       void *buf;
+
+       if (!pbe)
+               return 0;
+
+       buf = get_image_page(GFP_ATOMIC, PG_SAFE);
+       if (!buf)
+               return -ENOMEM;
+
+       while (pbe) {
+               swap_two_pages_data(pbe->copy_page, pbe->orig_page, buf);
+               pbe = pbe->next;
+       }
+       free_image_page(buf, PG_UNSAFE_CLEAR);
+       return 0;
 }
+#endif /* CONFIG_HIGHMEM */
index 1a3b0dd2c3fcc18b2db25fc7472560cb67edfb7e..f133d4a6d817bacfc2219476d72be55fb5d8face 100644 (file)
@@ -34,34 +34,123 @@ extern char resume_file[];
 #define SWSUSP_SIG     "S1SUSPEND"
 
 static struct swsusp_header {
-       char reserved[PAGE_SIZE - 20 - sizeof(swp_entry_t)];
-       swp_entry_t image;
+       char reserved[PAGE_SIZE - 20 - sizeof(sector_t)];
+       sector_t image;
        char    orig_sig[10];
        char    sig[10];
 } __attribute__((packed, aligned(PAGE_SIZE))) swsusp_header;
 
 /*
- * Saving part...
+ * General things
  */
 
 static unsigned short root_swap = 0xffff;
+static struct block_device *resume_bdev;
+
+/**
+ *     submit - submit BIO request.
+ *     @rw:    READ or WRITE.
+ *     @off    physical offset of page.
+ *     @page:  page we're reading or writing.
+ *     @bio_chain: list of pending biod (for async reading)
+ *
+ *     Straight from the textbook - allocate and initialize the bio.
+ *     If we're reading, make sure the page is marked as dirty.
+ *     Then submit it and, if @bio_chain == NULL, wait.
+ */
+static int submit(int rw, pgoff_t page_off, struct page *page,
+                       struct bio **bio_chain)
+{
+       struct bio *bio;
+
+       bio = bio_alloc(__GFP_WAIT | __GFP_HIGH, 1);
+       if (!bio)
+               return -ENOMEM;
+       bio->bi_sector = page_off * (PAGE_SIZE >> 9);
+       bio->bi_bdev = resume_bdev;
+       bio->bi_end_io = end_swap_bio_read;
+
+       if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
+               printk("swsusp: ERROR: adding page to bio at %ld\n", page_off);
+               bio_put(bio);
+               return -EFAULT;
+       }
+
+       lock_page(page);
+       bio_get(bio);
+
+       if (bio_chain == NULL) {
+               submit_bio(rw | (1 << BIO_RW_SYNC), bio);
+               wait_on_page_locked(page);
+               if (rw == READ)
+                       bio_set_pages_dirty(bio);
+               bio_put(bio);
+       } else {
+               if (rw == READ)
+                       get_page(page); /* These pages are freed later */
+               bio->bi_private = *bio_chain;
+               *bio_chain = bio;
+               submit_bio(rw | (1 << BIO_RW_SYNC), bio);
+       }
+       return 0;
+}
+
+static int bio_read_page(pgoff_t page_off, void *addr, struct bio **bio_chain)
+{
+       return submit(READ, page_off, virt_to_page(addr), bio_chain);
+}
+
+static int bio_write_page(pgoff_t page_off, void *addr, struct bio **bio_chain)
+{
+       return submit(WRITE, page_off, virt_to_page(addr), bio_chain);
+}
+
+static int wait_on_bio_chain(struct bio **bio_chain)
+{
+       struct bio *bio;
+       struct bio *next_bio;
+       int ret = 0;
+
+       if (bio_chain == NULL)
+               return 0;
+
+       bio = *bio_chain;
+       if (bio == NULL)
+               return 0;
+       while (bio) {
+               struct page *page;
+
+               next_bio = bio->bi_private;
+               page = bio->bi_io_vec[0].bv_page;
+               wait_on_page_locked(page);
+               if (!PageUptodate(page) || PageError(page))
+                       ret = -EIO;
+               put_page(page);
+               bio_put(bio);
+               bio = next_bio;
+       }
+       *bio_chain = NULL;
+       return ret;
+}
+
+/*
+ * Saving part
+ */
 
-static int mark_swapfiles(swp_entry_t start)
+static int mark_swapfiles(sector_t start)
 {
        int error;
 
-       rw_swap_page_sync(READ, swp_entry(root_swap, 0),
-                         virt_to_page((unsigned long)&swsusp_header), NULL);
+       bio_read_page(swsusp_resume_block, &swsusp_header, NULL);
        if (!memcmp("SWAP-SPACE",swsusp_header.sig, 10) ||
            !memcmp("SWAPSPACE2",swsusp_header.sig, 10)) {
                memcpy(swsusp_header.orig_sig,swsusp_header.sig, 10);
                memcpy(swsusp_header.sig,SWSUSP_SIG, 10);
                swsusp_header.image = start;
-               error = rw_swap_page_sync(WRITE, swp_entry(root_swap, 0),
-                               virt_to_page((unsigned long)&swsusp_header),
-                               NULL);
+               error = bio_write_page(swsusp_resume_block,
+                                       &swsusp_header, NULL);
        } else {
-               pr_debug("swsusp: Partition is not swap space.\n");
+               printk(KERN_ERR "swsusp: Swap header not found!\n");
                error = -ENODEV;
        }
        return error;
@@ -74,12 +163,21 @@ static int mark_swapfiles(swp_entry_t start)
 
 static int swsusp_swap_check(void) /* This is called before saving image */
 {
-       int res = swap_type_of(swsusp_resume_device);
+       int res;
+
+       res = swap_type_of(swsusp_resume_device, swsusp_resume_block);
+       if (res < 0)
+               return res;
+
+       root_swap = res;
+       resume_bdev = open_by_devnum(swsusp_resume_device, FMODE_WRITE);
+       if (IS_ERR(resume_bdev))
+               return PTR_ERR(resume_bdev);
+
+       res = set_blocksize(resume_bdev, PAGE_SIZE);
+       if (res < 0)
+               blkdev_put(resume_bdev);
 
-       if (res >= 0) {
-               root_swap = res;
-               return 0;
-       }
        return res;
 }
 
@@ -90,36 +188,26 @@ static int swsusp_swap_check(void) /* This is called before saving image */
  *     @bio_chain:     Link the next write BIO here
  */
 
-static int write_page(void *buf, unsigned long offset, struct bio **bio_chain)
+static int write_page(void *buf, sector_t offset, struct bio **bio_chain)
 {
-       swp_entry_t entry;
-       int error = -ENOSPC;
-
-       if (offset) {
-               struct page *page = virt_to_page(buf);
-
-               if (bio_chain) {
-                       /*
-                        * Whether or not we successfully allocated a copy page,
-                        * we take a ref on the page here.  It gets undone in
-                        * wait_on_bio_chain().
-                        */
-                       struct page *page_copy;
-                       page_copy = alloc_page(GFP_ATOMIC);
-                       if (page_copy == NULL) {
-                               WARN_ON_ONCE(1);
-                               bio_chain = NULL;       /* Go synchronous */
-                               get_page(page);
-                       } else {
-                               memcpy(page_address(page_copy),
-                                       page_address(page), PAGE_SIZE);
-                               page = page_copy;
-                       }
+       void *src;
+
+       if (!offset)
+               return -ENOSPC;
+
+       if (bio_chain) {
+               src = (void *)__get_free_page(__GFP_WAIT | __GFP_HIGH);
+               if (src) {
+                       memcpy(src, buf, PAGE_SIZE);
+               } else {
+                       WARN_ON_ONCE(1);
+                       bio_chain = NULL;       /* Go synchronous */
+                       src = buf;
                }
-               entry = swp_entry(root_swap, offset);
-               error = rw_swap_page_sync(WRITE, entry, page, bio_chain);
+       } else {
+               src = buf;
        }
-       return error;
+       return bio_write_page(offset, src, bio_chain);
 }
 
 /*
@@ -137,11 +225,11 @@ static int write_page(void *buf, unsigned long offset, struct bio **bio_chain)
  *     at a time.
  */
 
-#define MAP_PAGE_ENTRIES       (PAGE_SIZE / sizeof(long) - 1)
+#define MAP_PAGE_ENTRIES       (PAGE_SIZE / sizeof(sector_t) - 1)
 
 struct swap_map_page {
-       unsigned long           entries[MAP_PAGE_ENTRIES];
-       unsigned long           next_swap;
+       sector_t entries[MAP_PAGE_ENTRIES];
+       sector_t next_swap;
 };
 
 /**
@@ -151,7 +239,7 @@ struct swap_map_page {
 
 struct swap_map_handle {
        struct swap_map_page *cur;
-       unsigned long cur_swap;
+       sector_t cur_swap;
        struct bitmap_page *bitmap;
        unsigned int k;
 };
@@ -166,26 +254,6 @@ static void release_swap_writer(struct swap_map_handle *handle)
        handle->bitmap = NULL;
 }
 
-static void show_speed(struct timeval *start, struct timeval *stop,
-                       unsigned nr_pages, char *msg)
-{
-       s64 elapsed_centisecs64;
-       int centisecs;
-       int k;
-       int kps;
-
-       elapsed_centisecs64 = timeval_to_ns(stop) - timeval_to_ns(start);
-       do_div(elapsed_centisecs64, NSEC_PER_SEC / 100);
-       centisecs = elapsed_centisecs64;
-       if (centisecs == 0)
-               centisecs = 1;  /* avoid div-by-zero */
-       k = nr_pages * (PAGE_SIZE / 1024);
-       kps = (k * 100) / centisecs;
-       printk("%s %d kbytes in %d.%02d seconds (%d.%02d MB/s)\n", msg, k,
-                       centisecs / 100, centisecs % 100,
-                       kps / 1000, (kps % 1000) / 10);
-}
-
 static int get_swap_writer(struct swap_map_handle *handle)
 {
        handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_KERNEL);
@@ -196,7 +264,7 @@ static int get_swap_writer(struct swap_map_handle *handle)
                release_swap_writer(handle);
                return -ENOMEM;
        }
-       handle->cur_swap = alloc_swap_page(root_swap, handle->bitmap);
+       handle->cur_swap = alloc_swapdev_block(root_swap, handle->bitmap);
        if (!handle->cur_swap) {
                release_swap_writer(handle);
                return -ENOSPC;
@@ -205,43 +273,15 @@ static int get_swap_writer(struct swap_map_handle *handle)
        return 0;
 }
 
-static int wait_on_bio_chain(struct bio **bio_chain)
-{
-       struct bio *bio;
-       struct bio *next_bio;
-       int ret = 0;
-
-       if (bio_chain == NULL)
-               return 0;
-
-       bio = *bio_chain;
-       if (bio == NULL)
-               return 0;
-       while (bio) {
-               struct page *page;
-
-               next_bio = bio->bi_private;
-               page = bio->bi_io_vec[0].bv_page;
-               wait_on_page_locked(page);
-               if (!PageUptodate(page) || PageError(page))
-                       ret = -EIO;
-               put_page(page);
-               bio_put(bio);
-               bio = next_bio;
-       }
-       *bio_chain = NULL;
-       return ret;
-}
-
 static int swap_write_page(struct swap_map_handle *handle, void *buf,
                                struct bio **bio_chain)
 {
        int error = 0;
-       unsigned long offset;
+       sector_t offset;
 
        if (!handle->cur)
                return -EINVAL;
-       offset = alloc_swap_page(root_swap, handle->bitmap);
+       offset = alloc_swapdev_block(root_swap, handle->bitmap);
        error = write_page(buf, offset, bio_chain);
        if (error)
                return error;
@@ -250,7 +290,7 @@ static int swap_write_page(struct swap_map_handle *handle, void *buf,
                error = wait_on_bio_chain(bio_chain);
                if (error)
                        goto out;
-               offset = alloc_swap_page(root_swap, handle->bitmap);
+               offset = alloc_swapdev_block(root_swap, handle->bitmap);
                if (!offset)
                        return -ENOSPC;
                handle->cur->next_swap = offset;
@@ -261,7 +301,7 @@ static int swap_write_page(struct swap_map_handle *handle, void *buf,
                handle->cur_swap = offset;
                handle->k = 0;
        }
-out:
+ out:
        return error;
 }
 
@@ -315,7 +355,7 @@ static int save_image(struct swap_map_handle *handle,
                error = err2;
        if (!error)
                printk("\b\b\b\bdone\n");
-       show_speed(&start, &stop, nr_to_write, "Wrote");
+       swsusp_show_speed(&start, &stop, nr_to_write, "Wrote");
        return error;
 }
 
@@ -350,100 +390,50 @@ int swsusp_write(void)
        struct swsusp_info *header;
        int error;
 
-       if ((error = swsusp_swap_check())) {
+       error = swsusp_swap_check();
+       if (error) {
                printk(KERN_ERR "swsusp: Cannot find swap device, try "
                                "swapon -a.\n");
                return error;
        }
        memset(&snapshot, 0, sizeof(struct snapshot_handle));
        error = snapshot_read_next(&snapshot, PAGE_SIZE);
-       if (error < PAGE_SIZE)
-               return error < 0 ? error : -EFAULT;
+       if (error < PAGE_SIZE) {
+               if (error >= 0)
+                       error = -EFAULT;
+
+               goto out;
+       }
        header = (struct swsusp_info *)data_of(snapshot);
        if (!enough_swap(header->pages)) {
                printk(KERN_ERR "swsusp: Not enough free swap\n");
-               return -ENOSPC;
+               error = -ENOSPC;
+               goto out;
        }
        error = get_swap_writer(&handle);
        if (!error) {
-               unsigned long start = handle.cur_swap;
+               sector_t start = handle.cur_swap;
+
                error = swap_write_page(&handle, header, NULL);
                if (!error)
                        error = save_image(&handle, &snapshot,
                                        header->pages - 1);
+
                if (!error) {
                        flush_swap_writer(&handle);
                        printk("S");
-                       error = mark_swapfiles(swp_entry(root_swap, start));
+                       error = mark_swapfiles(start);
                        printk("|\n");
                }
        }
        if (error)
                free_all_swap_pages(root_swap, handle.bitmap);
        release_swap_writer(&handle);
+ out:
+       swsusp_close();
        return error;
 }
 
-static struct block_device *resume_bdev;
-
-/**
- *     submit - submit BIO request.
- *     @rw:    READ or WRITE.
- *     @off    physical offset of page.
- *     @page:  page we're reading or writing.
- *     @bio_chain: list of pending biod (for async reading)
- *
- *     Straight from the textbook - allocate and initialize the bio.
- *     If we're reading, make sure the page is marked as dirty.
- *     Then submit it and, if @bio_chain == NULL, wait.
- */
-static int submit(int rw, pgoff_t page_off, struct page *page,
-                       struct bio **bio_chain)
-{
-       struct bio *bio;
-
-       bio = bio_alloc(GFP_ATOMIC, 1);
-       if (!bio)
-               return -ENOMEM;
-       bio->bi_sector = page_off * (PAGE_SIZE >> 9);
-       bio->bi_bdev = resume_bdev;
-       bio->bi_end_io = end_swap_bio_read;
-
-       if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
-               printk("swsusp: ERROR: adding page to bio at %ld\n", page_off);
-               bio_put(bio);
-               return -EFAULT;
-       }
-
-       lock_page(page);
-       bio_get(bio);
-
-       if (bio_chain == NULL) {
-               submit_bio(rw | (1 << BIO_RW_SYNC), bio);
-               wait_on_page_locked(page);
-               if (rw == READ)
-                       bio_set_pages_dirty(bio);
-               bio_put(bio);
-       } else {
-               if (rw == READ)
-                       get_page(page); /* These pages are freed later */
-               bio->bi_private = *bio_chain;
-               *bio_chain = bio;
-               submit_bio(rw | (1 << BIO_RW_SYNC), bio);
-       }
-       return 0;
-}
-
-static int bio_read_page(pgoff_t page_off, void *addr, struct bio **bio_chain)
-{
-       return submit(READ, page_off, virt_to_page(addr), bio_chain);
-}
-
-static int bio_write_page(pgoff_t page_off, void *addr)
-{
-       return submit(WRITE, page_off, virt_to_page(addr), NULL);
-}
-
 /**
  *     The following functions allow us to read data using a swap map
  *     in a file-alike way
@@ -456,17 +446,18 @@ static void release_swap_reader(struct swap_map_handle *handle)
        handle->cur = NULL;
 }
 
-static int get_swap_reader(struct swap_map_handle *handle,
-                                      swp_entry_t start)
+static int get_swap_reader(struct swap_map_handle *handle, sector_t start)
 {
        int error;
 
-       if (!swp_offset(start))
+       if (!start)
                return -EINVAL;
-       handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_ATOMIC);
+
+       handle->cur = (struct swap_map_page *)get_zeroed_page(__GFP_WAIT | __GFP_HIGH);
        if (!handle->cur)
                return -ENOMEM;
-       error = bio_read_page(swp_offset(start), handle->cur, NULL);
+
+       error = bio_read_page(start, handle->cur, NULL);
        if (error) {
                release_swap_reader(handle);
                return error;
@@ -478,7 +469,7 @@ static int get_swap_reader(struct swap_map_handle *handle,
 static int swap_read_page(struct swap_map_handle *handle, void *buf,
                                struct bio **bio_chain)
 {
-       unsigned long offset;
+       sector_t offset;
        int error;
 
        if (!handle->cur)
@@ -547,11 +538,11 @@ static int load_image(struct swap_map_handle *handle,
                error = err2;
        if (!error) {
                printk("\b\b\b\bdone\n");
-               snapshot_free_unused_memory(snapshot);
+               snapshot_write_finalize(snapshot);
                if (!snapshot_image_loaded(snapshot))
                        error = -ENODATA;
        }
-       show_speed(&start, &stop, nr_to_read, "Read");
+       swsusp_show_speed(&start, &stop, nr_to_read, "Read");
        return error;
 }
 
@@ -600,12 +591,16 @@ int swsusp_check(void)
        if (!IS_ERR(resume_bdev)) {
                set_blocksize(resume_bdev, PAGE_SIZE);
                memset(&swsusp_header, 0, sizeof(swsusp_header));
-               if ((error = bio_read_page(0, &swsusp_header, NULL)))
+               error = bio_read_page(swsusp_resume_block,
+                                       &swsusp_header, NULL);
+               if (error)
                        return error;
+
                if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) {
                        memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10);
                        /* Reset swap signature now */
-                       error = bio_write_page(0, &swsusp_header);
+                       error = bio_write_page(swsusp_resume_block,
+                                               &swsusp_header, NULL);
                } else {
                        return -EINVAL;
                }
index 0b66659dc516f13eed980412dc196781ffa6892e..31aa0390c777d186652fe1b5dc3bfb4aafbaa338 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/bootmem.h>
 #include <linux/syscalls.h>
 #include <linux/highmem.h>
+#include <linux/time.h>
 
 #include "power.h"
 
@@ -64,10 +65,8 @@ int in_suspend __nosavedata = 0;
 
 #ifdef CONFIG_HIGHMEM
 unsigned int count_highmem_pages(void);
-int save_highmem(void);
 int restore_highmem(void);
 #else
-static inline int save_highmem(void) { return 0; }
 static inline int restore_highmem(void) { return 0; }
 static inline unsigned int count_highmem_pages(void) { return 0; }
 #endif
@@ -134,18 +133,18 @@ static int bitmap_set(struct bitmap_page *bitmap, unsigned long bit)
        return 0;
 }
 
-unsigned long alloc_swap_page(int swap, struct bitmap_page *bitmap)
+sector_t alloc_swapdev_block(int swap, struct bitmap_page *bitmap)
 {
        unsigned long offset;
 
        offset = swp_offset(get_swap_page_of_type(swap));
        if (offset) {
-               if (bitmap_set(bitmap, offset)) {
+               if (bitmap_set(bitmap, offset))
                        swap_free(swp_entry(swap, offset));
-                       offset = 0;
-               }
+               else
+                       return swapdev_block(swap, offset);
        }
-       return offset;
+       return 0;
 }
 
 void free_all_swap_pages(int swap, struct bitmap_page *bitmap)
@@ -165,6 +164,34 @@ void free_all_swap_pages(int swap, struct bitmap_page *bitmap)
        }
 }
 
+/**
+ *     swsusp_show_speed - print the time elapsed between two events represented by
+ *     @start and @stop
+ *
+ *     @nr_pages -     number of pages processed between @start and @stop
+ *     @msg -          introductory message to print
+ */
+
+void swsusp_show_speed(struct timeval *start, struct timeval *stop,
+                       unsigned nr_pages, char *msg)
+{
+       s64 elapsed_centisecs64;
+       int centisecs;
+       int k;
+       int kps;
+
+       elapsed_centisecs64 = timeval_to_ns(stop) - timeval_to_ns(start);
+       do_div(elapsed_centisecs64, NSEC_PER_SEC / 100);
+       centisecs = elapsed_centisecs64;
+       if (centisecs == 0)
+               centisecs = 1;  /* avoid div-by-zero */
+       k = nr_pages * (PAGE_SIZE / 1024);
+       kps = (k * 100) / centisecs;
+       printk("%s %d kbytes in %d.%02d seconds (%d.%02d MB/s)\n", msg, k,
+                       centisecs / 100, centisecs % 100,
+                       kps / 1000, (kps % 1000) / 10);
+}
+
 /**
  *     swsusp_shrink_memory -  Try to free as much memory as needed
  *
@@ -184,23 +211,37 @@ static inline unsigned long __shrink_memory(long tmp)
 
 int swsusp_shrink_memory(void)
 {
-       long size, tmp;
+       long tmp;
        struct zone *zone;
        unsigned long pages = 0;
        unsigned int i = 0;
        char *p = "-\\|/";
+       struct timeval start, stop;
 
        printk("Shrinking memory...  ");
+       do_gettimeofday(&start);
        do {
-               size = 2 * count_highmem_pages();
-               size += size / 50 + count_data_pages() + PAGES_FOR_IO;
+               long size, highmem_size;
+
+               highmem_size = count_highmem_pages();
+               size = count_data_pages() + PAGES_FOR_IO;
                tmp = size;
+               size += highmem_size;
                for_each_zone (zone)
-                       if (!is_highmem(zone) && populated_zone(zone)) {
-                               tmp -= zone->free_pages;
-                               tmp += zone->lowmem_reserve[ZONE_NORMAL];
-                               tmp += snapshot_additional_pages(zone);
+                       if (populated_zone(zone)) {
+                               if (is_highmem(zone)) {
+                                       highmem_size -= zone->free_pages;
+                               } else {
+                                       tmp -= zone->free_pages;
+                                       tmp += zone->lowmem_reserve[ZONE_NORMAL];
+                                       tmp += snapshot_additional_pages(zone);
+                               }
                        }
+
+               if (highmem_size < 0)
+                       highmem_size = 0;
+
+               tmp += highmem_size;
                if (tmp > 0) {
                        tmp = __shrink_memory(tmp);
                        if (!tmp)
@@ -212,7 +253,9 @@ int swsusp_shrink_memory(void)
                }
                printk("\b%c", p[i++%4]);
        } while (tmp > 0);
+       do_gettimeofday(&stop);
        printk("\bdone (%lu pages freed)\n", pages);
+       swsusp_show_speed(&start, &stop, pages, "Freed");
 
        return 0;
 }
@@ -223,6 +266,7 @@ int swsusp_suspend(void)
 
        if ((error = arch_prepare_suspend()))
                return error;
+
        local_irq_disable();
        /* At this point, device_suspend() has been called, but *not*
         * device_power_down(). We *must* device_power_down() now.
@@ -235,23 +279,16 @@ int swsusp_suspend(void)
                goto Enable_irqs;
        }
 
-       if ((error = save_highmem())) {
-               printk(KERN_ERR "swsusp: Not enough free pages for highmem\n");
-               goto Restore_highmem;
-       }
-
        save_processor_state();
        if ((error = swsusp_arch_suspend()))
                printk(KERN_ERR "Error %d suspending\n", error);
        /* Restore control flow magically appears here */
        restore_processor_state();
-Restore_highmem:
-       restore_highmem();
        /* NOTE:  device_power_up() is just a resume() for devices
         * that suspended with irqs off ... no overall powerup.
         */
        device_power_up();
-Enable_irqs:
+ Enable_irqs:
        local_irq_enable();
        return error;
 }
@@ -268,18 +305,23 @@ int swsusp_resume(void)
                printk(KERN_ERR "Some devices failed to power down, very bad\n");
        /* We'll ignore saved state, but this gets preempt count (etc) right */
        save_processor_state();
-       error = swsusp_arch_resume();
-       /* Code below is only ever reached in case of failure. Otherwise
-        * execution continues at place where swsusp_arch_suspend was called
-         */
-       BUG_ON(!error);
+       error = restore_highmem();
+       if (!error) {
+               error = swsusp_arch_resume();
+               /* The code below is only ever reached in case of a failure.
+                * Otherwise execution continues at place where
+                * swsusp_arch_suspend() was called
+                */
+               BUG_ON(!error);
+               /* This call to restore_highmem() undos the previous one */
+               restore_highmem();
+       }
        /* The only reason why swsusp_arch_resume() can fail is memory being
         * very tight, so we have to free it as soon as we can to avoid
         * subsequent failures
         */
        swsusp_free();
        restore_processor_state();
-       restore_highmem();
        touch_softlockup_watchdog();
        device_power_up();
        local_irq_enable();
index d991d3b0e5a4e326ea29b6b7fc50c4a926dd5e3e..89443b85163baa012d5a785c3491c21fe047ec75 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/suspend.h>
 #include <linux/syscalls.h>
+#include <linux/reboot.h>
 #include <linux/string.h>
 #include <linux/device.h>
 #include <linux/miscdevice.h>
@@ -21,6 +22,7 @@
 #include <linux/fs.h>
 #include <linux/console.h>
 #include <linux/cpu.h>
+#include <linux/freezer.h>
 
 #include <asm/uaccess.h>
 
@@ -54,7 +56,8 @@ static int snapshot_open(struct inode *inode, struct file *filp)
        filp->private_data = data;
        memset(&data->handle, 0, sizeof(struct snapshot_handle));
        if ((filp->f_flags & O_ACCMODE) == O_RDONLY) {
-               data->swap = swsusp_resume_device ? swap_type_of(swsusp_resume_device) : -1;
+               data->swap = swsusp_resume_device ?
+                               swap_type_of(swsusp_resume_device, 0) : -1;
                data->mode = O_RDONLY;
        } else {
                data->swap = -1;
@@ -76,10 +79,10 @@ static int snapshot_release(struct inode *inode, struct file *filp)
        free_all_swap_pages(data->swap, data->bitmap);
        free_bitmap(data->bitmap);
        if (data->frozen) {
-               down(&pm_sem);
+               mutex_lock(&pm_mutex);
                thaw_processes();
                enable_nonboot_cpus();
-               up(&pm_sem);
+               mutex_unlock(&pm_mutex);
        }
        atomic_inc(&device_available);
        return 0;
@@ -124,7 +127,8 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
 {
        int error = 0;
        struct snapshot_data *data;
-       loff_t offset, avail;
+       loff_t avail;
+       sector_t offset;
 
        if (_IOC_TYPE(cmd) != SNAPSHOT_IOC_MAGIC)
                return -ENOTTY;
@@ -140,7 +144,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
        case SNAPSHOT_FREEZE:
                if (data->frozen)
                        break;
-               down(&pm_sem);
+               mutex_lock(&pm_mutex);
                error = disable_nonboot_cpus();
                if (!error) {
                        error = freeze_processes();
@@ -150,7 +154,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
                                error = -EBUSY;
                        }
                }
-               up(&pm_sem);
+               mutex_unlock(&pm_mutex);
                if (!error)
                        data->frozen = 1;
                break;
@@ -158,10 +162,10 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
        case SNAPSHOT_UNFREEZE:
                if (!data->frozen)
                        break;
-               down(&pm_sem);
+               mutex_lock(&pm_mutex);
                thaw_processes();
                enable_nonboot_cpus();
-               up(&pm_sem);
+               mutex_unlock(&pm_mutex);
                data->frozen = 0;
                break;
 
@@ -170,7 +174,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
                        error = -EPERM;
                        break;
                }
-               down(&pm_sem);
+               mutex_lock(&pm_mutex);
                /* Free memory before shutting down devices. */
                error = swsusp_shrink_memory();
                if (!error) {
@@ -183,7 +187,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
                        }
                        resume_console();
                }
-               up(&pm_sem);
+               mutex_unlock(&pm_mutex);
                if (!error)
                        error = put_user(in_suspend, (unsigned int __user *)arg);
                if (!error)
@@ -191,13 +195,13 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
                break;
 
        case SNAPSHOT_ATOMIC_RESTORE:
+               snapshot_write_finalize(&data->handle);
                if (data->mode != O_WRONLY || !data->frozen ||
                    !snapshot_image_loaded(&data->handle)) {
                        error = -EPERM;
                        break;
                }
-               snapshot_free_unused_memory(&data->handle);
-               down(&pm_sem);
+               mutex_lock(&pm_mutex);
                pm_prepare_console();
                suspend_console();
                error = device_suspend(PMSG_PRETHAW);
@@ -207,7 +211,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
                }
                resume_console();
                pm_restore_console();
-               up(&pm_sem);
+               mutex_unlock(&pm_mutex);
                break;
 
        case SNAPSHOT_FREE:
@@ -238,10 +242,10 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
                                break;
                        }
                }
-               offset = alloc_swap_page(data->swap, data->bitmap);
+               offset = alloc_swapdev_block(data->swap, data->bitmap);
                if (offset) {
                        offset <<= PAGE_SHIFT;
-                       error = put_user(offset, (loff_t __user *)arg);
+                       error = put_user(offset, (sector_t __user *)arg);
                } else {
                        error = -ENOSPC;
                }
@@ -264,7 +268,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
                         * so we need to recode them
                         */
                        if (old_decode_dev(arg)) {
-                               data->swap = swap_type_of(old_decode_dev(arg));
+                               data->swap = swap_type_of(old_decode_dev(arg), 0);
                                if (data->swap < 0)
                                        error = -ENODEV;
                        } else {
@@ -282,7 +286,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
                        break;
                }
 
-               if (down_trylock(&pm_sem)) {
+               if (!mutex_trylock(&pm_mutex)) {
                        error = -EBUSY;
                        break;
                }
@@ -309,8 +313,66 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
                if (pm_ops->finish)
                        pm_ops->finish(PM_SUSPEND_MEM);
 
-OutS3:
-               up(&pm_sem);
+ OutS3:
+               mutex_unlock(&pm_mutex);
+               break;
+
+       case SNAPSHOT_PMOPS:
+               switch (arg) {
+
+               case PMOPS_PREPARE:
+                       if (pm_ops->prepare) {
+                               error = pm_ops->prepare(PM_SUSPEND_DISK);
+                       }
+                       break;
+
+               case PMOPS_ENTER:
+                       kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK);
+                       error = pm_ops->enter(PM_SUSPEND_DISK);
+                       break;
+
+               case PMOPS_FINISH:
+                       if (pm_ops && pm_ops->finish) {
+                               pm_ops->finish(PM_SUSPEND_DISK);
+                       }
+                       break;
+
+               default:
+                       printk(KERN_ERR "SNAPSHOT_PMOPS: invalid argument %ld\n", arg);
+                       error = -EINVAL;
+
+               }
+               break;
+
+       case SNAPSHOT_SET_SWAP_AREA:
+               if (data->bitmap) {
+                       error = -EPERM;
+               } else {
+                       struct resume_swap_area swap_area;
+                       dev_t swdev;
+
+                       error = copy_from_user(&swap_area, (void __user *)arg,
+                                       sizeof(struct resume_swap_area));
+                       if (error) {
+                               error = -EFAULT;
+                               break;
+                       }
+
+                       /*
+                        * User space encodes device types as two-byte values,
+                        * so we need to recode them
+                        */
+                       swdev = old_decode_dev(swap_area.dev);
+                       if (swdev) {
+                               offset = swap_area.offset;
+                               data->swap = swap_type_of(swdev, offset);
+                               if (data->swap < 0)
+                                       error = -ENODEV;
+                       } else {
+                               data->swap = -1;
+                               error = -EINVAL;
+                       }
+               }
                break;
 
        default:
@@ -321,7 +383,7 @@ OutS3:
        return error;
 }
 
-static struct file_operations snapshot_fops = {
+static const struct file_operations snapshot_fops = {
        .open = snapshot_open,
        .release = snapshot_release,
        .read = snapshot_read,
index 66426552fbfef24e49442ed08f8d595930feca32..185bb45eacf7289db6b99039634ad9f9f6fa5d96 100644 (file)
@@ -53,8 +53,6 @@ int console_printk[4] = {
        DEFAULT_CONSOLE_LOGLEVEL,       /* default_console_loglevel */
 };
 
-EXPORT_UNUSED_SYMBOL(console_printk);  /*  June 2006  */
-
 /*
  * Low lever drivers may need that to know if they can schedule in
  * their unblank() callback or not. So let's export it.
@@ -335,13 +333,25 @@ static void __call_console_drivers(unsigned long start, unsigned long end)
        }
 }
 
+static int __read_mostly ignore_loglevel;
+
+int __init ignore_loglevel_setup(char *str)
+{
+       ignore_loglevel = 1;
+       printk(KERN_INFO "debug: ignoring loglevel setting.\n");
+
+       return 1;
+}
+
+__setup("ignore_loglevel", ignore_loglevel_setup);
+
 /*
  * Write out chars from start to end - 1 inclusive
  */
 static void _call_console_drivers(unsigned long start,
                                unsigned long end, int msg_log_level)
 {
-       if (msg_log_level < console_loglevel &&
+       if ((msg_log_level < console_loglevel || ignore_loglevel) &&
                        console_drivers && start != end) {
                if ((start & LOG_BUF_MASK) > (end & LOG_BUF_MASK)) {
                        /* wrapped write */
@@ -631,12 +641,7 @@ EXPORT_SYMBOL(vprintk);
 
 asmlinkage long sys_syslog(int type, char __user *buf, int len)
 {
-       return 0;
-}
-
-int do_syslog(int type, char __user *buf, int len)
-{
-       return 0;
+       return -ENOSYS;
 }
 
 static void call_console_drivers(unsigned long start, unsigned long end)
@@ -777,7 +782,6 @@ int is_console_locked(void)
 {
        return console_locked;
 }
-EXPORT_UNUSED_SYMBOL(is_console_locked);  /*  June 2006  */
 
 /**
  * release_console_sem - unlock the console system
index f940b462eec9a34eb7c3cad4ee958a2ec0f1f5bc..fb5e03d57e9dac86b7aadb3b7c5496a467d5ba15 100644 (file)
@@ -40,7 +40,7 @@ int (*timer_hook)(struct pt_regs *) __read_mostly;
 
 static atomic_t *prof_buffer;
 static unsigned long prof_len, prof_shift;
-static int prof_on __read_mostly;
+int prof_on __read_mostly;
 static cpumask_t prof_cpu_mask = CPU_MASK_ALL;
 #ifdef CONFIG_SMP
 static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits);
@@ -51,9 +51,19 @@ static DEFINE_MUTEX(profile_flip_mutex);
 static int __init profile_setup(char * str)
 {
        static char __initdata schedstr[] = "schedule";
+       static char __initdata sleepstr[] = "sleep";
        int par;
 
-       if (!strncmp(str, schedstr, strlen(schedstr))) {
+       if (!strncmp(str, sleepstr, strlen(sleepstr))) {
+               prof_on = SLEEP_PROFILING;
+               if (str[strlen(sleepstr)] == ',')
+                       str += strlen(sleepstr) + 1;
+               if (get_option(&str, &par))
+                       prof_shift = par;
+               printk(KERN_INFO
+                       "kernel sleep profiling enabled (shift: %ld)\n",
+                       prof_shift);
+       } else if (!strncmp(str, sleepstr, strlen(sleepstr))) {
                prof_on = SCHED_PROFILING;
                if (str[strlen(schedstr)] == ',')
                        str += strlen(schedstr) + 1;
@@ -204,7 +214,8 @@ EXPORT_SYMBOL_GPL(profile_event_unregister);
  * positions to which hits are accounted during short intervals (e.g.
  * several seconds) is usually very small. Exclusion from buffer
  * flipping is provided by interrupt disablement (note that for
- * SCHED_PROFILING profile_hit() may be called from process context).
+ * SCHED_PROFILING or SLEEP_PROFILING profile_hit() may be called from
+ * process context).
  * The hash function is meant to be lightweight as opposed to strong,
  * and was vaguely inspired by ppc64 firmware-supported inverted
  * pagetable hash functions, but uses a full hashtable full of finite
@@ -257,7 +268,7 @@ static void profile_discard_flip_buffers(void)
        mutex_unlock(&profile_flip_mutex);
 }
 
-void profile_hit(int type, void *__pc)
+void profile_hits(int type, void *__pc, unsigned int nr_hits)
 {
        unsigned long primary, secondary, flags, pc = (unsigned long)__pc;
        int i, j, cpu;
@@ -274,21 +285,31 @@ void profile_hit(int type, void *__pc)
                put_cpu();
                return;
        }
+       /*
+        * We buffer the global profiler buffer into a per-CPU
+        * queue and thus reduce the number of global (and possibly
+        * NUMA-alien) accesses. The write-queue is self-coalescing:
+        */
        local_irq_save(flags);
        do {
                for (j = 0; j < PROFILE_GRPSZ; ++j) {
                        if (hits[i + j].pc == pc) {
-                               hits[i + j].hits++;
+                               hits[i + j].hits += nr_hits;
                                goto out;
                        } else if (!hits[i + j].hits) {
                                hits[i + j].pc = pc;
-                               hits[i + j].hits = 1;
+                               hits[i + j].hits = nr_hits;
                                goto out;
                        }
                }
                i = (i + secondary) & (NR_PROFILE_HIT - 1);
        } while (i != primary);
-       atomic_inc(&prof_buffer[pc]);
+
+       /*
+        * Add the current hit(s) and flush the write-queue out
+        * to the global buffer:
+        */
+       atomic_add(nr_hits, &prof_buffer[pc]);
        for (i = 0; i < NR_PROFILE_HIT; ++i) {
                atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
                hits[i].pc = hits[i].hits = 0;
@@ -298,7 +319,6 @@ out:
        put_cpu();
 }
 
-#ifdef CONFIG_HOTPLUG_CPU
 static int __devinit profile_cpu_callback(struct notifier_block *info,
                                        unsigned long action, void *__cpu)
 {
@@ -351,19 +371,19 @@ static int __devinit profile_cpu_callback(struct notifier_block *info,
        }
        return NOTIFY_OK;
 }
-#endif /* CONFIG_HOTPLUG_CPU */
 #else /* !CONFIG_SMP */
 #define profile_flip_buffers()         do { } while (0)
 #define profile_discard_flip_buffers() do { } while (0)
+#define profile_cpu_callback           NULL
 
-void profile_hit(int type, void *__pc)
+void profile_hits(int type, void *__pc, unsigned int nr_hits)
 {
        unsigned long pc;
 
        if (prof_on != type || !prof_buffer)
                return;
        pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
-       atomic_inc(&prof_buffer[min(pc, prof_len - 1)]);
+       atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
 }
 #endif /* !CONFIG_SMP */
 
@@ -442,7 +462,8 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
        read = 0;
 
        while (p < sizeof(unsigned int) && count > 0) {
-               put_user(*((char *)(&sample_step)+p),buf);
+               if (put_user(*((char *)(&sample_step)+p),buf))
+                       return -EFAULT;
                buf++; p++; count--; read++;
        }
        pnt = (char *)prof_buffer + p - sizeof(atomic_t);
@@ -480,7 +501,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
        return count;
 }
 
-static struct file_operations proc_profile_operations = {
+static const struct file_operations proc_profile_operations = {
        .read           = read_profile,
        .write          = write_profile,
 };
index 26bb5ffe1ef14ef61824180dd6163acdc104006d..3554b76da84cf08ebc2808b5f2a237a362e52330 100644 (file)
@@ -235,12 +235,14 @@ static void rcu_do_batch(struct rcu_data *rdp)
 
        list = rdp->donelist;
        while (list) {
-               next = rdp->donelist = list->next;
+               next = list->next;
+               prefetch(next);
                list->func(list);
                list = next;
                if (++count >= rdp->blimit)
                        break;
        }
+       rdp->donelist = list;
 
        local_irq_disable();
        rdp->qlen -= count;
index e2bda18f6f42779144829a2150b4e6fb8ac4b338..c52f981ea0086e569b37c5195cf291c6be55d446 100644 (file)
@@ -401,7 +401,7 @@ static void srcu_torture_cleanup(void)
        cleanup_srcu_struct(&srcu_ctl);
 }
 
-static int srcu_torture_read_lock(void)
+static int srcu_torture_read_lock(void) __acquires(&srcu_ctl)
 {
        return srcu_read_lock(&srcu_ctl);
 }
@@ -419,7 +419,7 @@ static void srcu_read_delay(struct rcu_random_state *rrsp)
                schedule_timeout_interruptible(longdelay);
 }
 
-static void srcu_torture_read_unlock(int idx)
+static void srcu_torture_read_unlock(int idx) __releases(&srcu_ctl)
 {
        srcu_read_unlock(&srcu_ctl, idx);
 }
index 2b92e8ece85be3074c2cb63f2588a1f311b95ae7..818e514729cf0f033d4b5bc98cfd7570a8879ce2 100644 (file)
@@ -959,7 +959,7 @@ static inline ssize_t relay_file_read_subbufs(struct file *filp,
        if (!desc->count)
                return 0;
 
-       mutex_lock(&filp->f_dentry->d_inode->i_mutex);
+       mutex_lock(&filp->f_path.dentry->d_inode->i_mutex);
        do {
                if (!relay_file_read_avail(buf, *ppos))
                        break;
@@ -979,7 +979,7 @@ static inline ssize_t relay_file_read_subbufs(struct file *filp,
                        *ppos = relay_file_read_end_pos(buf, read_start, ret);
                }
        } while (desc->count && ret);
-       mutex_unlock(&filp->f_dentry->d_inode->i_mutex);
+       mutex_unlock(&filp->f_path.dentry->d_inode->i_mutex);
 
        return desc->written;
 }
@@ -1013,7 +1013,7 @@ static ssize_t relay_file_sendfile(struct file *filp,
                                       actor, &desc);
 }
 
-struct file_operations relay_file_operations = {
+const struct file_operations relay_file_operations = {
        .open           = relay_file_open,
        .poll           = relay_file_poll,
        .mmap           = relay_file_mmap,
index 6de60c12143e63f539701c3bc1687f3f21d0df9d..7b9a497419d9501631e5a524582d6b812fb5e841 100644 (file)
@@ -88,7 +88,7 @@ static int r_show(struct seq_file *m, void *v)
        return 0;
 }
 
-static struct seq_operations resource_op = {
+static const struct seq_operations resource_op = {
        .start  = r_start,
        .next   = r_next,
        .stop   = r_stop,
@@ -115,14 +115,14 @@ static int iomem_open(struct inode *inode, struct file *file)
        return res;
 }
 
-static struct file_operations proc_ioports_operations = {
+static const struct file_operations proc_ioports_operations = {
        .open           = ioports_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
        .release        = seq_release,
 };
 
-static struct file_operations proc_iomem_operations = {
+static const struct file_operations proc_iomem_operations = {
        .open           = iomem_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
index 6dcea9dd8c94a23ffa4fcb1dd21ea6ba685692bf..015fc633c96c7338f8ffb3e01cc1ce3a17e72030 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/spinlock.h>
 #include <linux/sysdev.h>
 #include <linux/timer.h>
+#include <linux/freezer.h>
 
 #include "rtmutex.h"
 
index 3399701c680e392f46e21829cee8da0bf5482303..f385eff4682d7fbf169accde4c93d0bf4f42fd83 100644 (file)
@@ -34,7 +34,7 @@
 #include <linux/security.h>
 #include <linux/notifier.h>
 #include <linux/profile.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 #include <linux/vmalloc.h>
 #include <linux/blkdev.h>
 #include <linux/delay.h>
@@ -505,7 +505,7 @@ static int schedstat_open(struct inode *inode, struct file *file)
        return res;
 }
 
-struct file_operations proc_schedstat_operations = {
+const struct file_operations proc_schedstat_operations = {
        .open    = schedstat_open,
        .read    = seq_read,
        .llseek  = seq_lseek,
@@ -948,6 +948,17 @@ static void activate_task(struct task_struct *p, struct rq *rq, int local)
        }
 #endif
 
+       /*
+        * Sleep time is in units of nanosecs, so shift by 20 to get a
+        * milliseconds-range estimation of the amount of time that the task
+        * spent sleeping:
+        */
+       if (unlikely(prof_on == SLEEP_PROFILING)) {
+               if (p->state == TASK_UNINTERRUPTIBLE)
+                       profile_hits(SLEEP_PROFILING, (void *)get_wchan(p),
+                                    (now - p->timestamp) >> 20);
+       }
+
        if (!rt_task(p))
                p->prio = recalc_task_prio(p, now);
 
@@ -3333,6 +3344,7 @@ asmlinkage void __sched schedule(void)
                printk(KERN_ERR "BUG: scheduling while atomic: "
                        "%s/0x%08x/%d\n",
                        current->comm, preempt_count(), current->pid);
+               debug_show_held_locks(current);
                dump_stack();
        }
        profile_hit(SCHED_PROFILING, __builtin_return_address(0));
@@ -4804,18 +4816,18 @@ static void show_task(struct task_struct *p)
                show_stack(p, NULL);
 }
 
-void show_state(void)
+void show_state_filter(unsigned long state_filter)
 {
        struct task_struct *g, *p;
 
 #if (BITS_PER_LONG == 32)
        printk("\n"
-              "                                               sibling\n");
-       printk("  task             PC      pid father child younger older\n");
+              "                         free                        sibling\n");
+       printk("  task             PC    stack   pid father child younger older\n");
 #else
        printk("\n"
-              "                                                       sibling\n");
-       printk("  task                 PC          pid father child younger older\n");
+              "                                 free                        sibling\n");
+       printk("  task                 PC        stack   pid father child younger older\n");
 #endif
        read_lock(&tasklist_lock);
        do_each_thread(g, p) {
@@ -4824,11 +4836,16 @@ void show_state(void)
                 * console might take alot of time:
                 */
                touch_nmi_watchdog();
-               show_task(p);
+               if (p->state & state_filter)
+                       show_task(p);
        } while_each_thread(g, p);
 
        read_unlock(&tasklist_lock);
-       debug_show_all_locks();
+       /*
+        * Only show locks if all tasks are dumped:
+        */
+       if (state_filter == -1)
+               debug_show_all_locks();
 }
 
 /**
@@ -6723,8 +6740,6 @@ SYSDEV_ATTR(sched_smt_power_savings, 0644, sched_smt_power_savings_show,
            sched_smt_power_savings_store);
 #endif
 
-
-#ifdef CONFIG_HOTPLUG_CPU
 /*
  * Force a reinitialization of the sched domains hierarchy.  The domains
  * and groups cannot be updated in place without racing with the balancing
@@ -6757,7 +6772,6 @@ static int update_sched_domains(struct notifier_block *nfb,
 
        return NOTIFY_OK;
 }
-#endif
 
 void __init sched_init_smp(void)
 {
@@ -6867,6 +6881,7 @@ void __might_sleep(char *file, int line)
                                " context at %s:%d\n", file, line);
                printk("in_atomic():%d, irqs_disabled():%d\n",
                        in_atomic(), irqs_disabled());
+               debug_show_held_locks(current);
                dump_stack();
        }
 #endif
index df18c167a2a72d67d76cabc1768b741c12ed5e7e..1921ffdc5e777eee98081639ff6960b9baf49010 100644 (file)
 #include <linux/ptrace.h>
 #include <linux/signal.h>
 #include <linux/capability.h>
+#include <linux/freezer.h>
+#include <linux/pid_namespace.h>
+#include <linux/nsproxy.h>
+
 #include <asm/param.h>
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
@@ -33,7 +37,7 @@
  * SLAB caches for signal bits.
  */
 
-static kmem_cache_t *sigqueue_cachep;
+static struct kmem_cache *sigqueue_cachep;
 
 /*
  * In POSIX a signal is sent either to a specific thread (Linux task)
@@ -582,7 +586,7 @@ static int check_kill_permission(int sig, struct siginfo *info,
        error = -EPERM;
        if ((info == SEND_SIG_NOINFO || (!is_si_special(info) && SI_FROMUSER(info)))
            && ((sig != SIGCONT) ||
-               (current->signal->session != t->signal->session))
+               (process_session(current) != process_session(t)))
            && (current->euid ^ t->suid) && (current->euid ^ t->uid)
            && (current->uid ^ t->suid) && (current->uid ^ t->uid)
            && !capable(CAP_KILL))
@@ -1133,8 +1137,7 @@ int kill_pid_info(int sig, struct siginfo *info, struct pid *pid)
        return error;
 }
 
-int
-kill_proc_info(int sig, struct siginfo *info, pid_t pid)
+static int kill_proc_info(int sig, struct siginfo *info, pid_t pid)
 {
        int error;
        rcu_read_lock();
@@ -1877,8 +1880,12 @@ relock:
                if (sig_kernel_ignore(signr)) /* Default is nothing. */
                        continue;
 
-               /* Init gets no signals it doesn't want.  */
-               if (current == child_reaper)
+               /*
+                * Init of a pid space gets no signals it doesn't want from
+                * within that pid space. It can of course get signals from
+                * its parent pid space.
+                */
+               if (current == child_reaper(current))
                        continue;
 
                if (sig_kernel_stop(signr)) {
index bf25015dce162a541059c051567c3569069985b9..918e52df090e88ee0a03096bee651e6c3a4d6dce 100644 (file)
@@ -574,8 +574,6 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
 
        switch (action) {
        case CPU_UP_PREPARE:
-               BUG_ON(per_cpu(tasklet_vec, hotcpu).list);
-               BUG_ON(per_cpu(tasklet_hi_vec, hotcpu).list);
                p = kthread_create(ksoftirqd, hcpu, "ksoftirqd/%d", hotcpu);
                if (IS_ERR(p)) {
                        printk("ksoftirqd for %i failed\n", hotcpu);
index c87b461de38dc1b22e2c1597b27b422d6d409932..c7675c1bfdf24e8c9d45b22e67da5c5679ba662b 100644 (file)
@@ -1102,14 +1102,14 @@ asmlinkage long sys_setreuid(uid_t ruid, uid_t euid)
 asmlinkage long sys_setuid(uid_t uid)
 {
        int old_euid = current->euid;
-       int old_ruid, old_suid, new_ruid, new_suid;
+       int old_ruid, old_suid, new_suid;
        int retval;
 
        retval = security_task_setuid(uid, (uid_t)-1, (uid_t)-1, LSM_SETID_ID);
        if (retval)
                return retval;
 
-       old_ruid = new_ruid = current->uid;
+       old_ruid = current->uid;
        old_suid = current->suid;
        new_suid = old_suid;
        
@@ -1381,7 +1381,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
 
        if (p->real_parent == group_leader) {
                err = -EPERM;
-               if (p->signal->session != group_leader->signal->session)
+               if (process_session(p) != process_session(group_leader))
                        goto out;
                err = -EACCES;
                if (p->did_exec)
@@ -1397,16 +1397,13 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
                goto out;
 
        if (pgid != pid) {
-               struct task_struct *p;
+               struct task_struct *g =
+                       find_task_by_pid_type(PIDTYPE_PGID, pgid);
 
-               do_each_task_pid(pgid, PIDTYPE_PGID, p) {
-                       if (p->signal->session == group_leader->signal->session)
-                               goto ok_pgid;
-               } while_each_task_pid(pgid, PIDTYPE_PGID, p);
-               goto out;
+               if (!g || process_session(g) != process_session(group_leader))
+                       goto out;
        }
 
-ok_pgid:
        err = security_task_setpgid(p, pgid);
        if (err)
                goto out;
@@ -1459,7 +1456,7 @@ asmlinkage long sys_getpgrp(void)
 asmlinkage long sys_getsid(pid_t pid)
 {
        if (!pid)
-               return current->signal->session;
+               return process_session(current);
        else {
                int retval;
                struct task_struct *p;
@@ -1471,7 +1468,7 @@ asmlinkage long sys_getsid(pid_t pid)
                if (p) {
                        retval = security_task_getsid(p);
                        if (!retval)
-                               retval = p->signal->session;
+                               retval = process_session(p);
                }
                read_unlock(&tasklist_lock);
                return retval;
@@ -1484,7 +1481,6 @@ asmlinkage long sys_setsid(void)
        pid_t session;
        int err = -EPERM;
 
-       mutex_lock(&tty_mutex);
        write_lock_irq(&tasklist_lock);
 
        /* Fail if I am already a session leader */
@@ -1504,12 +1500,15 @@ asmlinkage long sys_setsid(void)
 
        group_leader->signal->leader = 1;
        __set_special_pids(session, session);
+
+       spin_lock(&group_leader->sighand->siglock);
        group_leader->signal->tty = NULL;
        group_leader->signal->tty_old_pgrp = 0;
+       spin_unlock(&group_leader->sighand->siglock);
+
        err = process_group(group_leader);
 out:
        write_unlock_irq(&tasklist_lock);
-       mutex_unlock(&tty_mutex);
        return err;
 }
 
index 09e569f4792be6a80e08924e6ef98245b70f6d95..025fcb3c66f87ce7b81c6dc6b3271dc28cbd5085 100644 (file)
@@ -54,6 +54,7 @@ extern int proc_nr_files(ctl_table *table, int write, struct file *filp,
 
 #ifdef CONFIG_X86
 #include <asm/nmi.h>
+#include <asm/stacktrace.h>
 #endif
 
 #if defined(CONFIG_SYSCTL)
@@ -91,7 +92,9 @@ extern char modprobe_path[];
 extern int sg_big_buff;
 #endif
 #ifdef CONFIG_SYSVIPC
-static int proc_do_ipc_string(ctl_table *table, int write, struct file *filp,
+static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp,
+               void __user *buffer, size_t *lenp, loff_t *ppos);
+static int proc_ipc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
                void __user *buffer, size_t *lenp, loff_t *ppos);
 #endif
 
@@ -136,6 +139,16 @@ static int parse_table(int __user *, int, void __user *, size_t __user *,
 static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
                  void __user *buffer, size_t *lenp, loff_t *ppos);
 
+static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
+                 void __user *oldval, size_t __user *oldlenp,
+                 void __user *newval, size_t newlen, void **context);
+
+#ifdef CONFIG_SYSVIPC
+static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
+                 void __user *oldval, size_t __user *oldlenp,
+                 void __user *newval, size_t newlen, void **context);
+#endif
+
 #ifdef CONFIG_PROC_SYSCTL
 static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp,
                  void __user *buffer, size_t *lenp, loff_t *ppos);
@@ -162,6 +175,40 @@ extern ctl_table inotify_table[];
 int sysctl_legacy_va_layout;
 #endif
 
+static void *get_uts(ctl_table *table, int write)
+{
+       char *which = table->data;
+#ifdef CONFIG_UTS_NS
+       struct uts_namespace *uts_ns = current->nsproxy->uts_ns;
+       which = (which - (char *)&init_uts_ns) + (char *)uts_ns;
+#endif
+       if (!write)
+               down_read(&uts_sem);
+       else
+               down_write(&uts_sem);
+       return which;
+}
+
+static void put_uts(ctl_table *table, int write, void *which)
+{
+       if (!write)
+               up_read(&uts_sem);
+       else
+               up_write(&uts_sem);
+}
+
+#ifdef CONFIG_SYSVIPC
+static void *get_ipc(ctl_table *table, int write)
+{
+       char *which = table->data;
+       struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns;
+       which = (which - (char *)&init_ipc_ns) + (char *)ipc_ns;
+       return which;
+}
+#else
+#define get_ipc(T,W) ((T)->data)
+#endif
+
 /* /proc declarations: */
 
 #ifdef CONFIG_PROC_SYSCTL
@@ -170,7 +217,7 @@ static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
 static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
 static int proc_opensys(struct inode *, struct file *);
 
-struct file_operations proc_sys_file_operations = {
+const struct file_operations proc_sys_file_operations = {
        .open           = proc_opensys,
        .read           = proc_readsys,
        .write          = proc_writesys,
@@ -228,7 +275,6 @@ static ctl_table root_table[] = {
 };
 
 static ctl_table kern_table[] = {
-#ifndef CONFIG_UTS_NS
        {
                .ctl_name       = KERN_OSTYPE,
                .procname       = "ostype",
@@ -236,7 +282,7 @@ static ctl_table kern_table[] = {
                .maxlen         = sizeof(init_uts_ns.name.sysname),
                .mode           = 0444,
                .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
+               .strategy       = &sysctl_uts_string,
        },
        {
                .ctl_name       = KERN_OSRELEASE,
@@ -245,7 +291,7 @@ static ctl_table kern_table[] = {
                .maxlen         = sizeof(init_uts_ns.name.release),
                .mode           = 0444,
                .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
+               .strategy       = &sysctl_uts_string,
        },
        {
                .ctl_name       = KERN_VERSION,
@@ -254,7 +300,7 @@ static ctl_table kern_table[] = {
                .maxlen         = sizeof(init_uts_ns.name.version),
                .mode           = 0444,
                .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
+               .strategy       = &sysctl_uts_string,
        },
        {
                .ctl_name       = KERN_NODENAME,
@@ -263,7 +309,7 @@ static ctl_table kern_table[] = {
                .maxlen         = sizeof(init_uts_ns.name.nodename),
                .mode           = 0644,
                .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
+               .strategy       = &sysctl_uts_string,
        },
        {
                .ctl_name       = KERN_DOMAINNAME,
@@ -272,56 +318,8 @@ static ctl_table kern_table[] = {
                .maxlen         = sizeof(init_uts_ns.name.domainname),
                .mode           = 0644,
                .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
-       },
-#else  /* !CONFIG_UTS_NS */
-       {
-               .ctl_name       = KERN_OSTYPE,
-               .procname       = "ostype",
-               .data           = NULL,
-               /* could maybe use __NEW_UTS_LEN here? */
-               .maxlen         = FIELD_SIZEOF(struct new_utsname, sysname),
-               .mode           = 0444,
-               .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
+               .strategy       = &sysctl_uts_string,
        },
-       {
-               .ctl_name       = KERN_OSRELEASE,
-               .procname       = "osrelease",
-               .data           = NULL,
-               .maxlen         = FIELD_SIZEOF(struct new_utsname, release),
-               .mode           = 0444,
-               .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
-       },
-       {
-               .ctl_name       = KERN_VERSION,
-               .procname       = "version",
-               .data           = NULL,
-               .maxlen         = FIELD_SIZEOF(struct new_utsname, version),
-               .mode           = 0444,
-               .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
-       },
-       {
-               .ctl_name       = KERN_NODENAME,
-               .procname       = "hostname",
-               .data           = NULL,
-               .maxlen         = FIELD_SIZEOF(struct new_utsname, nodename),
-               .mode           = 0644,
-               .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
-       },
-       {
-               .ctl_name       = KERN_DOMAINNAME,
-               .procname       = "domainname",
-               .data           = NULL,
-               .maxlen         = FIELD_SIZEOF(struct new_utsname, domainname),
-               .mode           = 0644,
-               .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
-       },
-#endif /* !CONFIG_UTS_NS */
        {
                .ctl_name       = KERN_PANIC,
                .procname       = "panic",
@@ -480,58 +478,65 @@ static ctl_table kern_table[] = {
        {
                .ctl_name       = KERN_SHMMAX,
                .procname       = "shmmax",
-               .data           = NULL,
-               .maxlen         = sizeof (size_t),
+               .data           = &init_ipc_ns.shm_ctlmax,
+               .maxlen         = sizeof (init_ipc_ns.shm_ctlmax),
                .mode           = 0644,
-               .proc_handler   = &proc_do_ipc_string,
+               .proc_handler   = &proc_ipc_doulongvec_minmax,
+               .strategy       = sysctl_ipc_data,
        },
        {
                .ctl_name       = KERN_SHMALL,
                .procname       = "shmall",
-               .data           = NULL,
-               .maxlen         = sizeof (size_t),
+               .data           = &init_ipc_ns.shm_ctlall,
+               .maxlen         = sizeof (init_ipc_ns.shm_ctlall),
                .mode           = 0644,
-               .proc_handler   = &proc_do_ipc_string,
+               .proc_handler   = &proc_ipc_doulongvec_minmax,
+               .strategy       = sysctl_ipc_data,
        },
        {
                .ctl_name       = KERN_SHMMNI,
                .procname       = "shmmni",
-               .data           = NULL,
-               .maxlen         = sizeof (int),
+               .data           = &init_ipc_ns.shm_ctlmni,
+               .maxlen         = sizeof (init_ipc_ns.shm_ctlmni),
                .mode           = 0644,
-               .proc_handler   = &proc_do_ipc_string,
+               .proc_handler   = &proc_ipc_dointvec,
+               .strategy       = sysctl_ipc_data,
        },
        {
                .ctl_name       = KERN_MSGMAX,
                .procname       = "msgmax",
-               .data           = NULL,
-               .maxlen         = sizeof (int),
+               .data           = &init_ipc_ns.msg_ctlmax,
+               .maxlen         = sizeof (init_ipc_ns.msg_ctlmax),
                .mode           = 0644,
-               .proc_handler   = &proc_do_ipc_string,
+               .proc_handler   = &proc_ipc_dointvec,
+               .strategy       = sysctl_ipc_data,
        },
        {
                .ctl_name       = KERN_MSGMNI,
                .procname       = "msgmni",
-               .data           = NULL,
-               .maxlen         = sizeof (int),
+               .data           = &init_ipc_ns.msg_ctlmni,
+               .maxlen         = sizeof (init_ipc_ns.msg_ctlmni),
                .mode           = 0644,
-               .proc_handler   = &proc_do_ipc_string,
+               .proc_handler   = &proc_ipc_dointvec,
+               .strategy       = sysctl_ipc_data,
        },
        {
                .ctl_name       = KERN_MSGMNB,
                .procname       =  "msgmnb",
-               .data           = NULL,
-               .maxlen         = sizeof (int),
+               .data           = &init_ipc_ns.msg_ctlmnb,
+               .maxlen         = sizeof (init_ipc_ns.msg_ctlmnb),
                .mode           = 0644,
-               .proc_handler   = &proc_do_ipc_string,
+               .proc_handler   = &proc_ipc_dointvec,
+               .strategy       = sysctl_ipc_data,
        },
        {
                .ctl_name       = KERN_SEM,
                .procname       = "sem",
-               .data           = NULL,
+               .data           = &init_ipc_ns.sem_ctls,
                .maxlen         = 4*sizeof (int),
                .mode           = 0644,
-               .proc_handler   = &proc_do_ipc_string,
+               .proc_handler   = &proc_ipc_dointvec,
+               .strategy       = sysctl_ipc_data,
        },
 #endif
 #ifdef CONFIG_MAGIC_SYSRQ
@@ -707,6 +712,14 @@ static ctl_table kern_table[] = {
                .mode           = 0444,
                .proc_handler   = &proc_dointvec,
        },
+       {
+               .ctl_name       = CTL_UNNUMBERED,
+               .procname       = "kstack_depth_to_print",
+               .data           = &kstack_depth_to_print,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec,
+       },
 #endif
 #if defined(CONFIG_MMU)
        {
@@ -977,17 +990,6 @@ static ctl_table vm_table[] = {
                .extra1         = &zero,
        },
 #endif
-#ifdef CONFIG_SWAP
-       {
-               .ctl_name       = VM_SWAP_TOKEN_TIMEOUT,
-               .procname       = "swap_token_timeout",
-               .data           = &swap_token_default_timeout,
-               .maxlen         = sizeof(swap_token_default_timeout),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec_jiffies,
-               .strategy       = &sysctl_jiffies,
-       },
-#endif
 #ifdef CONFIG_NUMA
        {
                .ctl_name       = VM_ZONE_RECLAIM_MODE,
@@ -1616,7 +1618,7 @@ static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
                          size_t count, loff_t *ppos)
 {
        int op;
-       struct proc_dir_entry *de = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *de = PDE(file->f_path.dentry->d_inode);
        struct ctl_table *table;
        size_t res;
        ssize_t error = -ENOTDIR;
@@ -1755,66 +1757,17 @@ int proc_dostring(ctl_table *table, int write, struct file *filp,
  *     Special case of dostring for the UTS structure. This has locks
  *     to observe. Should this be in kernel/sys.c ????
  */
-#ifndef CONFIG_UTS_NS
-static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
-                 void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-       int r;
 
-       if (!write) {
-               down_read(&uts_sem);
-               r=proc_dostring(table,0,filp,buffer,lenp, ppos);
-               up_read(&uts_sem);
-       } else {
-               down_write(&uts_sem);
-               r=proc_dostring(table,1,filp,buffer,lenp, ppos);
-               up_write(&uts_sem);
-       }
-       return r;
-}
-#else /* !CONFIG_UTS_NS */
 static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
                  void __user *buffer, size_t *lenp, loff_t *ppos)
 {
        int r;
-       struct uts_namespace* uts_ns = current->nsproxy->uts_ns;
-       char* which;
-
-       switch (table->ctl_name) {
-       case KERN_OSTYPE:
-               which = uts_ns->name.sysname;
-               break;
-       case KERN_NODENAME:
-               which = uts_ns->name.nodename;
-               break;
-       case KERN_OSRELEASE:
-               which = uts_ns->name.release;
-               break;
-       case KERN_VERSION:
-               which = uts_ns->name.version;
-               break;
-       case KERN_DOMAINNAME:
-               which = uts_ns->name.domainname;
-               break;
-       default:
-               r = -EINVAL;
-               goto out;
-       }
-
-       if (!write) {
-               down_read(&uts_sem);
-               r=_proc_do_string(which,table->maxlen,0,filp,buffer,lenp, ppos);
-               up_read(&uts_sem);
-       } else {
-               down_write(&uts_sem);
-               r=_proc_do_string(which,table->maxlen,1,filp,buffer,lenp, ppos);
-               up_write(&uts_sem);
-       }
- out:
+       void *which;
+       which = get_uts(table, write);
+       r = _proc_do_string(which, table->maxlen,write,filp,buffer,lenp, ppos);
+       put_uts(table, write, which);
        return r;
 }
-#endif /* !CONFIG_UTS_NS */
 
 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
                                 int *valp,
@@ -1886,7 +1839,7 @@ static int __do_proc_dointvec(void *tbl_data, ctl_table *table,
                        p = buf;
                        if (*p == '-' && left > 1) {
                                neg = 1;
-                               left--, p++;
+                               p++;
                        }
                        if (*p < '0' || *p > '9')
                                break;
@@ -2137,7 +2090,7 @@ static int __do_proc_doulongvec_minmax(void *data, ctl_table *table, int write,
                        p = buf;
                        if (*p == '-' && left > 1) {
                                neg = 1;
-                               left--, p++;
+                               p++;
                        }
                        if (*p < '0' || *p > '9')
                                break;
@@ -2393,46 +2346,24 @@ int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
 }
 
 #ifdef CONFIG_SYSVIPC
-static int proc_do_ipc_string(ctl_table *table, int write, struct file *filp,
-               void __user *buffer, size_t *lenp, loff_t *ppos)
+static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp,
+       void __user *buffer, size_t *lenp, loff_t *ppos)
 {
-       void *data;
-       struct ipc_namespace *ns;
-
-       ns = current->nsproxy->ipc_ns;
-
-       switch (table->ctl_name) {
-       case KERN_SHMMAX:
-               data = &ns->shm_ctlmax;
-               goto proc_minmax;
-       case KERN_SHMALL:
-               data = &ns->shm_ctlall;
-               goto proc_minmax;
-       case KERN_SHMMNI:
-               data = &ns->shm_ctlmni;
-               break;
-       case KERN_MSGMAX:
-               data = &ns->msg_ctlmax;
-               break;
-       case KERN_MSGMNI:
-               data = &ns->msg_ctlmni;
-               break;
-       case KERN_MSGMNB:
-               data = &ns->msg_ctlmnb;
-               break;
-       case KERN_SEM:
-               data = &ns->sem_ctls;
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       return __do_proc_dointvec(data, table, write, filp, buffer,
+       void *which;
+       which = get_ipc(table, write);
+       return __do_proc_dointvec(which, table, write, filp, buffer,
                        lenp, ppos, NULL, NULL);
-proc_minmax:
-       return __do_proc_doulongvec_minmax(data, table, write, filp, buffer,
+}
+
+static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
+       struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       void *which;
+       which = get_ipc(table, write);
+       return __do_proc_doulongvec_minmax(which, table, write, filp, buffer,
                        lenp, ppos, 1l, 1l);
 }
+
 #endif
 
 static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp,
@@ -2676,6 +2607,64 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
        return 1;
 }
 
+
+/* The generic string strategy routine: */
+static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
+                 void __user *oldval, size_t __user *oldlenp,
+                 void __user *newval, size_t newlen, void **context)
+{
+       struct ctl_table uts_table;
+       int r, write;
+       write = newval && newlen;
+       memcpy(&uts_table, table, sizeof(uts_table));
+       uts_table.data = get_uts(table, write);
+       r = sysctl_string(&uts_table, name, nlen,
+               oldval, oldlenp, newval, newlen, context);
+       put_uts(table, write, uts_table.data);
+       return r;
+}
+
+#ifdef CONFIG_SYSVIPC
+/* The generic sysctl ipc data routine. */
+static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
+               void __user *oldval, size_t __user *oldlenp,
+               void __user *newval, size_t newlen, void **context)
+{
+       size_t len;
+       void *data;
+
+       /* Get out of I don't have a variable */
+       if (!table->data || !table->maxlen)
+               return -ENOTDIR;
+
+       data = get_ipc(table, 1);
+       if (!data)
+               return -ENOTDIR;
+
+       if (oldval && oldlenp) {
+               if (get_user(len, oldlenp))
+                       return -EFAULT;
+               if (len) {
+                       if (len > table->maxlen)
+                               len = table->maxlen;
+                       if (copy_to_user(oldval, data, len))
+                               return -EFAULT;
+                       if (put_user(len, oldlenp))
+                               return -EFAULT;
+               }
+       }
+
+       if (newval && newlen) {
+               if (newlen > table->maxlen)
+                       newlen = table->maxlen;
+
+               if (copy_from_user(data, newval, newlen))
+                       return -EFAULT;
+       }
+       return 1;
+}
+#endif
+
 #else /* CONFIG_SYSCTL_SYSCALL */
 
 
@@ -2740,6 +2729,18 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
        return -ENOSYS;
 }
 
+static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
+                 void __user *oldval, size_t __user *oldlenp,
+                 void __user *newval, size_t newlen, void **context)
+{
+       return -ENOSYS;
+}
+static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
+               void __user *oldval, size_t __user *oldlenp,
+               void __user *newval, size_t newlen, void **context)
+{
+       return -ENOSYS;
+}
 #endif /* CONFIG_SYSCTL_SYSCALL */
 
 /*
index d3d28919d4b494a026701fb4c87426c99111fe7f..4c3476fa058d5627650779f0559dc17c3a7cb1b8 100644 (file)
@@ -34,7 +34,7 @@
 
 static DEFINE_PER_CPU(__u32, taskstats_seqnum) = { 0 };
 static int family_registered;
-kmem_cache_t *taskstats_cache;
+struct kmem_cache *taskstats_cache;
 
 static struct genl_family family = {
        .id             = GENL_ID_GENERATE,
@@ -69,7 +69,7 @@ enum actions {
 };
 
 static int prepare_reply(struct genl_info *info, u8 cmd, struct sk_buff **skbp,
-                       void **replyp, size_t size)
+                               size_t size)
 {
        struct sk_buff *skb;
        void *reply;
@@ -94,7 +94,6 @@ static int prepare_reply(struct genl_info *info, u8 cmd, struct sk_buff **skbp,
        }
 
        *skbp = skb;
-       *replyp = reply;
        return 0;
 }
 
@@ -119,10 +118,10 @@ static int send_reply(struct sk_buff *skb, pid_t pid)
 /*
  * Send taskstats data in @skb to listeners registered for @cpu's exit data
  */
-static void send_cpu_listeners(struct sk_buff *skb, unsigned int cpu)
+static void send_cpu_listeners(struct sk_buff *skb,
+                                       struct listener_list *listeners)
 {
        struct genlmsghdr *genlhdr = nlmsg_data((struct nlmsghdr *)skb->data);
-       struct listener_list *listeners;
        struct listener *s, *tmp;
        struct sk_buff *skb_next, *skb_cur = skb;
        void *reply = genlmsg_data(genlhdr);
@@ -135,7 +134,6 @@ static void send_cpu_listeners(struct sk_buff *skb, unsigned int cpu)
        }
 
        rc = 0;
-       listeners = &per_cpu(listener_array, cpu);
        down_read(&listeners->sem);
        list_for_each_entry(s, &listeners->list, list) {
                skb_next = NULL;
@@ -186,6 +184,7 @@ static int fill_pid(pid_t pid, struct task_struct *tsk,
        } else
                get_task_struct(tsk);
 
+       memset(stats, 0, sizeof(*stats));
        /*
         * Each accounting subsystem adds calls to its functions to
         * fill in relevant parts of struct taskstsats as follows
@@ -228,6 +227,8 @@ static int fill_tgid(pid_t tgid, struct task_struct *first,
 
        if (first->signal->stats)
                memcpy(stats, first->signal->stats, sizeof(*stats));
+       else
+               memset(stats, 0, sizeof(*stats));
 
        tsk = first;
        do {
@@ -344,14 +345,36 @@ static int parse(struct nlattr *na, cpumask_t *mask)
        return ret;
 }
 
+static struct taskstats *mk_reply(struct sk_buff *skb, int type, u32 pid)
+{
+       struct nlattr *na, *ret;
+       int aggr;
+
+       aggr = (type == TASKSTATS_TYPE_PID)
+                       ? TASKSTATS_TYPE_AGGR_PID
+                       : TASKSTATS_TYPE_AGGR_TGID;
+
+       na = nla_nest_start(skb, aggr);
+       if (!na)
+               goto err;
+       if (nla_put(skb, type, sizeof(pid), &pid) < 0)
+               goto err;
+       ret = nla_reserve(skb, TASKSTATS_TYPE_STATS, sizeof(struct taskstats));
+       if (!ret)
+               goto err;
+       nla_nest_end(skb, na);
+
+       return nla_data(ret);
+err:
+       return NULL;
+}
+
 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
 {
        int rc = 0;
        struct sk_buff *rep_skb;
-       struct taskstats stats;
-       void *reply;
+       struct taskstats *stats;
        size_t size;
-       struct nlattr *na;
        cpumask_t mask;
 
        rc = parse(info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK], &mask);
@@ -372,83 +395,71 @@ static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
        size = nla_total_size(sizeof(u32)) +
                nla_total_size(sizeof(struct taskstats)) + nla_total_size(0);
 
-       memset(&stats, 0, sizeof(stats));
-       rc = prepare_reply(info, TASKSTATS_CMD_NEW, &rep_skb, &reply, size);
+       rc = prepare_reply(info, TASKSTATS_CMD_NEW, &rep_skb, size);
        if (rc < 0)
                return rc;
 
+       rc = -EINVAL;
        if (info->attrs[TASKSTATS_CMD_ATTR_PID]) {
                u32 pid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_PID]);
-               rc = fill_pid(pid, NULL, &stats);
-               if (rc < 0)
+               stats = mk_reply(rep_skb, TASKSTATS_TYPE_PID, pid);
+               if (!stats)
                        goto err;
 
-               na = nla_nest_start(rep_skb, TASKSTATS_TYPE_AGGR_PID);
-               NLA_PUT_U32(rep_skb, TASKSTATS_TYPE_PID, pid);
-               NLA_PUT_TYPE(rep_skb, struct taskstats, TASKSTATS_TYPE_STATS,
-                               stats);
+               rc = fill_pid(pid, NULL, stats);
+               if (rc < 0)
+                       goto err;
        } else if (info->attrs[TASKSTATS_CMD_ATTR_TGID]) {
                u32 tgid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_TGID]);
-               rc = fill_tgid(tgid, NULL, &stats);
-               if (rc < 0)
+               stats = mk_reply(rep_skb, TASKSTATS_TYPE_TGID, tgid);
+               if (!stats)
                        goto err;
 
-               na = nla_nest_start(rep_skb, TASKSTATS_TYPE_AGGR_TGID);
-               NLA_PUT_U32(rep_skb, TASKSTATS_TYPE_TGID, tgid);
-               NLA_PUT_TYPE(rep_skb, struct taskstats, TASKSTATS_TYPE_STATS,
-                               stats);
-       } else {
-               rc = -EINVAL;
+               rc = fill_tgid(tgid, NULL, stats);
+               if (rc < 0)
+                       goto err;
+       } else
                goto err;
-       }
-
-       nla_nest_end(rep_skb, na);
 
        return send_reply(rep_skb, info->snd_pid);
-
-nla_put_failure:
-       rc = genlmsg_cancel(rep_skb, reply);
 err:
        nlmsg_free(rep_skb);
        return rc;
 }
 
-void taskstats_exit_alloc(struct taskstats **ptidstats, unsigned int *mycpu)
+static struct taskstats *taskstats_tgid_alloc(struct task_struct *tsk)
 {
-       struct listener_list *listeners;
-       struct taskstats *tmp;
-       /*
-        * This is the cpu on which the task is exiting currently and will
-        * be the one for which the exit event is sent, even if the cpu
-        * on which this function is running changes later.
-        */
-       *mycpu = raw_smp_processor_id();
+       struct signal_struct *sig = tsk->signal;
+       struct taskstats *stats;
 
-       *ptidstats = NULL;
-       tmp = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL);
-       if (!tmp)
-               return;
+       if (sig->stats || thread_group_empty(tsk))
+               goto ret;
 
-       listeners = &per_cpu(listener_array, *mycpu);
-       down_read(&listeners->sem);
-       if (!list_empty(&listeners->list)) {
-               *ptidstats = tmp;
-               tmp = NULL;
+       /* No problem if kmem_cache_zalloc() fails */
+       stats = kmem_cache_zalloc(taskstats_cache, GFP_KERNEL);
+
+       spin_lock_irq(&tsk->sighand->siglock);
+       if (!sig->stats) {
+               sig->stats = stats;
+               stats = NULL;
        }
-       up_read(&listeners->sem);
-       kfree(tmp);
+       spin_unlock_irq(&tsk->sighand->siglock);
+
+       if (stats)
+               kmem_cache_free(taskstats_cache, stats);
+ret:
+       return sig->stats;
 }
 
 /* Send pid data out on exit */
-void taskstats_exit_send(struct task_struct *tsk, struct taskstats *tidstats,
-                       int group_dead, unsigned int mycpu)
+void taskstats_exit(struct task_struct *tsk, int group_dead)
 {
        int rc;
+       struct listener_list *listeners;
+       struct taskstats *stats;
        struct sk_buff *rep_skb;
-       void *reply;
        size_t size;
        int is_thread_group;
-       struct nlattr *na;
 
        if (!family_registered)
                return;
@@ -459,7 +470,7 @@ void taskstats_exit_send(struct task_struct *tsk, struct taskstats *tidstats,
        size = nla_total_size(sizeof(u32)) +
                nla_total_size(sizeof(struct taskstats)) + nla_total_size(0);
 
-       is_thread_group = (tsk->signal->stats != NULL);
+       is_thread_group = !!taskstats_tgid_alloc(tsk);
        if (is_thread_group) {
                /* PID + STATS + TGID + STATS */
                size = 2 * size;
@@ -467,49 +478,39 @@ void taskstats_exit_send(struct task_struct *tsk, struct taskstats *tidstats,
                fill_tgid_exit(tsk);
        }
 
-       if (!tidstats)
+       listeners = &__raw_get_cpu_var(listener_array);
+       if (list_empty(&listeners->list))
                return;
 
-       rc = prepare_reply(NULL, TASKSTATS_CMD_NEW, &rep_skb, &reply, size);
-       if (rc < 0)
-               goto ret;
-
-       rc = fill_pid(tsk->pid, tsk, tidstats);
+       rc = prepare_reply(NULL, TASKSTATS_CMD_NEW, &rep_skb, size);
        if (rc < 0)
-               goto err_skb;
+               return;
 
-       na = nla_nest_start(rep_skb, TASKSTATS_TYPE_AGGR_PID);
-       NLA_PUT_U32(rep_skb, TASKSTATS_TYPE_PID, (u32)tsk->pid);
-       NLA_PUT_TYPE(rep_skb, struct taskstats, TASKSTATS_TYPE_STATS,
-                       *tidstats);
-       nla_nest_end(rep_skb, na);
+       stats = mk_reply(rep_skb, TASKSTATS_TYPE_PID, tsk->pid);
+       if (!stats)
+               goto err;
 
-       if (!is_thread_group)
-               goto send;
+       rc = fill_pid(tsk->pid, tsk, stats);
+       if (rc < 0)
+               goto err;
 
        /*
         * Doesn't matter if tsk is the leader or the last group member leaving
         */
-       if (!group_dead)
+       if (!is_thread_group || !group_dead)
                goto send;
 
-       na = nla_nest_start(rep_skb, TASKSTATS_TYPE_AGGR_TGID);
-       NLA_PUT_U32(rep_skb, TASKSTATS_TYPE_TGID, (u32)tsk->tgid);
-       /* No locking needed for tsk->signal->stats since group is dead */
-       NLA_PUT_TYPE(rep_skb, struct taskstats, TASKSTATS_TYPE_STATS,
-                       *tsk->signal->stats);
-       nla_nest_end(rep_skb, na);
+       stats = mk_reply(rep_skb, TASKSTATS_TYPE_TGID, tsk->tgid);
+       if (!stats)
+               goto err;
+
+       memcpy(stats, tsk->signal->stats, sizeof(*stats));
 
 send:
-       send_cpu_listeners(rep_skb, mycpu);
+       send_cpu_listeners(rep_skb, listeners);
        return;
-
-nla_put_failure:
-       genlmsg_cancel(rep_skb, reply);
-err_skb:
+err:
        nlmsg_free(rep_skb);
-ret:
-       return;
 }
 
 static struct genl_ops taskstats_ops = {
index ed0a21d4a902339acef700eea0e291220ce7fb2a..09c261329249dd5730d7694e214af8240385b48f 100644 (file)
 #include <linux/bootmem.h>
 #include <linux/sort.h>
 #include <linux/stop_machine.h>
+#include <linux/uaccess.h>
 #include <asm/sections.h>
 #include <asm/uaccess.h>
 #include <asm/unaligned.h>
 
-extern char __start_unwind[], __end_unwind[];
+extern const char __start_unwind[], __end_unwind[];
 extern const u8 __start_unwind_hdr[], __end_unwind_hdr[];
 
 #define MAX_STACK_DEPTH 8
@@ -94,6 +95,7 @@ static const struct {
 
 typedef unsigned long uleb128_t;
 typedef   signed long sleb128_t;
+#define sleb128abs __builtin_labs
 
 static struct unwind_table {
        struct {
@@ -135,6 +137,17 @@ struct unwind_state {
 
 static const struct cfa badCFA = { ARRAY_SIZE(reg_info), 1 };
 
+static unsigned unwind_debug;
+static int __init unwind_debug_setup(char *s)
+{
+       unwind_debug = simple_strtoul(s, NULL, 0);
+       return 1;
+}
+__setup("unwind_debug=", unwind_debug_setup);
+#define dprintk(lvl, fmt, args...) \
+       ((void)(lvl > unwind_debug \
+        || printk(KERN_DEBUG "unwind: " fmt "\n", ##args)))
+
 static struct unwind_table *find_table(unsigned long pc)
 {
        struct unwind_table *table;
@@ -151,7 +164,9 @@ static struct unwind_table *find_table(unsigned long pc)
 
 static unsigned long read_pointer(const u8 **pLoc,
                                   const void *end,
-                                  signed ptrType);
+                                  signed ptrType,
+                                  unsigned long text_base,
+                                  unsigned long data_base);
 
 static void init_unwind_table(struct unwind_table *table,
                               const char *name,
@@ -176,10 +191,13 @@ static void init_unwind_table(struct unwind_table *table,
        /* See if the linker provided table looks valid. */
        if (header_size <= 4
            || header_start[0] != 1
-           || (void *)read_pointer(&ptr, end, header_start[1]) != table_start
-           || header_start[2] == DW_EH_PE_omit
-           || read_pointer(&ptr, end, header_start[2]) <= 0
-           || header_start[3] == DW_EH_PE_omit)
+           || (void *)read_pointer(&ptr, end, header_start[1], 0, 0)
+              != table_start
+           || !read_pointer(&ptr, end, header_start[2], 0, 0)
+           || !read_pointer(&ptr, end, header_start[3], 0,
+                            (unsigned long)header_start)
+           || !read_pointer(&ptr, end, header_start[3], 0,
+                            (unsigned long)header_start))
                header_start = NULL;
        table->hdrsz = header_size;
        smp_wmb();
@@ -269,7 +287,7 @@ static void __init setup_unwind_table(struct unwind_table *table,
                ptr = (const u8 *)(fde + 2);
                if (!read_pointer(&ptr,
                                  (const u8 *)(fde + 1) + *fde,
-                                 ptrType))
+                                 ptrType, 0, 0))
                        return;
                ++n;
        }
@@ -279,6 +297,7 @@ static void __init setup_unwind_table(struct unwind_table *table,
 
        hdrSize = 4 + sizeof(unsigned long) + sizeof(unsigned int)
                + 2 * n * sizeof(unsigned long);
+       dprintk(2, "Binary lookup table size for %s: %lu bytes", table->name, hdrSize);
        header = alloc(hdrSize);
        if (!header)
                return;
@@ -303,7 +322,7 @@ static void __init setup_unwind_table(struct unwind_table *table,
                ptr = (const u8 *)(fde + 2);
                header->table[n].start = read_pointer(&ptr,
                                                      (const u8 *)(fde + 1) + *fde,
-                                                     fde_pointer_type(cie));
+                                                     fde_pointer_type(cie), 0, 0);
                header->table[n].fde = (unsigned long)fde;
                ++n;
        }
@@ -486,7 +505,9 @@ static const u32 *cie_for_fde(const u32 *fde, const struct unwind_table *table)
 
 static unsigned long read_pointer(const u8 **pLoc,
                                   const void *end,
-                                  signed ptrType)
+                                  signed ptrType,
+                                  unsigned long text_base,
+                                  unsigned long data_base)
 {
        unsigned long value = 0;
        union {
@@ -498,13 +519,17 @@ static unsigned long read_pointer(const u8 **pLoc,
                const unsigned long *pul;
        } ptr;
 
-       if (ptrType < 0 || ptrType == DW_EH_PE_omit)
+       if (ptrType < 0 || ptrType == DW_EH_PE_omit) {
+               dprintk(1, "Invalid pointer encoding %02X (%p,%p).", ptrType, *pLoc, end);
                return 0;
+       }
        ptr.p8 = *pLoc;
        switch(ptrType & DW_EH_PE_FORM) {
        case DW_EH_PE_data2:
-               if (end < (const void *)(ptr.p16u + 1))
+               if (end < (const void *)(ptr.p16u + 1)) {
+                       dprintk(1, "Data16 overrun (%p,%p).", ptr.p8, end);
                        return 0;
+               }
                if(ptrType & DW_EH_PE_signed)
                        value = get_unaligned(ptr.p16s++);
                else
@@ -512,8 +537,10 @@ static unsigned long read_pointer(const u8 **pLoc,
                break;
        case DW_EH_PE_data4:
 #ifdef CONFIG_64BIT
-               if (end < (const void *)(ptr.p32u + 1))
+               if (end < (const void *)(ptr.p32u + 1)) {
+                       dprintk(1, "Data32 overrun (%p,%p).", ptr.p8, end);
                        return 0;
+               }
                if(ptrType & DW_EH_PE_signed)
                        value = get_unaligned(ptr.p32s++);
                else
@@ -525,8 +552,10 @@ static unsigned long read_pointer(const u8 **pLoc,
                BUILD_BUG_ON(sizeof(u32) != sizeof(value));
 #endif
        case DW_EH_PE_native:
-               if (end < (const void *)(ptr.pul + 1))
+               if (end < (const void *)(ptr.pul + 1)) {
+                       dprintk(1, "DataUL overrun (%p,%p).", ptr.p8, end);
                        return 0;
+               }
                value = get_unaligned(ptr.pul++);
                break;
        case DW_EH_PE_leb128:
@@ -534,10 +563,14 @@ static unsigned long read_pointer(const u8 **pLoc,
                value = ptrType & DW_EH_PE_signed
                        ? get_sleb128(&ptr.p8, end)
                        : get_uleb128(&ptr.p8, end);
-               if ((const void *)ptr.p8 > end)
+               if ((const void *)ptr.p8 > end) {
+                       dprintk(1, "DataLEB overrun (%p,%p).", ptr.p8, end);
                        return 0;
+               }
                break;
        default:
+               dprintk(2, "Cannot decode pointer type %02X (%p,%p).",
+                       ptrType, ptr.p8, end);
                return 0;
        }
        switch(ptrType & DW_EH_PE_ADJUST) {
@@ -546,12 +579,33 @@ static unsigned long read_pointer(const u8 **pLoc,
        case DW_EH_PE_pcrel:
                value += (unsigned long)*pLoc;
                break;
+       case DW_EH_PE_textrel:
+               if (likely(text_base)) {
+                       value += text_base;
+                       break;
+               }
+               dprintk(2, "Text-relative encoding %02X (%p,%p), but zero text base.",
+                       ptrType, *pLoc, end);
+               return 0;
+       case DW_EH_PE_datarel:
+               if (likely(data_base)) {
+                       value += data_base;
+                       break;
+               }
+               dprintk(2, "Data-relative encoding %02X (%p,%p), but zero data base.",
+                       ptrType, *pLoc, end);
+               return 0;
        default:
+               dprintk(2, "Cannot adjust pointer type %02X (%p,%p).",
+                       ptrType, *pLoc, end);
                return 0;
        }
        if ((ptrType & DW_EH_PE_indirect)
-           && __get_user(value, (unsigned long *)value))
+           && probe_kernel_address((unsigned long *)value, value)) {
+               dprintk(1, "Cannot read indirect value %lx (%p,%p).",
+                       value, *pLoc, end);
                return 0;
+       }
        *pLoc = ptr.p8;
 
        return value;
@@ -594,7 +648,8 @@ static signed fde_pointer_type(const u32 *cie)
                        case 'P': {
                                        signed ptrType = *ptr++;
 
-                                       if (!read_pointer(&ptr, end, ptrType) || ptr > end)
+                                       if (!read_pointer(&ptr, end, ptrType, 0, 0)
+                                           || ptr > end)
                                                return -1;
                                }
                                break;
@@ -654,7 +709,8 @@ static int processCFI(const u8 *start,
                        case DW_CFA_nop:
                                break;
                        case DW_CFA_set_loc:
-                               if ((state->loc = read_pointer(&ptr.p8, end, ptrType)) == 0)
+                               state->loc = read_pointer(&ptr.p8, end, ptrType, 0, 0);
+                               if (state->loc == 0)
                                        result = 0;
                                break;
                        case DW_CFA_advance_loc1:
@@ -700,8 +756,10 @@ static int processCFI(const u8 *start,
                                        state->label = NULL;
                                        return 1;
                                }
-                               if (state->stackDepth >= MAX_STACK_DEPTH)
+                               if (state->stackDepth >= MAX_STACK_DEPTH) {
+                                       dprintk(1, "State stack overflow (%p,%p).", ptr.p8, end);
                                        return 0;
+                               }
                                state->stack[state->stackDepth++] = ptr.p8;
                                break;
                        case DW_CFA_restore_state:
@@ -716,8 +774,10 @@ static int processCFI(const u8 *start,
                                        result = processCFI(start, end, 0, ptrType, state);
                                        state->loc = loc;
                                        state->label = label;
-                               } else
+                               } else {
+                                       dprintk(1, "State stack underflow (%p,%p).", ptr.p8, end);
                                        return 0;
+                               }
                                break;
                        case DW_CFA_def_cfa:
                                state->cfa.reg = get_uleb128(&ptr.p8, end);
@@ -749,6 +809,7 @@ static int processCFI(const u8 *start,
                                break;
                        case DW_CFA_GNU_window_save:
                        default:
+                               dprintk(1, "Unrecognized CFI op %02X (%p,%p).", ptr.p8[-1], ptr.p8 - 1, end);
                                result = 0;
                                break;
                        }
@@ -764,12 +825,17 @@ static int processCFI(const u8 *start,
                        set_rule(*ptr.p8++ & 0x3f, Nowhere, 0, state);
                        break;
                }
-               if (ptr.p8 > end)
+               if (ptr.p8 > end) {
+                       dprintk(1, "Data overrun (%p,%p).", ptr.p8, end);
                        result = 0;
+               }
                if (result && targetLoc != 0 && targetLoc < state->loc)
                        return 1;
        }
 
+       if (result && ptr.p8 < end)
+               dprintk(1, "Data underrun (%p,%p).", ptr.p8, end);
+
        return result
           && ptr.p8 == end
           && (targetLoc == 0
@@ -786,7 +852,7 @@ int unwind(struct unwind_frame_info *frame)
 #define FRAME_REG(r, t) (((t *)frame)[reg_info[r].offs])
        const u32 *fde = NULL, *cie = NULL;
        const u8 *ptr = NULL, *end = NULL;
-       unsigned long pc = UNW_PC(frame) - frame->call_frame;
+       unsigned long pc = UNW_PC(frame) - frame->call_frame, sp;
        unsigned long startLoc = 0, endLoc = 0, cfa;
        unsigned i;
        signed ptrType = -1;
@@ -813,9 +879,9 @@ int unwind(struct unwind_frame_info *frame)
                        ptr = hdr + 4;
                        end = hdr + table->hdrsz;
                        if (tableSize
-                           && read_pointer(&ptr, end, hdr[1])
+                           && read_pointer(&ptr, end, hdr[1], 0, 0)
                               == (unsigned long)table->address
-                           && (i = read_pointer(&ptr, end, hdr[2])) > 0
+                           && (i = read_pointer(&ptr, end, hdr[2], 0, 0)) > 0
                            && i == (end - ptr) / (2 * tableSize)
                            && !((end - ptr) % (2 * tableSize))) {
                                do {
@@ -823,7 +889,8 @@ int unwind(struct unwind_frame_info *frame)
 
                                        startLoc = read_pointer(&cur,
                                                                cur + tableSize,
-                                                               hdr[3]);
+                                                               hdr[3], 0,
+                                                               (unsigned long)hdr);
                                        if (pc < startLoc)
                                                i /= 2;
                                        else {
@@ -834,13 +901,17 @@ int unwind(struct unwind_frame_info *frame)
                                if (i == 1
                                    && (startLoc = read_pointer(&ptr,
                                                                ptr + tableSize,
-                                                               hdr[3])) != 0
+                                                               hdr[3], 0,
+                                                               (unsigned long)hdr)) != 0
                                    && pc >= startLoc)
                                        fde = (void *)read_pointer(&ptr,
                                                                   ptr + tableSize,
-                                                                  hdr[3]);
+                                                                  hdr[3], 0,
+                                                                  (unsigned long)hdr);
                        }
                }
+               if(hdr && !fde)
+                       dprintk(3, "Binary lookup for %lx failed.", pc);
 
                if (fde != NULL) {
                        cie = cie_for_fde(fde, table);
@@ -851,17 +922,19 @@ int unwind(struct unwind_frame_info *frame)
                           && (ptrType = fde_pointer_type(cie)) >= 0
                           && read_pointer(&ptr,
                                           (const u8 *)(fde + 1) + *fde,
-                                          ptrType) == startLoc) {
+                                          ptrType, 0, 0) == startLoc) {
                                if (!(ptrType & DW_EH_PE_indirect))
                                        ptrType &= DW_EH_PE_FORM|DW_EH_PE_signed;
                                endLoc = startLoc
                                         + read_pointer(&ptr,
                                                        (const u8 *)(fde + 1) + *fde,
-                                                       ptrType);
+                                                       ptrType, 0, 0);
                                if(pc >= endLoc)
                                        fde = NULL;
                        } else
                                fde = NULL;
+                       if(!fde)
+                               dprintk(1, "Binary lookup result for %lx discarded.", pc);
                }
                if (fde == NULL) {
                        for (fde = table->address, tableSize = table->size;
@@ -881,7 +954,7 @@ int unwind(struct unwind_frame_info *frame)
                                ptr = (const u8 *)(fde + 2);
                                startLoc = read_pointer(&ptr,
                                                        (const u8 *)(fde + 1) + *fde,
-                                                       ptrType);
+                                                       ptrType, 0, 0);
                                if (!startLoc)
                                        continue;
                                if (!(ptrType & DW_EH_PE_indirect))
@@ -889,10 +962,12 @@ int unwind(struct unwind_frame_info *frame)
                                endLoc = startLoc
                                         + read_pointer(&ptr,
                                                        (const u8 *)(fde + 1) + *fde,
-                                                       ptrType);
+                                                       ptrType, 0, 0);
                                if (pc >= startLoc && pc < endLoc)
                                        break;
                        }
+                       if(!fde)
+                               dprintk(3, "Linear lookup for %lx failed.", pc);
                }
        }
        if (cie != NULL) {
@@ -926,6 +1001,8 @@ int unwind(struct unwind_frame_info *frame)
                        if (ptr >= end || *ptr)
                                cie = NULL;
                }
+               if(!cie)
+                       dprintk(1, "CIE unusable (%p,%p).", ptr, end);
                ++ptr;
        }
        if (cie != NULL) {
@@ -935,7 +1012,12 @@ int unwind(struct unwind_frame_info *frame)
                state.dataAlign = get_sleb128(&ptr, end);
                if (state.codeAlign == 0 || state.dataAlign == 0 || ptr >= end)
                        cie = NULL;
-               else {
+               else if (UNW_PC(frame) % state.codeAlign
+                        || UNW_SP(frame) % sleb128abs(state.dataAlign)) {
+                       dprintk(1, "Input pointer(s) misaligned (%lx,%lx).",
+                               UNW_PC(frame), UNW_SP(frame));
+                       return -EPERM;
+               } else {
                        retAddrReg = state.version <= 1 ? *ptr++ : get_uleb128(&ptr, end);
                        /* skip augmentation */
                        if (((const char *)(cie + 2))[1] == 'z') {
@@ -949,6 +1031,8 @@ int unwind(struct unwind_frame_info *frame)
                           || reg_info[retAddrReg].width != sizeof(unsigned long))
                                cie = NULL;
                }
+               if(!cie)
+                       dprintk(1, "CIE validation failed (%p,%p).", ptr, end);
        }
        if (cie != NULL) {
                state.cieStart = ptr;
@@ -962,11 +1046,15 @@ int unwind(struct unwind_frame_info *frame)
                        if ((ptr += augSize) > end)
                                fde = NULL;
                }
+               if(!fde)
+                       dprintk(1, "FDE validation failed (%p,%p).", ptr, end);
        }
        if (cie == NULL || fde == NULL) {
 #ifdef CONFIG_FRAME_POINTER
                unsigned long top, bottom;
 
+               if ((UNW_SP(frame) | UNW_FP(frame)) % sizeof(unsigned long))
+                       return -EPERM;
                top = STACK_TOP(frame->task);
                bottom = STACK_BOTTOM(frame->task);
 # if FRAME_RETADDR_OFFSET < 0
@@ -982,18 +1070,19 @@ int unwind(struct unwind_frame_info *frame)
                        & (sizeof(unsigned long) - 1))) {
                        unsigned long link;
 
-                       if (!__get_user(link,
+                       if (!probe_kernel_address(
                                        (unsigned long *)(UNW_FP(frame)
-                                                         + FRAME_LINK_OFFSET))
+                                                         + FRAME_LINK_OFFSET),
+                                                 link)
 # if FRAME_RETADDR_OFFSET < 0
                           && link > bottom && link < UNW_FP(frame)
 # else
                           && link > UNW_FP(frame) && link < bottom
 # endif
                           && !(link & (sizeof(link) - 1))
-                          && !__get_user(UNW_PC(frame),
+                          && !probe_kernel_address(
                                          (unsigned long *)(UNW_FP(frame)
-                                                           + FRAME_RETADDR_OFFSET))) {
+                                                           + FRAME_RETADDR_OFFSET), UNW_PC(frame))) {
                                UNW_SP(frame) = UNW_FP(frame) + FRAME_RETADDR_OFFSET
 # if FRAME_RETADDR_OFFSET < 0
                                        -
@@ -1016,8 +1105,11 @@ int unwind(struct unwind_frame_info *frame)
           || state.regs[retAddrReg].where == Nowhere
           || state.cfa.reg >= ARRAY_SIZE(reg_info)
           || reg_info[state.cfa.reg].width != sizeof(unsigned long)
-          || state.cfa.offs % sizeof(unsigned long))
+          || FRAME_REG(state.cfa.reg, unsigned long) % sizeof(unsigned long)
+          || state.cfa.offs % sizeof(unsigned long)) {
+               dprintk(1, "Unusable unwind info (%p,%p).", ptr, end);
                return -EIO;
+       }
        /* update frame */
 #ifndef CONFIG_AS_CFI_SIGNAL_FRAME
        if(frame->call_frame
@@ -1036,10 +1128,14 @@ int unwind(struct unwind_frame_info *frame)
 #else
 # define CASES CASE(8); CASE(16); CASE(32); CASE(64)
 #endif
+       pc = UNW_PC(frame);
+       sp = UNW_SP(frame);
        for (i = 0; i < ARRAY_SIZE(state.regs); ++i) {
                if (REG_INVALID(i)) {
                        if (state.regs[i].where == Nowhere)
                                continue;
+                       dprintk(1, "Cannot restore register %u (%d).",
+                               i, state.regs[i].where);
                        return -EIO;
                }
                switch(state.regs[i].where) {
@@ -1048,8 +1144,11 @@ int unwind(struct unwind_frame_info *frame)
                case Register:
                        if (state.regs[i].value >= ARRAY_SIZE(reg_info)
                           || REG_INVALID(state.regs[i].value)
-                          || reg_info[i].width > reg_info[state.regs[i].value].width)
+                          || reg_info[i].width > reg_info[state.regs[i].value].width) {
+                               dprintk(1, "Cannot restore register %u from register %lu.",
+                                       i, state.regs[i].value);
                                return -EIO;
+                       }
                        switch(reg_info[state.regs[i].value].width) {
 #define CASE(n) \
                        case sizeof(u##n): \
@@ -1059,6 +1158,9 @@ int unwind(struct unwind_frame_info *frame)
                        CASES;
 #undef CASE
                        default:
+                               dprintk(1, "Unsupported register size %u (%lu).",
+                                       reg_info[state.regs[i].value].width,
+                                       state.regs[i].value);
                                return -EIO;
                        }
                        break;
@@ -1083,12 +1185,17 @@ int unwind(struct unwind_frame_info *frame)
                        CASES;
 #undef CASE
                        default:
+                               dprintk(1, "Unsupported register size %u (%u).",
+                                       reg_info[i].width, i);
                                return -EIO;
                        }
                        break;
                case Value:
-                       if (reg_info[i].width != sizeof(unsigned long))
+                       if (reg_info[i].width != sizeof(unsigned long)) {
+                               dprintk(1, "Unsupported value size %u (%u).",
+                                       reg_info[i].width, i);
                                return -EIO;
+                       }
                        FRAME_REG(i, unsigned long) = cfa + state.regs[i].value
                                                            * state.dataAlign;
                        break;
@@ -1100,15 +1207,20 @@ int unwind(struct unwind_frame_info *frame)
                                    % sizeof(unsigned long)
                                    || addr < startLoc
                                    || addr + sizeof(unsigned long) < addr
-                                   || addr + sizeof(unsigned long) > endLoc)
+                                   || addr + sizeof(unsigned long) > endLoc) {
+                                       dprintk(1, "Bad memory location %lx (%lx).",
+                                               addr, state.regs[i].value);
                                        return -EIO;
+                               }
                                switch(reg_info[i].width) {
 #define CASE(n)     case sizeof(u##n): \
-                                       __get_user(FRAME_REG(i, u##n), (u##n *)addr); \
+                                       probe_kernel_address((u##n *)addr, FRAME_REG(i, u##n)); \
                                        break
                                CASES;
 #undef CASE
                                default:
+                                       dprintk(1, "Unsupported memory size %u (%u).",
+                                               reg_info[i].width, i);
                                        return -EIO;
                                }
                        }
@@ -1116,6 +1228,17 @@ int unwind(struct unwind_frame_info *frame)
                }
        }
 
+       if (UNW_PC(frame) % state.codeAlign
+           || UNW_SP(frame) % sleb128abs(state.dataAlign)) {
+               dprintk(1, "Output pointer(s) misaligned (%lx,%lx).",
+                       UNW_PC(frame), UNW_SP(frame));
+               return -EIO;
+       }
+       if (pc == UNW_PC(frame) && sp == UNW_SP(frame)) {
+               dprintk(1, "No progress (%lx,%lx).", pc, sp);
+               return -EIO;
+       }
+
        return 0;
 #undef CASES
 #undef FRAME_REG
index 220e586127a0ca9cd65b3ccfd6b01c4620fef2e7..4869563080e9e080954d26f34b70bbffc13de18b 100644 (file)
@@ -26,7 +26,7 @@
 #define __uidhashfn(uid)       (((uid >> UIDHASH_BITS) + uid) & UIDHASH_MASK)
 #define uidhashentry(uid)      (uidhash_table + __uidhashfn((uid)))
 
-static kmem_cache_t *uid_cachep;
+static struct kmem_cache *uid_cachep;
 static struct list_head uidhash_table[UIDHASH_SZ];
 
 /*
@@ -132,7 +132,7 @@ struct user_struct * alloc_uid(uid_t uid)
        if (!up) {
                struct user_struct *new;
 
-               new = kmem_cache_alloc(uid_cachep, SLAB_KERNEL);
+               new = kmem_cache_alloc(uid_cachep, GFP_KERNEL);
                if (!new)
                        return NULL;
                new->uid = uid;
index 8d1e7cb8a51a85327bc84a61705a7fe91881228e..db49886bfae17271ee19709a984c57c208c5065b 100644 (file)
@@ -29,6 +29,9 @@
 #include <linux/kthread.h>
 #include <linux/hardirq.h>
 #include <linux/mempolicy.h>
+#include <linux/freezer.h>
+#include <linux/kallsyms.h>
+#include <linux/debug_locks.h>
 
 /*
  * The per-CPU workqueue (if single thread, we always use the first
@@ -55,6 +58,8 @@ struct cpu_workqueue_struct {
        struct task_struct *thread;
 
        int run_depth;          /* Detect run_workqueue() recursion depth */
+
+       int freezeable;         /* Freeze the thread during suspend */
 } ____cacheline_aligned;
 
 /*
@@ -80,22 +85,19 @@ static inline int is_single_threaded(struct workqueue_struct *wq)
        return list_empty(&wq->list);
 }
 
+/*
+ * Set the workqueue on which a work item is to be run
+ * - Must *only* be called if the pending flag is set
+ */
 static inline void set_wq_data(struct work_struct *work, void *wq)
 {
-       unsigned long new, old, res;
+       unsigned long new;
+
+       BUG_ON(!work_pending(work));
 
-       /* assume the pending flag is already set and that the task has already
-        * been queued on this workqueue */
        new = (unsigned long) wq | (1UL << WORK_STRUCT_PENDING);
-       res = work->management;
-       if (res != new) {
-               do {
-                       old = res;
-                       new = (unsigned long) wq;
-                       new |= (old & WORK_STRUCT_FLAG_MASK);
-                       res = cmpxchg(&work->management, old, new);
-               } while (res != old);
-       }
+       new |= work->management & WORK_STRUCT_FLAG_MASK;
+       work->management = new;
 }
 
 static inline void *get_wq_data(struct work_struct *work)
@@ -103,6 +105,79 @@ static inline void *get_wq_data(struct work_struct *work)
        return (void *) (work->management & WORK_STRUCT_WQ_DATA_MASK);
 }
 
+static int __run_work(struct cpu_workqueue_struct *cwq, struct work_struct *work)
+{
+       int ret = 0;
+       unsigned long flags;
+
+       spin_lock_irqsave(&cwq->lock, flags);
+       /*
+        * We need to re-validate the work info after we've gotten
+        * the cpu_workqueue lock. We can run the work now iff:
+        *
+        *  - the wq_data still matches the cpu_workqueue_struct
+        *  - AND the work is still marked pending
+        *  - AND the work is still on a list (which will be this
+        *    workqueue_struct list)
+        *
+        * All these conditions are important, because we
+        * need to protect against the work being run right
+        * now on another CPU (all but the last one might be
+        * true if it's currently running and has not been
+        * released yet, for example).
+        */
+       if (get_wq_data(work) == cwq
+           && work_pending(work)
+           && !list_empty(&work->entry)) {
+               work_func_t f = work->func;
+               list_del_init(&work->entry);
+               spin_unlock_irqrestore(&cwq->lock, flags);
+
+               if (!test_bit(WORK_STRUCT_NOAUTOREL, &work->management))
+                       work_release(work);
+               f(work);
+
+               spin_lock_irqsave(&cwq->lock, flags);
+               cwq->remove_sequence++;
+               wake_up(&cwq->work_done);
+               ret = 1;
+       }
+       spin_unlock_irqrestore(&cwq->lock, flags);
+       return ret;
+}
+
+/**
+ * run_scheduled_work - run scheduled work synchronously
+ * @work: work to run
+ *
+ * This checks if the work was pending, and runs it
+ * synchronously if so. It returns a boolean to indicate
+ * whether it had any scheduled work to run or not.
+ *
+ * NOTE! This _only_ works for normal work_structs. You
+ * CANNOT use this for delayed work, because the wq data
+ * for delayed work will not point properly to the per-
+ * CPU workqueue struct, but will change!
+ */
+int fastcall run_scheduled_work(struct work_struct *work)
+{
+       for (;;) {
+               struct cpu_workqueue_struct *cwq;
+
+               if (!work_pending(work))
+                       return 0;
+               if (list_empty(&work->entry))
+                       return 0;
+               /* NOTE! This depends intimately on __queue_work! */
+               cwq = get_wq_data(work);
+               if (!cwq)
+                       return 0;
+               if (__run_work(cwq, work))
+                       return 1;
+       }
+}
+EXPORT_SYMBOL(run_scheduled_work);
+
 /* Preempt must be disabled. */
 static void __queue_work(struct cpu_workqueue_struct *cwq,
                         struct work_struct *work)
@@ -250,6 +325,17 @@ static void run_workqueue(struct cpu_workqueue_struct *cwq)
                        work_release(work);
                f(work);
 
+               if (unlikely(in_atomic() || lockdep_depth(current) > 0)) {
+                       printk(KERN_ERR "BUG: workqueue leaked lock or atomic: "
+                                       "%s/0x%08x/%d\n",
+                                       current->comm, preempt_count(),
+                                       current->pid);
+                       printk(KERN_ERR "    last function: ");
+                       print_symbol("%s\n", (unsigned long)f);
+                       debug_show_held_locks(current);
+                       dump_stack();
+               }
+
                spin_lock_irqsave(&cwq->lock, flags);
                cwq->remove_sequence++;
                wake_up(&cwq->work_done);
@@ -265,7 +351,8 @@ static int worker_thread(void *__cwq)
        struct k_sigaction sa;
        sigset_t blocked;
 
-       current->flags |= PF_NOFREEZE;
+       if (!cwq->freezeable)
+               current->flags |= PF_NOFREEZE;
 
        set_user_nice(current, -5);
 
@@ -288,6 +375,9 @@ static int worker_thread(void *__cwq)
 
        set_current_state(TASK_INTERRUPTIBLE);
        while (!kthread_should_stop()) {
+               if (cwq->freezeable)
+                       try_to_freeze();
+
                add_wait_queue(&cwq->more_work, &wait);
                if (list_empty(&cwq->worklist))
                        schedule();
@@ -364,7 +454,7 @@ void fastcall flush_workqueue(struct workqueue_struct *wq)
 EXPORT_SYMBOL_GPL(flush_workqueue);
 
 static struct task_struct *create_workqueue_thread(struct workqueue_struct *wq,
-                                                  int cpu)
+                                                  int cpu, int freezeable)
 {
        struct cpu_workqueue_struct *cwq = per_cpu_ptr(wq->cpu_wq, cpu);
        struct task_struct *p;
@@ -374,6 +464,7 @@ static struct task_struct *create_workqueue_thread(struct workqueue_struct *wq,
        cwq->thread = NULL;
        cwq->insert_sequence = 0;
        cwq->remove_sequence = 0;
+       cwq->freezeable = freezeable;
        INIT_LIST_HEAD(&cwq->worklist);
        init_waitqueue_head(&cwq->more_work);
        init_waitqueue_head(&cwq->work_done);
@@ -389,7 +480,7 @@ static struct task_struct *create_workqueue_thread(struct workqueue_struct *wq,
 }
 
 struct workqueue_struct *__create_workqueue(const char *name,
-                                           int singlethread)
+                                           int singlethread, int freezeable)
 {
        int cpu, destroy = 0;
        struct workqueue_struct *wq;
@@ -409,7 +500,7 @@ struct workqueue_struct *__create_workqueue(const char *name,
        mutex_lock(&workqueue_mutex);
        if (singlethread) {
                INIT_LIST_HEAD(&wq->list);
-               p = create_workqueue_thread(wq, singlethread_cpu);
+               p = create_workqueue_thread(wq, singlethread_cpu, freezeable);
                if (!p)
                        destroy = 1;
                else
@@ -417,7 +508,7 @@ struct workqueue_struct *__create_workqueue(const char *name,
        } else {
                list_add(&wq->list, &workqueues);
                for_each_online_cpu(cpu) {
-                       p = create_workqueue_thread(wq, cpu);
+                       p = create_workqueue_thread(wq, cpu, freezeable);
                        if (p) {
                                kthread_bind(p, cpu);
                                wake_up_process(p);
@@ -634,7 +725,6 @@ int current_is_keventd(void)
 
 }
 
-#ifdef CONFIG_HOTPLUG_CPU
 /* Take the work from this (downed) CPU. */
 static void take_over_work(struct workqueue_struct *wq, unsigned int cpu)
 {
@@ -667,7 +757,7 @@ static int __devinit workqueue_cpu_callback(struct notifier_block *nfb,
                mutex_lock(&workqueue_mutex);
                /* Create a new workqueue thread for it. */
                list_for_each_entry(wq, &workqueues, list) {
-                       if (!create_workqueue_thread(wq, hotcpu)) {
+                       if (!create_workqueue_thread(wq, hotcpu, 0)) {
                                printk("workqueue for %i failed\n", hotcpu);
                                return NOTIFY_BAD;
                        }
@@ -717,7 +807,6 @@ static int __devinit workqueue_cpu_callback(struct notifier_block *nfb,
 
        return NOTIFY_OK;
 }
-#endif
 
 void init_workqueues(void)
 {
index 734ce95a93d121ab892fdadcf0f51a54079e5747..47b172df3e312775f4accaa804fd42256d5331f7 100644 (file)
@@ -4,6 +4,9 @@
 
 menu "Library routines"
 
+config BITREVERSE
+       tristate
+
 config CRC_CCITT
        tristate "CRC-CCITT functions"
        help
@@ -23,6 +26,7 @@ config CRC16
 config CRC32
        tristate "CRC32 functions"
        default y
+       select BITREVERSE
        help
          This option is provided for the case where no in-kernel-tree
          modules require CRC32 functions, but a module built outside the
index d3679103a8e4eff9baafdfd30f41e9f28aefe7ef..6eccc643c32edc3e2b11920ba17c1bd73ba11609 100644 (file)
@@ -1,6 +1,7 @@
 
 config PRINTK_TIME
        bool "Show timing information on printks"
+       depends on PRINTK
        help
          Selecting this option causes timing information to be
          included in printk output.  This allows you to measure
@@ -284,7 +285,7 @@ config DEBUG_HIGHMEM
 config DEBUG_BUGVERBOSE
        bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EMBEDDED
        depends on BUG
-       depends on ARM || ARM26 || AVR32 || M32R || M68K || SPARC32 || SPARC64 || X86_32 || FRV || SUPERH
+       depends on ARM || ARM26 || AVR32 || M32R || M68K || SPARC32 || SPARC64 || FRV || SUPERH || GENERIC_BUG
        default !EMBEDDED
        help
          Say Y here to make BUG() panics output the file name and line number
@@ -412,3 +413,36 @@ config LKDTM
 
        Documentation on how to use the module can be found in
        drivers/misc/lkdtm.c
+
+config FAULT_INJECTION
+       bool "Fault-injection framework"
+       depends on DEBUG_KERNEL
+       depends on STACKTRACE
+       select FRAME_POINTER
+       help
+         Provide fault-injection framework.
+         For more details, see Documentation/fault-injection/.
+
+config FAILSLAB
+       bool "Fault-injection capability for kmalloc"
+       depends on FAULT_INJECTION
+       help
+         Provide fault-injection capability for kmalloc.
+
+config FAIL_PAGE_ALLOC
+       bool "Fault-injection capabilitiy for alloc_pages()"
+       depends on FAULT_INJECTION
+       help
+         Provide fault-injection capability for alloc_pages().
+
+config FAIL_MAKE_REQUEST
+       bool "Fault-injection capabilitiy for disk IO"
+       depends on FAULT_INJECTION
+       help
+         Provide fault-injection capability for disk IO.
+
+config FAULT_INJECTION_DEBUG_FS
+       bool "Debugfs entries for fault-injection capabilities"
+       depends on FAULT_INJECTION && SYSFS && DEBUG_FS
+       help
+         Enable configuration of fault-injection capabilities via debugfs.
index cf98fabaa549524d2f882d06649abfaa4c91239d..2d6106af53cdf88773e2798a2c90cad0cb6cee53 100644 (file)
@@ -25,7 +25,7 @@ lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
 lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
 lib-$(CONFIG_SEMAPHORE_SLEEPERS) += semaphore-sleepers.o
 lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o
-lib-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
+obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
 obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o
 obj-$(CONFIG_PLIST) += plist.o
 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
@@ -35,6 +35,7 @@ ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
   lib-y += dec_and_lock.o
 endif
 
+obj-$(CONFIG_BITREVERSE) += bitrev.o
 obj-$(CONFIG_CRC_CCITT)        += crc-ccitt.o
 obj-$(CONFIG_CRC16)    += crc16.o
 obj-$(CONFIG_CRC32)    += crc32.o
@@ -54,6 +55,9 @@ obj-$(CONFIG_SMP) += percpu_counter.o
 obj-$(CONFIG_AUDIT_GENERIC) += audit.o
 
 obj-$(CONFIG_SWIOTLB) += swiotlb.o
+obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o
+
+lib-$(CONFIG_GENERIC_BUG) += bug.o
 
 hostprogs-y    := gen_crc32table
 clean-files    := crc32table.h
diff --git a/lib/bitrev.c b/lib/bitrev.c
new file mode 100644 (file)
index 0000000..f4e1c49
--- /dev/null
@@ -0,0 +1,54 @@
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/bitrev.h>
+
+const u8 byte_rev_table[256] = {
+       0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+       0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+       0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+       0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+       0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+       0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+       0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+       0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+       0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+       0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+       0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+       0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+       0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+       0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+       0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+       0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+       0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+       0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+       0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+       0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+       0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+       0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+       0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+       0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+       0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+       0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+       0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+       0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+       0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+       0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+       0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+       0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
+};
+EXPORT_SYMBOL_GPL(byte_rev_table);
+
+static __always_inline u16 bitrev16(u16 x)
+{
+       return (bitrev8(x & 0xff) << 8) | bitrev8(x >> 8);
+}
+
+/**
+ * bitrev32 - reverse the order of bits in a u32 value
+ * @x: value to be bit-reversed
+ */
+u32 bitrev32(u32 x)
+{
+       return (bitrev16(x & 0xffff) << 16) | bitrev16(x >> 16);
+}
+EXPORT_SYMBOL(bitrev32);
diff --git a/lib/bug.c b/lib/bug.c
new file mode 100644 (file)
index 0000000..014b582
--- /dev/null
+++ b/lib/bug.c
@@ -0,0 +1,163 @@
+/*
+  Generic support for BUG()
+
+  This respects the following config options:
+
+  CONFIG_BUG - emit BUG traps.  Nothing happens without this.
+  CONFIG_GENERIC_BUG - enable this code.
+  CONFIG_DEBUG_BUGVERBOSE - emit full file+line information for each BUG
+
+  CONFIG_BUG and CONFIG_DEBUG_BUGVERBOSE are potentially user-settable
+  (though they're generally always on).
+
+  CONFIG_GENERIC_BUG is set by each architecture using this code.
+
+  To use this, your architecture must:
+
+  1. Set up the config options:
+     - Enable CONFIG_GENERIC_BUG if CONFIG_BUG
+
+  2. Implement BUG (and optionally BUG_ON, WARN, WARN_ON)
+     - Define HAVE_ARCH_BUG
+     - Implement BUG() to generate a faulting instruction
+     - NOTE: struct bug_entry does not have "file" or "line" entries
+       when CONFIG_DEBUG_BUGVERBOSE is not enabled, so you must generate
+       the values accordingly.
+
+  3. Implement the trap
+     - In the illegal instruction trap handler (typically), verify
+       that the fault was in kernel mode, and call report_bug()
+     - report_bug() will return whether it was a false alarm, a warning,
+       or an actual bug.
+     - You must implement the is_valid_bugaddr(bugaddr) callback which
+       returns true if the eip is a real kernel address, and it points
+       to the expected BUG trap instruction.
+
+    Jeremy Fitzhardinge <jeremy@goop.org> 2006
+ */
+#include <linux/list.h>
+#include <linux/module.h>
+#include <linux/bug.h>
+
+extern const struct bug_entry __start___bug_table[], __stop___bug_table[];
+
+#ifdef CONFIG_MODULES
+static LIST_HEAD(module_bug_list);
+
+static const struct bug_entry *module_find_bug(unsigned long bugaddr)
+{
+       struct module *mod;
+
+       list_for_each_entry(mod, &module_bug_list, bug_list) {
+               const struct bug_entry *bug = mod->bug_table;
+               unsigned i;
+
+               for (i = 0; i < mod->num_bugs; ++i, ++bug)
+                       if (bugaddr == bug->bug_addr)
+                               return bug;
+       }
+       return NULL;
+}
+
+int module_bug_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
+                       struct module *mod)
+{
+       char *secstrings;
+       unsigned int i;
+
+       mod->bug_table = NULL;
+       mod->num_bugs = 0;
+
+       /* Find the __bug_table section, if present */
+       secstrings = (char *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
+       for (i = 1; i < hdr->e_shnum; i++) {
+               if (strcmp(secstrings+sechdrs[i].sh_name, "__bug_table"))
+                       continue;
+               mod->bug_table = (void *) sechdrs[i].sh_addr;
+               mod->num_bugs = sechdrs[i].sh_size / sizeof(struct bug_entry);
+               break;
+       }
+
+       /*
+        * Strictly speaking this should have a spinlock to protect against
+        * traversals, but since we only traverse on BUG()s, a spinlock
+        * could potentially lead to deadlock and thus be counter-productive.
+        */
+       list_add(&mod->bug_list, &module_bug_list);
+
+       return 0;
+}
+
+void module_bug_cleanup(struct module *mod)
+{
+       list_del(&mod->bug_list);
+}
+
+#else
+
+static inline const struct bug_entry *module_find_bug(unsigned long bugaddr)
+{
+       return NULL;
+}
+#endif
+
+const struct bug_entry *find_bug(unsigned long bugaddr)
+{
+       const struct bug_entry *bug;
+
+       for (bug = __start___bug_table; bug < __stop___bug_table; ++bug)
+               if (bugaddr == bug->bug_addr)
+                       return bug;
+
+       return module_find_bug(bugaddr);
+}
+
+enum bug_trap_type report_bug(unsigned long bugaddr)
+{
+       const struct bug_entry *bug;
+       const char *file;
+       unsigned line, warning;
+
+       if (!is_valid_bugaddr(bugaddr))
+               return BUG_TRAP_TYPE_NONE;
+
+       bug = find_bug(bugaddr);
+
+       printk(KERN_EMERG "------------[ cut here ]------------\n");
+
+       file = NULL;
+       line = 0;
+       warning = 0;
+
+       if (bug) {
+#ifdef CONFIG_DEBUG_BUGVERBOSE
+               file = bug->file;
+               line = bug->line;
+#endif
+               warning = (bug->flags & BUGFLAG_WARNING) != 0;
+       }
+
+       if (warning) {
+               /* this is a WARN_ON rather than BUG/BUG_ON */
+               if (file)
+                       printk(KERN_ERR "Badness at %s:%u\n",
+                              file, line);
+               else
+                       printk(KERN_ERR "Badness at %p "
+                              "[verbose debug info unavailable]\n",
+                              (void *)bugaddr);
+
+               dump_stack();
+               return BUG_TRAP_TYPE_WARN;
+       }
+
+       if (file)
+               printk(KERN_CRIT "kernel BUG at %s:%u!\n",
+                      file, line);
+       else
+               printk(KERN_CRIT "Kernel BUG at %p "
+                      "[verbose debug info unavailable]\n",
+                      (void *)bugaddr);
+
+       return BUG_TRAP_TYPE_BUG;
+}
index 0331ed825ea79e568a881852020a80adc3d4d658..8a5b5303bd4f7a78187b4138eb08945c6333c10c 100644 (file)
 #include <linux/kernel.h>
 #include <linux/string.h>
 
+/*
+ *     If a hyphen was found in get_option, this will handle the
+ *     range of numbers, M-N.  This will expand the range and insert
+ *     the values[M, M+1, ..., N] into the ints array in get_options.
+ */
+
+static int get_range(char **str, int *pint)
+{
+       int x, inc_counter, upper_range;
+
+       (*str)++;
+       upper_range = simple_strtol((*str), NULL, 0);
+       inc_counter = upper_range - *pint;
+       for (x = *pint; x < upper_range; x++)
+               *pint++ = x;
+       return inc_counter;
+}
 
 /**
  *     get_option - Parse integer from an option string
@@ -29,6 +46,7 @@
  *     0 : no int in string
  *     1 : int found, no subsequent comma
  *     2 : int found including a subsequent comma
+ *     3 : hyphen found to denote a range
  */
 
 int get_option (char **str, int *pint)
@@ -44,6 +62,8 @@ int get_option (char **str, int *pint)
                (*str)++;
                return 2;
        }
+       if (**str == '-')
+               return 3;
 
        return 1;
 }
@@ -55,7 +75,8 @@ int get_option (char **str, int *pint)
  *     @ints: integer array
  *
  *     This function parses a string containing a comma-separated
- *     list of integers.  The parse halts when the array is
+ *     list of integers, a hyphen-separated range of _positive_ integers,
+ *     or a combination of both.  The parse halts when the array is
  *     full, or when no more numbers can be retrieved from the
  *     string.
  *
@@ -72,6 +93,18 @@ char *get_options(const char *str, int nints, int *ints)
                res = get_option ((char **)&str, ints + i);
                if (res == 0)
                        break;
+               if (res == 3) {
+                       int range_nums;
+                       range_nums = get_range((char **)&str, ints + i);
+                       if (range_nums < 0)
+                               break;
+                       /*
+                        * Decrement the result by one to leave out the
+                        * last number in the range.  The next iteration
+                        * will handle the upper number in the range
+                        */
+                       i += (range_nums - 1);
+               }
                i++;
                if (res == 1)
                        break;
index 285fd9bc61be1b089441663b587f34ff409fb1ba..bfc33314c72088845f46e35465c31827e7170422 100644 (file)
@@ -235,23 +235,8 @@ u32 __attribute_pure__ crc32_be(u32 crc, unsigned char const *p, size_t len)
 }
 #endif
 
-/**
- * bitreverse - reverse the order of bits in a u32 value
- * @x: value to be bit-reversed
- */
-u32 bitreverse(u32 x)
-{
-       x = (x >> 16) | (x << 16);
-       x = (x >> 8 & 0x00ff00ff) | (x << 8 & 0xff00ff00);
-       x = (x >> 4 & 0x0f0f0f0f) | (x << 4 & 0xf0f0f0f0);
-       x = (x >> 2 & 0x33333333) | (x << 2 & 0xcccccccc);
-       x = (x >> 1 & 0x55555555) | (x << 1 & 0xaaaaaaaa);
-       return x;
-}
-
 EXPORT_SYMBOL(crc32_le);
 EXPORT_SYMBOL(crc32_be);
-EXPORT_SYMBOL(bitreverse);
 
 /*
  * A brief CRC tutorial.
@@ -400,10 +385,7 @@ buf_dump(char const *prefix, unsigned char const *buf, size_t len)
 static void bytereverse(unsigned char *buf, size_t len)
 {
        while (len--) {
-               unsigned char x = *buf;
-               x = (x >> 4) | (x << 4);
-               x = (x >> 2 & 0x33) | (x << 2 & 0xcc);
-               x = (x >> 1 & 0x55) | (x << 1 & 0xaa);
+               unsigned char x = bitrev8(*buf);
                *buf++ = x;
        }
 }
@@ -460,11 +442,11 @@ static u32 test_step(u32 init, unsigned char *buf, size_t len)
        /* Now swap it around for the other test */
 
        bytereverse(buf, len + 4);
-       init = bitreverse(init);
-       crc2 = bitreverse(crc1);
-       if (crc1 != bitreverse(crc2))
+       init = bitrev32(init);
+       crc2 = bitrev32(crc1);
+       if (crc1 != bitrev32(crc2))
                printf("\nBit reversal fail: 0x%08x -> 0x%08x -> 0x%08x\n",
-                      crc1, crc2, bitreverse(crc2));
+                      crc1, crc2, bitrev32(crc2));
        crc1 = crc32_le(init, buf, len);
        if (crc1 != crc2)
                printf("\nCRC endianness fail: 0x%08x != 0x%08x\n", crc1,
diff --git a/lib/fault-inject.c b/lib/fault-inject.c
new file mode 100644 (file)
index 0000000..d143c0f
--- /dev/null
@@ -0,0 +1,336 @@
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/random.h>
+#include <linux/stat.h>
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/unwind.h>
+#include <linux/stacktrace.h>
+#include <linux/kallsyms.h>
+#include <linux/fault-inject.h>
+
+/*
+ * setup_fault_attr() is a helper function for various __setup handlers, so it
+ * returns 0 on error, because that is what __setup handlers do.
+ */
+int __init setup_fault_attr(struct fault_attr *attr, char *str)
+{
+       unsigned long probability;
+       unsigned long interval;
+       int times;
+       int space;
+
+       /* "<interval>,<probability>,<space>,<times>" */
+       if (sscanf(str, "%lu,%lu,%d,%d",
+                       &interval, &probability, &space, &times) < 4) {
+               printk(KERN_WARNING
+                       "FAULT_INJECTION: failed to parse arguments\n");
+               return 0;
+       }
+
+       attr->probability = probability;
+       attr->interval = interval;
+       atomic_set(&attr->times, times);
+       atomic_set(&attr->space, space);
+
+       return 1;
+}
+
+static void fail_dump(struct fault_attr *attr)
+{
+       if (attr->verbose > 0)
+               printk(KERN_NOTICE "FAULT_INJECTION: forcing a failure\n");
+       if (attr->verbose > 1)
+               dump_stack();
+}
+
+#define atomic_dec_not_zero(v)         atomic_add_unless((v), -1, 0)
+
+static bool fail_task(struct fault_attr *attr, struct task_struct *task)
+{
+       return !in_interrupt() && task->make_it_fail;
+}
+
+#define MAX_STACK_TRACE_DEPTH 32
+
+#ifdef CONFIG_STACK_UNWIND
+
+static asmlinkage int fail_stacktrace_callback(struct unwind_frame_info *info,
+                                               void *arg)
+{
+       int depth;
+       struct fault_attr *attr = arg;
+       bool found = (attr->require_start == 0 && attr->require_end == ULONG_MAX);
+
+       for (depth = 0; depth < attr->stacktrace_depth
+                       && unwind(info) == 0 && UNW_PC(info); depth++) {
+               if (arch_unw_user_mode(info))
+                       break;
+               if (attr->reject_start <= UNW_PC(info) &&
+                              UNW_PC(info) < attr->reject_end)
+                       return false;
+               if (attr->require_start <= UNW_PC(info) &&
+                              UNW_PC(info) < attr->require_end)
+                       found = true;
+       }
+       return found;
+}
+
+static bool fail_stacktrace(struct fault_attr *attr)
+{
+       struct unwind_frame_info info;
+
+       return unwind_init_running(&info, fail_stacktrace_callback, attr);
+}
+
+#elif defined(CONFIG_STACKTRACE)
+
+static bool fail_stacktrace(struct fault_attr *attr)
+{
+       struct stack_trace trace;
+       int depth = attr->stacktrace_depth;
+       unsigned long entries[MAX_STACK_TRACE_DEPTH];
+       int n;
+       bool found = (attr->require_start == 0 && attr->require_end == ULONG_MAX);
+
+       if (depth == 0)
+               return found;
+
+       trace.nr_entries = 0;
+       trace.entries = entries;
+       trace.max_entries = depth;
+       trace.skip = 1;
+       trace.all_contexts = 0;
+
+       save_stack_trace(&trace, NULL);
+       for (n = 0; n < trace.nr_entries; n++) {
+               if (attr->reject_start <= entries[n] &&
+                              entries[n] < attr->reject_end)
+                       return false;
+               if (attr->require_start <= entries[n] &&
+                              entries[n] < attr->require_end)
+                       found = true;
+       }
+       return found;
+}
+
+#else
+
+static inline bool fail_stacktrace(struct fault_attr *attr)
+{
+       static bool firsttime = true;
+
+       if (firsttime) {
+               printk(KERN_WARNING
+               "This architecture does not implement save_stack_trace()\n");
+               firsttime = false;
+       }
+       return false;
+}
+
+#endif
+
+/*
+ * This code is stolen from failmalloc-1.0
+ * http://www.nongnu.org/failmalloc/
+ */
+
+bool should_fail(struct fault_attr *attr, ssize_t size)
+{
+       if (attr->task_filter && !fail_task(attr, current))
+               return false;
+
+       if (atomic_read(&attr->times) == 0)
+               return false;
+
+       if (atomic_read(&attr->space) > size) {
+               atomic_sub(size, &attr->space);
+               return false;
+       }
+
+       if (attr->interval > 1) {
+               attr->count++;
+               if (attr->count % attr->interval)
+                       return false;
+       }
+
+       if (attr->probability <= random32() % 100)
+               return false;
+
+       if (!fail_stacktrace(attr))
+               return false;
+
+       fail_dump(attr);
+
+       if (atomic_read(&attr->times) != -1)
+               atomic_dec_not_zero(&attr->times);
+
+       return true;
+}
+
+#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
+
+static void debugfs_ul_set(void *data, u64 val)
+{
+       *(unsigned long *)data = val;
+}
+
+static void debugfs_ul_set_MAX_STACK_TRACE_DEPTH(void *data, u64 val)
+{
+       *(unsigned long *)data =
+               val < MAX_STACK_TRACE_DEPTH ?
+               val : MAX_STACK_TRACE_DEPTH;
+}
+
+static u64 debugfs_ul_get(void *data)
+{
+       return *(unsigned long *)data;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(fops_ul, debugfs_ul_get, debugfs_ul_set, "%llu\n");
+
+static struct dentry *debugfs_create_ul(const char *name, mode_t mode,
+                               struct dentry *parent, unsigned long *value)
+{
+       return debugfs_create_file(name, mode, parent, value, &fops_ul);
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(fops_ul_MAX_STACK_TRACE_DEPTH, debugfs_ul_get,
+                       debugfs_ul_set_MAX_STACK_TRACE_DEPTH, "%llu\n");
+
+static struct dentry *debugfs_create_ul_MAX_STACK_TRACE_DEPTH(
+       const char *name, mode_t mode,
+       struct dentry *parent, unsigned long *value)
+{
+       return debugfs_create_file(name, mode, parent, value,
+                                  &fops_ul_MAX_STACK_TRACE_DEPTH);
+}
+
+static void debugfs_atomic_t_set(void *data, u64 val)
+{
+       atomic_set((atomic_t *)data, val);
+}
+
+static u64 debugfs_atomic_t_get(void *data)
+{
+       return atomic_read((atomic_t *)data);
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(fops_atomic_t, debugfs_atomic_t_get,
+                       debugfs_atomic_t_set, "%lld\n");
+
+static struct dentry *debugfs_create_atomic_t(const char *name, mode_t mode,
+                               struct dentry *parent, atomic_t *value)
+{
+       return debugfs_create_file(name, mode, parent, value, &fops_atomic_t);
+}
+
+void cleanup_fault_attr_dentries(struct fault_attr *attr)
+{
+       debugfs_remove(attr->dentries.probability_file);
+       attr->dentries.probability_file = NULL;
+
+       debugfs_remove(attr->dentries.interval_file);
+       attr->dentries.interval_file = NULL;
+
+       debugfs_remove(attr->dentries.times_file);
+       attr->dentries.times_file = NULL;
+
+       debugfs_remove(attr->dentries.space_file);
+       attr->dentries.space_file = NULL;
+
+       debugfs_remove(attr->dentries.verbose_file);
+       attr->dentries.verbose_file = NULL;
+
+       debugfs_remove(attr->dentries.task_filter_file);
+       attr->dentries.task_filter_file = NULL;
+
+       debugfs_remove(attr->dentries.stacktrace_depth_file);
+       attr->dentries.stacktrace_depth_file = NULL;
+
+       debugfs_remove(attr->dentries.require_start_file);
+       attr->dentries.require_start_file = NULL;
+
+       debugfs_remove(attr->dentries.require_end_file);
+       attr->dentries.require_end_file = NULL;
+
+       debugfs_remove(attr->dentries.reject_start_file);
+       attr->dentries.reject_start_file = NULL;
+
+       debugfs_remove(attr->dentries.reject_end_file);
+       attr->dentries.reject_end_file = NULL;
+
+       if (attr->dentries.dir)
+               WARN_ON(!simple_empty(attr->dentries.dir));
+
+       debugfs_remove(attr->dentries.dir);
+       attr->dentries.dir = NULL;
+}
+
+int init_fault_attr_dentries(struct fault_attr *attr, const char *name)
+{
+       mode_t mode = S_IFREG | S_IRUSR | S_IWUSR;
+       struct dentry *dir;
+
+       memset(&attr->dentries, 0, sizeof(attr->dentries));
+
+       dir = debugfs_create_dir(name, NULL);
+       if (!dir)
+               goto fail;
+       attr->dentries.dir = dir;
+
+       attr->dentries.probability_file =
+               debugfs_create_ul("probability", mode, dir, &attr->probability);
+
+       attr->dentries.interval_file =
+               debugfs_create_ul("interval", mode, dir, &attr->interval);
+
+       attr->dentries.times_file =
+               debugfs_create_atomic_t("times", mode, dir, &attr->times);
+
+       attr->dentries.space_file =
+               debugfs_create_atomic_t("space", mode, dir, &attr->space);
+
+       attr->dentries.verbose_file =
+               debugfs_create_ul("verbose", mode, dir, &attr->verbose);
+
+       attr->dentries.task_filter_file = debugfs_create_bool("task-filter",
+                                               mode, dir, &attr->task_filter);
+
+       attr->dentries.stacktrace_depth_file =
+               debugfs_create_ul_MAX_STACK_TRACE_DEPTH(
+                       "stacktrace-depth", mode, dir, &attr->stacktrace_depth);
+
+       attr->dentries.require_start_file =
+               debugfs_create_ul("require-start", mode, dir, &attr->require_start);
+
+       attr->dentries.require_end_file =
+               debugfs_create_ul("require-end", mode, dir, &attr->require_end);
+
+       attr->dentries.reject_start_file =
+               debugfs_create_ul("reject-start", mode, dir, &attr->reject_start);
+
+       attr->dentries.reject_end_file =
+               debugfs_create_ul("reject-end", mode, dir, &attr->reject_end);
+
+
+       if (!attr->dentries.probability_file || !attr->dentries.interval_file
+           || !attr->dentries.times_file || !attr->dentries.space_file
+           || !attr->dentries.verbose_file || !attr->dentries.task_filter_file
+           || !attr->dentries.stacktrace_depth_file
+           || !attr->dentries.require_start_file
+           || !attr->dentries.require_end_file
+           || !attr->dentries.reject_start_file
+           || !attr->dentries.reject_end_file
+           )
+               goto fail;
+
+       return 0;
+fail:
+       cleanup_fault_attr_dentries(attr);
+       return -ENOMEM;
+}
+
+#endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */
index 16d2143fea4847e5c367e56d87db654599109713..71853531d3b0f6be6c0db0420ca8d646dd884469 100644 (file)
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -33,7 +33,7 @@
 #include <linux/string.h>
 #include <linux/idr.h>
 
-static kmem_cache_t *idr_layer_cache;
+static struct kmem_cache *idr_layer_cache;
 
 static struct idr_layer *alloc_layer(struct idr *idp)
 {
@@ -445,7 +445,7 @@ void *idr_replace(struct idr *idp, void *ptr, int id)
 }
 EXPORT_SYMBOL(idr_replace);
 
-static void idr_cache_ctor(void * idr_layer, kmem_cache_t *idr_layer_cache,
+static void idr_cache_ctor(void * idr_layer, struct kmem_cache *idr_layer_cache,
                unsigned long flags)
 {
        memset(idr_layer, 0, sizeof(struct idr_layer));
index 744a4b102c7fa595b09808f8a6f949318a1f57a1..7ce6dc138e90ed391618b222847a664024daf402 100644 (file)
@@ -111,10 +111,9 @@ char *kobject_get_path(struct kobject *kobj, gfp_t gfp_mask)
        len = get_kobj_path_length(kobj);
        if (len == 0)
                return NULL;
-       path = kmalloc(len, gfp_mask);
+       path = kzalloc(len, gfp_mask);
        if (!path)
                return NULL;
-       memset(path, 0x00, len);
        fill_kobj_path(kobj, path, len);
 
        return path;
index 7ba9d823d388665cdef6cb647a13cc0bd41ddb75..4350ba9655bd182c966c1fc40909ace292c8a4a6 100644 (file)
@@ -21,13 +21,15 @@ void __list_add(struct list_head *new,
                              struct list_head *next)
 {
        if (unlikely(next->prev != prev)) {
-               printk(KERN_ERR "list_add corruption. next->prev should be %p, but was %p\n",
-                       prev, next->prev);
+               printk(KERN_ERR "list_add corruption. next->prev should be "
+                       "prev (%p), but was %p. (next=%p).\n",
+                       prev, next->prev, next);
                BUG();
        }
        if (unlikely(prev->next != next)) {
-               printk(KERN_ERR "list_add corruption. prev->next should be %p, but was %p\n",
-                       next, prev->next);
+               printk(KERN_ERR "list_add corruption. prev->next should be "
+                       "next (%p), but was %p. (prev=%p).\n",
+                       next, prev->next, prev);
                BUG();
        }
        next->prev = new;
index 7945787f439a2152138da4b85c1604a8bed53c81..280332c1827cbb7b1d183e349f8eb1ba35cd2f8e 100644 (file)
@@ -963,7 +963,9 @@ static void dotest(void (*testcase_fn)(void), int expected, int lockclass_mask)
                        printk("failed|");
                } else {
                        unexpected_testcase_failures++;
+
                        printk("FAILED|");
+                       dump_stack();
                }
        } else {
                testcase_successes++;
index aa9bfd0bdbd1bd720ed1eb8c5416b180bad3b98a..d69ddbe438655be6b65672d2c7366371baadfd85 100644 (file)
@@ -2,6 +2,7 @@
  * Copyright (C) 2001 Momchil Velikov
  * Portions Copyright (C) 2001 Christoph Hellwig
  * Copyright (C) 2005 SGI, Christoph Lameter <clameter@sgi.com>
+ * Copyright (C) 2006 Nick Piggin
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -30,6 +31,7 @@
 #include <linux/gfp.h>
 #include <linux/string.h>
 #include <linux/bitops.h>
+#include <linux/rcupdate.h>
 
 
 #ifdef __KERNEL__
@@ -45,7 +47,9 @@
        ((RADIX_TREE_MAP_SIZE + BITS_PER_LONG - 1) / BITS_PER_LONG)
 
 struct radix_tree_node {
+       unsigned int    height;         /* Height from the bottom */
        unsigned int    count;
+       struct rcu_head rcu_head;
        void            *slots[RADIX_TREE_MAP_SIZE];
        unsigned long   tags[RADIX_TREE_MAX_TAGS][RADIX_TREE_TAG_LONGS];
 };
@@ -63,7 +67,7 @@ static unsigned long height_to_maxindex[RADIX_TREE_MAX_PATH] __read_mostly;
 /*
  * Radix tree node cache.
  */
-static kmem_cache_t *radix_tree_node_cachep;
+static struct kmem_cache *radix_tree_node_cachep;
 
 /*
  * Per-cpu pool of preloaded nodes
@@ -100,13 +104,21 @@ radix_tree_node_alloc(struct radix_tree_root *root)
                        rtp->nr--;
                }
        }
+       BUG_ON(radix_tree_is_direct_ptr(ret));
        return ret;
 }
 
+static void radix_tree_node_rcu_free(struct rcu_head *head)
+{
+       struct radix_tree_node *node =
+                       container_of(head, struct radix_tree_node, rcu_head);
+       kmem_cache_free(radix_tree_node_cachep, node);
+}
+
 static inline void
 radix_tree_node_free(struct radix_tree_node *node)
 {
-       kmem_cache_free(radix_tree_node_cachep, node);
+       call_rcu(&node->rcu_head, radix_tree_node_rcu_free);
 }
 
 /*
@@ -222,11 +234,12 @@ static int radix_tree_extend(struct radix_tree_root *root, unsigned long index)
        }
 
        do {
+               unsigned int newheight;
                if (!(node = radix_tree_node_alloc(root)))
                        return -ENOMEM;
 
                /* Increase the height.  */
-               node->slots[0] = root->rnode;
+               node->slots[0] = radix_tree_direct_to_ptr(root->rnode);
 
                /* Propagate the aggregated tag info into the new root */
                for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++) {
@@ -234,9 +247,11 @@ static int radix_tree_extend(struct radix_tree_root *root, unsigned long index)
                                tag_set(node, tag, 0);
                }
 
+               newheight = root->height+1;
+               node->height = newheight;
                node->count = 1;
-               root->rnode = node;
-               root->height++;
+               rcu_assign_pointer(root->rnode, node);
+               root->height = newheight;
        } while (height > root->height);
 out:
        return 0;
@@ -258,6 +273,8 @@ int radix_tree_insert(struct radix_tree_root *root,
        int offset;
        int error;
 
+       BUG_ON(radix_tree_is_direct_ptr(item));
+
        /* Make sure the tree is high enough.  */
        if (index > radix_tree_maxindex(root->height)) {
                error = radix_tree_extend(root, index);
@@ -275,11 +292,12 @@ int radix_tree_insert(struct radix_tree_root *root,
                        /* Have to add a child node.  */
                        if (!(slot = radix_tree_node_alloc(root)))
                                return -ENOMEM;
+                       slot->height = height;
                        if (node) {
-                               node->slots[offset] = slot;
+                               rcu_assign_pointer(node->slots[offset], slot);
                                node->count++;
                        } else
-                               root->rnode = slot;
+                               rcu_assign_pointer(root->rnode, slot);
                }
 
                /* Go a level down */
@@ -295,11 +313,11 @@ int radix_tree_insert(struct radix_tree_root *root,
 
        if (node) {
                node->count++;
-               node->slots[offset] = item;
+               rcu_assign_pointer(node->slots[offset], item);
                BUG_ON(tag_get(node, 0, offset));
                BUG_ON(tag_get(node, 1, offset));
        } else {
-               root->rnode = item;
+               rcu_assign_pointer(root->rnode, radix_tree_ptr_to_direct(item));
                BUG_ON(root_tag_get(root, 0));
                BUG_ON(root_tag_get(root, 1));
        }
@@ -308,49 +326,54 @@ int radix_tree_insert(struct radix_tree_root *root,
 }
 EXPORT_SYMBOL(radix_tree_insert);
 
-static inline void **__lookup_slot(struct radix_tree_root *root,
-                                  unsigned long index)
+/**
+ *     radix_tree_lookup_slot    -    lookup a slot in a radix tree
+ *     @root:          radix tree root
+ *     @index:         index key
+ *
+ *     Returns:  the slot corresponding to the position @index in the
+ *     radix tree @root. This is useful for update-if-exists operations.
+ *
+ *     This function cannot be called under rcu_read_lock, it must be
+ *     excluded from writers, as must the returned slot for subsequent
+ *     use by radix_tree_deref_slot() and radix_tree_replace slot.
+ *     Caller must hold tree write locked across slot lookup and
+ *     replace.
+ */
+void **radix_tree_lookup_slot(struct radix_tree_root *root, unsigned long index)
 {
        unsigned int height, shift;
-       struct radix_tree_node **slot;
-
-       height = root->height;
+       struct radix_tree_node *node, **slot;
 
-       if (index > radix_tree_maxindex(height))
+       node = root->rnode;
+       if (node == NULL)
                return NULL;
 
-       if (height == 0 && root->rnode)
+       if (radix_tree_is_direct_ptr(node)) {
+               if (index > 0)
+                       return NULL;
                return (void **)&root->rnode;
+       }
+
+       height = node->height;
+       if (index > radix_tree_maxindex(height))
+               return NULL;
 
        shift = (height-1) * RADIX_TREE_MAP_SHIFT;
-       slot = &root->rnode;
 
-       while (height > 0) {
-               if (*slot == NULL)
+       do {
+               slot = (struct radix_tree_node **)
+                       (node->slots + ((index>>shift) & RADIX_TREE_MAP_MASK));
+               node = *slot;
+               if (node == NULL)
                        return NULL;
 
-               slot = (struct radix_tree_node **)
-                       ((*slot)->slots +
-                               ((index >> shift) & RADIX_TREE_MAP_MASK));
                shift -= RADIX_TREE_MAP_SHIFT;
                height--;
-       }
+       } while (height > 0);
 
        return (void **)slot;
 }
-
-/**
- *     radix_tree_lookup_slot    -    lookup a slot in a radix tree
- *     @root:          radix tree root
- *     @index:         index key
- *
- *     Lookup the slot corresponding to the position @index in the radix tree
- *     @root. This is useful for update-if-exists operations.
- */
-void **radix_tree_lookup_slot(struct radix_tree_root *root, unsigned long index)
-{
-       return __lookup_slot(root, index);
-}
 EXPORT_SYMBOL(radix_tree_lookup_slot);
 
 /**
@@ -359,13 +382,45 @@ EXPORT_SYMBOL(radix_tree_lookup_slot);
  *     @index:         index key
  *
  *     Lookup the item at the position @index in the radix tree @root.
+ *
+ *     This function can be called under rcu_read_lock, however the caller
+ *     must manage lifetimes of leaf nodes (eg. RCU may also be used to free
+ *     them safely). No RCU barriers are required to access or modify the
+ *     returned item, however.
  */
 void *radix_tree_lookup(struct radix_tree_root *root, unsigned long index)
 {
-       void **slot;
+       unsigned int height, shift;
+       struct radix_tree_node *node, **slot;
+
+       node = rcu_dereference(root->rnode);
+       if (node == NULL)
+               return NULL;
+
+       if (radix_tree_is_direct_ptr(node)) {
+               if (index > 0)
+                       return NULL;
+               return radix_tree_direct_to_ptr(node);
+       }
+
+       height = node->height;
+       if (index > radix_tree_maxindex(height))
+               return NULL;
+
+       shift = (height-1) * RADIX_TREE_MAP_SHIFT;
 
-       slot = __lookup_slot(root, index);
-       return slot != NULL ? *slot : NULL;
+       do {
+               slot = (struct radix_tree_node **)
+                       (node->slots + ((index>>shift) & RADIX_TREE_MAP_MASK));
+               node = rcu_dereference(*slot);
+               if (node == NULL)
+                       return NULL;
+
+               shift -= RADIX_TREE_MAP_SHIFT;
+               height--;
+       } while (height > 0);
+
+       return node;
 }
 EXPORT_SYMBOL(radix_tree_lookup);
 
@@ -495,27 +550,30 @@ int radix_tree_tag_get(struct radix_tree_root *root,
                        unsigned long index, unsigned int tag)
 {
        unsigned int height, shift;
-       struct radix_tree_node *slot;
+       struct radix_tree_node *node;
        int saw_unset_tag = 0;
 
-       height = root->height;
-       if (index > radix_tree_maxindex(height))
-               return 0;
-
        /* check the root's tag bit */
        if (!root_tag_get(root, tag))
                return 0;
 
-       if (height == 0)
-               return 1;
+       node = rcu_dereference(root->rnode);
+       if (node == NULL)
+               return 0;
+
+       if (radix_tree_is_direct_ptr(node))
+               return (index == 0);
+
+       height = node->height;
+       if (index > radix_tree_maxindex(height))
+               return 0;
 
        shift = (height - 1) * RADIX_TREE_MAP_SHIFT;
-       slot = root->rnode;
 
        for ( ; ; ) {
                int offset;
 
-               if (slot == NULL)
+               if (node == NULL)
                        return 0;
 
                offset = (index >> shift) & RADIX_TREE_MAP_MASK;
@@ -524,15 +582,15 @@ int radix_tree_tag_get(struct radix_tree_root *root,
                 * This is just a debug check.  Later, we can bale as soon as
                 * we see an unset tag.
                 */
-               if (!tag_get(slot, tag, offset))
+               if (!tag_get(node, tag, offset))
                        saw_unset_tag = 1;
                if (height == 1) {
-                       int ret = tag_get(slot, tag, offset);
+                       int ret = tag_get(node, tag, offset);
 
                        BUG_ON(ret && saw_unset_tag);
                        return !!ret;
                }
-               slot = slot->slots[offset];
+               node = rcu_dereference(node->slots[offset]);
                shift -= RADIX_TREE_MAP_SHIFT;
                height--;
        }
@@ -541,47 +599,45 @@ EXPORT_SYMBOL(radix_tree_tag_get);
 #endif
 
 static unsigned int
-__lookup(struct radix_tree_root *root, void **results, unsigned long index,
+__lookup(struct radix_tree_node *slot, void **results, unsigned long index,
        unsigned int max_items, unsigned long *next_index)
 {
        unsigned int nr_found = 0;
        unsigned int shift, height;
-       struct radix_tree_node *slot;
        unsigned long i;
 
-       height = root->height;
-       if (height == 0) {
-               if (root->rnode && index == 0)
-                       results[nr_found++] = root->rnode;
+       height = slot->height;
+       if (height == 0)
                goto out;
-       }
-
        shift = (height-1) * RADIX_TREE_MAP_SHIFT;
-       slot = root->rnode;
 
        for ( ; height > 1; height--) {
-
-               for (i = (index >> shift) & RADIX_TREE_MAP_MASK ;
-                               i < RADIX_TREE_MAP_SIZE; i++) {
+               i = (index >> shift) & RADIX_TREE_MAP_MASK;
+               for (;;) {
                        if (slot->slots[i] != NULL)
                                break;
                        index &= ~((1UL << shift) - 1);
                        index += 1UL << shift;
                        if (index == 0)
                                goto out;       /* 32-bit wraparound */
+                       i++;
+                       if (i == RADIX_TREE_MAP_SIZE)
+                               goto out;
                }
-               if (i == RADIX_TREE_MAP_SIZE)
-                       goto out;
 
                shift -= RADIX_TREE_MAP_SHIFT;
-               slot = slot->slots[i];
+               slot = rcu_dereference(slot->slots[i]);
+               if (slot == NULL)
+                       goto out;
        }
 
        /* Bottom level: grab some items */
        for (i = index & RADIX_TREE_MAP_MASK; i < RADIX_TREE_MAP_SIZE; i++) {
+               struct radix_tree_node *node;
                index++;
-               if (slot->slots[i]) {
-                       results[nr_found++] = slot->slots[i];
+               node = slot->slots[i];
+               if (node) {
+                       results[nr_found++] = rcu_dereference(node);
                        if (nr_found == max_items)
                                goto out;
                }
@@ -603,28 +659,51 @@ out:
  *     *@results.
  *
  *     The implementation is naive.
+ *
+ *     Like radix_tree_lookup, radix_tree_gang_lookup may be called under
+ *     rcu_read_lock. In this case, rather than the returned results being
+ *     an atomic snapshot of the tree at a single point in time, the semantics
+ *     of an RCU protected gang lookup are as though multiple radix_tree_lookups
+ *     have been issued in individual locks, and results stored in 'results'.
  */
 unsigned int
 radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
                        unsigned long first_index, unsigned int max_items)
 {
-       const unsigned long max_index = radix_tree_maxindex(root->height);
+       unsigned long max_index;
+       struct radix_tree_node *node;
        unsigned long cur_index = first_index;
-       unsigned int ret = 0;
+       unsigned int ret;
+
+       node = rcu_dereference(root->rnode);
+       if (!node)
+               return 0;
 
+       if (radix_tree_is_direct_ptr(node)) {
+               if (first_index > 0)
+                       return 0;
+               node = radix_tree_direct_to_ptr(node);
+               results[0] = rcu_dereference(node);
+               return 1;
+       }
+
+       max_index = radix_tree_maxindex(node->height);
+
+       ret = 0;
        while (ret < max_items) {
                unsigned int nr_found;
                unsigned long next_index;       /* Index of next search */
 
                if (cur_index > max_index)
                        break;
-               nr_found = __lookup(root, results + ret, cur_index,
+               nr_found = __lookup(node, results + ret, cur_index,
                                        max_items - ret, &next_index);
                ret += nr_found;
                if (next_index == 0)
                        break;
                cur_index = next_index;
        }
+
        return ret;
 }
 EXPORT_SYMBOL(radix_tree_gang_lookup);
@@ -634,55 +713,64 @@ EXPORT_SYMBOL(radix_tree_gang_lookup);
  * open-coding the search.
  */
 static unsigned int
-__lookup_tag(struct radix_tree_root *root, void **results, unsigned long index,
+__lookup_tag(struct radix_tree_node *slot, void **results, unsigned long index,
        unsigned int max_items, unsigned long *next_index, unsigned int tag)
 {
        unsigned int nr_found = 0;
-       unsigned int shift;
-       unsigned int height = root->height;
-       struct radix_tree_node *slot;
+       unsigned int shift, height;
 
-       if (height == 0) {
-               if (root->rnode && index == 0)
-                       results[nr_found++] = root->rnode;
+       height = slot->height;
+       if (height == 0)
                goto out;
-       }
-
-       shift = (height - 1) * RADIX_TREE_MAP_SHIFT;
-       slot = root->rnode;
+       shift = (height-1) * RADIX_TREE_MAP_SHIFT;
 
-       do {
-               unsigned long i = (index >> shift) & RADIX_TREE_MAP_MASK;
+       while (height > 0) {
+               unsigned long i = (index >> shift) & RADIX_TREE_MAP_MASK ;
 
-               for ( ; i < RADIX_TREE_MAP_SIZE; i++) {
-                       if (tag_get(slot, tag, i)) {
-                               BUG_ON(slot->slots[i] == NULL);
+               for (;;) {
+                       if (tag_get(slot, tag, i))
                                break;
-                       }
                        index &= ~((1UL << shift) - 1);
                        index += 1UL << shift;
                        if (index == 0)
                                goto out;       /* 32-bit wraparound */
+                       i++;
+                       if (i == RADIX_TREE_MAP_SIZE)
+                               goto out;
                }
-               if (i == RADIX_TREE_MAP_SIZE)
-                       goto out;
                height--;
                if (height == 0) {      /* Bottom level: grab some items */
                        unsigned long j = index & RADIX_TREE_MAP_MASK;
 
                        for ( ; j < RADIX_TREE_MAP_SIZE; j++) {
+                               struct radix_tree_node *node;
                                index++;
-                               if (tag_get(slot, tag, j)) {
-                                       BUG_ON(slot->slots[j] == NULL);
-                                       results[nr_found++] = slot->slots[j];
+                               if (!tag_get(slot, tag, j))
+                                       continue;
+                               node = slot->slots[j];
+                               /*
+                                * Even though the tag was found set, we need to
+                                * recheck that we have a non-NULL node, because
+                                * if this lookup is lockless, it may have been
+                                * subsequently deleted.
+                                *
+                                * Similar care must be taken in any place that
+                                * lookup ->slots[x] without a lock (ie. can't
+                                * rely on its value remaining the same).
+                                */
+                               if (node) {
+                                       node = rcu_dereference(node);
+                                       results[nr_found++] = node;
                                        if (nr_found == max_items)
                                                goto out;
                                }
                        }
                }
                shift -= RADIX_TREE_MAP_SHIFT;
-               slot = slot->slots[i];
-       } while (height > 0);
+               slot = rcu_dereference(slot->slots[i]);
+               if (slot == NULL)
+                       break;
+       }
 out:
        *next_index = index;
        return nr_found;
@@ -706,27 +794,44 @@ radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,
                unsigned long first_index, unsigned int max_items,
                unsigned int tag)
 {
-       const unsigned long max_index = radix_tree_maxindex(root->height);
+       struct radix_tree_node *node;
+       unsigned long max_index;
        unsigned long cur_index = first_index;
-       unsigned int ret = 0;
+       unsigned int ret;
 
        /* check the root's tag bit */
        if (!root_tag_get(root, tag))
                return 0;
 
+       node = rcu_dereference(root->rnode);
+       if (!node)
+               return 0;
+
+       if (radix_tree_is_direct_ptr(node)) {
+               if (first_index > 0)
+                       return 0;
+               node = radix_tree_direct_to_ptr(node);
+               results[0] = rcu_dereference(node);
+               return 1;
+       }
+
+       max_index = radix_tree_maxindex(node->height);
+
+       ret = 0;
        while (ret < max_items) {
                unsigned int nr_found;
                unsigned long next_index;       /* Index of next search */
 
                if (cur_index > max_index)
                        break;
-               nr_found = __lookup_tag(root, results + ret, cur_index,
+               nr_found = __lookup_tag(node, results + ret, cur_index,
                                        max_items - ret, &next_index, tag);
                ret += nr_found;
                if (next_index == 0)
                        break;
                cur_index = next_index;
        }
+
        return ret;
 }
 EXPORT_SYMBOL(radix_tree_gang_lookup_tag);
@@ -742,8 +847,19 @@ static inline void radix_tree_shrink(struct radix_tree_root *root)
                        root->rnode->count == 1 &&
                        root->rnode->slots[0]) {
                struct radix_tree_node *to_free = root->rnode;
+               void *newptr;
 
-               root->rnode = to_free->slots[0];
+               /*
+                * We don't need rcu_assign_pointer(), since we are simply
+                * moving the node from one part of the tree to another. If
+                * it was safe to dereference the old pointer to it
+                * (to_free->slots[0]), it will be safe to dereference the new
+                * one (root->rnode).
+                */
+               newptr = to_free->slots[0];
+               if (root->height == 1)
+                       newptr = radix_tree_ptr_to_direct(newptr);
+               root->rnode = newptr;
                root->height--;
                /* must only free zeroed nodes into the slab */
                tag_clear(to_free, 0, 0);
@@ -767,6 +883,7 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
 {
        struct radix_tree_path path[RADIX_TREE_MAX_PATH], *pathp = path;
        struct radix_tree_node *slot = NULL;
+       struct radix_tree_node *to_free;
        unsigned int height, shift;
        int tag;
        int offset;
@@ -777,6 +894,7 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
 
        slot = root->rnode;
        if (height == 0 && root->rnode) {
+               slot = radix_tree_direct_to_ptr(slot);
                root_tag_clear_all(root);
                root->rnode = NULL;
                goto out;
@@ -809,10 +927,17 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
                        radix_tree_tag_clear(root, index, tag);
        }
 
+       to_free = NULL;
        /* Now free the nodes we do not need anymore */
        while (pathp->node) {
                pathp->node->slots[pathp->offset] = NULL;
                pathp->node->count--;
+               /*
+                * Queue the node for deferred freeing after the
+                * last reference to it disappears (set NULL, above).
+                */
+               if (to_free)
+                       radix_tree_node_free(to_free);
 
                if (pathp->node->count) {
                        if (pathp->node == root->rnode)
@@ -821,13 +946,15 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
                }
 
                /* Node with zero slots in use so free it */
-               radix_tree_node_free(pathp->node);
-
+               to_free = pathp->node;
                pathp--;
+
        }
        root_tag_clear_all(root);
        root->height = 0;
        root->rnode = NULL;
+       if (to_free)
+               radix_tree_node_free(to_free);
 
 out:
        return slot;
@@ -846,7 +973,7 @@ int radix_tree_tagged(struct radix_tree_root *root, unsigned int tag)
 EXPORT_SYMBOL(radix_tree_tagged);
 
 static void
-radix_tree_node_ctor(void *node, kmem_cache_t *cachep, unsigned long flags)
+radix_tree_node_ctor(void *node, struct kmem_cache *cachep, unsigned long flags)
 {
        memset(node, 0, sizeof(struct radix_tree_node));
 }
@@ -869,7 +996,6 @@ static __init void radix_tree_init_maxindex(void)
                height_to_maxindex[i] = __maxindex(i);
 }
 
-#ifdef CONFIG_HOTPLUG_CPU
 static int radix_tree_callback(struct notifier_block *nfb,
                             unsigned long action,
                             void *hcpu)
@@ -889,7 +1015,6 @@ static int radix_tree_callback(struct notifier_block *nfb,
        }
        return NOTIFY_OK;
 }
-#endif /* CONFIG_HOTPLUG_CPU */
 
 void __init radix_tree_init(void)
 {
index b6c4f898197c52f0b175ad0ea9e26466c338ea30..479fd462eaa9c7630df676bdddd91d4dd1212a2c 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/spinlock.h>
+#include <linux/nmi.h>
 #include <linux/interrupt.h>
 #include <linux/debug_locks.h>
 #include <linux/delay.h>
@@ -117,6 +118,9 @@ static void __spin_lock_debug(spinlock_t *lock)
                                raw_smp_processor_id(), current->comm,
                                current->pid, lock);
                        dump_stack();
+#ifdef CONFIG_SMP
+                       trigger_all_cpu_backtrace();
+#endif
                }
        }
 }
index eaa9abeea5364f6578c53c607d17955e3aebaef1..b2486cf887a06c1ecbd3c3d60d10682e2e5fc7d0 100644 (file)
 void percpu_depopulate(void *__pdata, int cpu)
 {
        struct percpu_data *pdata = __percpu_disguise(__pdata);
-       if (pdata->ptrs[cpu]) {
-               kfree(pdata->ptrs[cpu]);
-               pdata->ptrs[cpu] = NULL;
-       }
+
+       kfree(pdata->ptrs[cpu]);
+       pdata->ptrs[cpu] = NULL;
 }
 EXPORT_SYMBOL_GPL(percpu_depopulate);
 
@@ -123,6 +122,8 @@ EXPORT_SYMBOL_GPL(__percpu_alloc_mask);
  */
 void percpu_free(void *__pdata)
 {
+       if (unlikely(!__pdata))
+               return;
        __percpu_depopulate_mask(__pdata, &cpu_possible_map);
        kfree(__percpu_disguise(__pdata));
 }
index d53112fcb4040a3a2ecf930e013eb9933bc6d34f..00a96970b237efe9a62c8c6cd8859ef625868bc1 100644 (file)
@@ -27,8 +27,6 @@ unsigned long max_low_pfn;
 unsigned long min_low_pfn;
 unsigned long max_pfn;
 
-EXPORT_UNUSED_SYMBOL(max_pfn);  /*  June 2006  */
-
 static LIST_HEAD(bdata_list);
 #ifdef CONFIG_CRASH_DUMP
 /*
@@ -196,6 +194,10 @@ __alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size,
        if (limit && bdata->node_boot_start >= limit)
                return NULL;
 
+       /* on nodes without memory - bootmem_map is NULL */
+       if (!bdata->node_bootmem_map)
+               return NULL;
+
        end_pfn = bdata->node_low_pfn;
        limit = PFN_DOWN(limit);
        if (limit && end_pfn > limit)
index 168c78a121bb0f67835dabcae5e3f4edb74e8e7d..0df4c899e979ec1101cb629a660fc04b31e1095e 100644 (file)
@@ -38,7 +38,7 @@ asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
        if (!file)
                return -EBADF;
 
-       if (S_ISFIFO(file->f_dentry->d_inode->i_mode)) {
+       if (S_ISFIFO(file->f_path.dentry->d_inode->i_mode)) {
                ret = -ESPIPE;
                goto out;
        }
index 13df01c50479ce8fa2dc1fa283d6483c2a31937b..606432f71b3a17dafd791b46361c29a996beec18 100644 (file)
@@ -1445,7 +1445,6 @@ no_cached_page:
         * effect.
         */
        error = page_cache_read(file, pgoff);
-       grab_swap_token();
 
        /*
         * The page we want has now been added to the page cache.
@@ -2270,7 +2269,7 @@ __generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
        if (count == 0)
                goto out;
 
-       err = remove_suid(file->f_dentry);
+       err = remove_suid(file->f_path.dentry);
        if (err)
                goto out;
 
index b4fd0d7c9bfb23e08e2380d9b06bca14de4a95e7..8d667617f55847903ad1d364f6ee7fde3612f069 100644 (file)
@@ -379,7 +379,7 @@ xip_file_write(struct file *filp, const char __user *buf, size_t len,
        if (count == 0)
                goto out_backing;
 
-       ret = remove_suid(filp->f_dentry);
+       ret = remove_suid(filp->f_path.dentry);
        if (ret)
                goto out_backing;
 
index 7a9d0f5d246da922c132738f2476a688812fc1ac..b77a002c3352f7c91898b75b6636cc60e3ceadc2 100644 (file)
@@ -101,7 +101,6 @@ int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma,
 {
        int err = -ENOMEM;
        pte_t *pte;
-       pte_t pte_val;
        spinlock_t *ptl;
 
        pte = get_locked_pte(mm, addr, &ptl);
@@ -114,7 +113,6 @@ int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma,
        }
 
        set_pte_at(mm, addr, pte, pgoff_to_pte(pgoff));
-       pte_val = *pte;
        /*
         * We don't need to run update_mmu_cache() here because the "file pte"
         * being installed by install_file_pte() is not a real pte - it's a
index a088f593a807532aa9b37307a04b5427becfd449..0ccc7f2302529b0e3a237c556f895ab4ddfb3911 100644 (file)
@@ -109,7 +109,7 @@ static int alloc_fresh_huge_page(void)
        if (nid == MAX_NUMNODES)
                nid = first_node(node_online_map);
        if (page) {
-               page[1].lru.next = (void *)free_huge_page;      /* dtor */
+               set_compound_page_dtor(page, free_huge_page);
                spin_lock(&hugetlb_lock);
                nr_huge_pages++;
                nr_huge_pages_node[page_to_nid(page)]++;
@@ -344,7 +344,6 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
                        entry = *src_pte;
                        ptepage = pte_page(entry);
                        get_page(ptepage);
-                       add_mm_counter(dst, file_rss, HPAGE_SIZE / PAGE_SIZE);
                        set_huge_pte_at(dst, addr, dst_pte, entry);
                }
                spin_unlock(&src->page_table_lock);
@@ -365,6 +364,11 @@ void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
        pte_t pte;
        struct page *page;
        struct page *tmp;
+       /*
+        * A page gathering list, protected by per file i_mmap_lock. The
+        * lock is used to avoid list corruption from multiple unmapping
+        * of the same page since we are using page->lru.
+        */
        LIST_HEAD(page_list);
 
        WARN_ON(!is_vm_hugetlb_page(vma));
@@ -372,24 +376,21 @@ void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
        BUG_ON(end & ~HPAGE_MASK);
 
        spin_lock(&mm->page_table_lock);
-
-       /* Update high watermark before we lower rss */
-       update_hiwater_rss(mm);
-
        for (address = start; address < end; address += HPAGE_SIZE) {
                ptep = huge_pte_offset(mm, address);
                if (!ptep)
                        continue;
 
+               if (huge_pmd_unshare(mm, &address, ptep))
+                       continue;
+
                pte = huge_ptep_get_and_clear(mm, address, ptep);
                if (pte_none(pte))
                        continue;
 
                page = pte_page(pte);
                list_add(&page->lru, &page_list);
-               add_mm_counter(mm, file_rss, (int) -(HPAGE_SIZE / PAGE_SIZE));
        }
-
        spin_unlock(&mm->page_table_lock);
        flush_tlb_range(vma, start, end);
        list_for_each_entry_safe(page, tmp, &page_list, lru) {
@@ -515,7 +516,6 @@ retry:
        if (!pte_none(*ptep))
                goto backout;
 
-       add_mm_counter(mm, file_rss, HPAGE_SIZE / PAGE_SIZE);
        new_pte = make_huge_pte(vma, page, ((vma->vm_flags & VM_WRITE)
                                && (vma->vm_flags & VM_SHARED)));
        set_huge_pte_at(mm, address, ptep, new_pte);
@@ -653,11 +653,14 @@ void hugetlb_change_protection(struct vm_area_struct *vma,
        BUG_ON(address >= end);
        flush_cache_range(vma, address, end);
 
+       spin_lock(&vma->vm_file->f_mapping->i_mmap_lock);
        spin_lock(&mm->page_table_lock);
        for (; address < end; address += HPAGE_SIZE) {
                ptep = huge_pte_offset(mm, address);
                if (!ptep)
                        continue;
+               if (huge_pmd_unshare(mm, &address, ptep))
+                       continue;
                if (!pte_none(*ptep)) {
                        pte = huge_ptep_get_and_clear(mm, address, ptep);
                        pte = pte_mkhuge(pte_modify(pte, newprot));
@@ -666,6 +669,7 @@ void hugetlb_change_protection(struct vm_area_struct *vma,
                }
        }
        spin_unlock(&mm->page_table_lock);
+       spin_unlock(&vma->vm_file->f_mapping->i_mmap_lock);
 
        flush_tlb_range(vma, start, end);
 }
index 156861fcac436e4716537c7e5dff565dded43224..4198df0dff1c0f026355c1e8538761e81ba7254e 100644 (file)
@@ -1902,7 +1902,6 @@ int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end)
 
        return 0;
 }
-EXPORT_UNUSED_SYMBOL(vmtruncate_range);  /*  June 2006  */
 
 /**
  * swapin_readahead - swap in pages in hope we need them soon
@@ -1991,6 +1990,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
        delayacct_set_flag(DELAYACCT_PF_SWAPIN);
        page = lookup_swap_cache(entry);
        if (!page) {
+               grab_swap_token(); /* Contend for token _before_ read-in */
                swapin_readahead(entry, address, vma);
                page = read_swap_cache_async(entry, vma, address);
                if (!page) {
@@ -2008,7 +2008,6 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
                /* Had to read the page from swap area: Major fault */
                ret = VM_FAULT_MAJOR;
                count_vm_event(PGMAJFAULT);
-               grab_swap_token();
        }
 
        delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
index fd678a662eae1a015ef6393c2b6f23e586592105..0c055a090f4df19e042312e2a30cef3140fb8558 100644 (file)
@@ -72,7 +72,6 @@ static int __add_zone(struct zone *zone, unsigned long phys_start_pfn)
                        return ret;
        }
        memmap_init_zone(nr_pages, nid, zone_type, phys_start_pfn);
-       zonetable_add(zone, nid, zone_type, phys_start_pfn, nr_pages);
        return 0;
 }
 
index 617fb31086eef17d45f5b04df65ff3a851a7a19c..da9463946556311e9e0945583fd76cdd432298e5 100644 (file)
@@ -141,9 +141,11 @@ static struct zonelist *bind_zonelist(nodemask_t *nodes)
        enum zone_type k;
 
        max = 1 + MAX_NR_ZONES * nodes_weight(*nodes);
+       max++;                  /* space for zlcache_ptr (see mmzone.h) */
        zl = kmalloc(sizeof(struct zone *) * max, GFP_KERNEL);
        if (!zl)
                return NULL;
+       zl->zlcache_ptr = NULL;
        num = 0;
        /* First put in the highest zones from all nodes, then all the next 
           lower zones etc. Avoid empty zones because the memory allocator
@@ -219,7 +221,7 @@ static int check_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
        orig_pte = pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
        do {
                struct page *page;
-               unsigned int nid;
+               int nid;
 
                if (!pte_present(*pte))
                        continue;
@@ -1324,7 +1326,7 @@ struct mempolicy *__mpol_copy(struct mempolicy *old)
        atomic_set(&new->refcnt, 1);
        if (new->policy == MPOL_BIND) {
                int sz = ksize(old->v.zonelist);
-               new->v.zonelist = kmemdup(old->v.zonelist, sz, SLAB_KERNEL);
+               new->v.zonelist = kmemdup(old->v.zonelist, sz, GFP_KERNEL);
                if (!new->v.zonelist) {
                        kmem_cache_free(policy_cache, new);
                        return ERR_PTR(-ENOMEM);
@@ -1705,8 +1707,8 @@ void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new)
  * Display pages allocated per node and memory policy via /proc.
  */
 
-static const char *policy_types[] = { "default", "prefer", "bind",
-                                     "interleave" };
+static const char * const policy_types[] =
+       { "default", "prefer", "bind", "interleave" };
 
 /*
  * Convert a mempolicy into a string.
@@ -1855,7 +1857,7 @@ int show_numa_map(struct seq_file *m, void *v)
 
        if (file) {
                seq_printf(m, " file=");
-               seq_path(m, file->f_vfsmnt, file->f_dentry, "\n\t= ");
+               seq_path(m, file->f_path.mnt, file->f_path.dentry, "\n\t= ");
        } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
                seq_printf(m, " heap");
        } else if (vma->vm_start <= mm->start_stack &&
index b4979d423d2be5b7885f4cd7e24f45bdf7aa27ca..e9b161bde95b4c382092a1c94a8fcfbd4bcf58f0 100644 (file)
@@ -294,7 +294,7 @@ out:
 static int migrate_page_move_mapping(struct address_space *mapping,
                struct page *newpage, struct page *page)
 {
-       struct page **radix_pointer;
+       void **pslot;
 
        if (!mapping) {
                /* Anonymous page */
@@ -305,12 +305,11 @@ static int migrate_page_move_mapping(struct address_space *mapping,
 
        write_lock_irq(&mapping->tree_lock);
 
-       radix_pointer = (struct page **)radix_tree_lookup_slot(
-                                               &mapping->page_tree,
-                                               page_index(page));
+       pslot = radix_tree_lookup_slot(&mapping->page_tree,
+                                       page_index(page));
 
        if (page_count(page) != 2 + !!PagePrivate(page) ||
-                       *radix_pointer != page) {
+                       (struct page *)radix_tree_deref_slot(pslot) != page) {
                write_unlock_irq(&mapping->tree_lock);
                return -EAGAIN;
        }
@@ -318,7 +317,7 @@ static int migrate_page_move_mapping(struct address_space *mapping,
        /*
         * Now we know that no one else is looking at the page.
         */
-       get_page(newpage);
+       get_page(newpage);      /* add cache reference */
 #ifdef CONFIG_SWAP
        if (PageSwapCache(page)) {
                SetPageSwapCache(newpage);
@@ -326,8 +325,14 @@ static int migrate_page_move_mapping(struct address_space *mapping,
        }
 #endif
 
-       *radix_pointer = newpage;
+       radix_tree_replace_slot(pslot, newpage);
+
+       /*
+        * Drop cache reference from old page.
+        * We know this isn't the last reference.
+        */
        __put_page(page);
+
        write_unlock_irq(&mapping->tree_lock);
 
        return 0;
index b90c59573abf5da8bd00dcc7b224796ce66befc5..3446b7ef731e6c419cc0cf2656829eeca6fea5a7 100644 (file)
@@ -65,7 +65,7 @@ success:
                        ret = make_pages_present(start, end);
        }
 
-       vma->vm_mm->locked_vm -= pages;
+       mm->locked_vm -= pages;
 out:
        if (ret == -ENOMEM)
                ret = -EAGAIN;
index 7b40abd7cba26aeb49595af3f2ec15099e11e5ee..9717337293c3a7f3eb51ed60d70369efa8a24bb3 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -188,7 +188,7 @@ static void __remove_shared_vm_struct(struct vm_area_struct *vma,
                struct file *file, struct address_space *mapping)
 {
        if (vma->vm_flags & VM_DENYWRITE)
-               atomic_inc(&file->f_dentry->d_inode->i_writecount);
+               atomic_inc(&file->f_path.dentry->d_inode->i_writecount);
        if (vma->vm_flags & VM_SHARED)
                mapping->i_mmap_writable--;
 
@@ -399,7 +399,7 @@ static inline void __vma_link_file(struct vm_area_struct *vma)
                struct address_space *mapping = file->f_mapping;
 
                if (vma->vm_flags & VM_DENYWRITE)
-                       atomic_dec(&file->f_dentry->d_inode->i_writecount);
+                       atomic_dec(&file->f_path.dentry->d_inode->i_writecount);
                if (vma->vm_flags & VM_SHARED)
                        mapping->i_mmap_writable++;
 
@@ -907,7 +907,7 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
         *  mounted, in which case we dont add PROT_EXEC.)
         */
        if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
-               if (!(file && (file->f_vfsmnt->mnt_flags & MNT_NOEXEC)))
+               if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
                        prot |= PROT_EXEC;
 
        if (!len)
@@ -960,7 +960,7 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
                        return -EAGAIN;
        }
 
-       inode = file ? file->f_dentry->d_inode : NULL;
+       inode = file ? file->f_path.dentry->d_inode : NULL;
 
        if (file) {
                switch (flags & MAP_TYPE) {
@@ -989,7 +989,7 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
                case MAP_PRIVATE:
                        if (!(file->f_mode & FMODE_READ))
                                return -EACCES;
-                       if (file->f_vfsmnt->mnt_flags & MNT_NOEXEC) {
+                       if (file->f_path.mnt->mnt_flags & MNT_NOEXEC) {
                                if (vm_flags & VM_EXEC)
                                        return -EPERM;
                                vm_flags &= ~VM_MAYEXEC;
@@ -1736,7 +1736,7 @@ int split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
        if (mm->map_count >= sysctl_max_map_count)
                return -ENOMEM;
 
-       new = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+       new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
        if (!new)
                return -ENOMEM;
 
@@ -2057,7 +2057,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
                    vma_start < new_vma->vm_end)
                        *vmap = new_vma;
        } else {
-               new_vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+               new_vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
                if (new_vma) {
                        *new_vma = *vma;
                        pol = mpol_copy(vma_policy(vma));
index febea1c981685af5f05122434aa6f0ce11778430..eb5838634f181a1d6c58c948c10aac09dd272f26 100644 (file)
@@ -14,8 +14,6 @@ struct pglist_data *first_online_pgdat(void)
        return NODE_DATA(first_online_node);
 }
 
-EXPORT_UNUSED_SYMBOL(first_online_pgdat);  /*  June 2006  */
-
 struct pglist_data *next_online_pgdat(struct pglist_data *pgdat)
 {
        int nid = next_online_node(pgdat->node_id);
@@ -24,8 +22,6 @@ struct pglist_data *next_online_pgdat(struct pglist_data *pgdat)
                return NULL;
        return NODE_DATA(nid);
 }
-EXPORT_UNUSED_SYMBOL(next_online_pgdat);  /*  June 2006  */
-
 
 /*
  * next_zone - helper magic for for_each_zone()
@@ -45,5 +41,4 @@ struct zone *next_zone(struct zone *zone)
        }
        return zone;
 }
-EXPORT_UNUSED_SYMBOL(next_zone);  /*  June 2006  */
 
index 6a2a8aada40163c1653e8612ab29a4602e41d79c..23fb033e596d40e3d2bea57de77fb1e97bd87501 100644 (file)
@@ -523,7 +523,7 @@ static int validate_mmap_request(struct file *file,
                 */
                mapping = file->f_mapping;
                if (!mapping)
-                       mapping = file->f_dentry->d_inode->i_mapping;
+                       mapping = file->f_path.dentry->d_inode->i_mapping;
 
                capabilities = 0;
                if (mapping && mapping->backing_dev_info)
@@ -532,7 +532,7 @@ static int validate_mmap_request(struct file *file,
                if (!capabilities) {
                        /* no explicit capabilities set, so assume some
                         * defaults */
-                       switch (file->f_dentry->d_inode->i_mode & S_IFMT) {
+                       switch (file->f_path.dentry->d_inode->i_mode & S_IFMT) {
                        case S_IFREG:
                        case S_IFBLK:
                                capabilities = BDI_CAP_MAP_COPY;
@@ -563,11 +563,11 @@ static int validate_mmap_request(struct file *file,
                            !(file->f_mode & FMODE_WRITE))
                                return -EACCES;
 
-                       if (IS_APPEND(file->f_dentry->d_inode) &&
+                       if (IS_APPEND(file->f_path.dentry->d_inode) &&
                            (file->f_mode & FMODE_WRITE))
                                return -EACCES;
 
-                       if (locks_verify_locked(file->f_dentry->d_inode))
+                       if (locks_verify_locked(file->f_path.dentry->d_inode))
                                return -EAGAIN;
 
                        if (!(capabilities & BDI_CAP_MAP_DIRECT))
@@ -598,7 +598,7 @@ static int validate_mmap_request(struct file *file,
 
                /* handle executable mappings and implied executable
                 * mappings */
-               if (file->f_vfsmnt->mnt_flags & MNT_NOEXEC) {
+               if (file->f_path.mnt->mnt_flags & MNT_NOEXEC) {
                        if (prot & PROT_EXEC)
                                return -EPERM;
                }
@@ -808,10 +808,9 @@ unsigned long do_mmap_pgoff(struct file *file,
        vm_flags = determine_vm_flags(file, prot, flags, capabilities);
 
        /* we're going to need to record the mapping if it works */
-       vml = kmalloc(sizeof(struct vm_list_struct), GFP_KERNEL);
+       vml = kzalloc(sizeof(struct vm_list_struct), GFP_KERNEL);
        if (!vml)
                goto error_getting_vml;
-       memset(vml, 0, sizeof(*vml));
 
        down_write(&nommu_vma_sem);
 
@@ -834,7 +833,7 @@ unsigned long do_mmap_pgoff(struct file *file,
                                continue;
 
                        /* search for overlapping mappings on the same file */
-                       if (vma->vm_file->f_dentry->d_inode != file->f_dentry->d_inode)
+                       if (vma->vm_file->f_path.dentry->d_inode != file->f_path.dentry->d_inode)
                                continue;
 
                        if (vma->vm_pgoff >= pgoff + pglen)
@@ -887,11 +886,10 @@ unsigned long do_mmap_pgoff(struct file *file,
        }
 
        /* we're going to need a VMA struct as well */
-       vma = kmalloc(sizeof(struct vm_area_struct), GFP_KERNEL);
+       vma = kzalloc(sizeof(struct vm_area_struct), GFP_KERNEL);
        if (!vma)
                goto error_getting_vma;
 
-       memset(vma, 0, sizeof(*vma));
        INIT_LIST_HEAD(&vma->anon_vma_node);
        atomic_set(&vma->vm_usage, 1);
        if (file)
index 2e3ce3a928b97dd8eeb54b42fb6f363d15a6d2ae..223d9ccb7d64b6b28f5642ba3ab12629a170419a 100644 (file)
@@ -264,7 +264,7 @@ static struct task_struct *select_bad_process(unsigned long *ppoints)
  * flag though it's unlikely that  we select a process with CAP_SYS_RAW_IO
  * set.
  */
-static void __oom_kill_task(struct task_struct *p, const char *message)
+static void __oom_kill_task(struct task_struct *p, int verbose)
 {
        if (is_init(p)) {
                WARN_ON(1);
@@ -278,10 +278,8 @@ static void __oom_kill_task(struct task_struct *p, const char *message)
                return;
        }
 
-       if (message) {
-               printk(KERN_ERR "%s: Killed process %d (%s).\n",
-                               message, p->pid, p->comm);
-       }
+       if (verbose)
+               printk(KERN_ERR "Killed process %d (%s)\n", p->pid, p->comm);
 
        /*
         * We give our sacrificial lamb high priority and access to
@@ -294,7 +292,7 @@ static void __oom_kill_task(struct task_struct *p, const char *message)
        force_sig(SIGKILL, p);
 }
 
-static int oom_kill_task(struct task_struct *p, const char *message)
+static int oom_kill_task(struct task_struct *p)
 {
        struct mm_struct *mm;
        struct task_struct *g, *q;
@@ -313,15 +311,25 @@ static int oom_kill_task(struct task_struct *p, const char *message)
        if (mm == NULL)
                return 1;
 
-       __oom_kill_task(p, message);
+       /*
+        * Don't kill the process if any threads are set to OOM_DISABLE
+        */
+       do_each_thread(g, q) {
+               if (q->mm == mm && p->oomkilladj == OOM_DISABLE)
+                       return 1;
+       } while_each_thread(g, q);
+
+       __oom_kill_task(p, 1);
+
        /*
         * kill all processes that share the ->mm (i.e. all threads),
-        * but are in a different thread group
+        * but are in a different thread group. Don't let them have access
+        * to memory reserves though, otherwise we might deplete all memory.
         */
-       do_each_thread(g, q)
+       do_each_thread(g, q) {
                if (q->mm == mm && q->tgid != p->tgid)
-                       __oom_kill_task(q, message);
-       while_each_thread(g, q);
+                       force_sig(SIGKILL, p);
+       while_each_thread(g, q);
 
        return 0;
 }
@@ -337,21 +345,22 @@ static int oom_kill_process(struct task_struct *p, unsigned long points,
         * its children or threads, just set TIF_MEMDIE so it can die quickly
         */
        if (p->flags & PF_EXITING) {
-               __oom_kill_task(p, NULL);
+               __oom_kill_task(p, 0);
                return 0;
        }
 
-       printk(KERN_ERR "Out of Memory: Kill process %d (%s) score %li"
-                       " and children.\n", p->pid, p->comm, points);
+       printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
+                                       message, p->pid, p->comm, points);
+
        /* Try to kill a child first */
        list_for_each(tsk, &p->children) {
                c = list_entry(tsk, struct task_struct, sibling);
                if (c->mm == p->mm)
                        continue;
-               if (!oom_kill_task(c, message))
+               if (!oom_kill_task(c))
                        return 0;
        }
-       return oom_kill_task(p, message);
+       return oom_kill_task(p);
 }
 
 static BLOCKING_NOTIFIER_HEAD(oom_notify_list);
index aa6fcc7ca66f1f8bc976b5798039c3a0672d09eb..e6b17b2989e099636dcb1ec64587f130b8ad27c0 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/sort.h>
 #include <linux/pfn.h>
 #include <linux/backing-dev.h>
+#include <linux/fault-inject.h>
 
 #include <asm/tlbflush.h>
 #include <asm/div64.h>
@@ -83,14 +84,7 @@ int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = {
 
 EXPORT_SYMBOL(totalram_pages);
 
-/*
- * Used by page_zone() to look up the address of the struct zone whose
- * id is encoded in the upper bits of page->flags
- */
-struct zone *zone_table[1 << ZONETABLE_SHIFT] __read_mostly;
-EXPORT_SYMBOL(zone_table);
-
-static char *zone_names[MAX_NR_ZONES] = {
+static char * const zone_names[MAX_NR_ZONES] = {
         "DMA",
 #ifdef CONFIG_ZONE_DMA32
         "DMA32",
@@ -237,7 +231,7 @@ static void prep_compound_page(struct page *page, unsigned long order)
        int i;
        int nr_pages = 1 << order;
 
-       page[1].lru.next = (void *)free_compound_page;  /* set dtor */
+       set_compound_page_dtor(page, free_compound_page);
        page[1].lru.prev = (void *)order;
        for (i = 0; i < nr_pages; i++) {
                struct page *p = page + i;
@@ -486,7 +480,7 @@ static void free_one_page(struct zone *zone, struct page *page, int order)
        spin_lock(&zone->lock);
        zone->all_unreclaimable = 0;
        zone->pages_scanned = 0;
-       __free_one_page(page, zone ,order);
+       __free_one_page(page, zoneorder);
        spin_unlock(&zone->lock);
 }
 
@@ -605,6 +599,8 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
                        1 << PG_checked | 1 << PG_mappedtodisk);
        set_page_private(page, 0);
        set_page_refcounted(page);
+
+       arch_alloc_page(page, order);
        kernel_map_pages(page, 1 << order, 1);
 
        if (gfp_flags & __GFP_ZERO)
@@ -690,9 +686,15 @@ void drain_node_pages(int nodeid)
 
                        pcp = &pset->pcp[i];
                        if (pcp->count) {
+                               int to_drain;
+
                                local_irq_save(flags);
-                               free_pages_bulk(zone, pcp->count, &pcp->list, 0);
-                               pcp->count = 0;
+                               if (pcp->count >= pcp->batch)
+                                       to_drain = pcp->batch;
+                               else
+                                       to_drain = pcp->count;
+                               free_pages_bulk(zone, to_drain, &pcp->list, 0);
+                               pcp->count -= to_drain;
                                local_irq_restore(flags);
                        }
                }
@@ -700,7 +702,6 @@ void drain_node_pages(int nodeid)
 }
 #endif
 
-#if defined(CONFIG_PM) || defined(CONFIG_HOTPLUG_CPU)
 static void __drain_pages(unsigned int cpu)
 {
        unsigned long flags;
@@ -722,7 +723,6 @@ static void __drain_pages(unsigned int cpu)
                }
        }
 }
-#endif /* CONFIG_PM || CONFIG_HOTPLUG_CPU */
 
 #ifdef CONFIG_PM
 
@@ -893,6 +893,91 @@ failed:
 #define ALLOC_HIGH             0x20 /* __GFP_HIGH set */
 #define ALLOC_CPUSET           0x40 /* check for correct cpuset */
 
+#ifdef CONFIG_FAIL_PAGE_ALLOC
+
+static struct fail_page_alloc_attr {
+       struct fault_attr attr;
+
+       u32 ignore_gfp_highmem;
+       u32 ignore_gfp_wait;
+
+#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
+
+       struct dentry *ignore_gfp_highmem_file;
+       struct dentry *ignore_gfp_wait_file;
+
+#endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */
+
+} fail_page_alloc = {
+       .attr = FAULT_ATTR_INITIALIZER,
+       .ignore_gfp_wait = 1,
+       .ignore_gfp_highmem = 1,
+};
+
+static int __init setup_fail_page_alloc(char *str)
+{
+       return setup_fault_attr(&fail_page_alloc.attr, str);
+}
+__setup("fail_page_alloc=", setup_fail_page_alloc);
+
+static int should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
+{
+       if (gfp_mask & __GFP_NOFAIL)
+               return 0;
+       if (fail_page_alloc.ignore_gfp_highmem && (gfp_mask & __GFP_HIGHMEM))
+               return 0;
+       if (fail_page_alloc.ignore_gfp_wait && (gfp_mask & __GFP_WAIT))
+               return 0;
+
+       return should_fail(&fail_page_alloc.attr, 1 << order);
+}
+
+#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
+
+static int __init fail_page_alloc_debugfs(void)
+{
+       mode_t mode = S_IFREG | S_IRUSR | S_IWUSR;
+       struct dentry *dir;
+       int err;
+
+       err = init_fault_attr_dentries(&fail_page_alloc.attr,
+                                      "fail_page_alloc");
+       if (err)
+               return err;
+       dir = fail_page_alloc.attr.dentries.dir;
+
+       fail_page_alloc.ignore_gfp_wait_file =
+               debugfs_create_bool("ignore-gfp-wait", mode, dir,
+                                     &fail_page_alloc.ignore_gfp_wait);
+
+       fail_page_alloc.ignore_gfp_highmem_file =
+               debugfs_create_bool("ignore-gfp-highmem", mode, dir,
+                                     &fail_page_alloc.ignore_gfp_highmem);
+
+       if (!fail_page_alloc.ignore_gfp_wait_file ||
+                       !fail_page_alloc.ignore_gfp_highmem_file) {
+               err = -ENOMEM;
+               debugfs_remove(fail_page_alloc.ignore_gfp_wait_file);
+               debugfs_remove(fail_page_alloc.ignore_gfp_highmem_file);
+               cleanup_fault_attr_dentries(&fail_page_alloc.attr);
+       }
+
+       return err;
+}
+
+late_initcall(fail_page_alloc_debugfs);
+
+#endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */
+
+#else /* CONFIG_FAIL_PAGE_ALLOC */
+
+static inline int should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
+{
+       return 0;
+}
+
+#endif /* CONFIG_FAIL_PAGE_ALLOC */
+
 /*
  * Return 1 if free pages are above 'mark'. This takes into account the order
  * of the allocation.
@@ -925,31 +1010,160 @@ int zone_watermark_ok(struct zone *z, int order, unsigned long mark,
        return 1;
 }
 
+#ifdef CONFIG_NUMA
 /*
- * get_page_from_freeliest goes through the zonelist trying to allocate
+ * zlc_setup - Setup for "zonelist cache".  Uses cached zone data to
+ * skip over zones that are not allowed by the cpuset, or that have
+ * been recently (in last second) found to be nearly full.  See further
+ * comments in mmzone.h.  Reduces cache footprint of zonelist scans
+ * that have to skip over alot of full or unallowed zones.
+ *
+ * If the zonelist cache is present in the passed in zonelist, then
+ * returns a pointer to the allowed node mask (either the current
+ * tasks mems_allowed, or node_online_map.)
+ *
+ * If the zonelist cache is not available for this zonelist, does
+ * nothing and returns NULL.
+ *
+ * If the fullzones BITMAP in the zonelist cache is stale (more than
+ * a second since last zap'd) then we zap it out (clear its bits.)
+ *
+ * We hold off even calling zlc_setup, until after we've checked the
+ * first zone in the zonelist, on the theory that most allocations will
+ * be satisfied from that first zone, so best to examine that zone as
+ * quickly as we can.
+ */
+static nodemask_t *zlc_setup(struct zonelist *zonelist, int alloc_flags)
+{
+       struct zonelist_cache *zlc;     /* cached zonelist speedup info */
+       nodemask_t *allowednodes;       /* zonelist_cache approximation */
+
+       zlc = zonelist->zlcache_ptr;
+       if (!zlc)
+               return NULL;
+
+       if (jiffies - zlc->last_full_zap > 1 * HZ) {
+               bitmap_zero(zlc->fullzones, MAX_ZONES_PER_ZONELIST);
+               zlc->last_full_zap = jiffies;
+       }
+
+       allowednodes = !in_interrupt() && (alloc_flags & ALLOC_CPUSET) ?
+                                       &cpuset_current_mems_allowed :
+                                       &node_online_map;
+       return allowednodes;
+}
+
+/*
+ * Given 'z' scanning a zonelist, run a couple of quick checks to see
+ * if it is worth looking at further for free memory:
+ *  1) Check that the zone isn't thought to be full (doesn't have its
+ *     bit set in the zonelist_cache fullzones BITMAP).
+ *  2) Check that the zones node (obtained from the zonelist_cache
+ *     z_to_n[] mapping) is allowed in the passed in allowednodes mask.
+ * Return true (non-zero) if zone is worth looking at further, or
+ * else return false (zero) if it is not.
+ *
+ * This check -ignores- the distinction between various watermarks,
+ * such as GFP_HIGH, GFP_ATOMIC, PF_MEMALLOC, ...  If a zone is
+ * found to be full for any variation of these watermarks, it will
+ * be considered full for up to one second by all requests, unless
+ * we are so low on memory on all allowed nodes that we are forced
+ * into the second scan of the zonelist.
+ *
+ * In the second scan we ignore this zonelist cache and exactly
+ * apply the watermarks to all zones, even it is slower to do so.
+ * We are low on memory in the second scan, and should leave no stone
+ * unturned looking for a free page.
+ */
+static int zlc_zone_worth_trying(struct zonelist *zonelist, struct zone **z,
+                                               nodemask_t *allowednodes)
+{
+       struct zonelist_cache *zlc;     /* cached zonelist speedup info */
+       int i;                          /* index of *z in zonelist zones */
+       int n;                          /* node that zone *z is on */
+
+       zlc = zonelist->zlcache_ptr;
+       if (!zlc)
+               return 1;
+
+       i = z - zonelist->zones;
+       n = zlc->z_to_n[i];
+
+       /* This zone is worth trying if it is allowed but not full */
+       return node_isset(n, *allowednodes) && !test_bit(i, zlc->fullzones);
+}
+
+/*
+ * Given 'z' scanning a zonelist, set the corresponding bit in
+ * zlc->fullzones, so that subsequent attempts to allocate a page
+ * from that zone don't waste time re-examining it.
+ */
+static void zlc_mark_zone_full(struct zonelist *zonelist, struct zone **z)
+{
+       struct zonelist_cache *zlc;     /* cached zonelist speedup info */
+       int i;                          /* index of *z in zonelist zones */
+
+       zlc = zonelist->zlcache_ptr;
+       if (!zlc)
+               return;
+
+       i = z - zonelist->zones;
+
+       set_bit(i, zlc->fullzones);
+}
+
+#else  /* CONFIG_NUMA */
+
+static nodemask_t *zlc_setup(struct zonelist *zonelist, int alloc_flags)
+{
+       return NULL;
+}
+
+static int zlc_zone_worth_trying(struct zonelist *zonelist, struct zone **z,
+                               nodemask_t *allowednodes)
+{
+       return 1;
+}
+
+static void zlc_mark_zone_full(struct zonelist *zonelist, struct zone **z)
+{
+}
+#endif /* CONFIG_NUMA */
+
+/*
+ * get_page_from_freelist goes through the zonelist trying to allocate
  * a page.
  */
 static struct page *
 get_page_from_freelist(gfp_t gfp_mask, unsigned int order,
                struct zonelist *zonelist, int alloc_flags)
 {
-       struct zone **z = zonelist->zones;
+       struct zone **z;
        struct page *page = NULL;
-       int classzone_idx = zone_idx(*z);
+       int classzone_idx = zone_idx(zonelist->zones[0]);
        struct zone *zone;
+       nodemask_t *allowednodes = NULL;/* zonelist_cache approximation */
+       int zlc_active = 0;             /* set if using zonelist_cache */
+       int did_zlc_setup = 0;          /* just call zlc_setup() one time */
 
+zonelist_scan:
        /*
-        * Go through the zonelist once, looking for a zone with enough free.
+        * Scan zonelist, looking for a zone with enough free.
         * See also cpuset_zone_allowed() comment in kernel/cpuset.c.
         */
+       z = zonelist->zones;
+
        do {
+               if (NUMA_BUILD && zlc_active &&
+                       !zlc_zone_worth_trying(zonelist, z, allowednodes))
+                               continue;
                zone = *z;
                if (unlikely(NUMA_BUILD && (gfp_mask & __GFP_THISNODE) &&
                        zone->zone_pgdat != zonelist->zones[0]->zone_pgdat))
                                break;
                if ((alloc_flags & ALLOC_CPUSET) &&
-                               !cpuset_zone_allowed(zone, gfp_mask))
-                       continue;
+                       !cpuset_zone_allowed(zone, gfp_mask))
+                               goto try_next_zone;
 
                if (!(alloc_flags & ALLOC_NO_WATERMARKS)) {
                        unsigned long mark;
@@ -959,18 +1173,34 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order,
                                mark = zone->pages_low;
                        else
                                mark = zone->pages_high;
-                       if (!zone_watermark_ok(zone , order, mark,
-                                   classzone_idx, alloc_flags))
+                       if (!zone_watermark_ok(zone, order, mark,
+                                   classzone_idx, alloc_flags)) {
                                if (!zone_reclaim_mode ||
                                    !zone_reclaim(zone, gfp_mask, order))
-                                       continue;
+                                       goto this_zone_full;
+                       }
                }
 
                page = buffered_rmqueue(zonelist, zone, order, gfp_mask);
-               if (page) {
+               if (page)
                        break;
+this_zone_full:
+               if (NUMA_BUILD)
+                       zlc_mark_zone_full(zonelist, z);
+try_next_zone:
+               if (NUMA_BUILD && !did_zlc_setup) {
+                       /* we do zlc_setup after the first zone is tried */
+                       allowednodes = zlc_setup(zonelist, alloc_flags);
+                       zlc_active = 1;
+                       did_zlc_setup = 1;
                }
        } while (*(++z) != NULL);
+
+       if (unlikely(NUMA_BUILD && page == NULL && zlc_active)) {
+               /* Disable zlc cache for second zonelist scan */
+               zlc_active = 0;
+               goto zonelist_scan;
+       }
        return page;
 }
 
@@ -992,6 +1222,9 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order,
 
        might_sleep_if(wait);
 
+       if (should_fail_alloc_page(gfp_mask, order))
+               return NULL;
+
 restart:
        z = zonelist->zones;  /* the list of zones suitable for gfp_mask */
 
@@ -1005,9 +1238,19 @@ restart:
        if (page)
                goto got_pg;
 
-       do {
+       /*
+        * GFP_THISNODE (meaning __GFP_THISNODE, __GFP_NORETRY and
+        * __GFP_NOWARN set) should not cause reclaim since the subsystem
+        * (f.e. slab) using GFP_THISNODE may choose to trigger reclaim
+        * using a larger set of nodes after it has established that the
+        * allowed per node queues are empty and that nodes are
+        * over allocated.
+        */
+       if (NUMA_BUILD && (gfp_mask & GFP_THISNODE) == GFP_THISNODE)
+               goto nopage;
+
+       for (z = zonelist->zones; *z; z++)
                wakeup_kswapd(*z, order);
-       } while (*(++z));
 
        /*
         * OK, we're below the kswapd watermark and have kicked background
@@ -1041,6 +1284,7 @@ restart:
 
        /* This allocation should allow future memory freeing. */
 
+rebalance:
        if (((p->flags & PF_MEMALLOC) || unlikely(test_thread_flag(TIF_MEMDIE)))
                        && !in_interrupt()) {
                if (!(gfp_mask & __GFP_NOMEMALLOC)) {
@@ -1062,7 +1306,6 @@ nofail_alloc:
        if (!wait)
                goto nopage;
 
-rebalance:
        cond_resched();
 
        /* We now go into synchronous reclaim */
@@ -1262,7 +1505,7 @@ unsigned int nr_free_pagecache_pages(void)
 static inline void show_node(struct zone *zone)
 {
        if (NUMA_BUILD)
-               printk("Node %ld ", zone_to_nid(zone));
+               printk("Node %d ", zone_to_nid(zone));
 }
 
 void si_meminfo(struct sysinfo *val)
@@ -1542,6 +1785,24 @@ static void __meminit build_zonelists(pg_data_t *pgdat)
        }
 }
 
+/* Construct the zonelist performance cache - see further mmzone.h */
+static void __meminit build_zonelist_cache(pg_data_t *pgdat)
+{
+       int i;
+
+       for (i = 0; i < MAX_NR_ZONES; i++) {
+               struct zonelist *zonelist;
+               struct zonelist_cache *zlc;
+               struct zone **z;
+
+               zonelist = pgdat->node_zonelists + i;
+               zonelist->zlcache_ptr = zlc = &zonelist->zlcache;
+               bitmap_zero(zlc->fullzones, MAX_ZONES_PER_ZONELIST);
+               for (z = zonelist->zones; *z; z++)
+                       zlc->z_to_n[z - zonelist->zones] = zone_to_nid(*z);
+       }
+}
+
 #else  /* CONFIG_NUMA */
 
 static void __meminit build_zonelists(pg_data_t *pgdat)
@@ -1579,14 +1840,26 @@ static void __meminit build_zonelists(pg_data_t *pgdat)
        }
 }
 
+/* non-NUMA variant of zonelist performance cache - just NULL zlcache_ptr */
+static void __meminit build_zonelist_cache(pg_data_t *pgdat)
+{
+       int i;
+
+       for (i = 0; i < MAX_NR_ZONES; i++)
+               pgdat->node_zonelists[i].zlcache_ptr = NULL;
+}
+
 #endif /* CONFIG_NUMA */
 
 /* return values int ....just for stop_machine_run() */
 static int __meminit __build_all_zonelists(void *dummy)
 {
        int nid;
-       for_each_online_node(nid)
+
+       for_each_online_node(nid) {
                build_zonelists(NODE_DATA(nid));
+               build_zonelist_cache(NODE_DATA(nid));
+       }
        return 0;
 }
 
@@ -1715,20 +1988,6 @@ void zone_init_free_lists(struct pglist_data *pgdat, struct zone *zone,
        }
 }
 
-#define ZONETABLE_INDEX(x, zone_nr)    ((x << ZONES_SHIFT) | zone_nr)
-void zonetable_add(struct zone *zone, int nid, enum zone_type zid,
-               unsigned long pfn, unsigned long size)
-{
-       unsigned long snum = pfn_to_section_nr(pfn);
-       unsigned long end = pfn_to_section_nr(pfn + size);
-
-       if (FLAGS_HAS_NODE)
-               zone_table[ZONETABLE_INDEX(nid, zid)] = zone;
-       else
-               for (; snum <= end; snum++)
-                       zone_table[ZONETABLE_INDEX(snum, zid)] = zone;
-}
-
 #ifndef __HAVE_ARCH_MEMMAP_INIT
 #define memmap_init(size, nid, zone, start_pfn) \
        memmap_init_zone((size), (nid), (zone), (start_pfn))
@@ -1881,16 +2140,16 @@ static int __cpuinit pageset_cpuup_callback(struct notifier_block *nfb,
        int ret = NOTIFY_OK;
 
        switch (action) {
-               case CPU_UP_PREPARE:
-                       if (process_zones(cpu))
-                               ret = NOTIFY_BAD;
-                       break;
-               case CPU_UP_CANCELED:
-               case CPU_DEAD:
-                       free_zone_pagesets(cpu);
-                       break;
-               default:
-                       break;
+       case CPU_UP_PREPARE:
+               if (process_zones(cpu))
+                       ret = NOTIFY_BAD;
+               break;
+       case CPU_UP_CANCELED:
+       case CPU_DEAD:
+               free_zone_pagesets(cpu);
+               break;
+       default:
+               break;
        }
        return ret;
 }
@@ -2421,7 +2680,6 @@ static void __meminit free_area_init_core(struct pglist_data *pgdat,
                if (!size)
                        continue;
 
-               zonetable_add(zone, nid, j, zone_start_pfn, size);
                ret = init_currently_empty_zone(zone, zone_start_pfn, size);
                BUG_ON(ret);
                zone_start_pfn += size;
@@ -2736,7 +2994,6 @@ void __init free_area_init(unsigned long *zones_size)
                        __pa(PAGE_OFFSET) >> PAGE_SHIFT, NULL);
 }
 
-#ifdef CONFIG_HOTPLUG_CPU
 static int page_alloc_cpu_notify(struct notifier_block *self,
                                 unsigned long action, void *hcpu)
 {
@@ -2751,7 +3008,6 @@ static int page_alloc_cpu_notify(struct notifier_block *self,
        }
        return NOTIFY_OK;
 }
-#endif /* CONFIG_HOTPLUG_CPU */
 
 void __init page_alloc_init(void)
 {
@@ -3055,7 +3311,7 @@ void *__init alloc_large_system_hash(const char *tablename,
        /* allow the kernel cmdline to have a say */
        if (!numentries) {
                /* round applicable memory size up to nearest megabyte */
-               numentries = (flags & HASH_HIGHMEM) ? nr_all_pages : nr_kernel_pages;
+               numentries = nr_kernel_pages;
                numentries += (1UL << (20 - PAGE_SHIFT)) - 1;
                numentries >>= 20 - PAGE_SHIFT;
                numentries <<= 20 - PAGE_SHIFT;
@@ -3077,7 +3333,7 @@ void *__init alloc_large_system_hash(const char *tablename,
        if (numentries > max)
                numentries = max;
 
-       log2qty = long_log2(numentries);
+       log2qty = ilog2(numentries);
 
        do {
                size = bucketsize << log2qty;
@@ -3099,7 +3355,7 @@ void *__init alloc_large_system_hash(const char *tablename,
        printk("%s hash table entries: %d (order: %d, %lu bytes)\n",
               tablename,
               (1U << log2qty),
-              long_log2(size) - PAGE_SHIFT,
+              ilog2(size) - PAGE_SHIFT,
               size);
 
        if (_hash_shift)
index d4840ecbf8f9358e1dfc5918802f3604e1f06b93..dbffec0d78c98407737ac544cb2ea5ad17a9c7c2 100644 (file)
@@ -147,48 +147,3 @@ int swap_readpage(struct file *file, struct page *page)
 out:
        return ret;
 }
-
-#ifdef CONFIG_SOFTWARE_SUSPEND
-/*
- * A scruffy utility function to read or write an arbitrary swap page
- * and wait on the I/O.  The caller must have a ref on the page.
- *
- * We use end_swap_bio_read() even for writes, because it happens to do what
- * we want.
- */
-int rw_swap_page_sync(int rw, swp_entry_t entry, struct page *page,
-                       struct bio **bio_chain)
-{
-       struct bio *bio;
-       int ret = 0;
-       int bio_rw;
-
-       lock_page(page);
-
-       bio = get_swap_bio(GFP_KERNEL, entry.val, page, end_swap_bio_read);
-       if (bio == NULL) {
-               unlock_page(page);
-               ret = -ENOMEM;
-               goto out;
-       }
-
-       bio_rw = rw;
-       if (!bio_chain)
-               bio_rw |= (1 << BIO_RW_SYNC);
-       if (bio_chain)
-               bio_get(bio);
-       submit_bio(bio_rw, bio);
-       if (bio_chain == NULL) {
-               wait_on_page_locked(page);
-
-               if (!PageUptodate(page) || PageError(page))
-                       ret = -EIO;
-       }
-       if (bio_chain) {
-               bio->bi_private = *bio_chain;
-               *bio_chain = bio;
-       }
-out:
-       return ret;
-}
-#endif
index b02102feeb4be03d346583f2c81c8e7aba4e3ed8..8ce0900dc95ce13052ee6241f7cf6de91f828a8a 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/writeback.h>   // Prototypes pdflush_operation()
 #include <linux/kthread.h>
 #include <linux/cpuset.h>
+#include <linux/freezer.h>
 
 
 /*
index 23cb61a01c6e4123f313f5487a5942e7ee4c5fe4..c0df5ed05f624a61d7e685d9b5ff9c4bfa4d2f90 100644 (file)
@@ -148,13 +148,7 @@ int read_cache_pages(struct address_space *mapping, struct list_head *pages,
                if (!pagevec_add(&lru_pvec, page))
                        __pagevec_lru_add(&lru_pvec);
                if (ret) {
-                       while (!list_empty(pages)) {
-                               struct page *victim;
-
-                               victim = list_to_page(pages);
-                               list_del(&victim->lru);
-                               page_cache_release(victim);
-                       }
+                       put_pages_list(pages);
                        break;
                }
        }
@@ -456,7 +450,7 @@ static int make_ahead_window(struct address_space *mapping, struct file *filp,
  *
  * Note that @filp is purely used for passing on to the ->readpage[s]()
  * handler: it may refer to a different file from @mapping (so we may not use
- * @filp->f_mapping or @filp->f_dentry->d_inode here).
+ * @filp->f_mapping or @filp->f_path.dentry->d_inode here).
  * Also, @ra may not be equal to &@filp->f_ra.
  *
  */
index 4959535fc14c4a7aa3308bb316c4a13a3ba2baa3..4bb28d218eb5caf064026e479873cc994e282a88 100644 (file)
@@ -177,7 +177,7 @@ static inline void shmem_unacct_blocks(unsigned long flags, long pages)
 
 static struct super_operations shmem_ops;
 static const struct address_space_operations shmem_aops;
-static struct file_operations shmem_file_operations;
+static const struct file_operations shmem_file_operations;
 static struct inode_operations shmem_inode_operations;
 static struct inode_operations shmem_dir_inode_operations;
 static struct inode_operations shmem_special_inode_operations;
@@ -1225,7 +1225,7 @@ failed:
 
 struct page *shmem_nopage(struct vm_area_struct *vma, unsigned long address, int *type)
 {
-       struct inode *inode = vma->vm_file->f_dentry->d_inode;
+       struct inode *inode = vma->vm_file->f_path.dentry->d_inode;
        struct page *page = NULL;
        unsigned long idx;
        int error;
@@ -1248,7 +1248,7 @@ static int shmem_populate(struct vm_area_struct *vma,
        unsigned long addr, unsigned long len,
        pgprot_t prot, unsigned long pgoff, int nonblock)
 {
-       struct inode *inode = vma->vm_file->f_dentry->d_inode;
+       struct inode *inode = vma->vm_file->f_path.dentry->d_inode;
        struct mm_struct *mm = vma->vm_mm;
        enum sgp_type sgp = nonblock? SGP_QUICK: SGP_CACHE;
        unsigned long size;
@@ -1293,14 +1293,14 @@ static int shmem_populate(struct vm_area_struct *vma,
 #ifdef CONFIG_NUMA
 int shmem_set_policy(struct vm_area_struct *vma, struct mempolicy *new)
 {
-       struct inode *i = vma->vm_file->f_dentry->d_inode;
+       struct inode *i = vma->vm_file->f_path.dentry->d_inode;
        return mpol_set_shared_policy(&SHMEM_I(i)->policy, vma, new);
 }
 
 struct mempolicy *
 shmem_get_policy(struct vm_area_struct *vma, unsigned long addr)
 {
-       struct inode *i = vma->vm_file->f_dentry->d_inode;
+       struct inode *i = vma->vm_file->f_path.dentry->d_inode;
        unsigned long idx;
 
        idx = ((addr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
@@ -1310,7 +1310,7 @@ shmem_get_policy(struct vm_area_struct *vma, unsigned long addr)
 
 int shmem_lock(struct file *file, int lock, struct user_struct *user)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct shmem_inode_info *info = SHMEM_I(inode);
        int retval = -ENOMEM;
 
@@ -1422,7 +1422,7 @@ shmem_prepare_write(struct file *file, struct page *page, unsigned offset, unsig
 static ssize_t
 shmem_file_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 {
-       struct inode    *inode = file->f_dentry->d_inode;
+       struct inode    *inode = file->f_path.dentry->d_inode;
        loff_t          pos;
        unsigned long   written;
        ssize_t         err;
@@ -1442,7 +1442,7 @@ shmem_file_write(struct file *file, const char __user *buf, size_t count, loff_t
        if (err || !count)
                goto out;
 
-       err = remove_suid(file->f_dentry);
+       err = remove_suid(file->f_path.dentry);
        if (err)
                goto out;
 
@@ -1524,7 +1524,7 @@ out:
 
 static void do_shmem_file_read(struct file *filp, loff_t *ppos, read_descriptor_t *desc, read_actor_t actor)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct address_space *mapping = inode->i_mapping;
        unsigned long index, offset;
 
@@ -1943,7 +1943,7 @@ static int shmem_xattr_security_set(struct inode *inode, const char *name,
        return security_inode_setsecurity(inode, name, value, size, flags);
 }
 
-struct xattr_handler shmem_xattr_security_handler = {
+static struct xattr_handler shmem_xattr_security_handler = {
        .prefix = XATTR_SECURITY_PREFIX,
        .list   = shmem_xattr_security_list,
        .get    = shmem_xattr_security_get,
@@ -2263,7 +2263,7 @@ static struct kmem_cache *shmem_inode_cachep;
 static struct inode *shmem_alloc_inode(struct super_block *sb)
 {
        struct shmem_inode_info *p;
-       p = (struct shmem_inode_info *)kmem_cache_alloc(shmem_inode_cachep, SLAB_KERNEL);
+       p = (struct shmem_inode_info *)kmem_cache_alloc(shmem_inode_cachep, GFP_KERNEL);
        if (!p)
                return NULL;
        return &p->vfs_inode;
@@ -2319,7 +2319,7 @@ static const struct address_space_operations shmem_aops = {
        .migratepage    = migrate_page,
 };
 
-static struct file_operations shmem_file_operations = {
+static const struct file_operations shmem_file_operations = {
        .mmap           = shmem_mmap,
 #ifdef CONFIG_TMPFS
        .llseek         = generic_file_llseek,
@@ -2493,8 +2493,8 @@ struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags)
        d_instantiate(dentry, inode);
        inode->i_size = size;
        inode->i_nlink = 0;     /* It is unlinked */
-       file->f_vfsmnt = mntget(shm_mnt);
-       file->f_dentry = dentry;
+       file->f_path.mnt = mntget(shm_mnt);
+       file->f_path.dentry = dentry;
        file->f_mapping = inode->i_mapping;
        file->f_op = &shmem_file_operations;
        file->f_mode = FMODE_WRITE | FMODE_READ;
index 5de81473df342dabe224e68557acf6421c9cc019..56af694c9e6a386f75aa718f339a54eef6e27b8d 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
 #include       <linux/module.h>
 #include       <linux/rcupdate.h>
 #include       <linux/string.h>
+#include       <linux/uaccess.h>
 #include       <linux/nodemask.h>
 #include       <linux/mempolicy.h>
 #include       <linux/mutex.h>
+#include       <linux/fault-inject.h>
 #include       <linux/rtmutex.h>
 
-#include       <asm/uaccess.h>
 #include       <asm/cacheflush.h>
 #include       <asm/tlbflush.h>
 #include       <asm/page.h>
@@ -730,7 +731,10 @@ static inline void init_lock_keys(void)
 }
 #endif
 
-/* Guard access to the cache-chain. */
+/*
+ * 1. Guard access to the cache-chain.
+ * 2. Protect sanity of cpu_online_map against cpu hotplug events
+ */
 static DEFINE_MUTEX(cache_chain_mutex);
 static struct list_head cache_chain;
 
@@ -866,6 +870,22 @@ static void __slab_error(const char *function, struct kmem_cache *cachep,
        dump_stack();
 }
 
+/*
+ * By default on NUMA we use alien caches to stage the freeing of
+ * objects allocated from other nodes. This causes massive memory
+ * inefficiencies when using fake NUMA setup to split memory into a
+ * large number of small nodes, so it can be disabled on the command
+ * line
+  */
+
+static int use_alien_caches __read_mostly = 1;
+static int __init noaliencache_setup(char *s)
+{
+       use_alien_caches = 0;
+       return 1;
+}
+__setup("noaliencache", noaliencache_setup);
+
 #ifdef CONFIG_NUMA
 /*
  * Special reaping functions for NUMA systems called from cache_reap().
@@ -996,7 +1016,7 @@ static inline void *alternate_node_alloc(struct kmem_cache *cachep,
        return NULL;
 }
 
-static inline void *__cache_alloc_node(struct kmem_cache *cachep,
+static inline void *____cache_alloc_node(struct kmem_cache *cachep,
                 gfp_t flags, int nodeid)
 {
        return NULL;
@@ -1004,7 +1024,7 @@ static inline void *__cache_alloc_node(struct kmem_cache *cachep,
 
 #else  /* CONFIG_NUMA */
 
-static void *__cache_alloc_node(struct kmem_cache *, gfp_t, int);
+static void *____cache_alloc_node(struct kmem_cache *, gfp_t, int);
 static void *alternate_node_alloc(struct kmem_cache *, gfp_t);
 
 static struct array_cache **alloc_alien_cache(int node, int limit)
@@ -1114,7 +1134,7 @@ static inline int cache_free_alien(struct kmem_cache *cachep, void *objp)
         * Make sure we are not freeing a object from another node to the array
         * cache on this cpu.
         */
-       if (likely(slabp->nodeid == node))
+       if (likely(slabp->nodeid == node) || unlikely(!use_alien_caches))
                return 0;
 
        l3 = cachep->nodelists[node];
@@ -1192,7 +1212,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
                list_for_each_entry(cachep, &cache_chain, next) {
                        struct array_cache *nc;
                        struct array_cache *shared;
-                       struct array_cache **alien;
+                       struct array_cache **alien = NULL;
 
                        nc = alloc_arraycache(node, cachep->limit,
                                                cachep->batchcount);
@@ -1204,9 +1224,11 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
                        if (!shared)
                                goto bad;
 
-                       alien = alloc_alien_cache(node, cachep->limit);
-                       if (!alien)
-                               goto bad;
+                       if (use_alien_caches) {
+                                alien = alloc_alien_cache(node, cachep->limit);
+                                if (!alien)
+                                        goto bad;
+                        }
                        cachep->array[cpu] = nc;
                        l3 = cachep->nodelists[node];
                        BUG_ON(!l3);
@@ -1230,12 +1252,18 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
                        kfree(shared);
                        free_alien_cache(alien);
                }
-               mutex_unlock(&cache_chain_mutex);
                break;
        case CPU_ONLINE:
+               mutex_unlock(&cache_chain_mutex);
                start_cpu_timer(cpu);
                break;
 #ifdef CONFIG_HOTPLUG_CPU
+       case CPU_DOWN_PREPARE:
+               mutex_lock(&cache_chain_mutex);
+               break;
+       case CPU_DOWN_FAILED:
+               mutex_unlock(&cache_chain_mutex);
+               break;
        case CPU_DEAD:
                /*
                 * Even if all the cpus of a node are down, we don't free the
@@ -1246,8 +1274,8 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
                 * gets destroyed at kmem_cache_destroy().
                 */
                /* fall thru */
+#endif
        case CPU_UP_CANCELED:
-               mutex_lock(&cache_chain_mutex);
                list_for_each_entry(cachep, &cache_chain, next) {
                        struct array_cache *nc;
                        struct array_cache *shared;
@@ -1308,11 +1336,9 @@ free_array_cache:
                }
                mutex_unlock(&cache_chain_mutex);
                break;
-#endif
        }
        return NOTIFY_OK;
 bad:
-       mutex_unlock(&cache_chain_mutex);
        return NOTIFY_BAD;
 }
 
@@ -1580,12 +1606,7 @@ static void *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, int nodeid)
        flags |= __GFP_COMP;
 #endif
 
-       /*
-        * Under NUMA we want memory on the indicated node. We will handle
-        * the needed fallback ourselves since we want to serve from our
-        * per node object lists first for other nodes.
-        */
-       flags |= cachep->gfpflags | GFP_THISNODE;
+       flags |= cachep->gfpflags;
 
        page = alloc_pages_node(nodeid, flags, cachep->gfporder);
        if (!page)
@@ -2098,15 +2119,12 @@ kmem_cache_create (const char *name, size_t size, size_t align,
        }
 
        /*
-        * Prevent CPUs from coming and going.
-        * lock_cpu_hotplug() nests outside cache_chain_mutex
+        * We use cache_chain_mutex to ensure a consistent view of
+        * cpu_online_map as well.  Please see cpuup_callback
         */
-       lock_cpu_hotplug();
-
        mutex_lock(&cache_chain_mutex);
 
        list_for_each_entry(pc, &cache_chain, next) {
-               mm_segment_t old_fs = get_fs();
                char tmp;
                int res;
 
@@ -2115,9 +2133,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
                 * destroy its slab cache and no-one else reuses the vmalloc
                 * area of the module.  Print a warning.
                 */
-               set_fs(KERNEL_DS);
-               res = __get_user(tmp, pc->name);
-               set_fs(old_fs);
+               res = probe_kernel_address(pc->name, tmp);
                if (res) {
                        printk("SLAB: cache with size %d has lost its name\n",
                               pc->buffer_size);
@@ -2197,25 +2213,24 @@ kmem_cache_create (const char *name, size_t size, size_t align,
        if (flags & SLAB_RED_ZONE || flags & SLAB_STORE_USER)
                ralign = BYTES_PER_WORD;
 
-       /* 2) arch mandated alignment: disables debug if necessary */
+       /* 2) arch mandated alignment */
        if (ralign < ARCH_SLAB_MINALIGN) {
                ralign = ARCH_SLAB_MINALIGN;
-               if (ralign > BYTES_PER_WORD)
-                       flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
        }
-       /* 3) caller mandated alignment: disables debug if necessary */
+       /* 3) caller mandated alignment */
        if (ralign < align) {
                ralign = align;
-               if (ralign > BYTES_PER_WORD)
-                       flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
        }
+       /* disable debug if necessary */
+       if (ralign > BYTES_PER_WORD)
+               flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
        /*
         * 4) Store it.
         */
        align = ralign;
 
        /* Get cache's description obj. */
-       cachep = kmem_cache_zalloc(&cache_cache, SLAB_KERNEL);
+       cachep = kmem_cache_zalloc(&cache_cache, GFP_KERNEL);
        if (!cachep)
                goto oops;
 
@@ -2326,7 +2341,6 @@ oops:
                panic("kmem_cache_create(): failed to create slab `%s'\n",
                      name);
        mutex_unlock(&cache_chain_mutex);
-       unlock_cpu_hotplug();
        return cachep;
 }
 EXPORT_SYMBOL(kmem_cache_create);
@@ -2444,6 +2458,7 @@ out:
        return nr_freed;
 }
 
+/* Called with cache_chain_mutex held to protect against cpu hotplug */
 static int __cache_shrink(struct kmem_cache *cachep)
 {
        int ret = 0, i = 0;
@@ -2474,9 +2489,13 @@ static int __cache_shrink(struct kmem_cache *cachep)
  */
 int kmem_cache_shrink(struct kmem_cache *cachep)
 {
+       int ret;
        BUG_ON(!cachep || in_interrupt());
 
-       return __cache_shrink(cachep);
+       mutex_lock(&cache_chain_mutex);
+       ret = __cache_shrink(cachep);
+       mutex_unlock(&cache_chain_mutex);
+       return ret;
 }
 EXPORT_SYMBOL(kmem_cache_shrink);
 
@@ -2500,23 +2519,16 @@ void kmem_cache_destroy(struct kmem_cache *cachep)
 {
        BUG_ON(!cachep || in_interrupt());
 
-       /* Don't let CPUs to come and go */
-       lock_cpu_hotplug();
-
        /* Find the cache in the chain of caches. */
        mutex_lock(&cache_chain_mutex);
        /*
         * the chain is never empty, cache_cache is never destroyed
         */
        list_del(&cachep->next);
-       mutex_unlock(&cache_chain_mutex);
-
        if (__cache_shrink(cachep)) {
                slab_error(cachep, "Can't free all objects");
-               mutex_lock(&cache_chain_mutex);
                list_add(&cachep->next, &cache_chain);
                mutex_unlock(&cache_chain_mutex);
-               unlock_cpu_hotplug();
                return;
        }
 
@@ -2524,7 +2536,7 @@ void kmem_cache_destroy(struct kmem_cache *cachep)
                synchronize_rcu();
 
        __kmem_cache_destroy(cachep);
-       unlock_cpu_hotplug();
+       mutex_unlock(&cache_chain_mutex);
 }
 EXPORT_SYMBOL(kmem_cache_destroy);
 
@@ -2548,7 +2560,7 @@ static struct slab *alloc_slabmgmt(struct kmem_cache *cachep, void *objp,
        if (OFF_SLAB(cachep)) {
                /* Slab management obj is off-slab. */
                slabp = kmem_cache_alloc_node(cachep->slabp_cache,
-                                             local_flags, nodeid);
+                                             local_flags & ~GFP_THISNODE, nodeid);
                if (!slabp)
                        return NULL;
        } else {
@@ -2618,7 +2630,7 @@ static void cache_init_objs(struct kmem_cache *cachep,
 
 static void kmem_flagcheck(struct kmem_cache *cachep, gfp_t flags)
 {
-       if (flags & SLAB_DMA)
+       if (flags & GFP_DMA)
                BUG_ON(!(cachep->gfpflags & GFP_DMA));
        else
                BUG_ON(cachep->gfpflags & GFP_DMA);
@@ -2689,10 +2701,10 @@ static void slab_map_pages(struct kmem_cache *cache, struct slab *slab,
  * Grow (by 1) the number of slabs within a cache.  This is called by
  * kmem_cache_alloc() when there are no active objs left in a cache.
  */
-static int cache_grow(struct kmem_cache *cachep, gfp_t flags, int nodeid)
+static int cache_grow(struct kmem_cache *cachep,
+               gfp_t flags, int nodeid, void *objp)
 {
        struct slab *slabp;
-       void *objp;
        size_t offset;
        gfp_t local_flags;
        unsigned long ctor_flags;
@@ -2702,12 +2714,12 @@ static int cache_grow(struct kmem_cache *cachep, gfp_t flags, int nodeid)
         * Be lazy and only check for valid flags here,  keeping it out of the
         * critical path in kmem_cache_alloc().
         */
-       BUG_ON(flags & ~(SLAB_DMA | SLAB_LEVEL_MASK | SLAB_NO_GROW));
-       if (flags & SLAB_NO_GROW)
+       BUG_ON(flags & ~(GFP_DMA | GFP_LEVEL_MASK | __GFP_NO_GROW));
+       if (flags & __GFP_NO_GROW)
                return 0;
 
        ctor_flags = SLAB_CTOR_CONSTRUCTOR;
-       local_flags = (flags & SLAB_LEVEL_MASK);
+       local_flags = (flags & GFP_LEVEL_MASK);
        if (!(local_flags & __GFP_WAIT))
                /*
                 * Not allowed to sleep.  Need to tell a constructor about
@@ -2744,12 +2756,14 @@ static int cache_grow(struct kmem_cache *cachep, gfp_t flags, int nodeid)
         * Get mem for the objs.  Attempt to allocate a physical page from
         * 'nodeid'.
         */
-       objp = kmem_getpages(cachep, flags, nodeid);
+       if (!objp)
+               objp = kmem_getpages(cachep, flags, nodeid);
        if (!objp)
                goto failed;
 
        /* Get slab management. */
-       slabp = alloc_slabmgmt(cachep, objp, offset, local_flags, nodeid);
+       slabp = alloc_slabmgmt(cachep, objp, offset,
+                       local_flags & ~GFP_THISNODE, nodeid);
        if (!slabp)
                goto opps1;
 
@@ -2987,7 +3001,7 @@ alloc_done:
 
        if (unlikely(!ac->avail)) {
                int x;
-               x = cache_grow(cachep, flags, node);
+               x = cache_grow(cachep, flags | GFP_THISNODE, node, NULL);
 
                /* cache_grow can reenable interrupts, then ac could change. */
                ac = cpu_cache_get(cachep);
@@ -3063,18 +3077,101 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep,
 
                cachep->ctor(objp, cachep, ctor_flags);
        }
+#if ARCH_SLAB_MINALIGN
+       if ((u32)objp & (ARCH_SLAB_MINALIGN-1)) {
+               printk(KERN_ERR "0x%p: not aligned to ARCH_SLAB_MINALIGN=%d\n",
+                      objp, ARCH_SLAB_MINALIGN);
+       }
+#endif
        return objp;
 }
 #else
 #define cache_alloc_debugcheck_after(a,b,objp,d) (objp)
 #endif
 
+#ifdef CONFIG_FAILSLAB
+
+static struct failslab_attr {
+
+       struct fault_attr attr;
+
+       u32 ignore_gfp_wait;
+#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
+       struct dentry *ignore_gfp_wait_file;
+#endif
+
+} failslab = {
+       .attr = FAULT_ATTR_INITIALIZER,
+       .ignore_gfp_wait = 1,
+};
+
+static int __init setup_failslab(char *str)
+{
+       return setup_fault_attr(&failslab.attr, str);
+}
+__setup("failslab=", setup_failslab);
+
+static int should_failslab(struct kmem_cache *cachep, gfp_t flags)
+{
+       if (cachep == &cache_cache)
+               return 0;
+       if (flags & __GFP_NOFAIL)
+               return 0;
+       if (failslab.ignore_gfp_wait && (flags & __GFP_WAIT))
+               return 0;
+
+       return should_fail(&failslab.attr, obj_size(cachep));
+}
+
+#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
+
+static int __init failslab_debugfs(void)
+{
+       mode_t mode = S_IFREG | S_IRUSR | S_IWUSR;
+       struct dentry *dir;
+       int err;
+
+               err = init_fault_attr_dentries(&failslab.attr, "failslab");
+       if (err)
+               return err;
+       dir = failslab.attr.dentries.dir;
+
+       failslab.ignore_gfp_wait_file =
+               debugfs_create_bool("ignore-gfp-wait", mode, dir,
+                                     &failslab.ignore_gfp_wait);
+
+       if (!failslab.ignore_gfp_wait_file) {
+               err = -ENOMEM;
+               debugfs_remove(failslab.ignore_gfp_wait_file);
+               cleanup_fault_attr_dentries(&failslab.attr);
+       }
+
+       return err;
+}
+
+late_initcall(failslab_debugfs);
+
+#endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */
+
+#else /* CONFIG_FAILSLAB */
+
+static inline int should_failslab(struct kmem_cache *cachep, gfp_t flags)
+{
+       return 0;
+}
+
+#endif /* CONFIG_FAILSLAB */
+
 static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags)
 {
        void *objp;
        struct array_cache *ac;
 
        check_irq_off();
+
+       if (should_failslab(cachep, flags))
+               return NULL;
+
        ac = cpu_cache_get(cachep);
        if (likely(ac->avail)) {
                STATS_INC_ALLOCHIT(cachep);
@@ -3105,10 +3202,10 @@ static __always_inline void *__cache_alloc(struct kmem_cache *cachep,
                objp = ____cache_alloc(cachep, flags);
        /*
         * We may just have run out of memory on the local node.
-        * __cache_alloc_node() knows how to locate memory on other nodes
+        * ____cache_alloc_node() knows how to locate memory on other nodes
         */
        if (NUMA_BUILD && !objp)
-               objp = __cache_alloc_node(cachep, flags, numa_node_id());
+               objp = ____cache_alloc_node(cachep, flags, numa_node_id());
        local_irq_restore(save_flags);
        objp = cache_alloc_debugcheck_after(cachep, flags, objp,
                                            caller);
@@ -3135,15 +3232,17 @@ static void *alternate_node_alloc(struct kmem_cache *cachep, gfp_t flags)
        else if (current->mempolicy)
                nid_alloc = slab_node(current->mempolicy);
        if (nid_alloc != nid_here)
-               return __cache_alloc_node(cachep, flags, nid_alloc);
+               return ____cache_alloc_node(cachep, flags, nid_alloc);
        return NULL;
 }
 
 /*
  * Fallback function if there was no memory available and no objects on a
- * certain node and we are allowed to fall back. We mimick the behavior of
- * the page allocator. We fall back according to a zonelist determined by
- * the policy layer while obeying cpuset constraints.
+ * certain node and fall back is permitted. First we scan all the
+ * available nodelists for available objects. If that fails then we
+ * perform an allocation without specifying a node. This allows the page
+ * allocator to do its reclaim / fallback magic. We then insert the
+ * slab into the proper nodelist and then allocate from it.
  */
 void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
 {
@@ -3151,15 +3250,51 @@ void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
                                        ->node_zonelists[gfp_zone(flags)];
        struct zone **z;
        void *obj = NULL;
+       int nid;
 
+retry:
+       /*
+        * Look through allowed nodes for objects available
+        * from existing per node queues.
+        */
        for (z = zonelist->zones; *z && !obj; z++) {
-               int nid = zone_to_nid(*z);
+               nid = zone_to_nid(*z);
 
-               if (zone_idx(*z) <= ZONE_NORMAL &&
-                               cpuset_zone_allowed(*z, flags) &&
-                               cache->nodelists[nid])
-                       obj = __cache_alloc_node(cache,
-                                       flags | __GFP_THISNODE, nid);
+               if (cpuset_zone_allowed(*z, flags | __GFP_HARDWALL) &&
+                       cache->nodelists[nid] &&
+                       cache->nodelists[nid]->free_objects)
+                               obj = ____cache_alloc_node(cache,
+                                       flags | GFP_THISNODE, nid);
+       }
+
+       if (!obj) {
+               /*
+                * This allocation will be performed within the constraints
+                * of the current cpuset / memory policy requirements.
+                * We may trigger various forms of reclaim on the allowed
+                * set and go into memory reserves if necessary.
+                */
+               obj = kmem_getpages(cache, flags, -1);
+               if (obj) {
+                       /*
+                        * Insert into the appropriate per node queues
+                        */
+                       nid = page_to_nid(virt_to_page(obj));
+                       if (cache_grow(cache, flags, nid, obj)) {
+                               obj = ____cache_alloc_node(cache,
+                                       flags | GFP_THISNODE, nid);
+                               if (!obj)
+                                       /*
+                                        * Another processor may allocate the
+                                        * objects in the slab since we are
+                                        * not holding any locks.
+                                        */
+                                       goto retry;
+                       } else {
+                               kmem_freepages(cache, obj);
+                               obj = NULL;
+                       }
+               }
        }
        return obj;
 }
@@ -3167,7 +3302,7 @@ void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
 /*
  * A interface to enable slab creation on nodeid
  */
-static void *__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
+static void *____cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
                                int nodeid)
 {
        struct list_head *entry;
@@ -3216,7 +3351,7 @@ retry:
 
 must_grow:
        spin_unlock(&l3->list_lock);
-       x = cache_grow(cachep, flags, nodeid);
+       x = cache_grow(cachep, flags | GFP_THISNODE, nodeid, NULL);
        if (x)
                goto retry;
 
@@ -3434,35 +3569,59 @@ out:
  * @flags: See kmalloc().
  * @nodeid: node number of the target node.
  *
- * Identical to kmem_cache_alloc, except that this function is slow
- * and can sleep. And it will allocate memory on the given node, which
- * can improve the performance for cpu bound structures.
- * New and improved: it will now make sure that the object gets
- * put on the correct node list so that there is no false sharing.
+ * Identical to kmem_cache_alloc but it will allocate memory on the given
+ * node, which can improve the performance for cpu bound structures.
+ *
+ * Fallback to other node is possible if __GFP_THISNODE is not set.
  */
-void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid)
+static __always_inline void *
+__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
+               int nodeid, void *caller)
 {
        unsigned long save_flags;
-       void *ptr;
+       void *ptr = NULL;
 
        cache_alloc_debugcheck_before(cachep, flags);
        local_irq_save(save_flags);
 
-       if (nodeid == -1 || nodeid == numa_node_id() ||
-                       !cachep->nodelists[nodeid])
-               ptr = ____cache_alloc(cachep, flags);
-       else
-               ptr = __cache_alloc_node(cachep, flags, nodeid);
-       local_irq_restore(save_flags);
+       if (unlikely(nodeid == -1))
+               nodeid = numa_node_id();
 
-       ptr = cache_alloc_debugcheck_after(cachep, flags, ptr,
-                                          __builtin_return_address(0));
+       if (likely(cachep->nodelists[nodeid])) {
+               if (nodeid == numa_node_id()) {
+                       /*
+                        * Use the locally cached objects if possible.
+                        * However ____cache_alloc does not allow fallback
+                        * to other nodes. It may fail while we still have
+                        * objects on other nodes available.
+                        */
+                       ptr = ____cache_alloc(cachep, flags);
+               }
+               if (!ptr) {
+                       /* ___cache_alloc_node can fall back to other nodes */
+                       ptr = ____cache_alloc_node(cachep, flags, nodeid);
+               }
+       } else {
+               /* Node not bootstrapped yet */
+               if (!(flags & __GFP_THISNODE))
+                       ptr = fallback_alloc(cachep, flags);
+       }
+
+       local_irq_restore(save_flags);
+       ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
 
        return ptr;
 }
+
+void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid)
+{
+       return __cache_alloc_node(cachep, flags, nodeid,
+                       __builtin_return_address(0));
+}
 EXPORT_SYMBOL(kmem_cache_alloc_node);
 
-void *__kmalloc_node(size_t size, gfp_t flags, int node)
+static __always_inline void *
+__do_kmalloc_node(size_t size, gfp_t flags, int node, void *caller)
 {
        struct kmem_cache *cachep;
 
@@ -3471,8 +3630,29 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
                return NULL;
        return kmem_cache_alloc_node(cachep, flags, node);
 }
+
+#ifdef CONFIG_DEBUG_SLAB
+void *__kmalloc_node(size_t size, gfp_t flags, int node)
+{
+       return __do_kmalloc_node(size, flags, node,
+                       __builtin_return_address(0));
+}
 EXPORT_SYMBOL(__kmalloc_node);
-#endif
+
+void *__kmalloc_node_track_caller(size_t size, gfp_t flags,
+               int node, void *caller)
+{
+       return __do_kmalloc_node(size, flags, node, caller);
+}
+EXPORT_SYMBOL(__kmalloc_node_track_caller);
+#else
+void *__kmalloc_node(size_t size, gfp_t flags, int node)
+{
+       return __do_kmalloc_node(size, flags, node, NULL);
+}
+EXPORT_SYMBOL(__kmalloc_node);
+#endif /* CONFIG_DEBUG_SLAB */
+#endif /* CONFIG_NUMA */
 
 /**
  * __do_kmalloc - allocate memory
@@ -3583,13 +3763,15 @@ static int alloc_kmemlist(struct kmem_cache *cachep)
        int node;
        struct kmem_list3 *l3;
        struct array_cache *new_shared;
-       struct array_cache **new_alien;
+       struct array_cache **new_alien = NULL;
 
        for_each_online_node(node) {
 
-               new_alien = alloc_alien_cache(node, cachep->limit);
-               if (!new_alien)
-                       goto fail;
+                if (use_alien_caches) {
+                        new_alien = alloc_alien_cache(node, cachep->limit);
+                        if (!new_alien)
+                                goto fail;
+                }
 
                new_shared = alloc_arraycache(node,
                                cachep->shared*cachep->batchcount,
@@ -4038,7 +4220,7 @@ static int s_show(struct seq_file *m, void *p)
  * + further values on SMP and with statistics enabled
  */
 
-struct seq_operations slabinfo_op = {
+const struct seq_operations slabinfo_op = {
        .start = s_start,
        .next = s_next,
        .stop = s_stop,
@@ -4236,7 +4418,7 @@ static int leaks_show(struct seq_file *m, void *p)
        return 0;
 }
 
-struct seq_operations slabstats_op = {
+const struct seq_operations slabstats_op = {
        .start = leaks_start,
        .next = s_next,
        .stop = s_stop,
index b3c82ba300124ea28d1cb952f337e387b1c4b9eb..ac26eb0d73cddeaf53b20fb7a7d31f954b8bc117 100644 (file)
@@ -24,6 +24,25 @@ struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT]
 #endif
 EXPORT_SYMBOL(mem_section);
 
+#ifdef NODE_NOT_IN_PAGE_FLAGS
+/*
+ * If we did not store the node number in the page then we have to
+ * do a lookup in the section_to_node_table in order to find which
+ * node the page belongs to.
+ */
+#if MAX_NUMNODES <= 256
+static u8 section_to_node_table[NR_MEM_SECTIONS] __cacheline_aligned;
+#else
+static u16 section_to_node_table[NR_MEM_SECTIONS] __cacheline_aligned;
+#endif
+
+int page_to_nid(struct page *page)
+{
+       return section_to_node_table[page_to_section(page)];
+}
+EXPORT_SYMBOL(page_to_nid);
+#endif
+
 #ifdef CONFIG_SPARSEMEM_EXTREME
 static struct mem_section *sparse_index_alloc(int nid)
 {
@@ -49,6 +68,10 @@ static int sparse_index_init(unsigned long section_nr, int nid)
        struct mem_section *section;
        int ret = 0;
 
+#ifdef NODE_NOT_IN_PAGE_FLAGS
+       section_to_node_table[section_nr] = nid;
+#endif
+
        if (mem_section[root])
                return -EEXIST;
 
index d9a3770d8f3cf879cc53e7cc16fd3a60d3eb600b..2ed7be39795e3034986988502b75982698a1febb 100644 (file)
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -57,9 +57,9 @@ static void put_compound_page(struct page *page)
 {
        page = (struct page *)page_private(page);
        if (put_page_testzero(page)) {
-               void (*dtor)(struct page *page);
+               compound_page_dtor *dtor;
 
-               dtor = (void (*)(struct page *))page[1].lru.next;
+               dtor = get_compound_page_dtor(page);
                (*dtor)(page);
        }
 }
@@ -514,5 +514,7 @@ void __init swap_setup(void)
         * Right now other parts of the system means that we
         * _really_ don't want to cluster much more
         */
+#ifdef CONFIG_HOTPLUG_CPU
        hotcpu_notifier(cpu_swap_callback, 0);
+#endif
 }
index a15def63f28f19e8e9d0e9f550177b80b033526e..b9fc0e5de6d50d1892dca42e02ae5d0ad48d7a47 100644 (file)
@@ -427,34 +427,48 @@ void free_swap_and_cache(swp_entry_t entry)
 
 #ifdef CONFIG_SOFTWARE_SUSPEND
 /*
- * Find the swap type that corresponds to given device (if any)
+ * Find the swap type that corresponds to given device (if any).
  *
- * This is needed for software suspend and is done in such a way that inode
- * aliasing is allowed.
+ * @offset - number of the PAGE_SIZE-sized block of the device, starting
+ * from 0, in which the swap header is expected to be located.
+ *
+ * This is needed for the suspend to disk (aka swsusp).
  */
-int swap_type_of(dev_t device)
+int swap_type_of(dev_t device, sector_t offset)
 {
+       struct block_device *bdev = NULL;
        int i;
 
+       if (device)
+               bdev = bdget(device);
+
        spin_lock(&swap_lock);
        for (i = 0; i < nr_swapfiles; i++) {
-               struct inode *inode;
+               struct swap_info_struct *sis = swap_info + i;
 
-               if (!(swap_info[i].flags & SWP_WRITEOK))
+               if (!(sis->flags & SWP_WRITEOK))
                        continue;
 
-               if (!device) {
+               if (!bdev) {
                        spin_unlock(&swap_lock);
                        return i;
                }
-               inode = swap_info[i].swap_file->f_dentry->d_inode;
-               if (S_ISBLK(inode->i_mode) &&
-                   device == MKDEV(imajor(inode), iminor(inode))) {
-                       spin_unlock(&swap_lock);
-                       return i;
+               if (bdev == sis->bdev) {
+                       struct swap_extent *se;
+
+                       se = list_entry(sis->extent_list.next,
+                                       struct swap_extent, list);
+                       if (se->start_block == offset) {
+                               spin_unlock(&swap_lock);
+                               bdput(bdev);
+                               return i;
+                       }
                }
        }
        spin_unlock(&swap_lock);
+       if (bdev)
+               bdput(bdev);
+
        return -ENODEV;
 }
 
@@ -931,6 +945,23 @@ sector_t map_swap_page(struct swap_info_struct *sis, pgoff_t offset)
        }
 }
 
+#ifdef CONFIG_SOFTWARE_SUSPEND
+/*
+ * Get the (PAGE_SIZE) block corresponding to given offset on the swapdev
+ * corresponding to given index in swap_info (swap type).
+ */
+sector_t swapdev_block(int swap_type, pgoff_t offset)
+{
+       struct swap_info_struct *sis;
+
+       if (swap_type >= nr_swapfiles)
+               return 0;
+
+       sis = swap_info + swap_type;
+       return (sis->flags & SWP_WRITEOK) ? map_swap_page(sis, offset) : 0;
+}
+#endif /* CONFIG_SOFTWARE_SUSPEND */
+
 /*
  * Free all of a swapdev's extent information
  */
@@ -1274,10 +1305,13 @@ static void *swap_start(struct seq_file *swap, loff_t *pos)
 
        mutex_lock(&swapon_mutex);
 
+       if (!l)
+               return SEQ_START_TOKEN;
+
        for (i = 0; i < nr_swapfiles; i++, ptr++) {
                if (!(ptr->flags & SWP_USED) || !ptr->swap_map)
                        continue;
-               if (!l--)
+               if (!--l)
                        return ptr;
        }
 
@@ -1286,10 +1320,17 @@ static void *swap_start(struct seq_file *swap, loff_t *pos)
 
 static void *swap_next(struct seq_file *swap, void *v, loff_t *pos)
 {
-       struct swap_info_struct *ptr = v;
+       struct swap_info_struct *ptr;
        struct swap_info_struct *endptr = swap_info + nr_swapfiles;
 
-       for (++ptr; ptr < endptr; ptr++) {
+       if (v == SEQ_START_TOKEN)
+               ptr = swap_info;
+       else {
+               ptr = v;
+               ptr++;
+       }
+
+       for (; ptr < endptr; ptr++) {
                if (!(ptr->flags & SWP_USED) || !ptr->swap_map)
                        continue;
                ++*pos;
@@ -1310,14 +1351,16 @@ static int swap_show(struct seq_file *swap, void *v)
        struct file *file;
        int len;
 
-       if (v == swap_info)
-               seq_puts(swap, "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
+       if (ptr == SEQ_START_TOKEN) {
+               seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
+               return 0;
+       }
 
        file = ptr->swap_file;
-       len = seq_path(swap, file->f_vfsmnt, file->f_dentry, " \t\n\\");
+       len = seq_path(swap, file->f_path.mnt, file->f_path.dentry, " \t\n\\");
        seq_printf(swap, "%*s%s\t%u\t%u\t%d\n",
                       len < 40 ? 40 - len : 1, " ",
-                      S_ISBLK(file->f_dentry->d_inode->i_mode) ?
+                      S_ISBLK(file->f_path.dentry->d_inode->i_mode) ?
                                "partition" : "file\t",
                       ptr->pages << (PAGE_SHIFT - 10),
                       ptr->inuse_pages << (PAGE_SHIFT - 10),
@@ -1325,7 +1368,7 @@ static int swap_show(struct seq_file *swap, void *v)
        return 0;
 }
 
-static struct seq_operations swaps_op = {
+static const struct seq_operations swaps_op = {
        .start =        swap_start,
        .next =         swap_next,
        .stop =         swap_stop,
@@ -1337,7 +1380,7 @@ static int swaps_open(struct inode *inode, struct file *file)
        return seq_open(file, &swaps_op);
 }
 
-static struct file_operations proc_swaps_operations = {
+static const struct file_operations proc_swaps_operations = {
        .open           = swaps_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
@@ -1540,6 +1583,11 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
                error = -EINVAL;
                if (!maxpages)
                        goto bad_swap;
+               if (swapfilesize && maxpages > swapfilesize) {
+                       printk(KERN_WARNING
+                              "Swap area shorter than signature indicates\n");
+                       goto bad_swap;
+               }
                if (swap_header->info.nr_badpages && S_ISREG(inode->i_mode))
                        goto bad_swap;
                if (swap_header->info.nr_badpages > MAX_SWAP_BADPAGES)
@@ -1567,12 +1615,6 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
                        goto bad_swap;
        }
 
-       if (swapfilesize && maxpages > swapfilesize) {
-               printk(KERN_WARNING
-                      "Swap area shorter than signature indicates\n");
-               error = -EINVAL;
-               goto bad_swap;
-       }
        if (nr_good_pages) {
                p->swap_map[0] = SWAP_MAP_BAD;
                p->max = maxpages;
index f4c560b4a2b79862340fe7457af001f8e6141715..9ef9071f99bcd7322b8e1f6808a477403b891211 100644 (file)
  *
  * Simple token based thrashing protection, using the algorithm
  * described in:  http://www.cs.wm.edu/~sjiang/token.pdf
+ *
+ * Sep 2006, Ashwin Chaugule <ashwin.chaugule@celunite.com>
+ * Improved algorithm to pass token:
+ * Each task has a priority which is incremented if it contended
+ * for the token in an interval less than its previous attempt.
+ * If the token is acquired, that task's priority is boosted to prevent
+ * the token from bouncing around too often and to let the task make
+ * some progress in its execution.
  */
+
 #include <linux/jiffies.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/swap.h>
 
 static DEFINE_SPINLOCK(swap_token_lock);
-static unsigned long swap_token_timeout;
-static unsigned long swap_token_check;
-struct mm_struct * swap_token_mm = &init_mm;
-
-#define SWAP_TOKEN_CHECK_INTERVAL (HZ * 2)
-#define SWAP_TOKEN_TIMEOUT     (300 * HZ)
-/*
- * Currently disabled; Needs further code to work at HZ * 300.
- */
-unsigned long swap_token_default_timeout = SWAP_TOKEN_TIMEOUT;
-
-/*
- * Take the token away if the process had no page faults
- * in the last interval, or if it has held the token for
- * too long.
- */
-#define SWAP_TOKEN_ENOUGH_RSS 1
-#define SWAP_TOKEN_TIMED_OUT 2
-static int should_release_swap_token(struct mm_struct *mm)
-{
-       int ret = 0;
-       if (!mm->recent_pagein)
-               ret = SWAP_TOKEN_ENOUGH_RSS;
-       else if (time_after(jiffies, swap_token_timeout))
-               ret = SWAP_TOKEN_TIMED_OUT;
-       mm->recent_pagein = 0;
-       return ret;
-}
+struct mm_struct *swap_token_mm;
+static unsigned int global_faults;
 
-/*
- * Try to grab the swapout protection token.  We only try to
- * grab it once every TOKEN_CHECK_INTERVAL, both to prevent
- * SMP lock contention and to check that the process that held
- * the token before is no longer thrashing.
- */
 void grab_swap_token(void)
 {
-       struct mm_struct *mm;
-       int reason;
+       int current_interval;
 
-       /* We have the token. Let others know we still need it. */
-       if (has_swap_token(current->mm)) {
-               current->mm->recent_pagein = 1;
-               if (unlikely(!swap_token_default_timeout))
-                       disable_swap_token();
-               return;
-       }
-
-       if (time_after(jiffies, swap_token_check)) {
+       global_faults++;
 
-               if (!swap_token_default_timeout) {
-                       swap_token_check = jiffies + SWAP_TOKEN_CHECK_INTERVAL;
-                       return;
-               }
-
-               /* ... or if we recently held the token. */
-               if (time_before(jiffies, current->mm->swap_token_time))
-                       return;
+       current_interval = global_faults - current->mm->faultstamp;
 
-               if (!spin_trylock(&swap_token_lock))
-                       return;
+       if (!spin_trylock(&swap_token_lock))
+               return;
 
-               swap_token_check = jiffies + SWAP_TOKEN_CHECK_INTERVAL;
+       /* First come first served */
+       if (swap_token_mm == NULL) {
+               current->mm->token_priority = current->mm->token_priority + 2;
+               swap_token_mm = current->mm;
+               goto out;
+       }
 
-               mm = swap_token_mm;
-               if ((reason = should_release_swap_token(mm))) {
-                       unsigned long eligible = jiffies;
-                       if (reason == SWAP_TOKEN_TIMED_OUT) {
-                               eligible += swap_token_default_timeout;
-                       }
-                       mm->swap_token_time = eligible;
-                       swap_token_timeout = jiffies + swap_token_default_timeout;
+       if (current->mm != swap_token_mm) {
+               if (current_interval < current->mm->last_interval)
+                       current->mm->token_priority++;
+               else {
+                       current->mm->token_priority--;
+                       if (unlikely(current->mm->token_priority < 0))
+                               current->mm->token_priority = 0;
+               }
+               /* Check if we deserve the token */
+               if (current->mm->token_priority >
+                               swap_token_mm->token_priority) {
+                       current->mm->token_priority += 2;
                        swap_token_mm = current->mm;
                }
-               spin_unlock(&swap_token_lock);
+       } else {
+               /* Token holder came in again! */
+               current->mm->token_priority += 2;
        }
-       return;
+
+out:
+       current->mm->faultstamp = global_faults;
+       current->mm->last_interval = current_interval;
+       spin_unlock(&swap_token_lock);
+return;
 }
 
 /* Called on process exit. */
 void __put_swap_token(struct mm_struct *mm)
 {
        spin_lock(&swap_token_lock);
-       if (likely(mm == swap_token_mm)) {
-               mm->swap_token_time = jiffies + SWAP_TOKEN_CHECK_INTERVAL;
-               swap_token_mm = &init_mm;
-               swap_token_check = jiffies;
-       }
+       if (likely(mm == swap_token_mm))
+               swap_token_mm = NULL;
        spin_unlock(&swap_token_lock);
 }
index 5f2cbf0f153c7a35db2219cab124c0ac8513ce4c..c7f6e1914bc4e77264591f02958c32f1f8af1d93 100644 (file)
@@ -79,8 +79,8 @@ struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags)
        d_instantiate(dentry, inode);
        inode->i_nlink = 0;     /* It is unlinked */
 
-       file->f_vfsmnt = mntget(shm_mnt);
-       file->f_dentry = dentry;
+       file->f_path.mnt = mntget(shm_mnt);
+       file->f_path.dentry = dentry;
        file->f_mapping = inode->i_mapping;
        file->f_op = &ramfs_file_operations;
        file->f_mode = FMODE_WRITE | FMODE_READ;
index 518540a4a2a66a1ade20312d1d655ba6923e05b5..093f5fe6dd7795cc5d0ca15f5918eedc822b87f4 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/rwsem.h>
 #include <linux/delay.h>
 #include <linux/kthread.h>
+#include <linux/freezer.h>
 
 #include <asm/tlbflush.h>
 #include <asm/div64.h>
@@ -1172,11 +1173,12 @@ loop_again:
                        if (!zone_watermark_ok(zone, order, zone->pages_high,
                                               0, 0)) {
                                end_zone = i;
-                               goto scan;
+                               break;
                        }
                }
-               goto out;
-scan:
+               if (i < 0)
+                       goto out;
+
                for (i = 0; i <= end_zone; i++) {
                        struct zone *zone = pgdat->node_zones + i;
 
@@ -1259,6 +1261,9 @@ out:
        }
        if (!all_zones_ok) {
                cond_resched();
+
+               try_to_freeze();
+
                goto loop_again;
        }
 
@@ -1508,7 +1513,6 @@ out:
 }
 #endif
 
-#ifdef CONFIG_HOTPLUG_CPU
 /* It's optimal to keep kswapds on the same CPUs as their memory, but
    not required for correctness.  So if the last cpu in a node goes
    away, we get changed to run anywhere: as the first one comes back,
@@ -1529,7 +1533,6 @@ static int __devinit cpu_callback(struct notifier_block *nfb,
        }
        return NOTIFY_OK;
 }
-#endif /* CONFIG_HOTPLUG_CPU */
 
 /*
  * This kswapd start function will be called by init and node-hot-add.
index 8614e8f6743b599c3761d6d2ca30f0012048676e..dc005a0c96ae5a0162b9da79e43d663c61c9422a 100644 (file)
@@ -430,7 +430,7 @@ static int frag_show(struct seq_file *m, void *arg)
        return 0;
 }
 
-struct seq_operations fragmentation_op = {
+const struct seq_operations fragmentation_op = {
        .start  = frag_start,
        .next   = frag_next,
        .stop   = frag_stop,
@@ -452,7 +452,7 @@ struct seq_operations fragmentation_op = {
 #define TEXTS_FOR_ZONES(xx) xx "_dma", TEXT_FOR_DMA32(xx) xx "_normal", \
                                        TEXT_FOR_HIGHMEM(xx)
 
-static char *vmstat_text[] = {
+static const char * const vmstat_text[] = {
        /* Zoned VM counters */
        "nr_anon_pages",
        "nr_mapped",
@@ -597,7 +597,7 @@ static int zoneinfo_show(struct seq_file *m, void *arg)
        return 0;
 }
 
-struct seq_operations zoneinfo_op = {
+const struct seq_operations zoneinfo_op = {
        .start  = frag_start, /* iterate over all zones. The same as in
                               * fragmentation. */
        .next   = frag_next,
@@ -660,7 +660,7 @@ static void vmstat_stop(struct seq_file *m, void *arg)
        m->private = NULL;
 }
 
-struct seq_operations vmstat_op = {
+const struct seq_operations vmstat_op = {
        .start  = vmstat_start,
        .next   = vmstat_next,
        .stop   = vmstat_stop,
@@ -679,13 +679,13 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
                void *hcpu)
 {
        switch (action) {
-               case CPU_UP_PREPARE:
-               case CPU_UP_CANCELED:
-               case CPU_DEAD:
-                       refresh_zone_stat_thresholds();
-                       break;
-               default:
-                       break;
+       case CPU_UP_PREPARE:
+       case CPU_UP_CANCELED:
+       case CPU_DEAD:
+               refresh_zone_stat_thresholds();
+               break;
+       default:
+               break;
        }
        return NOTIFY_OK;
 }
index 91fe5f53ff112377755054d16ff82cd599dd54a5..739866bfe9e9d6992c05e64227964db56dcb3968 100644 (file)
@@ -393,7 +393,7 @@ static ssize_t proc_dev_atm_read(struct file *file, char __user *buf,
        if (count == 0) return 0;
        page = get_zeroed_page(GFP_KERNEL);
        if (!page) return -ENOMEM;
-       dev = PDE(file->f_dentry->d_inode)->data;
+       dev = PDE(file->f_path.dentry->d_inode)->data;
        if (!dev->ops->proc_read)
                length = -EINVAL;
        else {
index 5f0896ad0042d59662d33e351853a83538e13a96..21a0616152fc4d56b72ded295163eeb93c02a3dd 100644 (file)
 #include <linux/interrupt.h>
 
 /*
- *     The null address is defined as a callsign of all spaces with an
- *     SSID of zero.
+ * The default broadcast address of an interface is QST-0; the default address
+ * is LINUX-1.  The null address is defined as a callsign of all spaces with
+ * an SSID of zero.
  */
-ax25_address null_ax25_address = {{0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00}};
 
+const ax25_address ax25_bcast =
+       {{'Q' << 1, 'S' << 1, 'T' << 1, ' ' << 1, ' ' << 1, ' ' << 1, 0 << 1}};
+const ax25_address ax25_defaddr =
+       {{'L' << 1, 'I' << 1, 'N' << 1, 'U' << 1, 'X' << 1, ' ' << 1, 1 << 1}};
+const ax25_address null_ax25_address =
+       {{' ' << 1, ' ' << 1, ' ' << 1, ' ' << 1, ' ' << 1, ' ' << 1, 0 << 1}};
+
+EXPORT_SYMBOL_GPL(ax25_bcast);
+EXPORT_SYMBOL_GPL(ax25_defaddr);
 EXPORT_SYMBOL(null_ax25_address);
 
 /*
  *     ax25 -> ascii conversion
  */
-char *ax2asc(char *buf, ax25_address *a)
+char *ax2asc(char *buf, const ax25_address *a)
 {
        char c, *s;
        int n;
@@ -72,7 +81,7 @@ EXPORT_SYMBOL(ax2asc);
 /*
  *     ascii -> ax25 conversion
  */
-void asc2ax(ax25_address *addr, char *callsign)
+void asc2ax(ax25_address *addr, const char *callsign)
 {
        char *s;
        int n;
@@ -107,7 +116,7 @@ EXPORT_SYMBOL(asc2ax);
 /*
  *     Compare two ax.25 addresses
  */
-int ax25cmp(ax25_address *a, ax25_address *b)
+int ax25cmp(const ax25_address *a, const ax25_address *b)
 {
        int ct = 0;
 
@@ -128,7 +137,7 @@ EXPORT_SYMBOL(ax25cmp);
 /*
  *     Compare two AX.25 digipeater paths.
  */
-int ax25digicmp(ax25_digi *digi1, ax25_digi *digi2)
+int ax25digicmp(const ax25_digi *digi1, const ax25_digi *digi2)
 {
        int i;
 
@@ -149,7 +158,9 @@ int ax25digicmp(ax25_digi *digi1, ax25_digi *digi2)
  *     Given an AX.25 address pull of to, from, digi list, command/response and the start of data
  *
  */
-unsigned char *ax25_addr_parse(unsigned char *buf, int len, ax25_address *src, ax25_address *dest, ax25_digi *digi, int *flags, int *dama)
+const unsigned char *ax25_addr_parse(const unsigned char *buf, int len,
+       ax25_address *src, ax25_address *dest, ax25_digi *digi, int *flags,
+       int *dama)
 {
        int d = 0;
 
@@ -204,7 +215,8 @@ unsigned char *ax25_addr_parse(unsigned char *buf, int len, ax25_address *src, a
 /*
  *     Assemble an AX.25 header from the bits
  */
-int ax25_addr_build(unsigned char *buf, ax25_address *src, ax25_address *dest, ax25_digi *d, int flag, int modulus)
+int ax25_addr_build(unsigned char *buf, const ax25_address *src,
+       const ax25_address *dest, const ax25_digi *d, int flag, int modulus)
 {
        int len = 0;
        int ct  = 0;
@@ -261,7 +273,7 @@ int ax25_addr_build(unsigned char *buf, ax25_address *src, ax25_address *dest, a
        return len;
 }
 
-int ax25_addr_size(ax25_digi *dp)
+int ax25_addr_size(const ax25_digi *dp)
 {
        if (dp == NULL)
                return 2 * AX25_ADDR_LEN;
@@ -272,7 +284,7 @@ int ax25_addr_size(ax25_digi *dp)
 /*
  *     Reverse Digipeat List. May not pass both parameters as same struct
  */
-void ax25_digi_invert(ax25_digi *in, ax25_digi *out)
+void ax25_digi_invert(const ax25_digi *in, ax25_digi *out)
 {
        int ct;
 
index 1fb5d42f37ae959c05dc92df929924250eeca90a..e0e0d09023b2f0607e295397a699e5d7b2c55c25 100644 (file)
@@ -752,9 +752,9 @@ static int rfcomm_tty_ioctl(struct tty_struct *tty, struct file *filp, unsigned
        return -ENOIOCTLCMD;
 }
 
-static void rfcomm_tty_set_termios(struct tty_struct *tty, struct termios *old)
+static void rfcomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
 {
-       struct termios *new = (struct termios *) tty->termios;
+       struct ktermios *new = tty->termios;
        int old_baud_rate = tty_termios_baud_rate(old);
        int new_baud_rate = tty_termios_baud_rate(new);
 
index d9f04864d15d859d0ada8bbb57564999e55eb676..8ca448db7a0d779199fde2ed1c81f71eafbbca10 100644 (file)
@@ -23,7 +23,7 @@
 #include <asm/atomic.h>
 #include "br_private.h"
 
-static kmem_cache_t *br_fdb_cache __read_mostly;
+static struct kmem_cache *br_fdb_cache __read_mostly;
 static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
                      const unsigned char *addr);
 
index ac47ba2ba0284c9f22150305a54ac7b0ab9a6504..bd221ad52eaf76e46aa8522b4db1a75176e53ecc 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/netfilter_ipv6.h>
 #include <linux/netfilter_arp.h>
 #include <linux/in_route.h>
+#include <linux/inetdevice.h>
 
 #include <net/ip.h>
 #include <net/ipv6.h>
@@ -221,10 +222,14 @@ static void __br_dnat_complain(void)
  *
  * Otherwise, the packet is considered to be routed and we just
  * change the destination MAC address so that the packet will
- * later be passed up to the IP stack to be routed.
+ * later be passed up to the IP stack to be routed. For a redirected
+ * packet, ip_route_input() will give back the localhost as output device,
+ * which differs from the bridge device.
  *
  * Let us now consider the case that ip_route_input() fails:
  *
+ * This can be because the destination address is martian, in which case
+ * the packet will be dropped.
  * After a "echo '0' > /proc/sys/net/ipv4/ip_forward" ip_route_input()
  * will fail, while __ip_route_output_key() will return success. The source
  * address for __ip_route_output_key() is set to zero, so __ip_route_output_key
@@ -237,7 +242,8 @@ static void __br_dnat_complain(void)
  *
  * --Lennert, 20020411
  * --Bart, 20020416 (updated)
- * --Bart, 20021007 (updated) */
+ * --Bart, 20021007 (updated)
+ * --Bart, 20062711 (updated) */
 static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)
 {
        if (skb->pkt_type == PACKET_OTHERHOST) {
@@ -264,15 +270,15 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb)
        struct net_device *dev = skb->dev;
        struct iphdr *iph = skb->nh.iph;
        struct nf_bridge_info *nf_bridge = skb->nf_bridge;
+       int err;
 
        if (nf_bridge->mask & BRNF_PKT_TYPE) {
                skb->pkt_type = PACKET_OTHERHOST;
                nf_bridge->mask ^= BRNF_PKT_TYPE;
        }
        nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING;
-
        if (dnat_took_place(skb)) {
-               if (ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev)) {
+               if ((err = ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev))) {
                        struct rtable *rt;
                        struct flowi fl = {
                                .nl_u = {
@@ -283,19 +289,33 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb)
                                },
                                .proto = 0,
                        };
+                       struct in_device *in_dev = in_dev_get(dev);
+
+                       /* If err equals -EHOSTUNREACH the error is due to a
+                        * martian destination or due to the fact that
+                        * forwarding is disabled. For most martian packets,
+                        * ip_route_output_key() will fail. It won't fail for 2 types of
+                        * martian destinations: loopback destinations and destination
+                        * 0.0.0.0. In both cases the packet will be dropped because the
+                        * destination is the loopback device and not the bridge. */
+                       if (err != -EHOSTUNREACH || !in_dev || IN_DEV_FORWARD(in_dev))
+                               goto free_skb;
 
                        if (!ip_route_output_key(&rt, &fl)) {
                                /* - Bridged-and-DNAT'ed traffic doesn't
-                                *   require ip_forwarding.
-                                * - Deal with redirected traffic. */
-                               if (((struct dst_entry *)rt)->dev == dev ||
-                                   rt->rt_type == RTN_LOCAL) {
+                                *   require ip_forwarding. */
+                               if (((struct dst_entry *)rt)->dev == dev) {
                                        skb->dst = (struct dst_entry *)rt;
                                        goto bridged_dnat;
                                }
+                               /* we are sure that forwarding is disabled, so printing
+                                * this message is no problem. Note that the packet could
+                                * still have a martian destination address, in which case
+                                * the packet could be dropped even if forwarding were enabled */
                                __br_dnat_complain();
                                dst_release((struct dst_entry *)rt);
                        }
+free_skb:
                        kfree_skb(skb);
                        return 0;
                } else {
index 59d058a3b50487ea6c7c9dfcec8b541422ae3c45..e660cb57e42a0d1221d6c8ee5ba452f8ce9593c9 100644 (file)
@@ -3340,7 +3340,6 @@ void unregister_netdev(struct net_device *dev)
 
 EXPORT_SYMBOL(unregister_netdev);
 
-#ifdef CONFIG_HOTPLUG_CPU
 static int dev_cpu_callback(struct notifier_block *nfb,
                            unsigned long action,
                            void *ocpu)
@@ -3384,7 +3383,6 @@ static int dev_cpu_callback(struct notifier_block *nfb,
 
        return NOTIFY_OK;
 }
-#endif /* CONFIG_HOTPLUG_CPU */
 
 #ifdef CONFIG_NET_DMA
 /**
index 1a5e49da0e77bdaaaaebf5369a97153ff75f4918..836ec66069254752c7ca2b9db0a597419dd758a2 100644 (file)
@@ -125,7 +125,7 @@ void * dst_alloc(struct dst_ops * ops)
                if (ops->gc())
                        return NULL;
        }
-       dst = kmem_cache_alloc(ops->kmem_cachep, SLAB_ATOMIC);
+       dst = kmem_cache_alloc(ops->kmem_cachep, GFP_ATOMIC);
        if (!dst)
                return NULL;
        memset(dst, 0, ops->entry_size);
index b16d31ae5e54db47078a2f6039e1a776e6a02578..d137f971f97db39c702533d54550b68783550364 100644 (file)
@@ -44,7 +44,7 @@ static DEFINE_PER_CPU(struct flow_cache_entry **, flow_tables) = { NULL };
 
 #define flow_table(cpu) (per_cpu(flow_tables, cpu))
 
-static kmem_cache_t *flow_cachep __read_mostly;
+static struct kmem_cache *flow_cachep __read_mostly;
 
 static int flow_lwm, flow_hwm;
 
@@ -211,7 +211,7 @@ void *flow_cache_lookup(struct flowi *key, u16 family, u8 dir,
                if (flow_count(cpu) > flow_hwm)
                        flow_cache_shrink(cpu);
 
-               fle = kmem_cache_alloc(flow_cachep, SLAB_ATOMIC);
+               fle = kmem_cache_alloc(flow_cachep, GFP_ATOMIC);
                if (fle) {
                        fle->next = *head;
                        *head = fle;
@@ -340,7 +340,6 @@ static void __devinit flow_cache_cpu_prepare(int cpu)
        tasklet_init(tasklet, flow_cache_flush_tasklet, 0);
 }
 
-#ifdef CONFIG_HOTPLUG_CPU
 static int flow_cache_cpu(struct notifier_block *nfb,
                          unsigned long action,
                          void *hcpu)
@@ -349,7 +348,6 @@ static int flow_cache_cpu(struct notifier_block *nfb,
                __flow_cache_shrink((unsigned long)hcpu, 0);
        return NOTIFY_OK;
 }
-#endif /* CONFIG_HOTPLUG_CPU */
 
 static int __init flow_cache_init(void)
 {
index ba509a4a8e92939d9dbbbbed4ee432822979d217..e7300b6b40795e5011fa26ad87f0ed2766823fe7 100644 (file)
@@ -251,7 +251,7 @@ static struct neighbour *neigh_alloc(struct neigh_table *tbl)
                        goto out_entries;
        }
 
-       n = kmem_cache_alloc(tbl->kmem_cachep, SLAB_ATOMIC);
+       n = kmem_cache_alloc(tbl->kmem_cachep, GFP_ATOMIC);
        if (!n)
                goto out_entries;
 
@@ -577,9 +577,10 @@ void neigh_destroy(struct neighbour *neigh)
        while ((hh = neigh->hh) != NULL) {
                neigh->hh = hh->hh_next;
                hh->hh_next = NULL;
-               write_lock_bh(&hh->hh_lock);
+
+               write_seqlock_bh(&hh->hh_lock);
                hh->hh_output = neigh_blackhole;
-               write_unlock_bh(&hh->hh_lock);
+               write_sequnlock_bh(&hh->hh_lock);
                if (atomic_dec_and_test(&hh->hh_refcnt))
                        kfree(hh);
        }
@@ -897,9 +898,9 @@ static void neigh_update_hhs(struct neighbour *neigh)
 
        if (update) {
                for (hh = neigh->hh; hh; hh = hh->hh_next) {
-                       write_lock_bh(&hh->hh_lock);
+                       write_seqlock_bh(&hh->hh_lock);
                        update(hh, neigh->dev, neigh->ha);
-                       write_unlock_bh(&hh->hh_lock);
+                       write_sequnlock_bh(&hh->hh_lock);
                }
        }
 }
@@ -1089,7 +1090,7 @@ static void neigh_hh_init(struct neighbour *n, struct dst_entry *dst,
                        break;
 
        if (!hh && (hh = kzalloc(sizeof(*hh), GFP_ATOMIC)) != NULL) {
-               rwlock_init(&hh->hh_lock);
+               seqlock_init(&hh->hh_lock);
                hh->hh_type = protocol;
                atomic_set(&hh->hh_refcnt, 0);
                hh->hh_next = NULL;
index b3c559b9ac35cb9495edb39e4e77c8fedd5f26cf..8a271285f2f378d154d21927790e3a31cefd42a3 100644 (file)
@@ -330,6 +330,7 @@ static void arp_reply(struct sk_buff *skb)
        unsigned char *arp_ptr;
        int size, type = ARPOP_REPLY, ptype = ETH_P_ARP;
        __be32 sip, tip;
+       unsigned char *sha;
        struct sk_buff *send_skb;
        struct netpoll *np = NULL;
 
@@ -356,9 +357,14 @@ static void arp_reply(struct sk_buff *skb)
            arp->ar_op != htons(ARPOP_REQUEST))
                return;
 
-       arp_ptr = (unsigned char *)(arp+1) + skb->dev->addr_len;
+       arp_ptr = (unsigned char *)(arp+1);
+       /* save the location of the src hw addr */
+       sha = arp_ptr;
+       arp_ptr += skb->dev->addr_len;
        memcpy(&sip, arp_ptr, 4);
-       arp_ptr += 4 + skb->dev->addr_len;
+       arp_ptr += 4;
+       /* if we actually cared about dst hw addr, it would get copied here */
+       arp_ptr += skb->dev->addr_len;
        memcpy(&tip, arp_ptr, 4);
 
        /* Should we ignore arp? */
@@ -381,7 +387,7 @@ static void arp_reply(struct sk_buff *skb)
 
        if (np->dev->hard_header &&
            np->dev->hard_header(send_skb, skb->dev, ptype,
-                                np->remote_mac, np->local_mac,
+                                sha, np->local_mac,
                                 send_skb->len) < 0) {
                kfree_skb(send_skb);
                return;
@@ -405,7 +411,7 @@ static void arp_reply(struct sk_buff *skb)
        arp_ptr += np->dev->addr_len;
        memcpy(arp_ptr, &tip, 4);
        arp_ptr += 4;
-       memcpy(arp_ptr, np->remote_mac, np->dev->addr_len);
+       memcpy(arp_ptr, sha, np->dev->addr_len);
        arp_ptr += np->dev->addr_len;
        memcpy(arp_ptr, &sip, 4);
 
index 8e1c385e5ba914e2f50bee987ed0c96ff516ba9c..de7801d589e74605ec0914d357abce7886a599f4 100644 (file)
@@ -68,8 +68,8 @@
 
 #include "kmap_skb.h"
 
-static kmem_cache_t *skbuff_head_cache __read_mostly;
-static kmem_cache_t *skbuff_fclone_cache __read_mostly;
+static struct kmem_cache *skbuff_head_cache __read_mostly;
+static struct kmem_cache *skbuff_fclone_cache __read_mostly;
 
 /*
  *     Keep out-of-line to prevent kernel bloat.
@@ -132,6 +132,7 @@ EXPORT_SYMBOL(skb_truesize_bug);
  *     @gfp_mask: allocation mask
  *     @fclone: allocate from fclone cache instead of head cache
  *             and allocate a cloned (child) skb
+ *     @node: numa node to allocate memory on
  *
  *     Allocate a new &sk_buff. The returned buffer has no headroom and a
  *     tail room of size bytes. The object has a reference count of one.
@@ -141,9 +142,9 @@ EXPORT_SYMBOL(skb_truesize_bug);
  *     %GFP_ATOMIC.
  */
 struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
-                           int fclone)
+                           int fclone, int node)
 {
-       kmem_cache_t *cache;
+       struct kmem_cache *cache;
        struct skb_shared_info *shinfo;
        struct sk_buff *skb;
        u8 *data;
@@ -151,14 +152,14 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
        cache = fclone ? skbuff_fclone_cache : skbuff_head_cache;
 
        /* Get the HEAD */
-       skb = kmem_cache_alloc(cache, gfp_mask & ~__GFP_DMA);
+       skb = kmem_cache_alloc_node(cache, gfp_mask & ~__GFP_DMA, node);
        if (!skb)
                goto out;
 
        /* Get the DATA. Size must match skb_add_mtu(). */
        size = SKB_DATA_ALIGN(size);
-       data = kmalloc_track_caller(size + sizeof(struct skb_shared_info),
-                       gfp_mask);
+       data = kmalloc_node_track_caller(size + sizeof(struct skb_shared_info),
+                       gfp_mask, node);
        if (!data)
                goto nodata;
 
@@ -210,7 +211,7 @@ nodata:
  *     Buffers may only be allocated from interrupts using a @gfp_mask of
  *     %GFP_ATOMIC.
  */
-struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp,
+struct sk_buff *alloc_skb_from_cache(struct kmem_cache *cp,
                                     unsigned int size,
                                     gfp_t gfp_mask)
 {
@@ -267,9 +268,10 @@ nodata:
 struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
                unsigned int length, gfp_t gfp_mask)
 {
+       int node = dev->class_dev.dev ? dev_to_node(dev->class_dev.dev) : -1;
        struct sk_buff *skb;
 
-       skb = alloc_skb(length + NET_SKB_PAD, gfp_mask);
+       skb = __alloc_skb(length + NET_SKB_PAD, gfp_mask, 0, node);
        if (likely(skb)) {
                skb_reserve(skb, NET_SKB_PAD);
                skb->dev = dev;
index 419c7d3289c7a9689bca3e0164ed7ac01098c2d8..0ed5b4f0bc407aef5b376149dcc2d49aa3c49937 100644 (file)
@@ -810,24 +810,11 @@ lenout:
  */
 static void inline sock_lock_init(struct sock *sk)
 {
-       spin_lock_init(&sk->sk_lock.slock);
-       sk->sk_lock.owner = NULL;
-       init_waitqueue_head(&sk->sk_lock.wq);
-       /*
-        * Make sure we are not reinitializing a held lock:
-        */
-       debug_check_no_locks_freed((void *)&sk->sk_lock, sizeof(sk->sk_lock));
-
-       /*
-        * Mark both the sk_lock and the sk_lock.slock as a
-        * per-address-family lock class:
-        */
-       lockdep_set_class_and_name(&sk->sk_lock.slock,
-                                  af_family_slock_keys + sk->sk_family,
-                                  af_family_slock_key_strings[sk->sk_family]);
-       lockdep_init_map(&sk->sk_lock.dep_map,
-                        af_family_key_strings[sk->sk_family],
-                        af_family_keys + sk->sk_family, 0);
+       sock_lock_init_class_and_name(sk,
+                       af_family_slock_key_strings[sk->sk_family],
+                       af_family_slock_keys + sk->sk_family,
+                       af_family_key_strings[sk->sk_family],
+                       af_family_keys + sk->sk_family);
 }
 
 /**
@@ -841,7 +828,7 @@ struct sock *sk_alloc(int family, gfp_t priority,
                      struct proto *prot, int zero_it)
 {
        struct sock *sk = NULL;
-       kmem_cache_t *slab = prot->slab;
+       struct kmem_cache *slab = prot->slab;
 
        if (slab != NULL)
                sk = kmem_cache_alloc(slab, priority);
index cb1b8728d7eec0c55c6151da9fba7d00f42747e9..f69ab7b4408ecca979e5e6f43aefd2a051577c06 100644 (file)
@@ -2130,7 +2130,7 @@ int iw_handler_set_spy(struct net_device *        dev,
         * The rtnl_lock() make sure we don't race with the other iw_handlers.
         * This make sure wireless_spy_update() "see" that the spy list
         * is temporarily disabled. */
-       wmb();
+       smp_wmb();
 
        /* Are there are addresses to copy? */
        if(wrqu->data.length > 0) {
@@ -2159,7 +2159,7 @@ int iw_handler_set_spy(struct net_device *        dev,
        }
 
        /* Make sure above is updated before re-enabling */
-       wmb();
+       smp_wmb();
 
        /* Enable addresses */
        spydata->spy_number = wrqu->data.length;
index bdf1bb7a82c0758725522b69e7d73fe2663332e6..1f4727ddbdbfbf1e8d1214ed2604bb4a120306ac 100644 (file)
@@ -21,8 +21,8 @@
 
 #include <net/sock.h>
 
-static kmem_cache_t *dccp_ackvec_slab;
-static kmem_cache_t *dccp_ackvec_record_slab;
+static struct kmem_cache *dccp_ackvec_slab;
+static struct kmem_cache *dccp_ackvec_record_slab;
 
 static struct dccp_ackvec_record *dccp_ackvec_record_new(void)
 {
index ff05e59043cdb33769f810d16a8a667320d9e075..d8cf92f09e68f1896519f2583eff815cbb6f4cfb 100644 (file)
@@ -55,9 +55,9 @@ static inline void ccids_read_unlock(void)
 #define ccids_read_unlock() do { } while(0)
 #endif
 
-static kmem_cache_t *ccid_kmem_cache_create(int obj_size, const char *fmt,...)
+static struct kmem_cache *ccid_kmem_cache_create(int obj_size, const char *fmt,...)
 {
-       kmem_cache_t *slab;
+       struct kmem_cache *slab;
        char slab_name_fmt[32], *slab_name;
        va_list args;
 
@@ -75,7 +75,7 @@ static kmem_cache_t *ccid_kmem_cache_create(int obj_size, const char *fmt,...)
        return slab;
 }
 
-static void ccid_kmem_cache_destroy(kmem_cache_t *slab)
+static void ccid_kmem_cache_destroy(struct kmem_cache *slab)
 {
        if (slab != NULL) {
                const char *name = kmem_cache_name(slab);
index c7c29514dce8a16e5b29827a7ab3cb93136169bb..bcc2d12ae81ccb13d00e428c85840b37a0ac81ec 100644 (file)
@@ -27,9 +27,9 @@ struct ccid_operations {
        unsigned char   ccid_id;
        const char      *ccid_name;
        struct module   *ccid_owner;
-       kmem_cache_t    *ccid_hc_rx_slab;
+       struct kmem_cache       *ccid_hc_rx_slab;
        __u32           ccid_hc_rx_obj_size;
-       kmem_cache_t    *ccid_hc_tx_slab;
+       struct kmem_cache       *ccid_hc_tx_slab;
        __u32           ccid_hc_tx_obj_size;
        int             (*ccid_hc_rx_init)(struct ccid *ccid, struct sock *sk);
        int             (*ccid_hc_tx_init)(struct ccid *ccid, struct sock *sk);
index cf8c07b2704fcc03e589e1c9d4826365c2c6ca84..66a27b9688ca9240579ce897df70637b8698eb18 100644 (file)
@@ -295,7 +295,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
        new_packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist);
        if (new_packet == NULL || new_packet->dccphtx_sent) {
                new_packet = dccp_tx_hist_entry_new(ccid3_tx_hist,
-                                                   SLAB_ATOMIC);
+                                                   GFP_ATOMIC);
 
                if (unlikely(new_packet == NULL)) {
                        DCCP_WARN("%s, sk=%p, not enough mem to add to history,"
@@ -889,7 +889,7 @@ static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss)
                /* new loss event detected */
                /* calculate last interval length */
                seq_temp = dccp_delta_seqno(head->dccplih_seqno, seq_loss);
-               entry = dccp_li_hist_entry_new(ccid3_li_hist, SLAB_ATOMIC);
+               entry = dccp_li_hist_entry_new(ccid3_li_hist, GFP_ATOMIC);
 
                if (entry == NULL) {
                        DCCP_BUG("out of memory - can not allocate entry");
@@ -1011,7 +1011,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
        }
 
        packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp,
-                                       skb, SLAB_ATOMIC);
+                                       skb, GFP_ATOMIC);
        if (unlikely(packet == NULL)) {
                DCCP_WARN("%s, sk=%p, Not enough mem to add rx packet "
                          "to history, consider it lost!\n", dccp_role(sk), sk);
index 48b9b93f8acb999aa4b92a89e0285e5e2798e80c..0a0baef16b3e02f22fc79f0849bc742e59a408d5 100644 (file)
@@ -125,7 +125,7 @@ int dccp_li_hist_interval_new(struct dccp_li_hist *hist,
        int i;
 
        for (i = 0; i < DCCP_LI_HIST_IVAL_F_LENGTH; i++) {
-               entry = dccp_li_hist_entry_new(hist, SLAB_ATOMIC);
+               entry = dccp_li_hist_entry_new(hist, GFP_ATOMIC);
                if (entry == NULL) {
                        dccp_li_hist_purge(hist, list);
                        DCCP_BUG("loss interval list entry is NULL");
index 0ae85f0340b28f58e3a0b3cfb7ef777d608ce298..eb257014dd74c25339f46d96be60641f3fc337e9 100644 (file)
@@ -20,7 +20,7 @@
 #define DCCP_LI_HIST_IVAL_F_LENGTH  8
 
 struct dccp_li_hist {
-       kmem_cache_t *dccplih_slab;
+       struct kmem_cache *dccplih_slab;
 };
 
 extern struct dccp_li_hist *dccp_li_hist_new(const char *name);
index 067cf1c85a375daed16e3ffeeb621a46d2a5f192..9a8bcf224aa73151a3775d2426524c38e1d169dd 100644 (file)
@@ -68,14 +68,14 @@ struct dccp_rx_hist_entry {
 };
 
 struct dccp_tx_hist {
-       kmem_cache_t *dccptxh_slab;
+       struct kmem_cache *dccptxh_slab;
 };
 
 extern struct dccp_tx_hist *dccp_tx_hist_new(const char *name);
 extern void dccp_tx_hist_delete(struct dccp_tx_hist *hist);
 
 struct dccp_rx_hist {
-       kmem_cache_t *dccprxh_slab;
+       struct kmem_cache *dccprxh_slab;
 };
 
 extern struct dccp_rx_hist *dccp_rx_hist_new(const char *name);
index bdbc3f431668b3ff5765e06c0e92a16f804682e9..13b2421991bac8618b5fb27f139a9a2a42bdb4f3 100644 (file)
@@ -79,7 +79,7 @@ for( ; ((f) = *(fp)) != NULL && dn_key_eq((f)->fn_key, (key)); (fp) = &(f)->fn_n
 static struct hlist_head dn_fib_table_hash[DN_FIB_TABLE_HASHSZ];
 static DEFINE_RWLOCK(dn_fib_tables_lock);
 
-static kmem_cache_t *dn_hash_kmem __read_mostly;
+static struct kmem_cache *dn_hash_kmem __read_mostly;
 static int dn_fib_hash_zombies;
 
 static inline dn_fib_idx_t dn_hash(dn_fib_key_t key, struct dn_zone *dz)
@@ -590,7 +590,7 @@ create:
 
 replace:
        err = -ENOBUFS;
-       new_f = kmem_cache_alloc(dn_hash_kmem, SLAB_KERNEL);
+       new_f = kmem_cache_alloc(dn_hash_kmem, GFP_KERNEL);
        if (new_f == NULL)
                goto out;
 
index 08386c102954c07dc7b0a18108c12564a6ff7740..eec1a1dd91da255714c88f8081ac2d28cb94956f 100644 (file)
@@ -431,6 +431,17 @@ ieee80211softmac_handle_assoc_response(struct net_device * dev,
        return 0;
 }
 
+void
+ieee80211softmac_try_reassoc(struct ieee80211softmac_device *mac)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&mac->lock, flags);
+       mac->associnfo.associating = 1;
+       schedule_work(&mac->associnfo.work);
+       spin_unlock_irqrestore(&mac->lock, flags);
+}
+
 int
 ieee80211softmac_handle_disassoc(struct net_device * dev,
                                 struct ieee80211_disassoc *disassoc)
@@ -449,8 +460,7 @@ ieee80211softmac_handle_disassoc(struct net_device * dev,
        dprintk(KERN_INFO PFX "got disassoc frame\n");
        ieee80211softmac_disassoc(mac);
 
-       /* try to reassociate */
-       schedule_delayed_work(&mac->associnfo.work, 0);
+       ieee80211softmac_try_reassoc(mac);
 
        return 0;
 }
index 6012705aa4f8bba10fcc4905c726730339b72d43..8ed3e59b8024fd3f5dea77fd5e5df01162b3d039 100644 (file)
@@ -337,6 +337,8 @@ ieee80211softmac_deauth_from_net(struct ieee80211softmac_device *mac,
        /* can't transmit data right now... */
        netif_carrier_off(mac->dev);
        spin_unlock_irqrestore(&mac->lock, flags);
+
+       ieee80211softmac_try_reassoc(mac);
 }
 
 /* 
index c0dbe070e548f2faef2eb0b089ee2740b7f18a57..4c2bba34d328c811ad2261c83dc39b371b00d7c5 100644 (file)
@@ -239,4 +239,6 @@ void ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, in
 int ieee80211softmac_notify_internal(struct ieee80211softmac_device *mac,
        int event, void *event_context, notify_function_ptr fun, void *context, gfp_t gfp_mask);
 
+void ieee80211softmac_try_reassoc(struct ieee80211softmac_device *mac);
+
 #endif /* IEEE80211SOFTMAC_PRIV_H_ */
index 2ffaebd21c53d8931819853735bd07ddc47b16a8..480d72c7a42ca861bb9524a631ea23be8a03feaf 100644 (file)
@@ -495,7 +495,8 @@ ieee80211softmac_wx_set_mlme(struct net_device *dev,
                        printk(KERN_DEBUG PFX "wx_set_mlme: we should know the net here...\n");
                        goto out;
                }
-               return ieee80211softmac_deauth_req(mac, net, reason);
+               err =  ieee80211softmac_deauth_req(mac, net, reason);
+               goto out;
        case IW_MLME_DISASSOC:
                ieee80211softmac_send_disassoc_req(mac, reason);
                mac->associnfo.associated = 0;
index 107bb6cbb0b370be0f8e10b0d434a432fbc3ebdd..648f47c1c399e262c86cfc22588ff257a5babcd5 100644 (file)
@@ -45,8 +45,8 @@
 
 #include "fib_lookup.h"
 
-static kmem_cache_t *fn_hash_kmem __read_mostly;
-static kmem_cache_t *fn_alias_kmem __read_mostly;
+static struct kmem_cache *fn_hash_kmem __read_mostly;
+static struct kmem_cache *fn_alias_kmem __read_mostly;
 
 struct fib_node {
        struct hlist_node       fn_hash;
@@ -485,13 +485,13 @@ static int fn_hash_insert(struct fib_table *tb, struct fib_config *cfg)
                goto out;
 
        err = -ENOBUFS;
-       new_fa = kmem_cache_alloc(fn_alias_kmem, SLAB_KERNEL);
+       new_fa = kmem_cache_alloc(fn_alias_kmem, GFP_KERNEL);
        if (new_fa == NULL)
                goto out;
 
        new_f = NULL;
        if (!f) {
-               new_f = kmem_cache_alloc(fn_hash_kmem, SLAB_KERNEL);
+               new_f = kmem_cache_alloc(fn_hash_kmem, GFP_KERNEL);
                if (new_f == NULL)
                        goto out_free_new_fa;
 
index d17990ec724f68d30fa6987e8c61fd7dc21fdd5d..cfb249cc0a5859c2fb06cf3877a978c9e066b14c 100644 (file)
@@ -172,7 +172,7 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn);
 static struct tnode *halve(struct trie *t, struct tnode *tn);
 static void tnode_free(struct tnode *tn);
 
-static kmem_cache_t *fn_alias_kmem __read_mostly;
+static struct kmem_cache *fn_alias_kmem __read_mostly;
 static struct trie *trie_local = NULL, *trie_main = NULL;
 
 
@@ -1187,7 +1187,7 @@ static int fn_trie_insert(struct fib_table *tb, struct fib_config *cfg)
                        u8 state;
 
                        err = -ENOBUFS;
-                       new_fa = kmem_cache_alloc(fn_alias_kmem, SLAB_KERNEL);
+                       new_fa = kmem_cache_alloc(fn_alias_kmem, GFP_KERNEL);
                        if (new_fa == NULL)
                                goto out;
 
@@ -1232,7 +1232,7 @@ static int fn_trie_insert(struct fib_table *tb, struct fib_config *cfg)
                goto out;
 
        err = -ENOBUFS;
-       new_fa = kmem_cache_alloc(fn_alias_kmem, SLAB_KERNEL);
+       new_fa = kmem_cache_alloc(fn_alias_kmem, GFP_KERNEL);
        if (new_fa == NULL)
                goto out;
 
index 244c4f445c7d55779a99fe301152c2241bbcacd7..8c79c8a4ea5c2e2daee5f9184d2401ddd60b3192 100644 (file)
  * Allocate and initialize a new local port bind bucket.
  * The bindhash mutex for snum's hash chain must be held here.
  */
-struct inet_bind_bucket *inet_bind_bucket_create(kmem_cache_t *cachep,
+struct inet_bind_bucket *inet_bind_bucket_create(struct kmem_cache *cachep,
                                                 struct inet_bind_hashbucket *head,
                                                 const unsigned short snum)
 {
-       struct inet_bind_bucket *tb = kmem_cache_alloc(cachep, SLAB_ATOMIC);
+       struct inet_bind_bucket *tb = kmem_cache_alloc(cachep, GFP_ATOMIC);
 
        if (tb != NULL) {
                tb->port      = snum;
@@ -45,7 +45,7 @@ struct inet_bind_bucket *inet_bind_bucket_create(kmem_cache_t *cachep,
 /*
  * Caller must hold hashbucket lock for this tb with local BH disabled
  */
-void inet_bind_bucket_destroy(kmem_cache_t *cachep, struct inet_bind_bucket *tb)
+void inet_bind_bucket_destroy(struct kmem_cache *cachep, struct inet_bind_bucket *tb)
 {
        if (hlist_empty(&tb->owners)) {
                __hlist_del(&tb->node);
index 8c74f9168b7d7fe4426bf30628f4e90bdba6cd59..9f414e35c488fe2c1464b1aae47363b17968fb5f 100644 (file)
@@ -91,7 +91,7 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, const int stat
 {
        struct inet_timewait_sock *tw =
                kmem_cache_alloc(sk->sk_prot_creator->twsk_prot->twsk_slab,
-                                SLAB_ATOMIC);
+                                GFP_ATOMIC);
        if (tw != NULL) {
                const struct inet_sock *inet = inet_sk(sk);
 
@@ -178,7 +178,6 @@ void inet_twdr_hangman(unsigned long data)
        need_timer = 0;
        if (inet_twdr_do_twkill_work(twdr, twdr->slot)) {
                twdr->thread_slots |= (1 << twdr->slot);
-               mb();
                schedule_work(&twdr->twkill_work);
                need_timer = 1;
        } else {
index f072f3875af8dfd5c6505787230cc578d8085c1c..711eb6d0285a8a4709a8e89a9c1b88697dcce7ee 100644 (file)
@@ -73,7 +73,7 @@
 /* Exported for inet_getid inline function.  */
 DEFINE_SPINLOCK(inet_peer_idlock);
 
-static kmem_cache_t *peer_cachep __read_mostly;
+static struct kmem_cache *peer_cachep __read_mostly;
 
 #define node_height(x) x->avl_height
 static struct inet_peer peer_fake_node = {
index a35209d517ad6d01186805dea7964113312c0666..f071f84808fa52781d1ac862bb1f8e9318d56d30 100644 (file)
@@ -164,7 +164,6 @@ EXPORT_SYMBOL_GPL(ip_build_and_send_pkt);
 static inline int ip_finish_output2(struct sk_buff *skb)
 {
        struct dst_entry *dst = skb->dst;
-       struct hh_cache *hh = dst->hh;
        struct net_device *dev = dst->dev;
        int hh_len = LL_RESERVED_SPACE(dev);
 
@@ -183,16 +182,9 @@ static inline int ip_finish_output2(struct sk_buff *skb)
                skb = skb2;
        }
 
-       if (hh) {
-               int hh_alen;
-
-               read_lock_bh(&hh->hh_lock);
-               hh_alen = HH_DATA_ALIGN(hh->hh_len);
-               memcpy(skb->data - hh_alen, hh->hh_data, hh_alen);
-               read_unlock_bh(&hh->hh_lock);
-               skb_push(skb, hh->hh_len);
-               return hh->hh_output(skb);
-       } else if (dst->neighbour)
+       if (dst->hh)
+               return neigh_hh_output(dst->hh, skb);
+       else if (dst->neighbour)
                return dst->neighbour->output(skb);
 
        if (net_ratelimit())
index efcf45ecc8188f6aff5b6d875172487bdb514d65..ecb5422ea237d0ad811a46fa924ecd01d66720d9 100644 (file)
@@ -105,7 +105,7 @@ static DEFINE_SPINLOCK(mfc_unres_lock);
    In this case data path is free of exclusive locks at all.
  */
 
-static kmem_cache_t *mrt_cachep __read_mostly;
+static struct kmem_cache *mrt_cachep __read_mostly;
 
 static int ip_mr_forward(struct sk_buff *skb, struct mfc_cache *cache, int local);
 static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert);
index 8832eb517d5200355356eb0281b4f4cc6be8cb61..8086787a2c51e5c0df7f4043ac8778af0a819edf 100644 (file)
@@ -44,7 +44,7 @@
 static struct list_head *ip_vs_conn_tab;
 
 /*  SLAB cache for IPVS connections */
-static kmem_cache_t *ip_vs_conn_cachep __read_mostly;
+static struct kmem_cache *ip_vs_conn_cachep __read_mostly;
 
 /*  counter for current IPVS connections */
 static atomic_t ip_vs_conn_count = ATOMIC_INIT(0);
index 413c2d0a1f3dee117db48289865279113f70e348..71b76ade00e13fa9dee0bd00ec05578e910825b5 100644 (file)
@@ -375,6 +375,13 @@ static int mark_source_chains(struct xt_table_info *newinfo,
                            && unconditional(&e->arp)) {
                                unsigned int oldpos, size;
 
+                               if (t->verdict < -NF_MAX_VERDICT - 1) {
+                                       duprintf("mark_source_chains: bad "
+                                               "negative verdict (%i)\n",
+                                                               t->verdict);
+                                       return 0;
+                               }
+
                                /* Return: backtrack through the last
                                 * big jump.
                                 */
@@ -404,6 +411,14 @@ static int mark_source_chains(struct xt_table_info *newinfo,
                                if (strcmp(t->target.u.user.name,
                                           ARPT_STANDARD_TARGET) == 0
                                    && newpos >= 0) {
+                                       if (newpos > newinfo->size -
+                                               sizeof(struct arpt_entry)) {
+                                               duprintf("mark_source_chains: "
+                                                       "bad verdict (%i)\n",
+                                                               newpos);
+                                               return 0;
+                                       }
+
                                        /* This a jump; chase it. */
                                        duprintf("Jump rule %u -> %u\n",
                                                 pos, newpos);
@@ -426,8 +441,6 @@ static int mark_source_chains(struct xt_table_info *newinfo,
 static inline int standard_check(const struct arpt_entry_target *t,
                                 unsigned int max_offset)
 {
-       struct arpt_standard_target *targ = (void *)t;
-
        /* Check standard info. */
        if (t->u.target_size
            != ARPT_ALIGN(sizeof(struct arpt_standard_target))) {
@@ -437,18 +450,6 @@ static inline int standard_check(const struct arpt_entry_target *t,
                return 0;
        }
 
-       if (targ->verdict >= 0
-           && targ->verdict > max_offset - sizeof(struct arpt_entry)) {
-               duprintf("arpt_standard_check: bad verdict (%i)\n",
-                        targ->verdict);
-               return 0;
-       }
-
-       if (targ->verdict < -NF_MAX_VERDICT - 1) {
-               duprintf("arpt_standard_check: bad negative verdict (%i)\n",
-                        targ->verdict);
-               return 0;
-       }
        return 1;
 }
 
@@ -627,18 +628,20 @@ static int translate_table(const char *name,
                }
        }
 
+       if (!mark_source_chains(newinfo, valid_hooks, entry0)) {
+               duprintf("Looping hook\n");
+               return -ELOOP;
+       }
+
        /* Finally, each sanity check must pass */
        i = 0;
        ret = ARPT_ENTRY_ITERATE(entry0, newinfo->size,
                                 check_entry, name, size, &i);
 
-       if (ret != 0)
-               goto cleanup;
-
-       ret = -ELOOP;
-       if (!mark_source_chains(newinfo, valid_hooks, entry0)) {
-               duprintf("Looping hook\n");
-               goto cleanup;
+       if (ret != 0) {
+               ARPT_ENTRY_ITERATE(entry0, newinfo->size,
+                               cleanup_entry, &i);
+               return ret;
        }
 
        /* And one copy for every other CPU */
@@ -647,9 +650,6 @@ static int translate_table(const char *name,
                        memcpy(newinfo->entries[i], entry0, newinfo->size);
        }
 
-       return 0;
-cleanup:
-       ARPT_ENTRY_ITERATE(entry0, newinfo->size, cleanup_entry, &i);
        return ret;
 }
 
index f4b0e68a16d20b1b6013a61ea10f5b66ab9cd78c..8556a4f4f60abde4adf99135e4c28967f4d2d96b 100644 (file)
@@ -65,8 +65,8 @@ static LIST_HEAD(helpers);
 unsigned int ip_conntrack_htable_size __read_mostly = 0;
 int ip_conntrack_max __read_mostly;
 struct list_head *ip_conntrack_hash __read_mostly;
-static kmem_cache_t *ip_conntrack_cachep __read_mostly;
-static kmem_cache_t *ip_conntrack_expect_cachep __read_mostly;
+static struct kmem_cache *ip_conntrack_cachep __read_mostly;
+static struct kmem_cache *ip_conntrack_expect_cachep __read_mostly;
 struct ip_conntrack ip_conntrack_untracked;
 unsigned int ip_ct_log_invalid __read_mostly;
 static LIST_HEAD(unconfirmed);
index 8a455439b128258de3e42926640834975579d5af..0ff2956d35e5ab876d531efd2fe274c276ad5208 100644 (file)
@@ -401,6 +401,13 @@ mark_source_chains(struct xt_table_info *newinfo,
                            && unconditional(&e->ip)) {
                                unsigned int oldpos, size;
 
+                               if (t->verdict < -NF_MAX_VERDICT - 1) {
+                                       duprintf("mark_source_chains: bad "
+                                               "negative verdict (%i)\n",
+                                                               t->verdict);
+                                       return 0;
+                               }
+
                                /* Return: backtrack through the last
                                   big jump. */
                                do {
@@ -438,6 +445,13 @@ mark_source_chains(struct xt_table_info *newinfo,
                                if (strcmp(t->target.u.user.name,
                                           IPT_STANDARD_TARGET) == 0
                                    && newpos >= 0) {
+                                       if (newpos > newinfo->size -
+                                               sizeof(struct ipt_entry)) {
+                                               duprintf("mark_source_chains: "
+                                                       "bad verdict (%i)\n",
+                                                               newpos);
+                                               return 0;
+                                       }
                                        /* This a jump; chase it. */
                                        duprintf("Jump rule %u -> %u\n",
                                                 pos, newpos);
@@ -469,27 +483,6 @@ cleanup_match(struct ipt_entry_match *m, unsigned int *i)
        return 0;
 }
 
-static inline int
-standard_check(const struct ipt_entry_target *t,
-              unsigned int max_offset)
-{
-       struct ipt_standard_target *targ = (void *)t;
-
-       /* Check standard info. */
-       if (targ->verdict >= 0
-           && targ->verdict > max_offset - sizeof(struct ipt_entry)) {
-               duprintf("ipt_standard_check: bad verdict (%i)\n",
-                        targ->verdict);
-               return 0;
-       }
-       if (targ->verdict < -NF_MAX_VERDICT - 1) {
-               duprintf("ipt_standard_check: bad negative verdict (%i)\n",
-                        targ->verdict);
-               return 0;
-       }
-       return 1;
-}
-
 static inline int
 check_match(struct ipt_entry_match *m,
            const char *name,
@@ -576,12 +569,7 @@ check_entry(struct ipt_entry *e, const char *name, unsigned int size,
        if (ret)
                goto err;
 
-       if (t->u.kernel.target == &ipt_standard_target) {
-               if (!standard_check(t, size)) {
-                       ret = -EINVAL;
-                       goto err;
-               }
-       } else if (t->u.kernel.target->checkentry
+       if (t->u.kernel.target->checkentry
                   && !t->u.kernel.target->checkentry(name, e, target, t->data,
                                                      e->comefrom)) {
                duprintf("ip_tables: check failed for `%s'.\n",
@@ -718,17 +706,19 @@ translate_table(const char *name,
                }
        }
 
+       if (!mark_source_chains(newinfo, valid_hooks, entry0))
+               return -ELOOP;
+
        /* Finally, each sanity check must pass */
        i = 0;
        ret = IPT_ENTRY_ITERATE(entry0, newinfo->size,
                                check_entry, name, size, &i);
 
-       if (ret != 0)
-               goto cleanup;
-
-       ret = -ELOOP;
-       if (!mark_source_chains(newinfo, valid_hooks, entry0))
-               goto cleanup;
+       if (ret != 0) {
+               IPT_ENTRY_ITERATE(entry0, newinfo->size,
+                               cleanup_entry, &i);
+               return ret;
+       }
 
        /* And one copy for every other CPU */
        for_each_possible_cpu(i) {
@@ -736,9 +726,6 @@ translate_table(const char *name,
                        memcpy(newinfo->entries[i], entry0, newinfo->size);
        }
 
-       return 0;
-cleanup:
-       IPT_ENTRY_ITERATE(entry0, newinfo->size, cleanup_entry, &i);
        return ret;
 }
 
@@ -1529,25 +1516,8 @@ static inline int compat_copy_match_from_user(struct ipt_entry_match *m,
        void **dstptr, compat_uint_t *size, const char *name,
        const struct ipt_ip *ip, unsigned int hookmask)
 {
-       struct ipt_entry_match *dm;
-       struct ipt_match *match;
-       int ret;
-
-       dm = (struct ipt_entry_match *)*dstptr;
-       match = m->u.kernel.match;
        xt_compat_match_from_user(m, dstptr, size);
-
-       ret = xt_check_match(match, AF_INET, dm->u.match_size - sizeof(*dm),
-                            name, hookmask, ip->proto,
-                            ip->invflags & IPT_INV_PROTO);
-       if (!ret && m->u.kernel.match->checkentry
-           && !m->u.kernel.match->checkentry(name, ip, match, dm->data,
-                                             hookmask)) {
-               duprintf("ip_tables: check failed for `%s'.\n",
-                        m->u.kernel.match->name);
-               ret = -EINVAL;
-       }
-       return ret;
+       return 0;
 }
 
 static int compat_copy_entry_from_user(struct ipt_entry *e, void **dstptr,
@@ -1569,7 +1539,7 @@ static int compat_copy_entry_from_user(struct ipt_entry *e, void **dstptr,
        ret = IPT_MATCH_ITERATE(e, compat_copy_match_from_user, dstptr, size,
                        name, &de->ip, de->comefrom);
        if (ret)
-               goto err;
+               return ret;
        de->target_offset = e->target_offset - (origsize - *size);
        t = ipt_get_target(e);
        target = t->u.kernel.target;
@@ -1582,31 +1552,62 @@ static int compat_copy_entry_from_user(struct ipt_entry *e, void **dstptr,
                if ((unsigned char *)de - base < newinfo->underflow[h])
                        newinfo->underflow[h] -= origsize - *size;
        }
+       return ret;
+}
+
+static inline int compat_check_match(struct ipt_entry_match *m, const char *name,
+                               const struct ipt_ip *ip, unsigned int hookmask)
+{
+       struct ipt_match *match;
+       int ret;
+
+       match = m->u.kernel.match;
+       ret = xt_check_match(match, AF_INET, m->u.match_size - sizeof(*m),
+                            name, hookmask, ip->proto,
+                            ip->invflags & IPT_INV_PROTO);
+       if (!ret && m->u.kernel.match->checkentry
+           && !m->u.kernel.match->checkentry(name, ip, match, m->data,
+                                             hookmask)) {
+               duprintf("ip_tables: compat: check failed for `%s'.\n",
+                        m->u.kernel.match->name);
+               ret = -EINVAL;
+       }
+       return ret;
+}
+
+static inline int compat_check_target(struct ipt_entry *e, const char *name)
+{
+       struct ipt_entry_target *t;
+       struct ipt_target *target;
+       int ret;
 
-       t = ipt_get_target(de);
+       t = ipt_get_target(e);
        target = t->u.kernel.target;
        ret = xt_check_target(target, AF_INET, t->u.target_size - sizeof(*t),
                              name, e->comefrom, e->ip.proto,
                              e->ip.invflags & IPT_INV_PROTO);
-       if (ret)
-               goto err;
-
-       ret = -EINVAL;
-       if (t->u.kernel.target == &ipt_standard_target) {
-               if (!standard_check(t, *size))
-                       goto err;
-       } else if (t->u.kernel.target->checkentry
-                  && !t->u.kernel.target->checkentry(name, de, target,
-                                                     t->data, de->comefrom)) {
+       if (!ret && t->u.kernel.target->checkentry
+                  && !t->u.kernel.target->checkentry(name, e, target,
+                                                     t->data, e->comefrom)) {
                duprintf("ip_tables: compat: check failed for `%s'.\n",
                         t->u.kernel.target->name);
-               goto err;
+               ret = -EINVAL;
        }
-       ret = 0;
-err:
        return ret;
 }
 
+static inline int compat_check_entry(struct ipt_entry *e, const char *name)
+{
+       int ret;
+
+       ret = IPT_MATCH_ITERATE(e, compat_check_match, name, &e->ip,
+                                                               e->comefrom);
+       if (ret)
+               return ret;
+
+       return compat_check_target(e, name);
+}
+
 static int
 translate_compat_table(const char *name,
                unsigned int valid_hooks,
@@ -1695,6 +1696,11 @@ translate_compat_table(const char *name,
        if (!mark_source_chains(newinfo, valid_hooks, entry1))
                goto free_newinfo;
 
+       ret = IPT_ENTRY_ITERATE(entry1, newinfo->size, compat_check_entry,
+                                                                       name);
+       if (ret)
+               goto free_newinfo;
+
        /* And one copy for every other CPU */
        for_each_possible_cpu(i)
                if (newinfo->entries[i] && newinfo->entries[i] != entry1)
index 0983650622347bf2a6af923c9791a1ed575be5c5..fef56ae61abe5a2a496fab407d1a9614fd24712e 100644 (file)
@@ -683,7 +683,7 @@ static ssize_t clusterip_proc_write(struct file *file, const char __user *input,
 {
 #define PROC_WRITELEN  10
        char buffer[PROC_WRITELEN+1];
-       struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
        struct clusterip_config *c = pde->data;
        unsigned long nodenum;
 
index 126db44e71a8eaa3fd91fa5ba36f8bbd27db46fe..4db0e73c56f1956fb8c5929301af040a188a3b64 100644 (file)
@@ -401,7 +401,7 @@ static int recent_seq_open(struct inode *inode, struct file *file)
 static ssize_t recent_proc_write(struct file *file, const char __user *input,
                                 size_t size, loff_t *loff)
 {
-       struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
        struct recent_table *t = pde->data;
        struct recent_entry *e;
        char buf[sizeof("+255.255.255.255")], *c = buf;
index 9f3924c4905e213fcd2c9dcf23f011eadbb00e92..11c167118e87fa87ecfd7898a6190c06fd24d7a0 100644 (file)
@@ -1780,7 +1780,7 @@ static inline int __mkroute_input(struct sk_buff *skb,
 #endif
        if (in_dev->cnf.no_policy)
                rth->u.dst.flags |= DST_NOPOLICY;
-       if (in_dev->cnf.no_xfrm)
+       if (out_dev->cnf.no_xfrm)
                rth->u.dst.flags |= DST_NOXFRM;
        rth->fl.fl4_dst = daddr;
        rth->rt_dst     = daddr;
index 9304034c0c471cf376fb13e5fe41754ea707c2be..c701f6abbfc14a3ab05ba52c7469dc8cb5875df8 100644 (file)
@@ -4235,7 +4235,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
                 * Change state from SYN-SENT only after copied_seq
                 * is initialized. */
                tp->copied_seq = tp->rcv_nxt;
-               mb();
+               smp_mb();
                tcp_set_state(sk, TCP_ESTABLISHED);
 
                security_inet_conn_established(sk, skb);
@@ -4483,7 +4483,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
                case TCP_SYN_RECV:
                        if (acceptable) {
                                tp->copied_seq = tp->rcv_nxt;
-                               mb();
+                               smp_mb();
                                tcp_set_state(sk, TCP_ESTABLISHED);
                                sk->sk_state_change(sk);
 
index d4107bb701b58ba4492c68b51d902fb6e286b05a..fb9f69c616f5c3dbf43af6db14a8178aba46419b 100644 (file)
@@ -274,6 +274,8 @@ static void xfrm4_dst_destroy(struct dst_entry *dst)
 
        if (likely(xdst->u.rt.idev))
                in_dev_put(xdst->u.rt.idev);
+       if (likely(xdst->u.rt.peer))
+               inet_putpeer(xdst->u.rt.peer);
        xfrm_dst_destroy(xdst);
 }
 
index 87c8f54872b77fc0d3f187ca32cb1989569d6513..e5cd83b2205d41e9a2689224b12d4d8dbfaec2e9 100644 (file)
@@ -720,10 +720,8 @@ snmp6_mib_free(void *ptr[2])
 {
        if (ptr == NULL)
                return;
-       if (ptr[0])
-               free_percpu(ptr[0]);
-       if (ptr[1])
-               free_percpu(ptr[1]);
+       free_percpu(ptr[0]);
+       free_percpu(ptr[1]);
        ptr[0] = ptr[1] = NULL;
 }
 
index bf526115e5186ec00c88c81c517bf78dac35a831..96d8310ae9c822ed99f39899b49838e3318f56e0 100644 (file)
@@ -50,7 +50,7 @@
 
 struct rt6_statistics  rt6_stats;
 
-static kmem_cache_t * fib6_node_kmem __read_mostly;
+static struct kmem_cache * fib6_node_kmem __read_mostly;
 
 enum fib_walk_state_t
 {
@@ -150,7 +150,7 @@ static __inline__ struct fib6_node * node_alloc(void)
 {
        struct fib6_node *fn;
 
-       if ((fn = kmem_cache_alloc(fib6_node_kmem, SLAB_ATOMIC)) != NULL)
+       if ((fn = kmem_cache_alloc(fib6_node_kmem, GFP_ATOMIC)) != NULL)
                memset(fn, 0, sizeof(struct fib6_node));
 
        return fn;
index e05ecbb1412ddaa91777333cf358217eb3e08be7..7b7bd44fbf47f3a4b66af6a5bfef62ee8bff4d99 100644 (file)
@@ -72,20 +72,11 @@ static __inline__ void ipv6_select_ident(struct sk_buff *skb, struct frag_hdr *f
 
 static inline int ip6_output_finish(struct sk_buff *skb)
 {
-
        struct dst_entry *dst = skb->dst;
-       struct hh_cache *hh = dst->hh;
-
-       if (hh) {
-               int hh_alen;
-
-               read_lock_bh(&hh->hh_lock);
-               hh_alen = HH_DATA_ALIGN(hh->hh_len);
-               memcpy(skb->data - hh_alen, hh->hh_data, hh_alen);
-               read_unlock_bh(&hh->hh_lock);
-               skb_push(skb, hh->hh_len);
-               return hh->hh_output(skb);
-       } else if (dst->neighbour)
+
+       if (dst->hh)
+               return neigh_hh_output(dst->hh, skb);
+       else if (dst->neighbour)
                return dst->neighbour->output(skb);
 
        IP6_INC_STATS_BH(ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES);
@@ -624,13 +615,13 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
                skb_shinfo(skb)->frag_list = NULL;
                /* BUILD HEADER */
 
+               *prevhdr = NEXTHDR_FRAGMENT;
                tmp_hdr = kmemdup(skb->nh.raw, hlen, GFP_ATOMIC);
                if (!tmp_hdr) {
                        IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_FRAGFAILS);
                        return -ENOMEM;
                }
 
-               *prevhdr = NEXTHDR_FRAGMENT;
                __skb_pull(skb, hlen);
                fh = (struct frag_hdr*)__skb_push(skb, sizeof(struct frag_hdr));
                skb->nh.raw = __skb_push(skb, hlen);
index f63fb86d7c7b56732a108bcf1cfeae6b9f81472b..4eec4b3988b824af9b763cb615d4e2ee148d9127 100644 (file)
@@ -440,6 +440,13 @@ mark_source_chains(struct xt_table_info *newinfo,
                            && unconditional(&e->ipv6)) {
                                unsigned int oldpos, size;
 
+                               if (t->verdict < -NF_MAX_VERDICT - 1) {
+                                       duprintf("mark_source_chains: bad "
+                                               "negative verdict (%i)\n",
+                                                               t->verdict);
+                                       return 0;
+                               }
+
                                /* Return: backtrack through the last
                                   big jump. */
                                do {
@@ -477,6 +484,13 @@ mark_source_chains(struct xt_table_info *newinfo,
                                if (strcmp(t->target.u.user.name,
                                           IP6T_STANDARD_TARGET) == 0
                                    && newpos >= 0) {
+                                       if (newpos > newinfo->size -
+                                               sizeof(struct ip6t_entry)) {
+                                               duprintf("mark_source_chains: "
+                                                       "bad verdict (%i)\n",
+                                                               newpos);
+                                               return 0;
+                                       }
                                        /* This a jump; chase it. */
                                        duprintf("Jump rule %u -> %u\n",
                                                 pos, newpos);
@@ -508,27 +522,6 @@ cleanup_match(struct ip6t_entry_match *m, unsigned int *i)
        return 0;
 }
 
-static inline int
-standard_check(const struct ip6t_entry_target *t,
-              unsigned int max_offset)
-{
-       struct ip6t_standard_target *targ = (void *)t;
-
-       /* Check standard info. */
-       if (targ->verdict >= 0
-           && targ->verdict > max_offset - sizeof(struct ip6t_entry)) {
-               duprintf("ip6t_standard_check: bad verdict (%i)\n",
-                        targ->verdict);
-               return 0;
-       }
-       if (targ->verdict < -NF_MAX_VERDICT - 1) {
-               duprintf("ip6t_standard_check: bad negative verdict (%i)\n",
-                        targ->verdict);
-               return 0;
-       }
-       return 1;
-}
-
 static inline int
 check_match(struct ip6t_entry_match *m,
            const char *name,
@@ -616,12 +609,7 @@ check_entry(struct ip6t_entry *e, const char *name, unsigned int size,
        if (ret)
                goto err;
 
-       if (t->u.kernel.target == &ip6t_standard_target) {
-               if (!standard_check(t, size)) {
-                       ret = -EINVAL;
-                       goto err;
-               }
-       } else if (t->u.kernel.target->checkentry
+       if (t->u.kernel.target->checkentry
                   && !t->u.kernel.target->checkentry(name, e, target, t->data,
                                                      e->comefrom)) {
                duprintf("ip_tables: check failed for `%s'.\n",
@@ -758,17 +746,19 @@ translate_table(const char *name,
                }
        }
 
+       if (!mark_source_chains(newinfo, valid_hooks, entry0))
+               return -ELOOP;
+
        /* Finally, each sanity check must pass */
        i = 0;
        ret = IP6T_ENTRY_ITERATE(entry0, newinfo->size,
                                check_entry, name, size, &i);
 
-       if (ret != 0)
-               goto cleanup;
-
-       ret = -ELOOP;
-       if (!mark_source_chains(newinfo, valid_hooks, entry0))
-               goto cleanup;
+       if (ret != 0) {
+               IP6T_ENTRY_ITERATE(entry0, newinfo->size,
+                                  cleanup_entry, &i);
+               return ret;
+       }
 
        /* And one copy for every other CPU */
        for_each_possible_cpu(i) {
@@ -777,9 +767,6 @@ translate_table(const char *name,
        }
 
        return 0;
-cleanup:
-       IP6T_ENTRY_ITERATE(entry0, newinfo->size, cleanup_entry, &i);
-       return ret;
 }
 
 /* Gets counters. */
index c2e629d6aea40e5519c3b865d62e1a092e6c9b60..4ae1b19ada5d3eb9e3c3c7f0b1b7a8030002eacb 100644 (file)
@@ -854,7 +854,8 @@ back_from_confirm:
        }
 done:
        dst_release(dst);
-       release_sock(sk);
+       if (!inet->hdrincl)
+               release_sock(sk);
 out:   
        fl6_sock_release(flowlabel);
        return err<0?err:len;
index 01a5c52a2be324748d0e037e78d5bb7e226f3a90..12e426b9aacd19d2b03e3d35bfc230dcd3c42897 100644 (file)
@@ -50,7 +50,7 @@ static u32 xfrm6_tunnel_spi;
 #define XFRM6_TUNNEL_SPI_MIN   1
 #define XFRM6_TUNNEL_SPI_MAX   0xffffffff
 
-static kmem_cache_t *xfrm6_tunnel_spi_kmem __read_mostly;
+static struct kmem_cache *xfrm6_tunnel_spi_kmem __read_mostly;
 
 #define XFRM6_TUNNEL_SPI_BYADDR_HSIZE 256
 #define XFRM6_TUNNEL_SPI_BYSPI_HSIZE 256
@@ -180,7 +180,7 @@ try_next_2:;
        spi = 0;
        goto out;
 alloc_spi:
-       x6spi = kmem_cache_alloc(xfrm6_tunnel_spi_kmem, SLAB_ATOMIC);
+       x6spi = kmem_cache_alloc(xfrm6_tunnel_spi_kmem, GFP_ATOMIC);
        if (!x6spi)
                goto out;
 
index 197e3e7ed7e2d3aa2b7cbd39034d0744faf9c768..75e39ea599d81147fca02e540eb03f77e3f329d0 100644 (file)
@@ -146,7 +146,7 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self)
  *    do something rational.
  */
 void ircomm_tty_set_termios(struct tty_struct *tty, 
-                           struct termios *old_termios)
+                           struct ktermios *old_termios)
 {
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
        unsigned int cflag = tty->termios->c_cflag;
index 252f11012566ca1758851ef9489785ca8fe95ce7..03504f3e4990cb82bb8592845d79c7525d172b09 100644 (file)
@@ -1100,7 +1100,7 @@ int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
                        return -ENOMEM;
 
                /* Reserve space for MUX_CONTROL and LAP header */
-               skb_reserve(tx_skb, TTP_MAX_HEADER);
+               skb_reserve(tx_skb, TTP_MAX_HEADER + TTP_SAR_HEADER);
        } else {
                tx_skb = userdata;
                /*
@@ -1349,7 +1349,7 @@ int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
                        return -ENOMEM;
 
                /* Reserve space for MUX_CONTROL and LAP header */
-               skb_reserve(tx_skb, TTP_MAX_HEADER);
+               skb_reserve(tx_skb, TTP_MAX_HEADER + TTP_SAR_HEADER);
        } else {
                tx_skb = userdata;
                /*
index 0e1dbfbb9b109ae6e2be92bbac0a592ec4a2ecb0..5dd5094659a186655d88a50a44ba2849a44bc776 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/proc_fs.h>
 #include <linux/init.h>
 #include <net/xfrm.h>
+#include <linux/audit.h>
 
 #include <net/sock.h>
 
@@ -1420,6 +1421,9 @@ static int pfkey_add(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr,
        else
                err = xfrm_state_update(x);
 
+       xfrm_audit_log(audit_get_loginuid(current->audit_context), 0,
+                      AUDIT_MAC_IPSEC_ADDSA, err ? 0 : 1, NULL, x);
+
        if (err < 0) {
                x->km.state = XFRM_STATE_DEAD;
                __xfrm_state_put(x);
@@ -1460,8 +1464,12 @@ static int pfkey_delete(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
                err = -EPERM;
                goto out;
        }
-       
+
        err = xfrm_state_delete(x);
+
+       xfrm_audit_log(audit_get_loginuid(current->audit_context), 0,
+                      AUDIT_MAC_IPSEC_DELSA, err ? 0 : 1, NULL, x);
+
        if (err < 0)
                goto out;
 
@@ -1637,12 +1645,15 @@ static int pfkey_flush(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hd
 {
        unsigned proto;
        struct km_event c;
+       struct xfrm_audit audit_info;
 
        proto = pfkey_satype2proto(hdr->sadb_msg_satype);
        if (proto == 0)
                return -EINVAL;
 
-       xfrm_state_flush(proto);
+       audit_info.loginuid = audit_get_loginuid(current->audit_context);
+       audit_info.secid = 0;
+       xfrm_state_flush(proto, &audit_info);
        c.data.proto = proto;
        c.seq = hdr->sadb_msg_seq;
        c.pid = hdr->sadb_msg_pid;
@@ -2205,6 +2216,9 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
        err = xfrm_policy_insert(pol->sadb_x_policy_dir-1, xp,
                                 hdr->sadb_msg_type != SADB_X_SPDUPDATE);
 
+       xfrm_audit_log(audit_get_loginuid(current->audit_context), 0,
+                      AUDIT_MAC_IPSEC_ADDSPD, err ? 0 : 1, xp, NULL);
+
        if (err)
                goto out;
 
@@ -2282,6 +2296,10 @@ static int pfkey_spddelete(struct sock *sk, struct sk_buff *skb, struct sadb_msg
        xp = xfrm_policy_bysel_ctx(XFRM_POLICY_TYPE_MAIN, pol->sadb_x_policy_dir-1,
                                   &sel, tmp.security, 1);
        security_xfrm_policy_free(&tmp);
+
+       xfrm_audit_log(audit_get_loginuid(current->audit_context), 0,
+                      AUDIT_MAC_IPSEC_DELSPD, (xp) ? 1 : 0, xp, NULL);
+
        if (xp == NULL)
                return -ENOENT;
 
@@ -2416,8 +2434,11 @@ static int key_notify_policy_flush(struct km_event *c)
 static int pfkey_spdflush(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr, void **ext_hdrs)
 {
        struct km_event c;
+       struct xfrm_audit audit_info;
 
-       xfrm_policy_flush(XFRM_POLICY_TYPE_MAIN);
+       audit_info.loginuid = audit_get_loginuid(current->audit_context);
+       audit_info.secid = 0;
+       xfrm_policy_flush(XFRM_POLICY_TYPE_MAIN, &audit_info);
        c.data.type = XFRM_POLICY_TYPE_MAIN;
        c.event = XFRM_MSG_FLUSHPOLICY;
        c.pid = hdr->sadb_msg_pid;
index eaa0f8a1adb61422629284ea0d156fe32597b364..9b02ec4012fb3f4ab515d089cd4f3b1b14a20808 100644 (file)
@@ -108,7 +108,7 @@ static struct {
        size_t size;
 
        /* slab cache pointer */
-       kmem_cache_t *cachep;
+       struct kmem_cache *cachep;
 
        /* allocated slab cache + modules which uses this slab cache */
        int use;
@@ -147,7 +147,7 @@ int nf_conntrack_register_cache(u_int32_t features, const char *name,
 {
        int ret = 0;
        char *cache_name;
-       kmem_cache_t *cachep;
+       struct kmem_cache *cachep;
 
        DEBUGP("nf_conntrack_register_cache: features=0x%x, name=%s, size=%d\n",
               features, name, size);
@@ -226,7 +226,7 @@ EXPORT_SYMBOL_GPL(nf_conntrack_register_cache);
 /* FIXME: In the current, only nf_conntrack_cleanup() can call this function. */
 void nf_conntrack_unregister_cache(u_int32_t features)
 {
-       kmem_cache_t *cachep;
+       struct kmem_cache *cachep;
        char *name;
 
        /*
@@ -1093,7 +1093,7 @@ static void free_conntrack_hash(struct list_head *hash, int vmalloced, int size)
                           get_order(sizeof(struct list_head) * size));
 }
 
-void nf_conntrack_flush()
+void nf_conntrack_flush(void)
 {
        nf_ct_iterate_cleanup(kill_all, NULL);
 }
index 588d379370466f0f71cffb23acf8363c2f6795f1..9cbf926cdd14fb0d6af92917339e1cd1d3f23b23 100644 (file)
@@ -29,7 +29,7 @@
 LIST_HEAD(nf_conntrack_expect_list);
 EXPORT_SYMBOL_GPL(nf_conntrack_expect_list);
 
-kmem_cache_t *nf_conntrack_expect_cachep __read_mostly;
+struct kmem_cache *nf_conntrack_expect_cachep __read_mostly;
 static unsigned int nf_conntrack_expect_next_id;
 
 /* nf_conntrack_expect helper functions */
@@ -91,25 +91,28 @@ EXPORT_SYMBOL_GPL(nf_conntrack_expect_find_get);
 struct nf_conntrack_expect *
 find_expectation(const struct nf_conntrack_tuple *tuple)
 {
-       struct nf_conntrack_expect *i;
+       struct nf_conntrack_expect *exp;
+
+       exp = __nf_conntrack_expect_find(tuple);
+       if (!exp)
+               return NULL;
 
-       list_for_each_entry(i, &nf_conntrack_expect_list, list) {
        /* If master is not in hash table yet (ie. packet hasn't left
           this machine yet), how can other end know about expected?
           Hence these are not the droids you are looking for (if
           master ct never got confirmed, we'd hold a reference to it
           and weird things would happen to future packets). */
-               if (nf_ct_tuple_mask_cmp(tuple, &i->tuple, &i->mask)
-                   && nf_ct_is_confirmed(i->master)) {
-                       if (i->flags & NF_CT_EXPECT_PERMANENT) {
-                               atomic_inc(&i->use);
-                               return i;
-                       } else if (del_timer(&i->timeout)) {
-                               nf_ct_unlink_expect(i);
-                               return i;
-                       }
-               }
+       if (!nf_ct_is_confirmed(exp->master))
+               return NULL;
+
+       if (exp->flags & NF_CT_EXPECT_PERMANENT) {
+               atomic_inc(&exp->use);
+               return exp;
+       } else if (del_timer(&exp->timeout)) {
+               nf_ct_unlink_expect(exp);
+               return exp;
        }
+
        return NULL;
 }
 
index a98de0b54d6514accd49dd7b23c13a027fb17aa4..a5a6e192ac2d07ae5fe188b81777b75e645f01cc 100644 (file)
@@ -92,7 +92,7 @@ struct xt_hashlimit_htable {
 static DEFINE_SPINLOCK(hashlimit_lock);        /* protects htables list */
 static DEFINE_MUTEX(hlimit_mutex);     /* additional checkentry protection */
 static HLIST_HEAD(hashlimit_htables);
-static kmem_cache_t *hashlimit_cachep __read_mostly;
+static struct kmem_cache *hashlimit_cachep __read_mostly;
 
 static inline int dst_cmp(const struct dsthash_ent *ent, struct dsthash_dst *b)
 {
index 3baafb10f8f39e23b049a299bbf0cef29cecafb5..276131fe56dddb140afcfaf15e46bd6ead0263fa 100644 (file)
@@ -699,7 +699,7 @@ static struct sock *netlink_getsockbypid(struct sock *ssk, u32 pid)
 
 struct sock *netlink_getsockbyfilp(struct file *filp)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct sock *sock;
 
        if (!S_ISSOCK(inode->i_mode))
index b9b03747c1f39e5882c702e0cdde95c6a61dcfbd..548e4e6e698f041f3802a28339b4ed69ba971b7c 100644 (file)
@@ -143,6 +143,13 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
                goto errout;
        }
 
+       if (ops->dumpit)
+               ops->flags |= GENL_CMD_CAP_DUMP;
+       if (ops->doit)
+               ops->flags |= GENL_CMD_CAP_DO;
+       if (ops->policy)
+               ops->flags |= GENL_CMD_CAP_HASPOL;
+
        genl_lock();
        list_add_tail(&ops->ops_list, &family->ops_list);
        genl_unlock();
@@ -387,7 +394,7 @@ static void genl_rcv(struct sock *sk, int len)
 static struct genl_family genl_ctrl = {
        .id = GENL_ID_CTRL,
        .name = "nlctrl",
-       .version = 0x1,
+       .version = 0x2,
        .maxattr = CTRL_ATTR_MAX,
 };
 
@@ -425,15 +432,6 @@ static int ctrl_fill_info(struct genl_family *family, u32 pid, u32 seq,
                        NLA_PUT_U32(skb, CTRL_ATTR_OP_ID, ops->cmd);
                        NLA_PUT_U32(skb, CTRL_ATTR_OP_FLAGS, ops->flags);
 
-                       if (ops->policy)
-                               NLA_PUT_FLAG(skb, CTRL_ATTR_OP_POLICY);
-
-                       if (ops->doit)
-                               NLA_PUT_FLAG(skb, CTRL_ATTR_OP_DOIT);
-
-                       if (ops->dumpit)
-                               NLA_PUT_FLAG(skb, CTRL_ATTR_OP_DUMPIT);
-
                        nla_nest_end(skb, nest);
                }
 
index 08e68b67bbf642cedac2b537b79028c7f157bfaa..da73e8a8c18de58377376237907b32cf3baee35e 100644 (file)
@@ -660,7 +660,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
        sll->sll_ifindex = dev->ifindex;
 
        h->tp_status = status;
-       mb();
+       smp_mb();
 
        {
                struct page *p_start, *p_end;
index dada34a77b2194ab9750d2cdc518032f0fa413df..49effd92144e2908ea95ce6ecdff1fb4be7a6940 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/completion.h>
 #include <linux/spinlock.h>
 #include <linux/init.h>
+#include <linux/freezer.h>
 #include <rxrpc/krxiod.h>
 #include <rxrpc/transport.h>
 #include <rxrpc/peer.h>
index cea4eb5e2497a7c6e89234ef0a7e60c8bc863130..3ab0f77409f49c79de6c65dc361962bf14be1c94 100644 (file)
@@ -27,6 +27,7 @@
 #include <rxrpc/call.h>
 #include <linux/udp.h>
 #include <linux/ip.h>
+#include <linux/freezer.h>
 #include <net/sock.h>
 #include "internal.h"
 
index 3e7466900bd4e1260728ed63759d60794a88c69e..9a9b6132dba4840755e84a17e286a0b9da161996 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/completion.h>
+#include <linux/freezer.h>
 #include <rxrpc/rxrpc.h>
 #include <rxrpc/krxtimod.h>
 #include <asm/errno.h>
index f59a2c4aa039b463e6c4c7d4fc867ce6da8a7dcb..c797d6ada7de06948ef1fab1e225a224ffdc057d 100644 (file)
@@ -101,9 +101,10 @@ static int fw_classify(struct sk_buff *skb, struct tcf_proto *tp,
        struct fw_head *head = (struct fw_head*)tp->root;
        struct fw_filter *f;
        int r;
-       u32 id = skb->mark & head->mask;
+       u32 id = skb->mark;
 
        if (head != NULL) {
+               id &= head->mask;
                for (f=head->ht[fw_hash(id)]; f; f=f->next) {
                        if (f->id == id) {
                                *res = f->res;
index ba82dfab6043d7379094ec0771d1bbdfcbb470f3..f79a4f3d0a9584db88107acd901347c96a110087 100644 (file)
@@ -371,8 +371,6 @@ static void cbq_deactivate_class(struct cbq_class *this)
                                        return;
                                }
                        }
-
-                       cl = cl_prev->next_alive;
                        return;
                }
        } while ((cl_prev = cl) != q->active[prio]);
@@ -1258,6 +1256,8 @@ static unsigned int cbq_drop(struct Qdisc* sch)
                do {
                        if (cl->q->ops->drop && (len = cl->q->ops->drop(cl->q))) {
                                sch->q.qlen--;
+                               if (!cl->q->q.qlen)
+                                       cbq_deactivate_class(cl);
                                return len;
                        }
                } while ((cl = cl->next_alive) != cl_head);
@@ -1685,8 +1685,7 @@ static int cbq_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
 #endif
                }
                sch_tree_lock(sch);
-               *old = cl->q;
-               cl->q = new;
+               *old = xchg(&cl->q, new);
                qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
                qdisc_reset(*old);
                sch_tree_unlock(sch);
@@ -1704,6 +1703,14 @@ cbq_leaf(struct Qdisc *sch, unsigned long arg)
        return cl ? cl->q : NULL;
 }
 
+static void cbq_qlen_notify(struct Qdisc *sch, unsigned long arg)
+{
+       struct cbq_class *cl = (struct cbq_class *)arg;
+
+       if (cl->q->q.qlen == 0)
+               cbq_deactivate_class(cl);
+}
+
 static unsigned long cbq_get(struct Qdisc *sch, u32 classid)
 {
        struct cbq_sched_data *q = qdisc_priv(sch);
@@ -1988,12 +1995,17 @@ static int cbq_delete(struct Qdisc *sch, unsigned long arg)
 {
        struct cbq_sched_data *q = qdisc_priv(sch);
        struct cbq_class *cl = (struct cbq_class*)arg;
+       unsigned int qlen;
 
        if (cl->filters || cl->children || cl == &q->link)
                return -EBUSY;
 
        sch_tree_lock(sch);
 
+       qlen = cl->q->q.qlen;
+       qdisc_reset(cl->q);
+       qdisc_tree_decrease_qlen(cl->q, qlen);
+
        if (cl->next_alive)
                cbq_deactivate_class(cl);
 
@@ -2084,6 +2096,7 @@ static void cbq_walk(struct Qdisc *sch, struct qdisc_walker *arg)
 static struct Qdisc_class_ops cbq_class_ops = {
        .graft          =       cbq_graft,
        .leaf           =       cbq_leaf,
+       .qlen_notify    =       cbq_qlen_notify,
        .get            =       cbq_get,
        .put            =       cbq_put,
        .change         =       cbq_change_class,
index 215e68c2b615f1f55edb544a1dbb6a47d99928a6..15f23c5511a869d24927881868bc8a42cf581f5a 100644 (file)
@@ -147,6 +147,10 @@ struct htb_class {
        psched_tdiff_t mbuffer; /* max wait time */
        long tokens, ctokens;   /* current number of tokens */
        psched_time_t t_c;      /* checkpoint time */
+
+       int prio;               /* For parent to leaf return possible here */
+       int quantum;            /* we do backup. Finally full replacement  */
+                               /* of un.leaf originals should be done. */
 };
 
 /* TODO: maybe compute rate when size is too large .. or drop ? */
@@ -1271,6 +1275,38 @@ static void htb_destroy_filters(struct tcf_proto **fl)
        }
 }
 
+static inline int htb_parent_last_child(struct htb_class *cl)
+{
+       if (!cl->parent)
+               /* the root class */
+               return 0;
+
+       if (!(cl->parent->children.next == &cl->sibling &&
+               cl->parent->children.prev == &cl->sibling))
+               /* not the last child */
+               return 0;
+
+       return 1;
+}
+
+static void htb_parent_to_leaf(struct htb_class *cl, struct Qdisc *new_q)
+{
+       struct htb_class *parent = cl->parent;
+
+       BUG_TRAP(!cl->level && cl->un.leaf.q && !cl->prio_activity);
+
+       parent->level = 0;
+       memset(&parent->un.inner, 0, sizeof(parent->un.inner));
+       INIT_LIST_HEAD(&parent->un.leaf.drop_list);
+       parent->un.leaf.q = new_q ? new_q : &noop_qdisc;
+       parent->un.leaf.quantum = parent->quantum;
+       parent->un.leaf.prio = parent->prio;
+       parent->tokens = parent->buffer;
+       parent->ctokens = parent->cbuffer;
+       PSCHED_GET_TIME(parent->t_c);
+       parent->cmode = HTB_CAN_SEND;
+}
+
 static void htb_destroy_class(struct Qdisc *sch, struct htb_class *cl)
 {
        struct htb_sched *q = qdisc_priv(sch);
@@ -1328,6 +1364,8 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg)
        struct htb_sched *q = qdisc_priv(sch);
        struct htb_class *cl = (struct htb_class *)arg;
        unsigned int qlen;
+       struct Qdisc *new_q = NULL;
+       int last_child = 0;
 
        // TODO: why don't allow to delete subtree ? references ? does
        // tc subsys quarantee us that in htb_destroy it holds no class
@@ -1335,6 +1373,12 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg)
        if (!list_empty(&cl->children) || cl->filter_cnt)
                return -EBUSY;
 
+       if (!cl->level && htb_parent_last_child(cl)) {
+               new_q = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops,
+                                               cl->parent->classid);
+               last_child = 1;
+       }
+
        sch_tree_lock(sch);
 
        /* delete from hash and active; remainder in destroy_class */
@@ -1349,6 +1393,9 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg)
        if (cl->prio_activity)
                htb_deactivate(q, cl);
 
+       if (last_child)
+               htb_parent_to_leaf(cl, new_q);
+
        if (--cl->refcnt == 0)
                htb_destroy_class(sch, cl);
 
@@ -1483,6 +1530,10 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
                        cl->un.leaf.quantum = hopt->quantum;
                if ((cl->un.leaf.prio = hopt->prio) >= TC_HTB_NUMPRIO)
                        cl->un.leaf.prio = TC_HTB_NUMPRIO - 1;
+
+               /* backup for htb_parent_to_leaf */
+               cl->quantum = cl->un.leaf.quantum;
+               cl->prio = cl->un.leaf.prio;
        }
 
        cl->buffer = hopt->buffer;
index 11f3b549f4a4ef893f4cf2c05a93f782b5f5446b..f2ba8615895b4551ced90fab4f101774492bf351 100644 (file)
@@ -79,8 +79,8 @@ static struct sctp_pf *sctp_pf_inet_specific;
 static struct sctp_af *sctp_af_v4_specific;
 static struct sctp_af *sctp_af_v6_specific;
 
-kmem_cache_t *sctp_chunk_cachep __read_mostly;
-kmem_cache_t *sctp_bucket_cachep __read_mostly;
+struct kmem_cache *sctp_chunk_cachep __read_mostly;
+struct kmem_cache *sctp_bucket_cachep __read_mostly;
 
 /* Return the address of the control sock. */
 struct sock *sctp_get_ctl_sock(void)
index 04954e5f6846c2d16763ce1c0bcf2e6900957df7..30927d3a597f891e6c4a7dc852fa1b7a9802248a 100644 (file)
@@ -65,7 +65,7 @@
 #include <net/sctp/sctp.h>
 #include <net/sctp/sm.h>
 
-extern kmem_cache_t *sctp_chunk_cachep;
+extern struct kmem_cache *sctp_chunk_cachep;
 
 SCTP_STATIC
 struct sctp_chunk *sctp_make_chunk(const struct sctp_association *asoc,
@@ -979,7 +979,7 @@ struct sctp_chunk *sctp_chunkify(struct sk_buff *skb,
 {
        struct sctp_chunk *retval;
 
-       retval = kmem_cache_alloc(sctp_chunk_cachep, SLAB_ATOMIC);
+       retval = kmem_cache_alloc(sctp_chunk_cachep, GFP_ATOMIC);
 
        if (!retval)
                goto nodata;
index 02b27145b279420891ed29393ea92b62f56aa3b9..1e8132b8c4d98e71f3d4c7a1c48bea3b8f6ae7d4 100644 (file)
@@ -107,7 +107,7 @@ static void sctp_sock_migrate(struct sock *, struct sock *,
                              struct sctp_association *, sctp_socket_type_t);
 static char *sctp_hmac_alg = SCTP_COOKIE_HMAC_ALG;
 
-extern kmem_cache_t *sctp_bucket_cachep;
+extern struct kmem_cache *sctp_bucket_cachep;
 
 /* Get the sndbuf space available at the time on the association.  */
 static inline int sctp_wspace(struct sctp_association *asoc)
@@ -4989,7 +4989,7 @@ static struct sctp_bind_bucket *sctp_bucket_create(
 {
        struct sctp_bind_bucket *pp;
 
-       pp = kmem_cache_alloc(sctp_bucket_cachep, SLAB_ATOMIC);
+       pp = kmem_cache_alloc(sctp_bucket_cachep, GFP_ATOMIC);
        SCTP_DBG_OBJCNT_INC(bind_bucket);
        if (pp) {
                pp->port = snum;
index e8db54702a6913c98f5354bcf11c75b5d1dbb466..4e396312f8d58751d0c23914a056126e79ff72ac 100644 (file)
@@ -230,13 +230,13 @@ int move_addr_to_user(void *kaddr, int klen, void __user *uaddr,
 
 #define SOCKFS_MAGIC 0x534F434B
 
-static kmem_cache_t *sock_inode_cachep __read_mostly;
+static struct kmem_cache *sock_inode_cachep __read_mostly;
 
 static struct inode *sock_alloc_inode(struct super_block *sb)
 {
        struct socket_alloc *ei;
 
-       ei = kmem_cache_alloc(sock_inode_cachep, SLAB_KERNEL);
+       ei = kmem_cache_alloc(sock_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        init_waitqueue_head(&ei->socket.wait);
@@ -257,7 +257,7 @@ static void sock_destroy_inode(struct inode *inode)
                        container_of(inode, struct socket_alloc, vfs_inode));
 }
 
-static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags)
+static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
 {
        struct socket_alloc *ei = (struct socket_alloc *)foo;
 
@@ -305,7 +305,14 @@ static struct file_system_type sock_fs_type = {
 
 static int sockfs_delete_dentry(struct dentry *dentry)
 {
-       return 1;
+       /*
+        * At creation time, we pretended this dentry was hashed
+        * (by clearing DCACHE_UNHASHED bit in d_flags)
+        * At delete time, we restore the truth : not hashed.
+        * (so that dput() can proceed correctly)
+        */
+       dentry->d_flags |= DCACHE_UNHASHED;
+       return 0;
 }
 static struct dentry_operations sockfs_dentry_operations = {
        .d_delete = sockfs_delete_dentry,
@@ -353,16 +360,22 @@ static int sock_attach_fd(struct socket *sock, struct file *file)
 
        this.len = sprintf(name, "[%lu]", SOCK_INODE(sock)->i_ino);
        this.name = name;
-       this.hash = SOCK_INODE(sock)->i_ino;
+       this.hash = 0;
 
-       file->f_dentry = d_alloc(sock_mnt->mnt_sb->s_root, &this);
-       if (unlikely(!file->f_dentry))
+       file->f_path.dentry = d_alloc(sock_mnt->mnt_sb->s_root, &this);
+       if (unlikely(!file->f_path.dentry))
                return -ENOMEM;
 
-       file->f_dentry->d_op = &sockfs_dentry_operations;
-       d_add(file->f_dentry, SOCK_INODE(sock));
-       file->f_vfsmnt = mntget(sock_mnt);
-       file->f_mapping = file->f_dentry->d_inode->i_mapping;
+       file->f_path.dentry->d_op = &sockfs_dentry_operations;
+       /*
+        * We dont want to push this dentry into global dentry hash table.
+        * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED
+        * This permits a working /proc/$pid/fd/XXX on sockets
+        */
+       file->f_path.dentry->d_flags &= ~DCACHE_UNHASHED;
+       d_instantiate(file->f_path.dentry, SOCK_INODE(sock));
+       file->f_path.mnt = mntget(sock_mnt);
+       file->f_mapping = file->f_path.dentry->d_inode->i_mapping;
 
        sock->file = file;
        file->f_op = SOCK_INODE(sock)->i_fop = &socket_file_ops;
@@ -400,7 +413,7 @@ static struct socket *sock_from_file(struct file *file, int *err)
        if (file->f_op == &socket_file_ops)
                return file->private_data;      /* set in sock_map_fd */
 
-       inode = file->f_dentry->d_inode;
+       inode = file->f_path.dentry->d_inode;
        if (!S_ISSOCK(inode->i_mode)) {
                *err = -ENOTSOCK;
                return NULL;
index e5a84a482e57f7a3c644880084cb9afd817d1640..e1a104abb782d81635937f90aa202742f3836f84 100644 (file)
@@ -68,7 +68,7 @@ static struct rpc_credops gss_credops;
 #define GSS_CRED_SLACK         1024            /* XXX: unused */
 /* length of a krb5 verifier (48), plus data added before arguments when
  * using integrity (two 4-byte integers): */
-#define GSS_VERF_SLACK         56
+#define GSS_VERF_SLACK         100
 
 /* XXX this define must match the gssd define
 * as it is passed to gssd to signal the use of
@@ -94,46 +94,6 @@ struct gss_auth {
 static void gss_destroy_ctx(struct gss_cl_ctx *);
 static struct rpc_pipe_ops gss_upcall_ops;
 
-void
-print_hexl(u32 *p, u_int length, u_int offset)
-{
-       u_int i, j, jm;
-       u8 c, *cp;
-       
-       dprintk("RPC: print_hexl: length %d\n",length);
-       dprintk("\n");
-       cp = (u8 *) p;
-       
-       for (i = 0; i < length; i += 0x10) {
-               dprintk("  %04x: ", (u_int)(i + offset));
-               jm = length - i;
-               jm = jm > 16 ? 16 : jm;
-               
-               for (j = 0; j < jm; j++) {
-                       if ((j % 2) == 1)
-                               dprintk("%02x ", (u_int)cp[i+j]);
-                       else
-                               dprintk("%02x", (u_int)cp[i+j]);
-               }
-               for (; j < 16; j++) {
-                       if ((j % 2) == 1)
-                               dprintk("   ");
-                       else
-                               dprintk("  ");
-               }
-               dprintk(" ");
-               
-               for (j = 0; j < jm; j++) {
-                       c = cp[i+j];
-                       c = isprint(c) ? c : '.';
-                       dprintk("%c", c);
-               }
-               dprintk("\n");
-       }
-}
-
-EXPORT_SYMBOL(print_hexl);
-
 static inline struct gss_cl_ctx *
 gss_get_ctx(struct gss_cl_ctx *ctx)
 {
@@ -541,7 +501,7 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
        if (!buf)
                goto out;
 
-       clnt = RPC_I(filp->f_dentry->d_inode)->private;
+       clnt = RPC_I(filp->f_path.dentry->d_inode)->private;
        err = -EFAULT;
        if (copy_from_user(buf, src, mlen))
                goto err;
index e11a40b25cce68d40a2649cb999793d235fd455a..d926cda8862399de9d73d94c30063004a7c6b3f5 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/highmem.h>
 #include <linux/pagemap.h>
 #include <linux/sunrpc/gss_krb5.h>
+#include <linux/sunrpc/xdr.h>
 
 #ifdef RPC_DEBUG
 # define RPCDBG_FACILITY        RPCDBG_AUTH
@@ -61,9 +62,6 @@ krb5_encrypt(
        u8 local_iv[16] = {0};
        struct blkcipher_desc desc = { .tfm = tfm, .info = local_iv };
 
-       dprintk("RPC:      krb5_encrypt: input data:\n");
-       print_hexl((u32 *)in, length, 0);
-
        if (length % crypto_blkcipher_blocksize(tfm) != 0)
                goto out;
 
@@ -80,12 +78,9 @@ krb5_encrypt(
        sg_set_buf(sg, out, length);
 
        ret = crypto_blkcipher_encrypt_iv(&desc, sg, sg, length);
-
-       dprintk("RPC:      krb5_encrypt: output data:\n");
-       print_hexl((u32 *)out, length, 0);
 out:
        dprintk("RPC:      krb5_encrypt returns %d\n",ret);
-       return(ret);
+       return ret;
 }
 
 EXPORT_SYMBOL(krb5_encrypt);
@@ -103,9 +98,6 @@ krb5_decrypt(
        u8 local_iv[16] = {0};
        struct blkcipher_desc desc = { .tfm = tfm, .info = local_iv };
 
-       dprintk("RPC:      krb5_decrypt: input data:\n");
-       print_hexl((u32 *)in, length, 0);
-
        if (length % crypto_blkcipher_blocksize(tfm) != 0)
                goto out;
 
@@ -121,82 +113,13 @@ krb5_decrypt(
        sg_set_buf(sg, out, length);
 
        ret = crypto_blkcipher_decrypt_iv(&desc, sg, sg, length);
-
-       dprintk("RPC:      krb5_decrypt: output_data:\n");
-       print_hexl((u32 *)out, length, 0);
 out:
        dprintk("RPC:      gss_k5decrypt returns %d\n",ret);
-       return(ret);
+       return ret;
 }
 
 EXPORT_SYMBOL(krb5_decrypt);
 
-static int
-process_xdr_buf(struct xdr_buf *buf, int offset, int len,
-               int (*actor)(struct scatterlist *, void *), void *data)
-{
-       int i, page_len, thislen, page_offset, ret = 0;
-       struct scatterlist      sg[1];
-
-       if (offset >= buf->head[0].iov_len) {
-               offset -= buf->head[0].iov_len;
-       } else {
-               thislen = buf->head[0].iov_len - offset;
-               if (thislen > len)
-                       thislen = len;
-               sg_set_buf(sg, buf->head[0].iov_base + offset, thislen);
-               ret = actor(sg, data);
-               if (ret)
-                       goto out;
-               offset = 0;
-               len -= thislen;
-       }
-       if (len == 0)
-               goto out;
-
-       if (offset >= buf->page_len) {
-               offset -= buf->page_len;
-       } else {
-               page_len = buf->page_len - offset;
-               if (page_len > len)
-                       page_len = len;
-               len -= page_len;
-               page_offset = (offset + buf->page_base) & (PAGE_CACHE_SIZE - 1);
-               i = (offset + buf->page_base) >> PAGE_CACHE_SHIFT;
-               thislen = PAGE_CACHE_SIZE - page_offset;
-               do {
-                       if (thislen > page_len)
-                               thislen = page_len;
-                       sg->page = buf->pages[i];
-                       sg->offset = page_offset;
-                       sg->length = thislen;
-                       ret = actor(sg, data);
-                       if (ret)
-                               goto out;
-                       page_len -= thislen;
-                       i++;
-                       page_offset = 0;
-                       thislen = PAGE_CACHE_SIZE;
-               } while (page_len != 0);
-               offset = 0;
-       }
-       if (len == 0)
-               goto out;
-
-       if (offset < buf->tail[0].iov_len) {
-               thislen = buf->tail[0].iov_len - offset;
-               if (thislen > len)
-                       thislen = len;
-               sg_set_buf(sg, buf->tail[0].iov_base + offset, thislen);
-               ret = actor(sg, data);
-               len -= thislen;
-       }
-       if (len != 0)
-               ret = -EINVAL;
-out:
-       return ret;
-}
-
 static int
 checksummer(struct scatterlist *sg, void *data)
 {
@@ -207,23 +130,13 @@ checksummer(struct scatterlist *sg, void *data)
 
 /* checksum the plaintext data and hdrlen bytes of the token header */
 s32
-make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
+make_checksum(char *cksumname, char *header, int hdrlen, struct xdr_buf *body,
                   int body_offset, struct xdr_netobj *cksum)
 {
-       char                            *cksumname;
        struct hash_desc                desc; /* XXX add to ctx? */
        struct scatterlist              sg[1];
        int err;
 
-       switch (cksumtype) {
-               case CKSUMTYPE_RSA_MD5:
-                       cksumname = "md5";
-                       break;
-               default:
-                       dprintk("RPC:      krb5_make_checksum:"
-                               " unsupported checksum %d", cksumtype);
-                       return GSS_S_FAILURE;
-       }
        desc.tfm = crypto_alloc_hash(cksumname, 0, CRYPTO_ALG_ASYNC);
        if (IS_ERR(desc.tfm))
                return GSS_S_FAILURE;
@@ -237,7 +150,7 @@ make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
        err = crypto_hash_update(&desc, sg, hdrlen);
        if (err)
                goto out;
-       err = process_xdr_buf(body, body_offset, body->len - body_offset,
+       err = xdr_process_buf(body, body_offset, body->len - body_offset,
                              checksummer, &desc);
        if (err)
                goto out;
@@ -335,7 +248,7 @@ gss_encrypt_xdr_buf(struct crypto_blkcipher *tfm, struct xdr_buf *buf,
        desc.fragno = 0;
        desc.fraglen = 0;
 
-       ret = process_xdr_buf(buf, offset, buf->len - offset, encryptor, &desc);
+       ret = xdr_process_buf(buf, offset, buf->len - offset, encryptor, &desc);
        return ret;
 }
 
@@ -401,7 +314,7 @@ gss_decrypt_xdr_buf(struct crypto_blkcipher *tfm, struct xdr_buf *buf,
        desc.desc.flags = 0;
        desc.fragno = 0;
        desc.fraglen = 0;
-       return process_xdr_buf(buf, offset, buf->len - offset, decryptor, &desc);
+       return xdr_process_buf(buf, offset, buf->len - offset, decryptor, &desc);
 }
 
 EXPORT_SYMBOL(gss_decrypt_xdr_buf);
index 754b8cd6439f20e4157069ff9bbc5197b3e3010f..05d4bee86fc06d32c0ab559a936bfff92b8623ae 100644 (file)
@@ -129,6 +129,7 @@ gss_import_sec_context_kerberos(const void *p,
 {
        const void *end = (const void *)((const char *)p + len);
        struct  krb5_ctx *ctx;
+       int tmp;
 
        if (!(ctx = kzalloc(sizeof(*ctx), GFP_KERNEL)))
                goto out_err;
@@ -136,18 +137,23 @@ gss_import_sec_context_kerberos(const void *p,
        p = simple_get_bytes(p, end, &ctx->initiate, sizeof(ctx->initiate));
        if (IS_ERR(p))
                goto out_err_free_ctx;
-       p = simple_get_bytes(p, end, &ctx->seed_init, sizeof(ctx->seed_init));
-       if (IS_ERR(p))
+       /* The downcall format was designed before we completely understood
+        * the uses of the context fields; so it includes some stuff we
+        * just give some minimal sanity-checking, and some we ignore
+        * completely (like the next twenty bytes): */
+       if (unlikely(p + 20 > end || p + 20 < p))
                goto out_err_free_ctx;
-       p = simple_get_bytes(p, end, ctx->seed, sizeof(ctx->seed));
+       p += 20;
+       p = simple_get_bytes(p, end, &tmp, sizeof(tmp));
        if (IS_ERR(p))
                goto out_err_free_ctx;
-       p = simple_get_bytes(p, end, &ctx->signalg, sizeof(ctx->signalg));
-       if (IS_ERR(p))
+       if (tmp != SGN_ALG_DES_MAC_MD5)
                goto out_err_free_ctx;
-       p = simple_get_bytes(p, end, &ctx->sealalg, sizeof(ctx->sealalg));
+       p = simple_get_bytes(p, end, &tmp, sizeof(tmp));
        if (IS_ERR(p))
                goto out_err_free_ctx;
+       if (tmp != SEAL_ALG_DES)
+               goto out_err_free_ctx;
        p = simple_get_bytes(p, end, &ctx->endtime, sizeof(ctx->endtime));
        if (IS_ERR(p))
                goto out_err_free_ctx;
index 08601ee4cd7311d45c4a1146386ce22a0d96be76..d0bb5064f8c5ae1b0578b8f635cea5d5df0695a4 100644 (file)
@@ -77,7 +77,6 @@ gss_get_mic_kerberos(struct gss_ctx *gss_ctx, struct xdr_buf *text,
                struct xdr_netobj *token)
 {
        struct krb5_ctx         *ctx = gss_ctx->internal_ctx_id;
-       s32                     checksum_type;
        char                    cksumdata[16];
        struct xdr_netobj       md5cksum = {.len = 0, .data = cksumdata};
        unsigned char           *ptr, *krb5_hdr, *msg_start;
@@ -88,21 +87,6 @@ gss_get_mic_kerberos(struct gss_ctx *gss_ctx, struct xdr_buf *text,
 
        now = get_seconds();
 
-       switch (ctx->signalg) {
-               case SGN_ALG_DES_MAC_MD5:
-                       checksum_type = CKSUMTYPE_RSA_MD5;
-                       break;
-               default:
-                       dprintk("RPC:      gss_krb5_seal: ctx->signalg %d not"
-                               " supported\n", ctx->signalg);
-                       goto out_err;
-       }
-       if (ctx->sealalg != SEAL_ALG_NONE && ctx->sealalg != SEAL_ALG_DES) {
-               dprintk("RPC:      gss_krb5_seal: ctx->sealalg %d not supported\n",
-                       ctx->sealalg);
-               goto out_err;
-       }
-
        token->len = g_token_size(&ctx->mech_used, 22);
 
        ptr = token->data;
@@ -115,37 +99,26 @@ gss_get_mic_kerberos(struct gss_ctx *gss_ctx, struct xdr_buf *text,
        krb5_hdr = ptr - 2;
        msg_start = krb5_hdr + 24;
 
-       *(__be16 *)(krb5_hdr + 2) = htons(ctx->signalg);
+       *(__be16 *)(krb5_hdr + 2) = htons(SGN_ALG_DES_MAC_MD5);
        memset(krb5_hdr + 4, 0xff, 4);
 
-       if (make_checksum(checksum_type, krb5_hdr, 8, text, 0, &md5cksum))
-                       goto out_err;
-
-       switch (ctx->signalg) {
-       case SGN_ALG_DES_MAC_MD5:
-               if (krb5_encrypt(ctx->seq, NULL, md5cksum.data,
-                                 md5cksum.data, md5cksum.len))
-                       goto out_err;
-               memcpy(krb5_hdr + 16,
-                      md5cksum.data + md5cksum.len - KRB5_CKSUM_LENGTH,
-                      KRB5_CKSUM_LENGTH);
-
-               dprintk("RPC:      make_seal_token: cksum data: \n");
-               print_hexl((u32 *) (krb5_hdr + 16), KRB5_CKSUM_LENGTH, 0);
-               break;
-       default:
-               BUG();
-       }
+       if (make_checksum("md5", krb5_hdr, 8, text, 0, &md5cksum))
+               return GSS_S_FAILURE;
+
+       if (krb5_encrypt(ctx->seq, NULL, md5cksum.data,
+                         md5cksum.data, md5cksum.len))
+               return GSS_S_FAILURE;
+
+       memcpy(krb5_hdr + 16, md5cksum.data + md5cksum.len - KRB5_CKSUM_LENGTH,
+              KRB5_CKSUM_LENGTH);
 
        spin_lock(&krb5_seq_lock);
        seq_send = ctx->seq_send++;
        spin_unlock(&krb5_seq_lock);
 
-       if ((krb5_make_seq_num(ctx->seq, ctx->initiate ? 0 : 0xff,
-                              seq_send, krb5_hdr + 16, krb5_hdr + 8)))
-               goto out_err;
+       if (krb5_make_seq_num(ctx->seq, ctx->initiate ? 0 : 0xff,
+                              ctx->seq_send, krb5_hdr + 16, krb5_hdr + 8))
+               return GSS_S_FAILURE;
 
-       return ((ctx->endtime < now) ? GSS_S_CONTEXT_EXPIRED : GSS_S_COMPLETE);
-out_err:
-       return GSS_S_FAILURE;
+       return (ctx->endtime < now) ? GSS_S_CONTEXT_EXPIRED : GSS_S_COMPLETE;
 }
index 0828cf64100f977d241dac71d393a0148aa8f09a..87f8977ccece78861cd8d65c1e83007930b82cc0 100644 (file)
@@ -78,7 +78,6 @@ gss_verify_mic_kerberos(struct gss_ctx *gss_ctx,
        struct krb5_ctx         *ctx = gss_ctx->internal_ctx_id;
        int                     signalg;
        int                     sealalg;
-       s32                     checksum_type;
        char                    cksumdata[16];
        struct xdr_netobj       md5cksum = {.len = 0, .data = cksumdata};
        s32                     now;
@@ -86,96 +85,54 @@ gss_verify_mic_kerberos(struct gss_ctx *gss_ctx,
        s32                     seqnum;
        unsigned char           *ptr = (unsigned char *)read_token->data;
        int                     bodysize;
-       u32                     ret = GSS_S_DEFECTIVE_TOKEN;
 
        dprintk("RPC:      krb5_read_token\n");
 
        if (g_verify_token_header(&ctx->mech_used, &bodysize, &ptr,
                                        read_token->len))
-               goto out;
+               return GSS_S_DEFECTIVE_TOKEN;
 
        if ((*ptr++ != ((KG_TOK_MIC_MSG>>8)&0xff)) ||
            (*ptr++ != ( KG_TOK_MIC_MSG    &0xff))   )
-               goto out;
+               return GSS_S_DEFECTIVE_TOKEN;
 
        /* XXX sanity-check bodysize?? */
 
-       /* get the sign and seal algorithms */
-
        signalg = ptr[0] + (ptr[1] << 8);
-       sealalg = ptr[2] + (ptr[3] << 8);
+       if (signalg != SGN_ALG_DES_MAC_MD5)
+               return GSS_S_DEFECTIVE_TOKEN;
 
-       /* Sanity checks */
+       sealalg = ptr[2] + (ptr[3] << 8);
+       if (sealalg != SEAL_ALG_NONE)
+               return GSS_S_DEFECTIVE_TOKEN;
 
        if ((ptr[4] != 0xff) || (ptr[5] != 0xff))
-               goto out;
-
-       if (sealalg != 0xffff)
-               goto out;
-
-       /* there are several mappings of seal algorithms to sign algorithms,
-          but few enough that we can try them all. */
-
-       if ((ctx->sealalg == SEAL_ALG_NONE && signalg > 1) ||
-           (ctx->sealalg == SEAL_ALG_1 && signalg != SGN_ALG_3) ||
-           (ctx->sealalg == SEAL_ALG_DES3KD &&
-            signalg != SGN_ALG_HMAC_SHA1_DES3_KD))
-               goto out;
-
-       /* compute the checksum of the message */
-
-       /* initialize the the cksum */
-       switch (signalg) {
-       case SGN_ALG_DES_MAC_MD5:
-               checksum_type = CKSUMTYPE_RSA_MD5;
-               break;
-       default:
-               ret = GSS_S_DEFECTIVE_TOKEN;
-               goto out;
-       }
-
-       switch (signalg) {
-       case SGN_ALG_DES_MAC_MD5:
-               ret = make_checksum(checksum_type, ptr - 2, 8,
-                                        message_buffer, 0, &md5cksum);
-               if (ret)
-                       goto out;
-
-               ret = krb5_encrypt(ctx->seq, NULL, md5cksum.data,
-                                  md5cksum.data, 16);
-               if (ret)
-                       goto out;
-
-               if (memcmp(md5cksum.data + 8, ptr + 14, 8)) {
-                       ret = GSS_S_BAD_SIG;
-                       goto out;
-               }
-               break;
-       default:
-               ret = GSS_S_DEFECTIVE_TOKEN;
-               goto out;
-       }
+               return GSS_S_DEFECTIVE_TOKEN;
+
+       if (make_checksum("md5", ptr - 2, 8, message_buffer, 0, &md5cksum))
+               return GSS_S_FAILURE;
+
+       if (krb5_encrypt(ctx->seq, NULL, md5cksum.data, md5cksum.data, 16))
+               return GSS_S_FAILURE;
+
+       if (memcmp(md5cksum.data + 8, ptr + 14, 8))
+               return GSS_S_BAD_SIG;
 
        /* it got through unscathed.  Make sure the context is unexpired */
 
        now = get_seconds();
 
-       ret = GSS_S_CONTEXT_EXPIRED;
        if (now > ctx->endtime)
-               goto out;
+               return GSS_S_CONTEXT_EXPIRED;
 
        /* do sequencing checks */
 
-       ret = GSS_S_BAD_SIG;
-       if ((ret = krb5_get_seq_num(ctx->seq, ptr + 14, ptr + 6, &direction,
-                                   &seqnum)))
-               goto out;
+       if (krb5_get_seq_num(ctx->seq, ptr + 14, ptr + 6, &direction, &seqnum))
+               return GSS_S_FAILURE;
 
        if ((ctx->initiate && direction != 0xff) ||
            (!ctx->initiate && direction != 0))
-               goto out;
+               return GSS_S_BAD_SIG;
 
-       ret = GSS_S_COMPLETE;
-out:
-       return ret;
+       return GSS_S_COMPLETE;
 }
index cc45c1605f80eb7bbc6f2382bb2c3952f0446ec9..fe25b3d898dc53951be0c84166df3eae02487817 100644 (file)
@@ -57,9 +57,9 @@ gss_krb5_remove_padding(struct xdr_buf *buf, int blocksize)
                                        >>PAGE_CACHE_SHIFT;
                int offset = (buf->page_base + len - 1)
                                        & (PAGE_CACHE_SIZE - 1);
-               ptr = kmap_atomic(buf->pages[last], KM_SKB_SUNRPC_DATA);
+               ptr = kmap_atomic(buf->pages[last], KM_USER0);
                pad = *(ptr + offset);
-               kunmap_atomic(ptr, KM_SKB_SUNRPC_DATA);
+               kunmap_atomic(ptr, KM_USER0);
                goto out;
        } else
                len -= buf->page_len;
@@ -120,7 +120,6 @@ gss_wrap_kerberos(struct gss_ctx *ctx, int offset,
                struct xdr_buf *buf, struct page **pages)
 {
        struct krb5_ctx         *kctx = ctx->internal_ctx_id;
-       s32                     checksum_type;
        char                    cksumdata[16];
        struct xdr_netobj       md5cksum = {.len = 0, .data = cksumdata};
        int                     blocksize = 0, plainlen;
@@ -134,21 +133,6 @@ gss_wrap_kerberos(struct gss_ctx *ctx, int offset,
 
        now = get_seconds();
 
-       switch (kctx->signalg) {
-               case SGN_ALG_DES_MAC_MD5:
-                       checksum_type = CKSUMTYPE_RSA_MD5;
-                       break;
-               default:
-                       dprintk("RPC:      gss_krb5_seal: kctx->signalg %d not"
-                               " supported\n", kctx->signalg);
-                       goto out_err;
-       }
-       if (kctx->sealalg != SEAL_ALG_NONE && kctx->sealalg != SEAL_ALG_DES) {
-               dprintk("RPC:      gss_krb5_seal: kctx->sealalg %d not supported\n",
-                       kctx->sealalg);
-               goto out_err;
-       }
-
        blocksize = crypto_blkcipher_blocksize(kctx->enc);
        gss_krb5_add_padding(buf, offset, blocksize);
        BUG_ON((buf->len - offset) % blocksize);
@@ -175,37 +159,27 @@ gss_wrap_kerberos(struct gss_ctx *ctx, int offset,
        /* ptr now at byte 2 of header described in rfc 1964, section 1.2.1: */
        krb5_hdr = ptr - 2;
        msg_start = krb5_hdr + 24;
-       /* XXXJBF: */ BUG_ON(buf->head[0].iov_base + offset + headlen != msg_start + blocksize);
 
-       *(__be16 *)(krb5_hdr + 2) = htons(kctx->signalg);
+       *(__be16 *)(krb5_hdr + 2) = htons(SGN_ALG_DES_MAC_MD5);
        memset(krb5_hdr + 4, 0xff, 4);
-       *(__be16 *)(krb5_hdr + 4) = htons(kctx->sealalg);
+       *(__be16 *)(krb5_hdr + 4) = htons(SEAL_ALG_DES);
 
        make_confounder(msg_start, blocksize);
 
        /* XXXJBF: UGH!: */
        tmp_pages = buf->pages;
        buf->pages = pages;
-       if (make_checksum(checksum_type, krb5_hdr, 8, buf,
+       if (make_checksum("md5", krb5_hdr, 8, buf,
                                offset + headlen - blocksize, &md5cksum))
-               goto out_err;
+               return GSS_S_FAILURE;
        buf->pages = tmp_pages;
 
-       switch (kctx->signalg) {
-       case SGN_ALG_DES_MAC_MD5:
-               if (krb5_encrypt(kctx->seq, NULL, md5cksum.data,
-                                 md5cksum.data, md5cksum.len))
-                       goto out_err;
-               memcpy(krb5_hdr + 16,
-                      md5cksum.data + md5cksum.len - KRB5_CKSUM_LENGTH,
-                      KRB5_CKSUM_LENGTH);
-
-               dprintk("RPC:      make_seal_token: cksum data: \n");
-               print_hexl((u32 *) (krb5_hdr + 16), KRB5_CKSUM_LENGTH, 0);
-               break;
-       default:
-               BUG();
-       }
+       if (krb5_encrypt(kctx->seq, NULL, md5cksum.data,
+                         md5cksum.data, md5cksum.len))
+               return GSS_S_FAILURE;
+       memcpy(krb5_hdr + 16,
+              md5cksum.data + md5cksum.len - KRB5_CKSUM_LENGTH,
+              KRB5_CKSUM_LENGTH);
 
        spin_lock(&krb5_seq_lock);
        seq_send = kctx->seq_send++;
@@ -215,15 +189,13 @@ gss_wrap_kerberos(struct gss_ctx *ctx, int offset,
         * and encrypt at the same time: */
        if ((krb5_make_seq_num(kctx->seq, kctx->initiate ? 0 : 0xff,
                               seq_send, krb5_hdr + 16, krb5_hdr + 8)))
-               goto out_err;
+               return GSS_S_FAILURE;
 
        if (gss_encrypt_xdr_buf(kctx->enc, buf, offset + headlen - blocksize,
                                                                        pages))
-               goto out_err;
+               return GSS_S_FAILURE;
 
-       return ((kctx->endtime < now) ? GSS_S_CONTEXT_EXPIRED : GSS_S_COMPLETE);
-out_err:
-       return GSS_S_FAILURE;
+       return (kctx->endtime < now) ? GSS_S_CONTEXT_EXPIRED : GSS_S_COMPLETE;
 }
 
 u32
@@ -232,7 +204,6 @@ gss_unwrap_kerberos(struct gss_ctx *ctx, int offset, struct xdr_buf *buf)
        struct krb5_ctx         *kctx = ctx->internal_ctx_id;
        int                     signalg;
        int                     sealalg;
-       s32                     checksum_type;
        char                    cksumdata[16];
        struct xdr_netobj       md5cksum = {.len = 0, .data = cksumdata};
        s32                     now;
@@ -240,7 +211,6 @@ gss_unwrap_kerberos(struct gss_ctx *ctx, int offset, struct xdr_buf *buf)
        s32                     seqnum;
        unsigned char           *ptr;
        int                     bodysize;
-       u32                     ret = GSS_S_DEFECTIVE_TOKEN;
        void                    *data_start, *orig_start;
        int                     data_len;
        int                     blocksize;
@@ -250,98 +220,58 @@ gss_unwrap_kerberos(struct gss_ctx *ctx, int offset, struct xdr_buf *buf)
        ptr = (u8 *)buf->head[0].iov_base + offset;
        if (g_verify_token_header(&kctx->mech_used, &bodysize, &ptr,
                                        buf->len - offset))
-               goto out;
+               return GSS_S_DEFECTIVE_TOKEN;
 
        if ((*ptr++ != ((KG_TOK_WRAP_MSG>>8)&0xff)) ||
            (*ptr++ !=  (KG_TOK_WRAP_MSG    &0xff))   )
-               goto out;
+               return GSS_S_DEFECTIVE_TOKEN;
 
        /* XXX sanity-check bodysize?? */
 
        /* get the sign and seal algorithms */
 
        signalg = ptr[0] + (ptr[1] << 8);
-       sealalg = ptr[2] + (ptr[3] << 8);
+       if (signalg != SGN_ALG_DES_MAC_MD5)
+               return GSS_S_DEFECTIVE_TOKEN;
 
-       /* Sanity checks */
+       sealalg = ptr[2] + (ptr[3] << 8);
+       if (sealalg != SEAL_ALG_DES)
+               return GSS_S_DEFECTIVE_TOKEN;
 
        if ((ptr[4] != 0xff) || (ptr[5] != 0xff))
-               goto out;
-
-       if (sealalg == 0xffff)
-               goto out;
-
-       /* in the current spec, there is only one valid seal algorithm per
-          key type, so a simple comparison is ok */
-
-       if (sealalg != kctx->sealalg)
-               goto out;
-
-       /* there are several mappings of seal algorithms to sign algorithms,
-          but few enough that we can try them all. */
-
-       if ((kctx->sealalg == SEAL_ALG_NONE && signalg > 1) ||
-           (kctx->sealalg == SEAL_ALG_1 && signalg != SGN_ALG_3) ||
-           (kctx->sealalg == SEAL_ALG_DES3KD &&
-            signalg != SGN_ALG_HMAC_SHA1_DES3_KD))
-               goto out;
+               return GSS_S_DEFECTIVE_TOKEN;
 
        if (gss_decrypt_xdr_buf(kctx->enc, buf,
                        ptr + 22 - (unsigned char *)buf->head[0].iov_base))
-               goto out;
+               return GSS_S_DEFECTIVE_TOKEN;
 
-       /* compute the checksum of the message */
+       if (make_checksum("md5", ptr - 2, 8, buf,
+                ptr + 22 - (unsigned char *)buf->head[0].iov_base, &md5cksum))
+               return GSS_S_FAILURE;
 
-       /* initialize the the cksum */
-       switch (signalg) {
-       case SGN_ALG_DES_MAC_MD5:
-               checksum_type = CKSUMTYPE_RSA_MD5;
-               break;
-       default:
-               ret = GSS_S_DEFECTIVE_TOKEN;
-               goto out;
-       }
-
-       switch (signalg) {
-       case SGN_ALG_DES_MAC_MD5:
-               ret = make_checksum(checksum_type, ptr - 2, 8, buf,
-                        ptr + 22 - (unsigned char *)buf->head[0].iov_base, &md5cksum);
-               if (ret)
-                       goto out;
-
-               ret = krb5_encrypt(kctx->seq, NULL, md5cksum.data,
-                                  md5cksum.data, md5cksum.len);
-               if (ret)
-                       goto out;
-
-               if (memcmp(md5cksum.data + 8, ptr + 14, 8)) {
-                       ret = GSS_S_BAD_SIG;
-                       goto out;
-               }
-               break;
-       default:
-               ret = GSS_S_DEFECTIVE_TOKEN;
-               goto out;
-       }
+       if (krb5_encrypt(kctx->seq, NULL, md5cksum.data,
+                          md5cksum.data, md5cksum.len))
+               return GSS_S_FAILURE;
+
+       if (memcmp(md5cksum.data + 8, ptr + 14, 8))
+               return GSS_S_BAD_SIG;
 
        /* it got through unscathed.  Make sure the context is unexpired */
 
        now = get_seconds();
 
-       ret = GSS_S_CONTEXT_EXPIRED;
        if (now > kctx->endtime)
-               goto out;
+               return GSS_S_CONTEXT_EXPIRED;
 
        /* do sequencing checks */
 
-       ret = GSS_S_BAD_SIG;
-       if ((ret = krb5_get_seq_num(kctx->seq, ptr + 14, ptr + 6, &direction,
-                                   &seqnum)))
-               goto out;
+       if (krb5_get_seq_num(kctx->seq, ptr + 14, ptr + 6, &direction,
+                                   &seqnum))
+               return GSS_S_BAD_SIG;
 
        if ((kctx->initiate && direction != 0xff) ||
            (!kctx->initiate && direction != 0))
-               goto out;
+               return GSS_S_BAD_SIG;
 
        /* Copy the data back to the right position.  XXX: Would probably be
         * better to copy and encrypt at the same time. */
@@ -354,11 +284,8 @@ gss_unwrap_kerberos(struct gss_ctx *ctx, int offset, struct xdr_buf *buf)
        buf->head[0].iov_len -= (data_start - orig_start);
        buf->len -= (data_start - orig_start);
 
-       ret = GSS_S_DEFECTIVE_TOKEN;
        if (gss_krb5_remove_padding(buf, blocksize))
-               goto out;
+               return GSS_S_DEFECTIVE_TOKEN;
 
-       ret = GSS_S_COMPLETE;
-out:
-       return ret;
+       return GSS_S_COMPLETE;
 }
index d57f60838895d878efca25ba46628ca795237f16..41465072d0b59168cbdcb9a3aed3294a58ab7458 100644 (file)
@@ -82,133 +82,73 @@ simple_get_netobj(const void *p, const void *end, struct xdr_netobj *res)
        return q;
 }
 
-static inline const void *
-get_key(const void *p, const void *end, struct crypto_blkcipher **res,
-       int *resalg)
-{
-       struct xdr_netobj       key = { 0 };
-       int                     setkey = 0;
-       char                    *alg_name;
-
-       p = simple_get_bytes(p, end, resalg, sizeof(*resalg));
-       if (IS_ERR(p))
-               goto out_err;
-       p = simple_get_netobj(p, end, &key);
-       if (IS_ERR(p))
-               goto out_err;
-
-       switch (*resalg) {
-               case NID_des_cbc:
-                       alg_name = "cbc(des)";
-                       setkey = 1;
-                       break;
-               case NID_cast5_cbc:
-                       /* XXXX here in name only, not used */
-                       alg_name = "cbc(cast5)";
-                       setkey = 0; /* XXX will need to set to 1 */
-                       break;
-               case NID_md5:
-                       if (key.len == 0) {
-                               dprintk("RPC: SPKM3 get_key: NID_md5 zero Key length\n");
-                       }
-                       alg_name = "md5";
-                       setkey = 0;
-                       break;
-               default:
-                       dprintk("gss_spkm3_mech: unsupported algorithm %d\n", *resalg);
-                       goto out_err_free_key;
-       }
-       *res = crypto_alloc_blkcipher(alg_name, 0, CRYPTO_ALG_ASYNC);
-       if (IS_ERR(*res)) {
-               printk("gss_spkm3_mech: unable to initialize crypto algorthm %s\n", alg_name);
-               *res = NULL;
-               goto out_err_free_key;
-       }
-       if (setkey) {
-               if (crypto_blkcipher_setkey(*res, key.data, key.len)) {
-                       printk("gss_spkm3_mech: error setting key for crypto algorthm %s\n", alg_name);
-                       goto out_err_free_tfm;
-               }
-       }
-
-       if(key.len > 0)
-               kfree(key.data);
-       return p;
-
-out_err_free_tfm:
-       crypto_free_blkcipher(*res);
-out_err_free_key:
-       if(key.len > 0)
-               kfree(key.data);
-       p = ERR_PTR(-EINVAL);
-out_err:
-       return p;
-}
-
 static int
 gss_import_sec_context_spkm3(const void *p, size_t len,
                                struct gss_ctx *ctx_id)
 {
        const void *end = (const void *)((const char *)p + len);
        struct  spkm3_ctx *ctx;
+       int     version;
 
        if (!(ctx = kzalloc(sizeof(*ctx), GFP_KERNEL)))
                goto out_err;
 
+       p = simple_get_bytes(p, end, &version, sizeof(version));
+       if (IS_ERR(p))
+               goto out_err_free_ctx;
+       if (version != 1) {
+               dprintk("RPC: unknown spkm3 token format: obsolete nfs-utils?\n");
+               goto out_err_free_ctx;
+       }
+
        p = simple_get_netobj(p, end, &ctx->ctx_id);
        if (IS_ERR(p))
                goto out_err_free_ctx;
 
-       p = simple_get_bytes(p, end, &ctx->qop, sizeof(ctx->qop));
+       p = simple_get_bytes(p, end, &ctx->endtime, sizeof(ctx->endtime));
        if (IS_ERR(p))
                goto out_err_free_ctx_id;
 
        p = simple_get_netobj(p, end, &ctx->mech_used);
        if (IS_ERR(p))
-               goto out_err_free_mech;
+               goto out_err_free_ctx_id;
 
        p = simple_get_bytes(p, end, &ctx->ret_flags, sizeof(ctx->ret_flags));
        if (IS_ERR(p))
                goto out_err_free_mech;
 
-       p = simple_get_bytes(p, end, &ctx->req_flags, sizeof(ctx->req_flags));
+       p = simple_get_netobj(p, end, &ctx->conf_alg);
        if (IS_ERR(p))
                goto out_err_free_mech;
 
-       p = simple_get_netobj(p, end, &ctx->share_key);
-       if (IS_ERR(p))
-               goto out_err_free_s_key;
-
-       p = get_key(p, end, &ctx->derived_conf_key, &ctx->conf_alg);
+       p = simple_get_netobj(p, end, &ctx->derived_conf_key);
        if (IS_ERR(p))
-               goto out_err_free_s_key;
+               goto out_err_free_conf_alg;
 
-       p = get_key(p, end, &ctx->derived_integ_key, &ctx->intg_alg);
+       p = simple_get_netobj(p, end, &ctx->intg_alg);
        if (IS_ERR(p))
-               goto out_err_free_key1;
+               goto out_err_free_conf_key;
 
-       p = simple_get_bytes(p, end, &ctx->keyestb_alg, sizeof(ctx->keyestb_alg));
+       p = simple_get_netobj(p, end, &ctx->derived_integ_key);
        if (IS_ERR(p))
-               goto out_err_free_key2;
-
-       p = simple_get_bytes(p, end, &ctx->owf_alg, sizeof(ctx->owf_alg));
-       if (IS_ERR(p))
-               goto out_err_free_key2;
+               goto out_err_free_intg_alg;
 
        if (p != end)
-               goto out_err_free_key2;
+               goto out_err_free_intg_key;
 
        ctx_id->internal_ctx_id = ctx;
 
        dprintk("Successfully imported new spkm context.\n");
        return 0;
 
-out_err_free_key2:
-       crypto_free_blkcipher(ctx->derived_integ_key);
-out_err_free_key1:
-       crypto_free_blkcipher(ctx->derived_conf_key);
-out_err_free_s_key:
-       kfree(ctx->share_key.data);
+out_err_free_intg_key:
+       kfree(ctx->derived_integ_key.data);
+out_err_free_intg_alg:
+       kfree(ctx->intg_alg.data);
+out_err_free_conf_key:
+       kfree(ctx->derived_conf_key.data);
+out_err_free_conf_alg:
+       kfree(ctx->conf_alg.data);
 out_err_free_mech:
        kfree(ctx->mech_used.data);
 out_err_free_ctx_id:
@@ -220,13 +160,16 @@ out_err:
 }
 
 static void
-gss_delete_sec_context_spkm3(void *internal_ctx) {
+gss_delete_sec_context_spkm3(void *internal_ctx)
+{
        struct spkm3_ctx *sctx = internal_ctx;
 
-       crypto_free_blkcipher(sctx->derived_integ_key);
-       crypto_free_blkcipher(sctx->derived_conf_key);
-       kfree(sctx->share_key.data);
+       kfree(sctx->derived_integ_key.data);
+       kfree(sctx->intg_alg.data);
+       kfree(sctx->derived_conf_key.data);
+       kfree(sctx->conf_alg.data);
        kfree(sctx->mech_used.data);
+       kfree(sctx->ctx_id.data);
        kfree(sctx);
 }
 
@@ -238,7 +181,6 @@ gss_verify_mic_spkm3(struct gss_ctx         *ctx,
        u32 maj_stat = 0;
        struct spkm3_ctx *sctx = ctx->internal_ctx_id;
 
-       dprintk("RPC: gss_verify_mic_spkm3 calling spkm3_read_token\n");
        maj_stat = spkm3_read_token(sctx, checksum, signbuf, SPKM_MIC_TOK);
 
        dprintk("RPC: gss_verify_mic_spkm3 returning %d\n", maj_stat);
@@ -253,10 +195,9 @@ gss_get_mic_spkm3(struct gss_ctx   *ctx,
        u32 err = 0;
        struct spkm3_ctx *sctx = ctx->internal_ctx_id;
 
-       dprintk("RPC: gss_get_mic_spkm3\n");
-
        err = spkm3_make_token(sctx, message_buffer,
-                             message_token, SPKM_MIC_TOK);
+                               message_token, SPKM_MIC_TOK);
+       dprintk("RPC: gss_get_mic_spkm3 returning %d\n", err);
        return err;
 }
 
index 18c7862bc234a989c14e26bee79212de3f2a63fc..b179d58c6249cf66b2004aa18fb0560011f0c8e5 100644 (file)
 #include <linux/sunrpc/gss_spkm3.h>
 #include <linux/random.h>
 #include <linux/crypto.h>
+#include <linux/pagemap.h>
+#include <linux/scatterlist.h>
+#include <linux/sunrpc/xdr.h>
 
 #ifdef RPC_DEBUG
 # define RPCDBG_FACILITY        RPCDBG_AUTH
 #endif
 
+const struct xdr_netobj hmac_md5_oid = { 8, "\x2B\x06\x01\x05\x05\x08\x01\x01"};
+const struct xdr_netobj cast5_cbc_oid = {9, "\x2A\x86\x48\x86\xF6\x7D\x07\x42\x0A"};
+
 /*
  * spkm3_make_token()
  *
@@ -66,29 +72,23 @@ spkm3_make_token(struct spkm3_ctx *ctx,
        int                     ctxelen = 0, ctxzbit = 0;
        int                     md5elen = 0, md5zbit = 0;
 
-       dprintk("RPC: spkm3_make_token\n");
-
        now = jiffies;
 
        if (ctx->ctx_id.len != 16) {
                dprintk("RPC: spkm3_make_token BAD ctx_id.len %d\n",
-                       ctx->ctx_id.len);
+                               ctx->ctx_id.len);
                goto out_err;
        }
-               
-       switch (ctx->intg_alg) {
-               case NID_md5:
-                       checksum_type = CKSUMTYPE_RSA_MD5;
-                       break;
-               default:
-                       dprintk("RPC: gss_spkm3_seal: ctx->signalg %d not"
-                               " supported\n", ctx->intg_alg);
-                       goto out_err;
-       }
-       /* XXX since we don't support WRAP, perhaps we don't care... */
-       if (ctx->conf_alg != NID_cast5_cbc) {
-               dprintk("RPC: gss_spkm3_seal: ctx->sealalg %d not supported\n",
-                       ctx->conf_alg);
+
+       if (!g_OID_equal(&ctx->intg_alg, &hmac_md5_oid)) {
+               dprintk("RPC: gss_spkm3_seal: unsupported I-ALG algorithm."
+                               "only support hmac-md5 I-ALG.\n");
+               goto out_err;
+       } else
+               checksum_type = CKSUMTYPE_HMAC_MD5;
+
+       if (!g_OID_equal(&ctx->conf_alg, &cast5_cbc_oid)) {
+               dprintk("RPC: gss_spkm3_seal: unsupported C-ALG algorithm\n");
                goto out_err;
        }
 
@@ -96,10 +96,10 @@ spkm3_make_token(struct spkm3_ctx *ctx,
                /* Calculate checksum over the mic-header */
                asn1_bitstring_len(&ctx->ctx_id, &ctxelen, &ctxzbit);
                spkm3_mic_header(&mic_hdr.data, &mic_hdr.len, ctx->ctx_id.data,
-                                        ctxelen, ctxzbit);
-
-               if (make_checksum(checksum_type, mic_hdr.data, mic_hdr.len, 
-                                            text, 0, &md5cksum))
+                               ctxelen, ctxzbit);
+               if (make_spkm3_checksum(checksum_type, &ctx->derived_integ_key,
+                                       (char *)mic_hdr.data, mic_hdr.len,
+                                       text, 0, &md5cksum))
                        goto out_err;
 
                asn1_bitstring_len(&md5cksum, &md5elen, &md5zbit);
@@ -121,7 +121,66 @@ spkm3_make_token(struct spkm3_ctx *ctx,
 
        return  GSS_S_COMPLETE;
 out_err:
+       if (md5cksum.data)
+               kfree(md5cksum.data);
+
        token->data = NULL;
        token->len = 0;
        return GSS_S_FAILURE;
 }
+
+static int
+spkm3_checksummer(struct scatterlist *sg, void *data)
+{
+       struct hash_desc *desc = data;
+
+       return crypto_hash_update(desc, sg, sg->length);
+}
+
+/* checksum the plaintext data and hdrlen bytes of the token header */
+s32
+make_spkm3_checksum(s32 cksumtype, struct xdr_netobj *key, char *header,
+                   unsigned int hdrlen, struct xdr_buf *body,
+                   unsigned int body_offset, struct xdr_netobj *cksum)
+{
+       char                            *cksumname;
+       struct hash_desc                desc; /* XXX add to ctx? */
+       struct scatterlist              sg[1];
+       int err;
+
+       switch (cksumtype) {
+               case CKSUMTYPE_HMAC_MD5:
+                       cksumname = "md5";
+                       break;
+               default:
+                       dprintk("RPC:      spkm3_make_checksum:"
+                                       " unsupported checksum %d", cksumtype);
+                       return GSS_S_FAILURE;
+       }
+
+       if (key->data == NULL || key->len <= 0) return GSS_S_FAILURE;
+
+       desc.tfm = crypto_alloc_hash(cksumname, 0, CRYPTO_ALG_ASYNC);
+       if (IS_ERR(desc.tfm))
+               return GSS_S_FAILURE;
+       cksum->len = crypto_hash_digestsize(desc.tfm);
+       desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP;
+
+       err = crypto_hash_setkey(desc.tfm, key->data, key->len);
+       if (err)
+               goto out;
+
+       sg_set_buf(sg, header, hdrlen);
+       crypto_hash_update(&desc, sg, 1);
+
+       xdr_process_buf(body, body_offset, body->len - body_offset,
+                       spkm3_checksummer, &desc);
+       crypto_hash_final(&desc, cksum->data);
+
+out:
+       crypto_free_hash(desc.tfm);
+
+       return err ? GSS_S_FAILURE : 0;
+}
+
+EXPORT_SYMBOL(make_spkm3_checksum);
index 854a983ccf26fd7c5fbc7c9e439bbae19ad31b70..35188b6ea8f75a950709498fa5dc187e73b0c02f 100644 (file)
@@ -172,10 +172,10 @@ spkm3_mic_header(unsigned char **hdrbuf, unsigned int *hdrlen, unsigned char *ct
        *(u8 *)hptr++ = zbit;
        memcpy(hptr, ctxdata, elen);
        hptr += elen;
-       *hdrlen = hptr - top; 
+       *hdrlen = hptr - top;
 }
-               
-/* 
+
+/*
  * spkm3_mic_innercontext_token()
  *
  * *tokp points to the beginning of the SPKM_MIC token  described 
index 8537f581ef9b904f7abe5d821a6dcc7da1a41dec..e54581ca75702b43321aae63bced573ceffc73b8 100644 (file)
@@ -54,70 +54,70 @@ spkm3_read_token(struct spkm3_ctx *ctx,
                struct xdr_buf *message_buffer, /* signbuf */
                int toktype)
 {
+       s32                     checksum_type;
        s32                     code;
        struct xdr_netobj       wire_cksum = {.len =0, .data = NULL};
        char                    cksumdata[16];
        struct xdr_netobj       md5cksum = {.len = 0, .data = cksumdata};
        unsigned char           *ptr = (unsigned char *)read_token->data;
-       unsigned char           *cksum;
+       unsigned char           *cksum;
        int                     bodysize, md5elen;
        int                     mic_hdrlen;
        u32                     ret = GSS_S_DEFECTIVE_TOKEN;
 
-       dprintk("RPC: spkm3_read_token read_token->len %d\n", read_token->len);
-
        if (g_verify_token_header((struct xdr_netobj *) &ctx->mech_used,
                                        &bodysize, &ptr, read_token->len))
                goto out;
 
        /* decode the token */
 
-       if (toktype == SPKM_MIC_TOK) {
-
-               if ((ret = spkm3_verify_mic_token(&ptr, &mic_hdrlen, &cksum))) 
-                       goto out;
-
-               if (*cksum++ != 0x03) {
-                       dprintk("RPC: spkm3_read_token BAD checksum type\n");
-                       goto out;
-               }
-               md5elen = *cksum++; 
-               cksum++;        /* move past the zbit */
-       
-               if(!decode_asn1_bitstring(&wire_cksum, cksum, md5elen - 1, 16))
-                       goto out;
-
-               /* HARD CODED FOR MD5 */
-
-               /* compute the checksum of the message.
-               *  ptr + 2 = start of header piece of checksum
-               *  mic_hdrlen + 2 = length of header piece of checksum
-               */
-               ret = GSS_S_DEFECTIVE_TOKEN;
-               code = make_checksum(CKSUMTYPE_RSA_MD5, ptr + 2, 
-                                       mic_hdrlen + 2, 
-                                       message_buffer, 0, &md5cksum);
-
-               if (code)
-                       goto out;
-
-               dprintk("RPC: spkm3_read_token: digest wire_cksum.len %d:\n", 
-                       wire_cksum.len);
-               dprintk("          md5cksum.data\n");
-               print_hexl((u32 *) md5cksum.data, 16, 0);
-               dprintk("          cksum.data:\n");
-               print_hexl((u32 *) wire_cksum.data, wire_cksum.len, 0);
-
-               ret = GSS_S_BAD_SIG;
-               code = memcmp(md5cksum.data, wire_cksum.data, wire_cksum.len);
-               if (code)
-                       goto out;
-
-       } else { 
-               dprintk("RPC: BAD or UNSUPPORTED SPKM3 token type: %d\n",toktype);
+       if (toktype != SPKM_MIC_TOK) {
+               dprintk("RPC: BAD SPKM3 token type: %d\n", toktype);
+               goto out;
+       }
+
+       if ((ret = spkm3_verify_mic_token(&ptr, &mic_hdrlen, &cksum)))
+               goto out;
+
+       if (*cksum++ != 0x03) {
+               dprintk("RPC: spkm3_read_token BAD checksum type\n");
+               goto out;
+       }
+       md5elen = *cksum++;
+       cksum++;        /* move past the zbit */
+
+       if (!decode_asn1_bitstring(&wire_cksum, cksum, md5elen - 1, 16))
+               goto out;
+
+       /* HARD CODED FOR MD5 */
+
+       /* compute the checksum of the message.
+        * ptr + 2 = start of header piece of checksum
+        * mic_hdrlen + 2 = length of header piece of checksum
+        */
+       ret = GSS_S_DEFECTIVE_TOKEN;
+       if (!g_OID_equal(&ctx->intg_alg, &hmac_md5_oid)) {
+               dprintk("RPC: gss_spkm3_seal: unsupported I-ALG algorithm\n");
+               goto out;
+       }
+
+       checksum_type = CKSUMTYPE_HMAC_MD5;
+
+       code = make_spkm3_checksum(checksum_type,
+               &ctx->derived_integ_key, ptr + 2, mic_hdrlen + 2,
+               message_buffer, 0, &md5cksum);
+
+       if (code)
+               goto out;
+
+       ret = GSS_S_BAD_SIG;
+       code = memcmp(md5cksum.data, wire_cksum.data, wire_cksum.len);
+       if (code) {
+               dprintk("RPC: bad MIC checksum\n");
                goto out;
        }
 
+
        /* XXX: need to add expiration and sequencing */
        ret = GSS_S_COMPLETE;
 out:
index d96fd466a9a46ccb460f02dba2be901f2f59f7d0..80aff047457255647a293471087f6d1713a15306 100644 (file)
@@ -670,7 +670,7 @@ cache_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
 {
        struct cache_reader *rp = filp->private_data;
        struct cache_request *rq;
-       struct cache_detail *cd = PDE(filp->f_dentry->d_inode)->data;
+       struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data;
        int err;
 
        if (count == 0)
@@ -747,7 +747,7 @@ cache_write(struct file *filp, const char __user *buf, size_t count,
            loff_t *ppos)
 {
        int err;
-       struct cache_detail *cd = PDE(filp->f_dentry->d_inode)->data;
+       struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data;
 
        if (count == 0)
                return 0;
@@ -778,7 +778,7 @@ cache_poll(struct file *filp, poll_table *wait)
        unsigned int mask;
        struct cache_reader *rp = filp->private_data;
        struct cache_queue *cq;
-       struct cache_detail *cd = PDE(filp->f_dentry->d_inode)->data;
+       struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data;
 
        poll_wait(filp, &queue_wait, wait);
 
@@ -1254,7 +1254,7 @@ static struct file_operations content_file_operations = {
 static ssize_t read_flush(struct file *file, char __user *buf,
                            size_t count, loff_t *ppos)
 {
-       struct cache_detail *cd = PDE(file->f_dentry->d_inode)->data;
+       struct cache_detail *cd = PDE(file->f_path.dentry->d_inode)->data;
        char tbuf[20];
        unsigned long p = *ppos;
        int len;
@@ -1275,7 +1275,7 @@ static ssize_t read_flush(struct file *file, char __user *buf,
 static ssize_t write_flush(struct file * file, const char __user * buf,
                             size_t count, loff_t *ppos)
 {
-       struct cache_detail *cd = PDE(file->f_dentry->d_inode)->data;
+       struct cache_detail *cd = PDE(file->f_path.dentry->d_inode)->data;
        char tbuf[20];
        char *ep;
        long flushtime;
index dfeea4fea95a7f6dfb4ea038491aaba39ced48dc..aba528b9ae769a8aa0fb5b5ece07ff704dab2291 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/types.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/utsname.h>
 #include <linux/workqueue.h>
 
@@ -141,6 +142,10 @@ static struct rpc_clnt * rpc_new_client(struct rpc_xprt *xprt, char *servname, s
        clnt->cl_vers     = version->number;
        clnt->cl_stats    = program->stats;
        clnt->cl_metrics  = rpc_alloc_iostats(clnt);
+       err = -ENOMEM;
+       if (clnt->cl_metrics == NULL)
+               goto out_no_stats;
+       clnt->cl_program  = program;
 
        if (!xprt_bound(clnt->cl_xprt))
                clnt->cl_autobind = 1;
@@ -173,6 +178,8 @@ out_no_auth:
                rpc_put_mount();
        }
 out_no_path:
+       rpc_free_iostats(clnt->cl_metrics);
+out_no_stats:
        if (clnt->cl_server != clnt->cl_inline_name)
                kfree(clnt->cl_server);
        kfree(clnt);
@@ -252,12 +259,19 @@ struct rpc_clnt *
 rpc_clone_client(struct rpc_clnt *clnt)
 {
        struct rpc_clnt *new;
+       int err = -ENOMEM;
 
        new = kmemdup(clnt, sizeof(*new), GFP_KERNEL);
        if (!new)
                goto out_no_clnt;
        atomic_set(&new->cl_count, 1);
        atomic_set(&new->cl_users, 0);
+       new->cl_metrics = rpc_alloc_iostats(clnt);
+       if (new->cl_metrics == NULL)
+               goto out_no_stats;
+       err = rpc_setup_pipedir(new, clnt->cl_program->pipe_dir_name);
+       if (err != 0)
+               goto out_no_path;
        new->cl_parent = clnt;
        atomic_inc(&clnt->cl_count);
        new->cl_xprt = xprt_get(clnt->cl_xprt);
@@ -265,16 +279,17 @@ rpc_clone_client(struct rpc_clnt *clnt)
        new->cl_autobind = 0;
        new->cl_oneshot = 0;
        new->cl_dead = 0;
-       if (!IS_ERR(new->cl_dentry))
-               dget(new->cl_dentry);
        rpc_init_rtt(&new->cl_rtt_default, clnt->cl_xprt->timeout.to_initval);
        if (new->cl_auth)
                atomic_inc(&new->cl_auth->au_count);
-       new->cl_metrics = rpc_alloc_iostats(clnt);
        return new;
+out_no_path:
+       rpc_free_iostats(new->cl_metrics);
+out_no_stats:
+       kfree(new);
 out_no_clnt:
-       printk(KERN_INFO "RPC: out of memory in %s\n", __FUNCTION__);
-       return ERR_PTR(-ENOMEM);
+       dprintk("RPC: %s returned error %d\n", __FUNCTION__, err);
+       return ERR_PTR(err);
 }
 
 /*
@@ -327,16 +342,14 @@ rpc_destroy_client(struct rpc_clnt *clnt)
                rpcauth_destroy(clnt->cl_auth);
                clnt->cl_auth = NULL;
        }
-       if (clnt->cl_parent != clnt) {
-               if (!IS_ERR(clnt->cl_dentry))
-                       dput(clnt->cl_dentry);
-               rpc_destroy_client(clnt->cl_parent);
-               goto out_free;
-       }
        if (!IS_ERR(clnt->cl_dentry)) {
                rpc_rmdir(clnt->cl_dentry);
                rpc_put_mount();
        }
+       if (clnt->cl_parent != clnt) {
+               rpc_destroy_client(clnt->cl_parent);
+               goto out_free;
+       }
        if (clnt->cl_server != clnt->cl_inline_name)
                kfree(clnt->cl_server);
 out_free:
@@ -466,10 +479,9 @@ int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
 
        BUG_ON(flags & RPC_TASK_ASYNC);
 
-       status = -ENOMEM;
        task = rpc_new_task(clnt, flags, &rpc_default_ops, NULL);
        if (task == NULL)
-               goto out;
+               return -ENOMEM;
 
        /* Mask signals on RPC calls _and_ GSS_AUTH upcalls */
        rpc_task_sigmask(task, &oldset);
@@ -478,15 +490,17 @@ int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
 
        /* Set up the call info struct and execute the task */
        status = task->tk_status;
-       if (status == 0) {
-               atomic_inc(&task->tk_count);
-               status = rpc_execute(task);
-               if (status == 0)
-                       status = task->tk_status;
+       if (status != 0) {
+               rpc_release_task(task);
+               goto out;
        }
-       rpc_restore_sigmask(&oldset);
-       rpc_release_task(task);
+       atomic_inc(&task->tk_count);
+       status = rpc_execute(task);
+       if (status == 0)
+               status = task->tk_status;
+       rpc_put_task(task);
 out:
+       rpc_restore_sigmask(&oldset);
        return status;
 }
 
@@ -528,8 +542,7 @@ rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags,
        rpc_restore_sigmask(&oldset);           
        return status;
 out_release:
-       if (tk_ops->rpc_release != NULL)
-               tk_ops->rpc_release(data);
+       rpc_release_calldata(tk_ops, data);
        return status;
 }
 
@@ -581,7 +594,11 @@ EXPORT_SYMBOL_GPL(rpc_peeraddr);
 char *rpc_peeraddr2str(struct rpc_clnt *clnt, enum rpc_display_format_t format)
 {
        struct rpc_xprt *xprt = clnt->cl_xprt;
-       return xprt->ops->print_addr(xprt, format);
+
+       if (xprt->address_strings[format] != NULL)
+               return xprt->address_strings[format];
+       else
+               return "unprintable";
 }
 EXPORT_SYMBOL_GPL(rpc_peeraddr2str);
 
@@ -811,8 +828,10 @@ call_encode(struct rpc_task *task)
        if (encode == NULL)
                return;
 
+       lock_kernel();
        task->tk_status = rpcauth_wrap_req(task, encode, req, p,
                        task->tk_msg.rpc_argp);
+       unlock_kernel();
        if (task->tk_status == -ENOMEM) {
                /* XXX: Is this sane? */
                rpc_delay(task, 3*HZ);
@@ -1143,9 +1162,12 @@ call_decode(struct rpc_task *task)
 
        task->tk_action = rpc_exit_task;
 
-       if (decode)
+       if (decode) {
+               lock_kernel();
                task->tk_status = rpcauth_unwrap_resp(task, decode, req, p,
                                                      task->tk_msg.rpc_resp);
+               unlock_kernel();
+       }
        dprintk("RPC: %4d call_decode result %d\n", task->tk_pid,
                                        task->tk_status);
        return;
index e52afab413ded56212cad69a2801df58bc6b6d6c..3946ec3eb517a674881fc3b8d35277f2a5f3de44 100644 (file)
@@ -101,14 +101,14 @@ void rpc_getport(struct rpc_task *task)
        /* Autobind on cloned rpc clients is discouraged */
        BUG_ON(clnt->cl_parent != clnt);
 
+       status = -EACCES;               /* tell caller to check again */
+       if (xprt_test_and_set_binding(xprt))
+               goto bailout_nowake;
+
        /* Put self on queue before sending rpcbind request, in case
         * pmap_getport_done completes before we return from rpc_run_task */
        rpc_sleep_on(&xprt->binding, task, NULL, NULL);
 
-       status = -EACCES;               /* tell caller to check again */
-       if (xprt_test_and_set_binding(xprt))
-               goto bailout_nofree;
-
        /* Someone else may have bound if we slept */
        status = 0;
        if (xprt_bound(xprt))
@@ -134,7 +134,7 @@ void rpc_getport(struct rpc_task *task)
        child = rpc_run_task(pmap_clnt, RPC_TASK_ASYNC, &pmap_getport_ops, map);
        if (IS_ERR(child))
                goto bailout;
-       rpc_release_task(child);
+       rpc_put_task(child);
 
        task->tk_xprt->stat.bind_count++;
        return;
@@ -143,8 +143,9 @@ bailout:
        pmap_map_free(map);
        xprt_put(xprt);
 bailout_nofree:
-       task->tk_status = status;
        pmap_wake_portmap_waiters(xprt, status);
+bailout_nowake:
+       task->tk_status = status;
 }
 
 #ifdef CONFIG_ROOT_NFS
index 49dba5febbbdc84559267edda5a6f9ac73830043..89273d35e0cc433d554d2abe1a91305cea51a5d7 100644 (file)
@@ -33,7 +33,7 @@ static int rpc_mount_count;
 static struct file_system_type rpc_pipe_fs_type;
 
 
-static kmem_cache_t *rpc_inode_cachep __read_mostly;
+static struct kmem_cache *rpc_inode_cachep __read_mostly;
 
 #define RPC_UPCALL_TIMEOUT (30*HZ)
 
@@ -143,7 +143,7 @@ static struct inode *
 rpc_alloc_inode(struct super_block *sb)
 {
        struct rpc_inode *rpci;
-       rpci = (struct rpc_inode *)kmem_cache_alloc(rpc_inode_cachep, SLAB_KERNEL);
+       rpci = (struct rpc_inode *)kmem_cache_alloc(rpc_inode_cachep, GFP_KERNEL);
        if (!rpci)
                return NULL;
        return &rpci->vfs_inode;
@@ -214,7 +214,7 @@ out:
 static ssize_t
 rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct rpc_inode *rpci = RPC_I(inode);
        struct rpc_pipe_msg *msg;
        int res = 0;
@@ -257,7 +257,7 @@ out_unlock:
 static ssize_t
 rpc_pipe_write(struct file *filp, const char __user *buf, size_t len, loff_t *offset)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct rpc_inode *rpci = RPC_I(inode);
        int res;
 
@@ -275,7 +275,7 @@ rpc_pipe_poll(struct file *filp, struct poll_table_struct *wait)
        struct rpc_inode *rpci;
        unsigned int mask = 0;
 
-       rpci = RPC_I(filp->f_dentry->d_inode);
+       rpci = RPC_I(filp->f_path.dentry->d_inode);
        poll_wait(filp, &rpci->waitq, wait);
 
        mask = POLLOUT | POLLWRNORM;
@@ -290,7 +290,7 @@ static int
 rpc_pipe_ioctl(struct inode *ino, struct file *filp,
                unsigned int cmd, unsigned long arg)
 {
-       struct rpc_inode *rpci = RPC_I(filp->f_dentry->d_inode);
+       struct rpc_inode *rpci = RPC_I(filp->f_path.dentry->d_inode);
        int len;
 
        switch (cmd) {
@@ -824,7 +824,7 @@ static struct file_system_type rpc_pipe_fs_type = {
 };
 
 static void
-init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct rpc_inode *rpci = (struct rpc_inode *) foo;
 
index eff44bcdc95a2570e8ee9eb71117c225b78dfb84..79bc4cdf5d4861e70c2614012dfbec35d7409e72 100644 (file)
@@ -34,8 +34,8 @@ static int                    rpc_task_id;
 #define RPC_BUFFER_MAXSIZE     (2048)
 #define RPC_BUFFER_POOLSIZE    (8)
 #define RPC_TASK_POOLSIZE      (8)
-static kmem_cache_t    *rpc_task_slabp __read_mostly;
-static kmem_cache_t    *rpc_buffer_slabp __read_mostly;
+static struct kmem_cache       *rpc_task_slabp __read_mostly;
+static struct kmem_cache       *rpc_buffer_slabp __read_mostly;
 static mempool_t       *rpc_task_mempool __read_mostly;
 static mempool_t       *rpc_buffer_mempool __read_mostly;
 
@@ -266,12 +266,28 @@ static int rpc_wait_bit_interruptible(void *word)
        return 0;
 }
 
+static void rpc_set_active(struct rpc_task *task)
+{
+       if (test_and_set_bit(RPC_TASK_ACTIVE, &task->tk_runstate) != 0)
+               return;
+       spin_lock(&rpc_sched_lock);
+#ifdef RPC_DEBUG
+       task->tk_magic = RPC_TASK_MAGIC_ID;
+       task->tk_pid = rpc_task_id++;
+#endif
+       /* Add to global list of all tasks */
+       list_add_tail(&task->tk_task, &all_tasks);
+       spin_unlock(&rpc_sched_lock);
+}
+
 /*
  * Mark an RPC call as having completed by clearing the 'active' bit
  */
-static inline void rpc_mark_complete_task(struct rpc_task *task)
+static void rpc_mark_complete_task(struct rpc_task *task)
 {
-       rpc_clear_active(task);
+       smp_mb__before_clear_bit();
+       clear_bit(RPC_TASK_ACTIVE, &task->tk_runstate);
+       smp_mb__after_clear_bit();
        wake_up_bit(&task->tk_runstate, RPC_TASK_ACTIVE);
 }
 
@@ -295,13 +311,15 @@ EXPORT_SYMBOL(__rpc_wait_for_completion_task);
  */
 static void rpc_make_runnable(struct rpc_task *task)
 {
-       int do_ret;
-
        BUG_ON(task->tk_timeout_fn);
-       do_ret = rpc_test_and_set_running(task);
        rpc_clear_queued(task);
-       if (do_ret)
+       if (rpc_test_and_set_running(task))
                return;
+       /* We might have raced */
+       if (RPC_IS_QUEUED(task)) {
+               rpc_clear_running(task);
+               return;
+       }
        if (RPC_IS_ASYNC(task)) {
                int status;
 
@@ -333,9 +351,6 @@ static void __rpc_sleep_on(struct rpc_wait_queue *q, struct rpc_task *task,
                return;
        }
 
-       /* Mark the task as being activated if so needed */
-       rpc_set_active(task);
-
        __rpc_add_wait_queue(q, task);
 
        BUG_ON(task->tk_callback != NULL);
@@ -346,6 +361,9 @@ static void __rpc_sleep_on(struct rpc_wait_queue *q, struct rpc_task *task,
 void rpc_sleep_on(struct rpc_wait_queue *q, struct rpc_task *task,
                                rpc_action action, rpc_action timer)
 {
+       /* Mark the task as being activated if so needed */
+       rpc_set_active(task);
+
        /*
         * Protect the queue operations.
         */
@@ -409,16 +427,19 @@ __rpc_default_timer(struct rpc_task *task)
  */
 void rpc_wake_up_task(struct rpc_task *task)
 {
+       rcu_read_lock_bh();
        if (rpc_start_wakeup(task)) {
                if (RPC_IS_QUEUED(task)) {
                        struct rpc_wait_queue *queue = task->u.tk_wait.rpc_waitq;
 
-                       spin_lock_bh(&queue->lock);
+                       /* Note: we're already in a bh-safe context */
+                       spin_lock(&queue->lock);
                        __rpc_do_wake_up_task(task);
-                       spin_unlock_bh(&queue->lock);
+                       spin_unlock(&queue->lock);
                }
                rpc_finish_wakeup(task);
        }
+       rcu_read_unlock_bh();
 }
 
 /*
@@ -481,14 +502,16 @@ struct rpc_task * rpc_wake_up_next(struct rpc_wait_queue *queue)
        struct rpc_task *task = NULL;
 
        dprintk("RPC:      wake_up_next(%p \"%s\")\n", queue, rpc_qname(queue));
-       spin_lock_bh(&queue->lock);
+       rcu_read_lock_bh();
+       spin_lock(&queue->lock);
        if (RPC_IS_PRIORITY(queue))
                task = __rpc_wake_up_next_priority(queue);
        else {
                task_for_first(task, &queue->tasks[0])
                        __rpc_wake_up_task(task);
        }
-       spin_unlock_bh(&queue->lock);
+       spin_unlock(&queue->lock);
+       rcu_read_unlock_bh();
 
        return task;
 }
@@ -504,7 +527,8 @@ void rpc_wake_up(struct rpc_wait_queue *queue)
        struct rpc_task *task, *next;
        struct list_head *head;
 
-       spin_lock_bh(&queue->lock);
+       rcu_read_lock_bh();
+       spin_lock(&queue->lock);
        head = &queue->tasks[queue->maxpriority];
        for (;;) {
                list_for_each_entry_safe(task, next, head, u.tk_wait.list)
@@ -513,7 +537,8 @@ void rpc_wake_up(struct rpc_wait_queue *queue)
                        break;
                head--;
        }
-       spin_unlock_bh(&queue->lock);
+       spin_unlock(&queue->lock);
+       rcu_read_unlock_bh();
 }
 
 /**
@@ -528,7 +553,8 @@ void rpc_wake_up_status(struct rpc_wait_queue *queue, int status)
        struct rpc_task *task, *next;
        struct list_head *head;
 
-       spin_lock_bh(&queue->lock);
+       rcu_read_lock_bh();
+       spin_lock(&queue->lock);
        head = &queue->tasks[queue->maxpriority];
        for (;;) {
                list_for_each_entry_safe(task, next, head, u.tk_wait.list) {
@@ -539,7 +565,8 @@ void rpc_wake_up_status(struct rpc_wait_queue *queue, int status)
                        break;
                head--;
        }
-       spin_unlock_bh(&queue->lock);
+       spin_unlock(&queue->lock);
+       rcu_read_unlock_bh();
 }
 
 static void __rpc_atrun(struct rpc_task *task)
@@ -561,7 +588,9 @@ void rpc_delay(struct rpc_task *task, unsigned long delay)
  */
 static void rpc_prepare_task(struct rpc_task *task)
 {
+       lock_kernel();
        task->tk_ops->rpc_call_prepare(task, task->tk_calldata);
+       unlock_kernel();
 }
 
 /*
@@ -571,7 +600,9 @@ void rpc_exit_task(struct rpc_task *task)
 {
        task->tk_action = NULL;
        if (task->tk_ops->rpc_call_done != NULL) {
+               lock_kernel();
                task->tk_ops->rpc_call_done(task, task->tk_calldata);
+               unlock_kernel();
                if (task->tk_action != NULL) {
                        WARN_ON(RPC_ASSASSINATED(task));
                        /* Always release the RPC slot and buffer memory */
@@ -581,6 +612,15 @@ void rpc_exit_task(struct rpc_task *task)
 }
 EXPORT_SYMBOL(rpc_exit_task);
 
+void rpc_release_calldata(const struct rpc_call_ops *ops, void *calldata)
+{
+       if (ops->rpc_release != NULL) {
+               lock_kernel();
+               ops->rpc_release(calldata);
+               unlock_kernel();
+       }
+}
+
 /*
  * This is the RPC `scheduler' (or rather, the finite state machine).
  */
@@ -615,9 +655,7 @@ static int __rpc_execute(struct rpc_task *task)
                         */
                        save_callback=task->tk_callback;
                        task->tk_callback=NULL;
-                       lock_kernel();
                        save_callback(task);
-                       unlock_kernel();
                }
 
                /*
@@ -628,9 +666,7 @@ static int __rpc_execute(struct rpc_task *task)
                if (!RPC_IS_QUEUED(task)) {
                        if (task->tk_action == NULL)
                                break;
-                       lock_kernel();
                        task->tk_action(task);
-                       unlock_kernel();
                }
 
                /*
@@ -671,8 +707,6 @@ static int __rpc_execute(struct rpc_task *task)
        }
 
        dprintk("RPC: %4d, return %d, status %d\n", task->tk_pid, status, task->tk_status);
-       /* Wake up anyone who is waiting for task completion */
-       rpc_mark_complete_task(task);
        /* Release all resources associated with the task */
        rpc_release_task(task);
        return status;
@@ -786,15 +820,6 @@ void rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt, int flags, cons
                        task->tk_flags |= RPC_TASK_NOINTR;
        }
 
-#ifdef RPC_DEBUG
-       task->tk_magic = RPC_TASK_MAGIC_ID;
-       task->tk_pid = rpc_task_id++;
-#endif
-       /* Add to global list of all tasks */
-       spin_lock(&rpc_sched_lock);
-       list_add_tail(&task->tk_task, &all_tasks);
-       spin_unlock(&rpc_sched_lock);
-
        BUG_ON(task->tk_ops == NULL);
 
        /* starting timestamp */
@@ -810,8 +835,9 @@ rpc_alloc_task(void)
        return (struct rpc_task *)mempool_alloc(rpc_task_mempool, GFP_NOFS);
 }
 
-static void rpc_free_task(struct rpc_task *task)
+static void rpc_free_task(struct rcu_head *rcu)
 {
+       struct rpc_task *task = container_of(rcu, struct rpc_task, u.tk_rcu);
        dprintk("RPC: %4d freeing task\n", task->tk_pid);
        mempool_free(task, rpc_task_mempool);
 }
@@ -847,16 +873,34 @@ cleanup:
        goto out;
 }
 
-void rpc_release_task(struct rpc_task *task)
+
+void rpc_put_task(struct rpc_task *task)
 {
        const struct rpc_call_ops *tk_ops = task->tk_ops;
        void *calldata = task->tk_calldata;
 
+       if (!atomic_dec_and_test(&task->tk_count))
+               return;
+       /* Release resources */
+       if (task->tk_rqstp)
+               xprt_release(task);
+       if (task->tk_msg.rpc_cred)
+               rpcauth_unbindcred(task);
+       if (task->tk_client) {
+               rpc_release_client(task->tk_client);
+               task->tk_client = NULL;
+       }
+       if (task->tk_flags & RPC_TASK_DYNAMIC)
+               call_rcu_bh(&task->u.tk_rcu, rpc_free_task);
+       rpc_release_calldata(tk_ops, calldata);
+}
+EXPORT_SYMBOL(rpc_put_task);
+
+void rpc_release_task(struct rpc_task *task)
+{
 #ifdef RPC_DEBUG
        BUG_ON(task->tk_magic != RPC_TASK_MAGIC_ID);
 #endif
-       if (!atomic_dec_and_test(&task->tk_count))
-               return;
        dprintk("RPC: %4d release task\n", task->tk_pid);
 
        /* Remove from global task list */
@@ -869,23 +913,13 @@ void rpc_release_task(struct rpc_task *task)
        /* Synchronously delete any running timer */
        rpc_delete_timer(task);
 
-       /* Release resources */
-       if (task->tk_rqstp)
-               xprt_release(task);
-       if (task->tk_msg.rpc_cred)
-               rpcauth_unbindcred(task);
-       if (task->tk_client) {
-               rpc_release_client(task->tk_client);
-               task->tk_client = NULL;
-       }
-
 #ifdef RPC_DEBUG
        task->tk_magic = 0;
 #endif
-       if (task->tk_flags & RPC_TASK_DYNAMIC)
-               rpc_free_task(task);
-       if (tk_ops->rpc_release)
-               tk_ops->rpc_release(calldata);
+       /* Wake up anyone who is waiting for task completion */
+       rpc_mark_complete_task(task);
+
+       rpc_put_task(task);
 }
 
 /**
@@ -902,8 +936,7 @@ struct rpc_task *rpc_run_task(struct rpc_clnt *clnt, int flags,
        struct rpc_task *task;
        task = rpc_new_task(clnt, flags, ops, data);
        if (task == NULL) {
-               if (ops->rpc_release != NULL)
-                       ops->rpc_release(data);
+               rpc_release_calldata(ops, data);
                return ERR_PTR(-ENOMEM);
        }
        atomic_inc(&task->tk_count);
index 2635c543ba067979f4d31b95227117d1451ded73..634885b0c04dcc5e6e4909297b7368e73898086d 100644 (file)
@@ -16,7 +16,7 @@
 
 
 /**
- * skb_read_bits - copy some data bits from skb to internal buffer
+ * xdr_skb_read_bits - copy some data bits from skb to internal buffer
  * @desc: sk_buff copy helper
  * @to: copy destination
  * @len: number of bytes to copy
  * Possibly called several times to iterate over an sk_buff and copy
  * data out of it.
  */
-static size_t skb_read_bits(skb_reader_t *desc, void *to, size_t len)
+size_t xdr_skb_read_bits(struct xdr_skb_reader *desc, void *to, size_t len)
 {
        if (len > desc->count)
                len = desc->count;
-       if (skb_copy_bits(desc->skb, desc->offset, to, len))
+       if (unlikely(skb_copy_bits(desc->skb, desc->offset, to, len)))
                return 0;
        desc->count -= len;
        desc->offset += len;
@@ -36,14 +36,14 @@ static size_t skb_read_bits(skb_reader_t *desc, void *to, size_t len)
 }
 
 /**
- * skb_read_and_csum_bits - copy and checksum from skb to buffer
+ * xdr_skb_read_and_csum_bits - copy and checksum from skb to buffer
  * @desc: sk_buff copy helper
  * @to: copy destination
  * @len: number of bytes to copy
  *
  * Same as skb_read_bits, but calculate a checksum at the same time.
  */
-static size_t skb_read_and_csum_bits(skb_reader_t *desc, void *to, size_t len)
+static size_t xdr_skb_read_and_csum_bits(struct xdr_skb_reader *desc, void *to, size_t len)
 {
        unsigned int pos;
        __wsum csum2;
@@ -66,7 +66,7 @@ static size_t skb_read_and_csum_bits(skb_reader_t *desc, void *to, size_t len)
  * @copy_actor: virtual method for copying data
  *
  */
-ssize_t xdr_partial_copy_from_skb(struct xdr_buf *xdr, unsigned int base, skb_reader_t *desc, skb_read_actor_t copy_actor)
+ssize_t xdr_partial_copy_from_skb(struct xdr_buf *xdr, unsigned int base, struct xdr_skb_reader *desc, xdr_skb_read_actor copy_actor)
 {
        struct page     **ppage = xdr->pages;
        unsigned int    len, pglen = xdr->page_len;
@@ -148,7 +148,7 @@ out:
  */
 int csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb)
 {
-       skb_reader_t    desc;
+       struct xdr_skb_reader   desc;
 
        desc.skb = skb;
        desc.offset = sizeof(struct udphdr);
@@ -158,7 +158,7 @@ int csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb)
                goto no_checksum;
 
        desc.csum = csum_partial(skb->data, desc.offset, skb->csum);
-       if (xdr_partial_copy_from_skb(xdr, 0, &desc, skb_read_and_csum_bits) < 0)
+       if (xdr_partial_copy_from_skb(xdr, 0, &desc, xdr_skb_read_and_csum_bits) < 0)
                return -1;
        if (desc.offset != skb->len) {
                __wsum csum2;
@@ -173,7 +173,7 @@ int csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb)
                netdev_rx_csum_fault(skb->dev);
        return 0;
 no_checksum:
-       if (xdr_partial_copy_from_skb(xdr, 0, &desc, skb_read_bits) < 0)
+       if (xdr_partial_copy_from_skb(xdr, 0, &desc, xdr_skb_read_bits) < 0)
                return -1;
        if (desc.count)
                return -1;
index 192dff5dabcbc76258a378179d7132f5e3845bf8..d85fddeb6388f54e4293b85e1e64da965c2ebd76 100644 (file)
@@ -33,7 +33,6 @@ EXPORT_SYMBOL(rpciod_down);
 EXPORT_SYMBOL(rpciod_up);
 EXPORT_SYMBOL(rpc_new_task);
 EXPORT_SYMBOL(rpc_wake_up_status);
-EXPORT_SYMBOL(rpc_release_task);
 
 /* RPC client functions */
 EXPORT_SYMBOL(rpc_clone_client);
@@ -139,6 +138,8 @@ EXPORT_SYMBOL(nlm_debug);
 extern int register_rpc_pipefs(void);
 extern void unregister_rpc_pipefs(void);
 extern struct cache_detail ip_map_cache;
+extern int init_socket_xprt(void);
+extern void cleanup_socket_xprt(void);
 
 static int __init
 init_sunrpc(void)
@@ -156,6 +157,7 @@ init_sunrpc(void)
        rpc_proc_init();
 #endif
        cache_register(&ip_map_cache);
+       init_socket_xprt();
 out:
        return err;
 }
@@ -163,6 +165,7 @@ out:
 static void __exit
 cleanup_sunrpc(void)
 {
+       cleanup_socket_xprt();
        unregister_rpc_pipefs();
        rpc_destroy_mempool();
        if (cache_unregister(&ip_map_cache))
index ee9bb1522d5ecb54c245d060af9669edf34cd216..c7bb5f7f21a587213a4003ec1f5218492a579d3d 100644 (file)
@@ -119,7 +119,8 @@ EXPORT_SYMBOL(svc_auth_unregister);
 #define        DN_HASHMASK     (DN_HASHMAX-1)
 
 static struct hlist_head       auth_domain_table[DN_HASHMAX];
-static spinlock_t      auth_domain_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t      auth_domain_lock =
+       __SPIN_LOCK_UNLOCKED(auth_domain_lock);
 
 void auth_domain_put(struct auth_domain *dom)
 {
index 64ca1f61dd9497fde7cb31a235468ea1c2606fbe..99f54fb6d66903ae9b9887c76e4138838f60a43a 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
 #include <linux/file.h>
+#include <linux/freezer.h>
 #include <net/sock.h>
 #include <net/checksum.h>
 #include <net/ip.h>
@@ -84,6 +85,35 @@ static struct cache_deferred_req *svc_defer(struct cache_req *req);
  */
 static int svc_conn_age_period = 6*60;
 
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+static struct lock_class_key svc_key[2];
+static struct lock_class_key svc_slock_key[2];
+
+static inline void svc_reclassify_socket(struct socket *sock)
+{
+       struct sock *sk = sock->sk;
+       BUG_ON(sk->sk_lock.owner != NULL);
+       switch (sk->sk_family) {
+       case AF_INET:
+               sock_lock_init_class_and_name(sk, "slock-AF_INET-NFSD",
+                   &svc_slock_key[0], "sk_lock-AF_INET-NFSD", &svc_key[0]);
+               break;
+
+       case AF_INET6:
+               sock_lock_init_class_and_name(sk, "slock-AF_INET6-NFSD",
+                   &svc_slock_key[1], "sk_lock-AF_INET6-NFSD", &svc_key[1]);
+               break;
+
+       default:
+               BUG();
+       }
+}
+#else
+static inline void svc_reclassify_socket(struct socket *sock)
+{
+}
+#endif
+
 /*
  * Queue up an idle server thread.  Must have pool->sp_lock held.
  * Note: this is really a stack rather than a queue, so that we only
@@ -1556,6 +1586,8 @@ svc_create_socket(struct svc_serv *serv, int protocol, struct sockaddr_in *sin)
        if ((error = sock_create_kern(PF_INET, type, protocol, &sock)) < 0)
                return error;
 
+       svc_reclassify_socket(sock);
+
        if (type == SOCK_STREAM)
                sock->sk->sk_reuse = 1; /* allow address reuse */
        error = kernel_bind(sock, (struct sockaddr *) sin,
index d89b048ad6bba57a4964c72a216a93d3a3bff4fd..82b27528d0c45b50b2b25416b84b9f03b1d6ac74 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/sunrpc/types.h>
 #include <linux/sunrpc/sched.h>
 #include <linux/sunrpc/stats.h>
-#include <linux/sunrpc/xprt.h>
 
 /*
  * Declare the debug flags here
@@ -119,11 +118,6 @@ done:
 }
 
 
-static unsigned int min_slot_table_size = RPC_MIN_SLOT_TABLE;
-static unsigned int max_slot_table_size = RPC_MAX_SLOT_TABLE;
-static unsigned int xprt_min_resvport_limit = RPC_MIN_RESVPORT;
-static unsigned int xprt_max_resvport_limit = RPC_MAX_RESVPORT;
-
 static ctl_table debug_table[] = {
        {
                .ctl_name       = CTL_RPCDEBUG,
@@ -157,50 +151,6 @@ static ctl_table debug_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dodebug
        }, 
-       {
-               .ctl_name       = CTL_SLOTTABLE_UDP,
-               .procname       = "udp_slot_table_entries",
-               .data           = &xprt_udp_slot_table_entries,
-               .maxlen         = sizeof(unsigned int),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec_minmax,
-               .strategy       = &sysctl_intvec,
-               .extra1         = &min_slot_table_size,
-               .extra2         = &max_slot_table_size
-       },
-       {
-               .ctl_name       = CTL_SLOTTABLE_TCP,
-               .procname       = "tcp_slot_table_entries",
-               .data           = &xprt_tcp_slot_table_entries,
-               .maxlen         = sizeof(unsigned int),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec_minmax,
-               .strategy       = &sysctl_intvec,
-               .extra1         = &min_slot_table_size,
-               .extra2         = &max_slot_table_size
-       },
-       {
-               .ctl_name       = CTL_MIN_RESVPORT,
-               .procname       = "min_resvport",
-               .data           = &xprt_min_resvport,
-               .maxlen         = sizeof(unsigned int),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec_minmax,
-               .strategy       = &sysctl_intvec,
-               .extra1         = &xprt_min_resvport_limit,
-               .extra2         = &xprt_max_resvport_limit
-       },
-       {
-               .ctl_name       = CTL_MAX_RESVPORT,
-               .procname       = "max_resvport",
-               .data           = &xprt_max_resvport,
-               .maxlen         = sizeof(unsigned int),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec_minmax,
-               .strategy       = &sysctl_intvec,
-               .extra1         = &xprt_min_resvport_limit,
-               .extra2         = &xprt_max_resvport_limit
-       },
        { .ctl_name = 0 }
 };
 
index 9022eb8b37ed9d05ea2e1bd983747b49b4c0ff7b..a0af250ca319752a6c940ff6be4ef7beebc937f2 100644 (file)
@@ -640,41 +640,30 @@ xdr_buf_from_iov(struct kvec *iov, struct xdr_buf *buf)
        buf->buflen = buf->len = iov->iov_len;
 }
 
-/* Sets subiov to the intersection of iov with the buffer of length len
- * starting base bytes after iov.  Indicates empty intersection by setting
- * length of subiov to zero.  Decrements len by length of subiov, sets base
- * to zero (or decrements it by length of iov if subiov is empty). */
-static void
-iov_subsegment(struct kvec *iov, struct kvec *subiov, int *base, int *len)
-{
-       if (*base > iov->iov_len) {
-               subiov->iov_base = NULL;
-               subiov->iov_len = 0;
-               *base -= iov->iov_len;
-       } else {
-               subiov->iov_base = iov->iov_base + *base;
-               subiov->iov_len = min(*len, (int)iov->iov_len - *base);
-               *base = 0;
-       }
-       *len -= subiov->iov_len; 
-}
-
 /* Sets subbuf to the portion of buf of length len beginning base bytes
  * from the start of buf. Returns -1 if base of length are out of bounds. */
 int
 xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf,
-                       int base, int len)
+                       unsigned int base, unsigned int len)
 {
-       int i;
-
        subbuf->buflen = subbuf->len = len;
-       iov_subsegment(buf->head, subbuf->head, &base, &len);
+       if (base < buf->head[0].iov_len) {
+               subbuf->head[0].iov_base = buf->head[0].iov_base + base;
+               subbuf->head[0].iov_len = min_t(unsigned int, len,
+                                               buf->head[0].iov_len - base);
+               len -= subbuf->head[0].iov_len;
+               base = 0;
+       } else {
+               subbuf->head[0].iov_base = NULL;
+               subbuf->head[0].iov_len = 0;
+               base -= buf->head[0].iov_len;
+       }
 
        if (base < buf->page_len) {
-               i = (base + buf->page_base) >> PAGE_CACHE_SHIFT;
-               subbuf->pages = &buf->pages[i];
-               subbuf->page_base = (base + buf->page_base) & ~PAGE_CACHE_MASK;
-               subbuf->page_len = min((int)buf->page_len - base, len);
+               subbuf->page_len = min(buf->page_len - base, len);
+               base += buf->page_base;
+               subbuf->page_base = base & ~PAGE_CACHE_MASK;
+               subbuf->pages = &buf->pages[base >> PAGE_CACHE_SHIFT];
                len -= subbuf->page_len;
                base = 0;
        } else {
@@ -682,66 +671,85 @@ xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf,
                subbuf->page_len = 0;
        }
 
-       iov_subsegment(buf->tail, subbuf->tail, &base, &len);
+       if (base < buf->tail[0].iov_len) {
+               subbuf->tail[0].iov_base = buf->tail[0].iov_base + base;
+               subbuf->tail[0].iov_len = min_t(unsigned int, len,
+                                               buf->tail[0].iov_len - base);
+               len -= subbuf->tail[0].iov_len;
+               base = 0;
+       } else {
+               subbuf->tail[0].iov_base = NULL;
+               subbuf->tail[0].iov_len = 0;
+               base -= buf->tail[0].iov_len;
+       }
+
        if (base || len)
                return -1;
        return 0;
 }
 
-/* obj is assumed to point to allocated memory of size at least len: */
-int
-read_bytes_from_xdr_buf(struct xdr_buf *buf, int base, void *obj, int len)
+static void __read_bytes_from_xdr_buf(struct xdr_buf *subbuf, void *obj, unsigned int len)
 {
-       struct xdr_buf subbuf;
-       int this_len;
-       int status;
+       unsigned int this_len;
 
-       status = xdr_buf_subsegment(buf, &subbuf, base, len);
-       if (status)
-               goto out;
-       this_len = min(len, (int)subbuf.head[0].iov_len);
-       memcpy(obj, subbuf.head[0].iov_base, this_len);
+       this_len = min_t(unsigned int, len, subbuf->head[0].iov_len);
+       memcpy(obj, subbuf->head[0].iov_base, this_len);
        len -= this_len;
        obj += this_len;
-       this_len = min(len, (int)subbuf.page_len);
+       this_len = min_t(unsigned int, len, subbuf->page_len);
        if (this_len)
-               _copy_from_pages(obj, subbuf.pages, subbuf.page_base, this_len);
+               _copy_from_pages(obj, subbuf->pages, subbuf->page_base, this_len);
        len -= this_len;
        obj += this_len;
-       this_len = min(len, (int)subbuf.tail[0].iov_len);
-       memcpy(obj, subbuf.tail[0].iov_base, this_len);
-out:
-       return status;
+       this_len = min_t(unsigned int, len, subbuf->tail[0].iov_len);
+       memcpy(obj, subbuf->tail[0].iov_base, this_len);
 }
 
 /* obj is assumed to point to allocated memory of size at least len: */
-int
-write_bytes_to_xdr_buf(struct xdr_buf *buf, int base, void *obj, int len)
+int read_bytes_from_xdr_buf(struct xdr_buf *buf, unsigned int base, void *obj, unsigned int len)
 {
        struct xdr_buf subbuf;
-       int this_len;
        int status;
 
        status = xdr_buf_subsegment(buf, &subbuf, base, len);
-       if (status)
-               goto out;
-       this_len = min(len, (int)subbuf.head[0].iov_len);
-       memcpy(subbuf.head[0].iov_base, obj, this_len);
+       if (status != 0)
+               return status;
+       __read_bytes_from_xdr_buf(&subbuf, obj, len);
+       return 0;
+}
+
+static void __write_bytes_to_xdr_buf(struct xdr_buf *subbuf, void *obj, unsigned int len)
+{
+       unsigned int this_len;
+
+       this_len = min_t(unsigned int, len, subbuf->head[0].iov_len);
+       memcpy(subbuf->head[0].iov_base, obj, this_len);
        len -= this_len;
        obj += this_len;
-       this_len = min(len, (int)subbuf.page_len);
+       this_len = min_t(unsigned int, len, subbuf->page_len);
        if (this_len)
-               _copy_to_pages(subbuf.pages, subbuf.page_base, obj, this_len);
+               _copy_to_pages(subbuf->pages, subbuf->page_base, obj, this_len);
        len -= this_len;
        obj += this_len;
-       this_len = min(len, (int)subbuf.tail[0].iov_len);
-       memcpy(subbuf.tail[0].iov_base, obj, this_len);
-out:
-       return status;
+       this_len = min_t(unsigned int, len, subbuf->tail[0].iov_len);
+       memcpy(subbuf->tail[0].iov_base, obj, this_len);
+}
+
+/* obj is assumed to point to allocated memory of size at least len: */
+int write_bytes_to_xdr_buf(struct xdr_buf *buf, unsigned int base, void *obj, unsigned int len)
+{
+       struct xdr_buf subbuf;
+       int status;
+
+       status = xdr_buf_subsegment(buf, &subbuf, base, len);
+       if (status != 0)
+               return status;
+       __write_bytes_to_xdr_buf(&subbuf, obj, len);
+       return 0;
 }
 
 int
-xdr_decode_word(struct xdr_buf *buf, int base, u32 *obj)
+xdr_decode_word(struct xdr_buf *buf, unsigned int base, u32 *obj)
 {
        __be32  raw;
        int     status;
@@ -754,7 +762,7 @@ xdr_decode_word(struct xdr_buf *buf, int base, u32 *obj)
 }
 
 int
-xdr_encode_word(struct xdr_buf *buf, int base, u32 obj)
+xdr_encode_word(struct xdr_buf *buf, unsigned int base, u32 obj)
 {
        __be32  raw = htonl(obj);
 
@@ -765,44 +773,37 @@ xdr_encode_word(struct xdr_buf *buf, int base, u32 obj)
  * entirely in the head or the tail, set object to point to it; otherwise
  * try to find space for it at the end of the tail, copy it there, and
  * set obj to point to it. */
-int
-xdr_buf_read_netobj(struct xdr_buf *buf, struct xdr_netobj *obj, int offset)
+int xdr_buf_read_netobj(struct xdr_buf *buf, struct xdr_netobj *obj, unsigned int offset)
 {
-       u32     tail_offset = buf->head[0].iov_len + buf->page_len;
-       u32     obj_end_offset;
+       struct xdr_buf subbuf;
 
        if (xdr_decode_word(buf, offset, &obj->len))
-               goto out;
-       obj_end_offset = offset + 4 + obj->len;
-
-       if (obj_end_offset <= buf->head[0].iov_len) {
-               /* The obj is contained entirely in the head: */
-               obj->data = buf->head[0].iov_base + offset + 4;
-       } else if (offset + 4 >= tail_offset) {
-               if (obj_end_offset - tail_offset
-                               > buf->tail[0].iov_len)
-                       goto out;
-               /* The obj is contained entirely in the tail: */
-               obj->data = buf->tail[0].iov_base
-                       + offset - tail_offset + 4;
-       } else {
-               /* use end of tail as storage for obj:
-                * (We don't copy to the beginning because then we'd have
-                * to worry about doing a potentially overlapping copy.
-                * This assumes the object is at most half the length of the
-                * tail.) */
-               if (obj->len > buf->tail[0].iov_len)
-                       goto out;
-               obj->data = buf->tail[0].iov_base + buf->tail[0].iov_len - 
-                               obj->len;
-               if (read_bytes_from_xdr_buf(buf, offset + 4,
-                                       obj->data, obj->len))
-                       goto out;
+               return -EFAULT;
+       if (xdr_buf_subsegment(buf, &subbuf, offset + 4, obj->len))
+               return -EFAULT;
 
-       }
+       /* Is the obj contained entirely in the head? */
+       obj->data = subbuf.head[0].iov_base;
+       if (subbuf.head[0].iov_len == obj->len)
+               return 0;
+       /* ..or is the obj contained entirely in the tail? */
+       obj->data = subbuf.tail[0].iov_base;
+       if (subbuf.tail[0].iov_len == obj->len)
+               return 0;
+
+       /* use end of tail as storage for obj:
+        * (We don't copy to the beginning because then we'd have
+        * to worry about doing a potentially overlapping copy.
+        * This assumes the object is at most half the length of the
+        * tail.) */
+       if (obj->len > buf->buflen - buf->len)
+               return -ENOMEM;
+       if (buf->tail[0].iov_len != 0)
+               obj->data = buf->tail[0].iov_base + buf->tail[0].iov_len;
+       else
+               obj->data = buf->head[0].iov_base + buf->head[0].iov_len;
+       __read_bytes_from_xdr_buf(&subbuf, obj->data, obj->len);
        return 0;
-out:
-       return -1;
 }
 
 /* Returns 0 on success, or else a negative error code. */
@@ -1020,3 +1021,71 @@ xdr_encode_array2(struct xdr_buf *buf, unsigned int base,
 
        return xdr_xcode_array2(buf, base, desc, 1);
 }
+
+int
+xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len,
+                int (*actor)(struct scatterlist *, void *), void *data)
+{
+       int i, ret = 0;
+       unsigned page_len, thislen, page_offset;
+       struct scatterlist      sg[1];
+
+       if (offset >= buf->head[0].iov_len) {
+               offset -= buf->head[0].iov_len;
+       } else {
+               thislen = buf->head[0].iov_len - offset;
+               if (thislen > len)
+                       thislen = len;
+               sg_set_buf(sg, buf->head[0].iov_base + offset, thislen);
+               ret = actor(sg, data);
+               if (ret)
+                       goto out;
+               offset = 0;
+               len -= thislen;
+       }
+       if (len == 0)
+               goto out;
+
+       if (offset >= buf->page_len) {
+               offset -= buf->page_len;
+       } else {
+               page_len = buf->page_len - offset;
+               if (page_len > len)
+                       page_len = len;
+               len -= page_len;
+               page_offset = (offset + buf->page_base) & (PAGE_CACHE_SIZE - 1);
+               i = (offset + buf->page_base) >> PAGE_CACHE_SHIFT;
+               thislen = PAGE_CACHE_SIZE - page_offset;
+               do {
+                       if (thislen > page_len)
+                               thislen = page_len;
+                       sg->page = buf->pages[i];
+                       sg->offset = page_offset;
+                       sg->length = thislen;
+                       ret = actor(sg, data);
+                       if (ret)
+                               goto out;
+                       page_len -= thislen;
+                       i++;
+                       page_offset = 0;
+                       thislen = PAGE_CACHE_SIZE;
+               } while (page_len != 0);
+               offset = 0;
+       }
+       if (len == 0)
+               goto out;
+       if (offset < buf->tail[0].iov_len) {
+               thislen = buf->tail[0].iov_len - offset;
+               if (thislen > len)
+                       thislen = len;
+               sg_set_buf(sg, buf->tail[0].iov_base + offset, thislen);
+               ret = actor(sg, data);
+               len -= thislen;
+       }
+       if (len != 0)
+               ret = -EINVAL;
+out:
+       return ret;
+}
+EXPORT_SYMBOL(xdr_process_buf);
+
index 4f9a5d9791fb11fabeff5d1eb48b191ac070d3d9..7a3999f0a4a2aabc7e156bdb459a68a5cab7d6a7 100644 (file)
@@ -459,7 +459,6 @@ int xprt_adjust_timeout(struct rpc_rqst *req)
                if (to->to_maxval && req->rq_timeout >= to->to_maxval)
                        req->rq_timeout = to->to_maxval;
                req->rq_retries++;
-               pprintk("RPC: %lu retrans\n", jiffies);
        } else {
                req->rq_timeout = to->to_initval;
                req->rq_retries = 0;
@@ -468,7 +467,6 @@ int xprt_adjust_timeout(struct rpc_rqst *req)
                spin_lock_bh(&xprt->transport_lock);
                rpc_init_rtt(req->rq_task->tk_client->cl_rtt, to->to_initval);
                spin_unlock_bh(&xprt->transport_lock);
-               pprintk("RPC: %lu timeout\n", jiffies);
                status = -ETIMEDOUT;
        }
 
@@ -892,39 +890,25 @@ void xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long i
  */
 struct rpc_xprt *xprt_create_transport(int proto, struct sockaddr *ap, size_t size, struct rpc_timeout *to)
 {
-       int result;
        struct rpc_xprt *xprt;
        struct rpc_rqst *req;
 
-       if ((xprt = kzalloc(sizeof(struct rpc_xprt), GFP_KERNEL)) == NULL) {
-               dprintk("RPC:      xprt_create_transport: no memory\n");
-               return ERR_PTR(-ENOMEM);
-       }
-       if (size <= sizeof(xprt->addr)) {
-               memcpy(&xprt->addr, ap, size);
-               xprt->addrlen = size;
-       } else {
-               kfree(xprt);
-               dprintk("RPC:      xprt_create_transport: address too large\n");
-               return ERR_PTR(-EBADF);
-       }
-
        switch (proto) {
        case IPPROTO_UDP:
-               result = xs_setup_udp(xprt, to);
+               xprt = xs_setup_udp(ap, size, to);
                break;
        case IPPROTO_TCP:
-               result = xs_setup_tcp(xprt, to);
+               xprt = xs_setup_tcp(ap, size, to);
                break;
        default:
                printk(KERN_ERR "RPC: unrecognized transport protocol: %d\n",
                                proto);
                return ERR_PTR(-EIO);
        }
-       if (result) {
-               kfree(xprt);
-               dprintk("RPC:      xprt_create_transport: failed, %d\n", result);
-               return ERR_PTR(result);
+       if (IS_ERR(xprt)) {
+               dprintk("RPC:      xprt_create_transport: failed, %ld\n",
+                               -PTR_ERR(xprt));
+               return xprt;
        }
 
        kref_init(&xprt->kref);
@@ -970,8 +954,11 @@ static void xprt_destroy(struct kref *kref)
        dprintk("RPC:      destroying transport %p\n", xprt);
        xprt->shutdown = 1;
        del_timer_sync(&xprt->timer);
+
+       /*
+        * Tear down transport state and free the rpc_xprt
+        */
        xprt->ops->destroy(xprt);
-       kfree(xprt);
 }
 
 /**
index cfe3c15be94895cb606b0184ab0855af5eefb11b..49cabffd7fdb87a884a9416b9a46b5848d509506 100644 (file)
@@ -45,6 +45,92 @@ unsigned int xprt_tcp_slot_table_entries = RPC_DEF_SLOT_TABLE;
 unsigned int xprt_min_resvport = RPC_DEF_MIN_RESVPORT;
 unsigned int xprt_max_resvport = RPC_DEF_MAX_RESVPORT;
 
+/*
+ * We can register our own files under /proc/sys/sunrpc by
+ * calling register_sysctl_table() again.  The files in that
+ * directory become the union of all files registered there.
+ *
+ * We simply need to make sure that we don't collide with
+ * someone else's file names!
+ */
+
+#ifdef RPC_DEBUG
+
+static unsigned int min_slot_table_size = RPC_MIN_SLOT_TABLE;
+static unsigned int max_slot_table_size = RPC_MAX_SLOT_TABLE;
+static unsigned int xprt_min_resvport_limit = RPC_MIN_RESVPORT;
+static unsigned int xprt_max_resvport_limit = RPC_MAX_RESVPORT;
+
+static struct ctl_table_header *sunrpc_table_header;
+
+/*
+ * FIXME: changing the UDP slot table size should also resize the UDP
+ *        socket buffers for existing UDP transports
+ */
+static ctl_table xs_tunables_table[] = {
+       {
+               .ctl_name       = CTL_SLOTTABLE_UDP,
+               .procname       = "udp_slot_table_entries",
+               .data           = &xprt_udp_slot_table_entries,
+               .maxlen         = sizeof(unsigned int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec_minmax,
+               .strategy       = &sysctl_intvec,
+               .extra1         = &min_slot_table_size,
+               .extra2         = &max_slot_table_size
+       },
+       {
+               .ctl_name       = CTL_SLOTTABLE_TCP,
+               .procname       = "tcp_slot_table_entries",
+               .data           = &xprt_tcp_slot_table_entries,
+               .maxlen         = sizeof(unsigned int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec_minmax,
+               .strategy       = &sysctl_intvec,
+               .extra1         = &min_slot_table_size,
+               .extra2         = &max_slot_table_size
+       },
+       {
+               .ctl_name       = CTL_MIN_RESVPORT,
+               .procname       = "min_resvport",
+               .data           = &xprt_min_resvport,
+               .maxlen         = sizeof(unsigned int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec_minmax,
+               .strategy       = &sysctl_intvec,
+               .extra1         = &xprt_min_resvport_limit,
+               .extra2         = &xprt_max_resvport_limit
+       },
+       {
+               .ctl_name       = CTL_MAX_RESVPORT,
+               .procname       = "max_resvport",
+               .data           = &xprt_max_resvport,
+               .maxlen         = sizeof(unsigned int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec_minmax,
+               .strategy       = &sysctl_intvec,
+               .extra1         = &xprt_min_resvport_limit,
+               .extra2         = &xprt_max_resvport_limit
+       },
+       {
+               .ctl_name = 0,
+       },
+};
+
+static ctl_table sunrpc_table[] = {
+       {
+               .ctl_name       = CTL_SUNRPC,
+               .procname       = "sunrpc",
+               .mode           = 0555,
+               .child          = xs_tunables_table
+       },
+       {
+               .ctl_name = 0,
+       },
+};
+
+#endif
+
 /*
  * How many times to try sending a request on a socket before waiting
  * for the socket buffer to clear.
@@ -125,6 +211,55 @@ static inline void xs_pktdump(char *msg, u32 *packet, unsigned int count)
 }
 #endif
 
+struct sock_xprt {
+       struct rpc_xprt         xprt;
+
+       /*
+        * Network layer
+        */
+       struct socket *         sock;
+       struct sock *           inet;
+
+       /*
+        * State of TCP reply receive
+        */
+       __be32                  tcp_fraghdr,
+                               tcp_xid;
+
+       u32                     tcp_offset,
+                               tcp_reclen;
+
+       unsigned long           tcp_copied,
+                               tcp_flags;
+
+       /*
+        * Connection of transports
+        */
+       struct delayed_work     connect_worker;
+       unsigned short          port;
+
+       /*
+        * UDP socket buffer size parameters
+        */
+       size_t                  rcvsize,
+                               sndsize;
+
+       /*
+        * Saved socket callback addresses
+        */
+       void                    (*old_data_ready)(struct sock *, int);
+       void                    (*old_state_change)(struct sock *);
+       void                    (*old_write_space)(struct sock *);
+};
+
+/*
+ * TCP receive state flags
+ */
+#define TCP_RCV_LAST_FRAG      (1UL << 0)
+#define TCP_RCV_COPY_FRAGHDR   (1UL << 1)
+#define TCP_RCV_COPY_XID       (1UL << 2)
+#define TCP_RCV_COPY_DATA      (1UL << 3)
+
 static void xs_format_peer_addresses(struct rpc_xprt *xprt)
 {
        struct sockaddr_in *addr = (struct sockaddr_in *) &xprt->addr;
@@ -168,37 +303,52 @@ static void xs_free_peer_addresses(struct rpc_xprt *xprt)
 
 #define XS_SENDMSG_FLAGS       (MSG_DONTWAIT | MSG_NOSIGNAL)
 
-static inline int xs_send_head(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base, unsigned int len)
+static int xs_send_kvec(struct socket *sock, struct sockaddr *addr, int addrlen, struct kvec *vec, unsigned int base, int more)
 {
-       struct kvec iov = {
-               .iov_base       = xdr->head[0].iov_base + base,
-               .iov_len        = len - base,
-       };
        struct msghdr msg = {
                .msg_name       = addr,
                .msg_namelen    = addrlen,
-               .msg_flags      = XS_SENDMSG_FLAGS,
+               .msg_flags      = XS_SENDMSG_FLAGS | (more ? MSG_MORE : 0),
+       };
+       struct kvec iov = {
+               .iov_base       = vec->iov_base + base,
+               .iov_len        = vec->iov_len - base,
        };
 
-       if (xdr->len > len)
-               msg.msg_flags |= MSG_MORE;
-
-       if (likely(iov.iov_len))
+       if (iov.iov_len != 0)
                return kernel_sendmsg(sock, &msg, &iov, 1, iov.iov_len);
        return kernel_sendmsg(sock, &msg, NULL, 0, 0);
 }
 
-static int xs_send_tail(struct socket *sock, struct xdr_buf *xdr, unsigned int base, unsigned int len)
+static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more)
 {
-       struct kvec iov = {
-               .iov_base       = xdr->tail[0].iov_base + base,
-               .iov_len        = len - base,
-       };
-       struct msghdr msg = {
-               .msg_flags      = XS_SENDMSG_FLAGS,
-       };
+       struct page **ppage;
+       unsigned int remainder;
+       int err, sent = 0;
+
+       remainder = xdr->page_len - base;
+       base += xdr->page_base;
+       ppage = xdr->pages + (base >> PAGE_SHIFT);
+       base &= ~PAGE_MASK;
+       for(;;) {
+               unsigned int len = min_t(unsigned int, PAGE_SIZE - base, remainder);
+               int flags = XS_SENDMSG_FLAGS;
 
-       return kernel_sendmsg(sock, &msg, &iov, 1, iov.iov_len);
+               remainder -= len;
+               if (remainder != 0 || more)
+                       flags |= MSG_MORE;
+               err = sock->ops->sendpage(sock, *ppage, base, len, flags);
+               if (remainder == 0 || err != len)
+                       break;
+               sent += err;
+               ppage++;
+               base = 0;
+       }
+       if (sent == 0)
+               return err;
+       if (err > 0)
+               sent += err;
+       return sent;
 }
 
 /**
@@ -210,76 +360,51 @@ static int xs_send_tail(struct socket *sock, struct xdr_buf *xdr, unsigned int b
  * @base: starting position in the buffer
  *
  */
-static inline int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base)
+static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base)
 {
-       struct page **ppage = xdr->pages;
-       unsigned int len, pglen = xdr->page_len;
-       int err, ret = 0;
+       unsigned int remainder = xdr->len - base;
+       int err, sent = 0;
 
        if (unlikely(!sock))
                return -ENOTCONN;
 
        clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags);
+       if (base != 0) {
+               addr = NULL;
+               addrlen = 0;
+       }
 
-       len = xdr->head[0].iov_len;
-       if (base < len || (addr != NULL && base == 0)) {
-               err = xs_send_head(sock, addr, addrlen, xdr, base, len);
-               if (ret == 0)
-                       ret = err;
-               else if (err > 0)
-                       ret += err;
-               if (err != (len - base))
+       if (base < xdr->head[0].iov_len || addr != NULL) {
+               unsigned int len = xdr->head[0].iov_len - base;
+               remainder -= len;
+               err = xs_send_kvec(sock, addr, addrlen, &xdr->head[0], base, remainder != 0);
+               if (remainder == 0 || err != len)
                        goto out;
+               sent += err;
                base = 0;
        } else
-               base -= len;
+               base -= xdr->head[0].iov_len;
 
-       if (unlikely(pglen == 0))
-               goto copy_tail;
-       if (unlikely(base >= pglen)) {
-               base -= pglen;
-               goto copy_tail;
-       }
-       if (base || xdr->page_base) {
-               pglen -= base;
-               base += xdr->page_base;
-               ppage += base >> PAGE_CACHE_SHIFT;
-               base &= ~PAGE_CACHE_MASK;
-       }
-
-       do {
-               int flags = XS_SENDMSG_FLAGS;
-
-               len = PAGE_CACHE_SIZE;
-               if (base)
-                       len -= base;
-               if (pglen < len)
-                       len = pglen;
-
-               if (pglen != len || xdr->tail[0].iov_len != 0)
-                       flags |= MSG_MORE;
-
-               err = kernel_sendpage(sock, *ppage, base, len, flags);
-               if (ret == 0)
-                       ret = err;
-               else if (err > 0)
-                       ret += err;
-               if (err != len)
+       if (base < xdr->page_len) {
+               unsigned int len = xdr->page_len - base;
+               remainder -= len;
+               err = xs_send_pagedata(sock, xdr, base, remainder != 0);
+               if (remainder == 0 || err != len)
                        goto out;
+               sent += err;
                base = 0;
-               ppage++;
-       } while ((pglen -= len) != 0);
-copy_tail:
-       len = xdr->tail[0].iov_len;
-       if (base < len) {
-               err = xs_send_tail(sock, xdr, base, len);
-               if (ret == 0)
-                       ret = err;
-               else if (err > 0)
-                       ret += err;
-       }
+       } else
+               base -= xdr->page_len;
+
+       if (base >= xdr->tail[0].iov_len)
+               return sent;
+       err = xs_send_kvec(sock, NULL, 0, &xdr->tail[0], base, 0);
 out:
-       return ret;
+       if (sent == 0)
+               return err;
+       if (err > 0)
+               sent += err;
+       return sent;
 }
 
 /**
@@ -291,19 +416,20 @@ static void xs_nospace(struct rpc_task *task)
 {
        struct rpc_rqst *req = task->tk_rqstp;
        struct rpc_xprt *xprt = req->rq_xprt;
+       struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
 
        dprintk("RPC: %4d xmit incomplete (%u left of %u)\n",
                        task->tk_pid, req->rq_slen - req->rq_bytes_sent,
                        req->rq_slen);
 
-       if (test_bit(SOCK_ASYNC_NOSPACE, &xprt->sock->flags)) {
+       if (test_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags)) {
                /* Protect against races with write_space */
                spin_lock_bh(&xprt->transport_lock);
 
                /* Don't race with disconnect */
                if (!xprt_connected(xprt))
                        task->tk_status = -ENOTCONN;
-               else if (test_bit(SOCK_NOSPACE, &xprt->sock->flags))
+               else if (test_bit(SOCK_NOSPACE, &transport->sock->flags))
                        xprt_wait_for_buffer_space(task);
 
                spin_unlock_bh(&xprt->transport_lock);
@@ -327,6 +453,7 @@ static int xs_udp_send_request(struct rpc_task *task)
 {
        struct rpc_rqst *req = task->tk_rqstp;
        struct rpc_xprt *xprt = req->rq_xprt;
+       struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
        struct xdr_buf *xdr = &req->rq_snd_buf;
        int status;
 
@@ -335,8 +462,10 @@ static int xs_udp_send_request(struct rpc_task *task)
                                req->rq_svec->iov_len);
 
        req->rq_xtime = jiffies;
-       status = xs_sendpages(xprt->sock, (struct sockaddr *) &xprt->addr,
-                               xprt->addrlen, xdr, req->rq_bytes_sent);
+       status = xs_sendpages(transport->sock,
+                             (struct sockaddr *) &xprt->addr,
+                             xprt->addrlen, xdr,
+                             req->rq_bytes_sent);
 
        dprintk("RPC:      xs_udp_send_request(%u) = %d\n",
                        xdr->len - req->rq_bytes_sent, status);
@@ -392,6 +521,7 @@ static int xs_tcp_send_request(struct rpc_task *task)
 {
        struct rpc_rqst *req = task->tk_rqstp;
        struct rpc_xprt *xprt = req->rq_xprt;
+       struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
        struct xdr_buf *xdr = &req->rq_snd_buf;
        int status, retry = 0;
 
@@ -406,8 +536,8 @@ static int xs_tcp_send_request(struct rpc_task *task)
         * called sendmsg(). */
        while (1) {
                req->rq_xtime = jiffies;
-               status = xs_sendpages(xprt->sock, NULL, 0, xdr,
-                                               req->rq_bytes_sent);
+               status = xs_sendpages(transport->sock,
+                                       NULL, 0, xdr, req->rq_bytes_sent);
 
                dprintk("RPC:      xs_tcp_send_request(%u) = %d\n",
                                xdr->len - req->rq_bytes_sent, status);
@@ -485,8 +615,9 @@ out_release:
  */
 static void xs_close(struct rpc_xprt *xprt)
 {
-       struct socket *sock = xprt->sock;
-       struct sock *sk = xprt->inet;
+       struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
+       struct socket *sock = transport->sock;
+       struct sock *sk = transport->inet;
 
        if (!sk)
                goto clear_close_wait;
@@ -494,13 +625,13 @@ static void xs_close(struct rpc_xprt *xprt)
        dprintk("RPC:      xs_close xprt %p\n", xprt);
 
        write_lock_bh(&sk->sk_callback_lock);
-       xprt->inet = NULL;
-       xprt->sock = NULL;
+       transport->inet = NULL;
+       transport->sock = NULL;
 
        sk->sk_user_data = NULL;
-       sk->sk_data_ready = xprt->old_data_ready;
-       sk->sk_state_change = xprt->old_state_change;
-       sk->sk_write_space = xprt->old_write_space;
+       sk->sk_data_ready = transport->old_data_ready;
+       sk->sk_state_change = transport->old_state_change;
+       sk->sk_write_space = transport->old_write_space;
        write_unlock_bh(&sk->sk_callback_lock);
 
        sk->sk_no_check = 0;
@@ -519,15 +650,18 @@ clear_close_wait:
  */
 static void xs_destroy(struct rpc_xprt *xprt)
 {
+       struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
+
        dprintk("RPC:      xs_destroy xprt %p\n", xprt);
 
-       cancel_delayed_work(&xprt->connect_worker);
+       cancel_delayed_work(&transport->connect_worker);
        flush_scheduled_work();
 
        xprt_disconnect(xprt);
        xs_close(xprt);
        xs_free_peer_addresses(xprt);
        kfree(xprt->slot);
+       kfree(xprt);
 }
 
 static inline struct rpc_xprt *xprt_from_sock(struct sock *sk)
@@ -603,91 +737,75 @@ static void xs_udp_data_ready(struct sock *sk, int len)
        read_unlock(&sk->sk_callback_lock);
 }
 
-static inline size_t xs_tcp_copy_data(skb_reader_t *desc, void *p, size_t len)
-{
-       if (len > desc->count)
-               len = desc->count;
-       if (skb_copy_bits(desc->skb, desc->offset, p, len)) {
-               dprintk("RPC:      failed to copy %zu bytes from skb. %zu bytes remain\n",
-                               len, desc->count);
-               return 0;
-       }
-       desc->offset += len;
-       desc->count -= len;
-       dprintk("RPC:      copied %zu bytes from skb. %zu bytes remain\n",
-                       len, desc->count);
-       return len;
-}
-
-static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, skb_reader_t *desc)
+static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, struct xdr_skb_reader *desc)
 {
+       struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
        size_t len, used;
        char *p;
 
-       p = ((char *) &xprt->tcp_recm) + xprt->tcp_offset;
-       len = sizeof(xprt->tcp_recm) - xprt->tcp_offset;
-       used = xs_tcp_copy_data(desc, p, len);
-       xprt->tcp_offset += used;
+       p = ((char *) &transport->tcp_fraghdr) + transport->tcp_offset;
+       len = sizeof(transport->tcp_fraghdr) - transport->tcp_offset;
+       used = xdr_skb_read_bits(desc, p, len);
+       transport->tcp_offset += used;
        if (used != len)
                return;
 
-       xprt->tcp_reclen = ntohl(xprt->tcp_recm);
-       if (xprt->tcp_reclen & RPC_LAST_STREAM_FRAGMENT)
-               xprt->tcp_flags |= XPRT_LAST_FRAG;
+       transport->tcp_reclen = ntohl(transport->tcp_fraghdr);
+       if (transport->tcp_reclen & RPC_LAST_STREAM_FRAGMENT)
+               transport->tcp_flags |= TCP_RCV_LAST_FRAG;
        else
-               xprt->tcp_flags &= ~XPRT_LAST_FRAG;
-       xprt->tcp_reclen &= RPC_FRAGMENT_SIZE_MASK;
+               transport->tcp_flags &= ~TCP_RCV_LAST_FRAG;
+       transport->tcp_reclen &= RPC_FRAGMENT_SIZE_MASK;
 
-       xprt->tcp_flags &= ~XPRT_COPY_RECM;
-       xprt->tcp_offset = 0;
+       transport->tcp_flags &= ~TCP_RCV_COPY_FRAGHDR;
+       transport->tcp_offset = 0;
 
        /* Sanity check of the record length */
-       if (unlikely(xprt->tcp_reclen < 4)) {
+       if (unlikely(transport->tcp_reclen < 4)) {
                dprintk("RPC:      invalid TCP record fragment length\n");
                xprt_disconnect(xprt);
                return;
        }
        dprintk("RPC:      reading TCP record fragment of length %d\n",
-                       xprt->tcp_reclen);
+                       transport->tcp_reclen);
 }
 
-static void xs_tcp_check_recm(struct rpc_xprt *xprt)
+static void xs_tcp_check_fraghdr(struct sock_xprt *transport)
 {
-       dprintk("RPC:      xprt = %p, tcp_copied = %lu, tcp_offset = %u, tcp_reclen = %u, tcp_flags = %lx\n",
-                       xprt, xprt->tcp_copied, xprt->tcp_offset, xprt->tcp_reclen, xprt->tcp_flags);
-       if (xprt->tcp_offset == xprt->tcp_reclen) {
-               xprt->tcp_flags |= XPRT_COPY_RECM;
-               xprt->tcp_offset = 0;
-               if (xprt->tcp_flags & XPRT_LAST_FRAG) {
-                       xprt->tcp_flags &= ~XPRT_COPY_DATA;
-                       xprt->tcp_flags |= XPRT_COPY_XID;
-                       xprt->tcp_copied = 0;
+       if (transport->tcp_offset == transport->tcp_reclen) {
+               transport->tcp_flags |= TCP_RCV_COPY_FRAGHDR;
+               transport->tcp_offset = 0;
+               if (transport->tcp_flags & TCP_RCV_LAST_FRAG) {
+                       transport->tcp_flags &= ~TCP_RCV_COPY_DATA;
+                       transport->tcp_flags |= TCP_RCV_COPY_XID;
+                       transport->tcp_copied = 0;
                }
        }
 }
 
-static inline void xs_tcp_read_xid(struct rpc_xprt *xprt, skb_reader_t *desc)
+static inline void xs_tcp_read_xid(struct sock_xprt *transport, struct xdr_skb_reader *desc)
 {
        size_t len, used;
        char *p;
 
-       len = sizeof(xprt->tcp_xid) - xprt->tcp_offset;
+       len = sizeof(transport->tcp_xid) - transport->tcp_offset;
        dprintk("RPC:      reading XID (%Zu bytes)\n", len);
-       p = ((char *) &xprt->tcp_xid) + xprt->tcp_offset;
-       used = xs_tcp_copy_data(desc, p, len);
-       xprt->tcp_offset += used;
+       p = ((char *) &transport->tcp_xid) + transport->tcp_offset;
+       used = xdr_skb_read_bits(desc, p, len);
+       transport->tcp_offset += used;
        if (used != len)
                return;
-       xprt->tcp_flags &= ~XPRT_COPY_XID;
-       xprt->tcp_flags |= XPRT_COPY_DATA;
-       xprt->tcp_copied = 4;
+       transport->tcp_flags &= ~TCP_RCV_COPY_XID;
+       transport->tcp_flags |= TCP_RCV_COPY_DATA;
+       transport->tcp_copied = 4;
        dprintk("RPC:      reading reply for XID %08x\n",
-                                               ntohl(xprt->tcp_xid));
-       xs_tcp_check_recm(xprt);
+                       ntohl(transport->tcp_xid));
+       xs_tcp_check_fraghdr(transport);
 }
 
-static inline void xs_tcp_read_request(struct rpc_xprt *xprt, skb_reader_t *desc)
+static inline void xs_tcp_read_request(struct rpc_xprt *xprt, struct xdr_skb_reader *desc)
 {
+       struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
        struct rpc_rqst *req;
        struct xdr_buf *rcvbuf;
        size_t len;
@@ -695,116 +813,118 @@ static inline void xs_tcp_read_request(struct rpc_xprt *xprt, skb_reader_t *desc
 
        /* Find and lock the request corresponding to this xid */
        spin_lock(&xprt->transport_lock);
-       req = xprt_lookup_rqst(xprt, xprt->tcp_xid);
+       req = xprt_lookup_rqst(xprt, transport->tcp_xid);
        if (!req) {
-               xprt->tcp_flags &= ~XPRT_COPY_DATA;
+               transport->tcp_flags &= ~TCP_RCV_COPY_DATA;
                dprintk("RPC:      XID %08x request not found!\n",
-                               ntohl(xprt->tcp_xid));
+                               ntohl(transport->tcp_xid));
                spin_unlock(&xprt->transport_lock);
                return;
        }
 
        rcvbuf = &req->rq_private_buf;
        len = desc->count;
-       if (len > xprt->tcp_reclen - xprt->tcp_offset) {
-               skb_reader_t my_desc;
+       if (len > transport->tcp_reclen - transport->tcp_offset) {
+               struct xdr_skb_reader my_desc;
 
-               len = xprt->tcp_reclen - xprt->tcp_offset;
+               len = transport->tcp_reclen - transport->tcp_offset;
                memcpy(&my_desc, desc, sizeof(my_desc));
                my_desc.count = len;
-               r = xdr_partial_copy_from_skb(rcvbuf, xprt->tcp_copied,
-                                         &my_desc, xs_tcp_copy_data);
+               r = xdr_partial_copy_from_skb(rcvbuf, transport->tcp_copied,
+                                         &my_desc, xdr_skb_read_bits);
                desc->count -= r;
                desc->offset += r;
        } else
-               r = xdr_partial_copy_from_skb(rcvbuf, xprt->tcp_copied,
-                                         desc, xs_tcp_copy_data);
+               r = xdr_partial_copy_from_skb(rcvbuf, transport->tcp_copied,
+                                         desc, xdr_skb_read_bits);
 
        if (r > 0) {
-               xprt->tcp_copied += r;
-               xprt->tcp_offset += r;
+               transport->tcp_copied += r;
+               transport->tcp_offset += r;
        }
        if (r != len) {
                /* Error when copying to the receive buffer,
                 * usually because we weren't able to allocate
                 * additional buffer pages. All we can do now
-                * is turn off XPRT_COPY_DATA, so the request
+                * is turn off TCP_RCV_COPY_DATA, so the request
                 * will not receive any additional updates,
                 * and time out.
                 * Any remaining data from this record will
                 * be discarded.
                 */
-               xprt->tcp_flags &= ~XPRT_COPY_DATA;
+               transport->tcp_flags &= ~TCP_RCV_COPY_DATA;
                dprintk("RPC:      XID %08x truncated request\n",
-                               ntohl(xprt->tcp_xid));
+                               ntohl(transport->tcp_xid));
                dprintk("RPC:      xprt = %p, tcp_copied = %lu, tcp_offset = %u, tcp_reclen = %u\n",
-                               xprt, xprt->tcp_copied, xprt->tcp_offset, xprt->tcp_reclen);
+                               xprt, transport->tcp_copied, transport->tcp_offset,
+                                       transport->tcp_reclen);
                goto out;
        }
 
        dprintk("RPC:      XID %08x read %Zd bytes\n",
-                       ntohl(xprt->tcp_xid), r);
+                       ntohl(transport->tcp_xid), r);
        dprintk("RPC:      xprt = %p, tcp_copied = %lu, tcp_offset = %u, tcp_reclen = %u\n",
-                       xprt, xprt->tcp_copied, xprt->tcp_offset, xprt->tcp_reclen);
-
-       if (xprt->tcp_copied == req->rq_private_buf.buflen)
-               xprt->tcp_flags &= ~XPRT_COPY_DATA;
-       else if (xprt->tcp_offset == xprt->tcp_reclen) {
-               if (xprt->tcp_flags & XPRT_LAST_FRAG)
-                       xprt->tcp_flags &= ~XPRT_COPY_DATA;
+                       xprt, transport->tcp_copied, transport->tcp_offset,
+                               transport->tcp_reclen);
+
+       if (transport->tcp_copied == req->rq_private_buf.buflen)
+               transport->tcp_flags &= ~TCP_RCV_COPY_DATA;
+       else if (transport->tcp_offset == transport->tcp_reclen) {
+               if (transport->tcp_flags & TCP_RCV_LAST_FRAG)
+                       transport->tcp_flags &= ~TCP_RCV_COPY_DATA;
        }
 
 out:
-       if (!(xprt->tcp_flags & XPRT_COPY_DATA))
-               xprt_complete_rqst(req->rq_task, xprt->tcp_copied);
+       if (!(transport->tcp_flags & TCP_RCV_COPY_DATA))
+               xprt_complete_rqst(req->rq_task, transport->tcp_copied);
        spin_unlock(&xprt->transport_lock);
-       xs_tcp_check_recm(xprt);
+       xs_tcp_check_fraghdr(transport);
 }
 
-static inline void xs_tcp_read_discard(struct rpc_xprt *xprt, skb_reader_t *desc)
+static inline void xs_tcp_read_discard(struct sock_xprt *transport, struct xdr_skb_reader *desc)
 {
        size_t len;
 
-       len = xprt->tcp_reclen - xprt->tcp_offset;
+       len = transport->tcp_reclen - transport->tcp_offset;
        if (len > desc->count)
                len = desc->count;
        desc->count -= len;
        desc->offset += len;
-       xprt->tcp_offset += len;
+       transport->tcp_offset += len;
        dprintk("RPC:      discarded %Zu bytes\n", len);
-       xs_tcp_check_recm(xprt);
+       xs_tcp_check_fraghdr(transport);
 }
 
 static int xs_tcp_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, unsigned int offset, size_t len)
 {
        struct rpc_xprt *xprt = rd_desc->arg.data;
-       skb_reader_t desc = {
+       struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
+       struct xdr_skb_reader desc = {
                .skb    = skb,
                .offset = offset,
                .count  = len,
-               .csum   = 0
        };
 
        dprintk("RPC:      xs_tcp_data_recv started\n");
        do {
                /* Read in a new fragment marker if necessary */
                /* Can we ever really expect to get completely empty fragments? */
-               if (xprt->tcp_flags & XPRT_COPY_RECM) {
+               if (transport->tcp_flags & TCP_RCV_COPY_FRAGHDR) {
                        xs_tcp_read_fraghdr(xprt, &desc);
                        continue;
                }
                /* Read in the xid if necessary */
-               if (xprt->tcp_flags & XPRT_COPY_XID) {
-                       xs_tcp_read_xid(xprt, &desc);
+               if (transport->tcp_flags & TCP_RCV_COPY_XID) {
+                       xs_tcp_read_xid(transport, &desc);
                        continue;
                }
                /* Read in the request data */
-               if (xprt->tcp_flags & XPRT_COPY_DATA) {
+               if (transport->tcp_flags & TCP_RCV_COPY_DATA) {
                        xs_tcp_read_request(xprt, &desc);
                        continue;
                }
                /* Skip over any trailing bytes on short reads */
-               xs_tcp_read_discard(xprt, &desc);
+               xs_tcp_read_discard(transport, &desc);
        } while (desc.count);
        dprintk("RPC:      xs_tcp_data_recv done\n");
        return len - desc.count;
@@ -858,11 +978,16 @@ static void xs_tcp_state_change(struct sock *sk)
        case TCP_ESTABLISHED:
                spin_lock_bh(&xprt->transport_lock);
                if (!xprt_test_and_set_connected(xprt)) {
+                       struct sock_xprt *transport = container_of(xprt,
+                                       struct sock_xprt, xprt);
+
                        /* Reset TCP record info */
-                       xprt->tcp_offset = 0;
-                       xprt->tcp_reclen = 0;
-                       xprt->tcp_copied = 0;
-                       xprt->tcp_flags = XPRT_COPY_RECM | XPRT_COPY_XID;
+                       transport->tcp_offset = 0;
+                       transport->tcp_reclen = 0;
+                       transport->tcp_copied = 0;
+                       transport->tcp_flags =
+                               TCP_RCV_COPY_FRAGHDR | TCP_RCV_COPY_XID;
+
                        xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO;
                        xprt_wake_pending_tasks(xprt, 0);
                }
@@ -951,15 +1076,16 @@ static void xs_tcp_write_space(struct sock *sk)
 
 static void xs_udp_do_set_buffer_size(struct rpc_xprt *xprt)
 {
-       struct sock *sk = xprt->inet;
+       struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
+       struct sock *sk = transport->inet;
 
-       if (xprt->rcvsize) {
+       if (transport->rcvsize) {
                sk->sk_userlocks |= SOCK_RCVBUF_LOCK;
-               sk->sk_rcvbuf = xprt->rcvsize * xprt->max_reqs *  2;
+               sk->sk_rcvbuf = transport->rcvsize * xprt->max_reqs * 2;
        }
-       if (xprt->sndsize) {
+       if (transport->sndsize) {
                sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
-               sk->sk_sndbuf = xprt->sndsize * xprt->max_reqs * 2;
+               sk->sk_sndbuf = transport->sndsize * xprt->max_reqs * 2;
                sk->sk_write_space(sk);
        }
 }
@@ -974,12 +1100,14 @@ static void xs_udp_do_set_buffer_size(struct rpc_xprt *xprt)
  */
 static void xs_udp_set_buffer_size(struct rpc_xprt *xprt, size_t sndsize, size_t rcvsize)
 {
-       xprt->sndsize = 0;
+       struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
+
+       transport->sndsize = 0;
        if (sndsize)
-               xprt->sndsize = sndsize + 1024;
-       xprt->rcvsize = 0;
+               transport->sndsize = sndsize + 1024;
+       transport->rcvsize = 0;
        if (rcvsize)
-               xprt->rcvsize = rcvsize + 1024;
+               transport->rcvsize = rcvsize + 1024;
 
        xs_udp_do_set_buffer_size(xprt);
 }
@@ -1002,19 +1130,6 @@ static unsigned short xs_get_random_port(void)
        return rand + xprt_min_resvport;
 }
 
-/**
- * xs_print_peer_address - format an IPv4 address for printing
- * @xprt: generic transport
- * @format: flags field indicating which parts of the address to render
- */
-static char *xs_print_peer_address(struct rpc_xprt *xprt, enum rpc_display_format_t format)
-{
-       if (xprt->address_strings[format] != NULL)
-               return xprt->address_strings[format];
-       else
-               return "unprintable";
-}
-
 /**
  * xs_set_port - reset the port number in the remote endpoint address
  * @xprt: generic transport
@@ -1030,20 +1145,20 @@ static void xs_set_port(struct rpc_xprt *xprt, unsigned short port)
        sap->sin_port = htons(port);
 }
 
-static int xs_bindresvport(struct rpc_xprt *xprt, struct socket *sock)
+static int xs_bindresvport(struct sock_xprt *transport, struct socket *sock)
 {
        struct sockaddr_in myaddr = {
                .sin_family = AF_INET,
        };
        int err;
-       unsigned short port = xprt->port;
+       unsigned short port = transport->port;
 
        do {
                myaddr.sin_port = htons(port);
                err = kernel_bind(sock, (struct sockaddr *) &myaddr,
                                                sizeof(myaddr));
                if (err == 0) {
-                       xprt->port = port;
+                       transport->port = port;
                        dprintk("RPC:      xs_bindresvport bound to port %u\n",
                                        port);
                        return 0;
@@ -1052,12 +1167,41 @@ static int xs_bindresvport(struct rpc_xprt *xprt, struct socket *sock)
                        port = xprt_max_resvport;
                else
                        port--;
-       } while (err == -EADDRINUSE && port != xprt->port);
+       } while (err == -EADDRINUSE && port != transport->port);
 
        dprintk("RPC:      can't bind to reserved port (%d).\n", -err);
        return err;
 }
 
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+static struct lock_class_key xs_key[2];
+static struct lock_class_key xs_slock_key[2];
+
+static inline void xs_reclassify_socket(struct socket *sock)
+{
+       struct sock *sk = sock->sk;
+       BUG_ON(sk->sk_lock.owner != NULL);
+       switch (sk->sk_family) {
+       case AF_INET:
+               sock_lock_init_class_and_name(sk, "slock-AF_INET-NFS",
+                       &xs_slock_key[0], "sk_lock-AF_INET-NFS", &xs_key[0]);
+               break;
+
+       case AF_INET6:
+               sock_lock_init_class_and_name(sk, "slock-AF_INET6-NFS",
+                       &xs_slock_key[1], "sk_lock-AF_INET6-NFS", &xs_key[1]);
+               break;
+
+       default:
+               BUG();
+       }
+}
+#else
+static inline void xs_reclassify_socket(struct socket *sock)
+{
+}
+#endif
+
 /**
  * xs_udp_connect_worker - set up a UDP socket
  * @work: RPC transport to connect
@@ -1066,9 +1210,10 @@ static int xs_bindresvport(struct rpc_xprt *xprt, struct socket *sock)
  */
 static void xs_udp_connect_worker(struct work_struct *work)
 {
-       struct rpc_xprt *xprt =
-               container_of(work, struct rpc_xprt, connect_worker.work);
-       struct socket *sock = xprt->sock;
+       struct sock_xprt *transport =
+               container_of(work, struct sock_xprt, connect_worker.work);
+       struct rpc_xprt *xprt = &transport->xprt;
+       struct socket *sock = transport->sock;
        int err, status = -EIO;
 
        if (xprt->shutdown || !xprt_bound(xprt))
@@ -1081,24 +1226,25 @@ static void xs_udp_connect_worker(struct work_struct *work)
                dprintk("RPC:      can't create UDP transport socket (%d).\n", -err);
                goto out;
        }
+       xs_reclassify_socket(sock);
 
-       if (xprt->resvport && xs_bindresvport(xprt, sock) < 0) {
+       if (xprt->resvport && xs_bindresvport(transport, sock) < 0) {
                sock_release(sock);
                goto out;
        }
 
        dprintk("RPC:      worker connecting xprt %p to address: %s\n",
-                       xprt, xs_print_peer_address(xprt, RPC_DISPLAY_ALL));
+                       xprt, xprt->address_strings[RPC_DISPLAY_ALL]);
 
-       if (!xprt->inet) {
+       if (!transport->inet) {
                struct sock *sk = sock->sk;
 
                write_lock_bh(&sk->sk_callback_lock);
 
                sk->sk_user_data = xprt;
-               xprt->old_data_ready = sk->sk_data_ready;
-               xprt->old_state_change = sk->sk_state_change;
-               xprt->old_write_space = sk->sk_write_space;
+               transport->old_data_ready = sk->sk_data_ready;
+               transport->old_state_change = sk->sk_state_change;
+               transport->old_write_space = sk->sk_write_space;
                sk->sk_data_ready = xs_udp_data_ready;
                sk->sk_write_space = xs_udp_write_space;
                sk->sk_no_check = UDP_CSUM_NORCV;
@@ -1107,8 +1253,8 @@ static void xs_udp_connect_worker(struct work_struct *work)
                xprt_set_connected(xprt);
 
                /* Reset to new socket */
-               xprt->sock = sock;
-               xprt->inet = sk;
+               transport->sock = sock;
+               transport->inet = sk;
 
                write_unlock_bh(&sk->sk_callback_lock);
        }
@@ -1126,7 +1272,7 @@ out:
 static void xs_tcp_reuse_connection(struct rpc_xprt *xprt)
 {
        int result;
-       struct socket *sock = xprt->sock;
+       struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
        struct sockaddr any;
 
        dprintk("RPC:      disconnecting xprt %p to reuse port\n", xprt);
@@ -1137,7 +1283,7 @@ static void xs_tcp_reuse_connection(struct rpc_xprt *xprt)
         */
        memset(&any, 0, sizeof(any));
        any.sa_family = AF_UNSPEC;
-       result = kernel_connect(sock, &any, sizeof(any), 0);
+       result = kernel_connect(transport->sock, &any, sizeof(any), 0);
        if (result)
                dprintk("RPC:      AF_UNSPEC connect return code %d\n",
                                result);
@@ -1151,22 +1297,24 @@ static void xs_tcp_reuse_connection(struct rpc_xprt *xprt)
  */
 static void xs_tcp_connect_worker(struct work_struct *work)
 {
-       struct rpc_xprt *xprt =
-               container_of(work, struct rpc_xprt, connect_worker.work);
-       struct socket *sock = xprt->sock;
+       struct sock_xprt *transport =
+               container_of(work, struct sock_xprt, connect_worker.work);
+       struct rpc_xprt *xprt = &transport->xprt;
+       struct socket *sock = transport->sock;
        int err, status = -EIO;
 
        if (xprt->shutdown || !xprt_bound(xprt))
                goto out;
 
-       if (!xprt->sock) {
+       if (!sock) {
                /* start from scratch */
                if ((err = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock)) < 0) {
                        dprintk("RPC:      can't create TCP transport socket (%d).\n", -err);
                        goto out;
                }
+               xs_reclassify_socket(sock);
 
-               if (xprt->resvport && xs_bindresvport(xprt, sock) < 0) {
+               if (xprt->resvport && xs_bindresvport(transport, sock) < 0) {
                        sock_release(sock);
                        goto out;
                }
@@ -1175,17 +1323,17 @@ static void xs_tcp_connect_worker(struct work_struct *work)
                xs_tcp_reuse_connection(xprt);
 
        dprintk("RPC:      worker connecting xprt %p to address: %s\n",
-                       xprt, xs_print_peer_address(xprt, RPC_DISPLAY_ALL));
+                       xprt, xprt->address_strings[RPC_DISPLAY_ALL]);
 
-       if (!xprt->inet) {
+       if (!transport->inet) {
                struct sock *sk = sock->sk;
 
                write_lock_bh(&sk->sk_callback_lock);
 
                sk->sk_user_data = xprt;
-               xprt->old_data_ready = sk->sk_data_ready;
-               xprt->old_state_change = sk->sk_state_change;
-               xprt->old_write_space = sk->sk_write_space;
+               transport->old_data_ready = sk->sk_data_ready;
+               transport->old_state_change = sk->sk_state_change;
+               transport->old_write_space = sk->sk_write_space;
                sk->sk_data_ready = xs_tcp_data_ready;
                sk->sk_state_change = xs_tcp_state_change;
                sk->sk_write_space = xs_tcp_write_space;
@@ -1200,8 +1348,8 @@ static void xs_tcp_connect_worker(struct work_struct *work)
                xprt_clear_connected(xprt);
 
                /* Reset to new socket */
-               xprt->sock = sock;
-               xprt->inet = sk;
+               transport->sock = sock;
+               transport->inet = sk;
 
                write_unlock_bh(&sk->sk_callback_lock);
        }
@@ -1250,21 +1398,22 @@ out_clear:
 static void xs_connect(struct rpc_task *task)
 {
        struct rpc_xprt *xprt = task->tk_xprt;
+       struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
 
        if (xprt_test_and_set_connecting(xprt))
                return;
 
-       if (xprt->sock != NULL) {
+       if (transport->sock != NULL) {
                dprintk("RPC:      xs_connect delayed xprt %p for %lu seconds\n",
                                xprt, xprt->reestablish_timeout / HZ);
-               schedule_delayed_work(&xprt->connect_worker,
+               schedule_delayed_work(&transport->connect_worker,
                                        xprt->reestablish_timeout);
                xprt->reestablish_timeout <<= 1;
                if (xprt->reestablish_timeout > XS_TCP_MAX_REEST_TO)
                        xprt->reestablish_timeout = XS_TCP_MAX_REEST_TO;
        } else {
                dprintk("RPC:      xs_connect scheduled xprt %p\n", xprt);
-               schedule_delayed_work(&xprt->connect_worker, 0);
+               schedule_delayed_work(&transport->connect_worker, 0);
 
                /* flush_scheduled_work can sleep... */
                if (!RPC_IS_ASYNC(task))
@@ -1280,8 +1429,10 @@ static void xs_connect(struct rpc_task *task)
  */
 static void xs_udp_print_stats(struct rpc_xprt *xprt, struct seq_file *seq)
 {
+       struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
+
        seq_printf(seq, "\txprt:\tudp %u %lu %lu %lu %lu %Lu %Lu\n",
-                       xprt->port,
+                       transport->port,
                        xprt->stat.bind_count,
                        xprt->stat.sends,
                        xprt->stat.recvs,
@@ -1298,13 +1449,14 @@ static void xs_udp_print_stats(struct rpc_xprt *xprt, struct seq_file *seq)
  */
 static void xs_tcp_print_stats(struct rpc_xprt *xprt, struct seq_file *seq)
 {
+       struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
        long idle_time = 0;
 
        if (xprt_connected(xprt))
                idle_time = (long)(jiffies - xprt->last_used) / HZ;
 
        seq_printf(seq, "\txprt:\ttcp %u %lu %lu %lu %ld %lu %lu %lu %Lu %Lu\n",
-                       xprt->port,
+                       transport->port,
                        xprt->stat.bind_count,
                        xprt->stat.connect_count,
                        xprt->stat.connect_time,
@@ -1318,7 +1470,6 @@ static void xs_tcp_print_stats(struct rpc_xprt *xprt, struct seq_file *seq)
 
 static struct rpc_xprt_ops xs_udp_ops = {
        .set_buffer_size        = xs_udp_set_buffer_size,
-       .print_addr             = xs_print_peer_address,
        .reserve_xprt           = xprt_reserve_xprt_cong,
        .release_xprt           = xprt_release_xprt_cong,
        .rpcbind                = rpc_getport,
@@ -1336,7 +1487,6 @@ static struct rpc_xprt_ops xs_udp_ops = {
 };
 
 static struct rpc_xprt_ops xs_tcp_ops = {
-       .print_addr             = xs_print_peer_address,
        .reserve_xprt           = xprt_reserve_xprt,
        .release_xprt           = xs_tcp_release_xprt,
        .rpcbind                = rpc_getport,
@@ -1351,33 +1501,64 @@ static struct rpc_xprt_ops xs_tcp_ops = {
        .print_stats            = xs_tcp_print_stats,
 };
 
+static struct rpc_xprt *xs_setup_xprt(struct sockaddr *addr, size_t addrlen, unsigned int slot_table_size)
+{
+       struct rpc_xprt *xprt;
+       struct sock_xprt *new;
+
+       if (addrlen > sizeof(xprt->addr)) {
+               dprintk("RPC:      xs_setup_xprt: address too large\n");
+               return ERR_PTR(-EBADF);
+       }
+
+       new = kzalloc(sizeof(*new), GFP_KERNEL);
+       if (new == NULL) {
+               dprintk("RPC:      xs_setup_xprt: couldn't allocate rpc_xprt\n");
+               return ERR_PTR(-ENOMEM);
+       }
+       xprt = &new->xprt;
+
+       xprt->max_reqs = slot_table_size;
+       xprt->slot = kcalloc(xprt->max_reqs, sizeof(struct rpc_rqst), GFP_KERNEL);
+       if (xprt->slot == NULL) {
+               kfree(xprt);
+               dprintk("RPC:      xs_setup_xprt: couldn't allocate slot table\n");
+               return ERR_PTR(-ENOMEM);
+       }
+
+       memcpy(&xprt->addr, addr, addrlen);
+       xprt->addrlen = addrlen;
+       new->port = xs_get_random_port();
+
+       return xprt;
+}
+
 /**
  * xs_setup_udp - Set up transport to use a UDP socket
- * @xprt: transport to set up
+ * @addr: address of remote server
+ * @addrlen: length of address in bytes
  * @to:   timeout parameters
  *
  */
-int xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to)
+struct rpc_xprt *xs_setup_udp(struct sockaddr *addr, size_t addrlen, struct rpc_timeout *to)
 {
-       size_t slot_table_size;
-       struct sockaddr_in *addr = (struct sockaddr_in *) &xprt->addr;
+       struct rpc_xprt *xprt;
+       struct sock_xprt *transport;
 
-       xprt->max_reqs = xprt_udp_slot_table_entries;
-       slot_table_size = xprt->max_reqs * sizeof(xprt->slot[0]);
-       xprt->slot = kzalloc(slot_table_size, GFP_KERNEL);
-       if (xprt->slot == NULL)
-               return -ENOMEM;
+       xprt = xs_setup_xprt(addr, addrlen, xprt_udp_slot_table_entries);
+       if (IS_ERR(xprt))
+               return xprt;
+       transport = container_of(xprt, struct sock_xprt, xprt);
 
-       if (ntohs(addr->sin_port) != 0)
+       if (ntohs(((struct sockaddr_in *)addr)->sin_port) != 0)
                xprt_set_bound(xprt);
-       xprt->port = xs_get_random_port();
 
        xprt->prot = IPPROTO_UDP;
        xprt->tsh_size = 0;
        /* XXX: header size can vary due to auth type, IPv6, etc. */
        xprt->max_payload = (1U << 16) - (MAX_HEADER << 3);
 
-       INIT_DELAYED_WORK(&xprt->connect_worker, xs_udp_connect_worker);
+       INIT_DELAYED_WORK(&transport->connect_worker, xs_udp_connect_worker);
        xprt->bind_timeout = XS_BIND_TO;
        xprt->connect_timeout = XS_UDP_CONN_TO;
        xprt->reestablish_timeout = XS_UDP_REEST_TO;
@@ -1392,37 +1573,36 @@ int xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to)
 
        xs_format_peer_addresses(xprt);
        dprintk("RPC:      set up transport to address %s\n",
-                       xs_print_peer_address(xprt, RPC_DISPLAY_ALL));
+                       xprt->address_strings[RPC_DISPLAY_ALL]);
 
-       return 0;
+       return xprt;
 }
 
 /**
  * xs_setup_tcp - Set up transport to use a TCP socket
- * @xprt: transport to set up
+ * @addr: address of remote server
+ * @addrlen: length of address in bytes
  * @to: timeout parameters
  *
  */
-int xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to)
+struct rpc_xprt *xs_setup_tcp(struct sockaddr *addr, size_t addrlen, struct rpc_timeout *to)
 {
-       size_t slot_table_size;
-       struct sockaddr_in *addr = (struct sockaddr_in *) &xprt->addr;
+       struct rpc_xprt *xprt;
+       struct sock_xprt *transport;
 
-       xprt->max_reqs = xprt_tcp_slot_table_entries;
-       slot_table_size = xprt->max_reqs * sizeof(xprt->slot[0]);
-       xprt->slot = kzalloc(slot_table_size, GFP_KERNEL);
-       if (xprt->slot == NULL)
-               return -ENOMEM;
+       xprt = xs_setup_xprt(addr, addrlen, xprt_tcp_slot_table_entries);
+       if (IS_ERR(xprt))
+               return xprt;
+       transport = container_of(xprt, struct sock_xprt, xprt);
 
-       if (ntohs(addr->sin_port) != 0)
+       if (ntohs(((struct sockaddr_in *)addr)->sin_port) != 0)
                xprt_set_bound(xprt);
-       xprt->port = xs_get_random_port();
 
        xprt->prot = IPPROTO_TCP;
        xprt->tsh_size = sizeof(rpc_fraghdr) / sizeof(u32);
        xprt->max_payload = RPC_MAX_FRAGMENT_SIZE;
 
-       INIT_DELAYED_WORK(&xprt->connect_worker, xs_tcp_connect_worker);
+       INIT_DELAYED_WORK(&transport->connect_worker, xs_tcp_connect_worker);
        xprt->bind_timeout = XS_BIND_TO;
        xprt->connect_timeout = XS_TCP_CONN_TO;
        xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO;
@@ -1437,7 +1617,40 @@ int xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to)
 
        xs_format_peer_addresses(xprt);
        dprintk("RPC:      set up transport to address %s\n",
-                       xs_print_peer_address(xprt, RPC_DISPLAY_ALL));
+                       xprt->address_strings[RPC_DISPLAY_ALL]);
+
+       return xprt;
+}
+
+/**
+ * init_socket_xprt - set up xprtsock's sysctls
+ *
+ */
+int init_socket_xprt(void)
+{
+#ifdef RPC_DEBUG
+       if (!sunrpc_table_header) {
+               sunrpc_table_header = register_sysctl_table(sunrpc_table, 1);
+#ifdef CONFIG_PROC_FS
+               if (sunrpc_table[0].de)
+                       sunrpc_table[0].de->owner = THIS_MODULE;
+#endif
+       }
+#endif
 
        return 0;
 }
+
+/**
+ * cleanup_socket_xprt - remove xprtsock's sysctls
+ *
+ */
+void cleanup_socket_xprt(void)
+{
+#ifdef RPC_DEBUG
+       if (sunrpc_table_header) {
+               unregister_sysctl_table(sunrpc_table_header);
+               sunrpc_table_header = NULL;
+       }
+#endif
+}
index ae6ddf00a1aaea8aaaa17d708e4d4eaca4bfe059..eb80778d6d9c6d22781b205a21b139bd4c87f052 100644 (file)
@@ -42,7 +42,7 @@ struct queue_item {
        unsigned long data;
 };
 
-static kmem_cache_t *tipc_queue_item_cache;
+static struct kmem_cache *tipc_queue_item_cache;
 static struct list_head signal_queue_head;
 static DEFINE_SPINLOCK(qitem_lock);
 static int handler_enabled = 0;
index 746c2f4a5fa62a290418a0b7780b165678ae7f96..f14ad6635fccf15a324831a1d094ed6d529cd8cb 100644 (file)
@@ -96,7 +96,7 @@ atomic_t unix_tot_inflight = ATOMIC_INIT(0);
 static struct sock *unix_get_socket(struct file *filp)
 {
        struct sock *u_sock = NULL;
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
 
        /*
         *      Socket ?
index 316211d9f17d97ffeab6823778c03113cdd5a76a..769cdd62c1bbab511af3c675433e2af191174840 100644 (file)
 
 #define KMEM_SAFETYZONE 8
 
-/***********FOR DEBUGGING PURPOSES*********************************************
-static void * dbg_kmalloc(unsigned int size, int prio, int line) {
-       int i = 0;
-       void * v = kmalloc(size+sizeof(unsigned int)+2*KMEM_SAFETYZONE*8,prio);
-       char * c1 = v;
-       c1 += sizeof(unsigned int);
-       *((unsigned int *)v) = size;
-
-       for (i = 0; i < KMEM_SAFETYZONE; i++) {
-               c1[0] = 'D'; c1[1] = 'E'; c1[2] = 'A'; c1[3] = 'D';
-               c1[4] = 'B'; c1[5] = 'E'; c1[6] = 'E'; c1[7] = 'F';
-               c1 += 8;
-       }
-       c1 += size;
-       for (i = 0; i < KMEM_SAFETYZONE; i++) {
-               c1[0] = 'M'; c1[1] = 'U'; c1[2] = 'N'; c1[3] = 'G';
-               c1[4] = 'W'; c1[5] = 'A'; c1[6] = 'L'; c1[7] = 'L';
-               c1 += 8;
-       }
-       v = ((char *)v) + sizeof(unsigned int) + KMEM_SAFETYZONE*8;
-       printk(KERN_INFO "line %d  kmalloc(%d,%d) = %p\n",line,size,prio,v);
-       return v;
-}
-static void dbg_kfree(void * v, int line) {
-       unsigned int * sp = (unsigned int *)(((char *)v) - (sizeof(unsigned int) + KMEM_SAFETYZONE*8));
-       unsigned int size = *sp;
-       char * c1 = ((char *)v) - KMEM_SAFETYZONE*8;
-       int i = 0;
-       for (i = 0; i < KMEM_SAFETYZONE; i++) {
-               if (   c1[0] != 'D' || c1[1] != 'E' || c1[2] != 'A' || c1[3] != 'D'
-                   || c1[4] != 'B' || c1[5] != 'E' || c1[6] != 'E' || c1[7] != 'F') {
-                       printk(KERN_INFO "kmalloced block at %p has been corrupted (underrun)!\n",v);
-                       printk(KERN_INFO " %4x: %2x %2x %2x %2x %2x %2x %2x %2x\n", i*8,
-                                       c1[0],c1[1],c1[2],c1[3],c1[4],c1[5],c1[6],c1[7] );
-               }
-               c1 += 8;
-       }
-       c1 += size;
-       for (i = 0; i < KMEM_SAFETYZONE; i++) {
-               if (   c1[0] != 'M' || c1[1] != 'U' || c1[2] != 'N' || c1[3] != 'G'
-                   || c1[4] != 'W' || c1[5] != 'A' || c1[6] != 'L' || c1[7] != 'L'
-                  ) {
-                       printk(KERN_INFO "kmalloced block at %p has been corrupted (overrun):\n",v);
-                       printk(KERN_INFO " %4x: %2x %2x %2x %2x %2x %2x %2x %2x\n", i*8,
-                                       c1[0],c1[1],c1[2],c1[3],c1[4],c1[5],c1[6],c1[7] );
-               }
-               c1 += 8;
-       }
-       printk(KERN_INFO "line %d  kfree(%p)\n",line,v);
-       v = ((char *)v) - (sizeof(unsigned int) + KMEM_SAFETYZONE*8);
-       kfree(v);
-}
-
-#define kmalloc(x,y) dbg_kmalloc(x,y,__LINE__)
-#define kfree(x) dbg_kfree(x,__LINE__)
-*****************************************************************************/
-
 /*
  *     Function Prototypes
  */
index 5a0dbeb6bbe817f02c7750ea75e5f3e6713680cf..6b381fc0383d1ea7bde417f5c4665c03a4db418b 100644 (file)
@@ -119,6 +119,23 @@ static struct xfrm_algo_desc aalg_list[] = {
                .sadb_alg_maxbits = 160
        }
 },
+{
+       .name = "xcbc(aes)",
+
+       .uinfo = {
+               .auth = {
+                       .icv_truncbits = 96,
+                       .icv_fullbits = 128,
+               }
+       },
+
+       .desc = {
+               .sadb_alg_id = SADB_X_AALG_AES_XCBC_MAC,
+               .sadb_alg_ivlen = 0,
+               .sadb_alg_minbits = 128,
+               .sadb_alg_maxbits = 128
+       }
+},
 };
 
 static struct xfrm_algo_desc ealg_list[] = {
index e8198a2c785df7416143c0781bd042f8aba995d2..414f890703802a0e2ef761df2573561f54f1b79e 100644 (file)
@@ -12,7 +12,7 @@
 #include <net/ip.h>
 #include <net/xfrm.h>
 
-static kmem_cache_t *secpath_cachep __read_mostly;
+static struct kmem_cache *secpath_cachep __read_mostly;
 
 void __secpath_destroy(struct sec_path *sp)
 {
@@ -27,7 +27,7 @@ struct sec_path *secpath_dup(struct sec_path *src)
 {
        struct sec_path *sp;
 
-       sp = kmem_cache_alloc(secpath_cachep, SLAB_ATOMIC);
+       sp = kmem_cache_alloc(secpath_cachep, GFP_ATOMIC);
        if (!sp)
                return NULL;
 
index f6c77bd36fddf7f8d597121c156b8d4c0d879c73..bebd40e5a62e161f03f630adac629d8baa014d99 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/cache.h>
 #include <net/xfrm.h>
 #include <net/ip.h>
+#include <linux/audit.h>
 
 #include "xfrm_hash.h"
 
@@ -39,7 +40,7 @@ EXPORT_SYMBOL(xfrm_policy_count);
 static DEFINE_RWLOCK(xfrm_policy_afinfo_lock);
 static struct xfrm_policy_afinfo *xfrm_policy_afinfo[NPROTO];
 
-static kmem_cache_t *xfrm_dst_cache __read_mostly;
+static struct kmem_cache *xfrm_dst_cache __read_mostly;
 
 static struct work_struct xfrm_policy_gc_work;
 static HLIST_HEAD(xfrm_policy_gc_list);
@@ -804,7 +805,7 @@ struct xfrm_policy *xfrm_policy_byid(u8 type, int dir, u32 id, int delete)
 }
 EXPORT_SYMBOL(xfrm_policy_byid);
 
-void xfrm_policy_flush(u8 type)
+void xfrm_policy_flush(u8 type, struct xfrm_audit *audit_info)
 {
        int dir;
 
@@ -824,6 +825,9 @@ void xfrm_policy_flush(u8 type)
                        hlist_del(&pol->byidx);
                        write_unlock_bh(&xfrm_policy_lock);
 
+                       xfrm_audit_log(audit_info->loginuid, audit_info->secid,
+                                      AUDIT_MAC_IPSEC_DELSPD, 1, pol, NULL);
+
                        xfrm_policy_kill(pol);
                        killed++;
 
@@ -842,6 +846,11 @@ void xfrm_policy_flush(u8 type)
                                hlist_del(&pol->byidx);
                                write_unlock_bh(&xfrm_policy_lock);
 
+                               xfrm_audit_log(audit_info->loginuid,
+                                              audit_info->secid,
+                                              AUDIT_MAC_IPSEC_DELSPD, 1,
+                                              pol, NULL);
+
                                xfrm_policy_kill(pol);
                                killed++;
 
@@ -860,33 +869,12 @@ EXPORT_SYMBOL(xfrm_policy_flush);
 int xfrm_policy_walk(u8 type, int (*func)(struct xfrm_policy *, int, int, void*),
                     void *data)
 {
-       struct xfrm_policy *pol;
+       struct xfrm_policy *pol, *last = NULL;
        struct hlist_node *entry;
-       int dir, count, error;
+       int dir, last_dir = 0, count, error;
 
        read_lock_bh(&xfrm_policy_lock);
        count = 0;
-       for (dir = 0; dir < 2*XFRM_POLICY_MAX; dir++) {
-               struct hlist_head *table = xfrm_policy_bydst[dir].table;
-               int i;
-
-               hlist_for_each_entry(pol, entry,
-                                    &xfrm_policy_inexact[dir], bydst) {
-                       if (pol->type == type)
-                               count++;
-               }
-               for (i = xfrm_policy_bydst[dir].hmask; i >= 0; i--) {
-                       hlist_for_each_entry(pol, entry, table + i, bydst) {
-                               if (pol->type == type)
-                                       count++;
-                       }
-               }
-       }
-
-       if (count == 0) {
-               error = -ENOENT;
-               goto out;
-       }
 
        for (dir = 0; dir < 2*XFRM_POLICY_MAX; dir++) {
                struct hlist_head *table = xfrm_policy_bydst[dir].table;
@@ -896,21 +884,37 @@ int xfrm_policy_walk(u8 type, int (*func)(struct xfrm_policy *, int, int, void*)
                                     &xfrm_policy_inexact[dir], bydst) {
                        if (pol->type != type)
                                continue;
-                       error = func(pol, dir % XFRM_POLICY_MAX, --count, data);
-                       if (error)
-                               goto out;
+                       if (last) {
+                               error = func(last, last_dir % XFRM_POLICY_MAX,
+                                            count, data);
+                               if (error)
+                                       goto out;
+                       }
+                       last = pol;
+                       last_dir = dir;
+                       count++;
                }
                for (i = xfrm_policy_bydst[dir].hmask; i >= 0; i--) {
                        hlist_for_each_entry(pol, entry, table + i, bydst) {
                                if (pol->type != type)
                                        continue;
-                               error = func(pol, dir % XFRM_POLICY_MAX, --count, data);
-                               if (error)
-                                       goto out;
+                               if (last) {
+                                       error = func(last, last_dir % XFRM_POLICY_MAX,
+                                                    count, data);
+                                       if (error)
+                                               goto out;
+                               }
+                               last = pol;
+                               last_dir = dir;
+                               count++;
                        }
                }
        }
-       error = 0;
+       if (count == 0) {
+               error = -ENOENT;
+               goto out;
+       }
+       error = func(last, last_dir % XFRM_POLICY_MAX, 0, data);
 out:
        read_unlock_bh(&xfrm_policy_lock);
        return error;
@@ -1982,6 +1986,117 @@ int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *first,
 
 EXPORT_SYMBOL(xfrm_bundle_ok);
 
+#ifdef CONFIG_AUDITSYSCALL
+/* Audit addition and deletion of SAs and ipsec policy */
+
+void xfrm_audit_log(uid_t auid, u32 sid, int type, int result,
+                   struct xfrm_policy *xp, struct xfrm_state *x)
+{
+
+       char *secctx;
+       u32 secctx_len;
+       struct xfrm_sec_ctx *sctx = NULL;
+       struct audit_buffer *audit_buf;
+       int family;
+       extern int audit_enabled;
+
+       if (audit_enabled == 0)
+               return;
+
+       audit_buf = audit_log_start(current->audit_context, GFP_ATOMIC, type);
+       if (audit_buf == NULL)
+       return;
+
+       switch(type) {
+       case AUDIT_MAC_IPSEC_ADDSA:
+               audit_log_format(audit_buf, "SAD add: auid=%u", auid);
+               break;
+       case AUDIT_MAC_IPSEC_DELSA:
+               audit_log_format(audit_buf, "SAD delete: auid=%u", auid);
+               break;
+       case AUDIT_MAC_IPSEC_ADDSPD:
+               audit_log_format(audit_buf, "SPD add: auid=%u", auid);
+               break;
+       case AUDIT_MAC_IPSEC_DELSPD:
+               audit_log_format(audit_buf, "SPD delete: auid=%u", auid);
+               break;
+       default:
+               return;
+       }
+
+       if (sid != 0 &&
+               security_secid_to_secctx(sid, &secctx, &secctx_len) == 0)
+               audit_log_format(audit_buf, " subj=%s", secctx);
+       else
+               audit_log_task_context(audit_buf);
+
+       if (xp) {
+               family = xp->selector.family;
+               if (xp->security)
+                       sctx = xp->security;
+       } else {
+               family = x->props.family;
+               if (x->security)
+                       sctx = x->security;
+       }
+
+       if (sctx)
+               audit_log_format(audit_buf,
+                               " sec_alg=%u sec_doi=%u sec_obj=%s",
+                               sctx->ctx_alg, sctx->ctx_doi, sctx->ctx_str);
+
+       switch(family) {
+       case AF_INET:
+               {
+                       struct in_addr saddr, daddr;
+                       if (xp) {
+                               saddr.s_addr = xp->selector.saddr.a4;
+                               daddr.s_addr = xp->selector.daddr.a4;
+                       } else {
+                               saddr.s_addr = x->props.saddr.a4;
+                               daddr.s_addr = x->id.daddr.a4;
+                       }
+                       audit_log_format(audit_buf,
+                                        " src=%u.%u.%u.%u dst=%u.%u.%u.%u",
+                                        NIPQUAD(saddr), NIPQUAD(daddr));
+               }
+                       break;
+       case AF_INET6:
+               {
+                       struct in6_addr saddr6, daddr6;
+                       if (xp) {
+                               memcpy(&saddr6, xp->selector.saddr.a6,
+                                       sizeof(struct in6_addr));
+                               memcpy(&daddr6, xp->selector.daddr.a6,
+                                       sizeof(struct in6_addr));
+                       } else {
+                               memcpy(&saddr6, x->props.saddr.a6,
+                                       sizeof(struct in6_addr));
+                               memcpy(&daddr6, x->id.daddr.a6,
+                                       sizeof(struct in6_addr));
+                       }
+                       audit_log_format(audit_buf,
+                                        " src=" NIP6_FMT "dst=" NIP6_FMT,
+                                        NIP6(saddr6), NIP6(daddr6));
+               }
+               break;
+       }
+
+       if (x)
+               audit_log_format(audit_buf, " spi=%lu(0x%lx) protocol=%s",
+                               (unsigned long)ntohl(x->id.spi),
+                               (unsigned long)ntohl(x->id.spi),
+                               x->id.proto == IPPROTO_AH ? "AH" :
+                               (x->id.proto == IPPROTO_ESP ?
+                               "ESP" : "IPCOMP"));
+
+       audit_log_format(audit_buf, " res=%u", result);
+       audit_log_end(audit_buf);
+}
+
+EXPORT_SYMBOL(xfrm_audit_log);
+#endif /* CONFIG_AUDITSYSCALL */
+
 int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
 {
        int err = 0;
index da54a64ccfa3b9ffb4d4401ad3fac881591ce2dd..fdb08d9f34aa684b1180985e031e77f1de116f55 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/module.h>
 #include <linux/cache.h>
 #include <asm/uaccess.h>
+#include <linux/audit.h>
 
 #include "xfrm_hash.h"
 
@@ -238,6 +239,7 @@ static void xfrm_timer_handler(unsigned long data)
        unsigned long now = (unsigned long)xtime.tv_sec;
        long next = LONG_MAX;
        int warn = 0;
+       int err = 0;
 
        spin_lock(&x->lock);
        if (x->km.state == XFRM_STATE_DEAD)
@@ -295,9 +297,14 @@ expired:
                next = 2;
                goto resched;
        }
-       if (!__xfrm_state_delete(x) && x->id.spi)
+
+       err = __xfrm_state_delete(x);
+       if (!err && x->id.spi)
                km_state_expired(x, 1, 0);
 
+       xfrm_audit_log(audit_get_loginuid(current->audit_context), 0,
+                      AUDIT_MAC_IPSEC_DELSA, err ? 0 : 1, NULL, x);
+
 out:
        spin_unlock(&x->lock);
 }
@@ -384,9 +391,10 @@ int xfrm_state_delete(struct xfrm_state *x)
 }
 EXPORT_SYMBOL(xfrm_state_delete);
 
-void xfrm_state_flush(u8 proto)
+void xfrm_state_flush(u8 proto, struct xfrm_audit *audit_info)
 {
        int i;
+       int err = 0;
 
        spin_lock_bh(&xfrm_state_lock);
        for (i = 0; i <= xfrm_state_hmask; i++) {
@@ -399,7 +407,11 @@ restart:
                                xfrm_state_hold(x);
                                spin_unlock_bh(&xfrm_state_lock);
 
-                               xfrm_state_delete(x);
+                               err = xfrm_state_delete(x);
+                               xfrm_audit_log(audit_info->loginuid,
+                                              audit_info->secid,
+                                              AUDIT_MAC_IPSEC_DELSA,
+                                              err ? 0 : 1, NULL, x);
                                xfrm_state_put(x);
 
                                spin_lock_bh(&xfrm_state_lock);
@@ -1099,7 +1111,7 @@ int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*),
                    void *data)
 {
        int i;
-       struct xfrm_state *x;
+       struct xfrm_state *x, *last = NULL;
        struct hlist_node *entry;
        int count = 0;
        int err = 0;
@@ -1107,24 +1119,22 @@ int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*),
        spin_lock_bh(&xfrm_state_lock);
        for (i = 0; i <= xfrm_state_hmask; i++) {
                hlist_for_each_entry(x, entry, xfrm_state_bydst+i, bydst) {
-                       if (xfrm_id_proto_match(x->id.proto, proto))
-                               count++;
+                       if (!xfrm_id_proto_match(x->id.proto, proto))
+                               continue;
+                       if (last) {
+                               err = func(last, count, data);
+                               if (err)
+                                       goto out;
+                       }
+                       last = x;
+                       count++;
                }
        }
        if (count == 0) {
                err = -ENOENT;
                goto out;
        }
-
-       for (i = 0; i <= xfrm_state_hmask; i++) {
-               hlist_for_each_entry(x, entry, xfrm_state_bydst+i, bydst) {
-                       if (!xfrm_id_proto_match(x->id.proto, proto))
-                               continue;
-                       err = func(x, --count, data);
-                       if (err)
-                               goto out;
-               }
-       }
+       err = func(last, 0, data);
 out:
        spin_unlock_bh(&xfrm_state_lock);
        return err;
index 311205ffa7750747197135e23984f0adb6e5178c..e5372b11fc8f105bd4ecf6071c0418f71855760c 100644 (file)
@@ -31,6 +31,7 @@
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
 #include <linux/in6.h>
 #endif
+#include <linux/audit.h>
 
 static int verify_one_alg(struct rtattr **xfrma, enum xfrm_attr_type_t type)
 {
@@ -454,6 +455,9 @@ static int xfrm_add_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma)
        else
                err = xfrm_state_update(x);
 
+       xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
+                      AUDIT_MAC_IPSEC_ADDSA, err ? 0 : 1, NULL, x);
+
        if (err < 0) {
                x->km.state = XFRM_STATE_DEAD;
                __xfrm_state_put(x);
@@ -523,6 +527,10 @@ static int xfrm_del_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma)
        }
 
        err = xfrm_state_delete(x);
+
+       xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
+                      AUDIT_MAC_IPSEC_DELSA, err ? 0 : 1, NULL, x);
+
        if (err < 0)
                goto out;
 
@@ -1030,6 +1038,9 @@ static int xfrm_add_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfr
         * a type XFRM_MSG_UPDPOLICY - JHS */
        excl = nlh->nlmsg_type == XFRM_MSG_NEWPOLICY;
        err = xfrm_policy_insert(p->dir, xp, excl);
+       xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
+                      AUDIT_MAC_IPSEC_DELSPD, err ? 0 : 1, xp, NULL);
+
        if (err) {
                security_xfrm_policy_free(xp);
                kfree(xp);
@@ -1257,6 +1268,10 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfr
                xp = xfrm_policy_bysel_ctx(type, p->dir, &p->sel, tmp.security, delete);
                security_xfrm_policy_free(&tmp);
        }
+       if (delete)
+               xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
+                              AUDIT_MAC_IPSEC_DELSPD, (xp) ? 1 : 0, xp, NULL);
+
        if (xp == NULL)
                return -ENOENT;
 
@@ -1291,8 +1306,11 @@ static int xfrm_flush_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma
 {
        struct km_event c;
        struct xfrm_usersa_flush *p = NLMSG_DATA(nlh);
+       struct xfrm_audit audit_info;
 
-       xfrm_state_flush(p->proto);
+       audit_info.loginuid = NETLINK_CB(skb).loginuid;
+       audit_info.secid = NETLINK_CB(skb).sid;
+       xfrm_state_flush(p->proto, &audit_info);
        c.data.proto = p->proto;
        c.event = nlh->nlmsg_type;
        c.seq = nlh->nlmsg_seq;
@@ -1442,12 +1460,15 @@ static int xfrm_flush_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **x
        struct km_event c;
        u8 type = XFRM_POLICY_TYPE_MAIN;
        int err;
+       struct xfrm_audit audit_info;
 
        err = copy_from_user_policy_type(&type, (struct rtattr **)xfrma);
        if (err)
                return err;
 
-       xfrm_policy_flush(type);
+       audit_info.loginuid = NETLINK_CB(skb).loginuid;
+       audit_info.secid = NETLINK_CB(skb).sid;
+       xfrm_policy_flush(type, &audit_info);
        c.data.type = type;
        c.event = nlh->nlmsg_type;
        c.seq = nlh->nlmsg_seq;
@@ -1502,6 +1523,9 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh, void *
        err = 0;
        if (up->hard) {
                xfrm_policy_delete(xp, p->dir);
+               xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
+                               AUDIT_MAC_IPSEC_DELSPD, 1, xp, NULL);
+
        } else {
                // reset the timers here?
                printk("Dont know what to do with soft policy expire\n");
@@ -1533,8 +1557,11 @@ static int xfrm_add_sa_expire(struct sk_buff *skb, struct nlmsghdr *nlh, void **
                goto out;
        km_state_expired(x, ue->hard, current->pid);
 
-       if (ue->hard)
+       if (ue->hard) {
                __xfrm_state_delete(x);
+               xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
+                              AUDIT_MAC_IPSEC_DELSA, 1, NULL, x);
+       }
 out:
        spin_unlock_bh(&x->lock);
        xfrm_state_put(x);
index 22d281c6ec244c16bb0dc1c870e7f5c5ce913fb5..8b809b264d18356ead4dc3012a2a091e3f423cb5 100644 (file)
@@ -43,7 +43,7 @@ struct sym_entry {
 
 static struct sym_entry *table;
 static unsigned int table_size, table_cnt;
-static unsigned long long _stext, _etext, _sinittext, _einittext, _sextratext, _eextratext;
+static unsigned long long _text, _stext, _etext, _sinittext, _einittext, _sextratext, _eextratext;
 static int all_symbols = 0;
 static char symbol_prefix_char = '\0';
 
@@ -91,7 +91,9 @@ static int read_symbol(FILE *in, struct sym_entry *s)
                sym++;
 
        /* Ignore most absolute/undefined (?) symbols. */
-       if (strcmp(sym, "_stext") == 0)
+       if (strcmp(sym, "_text") == 0)
+               _text = s->addr;
+       else if (strcmp(sym, "_stext") == 0)
                _stext = s->addr;
        else if (strcmp(sym, "_etext") == 0)
                _etext = s->addr;
@@ -263,11 +265,27 @@ static void write_src(void)
        printf("#define ALGN .align 4\n");
        printf("#endif\n");
 
-       printf(".data\n");
+       printf("\t.section .rodata, \"a\"\n");
 
+       /* Provide proper symbols relocatability by their '_text'
+        * relativeness.  The symbol names cannot be used to construct
+        * normal symbol references as the list of symbols contains
+        * symbols that are declared static and are private to their
+        * .o files.  This prevents .tmp_kallsyms.o or any other
+        * object from referencing them.
+        */
        output_label("kallsyms_addresses");
        for (i = 0; i < table_cnt; i++) {
-               printf("\tPTR\t%#llx\n", table[i].addr);
+               if (toupper(table[i].sym[0]) != 'A') {
+                       if (_text <= table[i].addr)
+                               printf("\tPTR\t_text + %#llx\n",
+                                       table[i].addr - _text);
+                       else
+                               printf("\tPTR\t_text - %#llx\n",
+                                       _text - table[i].addr);
+               } else {
+                       printf("\tPTR\t%#llx\n", table[i].addr);
+               }
        }
        printf("\n");
 
index 338bdea9654177316a9044c86a9667039fb6845e..f5628c57640b134fe2f8689fd3993d43f011ca3e 100644 (file)
@@ -798,7 +798,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
                        QAction *action;
 
                        headerPopup = new QPopupMenu(this);
-                       action = new QAction("Show Name", 0, this);
+                       action = new QAction(NULL, "Show Name", 0, this);
                          action->setToggleAction(TRUE);
                          connect(action, SIGNAL(toggled(bool)),
                                  parent(), SLOT(setShowName(bool)));
@@ -806,7 +806,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
                                  action, SLOT(setOn(bool)));
                          action->setOn(showName);
                          action->addTo(headerPopup);
-                       action = new QAction("Show Range", 0, this);
+                       action = new QAction(NULL, "Show Range", 0, this);
                          action->setToggleAction(TRUE);
                          connect(action, SIGNAL(toggled(bool)),
                                  parent(), SLOT(setShowRange(bool)));
@@ -814,7 +814,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
                                  action, SLOT(setOn(bool)));
                          action->setOn(showRange);
                          action->addTo(headerPopup);
-                       action = new QAction("Show Data", 0, this);
+                       action = new QAction(NULL, "Show Data", 0, this);
                          action->setToggleAction(TRUE);
                          connect(action, SIGNAL(toggled(bool)),
                                  parent(), SLOT(setShowData(bool)));
@@ -1161,7 +1161,7 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char
 QPopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos)
 {
        QPopupMenu* popup = Parent::createPopupMenu(pos);
-       QAction* action = new QAction("Show Debug Info", 0, popup);
+       QAction* action = new QAction(NULL,"Show Debug Info", 0, popup);
          action->setToggleAction(TRUE);
          connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
          connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool)));
index 187f5de4612c2247bee0e003ac397db6ff70cbc1..df3b272f7ce6b1d47bc2014b9c5f18e9ec763d2b 100755 (executable)
@@ -1430,7 +1430,7 @@ sub create_parameterlist($$$) {
            # corresponding data structures "correctly". Catch it later in
            # output_* subs.
            push_parameter($arg, "", $file);
-       } elsif ($arg =~ m/\(/) {
+       } elsif ($arg =~ m/\(.*\*/) {
            # pointer-to-function
            $arg =~ tr/#/,/;
            $arg =~ m/[^\(]+\(\*([^\)]+)\)/;
index 2e1141623147887ffa2f91bb6e53b362a0a5f821..ac0a582229924d3d65d7903724fe2900a424088a 100644 (file)
@@ -911,6 +911,7 @@ static int init_section_ref_ok(const char *name)
                ".toc1",  /* used by ppc64 */
                ".stab",
                ".rodata",
+               ".parainstructions",
                ".text.lock",
                "__bug_table", /* used by powerpc for BUG() */
                ".pci_fixup_header",
@@ -931,6 +932,7 @@ static int init_section_ref_ok(const char *name)
                ".altinstructions",
                ".eh_frame",
                ".debug",
+               ".parainstructions",
                NULL
        };
        /* part of section name */
index 84999f69773d6cc232ea6db365eac38e4e1b83ba..72876dfadc8ae9fd6125737910cd8555ae8d17f1 100755 (executable)
@@ -48,6 +48,8 @@ fsck.reiser4 -V 2>&1 | grep ^fsck.reiser4 | awk \
 xfs_db -V 2>&1 | grep version | awk \
 'NR==1{print "xfsprogs              ", $3}'
 
+pccardctl -V 2>&1| grep pcmciautils | awk '{print "pcmciautils           ", $2}'
+
 cardmgr -V 2>&1| grep version | awk \
 'NR==1{print "pcmcia-cs             ", $3}'
 
@@ -87,10 +89,16 @@ loadkeys -h 2>&1 | awk \
 loadkeys -V 2>&1 | awk \
 '(NR==1 && ($2 ~ /console-tools/)) {print "Console-tools         ", $3}'
 
+oprofiled --version 2>&1 | awk \
+'(NR==1 && ($2 == "oprofile")) {print "oprofile              ", $3}'
+
 expr --v 2>&1 | awk 'NR==1{print "Sh-utils              ", $NF}'
 
 udevinfo -V 2>&1 | grep version | awk '{print "udev                  ", $3}'
 
+iwconfig --version 2>&1 | awk \
+'(NR==1 && ($3 == "version")) {print "wireless-tools        ",$4}'
+
 if [ -e /proc/modules ]; then
     X=`cat /proc/modules | sed -e "s/ .*$//"`
     echo "Modules Loaded         "$X
index 70eacbe5abde215e61d1eb74c95bd89f7133a2ba..ac9326c5f1da3f1e1781d8654ac816bb83355560 100644 (file)
@@ -20,7 +20,7 @@
 #include <linux/err.h>
 #include "internal.h"
 
-static kmem_cache_t    *key_jar;
+static struct kmem_cache       *key_jar;
 struct rb_root         key_serial_tree; /* tree of keys indexed by serial */
 DEFINE_SPINLOCK(key_serial_lock);
 
@@ -285,16 +285,14 @@ struct key *key_alloc(struct key_type *type, const char *desc,
        }
 
        /* allocate and initialise the key and its description */
-       key = kmem_cache_alloc(key_jar, SLAB_KERNEL);
+       key = kmem_cache_alloc(key_jar, GFP_KERNEL);
        if (!key)
                goto no_memory_2;
 
        if (desc) {
-               key->description = kmalloc(desclen, GFP_KERNEL);
+               key->description = kmemdup(desc, desclen, GFP_KERNEL);
                if (!key->description)
                        goto no_memory_3;
-
-               memcpy(key->description, desc, desclen);
        }
 
        atomic_set(&key->usage, 1);
index e8d02acc51e7180f23a31b849ccce820418fd55c..ad45ce73964b193db630606c2d302dd6414f57c9 100644 (file)
@@ -706,12 +706,10 @@ int __key_link(struct key *keyring, struct key *key)
                                BUG_ON(size > PAGE_SIZE);
 
                                ret = -ENOMEM;
-                               nklist = kmalloc(size, GFP_KERNEL);
+                               nklist = kmemdup(klist, size, GFP_KERNEL);
                                if (!nklist)
                                        goto error2;
 
-                               memcpy(nklist, klist, size);
-
                                /* replace matched key */
                                atomic_inc(&key->usage);
                                nklist->keys[loop] = key;
index 32150cf7c37f8de1662758746e1123a6e8a100e6..b6f86808475a0aedfb28e9d677fda7db553f006b 100644 (file)
@@ -27,7 +27,7 @@ static DEFINE_MUTEX(key_session_mutex);
 struct key_user root_key_user = {
        .usage          = ATOMIC_INIT(3),
        .consq          = LIST_HEAD_INIT(root_key_user.consq),
-       .lock           = SPIN_LOCK_UNLOCKED,
+       .lock           = __SPIN_LOCK_UNLOCKED(root_key_user.lock),
        .nkeys          = ATOMIC_INIT(2),
        .nikeys         = ATOMIC_INIT(2),
        .uid            = 0,
index e73ac1ab7cfd49fef995f4dc63694276aa563037..e7c0b5e2066bbb532995ba0758516c236b60c1d1 100644 (file)
@@ -124,7 +124,7 @@ DEFINE_PER_CPU(struct avc_cache_stats, avc_cache_stats) = { 0 };
 
 static struct avc_cache avc_cache;
 static struct avc_callback_node *avc_callbacks;
-static kmem_cache_t *avc_node_cachep;
+static struct kmem_cache *avc_node_cachep;
 
 static inline int avc_hash(u32 ssid, u32 tsid, u16 tclass)
 {
@@ -332,7 +332,7 @@ static struct avc_node *avc_alloc_node(void)
 {
        struct avc_node *node;
 
-       node = kmem_cache_alloc(avc_node_cachep, SLAB_ATOMIC);
+       node = kmem_cache_alloc(avc_node_cachep, GFP_ATOMIC);
        if (!node)
                goto out;
 
index 78f98fe084ebdd57e9bf24e223e590487e2018fd..3753416eb9b98834e2d3645a761de7f2e595717c 100644 (file)
@@ -124,7 +124,7 @@ static struct security_operations *secondary_ops = NULL;
 static LIST_HEAD(superblock_security_head);
 static DEFINE_SPINLOCK(sb_security_lock);
 
-static kmem_cache_t *sel_inode_cache;
+static struct kmem_cache *sel_inode_cache;
 
 /* Return security context for a given sid or just the context 
    length if the buffer is null or length is 0 */
@@ -181,7 +181,7 @@ static int inode_alloc_security(struct inode *inode)
        struct task_security_struct *tsec = current->security;
        struct inode_security_struct *isec;
 
-       isec = kmem_cache_alloc(sel_inode_cache, SLAB_KERNEL);
+       isec = kmem_cache_alloc(sel_inode_cache, GFP_KERNEL);
        if (!isec)
                return -ENOMEM;
 
@@ -1120,8 +1120,8 @@ static int file_has_perm(struct task_struct *tsk,
 {
        struct task_security_struct *tsec = tsk->security;
        struct file_security_struct *fsec = file->f_security;
-       struct vfsmount *mnt = file->f_vfsmnt;
-       struct dentry *dentry = file->f_dentry;
+       struct vfsmount *mnt = file->f_path.mnt;
+       struct dentry *dentry = file->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        struct avc_audit_data ad;
        int rc;
@@ -1581,7 +1581,7 @@ static int selinux_bprm_alloc_security(struct linux_binprm *bprm)
 static int selinux_bprm_set_security(struct linux_binprm *bprm)
 {
        struct task_security_struct *tsec;
-       struct inode *inode = bprm->file->f_dentry->d_inode;
+       struct inode *inode = bprm->file->f_path.dentry->d_inode;
        struct inode_security_struct *isec;
        struct bprm_security_struct *bsec;
        u32 newsid;
@@ -1621,10 +1621,10 @@ static int selinux_bprm_set_security(struct linux_binprm *bprm)
        }
 
        AVC_AUDIT_DATA_INIT(&ad, FS);
-       ad.u.fs.mnt = bprm->file->f_vfsmnt;
-       ad.u.fs.dentry = bprm->file->f_dentry;
+       ad.u.fs.mnt = bprm->file->f_path.mnt;
+       ad.u.fs.dentry = bprm->file->f_path.dentry;
 
-       if (bprm->file->f_vfsmnt->mnt_flags & MNT_NOSUID)
+       if (bprm->file->f_path.mnt->mnt_flags & MNT_NOSUID)
                newsid = tsec->sid;
 
         if (tsec->sid == newsid) {
@@ -1695,9 +1695,10 @@ static inline void flush_unauthorized_files(struct files_struct * files)
        struct tty_struct *tty;
        struct fdtable *fdt;
        long j = -1;
+       int drop_tty = 0;
 
        mutex_lock(&tty_mutex);
-       tty = current->signal->tty;
+       tty = get_current_tty();
        if (tty) {
                file_list_lock();
                file = list_entry(tty->tty_files.next, typeof(*file), f_u.fu_list);
@@ -1707,15 +1708,17 @@ static inline void flush_unauthorized_files(struct files_struct * files)
                           than using file_has_perm, as this particular open
                           file may belong to another process and we are only
                           interested in the inode-based check here. */
-                       struct inode *inode = file->f_dentry->d_inode;
+                       struct inode *inode = file->f_path.dentry->d_inode;
                        if (inode_has_perm(current, inode,
                                           FILE__READ | FILE__WRITE, NULL)) {
-                               /* Reset controlling tty. */
-                               current->signal->tty = NULL;
-                               current->signal->tty_old_pgrp = 0;
+                               drop_tty = 1;
                        }
                }
                file_list_unlock();
+
+               /* Reset controlling tty. */
+               if (drop_tty)
+                       proc_set_tty(current, NULL);
        }
        mutex_unlock(&tty_mutex);
 
@@ -2417,7 +2420,7 @@ static int selinux_inode_listsecurity(struct inode *inode, char *buffer, size_t
 static int selinux_file_permission(struct file *file, int mask)
 {
        int rc;
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
 
        if (!mask) {
                /* No permission to check.  Existence test. */
@@ -2594,7 +2597,7 @@ static int selinux_file_fcntl(struct file *file, unsigned int cmd,
 
        switch (cmd) {
                case F_SETFL:
-                       if (!file->f_dentry || !file->f_dentry->d_inode) {
+                       if (!file->f_path.dentry || !file->f_path.dentry->d_inode) {
                                err = -EINVAL;
                                break;
                        }
@@ -2620,7 +2623,7 @@ static int selinux_file_fcntl(struct file *file, unsigned int cmd,
                case F_SETLK64:
                case F_SETLKW64:
 #endif
-                       if (!file->f_dentry || !file->f_dentry->d_inode) {
+                       if (!file->f_path.dentry || !file->f_path.dentry->d_inode) {
                                err = -EINVAL;
                                break;
                        }
index cd244419c980b2ef7cfd2df7ce4e4bdae252ccb2..c8bf6e172f6e02ed8246f26d642d8841181b8151 100644 (file)
@@ -448,7 +448,7 @@ static ssize_t (*write_op[])(struct file *, char *, size_t) = {
 
 static ssize_t selinux_transaction_write(struct file *file, const char __user *buf, size_t size, loff_t *pos)
 {
-       ino_t ino =  file->f_dentry->d_inode->i_ino;
+       ino_t ino =  file->f_path.dentry->d_inode->i_ino;
        char *data;
        ssize_t rv;
 
@@ -805,7 +805,7 @@ static ssize_t sel_read_bool(struct file *filep, char __user *buf,
                goto out;
        }
 
-       inode = filep->f_dentry->d_inode;
+       inode = filep->f_path.dentry->d_inode;
        cur_enforcing = security_get_bool_value(inode->i_ino - BOOL_INO_OFFSET);
        if (cur_enforcing < 0) {
                ret = cur_enforcing;
@@ -864,7 +864,7 @@ static ssize_t sel_write_bool(struct file *filep, const char __user *buf,
        if (new_value)
                new_value = 1;
 
-       inode = filep->f_dentry->d_inode;
+       inode = filep->f_path.dentry->d_inode;
        bool_pending_values[inode->i_ino - BOOL_INO_OFFSET] = new_value;
        length = count;
 
@@ -965,7 +965,7 @@ static void sel_remove_bools(struct dentry *de)
        file_list_lock();
        list_for_each(p, &sb->s_files) {
                struct file * filp = list_entry(p, struct file, f_u.fu_list);
-               struct dentry * dentry = filp->f_dentry;
+               struct dentry * dentry = filp->f_path.dentry;
 
                if (dentry->d_parent != de) {
                        continue;
index d049c7acbc8bc9b5a03853eeeb0496ac0901ee45..ebb993c5c244d3e5fb72468eee758fe40550e23a 100644 (file)
@@ -28,7 +28,7 @@
  (keyp->source_type << 9)) & \
  AVTAB_HASH_MASK)
 
-static kmem_cache_t *avtab_node_cachep;
+static struct kmem_cache *avtab_node_cachep;
 
 static struct avtab_node*
 avtab_insert_node(struct avtab *h, int hvalue,
@@ -36,7 +36,7 @@ avtab_insert_node(struct avtab *h, int hvalue,
                  struct avtab_key *key, struct avtab_datum *datum)
 {
        struct avtab_node * newnode;
-       newnode = kmem_cache_alloc(avtab_node_cachep, SLAB_KERNEL);
+       newnode = kmem_cache_alloc(avtab_node_cachep, GFP_KERNEL);
        if (newnode == NULL)
                return NULL;
        memset(newnode, 0, sizeof(struct avtab_node));
index c79a9afd0955e2b9a2fa98fb5872616cef819ac4..c7e1b26461938eea09e0381fd0e83e213219fb4f 100644 (file)
@@ -125,7 +125,7 @@ struct audio_stream {
 #else
        dma_regs_t *dma_regs;   /* points to our DMA registers */
 #endif
-       int active:1;           /* we are using this stream for transfer now */
+       unsigned int active:1;  /* we are using this stream for transfer now */
        int period;             /* current transfer period */
        int periods;            /* current count of periods registerd in the DMA engine */
        int tx_spin;            /* are we recoding - flag used to do DMA trans. for sync */
index 0b4aab3225e5270a998e77e06e7821973b3e2146..54591e2eb6eea23d8febdf0d42d94421d5db3a3f 100644 (file)
@@ -488,7 +488,7 @@ static long snd_info_entry_ioctl(struct file *file, unsigned int cmd,
 
 static int snd_info_entry_mmap(struct file *file, struct vm_area_struct *vma)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        struct snd_info_private_data *data;
        struct snd_info_entry *entry;
 
index 66e24b5da4694dbaa40529a98b14743520aa41ef..b52e89393fa399062c93b46b81f3fa84be36d591 100644 (file)
@@ -1604,7 +1604,7 @@ static struct file *snd_pcm_file_fd(int fd)
        file = fget(fd);
        if (!file)
                return NULL;
-       inode = file->f_dentry->d_inode;
+       inode = file->f_path.dentry->d_inode;
        if (!S_ISCHR(inode->i_mode) ||
            imajor(inode) != snd_major) {
                fput(file);
@@ -3027,7 +3027,7 @@ static struct page * snd_pcm_mmap_status_nopage(struct vm_area_struct *area,
        struct page * page;
        
        if (substream == NULL)
-               return NOPAGE_OOM;
+               return NOPAGE_SIGBUS;
        runtime = substream->runtime;
        page = virt_to_page(runtime->status);
        get_page(page);
@@ -3070,7 +3070,7 @@ static struct page * snd_pcm_mmap_control_nopage(struct vm_area_struct *area,
        struct page * page;
        
        if (substream == NULL)
-               return NOPAGE_OOM;
+               return NOPAGE_SIGBUS;
        runtime = substream->runtime;
        page = virt_to_page(runtime->control);
        get_page(page);
@@ -3131,18 +3131,18 @@ static struct page *snd_pcm_mmap_data_nopage(struct vm_area_struct *area,
        size_t dma_bytes;
        
        if (substream == NULL)
-               return NOPAGE_OOM;
+               return NOPAGE_SIGBUS;
        runtime = substream->runtime;
        offset = area->vm_pgoff << PAGE_SHIFT;
        offset += address - area->vm_start;
-       snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM);
+       snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_SIGBUS);
        dma_bytes = PAGE_ALIGN(runtime->dma_bytes);
        if (offset > dma_bytes - PAGE_SIZE)
                return NOPAGE_SIGBUS;
        if (substream->ops->page) {
                page = substream->ops->page(substream, offset);
                if (! page)
-                       return NOPAGE_OOM;
+                       return NOPAGE_OOM; /* XXX: is this really due to OOM? */
        } else {
                vaddr = runtime->dma_area + offset;
                page = virt_to_page(vaddr);
index cc2b9ab7f4e5355d490aeebff240240b2a9446f1..a0588c21324ac6ae98fbfccbf286139c1a97d582 100644 (file)
@@ -5,20 +5,6 @@
 #
 # Prompt user for primary drivers.
 
-config OSS_OBSOLETE_DRIVER
-       bool "Obsolete OSS drivers"
-       depends on SOUND_PRIME
-       help
-         This option enables support for obsolete OSS drivers that
-         are scheduled for removal in the near future since there
-         are ALSA drivers for the same hardware.
-
-         Please contact Adrian Bunk <bunk@stusta.de> if you had to
-         say Y here because your soundcard is not properly supported
-         by ALSA.
-
-         If unsure, say N.
-
 config SOUND_BT878
        tristate "BT878 audio dma"
        depends on SOUND_PRIME && PCI
@@ -35,40 +21,6 @@ config SOUND_BT878
          To compile this driver as a module, choose M here: the module will
          be called btaudio.
 
-config SOUND_EMU10K1
-       tristate "Creative SBLive! (EMU10K1)"
-       depends on SOUND_PRIME && PCI && OSS_OBSOLETE_DRIVER
-       ---help---
-         Say Y or M if you have a PCI sound card using the EMU10K1 chipset,
-         such as the Creative SBLive!, SB PCI512 or Emu-APS.
-
-         For more information on this driver and the degree of support for
-         the different card models please check:
-
-               <http://sourceforge.net/projects/emu10k1/>
-
-         It is now possible to load dsp microcode patches into the EMU10K1
-         chip.  These patches are used to implement real time sound
-         processing effects which include for example: signal routing,
-         bass/treble control, AC3 passthrough, ...
-         Userspace tools to create new patches and load/unload them can be
-         found in the emu-tools package at the above URL.
-
-config MIDI_EMU10K1
-       bool "Creative SBLive! MIDI (EXPERIMENTAL)"
-       depends on SOUND_EMU10K1 && EXPERIMENTAL && ISA_DMA_API
-       help
-         Say Y if you want to be able to use the OSS /dev/sequencer
-         interface.  This code is still experimental.
-
-config SOUND_FUSION
-       tristate "Crystal SoundFusion (CS4280/461x)"
-       depends on SOUND_PRIME && PCI && OSS_OBSOLETE_DRIVER
-       help
-         This module drives the Crystal SoundFusion devices (CS4280/46xx
-         series) when wired as native sound drivers with AC97 codecs.  If
-         this driver does not work try the CS4232 driver.
-
 config SOUND_BCM_CS4297A
        tristate "Crystal Sound CS4297a (for Swarm)"
        depends on SOUND_PRIME && SIBYTE_SWARM
@@ -448,47 +400,6 @@ config SOUND_DMAP
 
          Say Y unless you have 16MB or more RAM or a PCI sound card.
 
-config SOUND_AD1816
-       tristate "AD1816(A) based cards (EXPERIMENTAL)"
-       depends on EXPERIMENTAL && SOUND_OSS && OSS_OBSOLETE_DRIVER
-       help
-         Say M here if you have a sound card based on the Analog Devices
-         AD1816(A) chip.
-
-         If you compile the driver into the kernel, you have to add
-         "ad1816=<io>,<irq>,<dma>,<dma2>" to the kernel command line.
-
-config SOUND_AD1889
-       tristate "AD1889 based cards (AD1819 codec) (EXPERIMENTAL)"
-       depends on EXPERIMENTAL && SOUND_OSS && PCI && OSS_OBSOLETE_DRIVER
-       help
-         Say M here if you have a sound card based on the Analog Devices
-         AD1889 chip.
-
-config SOUND_ADLIB
-       tristate "Adlib Cards"
-       depends on SOUND_OSS && OSS_OBSOLETE_DRIVER
-       help
-         Includes ASB 64 4D. Information on programming AdLib cards is
-         available at <http://www.itsnet.com/home/ldragon/Specs/adlib.html>.
-
-config SOUND_ACI_MIXER
-       tristate "ACI mixer (miroSOUND PCM1-pro/PCM12/PCM20)"
-       depends on SOUND_OSS && OSS_OBSOLETE_DRIVER
-       ---help---
-         ACI (Audio Command Interface) is a protocol used to communicate with
-         the microcontroller on some sound cards produced by miro and
-         Cardinal Technologies.  The main function of the ACI is to control
-         the mixer and to get a product identification.
-
-         This VoxWare ACI driver currently supports the ACI functions on the
-         miroSOUND PCM1-pro, PCM12 and PCM20 radio. On the PCM20 radio, ACI
-         also controls the radio tuner. This is supported in the video4linux
-         miropcm20 driver (say M or Y here and go back to "Multimedia
-         devices" -> "Radio Adapters").
-
-         This driver is also available as a module and will be called aci.
-
 config SOUND_CS4232
        tristate "Crystal CS4232 based (PnP) cards"
        depends on SOUND_OSS
@@ -594,18 +505,6 @@ config SOUND_MPU401
          If you compile the driver into the kernel, you have to add
          "mpu401=<io>,<irq>" to the kernel command line.
 
-config SOUND_NM256
-       tristate "NM256AV/NM256ZX audio support"
-       depends on SOUND_OSS && OSS_OBSOLETE_DRIVER
-       help
-         Say M here to include audio support for the NeoMagic 256AV/256ZX
-         chipsets. These are the audio chipsets found in the Sony
-         Z505S/SX/DX, some Sony F-series, and the Dell Latitude CPi and CPt
-         laptops. It includes support for an AC97-compatible mixer and an
-         apparently proprietary sound engine.
-
-         See <file:Documentation/sound/oss/NM256> for further information.
-
 config SOUND_PAS
        tristate "ProAudioSpectrum 16 support"
        depends on SOUND_OSS
@@ -714,20 +613,6 @@ config SOUND_YM3812
 
          If unsure, say Y.
 
-config SOUND_OPL3SA2
-       tristate "Yamaha OPL3-SA2 and SA3 based PnP cards"
-       depends on SOUND_OSS && OSS_OBSOLETE_DRIVER
-       help
-         Say Y or M if you have a card based on one of these Yamaha sound
-         chipsets or the "SAx", which is actually a SA3. Read
-         <file:Documentation/sound/oss/OPL3-SA2> for more information on
-         configuring these cards.
-
-         If you compile the driver into the kernel and do not also
-         configure in the optional ISA PnP support, you will have to add
-         "opl3sa2=<io>,<irq>,<dma>,<dma2>,<mssio>,<mpuio>" to the kernel
-         command line.
-
 config SOUND_UART6850
        tristate "6850 UART support"
        depends on SOUND_OSS
index 6ad38411423989b7d3232e92c7cd43f820574634..ad7210a00dc01ead45e119d7fed3f2c613124ed6 100644 (file)
@@ -1020,6 +1020,7 @@ static int __devinit btaudio_probe(struct pci_dev *pci_dev,
  fail2:
         free_irq(bta->irq,bta);        
  fail1:
+       iounmap(bta->mmio);
        kfree(bta);
  fail0:
        release_mem_region(pci_resource_start(pci_dev,0),
@@ -1051,6 +1052,7 @@ static void __devexit btaudio_remove(struct pci_dev *pci_dev)
         free_irq(bta->irq,bta);
        release_mem_region(pci_resource_start(pci_dev,0),
                           pci_resource_len(pci_dev,0));
+       iounmap(bta->mmio);
 
        /* remove from linked list */
        if (bta == btaudios) {
index 87bd3100aef3800cb9da9d56a25132c64d23aeef..80b836e80d993745b11b16dcd5c1f86da4c07795 100644 (file)
@@ -1051,7 +1051,7 @@ static int sq_release(struct inode *inode, struct file *file)
 
        if (file->f_mode & FMODE_WRITE) {
                if (write_sq.busy)
-                       rc = sq_fsync(file, file->f_dentry);
+                       rc = sq_fsync(file, file->f_path.dentry);
 
                sq_reset_output() ; /* make sure dma is stopped and all is quiet */
                write_sq_release_buffers();
@@ -1217,7 +1217,7 @@ static int sq_ioctl(struct inode *inode, struct file *file, u_int cmd,
                if ((file->f_mode & FMODE_READ) && dmasound.mach.record)
                        sq_reset_input() ;
                if (file->f_mode & FMODE_WRITE) {
-                       result = sq_fsync(file, file->f_dentry);
+                       result = sq_fsync(file, file->f_path.dentry);
                        sq_reset_output() ;
                }
                /* if we are the shared resource owner then release them */
index 86dd23974e055110817c5d6a3f8e03664d487f2a..49f902f35c280a32d6441bcb6f1808fe811f1e46 100644 (file)
@@ -111,9 +111,15 @@ static ssize_t emu10k1_audio_read(struct file *file, char __user *buffer, size_t
 
                if ((bytestocopy >= wiinst->buffer.fragment_size)
                    || (bytestocopy >= count)) {
+                       int rc;
+
                        bytestocopy = min_t(u32, bytestocopy, count);
 
-                       emu10k1_wavein_xferdata(wiinst, (u8 __user *)buffer, &bytestocopy);
+                       rc = emu10k1_wavein_xferdata(wiinst,
+                                                    (u8 __user *)buffer,
+                                                    &bytestocopy);
+                       if (rc)
+                               return rc;
 
                        count -= bytestocopy;
                        buffer += bytestocopy;
index 8bbf44b881b40d3c3f2f7904e002a09769a74795..060d1be94d335f5fc5c6c1ef885c3e854bf69692 100644 (file)
@@ -304,11 +304,12 @@ void emu10k1_wavein_getxfersize(struct wiinst *wiinst, u32 * size)
        }
 }
 
-static void copy_block(u8 __user *dst, u8 * src, u32 str, u32 len, u8 cov)
+static int copy_block(u8 __user *dst, u8 * src, u32 str, u32 len, u8 cov)
 {
-       if (cov == 1)
-               __copy_to_user(dst, src + str, len);
-       else {
+       if (cov == 1) {
+               if (__copy_to_user(dst, src + str, len))
+                       return -EFAULT;
+       } else {
                u8 byte;
                u32 i;
 
@@ -316,22 +317,26 @@ static void copy_block(u8 __user *dst, u8 * src, u32 str, u32 len, u8 cov)
 
                for (i = 0; i < len; i++) {
                        byte = src[2 * i] ^ 0x80;
-                       __copy_to_user(dst + i, &byte, 1);
+                       if (__copy_to_user(dst + i, &byte, 1))
+                               return -EFAULT;
                }
        }
+
+       return 0;
 }
 
-void emu10k1_wavein_xferdata(struct wiinst *wiinst, u8 __user *data, u32 * size)
+int emu10k1_wavein_xferdata(struct wiinst *wiinst, u8 __user *data, u32 * size)
 {
        struct wavein_buffer *buffer = &wiinst->buffer;
        u32 sizetocopy, sizetocopy_now, start;
        unsigned long flags;
+       int ret;
 
        sizetocopy = min_t(u32, buffer->size, *size);
        *size = sizetocopy;
 
        if (!sizetocopy)
-               return;
+               return 0;
 
        spin_lock_irqsave(&wiinst->lock, flags);
        start = buffer->pos;
@@ -345,11 +350,17 @@ void emu10k1_wavein_xferdata(struct wiinst *wiinst, u8 __user *data, u32 * size)
        if (sizetocopy > sizetocopy_now) {
                sizetocopy -= sizetocopy_now;
 
-               copy_block(data, buffer->addr, start, sizetocopy_now, buffer->cov);
-               copy_block(data + sizetocopy_now, buffer->addr, 0, sizetocopy, buffer->cov);
+               ret = copy_block(data, buffer->addr, start, sizetocopy_now,
+                                buffer->cov);
+               if (ret == 0)
+                       ret = copy_block(data + sizetocopy_now, buffer->addr, 0,
+                                        sizetocopy, buffer->cov);
        } else {
-               copy_block(data, buffer->addr, start, sizetocopy, buffer->cov);
+               ret = copy_block(data, buffer->addr, start, sizetocopy,
+                                buffer->cov);
        }
+
+       return ret;
 }
 
 void emu10k1_wavein_update(struct emu10k1_card *card, struct wiinst *wiinst)
index 15cfb9b35596009faa5be7a935fe8283cb0807b7..e82029b46ad193970cc571f8e646768fd0ae153e 100644 (file)
@@ -83,7 +83,7 @@ void emu10k1_wavein_close(struct emu10k1_wavedevice *);
 void emu10k1_wavein_start(struct emu10k1_wavedevice *);
 void emu10k1_wavein_stop(struct emu10k1_wavedevice *);
 void emu10k1_wavein_getxfersize(struct wiinst *, u32 *);
-void emu10k1_wavein_xferdata(struct wiinst *, u8 __user *, u32 *);
+int emu10k1_wavein_xferdata(struct wiinst *, u8 __user *, u32 *);
 int emu10k1_wavein_setformat(struct emu10k1_wavedevice *, struct wave_format *);
 void emu10k1_wavein_update(struct emu10k1_card *, struct wiinst *);
 
index 4e3baca7d41f3d2856accd469e0292d749a07e47..6d21d4368decbe08aef8cdfd5c6745d7122c2bc1 100644 (file)
@@ -162,12 +162,15 @@ ssize_t emu10k1_pt_write(struct file *file, const char __user *buffer, size_t co
 
                DPD(3, "prepend size %d, prepending %d bytes\n", pt->prepend_size, needed);
                if (count < needed) {
-                       copy_from_user(pt->buf + pt->prepend_size, buffer, count);
+                       if (copy_from_user(pt->buf + pt->prepend_size,
+                                          buffer, count))
+                               return -EFAULT;
                        pt->prepend_size += count;
                        DPD(3, "prepend size now %d\n", pt->prepend_size);
                        return count;
                }
-               copy_from_user(pt->buf + pt->prepend_size, buffer, needed);
+               if (copy_from_user(pt->buf + pt->prepend_size, buffer, needed))
+                       return -EFAULT;
                r = pt_putblock(wave_dev, (u16 *) pt->buf, nonblock);
                if (r)
                        return r;
@@ -178,7 +181,8 @@ ssize_t emu10k1_pt_write(struct file *file, const char __user *buffer, size_t co
        blocks_copied = 0;
        while (blocks > 0) {
                u16 __user *bufptr = (u16 __user *) buffer + (bytes_copied/2);
-               copy_from_user(pt->buf, bufptr, PT_BLOCKSIZE);
+               if (copy_from_user(pt->buf, bufptr, PT_BLOCKSIZE))
+                       return -EFAULT;
                r = pt_putblock(wave_dev, (u16 *)pt->buf, nonblock);
                if (r) {
                        if (bytes_copied)
@@ -193,7 +197,8 @@ ssize_t emu10k1_pt_write(struct file *file, const char __user *buffer, size_t co
        i = count - bytes_copied;
        if (i) {
                pt->prepend_size = i;
-               copy_from_user(pt->buf, buffer + bytes_copied, i);
+               if (copy_from_user(pt->buf, buffer + bytes_copied, i))
+                       return -EFAULT;
                bytes_copied += i;
                DPD(3, "filling prepend buffer with %d bytes", i);
        }
index d5146790f5e3e678dc9a463aeb96b0f6948efe05..24110d63b136803e1d9ac9a2942b213e068a066e 100644 (file)
@@ -1007,7 +1007,7 @@ static int dsp_write(const char __user *buf, size_t len)
 
 static ssize_t dev_read(struct file *file, char __user *buf, size_t count, loff_t *off)
 {
-       int minor = iminor(file->f_dentry->d_inode);
+       int minor = iminor(file->f_path.dentry->d_inode);
        if (minor == dev.dsp_minor)
                return dsp_read(buf, count);
        else
@@ -1016,7 +1016,7 @@ static ssize_t dev_read(struct file *file, char __user *buf, size_t count, loff_
 
 static ssize_t dev_write(struct file *file, const char __user *buf, size_t count, loff_t *off)
 {
-       int minor = iminor(file->f_dentry->d_inode);
+       int minor = iminor(file->f_path.dentry->d_inode);
        if (minor == dev.dsp_minor)
                return dsp_write(buf, count);
        else
index 8fb8e7f995563993660243d2befd3502ca407b94..a89108cb74eae7c18ae772163dca1ac93161aaa0 100644 (file)
@@ -141,7 +141,7 @@ static int get_mixer_levels(void __user * arg)
 
 static ssize_t sound_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 {
-       int dev = iminor(file->f_dentry->d_inode);
+       int dev = iminor(file->f_path.dentry->d_inode);
        int ret = -EINVAL;
 
        /*
@@ -174,7 +174,7 @@ static ssize_t sound_read(struct file *file, char __user *buf, size_t count, lof
 
 static ssize_t sound_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 {
-       int dev = iminor(file->f_dentry->d_inode);
+       int dev = iminor(file->f_path.dentry->d_inode);
        int ret = -EINVAL;
        
        lock_kernel();
@@ -393,7 +393,7 @@ static int sound_ioctl(struct inode *inode, struct file *file,
 
 static unsigned int sound_poll(struct file *file, poll_table * wait)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int dev = iminor(inode);
 
        DEB(printk("sound_poll(dev=%d)\n", dev));
@@ -418,7 +418,7 @@ static int sound_mmap(struct file *file, struct vm_area_struct *vma)
        int dev_class;
        unsigned long size;
        struct dma_buffparms *dmap = NULL;
-       int dev = iminor(file->f_dentry->d_inode);
+       int dev = iminor(file->f_path.dentry->d_inode);
 
        dev_class = dev & 0x0f;
        dev >>= 4;
index 17837d4b5ed311effabe0b548fae61660a1fd1fa..c96cc8c68b3bec1135aefc7fd7e6c370c540121d 100644 (file)
@@ -2120,8 +2120,8 @@ static struct page * via_mm_nopage (struct vm_area_struct * vma,
                return NOPAGE_SIGBUS; /* Disallow mremap */
        }
         if (!card) {
-               DPRINTK ("EXIT, returning NOPAGE_OOM\n");
-               return NOPAGE_OOM;      /* Nothing allocated */
+               DPRINTK ("EXIT, returning NOPAGE_SIGBUS\n");
+               return NOPAGE_SIGBUS;   /* Nothing allocated */
        }
 
        pgoff = vma->vm_pgoff + ((address - vma->vm_start) >> PAGE_SHIFT);
index 3a181d4c0dc6d3764f7da6ffdc878bb2023fe440..3304344713ae1107e56a0af15485a960a3218ff7 100644 (file)
@@ -19,7 +19,7 @@ static int do_mod_firmware_load(const char *fn, char **fp)
                printk(KERN_INFO "Unable to load '%s'.\n", fn);
                return 0;
        }
-       l = filp->f_dentry->d_inode->i_size;
+       l = filp->f_path.dentry->d_inode->i_size;
        if (l <= 0 || l > 131072)
        {
                printk(KERN_INFO "Invalid firmware '%s'\n", fn);
index 4b52d18dcd539199050bb033e4d4e7ba2e40c736..b76b3dd9df25d48d878548238f040018c443b075 100644 (file)
@@ -48,7 +48,7 @@ static struct page * snd_us428ctls_vm_nopage(struct vm_area_struct *area, unsign
        
        offset = area->vm_pgoff << PAGE_SHIFT;
        offset += address - area->vm_start;
-       snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM);
+       snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_SIGBUS);
        vaddr = (char*)((struct usX2Ydev *)area->vm_private_data)->us428ctls_sharedmem + offset;
        page = virt_to_page(vaddr);
        get_page(page);